Commit 84dbe559 by xiongziliang

完善接口

parent 8d032a40
...@@ -42,7 +42,17 @@ using namespace toolkit; ...@@ -42,7 +42,17 @@ using namespace toolkit;
namespace mediakit { namespace mediakit {
class PlayerBase : public mINI{ class DemuxerBase {
public:
typedef std::shared_ptr<DemuxerBase> Ptr;
virtual float getDuration() const { return 0;}
virtual bool isInited() const { return true; }
virtual vector<Track::Ptr> getTracks() const { return vector<Track::Ptr>();}
};
class PlayerBase : public DemuxerBase, public mINI{
public: public:
typedef std::shared_ptr<PlayerBase> Ptr; typedef std::shared_ptr<PlayerBase> Ptr;
typedef enum { typedef enum {
...@@ -76,13 +86,8 @@ public: ...@@ -76,13 +86,8 @@ public:
virtual float getProgress() const { return 0;} virtual float getProgress() const { return 0;}
virtual void seekTo(float fProgress) {} virtual void seekTo(float fProgress) {}
virtual void setMediaSouce(const MediaSource::Ptr & src) {} virtual void setMediaSouce(const MediaSource::Ptr & src) {}
virtual bool isInited() const { return true; }
//TrackVideo = 0, TrackAudio = 1 //TrackVideo = 0, TrackAudio = 1
virtual float getRtpLossRate(int trackType) const {return 0; } virtual float getRtpLossRate(int trackType) const {return 0; }
virtual float getDuration() const { return 0;}
virtual vector<Track::Ptr> getTracks() const { return vector<Track::Ptr>();}
protected: protected:
virtual void onShutdown(const SockException &ex) {} virtual void onShutdown(const SockException &ex) {}
virtual void onPlayResult(const SockException &ex) {} virtual void onPlayResult(const SockException &ex) {}
......
...@@ -101,6 +101,11 @@ void RtmpMuxer::inputFrame(const Frame::Ptr &frame) { ...@@ -101,6 +101,11 @@ void RtmpMuxer::inputFrame(const Frame::Ptr &frame) {
_trackReadyCallback.erase(it_callback); _trackReadyCallback.erase(it_callback);
} }
} }
if(!_inited && _trackReadyCallback.empty()){
_inited = true;
onInited();
}
} }
bool RtmpMuxer::inputRtmp(const RtmpPacket::Ptr &rtmp , bool key_pos) { bool RtmpMuxer::inputRtmp(const RtmpPacket::Ptr &rtmp , bool key_pos) {
......
...@@ -72,11 +72,15 @@ public: ...@@ -72,11 +72,15 @@ public:
* @return * @return
*/ */
RtmpRingInterface::RingType::Ptr getRtmpRing() const; RtmpRingInterface::RingType::Ptr getRtmpRing() const;
protected:
virtual void onInited(){};
private: private:
map<int,Track::Ptr> _track_map; map<int,Track::Ptr> _track_map;
map<int,function<void()> > _trackReadyCallback; map<int,function<void()> > _trackReadyCallback;
RtmpRingInterface::RingType::Ptr _rtmpRing; RtmpRingInterface::RingType::Ptr _rtmpRing;
AMFValue _metedata; AMFValue _metedata;
bool _inited = false;
}; };
......
...@@ -89,6 +89,11 @@ void RtspMuxer::inputFrame(const Frame::Ptr &frame) { ...@@ -89,6 +89,11 @@ void RtspMuxer::inputFrame(const Frame::Ptr &frame) {
_trackReadyCallback.erase(it_callback); _trackReadyCallback.erase(it_callback);
} }
} }
if(!_inited && _trackReadyCallback.empty()){
_inited = true;
onInited();
}
} }
bool RtspMuxer::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) { bool RtspMuxer::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) {
......
...@@ -76,11 +76,15 @@ public: ...@@ -76,11 +76,15 @@ public:
* @return * @return
*/ */
RtpRingInterface::RingType::Ptr getRtpRing() const; RtpRingInterface::RingType::Ptr getRtpRing() const;
protected:
virtual void onInited(){};
private: private:
map<int,Track::Ptr> _track_map; map<int,Track::Ptr> _track_map;
map<int,function<void()> > _trackReadyCallback; map<int,function<void()> > _trackReadyCallback;
RtpRingInterface::RingType::Ptr _rtpRing; RtpRingInterface::RingType::Ptr _rtpRing;
string _sdp; string _sdp;
bool _inited = false;
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论