完善接口

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 {
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:
typedef std::shared_ptr<PlayerBase> 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<Track::Ptr> getTracks() const { return vector<Track::Ptr>();}
protected:
virtual void onShutdown(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);
}
}
if(!_inited && _trackReadyCallback.empty()){
_inited = true;
onInited();
}
}
bool RtmpMuxer::inputRtmp(const RtmpPacket::Ptr &rtmp , bool key_pos) {

View File

@ -72,11 +72,15 @@ public:
* @return
*/
RtmpRingInterface::RingType::Ptr getRtmpRing() const;
protected:
virtual void onInited(){};
private:
map<int,Track::Ptr> _track_map;
map<int,function<void()> > _trackReadyCallback;
RtmpRingInterface::RingType::Ptr _rtmpRing;
AMFValue _metedata;
bool _inited = false;
};

View File

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

View File

@ -76,11 +76,15 @@ public:
* @return
*/
RtpRingInterface::RingType::Ptr getRtpRing() const;
protected:
virtual void onInited(){};
private:
map<int,Track::Ptr> _track_map;
map<int,function<void()> > _trackReadyCallback;
RtpRingInterface::RingType::Ptr _rtpRing;
string _sdp;
bool _inited = false;
};