mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163.
This commit is contained in:
parent
0f7cafe50b
commit
44bc7976ac
17 changed files with 317 additions and 270 deletions
|
@ -562,6 +562,7 @@ Supported operating systems and hardware:
|
||||||
|
|
||||||
### SRS 2.0 history
|
### SRS 2.0 history
|
||||||
|
|
||||||
|
* v2.0, 2015-05-19, merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163.
|
||||||
* v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS.
|
* v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS.
|
||||||
* v2.0, 2015-04-20, support ingest hls live stream to RTMP.
|
* v2.0, 2015-04-20, support ingest hls live stream to RTMP.
|
||||||
* v2.0, 2015-04-15, for [#383](https://github.com/simple-rtmp-server/srs/issues/383), support mix_correct algorithm. 2.0.161.
|
* v2.0, 2015-04-15, for [#383](https://github.com/simple-rtmp-server/srs/issues/383), support mix_correct algorithm. 2.0.161.
|
||||||
|
|
|
@ -514,12 +514,12 @@
|
||||||
3C12324B1AAE81CE00CE8F6C /* app */ = {
|
3C12324B1AAE81CE00CE8F6C /* app */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */,
|
|
||||||
3C28EDDE1AF5C43F00A3AEAC /* srs_app_caster_flv.hpp */,
|
|
||||||
3CD88B3D1ACA9C58000359E0 /* srs_app_async_call.cpp */,
|
3CD88B3D1ACA9C58000359E0 /* srs_app_async_call.cpp */,
|
||||||
3CD88B3E1ACA9C58000359E0 /* srs_app_async_call.hpp */,
|
3CD88B3E1ACA9C58000359E0 /* srs_app_async_call.hpp */,
|
||||||
3C12324C1AAE81D900CE8F6C /* srs_app_bandwidth.cpp */,
|
3C12324C1AAE81D900CE8F6C /* srs_app_bandwidth.cpp */,
|
||||||
3C12324D1AAE81D900CE8F6C /* srs_app_bandwidth.hpp */,
|
3C12324D1AAE81D900CE8F6C /* srs_app_bandwidth.hpp */,
|
||||||
|
3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */,
|
||||||
|
3C28EDDE1AF5C43F00A3AEAC /* srs_app_caster_flv.hpp */,
|
||||||
3C12324E1AAE81D900CE8F6C /* srs_app_config.cpp */,
|
3C12324E1AAE81D900CE8F6C /* srs_app_config.cpp */,
|
||||||
3C12324F1AAE81D900CE8F6C /* srs_app_config.hpp */,
|
3C12324F1AAE81D900CE8F6C /* srs_app_config.hpp */,
|
||||||
3C1232501AAE81D900CE8F6C /* srs_app_conn.cpp */,
|
3C1232501AAE81D900CE8F6C /* srs_app_conn.cpp */,
|
||||||
|
@ -536,10 +536,10 @@
|
||||||
3C12325B1AAE81D900CE8F6C /* srs_app_ffmpeg.hpp */,
|
3C12325B1AAE81D900CE8F6C /* srs_app_ffmpeg.hpp */,
|
||||||
3C12325C1AAE81D900CE8F6C /* srs_app_forward.cpp */,
|
3C12325C1AAE81D900CE8F6C /* srs_app_forward.cpp */,
|
||||||
3C12325D1AAE81D900CE8F6C /* srs_app_forward.hpp */,
|
3C12325D1AAE81D900CE8F6C /* srs_app_forward.hpp */,
|
||||||
3C12325E1AAE81D900CE8F6C /* srs_app_heartbeat.cpp */,
|
|
||||||
3C12325F1AAE81D900CE8F6C /* srs_app_heartbeat.hpp */,
|
|
||||||
3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */,
|
3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */,
|
||||||
3C1EE6AD1AB1055800576EE9 /* srs_app_hds.hpp */,
|
3C1EE6AD1AB1055800576EE9 /* srs_app_hds.hpp */,
|
||||||
|
3C12325E1AAE81D900CE8F6C /* srs_app_heartbeat.cpp */,
|
||||||
|
3C12325F1AAE81D900CE8F6C /* srs_app_heartbeat.hpp */,
|
||||||
3C1232601AAE81D900CE8F6C /* srs_app_hls.cpp */,
|
3C1232601AAE81D900CE8F6C /* srs_app_hls.cpp */,
|
||||||
3C1232611AAE81D900CE8F6C /* srs_app_hls.hpp */,
|
3C1232611AAE81D900CE8F6C /* srs_app_hls.hpp */,
|
||||||
3C1232621AAE81D900CE8F6C /* srs_app_http_api.cpp */,
|
3C1232621AAE81D900CE8F6C /* srs_app_http_api.cpp */,
|
||||||
|
|
|
@ -441,10 +441,22 @@ int SrsConfig::reload_conf(SrsConfig* conf)
|
||||||
// daemon
|
// daemon
|
||||||
//
|
//
|
||||||
// always support reload without additional code:
|
// always support reload without additional code:
|
||||||
// chunk_size, ff_log_dir, max_connections,
|
// chunk_size, ff_log_dir,
|
||||||
// bandcheck, http_hooks, heartbeat,
|
// bandcheck, http_hooks, heartbeat,
|
||||||
// token_traverse, debug_srs_upnode,
|
// token_traverse, debug_srs_upnode,
|
||||||
// security
|
// security
|
||||||
|
|
||||||
|
// merge config: max_connections
|
||||||
|
if (!srs_directive_equals(root->get("max_connections"), old_root->get("max_connections"))) {
|
||||||
|
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||||
|
ISrsReloadHandler* subscribe = *it;
|
||||||
|
if ((ret = subscribe->on_reload_max_conns()) != ERROR_SUCCESS) {
|
||||||
|
srs_error("notify subscribes reload max_connections failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
srs_trace("reload max_connections success.");
|
||||||
|
}
|
||||||
|
|
||||||
// merge config: listen
|
// merge config: listen
|
||||||
if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) {
|
if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) {
|
||||||
|
|
|
@ -40,6 +40,11 @@ int ISrsReloadHandler::on_reload_listen()
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ISrsReloadHandler::on_reload_max_conns()
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int ISrsReloadHandler::on_reload_pid()
|
int ISrsReloadHandler::on_reload_pid()
|
||||||
{
|
{
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
ISrsReloadHandler();
|
ISrsReloadHandler();
|
||||||
virtual ~ISrsReloadHandler();
|
virtual ~ISrsReloadHandler();
|
||||||
public:
|
public:
|
||||||
|
virtual int on_reload_max_conns();
|
||||||
virtual int on_reload_listen();
|
virtual int on_reload_listen();
|
||||||
virtual int on_reload_pid();
|
virtual int on_reload_pid();
|
||||||
virtual int on_reload_log_tank();
|
virtual int on_reload_log_tank();
|
||||||
|
@ -55,6 +56,7 @@ public:
|
||||||
virtual int on_reload_http_stream_enabled();
|
virtual int on_reload_http_stream_enabled();
|
||||||
virtual int on_reload_http_stream_disabled();
|
virtual int on_reload_http_stream_disabled();
|
||||||
virtual int on_reload_http_stream_updated();
|
virtual int on_reload_http_stream_updated();
|
||||||
|
public:
|
||||||
virtual int on_reload_vhost_http_updated();
|
virtual int on_reload_vhost_http_updated();
|
||||||
virtual int on_reload_vhost_http_remux_updated();
|
virtual int on_reload_vhost_http_remux_updated();
|
||||||
virtual int on_reload_vhost_added(std::string vhost);
|
virtual int on_reload_vhost_added(std::string vhost);
|
||||||
|
|
|
@ -1068,24 +1068,24 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pause or other msg.
|
// pause
|
||||||
SrsPausePacket* pause = dynamic_cast<SrsPausePacket*>(pkt);
|
SrsPausePacket* pause = dynamic_cast<SrsPausePacket*>(pkt);
|
||||||
if (!pause) {
|
if (pause) {
|
||||||
srs_info("ignore all amf0/amf3 command except pause.");
|
if ((ret = rtmp->on_play_client_pause(res->stream_id, pause->is_pause)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("rtmp process play client pause failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ret = consumer->on_play_client_pause(pause->is_pause)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("consumer process play client pause failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
srs_info("process pause success, is_pause=%d, time=%d.", pause->is_pause, pause->time_ms);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = rtmp->on_play_client_pause(res->stream_id, pause->is_pause)) != ERROR_SUCCESS) {
|
// other msg.
|
||||||
srs_error("rtmp process play client pause failed. ret=%d", ret);
|
srs_info("ignore all amf0/amf3 command except pause and video control.");
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = consumer->on_play_client_pause(pause->is_pause)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("consumer process play client pause failed. ret=%d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
srs_info("process pause success, is_pause=%d, time=%d.", pause->is_pause, pause->time_ms);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,23 +113,23 @@ std::string srs_listener_type2string(SrsListenerType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
|
SrsListener::SrsListener(SrsServer* svr, SrsListenerType t)
|
||||||
{
|
{
|
||||||
_port = 0;
|
port = 0;
|
||||||
_server = server;
|
server = svr;
|
||||||
_type = type;
|
type = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsListener::~SrsListener()
|
SrsListener::~SrsListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsListenerType SrsListener::type()
|
SrsListenerType SrsListener::listen_type()
|
||||||
{
|
{
|
||||||
return _type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStreamListener::SrsStreamListener(SrsServer* server, SrsListenerType type) : SrsListener(server, type)
|
SrsStreamListener::SrsStreamListener(SrsServer* svr, SrsListenerType t) : SrsListener(svr, t)
|
||||||
{
|
{
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
}
|
}
|
||||||
|
@ -139,12 +139,12 @@ SrsStreamListener::~SrsStreamListener()
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsStreamListener::listen(string ip, int port)
|
int SrsStreamListener::listen(string i, int p)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
_ip = ip;
|
ip = i;
|
||||||
_port = port;
|
port = p;
|
||||||
|
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
listener = new SrsTcpListener(this, ip, port);
|
listener = new SrsTcpListener(this, ip, port);
|
||||||
|
@ -158,7 +158,7 @@ int SrsStreamListener::listen(string ip, int port)
|
||||||
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
||||||
pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port);
|
pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port);
|
||||||
|
|
||||||
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd());
|
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ int SrsStreamListener::on_tcp_client(st_netfd_t stfd)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
if ((ret = _server->accept_client(_type, stfd)) != ERROR_SUCCESS) {
|
if ((ret = server->accept_client(type, stfd)) != ERROR_SUCCESS) {
|
||||||
srs_warn("accept client error. ret=%d", ret);
|
srs_warn("accept client error. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -176,14 +176,14 @@ int SrsStreamListener::on_tcp_client(st_netfd_t stfd)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SRS_AUTO_STREAM_CASTER
|
#ifdef SRS_AUTO_STREAM_CASTER
|
||||||
SrsRtspListener::SrsRtspListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type)
|
SrsRtspListener::SrsRtspListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsListener(svr, t)
|
||||||
{
|
{
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
|
|
||||||
// the caller already ensure the type is ok,
|
// the caller already ensure the type is ok,
|
||||||
// we just assert here for unknown stream caster.
|
// we just assert here for unknown stream caster.
|
||||||
srs_assert(_type == SrsListenerRtsp);
|
srs_assert(type == SrsListenerRtsp);
|
||||||
if (_type == SrsListenerRtsp) {
|
if (type == SrsListenerRtsp) {
|
||||||
caster = new SrsRtspCaster(c);
|
caster = new SrsRtspCaster(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,16 +194,16 @@ SrsRtspListener::~SrsRtspListener()
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsRtspListener::listen(string ip, int port)
|
int SrsRtspListener::listen(string i, int p)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
// the caller already ensure the type is ok,
|
// the caller already ensure the type is ok,
|
||||||
// we just assert here for unknown stream caster.
|
// we just assert here for unknown stream caster.
|
||||||
srs_assert(_type == SrsListenerRtsp);
|
srs_assert(type == SrsListenerRtsp);
|
||||||
|
|
||||||
_ip = ip;
|
ip = i;
|
||||||
_port = port;
|
port = p;
|
||||||
|
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
listener = new SrsTcpListener(this, ip, port);
|
listener = new SrsTcpListener(this, ip, port);
|
||||||
|
@ -215,9 +215,9 @@ int SrsRtspListener::listen(string ip, int port)
|
||||||
|
|
||||||
srs_info("listen thread cid=%d, current_cid=%d, "
|
srs_info("listen thread cid=%d, current_cid=%d, "
|
||||||
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
||||||
pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port);
|
pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port);
|
||||||
|
|
||||||
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd());
|
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -234,14 +234,14 @@ int SrsRtspListener::on_tcp_client(st_netfd_t stfd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type)
|
SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsListener(svr, t)
|
||||||
{
|
{
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
|
|
||||||
// the caller already ensure the type is ok,
|
// the caller already ensure the type is ok,
|
||||||
// we just assert here for unknown stream caster.
|
// we just assert here for unknown stream caster.
|
||||||
srs_assert(_type == SrsListenerFlv);
|
srs_assert(type == SrsListenerFlv);
|
||||||
if (_type == SrsListenerFlv) {
|
if (type == SrsListenerFlv) {
|
||||||
caster = new SrsAppCasterFlv(c);
|
caster = new SrsAppCasterFlv(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,16 +252,16 @@ SrsHttpFlvListener::~SrsHttpFlvListener()
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsHttpFlvListener::listen(string ip, int port)
|
int SrsHttpFlvListener::listen(string i, int p)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
// the caller already ensure the type is ok,
|
// the caller already ensure the type is ok,
|
||||||
// we just assert here for unknown stream caster.
|
// we just assert here for unknown stream caster.
|
||||||
srs_assert(_type == SrsListenerFlv);
|
srs_assert(type == SrsListenerFlv);
|
||||||
|
|
||||||
_ip = ip;
|
ip = i;
|
||||||
_port = port;
|
port = p;
|
||||||
|
|
||||||
if ((ret = caster->initialize()) != ERROR_SUCCESS) {
|
if ((ret = caster->initialize()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -277,9 +277,9 @@ int SrsHttpFlvListener::listen(string ip, int port)
|
||||||
|
|
||||||
srs_info("listen thread cid=%d, current_cid=%d, "
|
srs_info("listen thread cid=%d, current_cid=%d, "
|
||||||
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
||||||
pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port);
|
pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port);
|
||||||
|
|
||||||
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd());
|
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -295,36 +295,29 @@ int SrsHttpFlvListener::on_tcp_client(st_netfd_t stfd)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type)
|
SrsUdpStreamListener::SrsUdpStreamListener(SrsServer* svr, SrsListenerType t, ISrsUdpHandler* c) : SrsListener(svr, t)
|
||||||
{
|
{
|
||||||
_type = type;
|
|
||||||
listener = NULL;
|
listener = NULL;
|
||||||
|
caster = c;
|
||||||
// the caller already ensure the type is ok,
|
|
||||||
// we just assert here for unknown stream caster.
|
|
||||||
srs_assert(_type == SrsListenerMpegTsOverUdp);
|
|
||||||
if (_type == SrsListenerMpegTsOverUdp) {
|
|
||||||
caster = new SrsMpegtsOverUdp(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsUdpCasterListener::~SrsUdpCasterListener()
|
SrsUdpStreamListener::~SrsUdpStreamListener()
|
||||||
{
|
{
|
||||||
srs_freep(caster);
|
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsUdpCasterListener::listen(string ip, int port)
|
int SrsUdpStreamListener::listen(string i, int p)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
// the caller already ensure the type is ok,
|
// the caller already ensure the type is ok,
|
||||||
// we just assert here for unknown stream caster.
|
// we just assert here for unknown stream caster.
|
||||||
srs_assert(_type == SrsListenerMpegTsOverUdp);
|
srs_assert(type == SrsListenerMpegTsOverUdp);
|
||||||
|
|
||||||
_ip = ip;
|
ip = i;
|
||||||
_port = port;
|
port = p;
|
||||||
|
|
||||||
srs_freep(listener);
|
srs_freep(listener);
|
||||||
listener = new SrsUdpListener(caster, ip, port);
|
listener = new SrsUdpListener(caster, ip, port);
|
||||||
|
@ -336,12 +329,28 @@ int SrsUdpCasterListener::listen(string ip, int port)
|
||||||
|
|
||||||
srs_info("listen thread cid=%d, current_cid=%d, "
|
srs_info("listen thread cid=%d, current_cid=%d, "
|
||||||
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
||||||
pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port);
|
pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port);
|
||||||
|
|
||||||
srs_trace("%s listen at udp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd());
|
srs_trace("%s listen at udp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SRS_AUTO_STREAM_CASTER
|
||||||
|
SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsUdpStreamListener(svr, t, NULL)
|
||||||
|
{
|
||||||
|
// the caller already ensure the type is ok,
|
||||||
|
// we just assert here for unknown stream caster.
|
||||||
|
srs_assert(type == SrsListenerMpegTsOverUdp);
|
||||||
|
if (type == SrsListenerMpegTsOverUdp) {
|
||||||
|
caster = new SrsMpegtsOverUdp(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsUdpCasterListener::~SrsUdpCasterListener()
|
||||||
|
{
|
||||||
|
srs_freep(caster);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SrsSignalManager* SrsSignalManager::instance = NULL;
|
SrsSignalManager* SrsSignalManager::instance = NULL;
|
||||||
|
@ -588,6 +597,34 @@ int SrsServer::initialize(ISrsServerCycle* cycle_handler)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrsServer::initialize_st()
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
// init st
|
||||||
|
if ((ret = srs_init_st()) != ERROR_SUCCESS) {
|
||||||
|
srs_error("init st failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @remark, st alloc segment use mmap, which only support 32757 threads,
|
||||||
|
// if need to support more, for instance, 100k threads, define the macro MALLOC_STACK.
|
||||||
|
// TODO: FIXME: maybe can use "sysctl vm.max_map_count" to refine.
|
||||||
|
if (_srs_config->get_max_connections() > 32756) {
|
||||||
|
ret = ERROR_ST_EXCEED_THREADS;
|
||||||
|
srs_error("st mmap for stack allocation must <= %d threads, "
|
||||||
|
"@see Makefile of st for MALLOC_STACK, please build st manually by "
|
||||||
|
"\"make EXTRA_CFLAGS=-DMALLOC_STACK linux-debug\", ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set current log id.
|
||||||
|
_srs_context->generate_id();
|
||||||
|
srs_trace("server main cid=%d", _srs_context->get_id());
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int SrsServer::initialize_signal()
|
int SrsServer::initialize_signal()
|
||||||
{
|
{
|
||||||
return signal_manager->initialize();
|
return signal_manager->initialize();
|
||||||
|
@ -669,34 +706,6 @@ int SrsServer::acquire_pid_file()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsServer::initialize_st()
|
|
||||||
{
|
|
||||||
int ret = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
// init st
|
|
||||||
if ((ret = srs_init_st()) != ERROR_SUCCESS) {
|
|
||||||
srs_error("init st failed. ret=%d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @remark, st alloc segment use mmap, which only support 32757 threads,
|
|
||||||
// if need to support more, for instance, 100k threads, define the macro MALLOC_STACK.
|
|
||||||
// TODO: FIXME: maybe can use "sysctl vm.max_map_count" to refine.
|
|
||||||
if (_srs_config->get_max_connections() > 32756) {
|
|
||||||
ret = ERROR_ST_EXCEED_THREADS;
|
|
||||||
srs_error("st mmap for stack allocation must <= %d threads, "
|
|
||||||
"@see Makefile of st for MALLOC_STACK, please build st manually by "
|
|
||||||
"\"make EXTRA_CFLAGS=-DMALLOC_STACK linux-debug\", ret=%d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set current log id.
|
|
||||||
_srs_context->generate_id();
|
|
||||||
srs_trace("server main cid=%d", _srs_context->get_id());
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsServer::listen()
|
int SrsServer::listen()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
@ -959,6 +968,7 @@ int SrsServer::do_cycle()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
srs_info("server main thread loop");
|
srs_info("server main thread loop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1103,7 +1113,7 @@ void SrsServer::close_listeners(SrsListenerType type)
|
||||||
for (it = listeners.begin(); it != listeners.end();) {
|
for (it = listeners.begin(); it != listeners.end();) {
|
||||||
SrsListener* listener = *it;
|
SrsListener* listener = *it;
|
||||||
|
|
||||||
if (listener->type() != type) {
|
if (listener->listen_type() != type) {
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1264,7 +1274,7 @@ int SrsServer::on_reload_http_stream_enabled()
|
||||||
#ifdef SRS_AUTO_HTTP_SERVER
|
#ifdef SRS_AUTO_HTTP_SERVER
|
||||||
ret = listen_http_stream();
|
ret = listen_http_stream();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,17 +80,17 @@ enum SrsListenerType
|
||||||
class SrsListener
|
class SrsListener
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
SrsListenerType _type;
|
SrsListenerType type;
|
||||||
protected:
|
protected:
|
||||||
std::string _ip;
|
std::string ip;
|
||||||
int _port;
|
int port;
|
||||||
SrsServer* _server;
|
SrsServer* server;
|
||||||
public:
|
public:
|
||||||
SrsListener(SrsServer* server, SrsListenerType type);
|
SrsListener(SrsServer* svr, SrsListenerType t);
|
||||||
virtual ~SrsListener();
|
virtual ~SrsListener();
|
||||||
public:
|
public:
|
||||||
virtual SrsListenerType type();
|
virtual SrsListenerType listen_type();
|
||||||
virtual int listen(std::string ip, int port) = 0;
|
virtual int listen(std::string i, int p) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,10 +120,10 @@ private:
|
||||||
SrsTcpListener* listener;
|
SrsTcpListener* listener;
|
||||||
ISrsTcpHandler* caster;
|
ISrsTcpHandler* caster;
|
||||||
public:
|
public:
|
||||||
SrsRtspListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c);
|
SrsRtspListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c);
|
||||||
virtual ~SrsRtspListener();
|
virtual ~SrsRtspListener();
|
||||||
public:
|
public:
|
||||||
virtual int listen(std::string ip, int port);
|
virtual int listen(std::string i, int p);
|
||||||
// ISrsTcpHandler
|
// ISrsTcpHandler
|
||||||
public:
|
public:
|
||||||
virtual int on_tcp_client(st_netfd_t stfd);
|
virtual int on_tcp_client(st_netfd_t stfd);
|
||||||
|
@ -138,28 +138,40 @@ private:
|
||||||
SrsTcpListener* listener;
|
SrsTcpListener* listener;
|
||||||
SrsAppCasterFlv* caster;
|
SrsAppCasterFlv* caster;
|
||||||
public:
|
public:
|
||||||
SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c);
|
SrsHttpFlvListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c);
|
||||||
virtual ~SrsHttpFlvListener();
|
virtual ~SrsHttpFlvListener();
|
||||||
public:
|
public:
|
||||||
virtual int listen(std::string ip, int port);
|
virtual int listen(std::string i, int p);
|
||||||
// ISrsTcpHandler
|
// ISrsTcpHandler
|
||||||
public:
|
public:
|
||||||
virtual int on_tcp_client(st_netfd_t stfd);
|
virtual int on_tcp_client(st_netfd_t stfd);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the udp listener, for udp server.
|
* the udp listener, for udp server.
|
||||||
*/
|
*/
|
||||||
class SrsUdpCasterListener : public SrsListener
|
class SrsUdpStreamListener : public SrsListener
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
SrsUdpListener* listener;
|
SrsUdpListener* listener;
|
||||||
ISrsUdpHandler* caster;
|
ISrsUdpHandler* caster;
|
||||||
public:
|
public:
|
||||||
SrsUdpCasterListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c);
|
SrsUdpStreamListener(SrsServer* svr, SrsListenerType t, ISrsUdpHandler* c);
|
||||||
virtual ~SrsUdpCasterListener();
|
virtual ~SrsUdpStreamListener();
|
||||||
public:
|
public:
|
||||||
virtual int listen(std::string ip, int port);
|
virtual int listen(std::string i, int p);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the udp listener, for udp stream caster server.
|
||||||
|
*/
|
||||||
|
#ifdef SRS_AUTO_STREAM_CASTER
|
||||||
|
class SrsUdpCasterListener : public SrsUdpStreamListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SrsUdpCasterListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c);
|
||||||
|
virtual ~SrsUdpCasterListener();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -337,7 +349,7 @@ public:
|
||||||
* @param client_stfd, the client fd in st boxed, the underlayer fd.
|
* @param client_stfd, the client fd in st boxed, the underlayer fd.
|
||||||
*/
|
*/
|
||||||
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
virtual int accept_client(SrsListenerType type, st_netfd_t client_stfd);
|
||||||
// interface ISrsThreadHandler.
|
// interface ISrsReloadHandler.
|
||||||
public:
|
public:
|
||||||
virtual int on_reload_listen();
|
virtual int on_reload_listen();
|
||||||
virtual int on_reload_pid();
|
virtual int on_reload_pid();
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 2
|
#define VERSION_MAJOR 2
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 162
|
#define VERSION_REVISION 163
|
||||||
|
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
|
@ -723,8 +723,8 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg)
|
||||||
// because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS).
|
// because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS).
|
||||||
|
|
||||||
// about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58
|
// about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58
|
||||||
// PES_packet_data_byte "C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
|
// PES_packet_data_byte ¨C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
|
||||||
// indicated by the packets stream_id or PID. When the elementary stream data conforms to ITU-T
|
// indicated by the packet¡¯s stream_id or PID. When the elementary stream data conforms to ITU-T
|
||||||
// Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 13818-3, the PES_packet_data_bytes shall be byte aligned to the bytes of this
|
// Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 13818-3, the PES_packet_data_bytes shall be byte aligned to the bytes of this
|
||||||
// Recommendation | International Standard. The byte-order of the elementary stream shall be preserved. The number of
|
// Recommendation | International Standard. The byte-order of the elementary stream shall be preserved. The number of
|
||||||
// PES_packet_data_bytes, N, is specified by the PES_packet_length field. N shall be equal to the value indicated in the
|
// PES_packet_data_bytes, N, is specified by the PES_packet_length field. N shall be equal to the value indicated in the
|
||||||
|
@ -735,12 +735,12 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg)
|
||||||
// PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future.
|
// PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future.
|
||||||
|
|
||||||
// about the bytes of stream_id, define in hls-mpeg-ts-iso13818-1.pdf, page 49
|
// about the bytes of stream_id, define in hls-mpeg-ts-iso13818-1.pdf, page 49
|
||||||
// stream_id "C In Program Streams, the stream_id specifies the type and number of the elementary stream as defined by the
|
// stream_id ¨C In Program Streams, the stream_id specifies the type and number of the elementary stream as defined by the
|
||||||
// stream_id Table 2-18. In Transport Streams, the stream_id may be set to any valid value which correctly describes the
|
// stream_id Table 2-18. In Transport Streams, the stream_id may be set to any valid value which correctly describes the
|
||||||
// elementary stream type as defined in Table 2-18. In Transport Streams, the elementary stream type is specified in the
|
// elementary stream type as defined in Table 2-18. In Transport Streams, the elementary stream type is specified in the
|
||||||
// Program Specific Information as specified in 2.4.4.
|
// Program Specific Information as specified in 2.4.4.
|
||||||
|
|
||||||
// about the stream_id table, define in Table 2-18 "C Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52.
|
// about the stream_id table, define in Table 2-18 ¨C Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52.
|
||||||
//
|
//
|
||||||
// 110x xxxx
|
// 110x xxxx
|
||||||
// ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC
|
// ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC
|
||||||
|
|
|
@ -344,6 +344,10 @@ int run_master()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ret = _srs_server->initialize_signal()) != ERROR_SUCCESS) {
|
if ((ret = _srs_server->initialize_signal()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -352,10 +356,6 @@ int run_master()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = _srs_server->initialize_st()) != ERROR_SUCCESS) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = _srs_server->listen()) != ERROR_SUCCESS) {
|
if ((ret = _srs_server->listen()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,36 +38,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
|
||||||
* the signature for packets to client.
|
|
||||||
*/
|
|
||||||
#define RTMP_SIG_FMS_VER "3,5,3,888"
|
|
||||||
#define RTMP_SIG_AMF0_VER 0
|
|
||||||
#define RTMP_SIG_CLIENT_ID "ASAICiss"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* onStatus consts.
|
|
||||||
*/
|
|
||||||
#define StatusLevel "level"
|
|
||||||
#define StatusCode "code"
|
|
||||||
#define StatusDescription "description"
|
|
||||||
#define StatusDetails "details"
|
|
||||||
#define StatusClientId "clientid"
|
|
||||||
// status value
|
|
||||||
#define StatusLevelStatus "status"
|
|
||||||
// status error
|
|
||||||
#define StatusLevelError "error"
|
|
||||||
// code value
|
|
||||||
#define StatusCodeConnectSuccess "NetConnection.Connect.Success"
|
|
||||||
#define StatusCodeConnectRejected "NetConnection.Connect.Rejected"
|
|
||||||
#define StatusCodeStreamReset "NetStream.Play.Reset"
|
|
||||||
#define StatusCodeStreamStart "NetStream.Play.Start"
|
|
||||||
#define StatusCodeStreamPause "NetStream.Pause.Notify"
|
|
||||||
#define StatusCodeStreamUnpause "NetStream.Unpause.Notify"
|
|
||||||
#define StatusCodePublishStart "NetStream.Publish.Start"
|
|
||||||
#define StatusCodeDataStart "NetStream.Data.Start"
|
|
||||||
#define StatusCodeUnpublishSuccess "NetStream.Unpublish.Success"
|
|
||||||
|
|
||||||
// FMLE
|
// FMLE
|
||||||
#define RTMP_AMF0_COMMAND_ON_FC_PUBLISH "onFCPublish"
|
#define RTMP_AMF0_COMMAND_ON_FC_PUBLISH "onFCPublish"
|
||||||
#define RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH "onFCUnpublish"
|
#define RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH "onFCUnpublish"
|
||||||
|
|
|
@ -48,6 +48,36 @@ class SrsPacket;
|
||||||
class SrsAmf0Object;
|
class SrsAmf0Object;
|
||||||
class IMergeReadHandler;
|
class IMergeReadHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the signature for packets to client.
|
||||||
|
*/
|
||||||
|
#define RTMP_SIG_FMS_VER "3,5,3,888"
|
||||||
|
#define RTMP_SIG_AMF0_VER 0
|
||||||
|
#define RTMP_SIG_CLIENT_ID "ASAICiss"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onStatus consts.
|
||||||
|
*/
|
||||||
|
#define StatusLevel "level"
|
||||||
|
#define StatusCode "code"
|
||||||
|
#define StatusDescription "description"
|
||||||
|
#define StatusDetails "details"
|
||||||
|
#define StatusClientId "clientid"
|
||||||
|
// status value
|
||||||
|
#define StatusLevelStatus "status"
|
||||||
|
// status error
|
||||||
|
#define StatusLevelError "error"
|
||||||
|
// code value
|
||||||
|
#define StatusCodeConnectSuccess "NetConnection.Connect.Success"
|
||||||
|
#define StatusCodeConnectRejected "NetConnection.Connect.Rejected"
|
||||||
|
#define StatusCodeStreamReset "NetStream.Play.Reset"
|
||||||
|
#define StatusCodeStreamStart "NetStream.Play.Start"
|
||||||
|
#define StatusCodeStreamPause "NetStream.Pause.Notify"
|
||||||
|
#define StatusCodeStreamUnpause "NetStream.Unpause.Notify"
|
||||||
|
#define StatusCodePublishStart "NetStream.Publish.Start"
|
||||||
|
#define StatusCodeDataStart "NetStream.Data.Start"
|
||||||
|
#define StatusCodeUnpublishSuccess "NetStream.Unpublish.Success"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the original request from client.
|
* the original request from client.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,89 +43,6 @@ using namespace std;
|
||||||
// increase recv timeout to got an entire message.
|
// increase recv timeout to got an entire message.
|
||||||
#define SRS_MIN_RECV_TIMEOUT_US (int64_t)(60*1000*1000LL)
|
#define SRS_MIN_RECV_TIMEOUT_US (int64_t)(60*1000*1000LL)
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*****************************************************************************
|
|
||||||
****************************************************************************/
|
|
||||||
/**
|
|
||||||
5. Protocol Control Messages
|
|
||||||
RTMP reserves message type IDs 1-7 for protocol control messages.
|
|
||||||
These messages contain information needed by the RTM Chunk Stream
|
|
||||||
protocol or RTMP itself. Protocol messages with IDs 1 & 2 are
|
|
||||||
reserved for usage with RTM Chunk Stream protocol. Protocol messages
|
|
||||||
with IDs 3-6 are reserved for usage of RTMP. Protocol message with ID
|
|
||||||
7 is used between edge server and origin server.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_SetChunkSize 0x01
|
|
||||||
#define RTMP_MSG_AbortMessage 0x02
|
|
||||||
#define RTMP_MSG_Acknowledgement 0x03
|
|
||||||
#define RTMP_MSG_UserControlMessage 0x04
|
|
||||||
#define RTMP_MSG_WindowAcknowledgementSize 0x05
|
|
||||||
#define RTMP_MSG_SetPeerBandwidth 0x06
|
|
||||||
#define RTMP_MSG_EdgeAndOriginServerCommand 0x07
|
|
||||||
/**
|
|
||||||
3. Types of messages
|
|
||||||
The server and the client send messages over the network to
|
|
||||||
communicate with each other. The messages can be of any type which
|
|
||||||
includes audio messages, video messages, command messages, shared
|
|
||||||
object messages, data messages, and user control messages.
|
|
||||||
3.1. Command message
|
|
||||||
Command messages carry the AMF-encoded commands between the client
|
|
||||||
and the server. These messages have been assigned message type value
|
|
||||||
of 20 for AMF0 encoding and message type value of 17 for AMF3
|
|
||||||
encoding. These messages are sent to perform some operations like
|
|
||||||
connect, createStream, publish, play, pause on the peer. Command
|
|
||||||
messages like onstatus, result etc. are used to inform the sender
|
|
||||||
about the status of the requested commands. A command message
|
|
||||||
consists of command name, transaction ID, and command object that
|
|
||||||
contains related parameters. A client or a server can request Remote
|
|
||||||
Procedure Calls (RPC) over streams that are communicated using the
|
|
||||||
command messages to the peer.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_AMF3CommandMessage 17 // 0x11
|
|
||||||
#define RTMP_MSG_AMF0CommandMessage 20 // 0x14
|
|
||||||
/**
|
|
||||||
3.2. Data message
|
|
||||||
The client or the server sends this message to send Metadata or any
|
|
||||||
user data to the peer. Metadata includes details about the
|
|
||||||
data(audio, video etc.) like creation time, duration, theme and so
|
|
||||||
on. These messages have been assigned message type value of 18 for
|
|
||||||
AMF0 and message type value of 15 for AMF3.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_AMF0DataMessage 18 // 0x12
|
|
||||||
#define RTMP_MSG_AMF3DataMessage 15 // 0x0F
|
|
||||||
/**
|
|
||||||
3.3. Shared object message
|
|
||||||
A shared object is a Flash object (a collection of name value pairs)
|
|
||||||
that are in synchronization across multiple clients, instances, and
|
|
||||||
so on. The message types kMsgContainer=19 for AMF0 and
|
|
||||||
kMsgContainerEx=16 for AMF3 are reserved for shared object events.
|
|
||||||
Each message can contain multiple events.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_AMF3SharedObject 16 // 0x10
|
|
||||||
#define RTMP_MSG_AMF0SharedObject 19 // 0x13
|
|
||||||
/**
|
|
||||||
3.4. Audio message
|
|
||||||
The client or the server sends this message to send audio data to the
|
|
||||||
peer. The message type value of 8 is reserved for audio messages.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_AudioMessage 8 // 0x08
|
|
||||||
/* *
|
|
||||||
3.5. Video message
|
|
||||||
The client or the server sends this message to send video data to the
|
|
||||||
peer. The message type value of 9 is reserved for video messages.
|
|
||||||
These messages are large and can delay the sending of other type of
|
|
||||||
messages. To avoid such a situation, the video message is assigned
|
|
||||||
the lowest priority.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_VideoMessage 9 // 0x09
|
|
||||||
/**
|
|
||||||
3.6. Aggregate message
|
|
||||||
An aggregate message is a single message that contains a list of submessages.
|
|
||||||
The message type value of 22 is reserved for aggregate
|
|
||||||
messages.
|
|
||||||
*/
|
|
||||||
#define RTMP_MSG_AggregateMessage 22 // 0x16
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -172,24 +89,6 @@ messages.
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/**
|
|
||||||
* amf0 command message, command name macros
|
|
||||||
*/
|
|
||||||
#define RTMP_AMF0_COMMAND_CONNECT "connect"
|
|
||||||
#define RTMP_AMF0_COMMAND_CREATE_STREAM "createStream"
|
|
||||||
#define RTMP_AMF0_COMMAND_CLOSE_STREAM "closeStream"
|
|
||||||
#define RTMP_AMF0_COMMAND_PLAY "play"
|
|
||||||
#define RTMP_AMF0_COMMAND_PAUSE "pause"
|
|
||||||
#define RTMP_AMF0_COMMAND_ON_BW_DONE "onBWDone"
|
|
||||||
#define RTMP_AMF0_COMMAND_ON_STATUS "onStatus"
|
|
||||||
#define RTMP_AMF0_COMMAND_RESULT "_result"
|
|
||||||
#define RTMP_AMF0_COMMAND_ERROR "_error"
|
|
||||||
#define RTMP_AMF0_COMMAND_RELEASE_STREAM "releaseStream"
|
|
||||||
#define RTMP_AMF0_COMMAND_FC_PUBLISH "FCPublish"
|
|
||||||
#define RTMP_AMF0_COMMAND_UNPUBLISH "FCUnpublish"
|
|
||||||
#define RTMP_AMF0_COMMAND_PUBLISH "publish"
|
|
||||||
#define RTMP_AMF0_DATA_SAMPLE_ACCESS "|RtmpSampleAccess"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* band width check method name, which will be invoked by client.
|
* band width check method name, which will be invoked by client.
|
||||||
* band width check mothods use SrsBandwidthPacket as its internal packet type,
|
* band width check mothods use SrsBandwidthPacket as its internal packet type,
|
||||||
|
|
|
@ -56,6 +56,110 @@ class SrsChunkStream;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
class IMergeReadHandler;
|
class IMergeReadHandler;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
*****************************************************************************
|
||||||
|
****************************************************************************/
|
||||||
|
/**
|
||||||
|
5. Protocol Control Messages
|
||||||
|
RTMP reserves message type IDs 1-7 for protocol control messages.
|
||||||
|
These messages contain information needed by the RTM Chunk Stream
|
||||||
|
protocol or RTMP itself. Protocol messages with IDs 1 & 2 are
|
||||||
|
reserved for usage with RTM Chunk Stream protocol. Protocol messages
|
||||||
|
with IDs 3-6 are reserved for usage of RTMP. Protocol message with ID
|
||||||
|
7 is used between edge server and origin server.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_SetChunkSize 0x01
|
||||||
|
#define RTMP_MSG_AbortMessage 0x02
|
||||||
|
#define RTMP_MSG_Acknowledgement 0x03
|
||||||
|
#define RTMP_MSG_UserControlMessage 0x04
|
||||||
|
#define RTMP_MSG_WindowAcknowledgementSize 0x05
|
||||||
|
#define RTMP_MSG_SetPeerBandwidth 0x06
|
||||||
|
#define RTMP_MSG_EdgeAndOriginServerCommand 0x07
|
||||||
|
/**
|
||||||
|
3. Types of messages
|
||||||
|
The server and the client send messages over the network to
|
||||||
|
communicate with each other. The messages can be of any type which
|
||||||
|
includes audio messages, video messages, command messages, shared
|
||||||
|
object messages, data messages, and user control messages.
|
||||||
|
3.1. Command message
|
||||||
|
Command messages carry the AMF-encoded commands between the client
|
||||||
|
and the server. These messages have been assigned message type value
|
||||||
|
of 20 for AMF0 encoding and message type value of 17 for AMF3
|
||||||
|
encoding. These messages are sent to perform some operations like
|
||||||
|
connect, createStream, publish, play, pause on the peer. Command
|
||||||
|
messages like onstatus, result etc. are used to inform the sender
|
||||||
|
about the status of the requested commands. A command message
|
||||||
|
consists of command name, transaction ID, and command object that
|
||||||
|
contains related parameters. A client or a server can request Remote
|
||||||
|
Procedure Calls (RPC) over streams that are communicated using the
|
||||||
|
command messages to the peer.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_AMF3CommandMessage 17 // 0x11
|
||||||
|
#define RTMP_MSG_AMF0CommandMessage 20 // 0x14
|
||||||
|
/**
|
||||||
|
3.2. Data message
|
||||||
|
The client or the server sends this message to send Metadata or any
|
||||||
|
user data to the peer. Metadata includes details about the
|
||||||
|
data(audio, video etc.) like creation time, duration, theme and so
|
||||||
|
on. These messages have been assigned message type value of 18 for
|
||||||
|
AMF0 and message type value of 15 for AMF3.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_AMF0DataMessage 18 // 0x12
|
||||||
|
#define RTMP_MSG_AMF3DataMessage 15 // 0x0F
|
||||||
|
/**
|
||||||
|
3.3. Shared object message
|
||||||
|
A shared object is a Flash object (a collection of name value pairs)
|
||||||
|
that are in synchronization across multiple clients, instances, and
|
||||||
|
so on. The message types kMsgContainer=19 for AMF0 and
|
||||||
|
kMsgContainerEx=16 for AMF3 are reserved for shared object events.
|
||||||
|
Each message can contain multiple events.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_AMF3SharedObject 16 // 0x10
|
||||||
|
#define RTMP_MSG_AMF0SharedObject 19 // 0x13
|
||||||
|
/**
|
||||||
|
3.4. Audio message
|
||||||
|
The client or the server sends this message to send audio data to the
|
||||||
|
peer. The message type value of 8 is reserved for audio messages.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_AudioMessage 8 // 0x08
|
||||||
|
/* *
|
||||||
|
3.5. Video message
|
||||||
|
The client or the server sends this message to send video data to the
|
||||||
|
peer. The message type value of 9 is reserved for video messages.
|
||||||
|
These messages are large and can delay the sending of other type of
|
||||||
|
messages. To avoid such a situation, the video message is assigned
|
||||||
|
the lowest priority.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_VideoMessage 9 // 0x09
|
||||||
|
/**
|
||||||
|
3.6. Aggregate message
|
||||||
|
An aggregate message is a single message that contains a list of submessages.
|
||||||
|
The message type value of 22 is reserved for aggregate
|
||||||
|
messages.
|
||||||
|
*/
|
||||||
|
#define RTMP_MSG_AggregateMessage 22 // 0x16
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
*****************************************************************************
|
||||||
|
****************************************************************************/
|
||||||
|
/**
|
||||||
|
* amf0 command message, command name macros
|
||||||
|
*/
|
||||||
|
#define RTMP_AMF0_COMMAND_CONNECT "connect"
|
||||||
|
#define RTMP_AMF0_COMMAND_CREATE_STREAM "createStream"
|
||||||
|
#define RTMP_AMF0_COMMAND_CLOSE_STREAM "closeStream"
|
||||||
|
#define RTMP_AMF0_COMMAND_PLAY "play"
|
||||||
|
#define RTMP_AMF0_COMMAND_PAUSE "pause"
|
||||||
|
#define RTMP_AMF0_COMMAND_ON_BW_DONE "onBWDone"
|
||||||
|
#define RTMP_AMF0_COMMAND_ON_STATUS "onStatus"
|
||||||
|
#define RTMP_AMF0_COMMAND_RESULT "_result"
|
||||||
|
#define RTMP_AMF0_COMMAND_ERROR "_error"
|
||||||
|
#define RTMP_AMF0_COMMAND_RELEASE_STREAM "releaseStream"
|
||||||
|
#define RTMP_AMF0_COMMAND_FC_PUBLISH "FCPublish"
|
||||||
|
#define RTMP_AMF0_COMMAND_UNPUBLISH "FCUnpublish"
|
||||||
|
#define RTMP_AMF0_COMMAND_PUBLISH "publish"
|
||||||
|
#define RTMP_AMF0_DATA_SAMPLE_ACCESS "|RtmpSampleAccess"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
|
@ -78,22 +78,22 @@ void srs_vhost_resolve(string& vhost, string& app, string& param)
|
||||||
app = srs_string_replace(app, "&&", "?");
|
app = srs_string_replace(app, "&&", "?");
|
||||||
app = srs_string_replace(app, "=", "?");
|
app = srs_string_replace(app, "=", "?");
|
||||||
|
|
||||||
if ((pos = app.find("?")) == std::string::npos) {
|
if ((pos = app.find("?")) != std::string::npos) {
|
||||||
return;
|
std::string query = app.substr(pos + 1);
|
||||||
}
|
app = app.substr(0, pos);
|
||||||
|
|
||||||
std::string query = app.substr(pos + 1);
|
if ((pos = query.find("vhost?")) != std::string::npos) {
|
||||||
app = app.substr(0, pos);
|
query = query.substr(pos + 6);
|
||||||
|
if (!query.empty()) {
|
||||||
if ((pos = query.find("vhost?")) != std::string::npos) {
|
vhost = query;
|
||||||
query = query.substr(pos + 6);
|
}
|
||||||
if (!query.empty()) {
|
if ((pos = vhost.find("?")) != std::string::npos) {
|
||||||
vhost = query;
|
vhost = vhost.substr(0, pos);
|
||||||
}
|
}
|
||||||
if ((pos = vhost.find("?")) != std::string::npos) {
|
|
||||||
vhost = vhost.substr(0, pos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* others */
|
||||||
}
|
}
|
||||||
|
|
||||||
void srs_random_generate(char* bytes, int size)
|
void srs_random_generate(char* bytes, int size)
|
||||||
|
|
|
@ -63,7 +63,9 @@ extern void srs_discovery_tc_url(
|
||||||
* app...vhost...request_vhost
|
* app...vhost...request_vhost
|
||||||
* @param param, the query, for example, ?vhost=xxx
|
* @param param, the query, for example, ?vhost=xxx
|
||||||
*/
|
*/
|
||||||
extern void srs_vhost_resolve(std::string& vhost, std::string& app, std::string& param);
|
extern void srs_vhost_resolve(
|
||||||
|
std::string& vhost, std::string& app, std::string& param
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate ramdom data for handshake.
|
* generate ramdom data for handshake.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue