mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
support reload dvr
This commit is contained in:
parent
9861fc4fe3
commit
4b82a4f510
6 changed files with 54 additions and 0 deletions
|
@ -851,6 +851,17 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
|
|||
}
|
||||
srs_trace("vhost %s reload hls success.", vhost.c_str());
|
||||
}
|
||||
// dvr, only one per vhost
|
||||
if (!srs_directive_equals(new_vhost->get("dvr"), old_vhost->get("dvr"))) {
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
ISrsReloadHandler* subscribe = *it;
|
||||
if ((ret = subscribe->on_reload_vhost_dvr(vhost)) != ERROR_SUCCESS) {
|
||||
srs_error("vhost %s notify subscribes dvr failed. ret=%d", vhost.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
srs_trace("vhost %s reload hls success.", vhost.c_str());
|
||||
}
|
||||
// http, only one per vhost.
|
||||
if (!srs_directive_equals(new_vhost->get("http"), old_vhost->get("http"))) {
|
||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||
|
|
|
@ -364,6 +364,10 @@ int SrsDvr::on_meta_data(SrsOnMetaDataPacket* metadata)
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (!dvr_enabled) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
char* payload = NULL;
|
||||
if ((ret = metadata->encode(size, payload)) != ERROR_SUCCESS) {
|
||||
|
@ -382,6 +386,12 @@ int SrsDvr::on_audio(SrsSharedPtrMessage* audio)
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
SrsAutoFree(SrsSharedPtrMessage, audio, false);
|
||||
|
||||
if (!dvr_enabled) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t timestamp = audio->header.timestamp;
|
||||
char* payload = (char*)audio->payload;
|
||||
int size = (int)audio->size;
|
||||
|
@ -396,6 +406,12 @@ int SrsDvr::on_video(SrsSharedPtrMessage* video)
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
SrsAutoFree(SrsSharedPtrMessage, video, false);
|
||||
|
||||
if (!dvr_enabled) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t timestamp = video->header.timestamp;
|
||||
char* payload = (char*)video->payload;
|
||||
int size = (int)video->size;
|
||||
|
|
|
@ -130,6 +130,11 @@ int ISrsReloadHandler::on_reload_vhost_hls(string /*vhost*/)
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int ISrsReloadHandler::on_reload_vhost_dvr(string /*vhost*/)
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int ISrsReloadHandler::on_reload_vhost_transcode(string /*vhost*/)
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
virtual int on_reload_vhost_queue_length(std::string vhost);
|
||||
virtual int on_reload_vhost_forward(std::string vhost);
|
||||
virtual int on_reload_vhost_hls(std::string vhost);
|
||||
virtual int on_reload_vhost_dvr(std::string vhost);
|
||||
virtual int on_reload_vhost_transcode(std::string vhost);
|
||||
virtual int on_reload_ingest_removed(std::string vhost, std::string ingest_id);
|
||||
virtual int on_reload_ingest_added(std::string vhost, std::string ingest_id);
|
||||
|
|
|
@ -605,6 +605,26 @@ int SrsSource::on_reload_vhost_hls(string vhost)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::on_reload_vhost_dvr(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (req->vhost != vhost) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_DVR
|
||||
dvr->on_unpublish();
|
||||
if ((ret = dvr->on_publish(req)) != ERROR_SUCCESS) {
|
||||
srs_error("dvr publish failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_trace("vhost %s dvr reload success", vhost.c_str());
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::on_reload_vhost_transcode(string vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
|
|
@ -278,6 +278,7 @@ public:
|
|||
virtual int on_reload_vhost_queue_length(std::string vhost);
|
||||
virtual int on_reload_vhost_forward(std::string vhost);
|
||||
virtual int on_reload_vhost_hls(std::string vhost);
|
||||
virtual int on_reload_vhost_dvr(std::string vhost);
|
||||
virtual int on_reload_vhost_transcode(std::string vhost);
|
||||
public:
|
||||
// for the SrsForwarder to callback to request the sequence headers.
|
||||
|
|
Loading…
Reference in a new issue