mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine srs-librtmp, set the schema, rather that connect app3
This commit is contained in:
parent
4e96c443d8
commit
89a5fa69d1
5 changed files with 65 additions and 61 deletions
|
@ -549,22 +549,22 @@ fi
|
|||
#####################################################################################
|
||||
# cherrypy for http hooks callback, CherryPy-3.2.4
|
||||
#####################################################################################
|
||||
if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then
|
||||
echo "CherryPy-3.2.4 is ok.";
|
||||
else
|
||||
require_sudoer "install CherryPy-3.2.4"
|
||||
echo "Installing CherryPy-3.2.4";
|
||||
(
|
||||
sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} &&
|
||||
unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
|
||||
sudo python setup.py install
|
||||
)
|
||||
fi
|
||||
# check status
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "build CherryPy-3.2.4 failed, ret=$ret"; exit $ret; fi
|
||||
if [ ! -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi
|
||||
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then
|
||||
echo "CherryPy-3.2.4 is ok.";
|
||||
else
|
||||
require_sudoer "install CherryPy-3.2.4"
|
||||
echo "Installing CherryPy-3.2.4";
|
||||
(
|
||||
sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} &&
|
||||
unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
|
||||
sudo python setup.py install
|
||||
)
|
||||
fi
|
||||
# check status
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "build CherryPy-3.2.4 failed, ret=$ret"; exit $ret; fi
|
||||
if [ ! -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]; then echo "build CherryPy-3.2.4 failed."; exit -1; fi
|
||||
|
||||
echo "Link players to cherrypy static-dir"
|
||||
rm -rf research/api-server/static-dir/players &&
|
||||
ln -sf `pwd`/research/players research/api-server/static-dir/players &&
|
||||
|
|
|
@ -59,7 +59,7 @@ ret=$?; if [[ $ret -ne 0 ]]; then
|
|||
echo -e "${RED}failed to generate the srs_librtmp.cpp${BLACK}"
|
||||
exit $ret
|
||||
fi
|
||||
# module to cpp files.
|
||||
# module to hpp files.
|
||||
function build_module_hpp()
|
||||
{
|
||||
echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
|
||||
|
|
4
trunk/configure
vendored
4
trunk/configure
vendored
|
@ -154,9 +154,9 @@ MODULE_ID="KERNEL"
|
|||
MODULE_DEPENDS=("CORE")
|
||||
ModuleLibIncs=(${SRS_OBJS_DIR})
|
||||
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_buffer"
|
||||
"srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_file"
|
||||
"srs_kernel_utility" "srs_kernel_flv" "srs_kernel_codec" "srs_kernel_io"
|
||||
"srs_kernel_consts" "srs_kernel_aac" "srs_kernel_mp3" "srs_kernel_ts"
|
||||
"srs_kernel_stream" "srs_kernel_balance" "srs_kernel_mp4" "srs_kernel_io")
|
||||
"srs_kernel_stream" "srs_kernel_balance" "srs_kernel_mp4" "srs_kernel_file")
|
||||
KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
|
||||
KERNEL_OBJS="${MODULE_OBJS[@]}"
|
||||
#
|
||||
|
|
|
@ -72,6 +72,7 @@ struct Context
|
|||
std::string app;
|
||||
std::string stream;
|
||||
std::string param;
|
||||
srs_url_schema schema;
|
||||
|
||||
// extra request object for connect to server, NULL to ignore.
|
||||
SrsRequest* req;
|
||||
|
@ -122,6 +123,7 @@ struct Context
|
|||
h264_sps_changed = false;
|
||||
h264_pps_changed = false;
|
||||
rtimeout = stimeout = SRS_CONSTS_NO_TMMS;
|
||||
schema = srs_url_schema_forbidden;
|
||||
}
|
||||
virtual ~Context() {
|
||||
srs_freep(req);
|
||||
|
@ -741,11 +743,22 @@ int srs_rtmp_connect_app(srs_rtmp_t rtmp)
|
|||
|
||||
srs_assert(rtmp != NULL);
|
||||
Context* context = (Context*)rtmp;
|
||||
|
||||
string tcUrl = srs_generate_tc_url(
|
||||
context->ip, context->vhost, context->app, context->port,
|
||||
context->param
|
||||
);
|
||||
|
||||
string tcUrl;
|
||||
switch(context->schema) {
|
||||
case srs_url_schema_normal:
|
||||
tcUrl=srs_generate_normal_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
case srs_url_schema_via:
|
||||
tcUrl=srs_generate_via_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
case srs_url_schema_vis:
|
||||
case srs_url_schema_vis2:
|
||||
tcUrl=srs_generate_vis_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ret = context->rtmp->connect_app(
|
||||
context->app, tcUrl, context->req, true)) != ERROR_SUCCESS)
|
||||
|
@ -774,10 +787,21 @@ int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
|
|||
srs_assert(rtmp != NULL);
|
||||
Context* context = (Context*)rtmp;
|
||||
|
||||
string tcUrl = srs_generate_tc_url(
|
||||
context->ip, context->vhost, context->app, context->port,
|
||||
context->param
|
||||
);
|
||||
string tcUrl;
|
||||
switch(context->schema) {
|
||||
case srs_url_schema_normal:
|
||||
tcUrl=srs_generate_normal_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
case srs_url_schema_via:
|
||||
tcUrl=srs_generate_via_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
case srs_url_schema_vis:
|
||||
case srs_url_schema_vis2:
|
||||
tcUrl=srs_generate_vis_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
std::string sip, sserver, sprimary, sauthors, sversion;
|
||||
|
||||
|
@ -795,34 +819,14 @@ int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int srs_rtmp_connect_app3(srs_rtmp_t rtmp, enum srs_url_schema sus)
|
||||
int srs_rtmp_set_schema(srs_rtmp_t rtmp, enum srs_url_schema schema)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
srs_assert(rtmp != NULL);
|
||||
Context* context = (Context*)rtmp;
|
||||
|
||||
string tcUrl;
|
||||
switch(sus) {
|
||||
case srs_url_schema_normal:
|
||||
tcUrl=srs_generate_normal_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
case srs_url_schema_via:
|
||||
tcUrl=srs_generate_via_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
case srs_url_schema_vis:
|
||||
case srs_url_schema_vis2:
|
||||
tcUrl=srs_generate_vis_tc_url(context->ip, context->vhost, context->app, context->port);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ret = context->rtmp->connect_app(
|
||||
context->app, tcUrl, context->req, true)) != ERROR_SUCCESS)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
context->schema = schema;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -79,10 +79,13 @@ extern "C"{
|
|||
* srs_url_schema_vis : rtmp://ip:port/app/stream?vhost=xxx
|
||||
* srs_url_schema_vis2 : rtmp://ip:port/app/stream?domain=xxx
|
||||
*/
|
||||
enum srs_url_schema{
|
||||
enum srs_url_schema
|
||||
{
|
||||
// Forbidden.
|
||||
srs_url_schema_forbidden = 0,
|
||||
// Normal RTMP URL, the vhost put in host field, using DNS to resolve the server ip.
|
||||
// For example, rtmp://vhost:port/app/stream
|
||||
srs_url_schema_normal = 0,
|
||||
srs_url_schema_normal,
|
||||
// VIA(vhost in app), the vhost put in app field.
|
||||
// For example, rtmp://ip:port/vhost/app/stream
|
||||
srs_url_schema_via,
|
||||
|
@ -225,16 +228,13 @@ extern int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
|
|||
char srs_primary[128], char srs_authors[128],
|
||||
char srs_version[32], int* srs_id, int* srs_pid
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* connect to rtmp vhost/app
|
||||
* category: publish/play
|
||||
* previous: handshake
|
||||
* next: publish or play
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
*/
|
||||
extern int srs_rtmp_connect_app3(srs_rtmp_t rtmp, enum srs_url_schema sus);
|
||||
* Set the schema of URL when connect to server.
|
||||
* @param schema, The schema of URL, @see srs_url_schema.
|
||||
* @return 0, success; otherswise, failed.
|
||||
*/
|
||||
extern int srs_rtmp_set_schema(srs_rtmp_t rtmp, enum srs_url_schema schema);
|
||||
|
||||
/**
|
||||
* play a live/vod stream.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue