mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Refactor code
This commit is contained in:
parent
44c8334b71
commit
6740a03a9c
3 changed files with 24 additions and 23 deletions
|
@ -1424,7 +1424,8 @@ srs_error_t SrsRtcPlayer::package_stap_a(SrsRtcSource* source, SrsSharedPtrMessa
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
SrsMetaCache* meta = dynamic_cast<SrsRtcFromRtmpBridger*>(source->bridger())->cached_meta();
|
||||
SrsRtcFromRtmpBridger* bridger = dynamic_cast<SrsRtcFromRtmpBridger*>(source->bridger());
|
||||
SrsMetaCache* meta = bridger->cached_meta();
|
||||
if (!meta) {
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -456,6 +456,11 @@ srs_error_t SrsRtcFromRtmpBridger::initialize(SrsRequest* r)
|
|||
return err;
|
||||
}
|
||||
|
||||
SrsMetaCache* SrsRtcFromRtmpBridger::cached_meta()
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
srs_error_t SrsRtcFromRtmpBridger::on_publish()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -476,6 +481,19 @@ srs_error_t SrsRtcFromRtmpBridger::on_publish()
|
|||
return err;
|
||||
}
|
||||
|
||||
void SrsRtcFromRtmpBridger::on_unpublish()
|
||||
{
|
||||
// TODO: FIXME: Should sync with bridger?
|
||||
source_->on_unpublish();
|
||||
|
||||
rtc->on_unpublish();
|
||||
|
||||
// Reset the metadata cache, to make VLC happy when disable/enable stream.
|
||||
// @see https://github.com/ossrs/srs/issues/1630#issuecomment-597979448
|
||||
meta->update_previous_vsh();
|
||||
meta->update_previous_ash();
|
||||
}
|
||||
|
||||
srs_error_t SrsRtcFromRtmpBridger::on_audio(SrsSharedPtrMessage* msg)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -528,21 +546,3 @@ srs_error_t SrsRtcFromRtmpBridger::on_video(SrsSharedPtrMessage* msg)
|
|||
return source_->on_video_imp(msg);
|
||||
}
|
||||
|
||||
void SrsRtcFromRtmpBridger::on_unpublish()
|
||||
{
|
||||
// TODO: FIXME: Should sync with bridger?
|
||||
source_->on_unpublish();
|
||||
|
||||
rtc->on_unpublish();
|
||||
|
||||
// Reset the metadata cache, to make VLC happy when disable/enable stream.
|
||||
// @see https://github.com/ossrs/srs/issues/1630#issuecomment-597979448
|
||||
meta->update_previous_vsh();
|
||||
meta->update_previous_ash();
|
||||
}
|
||||
|
||||
SrsMetaCache* SrsRtcFromRtmpBridger::cached_meta()
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
|
|
|
@ -182,12 +182,12 @@ public:
|
|||
virtual ~SrsRtcFromRtmpBridger();
|
||||
public:
|
||||
virtual srs_error_t initialize(SrsRequest* r);
|
||||
virtual srs_error_t on_publish();
|
||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* audio);
|
||||
virtual srs_error_t on_video(SrsSharedPtrMessage* video);
|
||||
virtual void on_unpublish();
|
||||
// For RTC, we need to package SPS/PPS(in cached meta) before each IDR.
|
||||
SrsMetaCache* cached_meta();
|
||||
virtual srs_error_t on_publish();
|
||||
virtual void on_unpublish();
|
||||
virtual srs_error_t on_audio(SrsSharedPtrMessage* audio);
|
||||
virtual srs_error_t on_video(SrsSharedPtrMessage* video);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue