diff --git a/src/Player/PlayerBase.h b/src/Player/PlayerBase.h index dbd6f722..43324b71 100644 --- a/src/Player/PlayerBase.h +++ b/src/Player/PlayerBase.h @@ -42,7 +42,17 @@ using namespace toolkit; namespace mediakit { -class PlayerBase : public mINI{ +class DemuxerBase { +public: + typedef std::shared_ptr Ptr; + + virtual float getDuration() const { return 0;} + virtual bool isInited() const { return true; } + virtual vector getTracks() const { return vector();} +}; + + +class PlayerBase : public DemuxerBase, public mINI{ public: typedef std::shared_ptr Ptr; typedef enum { @@ -76,13 +86,8 @@ public: virtual float getProgress() const { return 0;} virtual void seekTo(float fProgress) {} virtual void setMediaSouce(const MediaSource::Ptr & src) {} - - virtual bool isInited() const { return true; } //TrackVideo = 0, TrackAudio = 1 virtual float getRtpLossRate(int trackType) const {return 0; } - virtual float getDuration() const { return 0;} - - virtual vector getTracks() const { return vector();} protected: virtual void onShutdown(const SockException &ex) {} virtual void onPlayResult(const SockException &ex) {} diff --git a/src/RtmpMuxer/RtmpMuxer.cpp b/src/RtmpMuxer/RtmpMuxer.cpp index 12b644f5..402a0b23 100644 --- a/src/RtmpMuxer/RtmpMuxer.cpp +++ b/src/RtmpMuxer/RtmpMuxer.cpp @@ -101,6 +101,11 @@ void RtmpMuxer::inputFrame(const Frame::Ptr &frame) { _trackReadyCallback.erase(it_callback); } } + + if(!_inited && _trackReadyCallback.empty()){ + _inited = true; + onInited(); + } } bool RtmpMuxer::inputRtmp(const RtmpPacket::Ptr &rtmp , bool key_pos) { diff --git a/src/RtmpMuxer/RtmpMuxer.h b/src/RtmpMuxer/RtmpMuxer.h index d0f2ae71..770aa06b 100644 --- a/src/RtmpMuxer/RtmpMuxer.h +++ b/src/RtmpMuxer/RtmpMuxer.h @@ -72,11 +72,15 @@ public: * @return */ RtmpRingInterface::RingType::Ptr getRtmpRing() const; + +protected: + virtual void onInited(){}; private: map _track_map; map > _trackReadyCallback; RtmpRingInterface::RingType::Ptr _rtmpRing; AMFValue _metedata; + bool _inited = false; }; diff --git a/src/RtspMuxer/RtspMuxer.cpp b/src/RtspMuxer/RtspMuxer.cpp index 62418df6..e420300e 100644 --- a/src/RtspMuxer/RtspMuxer.cpp +++ b/src/RtspMuxer/RtspMuxer.cpp @@ -89,6 +89,11 @@ void RtspMuxer::inputFrame(const Frame::Ptr &frame) { _trackReadyCallback.erase(it_callback); } } + + if(!_inited && _trackReadyCallback.empty()){ + _inited = true; + onInited(); + } } bool RtspMuxer::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) { diff --git a/src/RtspMuxer/RtspMuxer.h b/src/RtspMuxer/RtspMuxer.h index 5cc1ece4..05d90003 100644 --- a/src/RtspMuxer/RtspMuxer.h +++ b/src/RtspMuxer/RtspMuxer.h @@ -76,11 +76,15 @@ public: * @return */ RtpRingInterface::RingType::Ptr getRtpRing() const; + +protected: + virtual void onInited(){}; private: map _track_map; map > _trackReadyCallback; RtpRingInterface::RingType::Ptr _rtpRing; string _sdp; + bool _inited = false; };