mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #299, refine the signature of api for hls/dash
This commit is contained in:
parent
711b58e0b2
commit
ede1c34a25
6 changed files with 54 additions and 32 deletions
|
@ -68,7 +68,7 @@ int SrsMpegDash::on_publish()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsMpegDash::on_audio(SrsSharedPtrMessage* shared_audio)
|
int SrsMpegDash::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ int SrsMpegDash::on_audio(SrsSharedPtrMessage* shared_audio)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsMpegDash::on_video(SrsSharedPtrMessage* shared_video, bool is_sequence_header)
|
int SrsMpegDash::on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
class SrsRequest;
|
class SrsRequest;
|
||||||
class SrsOriginHub;
|
class SrsOriginHub;
|
||||||
class SrsSharedPtrMessage;
|
class SrsSharedPtrMessage;
|
||||||
|
class SrsFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class SrsFragmentedMp4
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The MPEG-DASH encoder, transmux RTMP to DASH.
|
* The MPEG-DASH encoder, transmux RTMP to DASH.
|
||||||
|
@ -52,9 +60,9 @@ public:
|
||||||
// When stream start publishing.
|
// When stream start publishing.
|
||||||
virtual int on_publish();
|
virtual int on_publish();
|
||||||
// When got an shared audio message.
|
// When got an shared audio message.
|
||||||
virtual int on_audio(SrsSharedPtrMessage* shared_audio);
|
virtual int on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
|
||||||
// When got an shared video message.
|
// When got an shared video message.
|
||||||
virtual int on_video(SrsSharedPtrMessage* shared_video, bool is_sequence_header);
|
virtual int on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);
|
||||||
// When stream stop publishing.
|
// When stream stop publishing.
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1056,7 +1056,6 @@ SrsHls::SrsHls()
|
||||||
{
|
{
|
||||||
req = NULL;
|
req = NULL;
|
||||||
hub = NULL;
|
hub = NULL;
|
||||||
format = NULL;
|
|
||||||
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
disposable = false;
|
disposable = false;
|
||||||
|
@ -1119,13 +1118,12 @@ int SrsHls::cycle()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsHls::initialize(SrsOriginHub* h, SrsFormat* f, SrsRequest* r)
|
int SrsHls::initialize(SrsOriginHub* h, SrsRequest* r)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
hub = h;
|
hub = h;
|
||||||
req = r;
|
req = r;
|
||||||
format = f;
|
|
||||||
|
|
||||||
if ((ret = controller->initialize()) != ERROR_SUCCESS) {
|
if ((ret = controller->initialize()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -321,7 +321,6 @@ private:
|
||||||
int64_t last_update_time;
|
int64_t last_update_time;
|
||||||
private:
|
private:
|
||||||
SrsOriginHub* hub;
|
SrsOriginHub* hub;
|
||||||
SrsFormat* format;
|
|
||||||
SrsRtmpJitter* jitter;
|
SrsRtmpJitter* jitter;
|
||||||
SrsPithyPrint* pprint;
|
SrsPithyPrint* pprint;
|
||||||
/**
|
/**
|
||||||
|
@ -348,7 +347,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* initialize the hls by handler and source.
|
* initialize the hls by handler and source.
|
||||||
*/
|
*/
|
||||||
virtual int initialize(SrsOriginHub* h, SrsFormat* f, SrsRequest* r);
|
virtual int initialize(SrsOriginHub* h, SrsRequest* r);
|
||||||
/**
|
/**
|
||||||
* publish stream event, continue to write the m3u8,
|
* publish stream event, continue to write the m3u8,
|
||||||
* for the muxer object not destroyed.
|
* for the muxer object not destroyed.
|
||||||
|
|
|
@ -896,7 +896,7 @@ int SrsOriginHub::initialize(SrsSource* s, SrsRequest* r)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = hls->initialize(this, format, req)) != ERROR_SUCCESS) {
|
if ((ret = hls->initialize(this, req)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,7 +1018,7 @@ int SrsOriginHub::on_audio(SrsSharedPtrMessage* shared_audio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = dash->on_audio(msg)) != ERROR_SUCCESS) {
|
if ((ret = dash->on_audio(msg, format)) != ERROR_SUCCESS) {
|
||||||
srs_warn("DASH failed, ignore and disable it. ret=%d", ret);
|
srs_warn("DASH failed, ignore and disable it. ret=%d", ret);
|
||||||
dash->on_unpublish();
|
dash->on_unpublish();
|
||||||
ret = ERROR_SUCCESS;
|
ret = ERROR_SUCCESS;
|
||||||
|
@ -1120,7 +1120,7 @@ int SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_sequence_h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = dash->on_video(msg, is_sequence_header)) != ERROR_SUCCESS) {
|
if ((ret = dash->on_video(msg, format)) != ERROR_SUCCESS) {
|
||||||
srs_warn("DASH failed, ignore and disable it. ret=%d", ret);
|
srs_warn("DASH failed, ignore and disable it. ret=%d", ret);
|
||||||
dash->on_unpublish();
|
dash->on_unpublish();
|
||||||
ret = ERROR_SUCCESS;
|
ret = ERROR_SUCCESS;
|
||||||
|
@ -1339,14 +1339,25 @@ int SrsOriginHub::on_reload_vhost_dash(string vhost)
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSharedPtrMessage* cache_sh_video = source->meta->vsh();
|
SrsSharedPtrMessage* cache_sh_video = source->meta->vsh();
|
||||||
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
if (cache_sh_video) {
|
||||||
if (cache_sh_video && (ret = dash->on_video(cache_sh_video, true)) != ERROR_SUCCESS) {
|
if ((ret = format->on_video(cache_sh_video)) != ERROR_SUCCESS) {
|
||||||
srs_error("DASH consume video failed. ret=%d", ret);
|
return ret;
|
||||||
return ret;
|
}
|
||||||
|
if ((ret = dash->on_video(cache_sh_video, format)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("DASH consume video failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cache_sh_audio && (ret = dash->on_audio(cache_sh_audio)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("DASH consume audio failed. ret=%d", ret);
|
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
||||||
return ret;
|
if (cache_sh_audio) {
|
||||||
|
if ((ret = format->on_audio(cache_sh_audio)) != ERROR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if ((ret = dash->on_audio(cache_sh_audio, format)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("DASH consume audio failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1381,19 +1392,25 @@ int SrsOriginHub::on_reload_vhost_hls(string vhost)
|
||||||
// when reload to start hls, hls will never get the sequence header in stream,
|
// when reload to start hls, hls will never get the sequence header in stream,
|
||||||
// use the SrsSource.on_hls_start to push the sequence header to HLS.
|
// use the SrsSource.on_hls_start to push the sequence header to HLS.
|
||||||
SrsSharedPtrMessage* cache_sh_video = source->meta->vsh();
|
SrsSharedPtrMessage* cache_sh_video = source->meta->vsh();
|
||||||
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
if (cache_sh_video) {
|
||||||
|
if ((ret = format->on_video(cache_sh_video)) != ERROR_SUCCESS) {
|
||||||
// feed the hls the metadata/sequence header,
|
return ret;
|
||||||
// when reload to start hls, hls will never get the sequence header in stream,
|
}
|
||||||
// use the SrsSource.on_hls_start to push the sequence header to HLS.
|
if ((ret = hls->on_video(cache_sh_video, format)) != ERROR_SUCCESS) {
|
||||||
// TODO: maybe need to decode the metadata?
|
srs_error("hls process video sequence header message failed. ret=%d", ret);
|
||||||
if (cache_sh_video && (ret = hls->on_video(cache_sh_video, format)) != ERROR_SUCCESS) {
|
return ret;
|
||||||
srs_error("hls process video sequence header message failed. ret=%d", ret);
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
if (cache_sh_audio && (ret = hls->on_audio(cache_sh_audio, format)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("hls process audio sequence header message failed. ret=%d", ret);
|
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
||||||
return ret;
|
if (cache_sh_audio) {
|
||||||
|
if ((ret = format->on_audio(cache_sh_audio)) != ERROR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if ((ret = hls->on_audio(cache_sh_audio, format)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("hls process audio sequence header message failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1626,7 +1626,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transmux the RTMP stream to TS stream.
|
* Transmux the RTMP stream to HTTP-TS stream.
|
||||||
*/
|
*/
|
||||||
class SrsTsTransmuxer
|
class SrsTsTransmuxer
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue