完善接口

This commit is contained in:
xiongziliang 2018-10-25 15:45:38 +08:00
parent 8d032a40ec
commit 84dbe5597d
5 changed files with 29 additions and 6 deletions

View File

@ -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:
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) {}

View File

@ -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) {

View File

@ -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;
}; };

View File

@ -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) {

View File

@ -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;
}; };