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;
|
||||
}
|
||||
|
||||
int SrsMpegDash::on_audio(SrsSharedPtrMessage* shared_audio)
|
||||
int SrsMpegDash::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -79,7 +79,7 @@ int SrsMpegDash::on_audio(SrsSharedPtrMessage* shared_audio)
|
|||
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;
|
||||
|
||||
|
|
|
@ -32,6 +32,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
class SrsRequest;
|
||||
class SrsOriginHub;
|
||||
class SrsSharedPtrMessage;
|
||||
class SrsFormat;
|
||||
|
||||
/**
|
||||
*/
|
||||
class SrsFragmentedMp4
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
/**
|
||||
* The MPEG-DASH encoder, transmux RTMP to DASH.
|
||||
|
@ -52,9 +60,9 @@ public:
|
|||
// When stream start publishing.
|
||||
virtual int on_publish();
|
||||
// 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.
|
||||
virtual int on_video(SrsSharedPtrMessage* shared_video, bool is_sequence_header);
|
||||
virtual int on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);
|
||||
// When stream stop publishing.
|
||||
virtual void on_unpublish();
|
||||
};
|
||||
|
|
|
@ -1056,7 +1056,6 @@ SrsHls::SrsHls()
|
|||
{
|
||||
req = NULL;
|
||||
hub = NULL;
|
||||
format = NULL;
|
||||
|
||||
enabled = false;
|
||||
disposable = false;
|
||||
|
@ -1119,13 +1118,12 @@ int SrsHls::cycle()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsHls::initialize(SrsOriginHub* h, SrsFormat* f, SrsRequest* r)
|
||||
int SrsHls::initialize(SrsOriginHub* h, SrsRequest* r)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
hub = h;
|
||||
req = r;
|
||||
format = f;
|
||||
|
||||
if ((ret = controller->initialize()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
|
|
|
@ -321,7 +321,6 @@ private:
|
|||
int64_t last_update_time;
|
||||
private:
|
||||
SrsOriginHub* hub;
|
||||
SrsFormat* format;
|
||||
SrsRtmpJitter* jitter;
|
||||
SrsPithyPrint* pprint;
|
||||
/**
|
||||
|
@ -348,7 +347,7 @@ public:
|
|||
/**
|
||||
* 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,
|
||||
* for the muxer object not destroyed.
|
||||
|
|
|
@ -896,7 +896,7 @@ int SrsOriginHub::initialize(SrsSource* s, SrsRequest* r)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = hls->initialize(this, format, req)) != ERROR_SUCCESS) {
|
||||
if ((ret = hls->initialize(this, req)) != ERROR_SUCCESS) {
|
||||
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);
|
||||
dash->on_unpublish();
|
||||
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);
|
||||
dash->on_unpublish();
|
||||
ret = ERROR_SUCCESS;
|
||||
|
@ -1339,15 +1339,26 @@ int SrsOriginHub::on_reload_vhost_dash(string vhost)
|
|||
}
|
||||
|
||||
SrsSharedPtrMessage* cache_sh_video = source->meta->vsh();
|
||||
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
||||
if (cache_sh_video && (ret = dash->on_video(cache_sh_video, true)) != ERROR_SUCCESS) {
|
||||
if (cache_sh_video) {
|
||||
if ((ret = format->on_video(cache_sh_video)) != ERROR_SUCCESS) {
|
||||
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) {
|
||||
}
|
||||
|
||||
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
||||
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;
|
||||
}
|
||||
|
@ -1381,20 +1392,26 @@ int SrsOriginHub::on_reload_vhost_hls(string vhost)
|
|||
// 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.
|
||||
SrsSharedPtrMessage* cache_sh_video = source->meta->vsh();
|
||||
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
||||
|
||||
// feed the hls the metadata/sequence header,
|
||||
// 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.
|
||||
// TODO: maybe need to decode the metadata?
|
||||
if (cache_sh_video && (ret = hls->on_video(cache_sh_video, format)) != ERROR_SUCCESS) {
|
||||
if (cache_sh_video) {
|
||||
if ((ret = format->on_video(cache_sh_video)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = hls->on_video(cache_sh_video, format)) != ERROR_SUCCESS) {
|
||||
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) {
|
||||
}
|
||||
|
||||
SrsSharedPtrMessage* cache_sh_audio = source->meta->ash();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1626,7 +1626,7 @@ private:
|
|||
};
|
||||
|
||||
/**
|
||||
* Transmux the RTMP stream to TS stream.
|
||||
* Transmux the RTMP stream to HTTP-TS stream.
|
||||
*/
|
||||
class SrsTsTransmuxer
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue