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,9 +549,10 @@ fi
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
# cherrypy for http hooks callback, CherryPy-3.2.4
|
# cherrypy for http hooks callback, CherryPy-3.2.4
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then
|
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.";
|
echo "CherryPy-3.2.4 is ok.";
|
||||||
else
|
else
|
||||||
require_sudoer "install CherryPy-3.2.4"
|
require_sudoer "install CherryPy-3.2.4"
|
||||||
echo "Installing CherryPy-3.2.4";
|
echo "Installing CherryPy-3.2.4";
|
||||||
(
|
(
|
||||||
|
@ -559,12 +560,11 @@ else
|
||||||
unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
|
unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 &&
|
||||||
sudo python setup.py install
|
sudo python setup.py install
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
# check status
|
# check status
|
||||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "build CherryPy-3.2.4 failed, ret=$ret"; exit $ret; fi
|
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 [ ! -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
|
|
||||||
echo "Link players to cherrypy static-dir"
|
echo "Link players to cherrypy static-dir"
|
||||||
rm -rf research/api-server/static-dir/players &&
|
rm -rf research/api-server/static-dir/players &&
|
||||||
ln -sf `pwd`/research/players 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}"
|
echo -e "${RED}failed to generate the srs_librtmp.cpp${BLACK}"
|
||||||
exit $ret
|
exit $ret
|
||||||
fi
|
fi
|
||||||
# module to cpp files.
|
# module to hpp files.
|
||||||
function build_module_hpp()
|
function build_module_hpp()
|
||||||
{
|
{
|
||||||
echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
|
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")
|
MODULE_DEPENDS=("CORE")
|
||||||
ModuleLibIncs=(${SRS_OBJS_DIR})
|
ModuleLibIncs=(${SRS_OBJS_DIR})
|
||||||
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_buffer"
|
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_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_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh
|
||||||
KERNEL_OBJS="${MODULE_OBJS[@]}"
|
KERNEL_OBJS="${MODULE_OBJS[@]}"
|
||||||
#
|
#
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct Context
|
||||||
std::string app;
|
std::string app;
|
||||||
std::string stream;
|
std::string stream;
|
||||||
std::string param;
|
std::string param;
|
||||||
|
srs_url_schema schema;
|
||||||
|
|
||||||
// extra request object for connect to server, NULL to ignore.
|
// extra request object for connect to server, NULL to ignore.
|
||||||
SrsRequest* req;
|
SrsRequest* req;
|
||||||
|
@ -122,6 +123,7 @@ struct Context
|
||||||
h264_sps_changed = false;
|
h264_sps_changed = false;
|
||||||
h264_pps_changed = false;
|
h264_pps_changed = false;
|
||||||
rtimeout = stimeout = SRS_CONSTS_NO_TMMS;
|
rtimeout = stimeout = SRS_CONSTS_NO_TMMS;
|
||||||
|
schema = srs_url_schema_forbidden;
|
||||||
}
|
}
|
||||||
virtual ~Context() {
|
virtual ~Context() {
|
||||||
srs_freep(req);
|
srs_freep(req);
|
||||||
|
@ -742,10 +744,21 @@ int srs_rtmp_connect_app(srs_rtmp_t rtmp)
|
||||||
srs_assert(rtmp != NULL);
|
srs_assert(rtmp != NULL);
|
||||||
Context* context = (Context*)rtmp;
|
Context* context = (Context*)rtmp;
|
||||||
|
|
||||||
string tcUrl = srs_generate_tc_url(
|
string tcUrl;
|
||||||
context->ip, context->vhost, context->app, context->port,
|
switch(context->schema) {
|
||||||
context->param
|
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(
|
if ((ret = context->rtmp->connect_app(
|
||||||
context->app, tcUrl, context->req, true)) != ERROR_SUCCESS)
|
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);
|
srs_assert(rtmp != NULL);
|
||||||
Context* context = (Context*)rtmp;
|
Context* context = (Context*)rtmp;
|
||||||
|
|
||||||
string tcUrl = srs_generate_tc_url(
|
string tcUrl;
|
||||||
context->ip, context->vhost, context->app, context->port,
|
switch(context->schema) {
|
||||||
context->param
|
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;
|
std::string sip, sserver, sprimary, sauthors, sversion;
|
||||||
|
|
||||||
|
@ -795,34 +819,14 @@ int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
|
||||||
return ret;
|
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;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
srs_assert(rtmp != NULL);
|
srs_assert(rtmp != NULL);
|
||||||
Context* context = (Context*)rtmp;
|
Context* context = (Context*)rtmp;
|
||||||
|
|
||||||
string tcUrl;
|
context->schema = schema;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,10 +79,13 @@ extern "C"{
|
||||||
* srs_url_schema_vis : rtmp://ip:port/app/stream?vhost=xxx
|
* srs_url_schema_vis : rtmp://ip:port/app/stream?vhost=xxx
|
||||||
* srs_url_schema_vis2 : rtmp://ip:port/app/stream?domain=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.
|
// Normal RTMP URL, the vhost put in host field, using DNS to resolve the server ip.
|
||||||
// For example, rtmp://vhost:port/app/stream
|
// 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.
|
// VIA(vhost in app), the vhost put in app field.
|
||||||
// For example, rtmp://ip:port/vhost/app/stream
|
// For example, rtmp://ip:port/vhost/app/stream
|
||||||
srs_url_schema_via,
|
srs_url_schema_via,
|
||||||
|
@ -227,14 +230,11 @@ extern int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* connect to rtmp vhost/app
|
* Set the schema of URL when connect to server.
|
||||||
* category: publish/play
|
* @param schema, The schema of URL, @see srs_url_schema.
|
||||||
* previous: handshake
|
* @return 0, success; otherswise, failed.
|
||||||
* next: publish or play
|
*/
|
||||||
*
|
extern int srs_rtmp_set_schema(srs_rtmp_t rtmp, enum srs_url_schema schema);
|
||||||
* @return 0, success; otherswise, failed.
|
|
||||||
*/
|
|
||||||
extern int srs_rtmp_connect_app3(srs_rtmp_t rtmp, enum srs_url_schema sus);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* play a live/vod stream.
|
* play a live/vod stream.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue