diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index e5872880..1809f8c5 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -95,7 +95,7 @@ vector MediaSource::getTracks(bool ready) const { if(!listener){ return vector(); } - return listener->getTracks(const_cast(*this), ready); + return listener->getMediaTracks(const_cast(*this), ready); } void MediaSource::setListener(const std::weak_ptr &listener){ @@ -636,12 +636,12 @@ bool MediaSourceEventInterceptor::isRecording(MediaSource &sender, Recorder::typ return listener->isRecording(sender, type); } -vector MediaSourceEventInterceptor::getTracks(MediaSource &sender, bool trackReady) const { +vector MediaSourceEventInterceptor::getMediaTracks(MediaSource &sender, bool trackReady) const { auto listener = _listener.lock(); if (!listener) { return vector(); } - return listener->getTracks(sender, trackReady); + return listener->getMediaTracks(sender, trackReady); } void MediaSourceEventInterceptor::startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function &cb){ diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index 8d1667b6..8e433dfe 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -82,7 +82,7 @@ public: // 获取录制状态 virtual bool isRecording(MediaSource &sender, Recorder::type type) { return false; }; // 获取所有track相关信息 - virtual vector getTracks(MediaSource &sender, bool trackReady = true) const { return vector(); }; + virtual vector getMediaTracks(MediaSource &sender, bool trackReady = true) const { return vector(); }; // 开始发送ps-rtp virtual void startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function &cb) { cb(0, SockException(Err_other, "not implemented"));}; // 停止发送ps-rtp @@ -112,7 +112,7 @@ public: void onRegist(MediaSource &sender, bool regist) override; bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path, size_t max_second) override; bool isRecording(MediaSource &sender, Recorder::type type) override; - vector getTracks(MediaSource &sender, bool trackReady = true) const override; + vector getMediaTracks(MediaSource &sender, bool trackReady = true) const override; void startSendRtp(MediaSource &sender, const string &dst_url, uint16_t dst_port, const string &ssrc, bool is_udp, uint16_t src_port, const function &cb) override; bool stopSendRtp(MediaSource &sender, const string &ssrc) override; @@ -200,7 +200,7 @@ public: using SchemaVhostAppStreamMap = unordered_map; MediaSource(const string &schema, const string &vhost, const string &app, const string &stream_id) ; - virtual ~MediaSource() ; + virtual ~MediaSource(); ////////////////获取MediaSource相关信息//////////////// diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index d609cefe..ec9c644f 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -149,7 +149,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type case Recorder::type_hls : { if (start && !_hls) { //开始录制 - auto hls = dynamic_pointer_cast(makeRecorder(sender, MediaSink::getTracks(), type, custom_path, max_second)); + auto hls = dynamic_pointer_cast(makeRecorder(sender, getTracks(), type, custom_path, max_second)); if (hls) { //设置HlsMediaSource的事件监听器 hls->setListener(shared_from_this()); @@ -164,7 +164,7 @@ bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type case Recorder::type_mp4 : { if (start && !_mp4) { //开始录制 - _mp4 = makeRecorder(sender, MediaSink::getTracks(), type, custom_path, max_second); + _mp4 = makeRecorder(sender, getTracks(), type, custom_path, max_second); } else if (!start && _mp4) { //停止录制 _mp4 = nullptr; @@ -197,7 +197,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &, const string &dst_url, u if (!strong_self || ex) { return; } - for (auto &track : strong_self->MediaSink::getTracks(false)) { + for (auto &track : strong_self->getTracks(false)) { rtp_sender->addTrack(track); } rtp_sender->addTrackCompleted(); @@ -232,6 +232,10 @@ bool MultiMediaSourceMuxer::stopSendRtp(MediaSource &sender, const string &ssrc) #endif//ENABLE_RTPPROXY } +vector MultiMediaSourceMuxer::getMediaTracks(MediaSource &sender, bool trackReady) const { + return getTracks(trackReady); +} + void MultiMediaSourceMuxer::onTrackReady(const Track::Ptr &track) { if (CodecL16 == track->getCodecId()) { WarnL << "L16音频格式目前只支持RTSP协议推流拉流!!!"; diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index 95e9dde8..a3a782cb 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -66,6 +66,11 @@ public: */ void setTimeStamp(uint32_t stamp); + /** + * 重置track + */ + void resetTracks() override; + /////////////////////////////////MediaSourceEvent override///////////////////////////////// /** @@ -108,9 +113,11 @@ public: bool stopSendRtp(MediaSource &sender, const string &ssrc) override; /** - * 重置track + * 获取所有Track + * @param trackReady 是否筛选过滤未就绪的track + * @return 所有Track */ - void resetTracks() override; + vector getMediaTracks(MediaSource &sender, bool trackReady = true) const override; protected: /////////////////////////////////MediaSink override///////////////////////////////// diff --git a/src/Rtmp/RtmpMediaSourceImp.h b/src/Rtmp/RtmpMediaSourceImp.h index 14672f97..ad1d9dfd 100644 --- a/src/Rtmp/RtmpMediaSourceImp.h +++ b/src/Rtmp/RtmpMediaSourceImp.h @@ -127,7 +127,7 @@ public: if (_recreate_metadata) { //更新metadata - for (auto &track : _muxer->MediaSink::getTracks()) { + for (auto &track : _muxer->getTracks()) { Metadata::addTrack(_metadata, track); } RtmpMediaSource::updateMetaData(_metadata);