mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #293, support rtmp remux to http flv live stream.
This commit is contained in:
parent
53d9faf395
commit
3b853a6dbd
5 changed files with 53 additions and 9 deletions
|
@ -476,7 +476,10 @@ Supported operating systems and hardware:
|
|||
[#179](https://github.com/winlinvip/simple-rtmp-server/issues/179) and
|
||||
[274](https://github.com/winlinvip/simple-rtmp-server/issues/274).
|
||||
1. Support rtmp remux to http flv live stream, read
|
||||
[#293](https://github.com/winlinvip/simple-rtmp-server/issues/293).
|
||||
[#293](https://github.com/winlinvip/simple-rtmp-server/issues/293)(
|
||||
[CN](https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_DeliveryHttpFlvStream),
|
||||
[EN](https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_DeliveryHttpFlvStream)
|
||||
).
|
||||
1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech).
|
||||
1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/winlinvip/simple-rtmp-server/issues/92).
|
||||
1. [no-plan] Support multiple processes, for both origin and edge
|
||||
|
|
|
@ -402,6 +402,7 @@ int SrsGoHttpFileServer::copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, Sr
|
|||
|
||||
SrsGoHttpMuxEntry::SrsGoHttpMuxEntry()
|
||||
{
|
||||
enabled = true;
|
||||
explicit_match = false;
|
||||
handler = NULL;
|
||||
}
|
||||
|
@ -572,6 +573,10 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph)
|
|||
std::string pattern = it->first;
|
||||
SrsGoHttpMuxEntry* entry = it->second;
|
||||
|
||||
if (!entry->enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!path_match(pattern, path)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -230,6 +230,7 @@ public:
|
|||
bool explicit_match;
|
||||
ISrsGoHttpHandler* handler;
|
||||
std::string pattern;
|
||||
bool enabled;
|
||||
public:
|
||||
SrsGoHttpMuxEntry();
|
||||
virtual ~SrsGoHttpMuxEntry();
|
||||
|
|
|
@ -282,12 +282,22 @@ int SrsLiveStream::send_messages(SrsFlvEncoder* enc, SrsSharedPtrMessage** msgs,
|
|||
return ret;
|
||||
}
|
||||
|
||||
SrsLiveEntry::SrsLiveEntry()
|
||||
{
|
||||
stream = NULL;
|
||||
}
|
||||
|
||||
SrsHttpServer::SrsHttpServer()
|
||||
{
|
||||
}
|
||||
|
||||
SrsHttpServer::~SrsHttpServer()
|
||||
{
|
||||
std::map<std::string, SrsLiveEntry*>::iterator it;
|
||||
for (it = flvs.begin(); it != flvs.end(); ++it) {
|
||||
SrsLiveEntry* entry = it->second;
|
||||
srs_freep(entry);
|
||||
}
|
||||
flvs.clear();
|
||||
}
|
||||
|
||||
|
@ -318,7 +328,15 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r)
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::string mount = flvs[r->vhost];
|
||||
SrsLiveEntry* entry = flvs[r->vhost];
|
||||
|
||||
// TODO: FIXME: supports reload.
|
||||
if (entry->stream) {
|
||||
entry->stream->entry->enabled = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string mount = entry->mount;
|
||||
|
||||
// replace the vhost variable
|
||||
mount = srs_string_replace(mount, "[vhost]", r->vhost);
|
||||
|
@ -328,8 +346,10 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r)
|
|||
// remove the default vhost mount
|
||||
mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/");
|
||||
|
||||
entry->stream = new SrsLiveStream(s, r);
|
||||
|
||||
// mount the http flv stream.
|
||||
if ((ret = mux.handle(mount, new SrsLiveStream(s, r))) != ERROR_SUCCESS) {
|
||||
if ((ret = mux.handle(mount, entry->stream)) != ERROR_SUCCESS) {
|
||||
srs_error("http: mount flv stream for vhost=%s failed. ret=%d", r->vhost.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -345,7 +365,8 @@ void SrsHttpServer::unmount(SrsSource* s, SrsRequest* r)
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: FIXME: implements it.
|
||||
SrsLiveEntry* entry = flvs[r->vhost];
|
||||
entry->stream->entry->enabled = false;
|
||||
}
|
||||
|
||||
int SrsHttpServer::on_reload_vhost_http_updated()
|
||||
|
@ -440,10 +461,12 @@ int SrsHttpServer::mount_flv_streaming()
|
|||
continue;
|
||||
}
|
||||
|
||||
std::string mount = _srs_config->get_vhost_http_flv_mount(vhost);
|
||||
flvs[vhost] = mount;
|
||||
SrsLiveEntry* entry = new SrsLiveEntry();
|
||||
entry->vhost = vhost;
|
||||
entry->mount = _srs_config->get_vhost_http_flv_mount(vhost);
|
||||
flvs[vhost] = entry;
|
||||
srs_trace("http flv live stream, vhost=%s, mount=%s",
|
||||
vhost.c_str(), mount.c_str());
|
||||
vhost.c_str(), entry->mount.c_str());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -100,6 +100,18 @@ private:
|
|||
virtual int send_messages(SrsFlvEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs);
|
||||
};
|
||||
|
||||
/**
|
||||
* the srs live entry
|
||||
*/
|
||||
struct SrsLiveEntry
|
||||
{
|
||||
std::string vhost;
|
||||
std::string mount;
|
||||
SrsLiveStream* stream;
|
||||
|
||||
SrsLiveEntry();
|
||||
};
|
||||
|
||||
/**
|
||||
* the http server instance,
|
||||
* serve http static file, flv vod stream and flv live stream.
|
||||
|
@ -109,7 +121,7 @@ class SrsHttpServer : public ISrsReloadHandler
|
|||
public:
|
||||
SrsGoHttpServeMux mux;
|
||||
// the flv live streaming template.
|
||||
std::map<std::string, std::string> flvs;
|
||||
std::map<std::string, SrsLiveEntry*> flvs;
|
||||
public:
|
||||
SrsHttpServer();
|
||||
virtual ~SrsHttpServer();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue