mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-27 04:22:20 +08:00
初步完成Rtp解包
This commit is contained in:
@@ -27,6 +27,8 @@ typedef enum {
|
||||
|
||||
class CodecInfo {
|
||||
public:
|
||||
typedef std::shared_ptr<CodecInfo> Ptr;
|
||||
|
||||
CodecInfo(){}
|
||||
virtual ~CodecInfo(){}
|
||||
|
||||
@@ -63,6 +65,7 @@ public:
|
||||
class FrameRingInterface {
|
||||
public:
|
||||
typedef RingBuffer<Frame::Ptr> RingType;
|
||||
typedef std::shared_ptr<FrameRingInterface> Ptr;
|
||||
|
||||
FrameRingInterface(){}
|
||||
virtual ~FrameRingInterface(){}
|
||||
@@ -83,8 +86,9 @@ public:
|
||||
* 写入帧数据
|
||||
* @param frame 帧
|
||||
* @param key_pos 是否为关键帧
|
||||
* @return 是否为关键帧
|
||||
*/
|
||||
virtual void inputFrame(const Frame::Ptr &frame,bool key_pos) = 0;
|
||||
virtual bool inputFrame(const Frame::Ptr &frame,bool key_pos) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -118,8 +122,9 @@ public:
|
||||
* @param frame
|
||||
* @param key_pos
|
||||
*/
|
||||
void inputFrame(const Frame::Ptr &frame,bool key_pos) override{
|
||||
bool inputFrame(const Frame::Ptr &frame,bool key_pos) override{
|
||||
_frameRing->write(frame,key_pos);
|
||||
return key_pos;
|
||||
}
|
||||
protected:
|
||||
RingType::Ptr _frameRing;
|
||||
|
||||
@@ -87,8 +87,7 @@ public:
|
||||
virtual float getRtpLossRate(int trackType) const {return 0; }
|
||||
virtual float getDuration() const { return 0;}
|
||||
|
||||
virtual int getTrackCount() const { return 0;}
|
||||
virtual Track::Ptr getTrack(int index) const {return nullptr;}
|
||||
virtual vector<Track::Ptr> getTracks() const { return vector<Track::Ptr>();}
|
||||
protected:
|
||||
virtual void onShutdown(const SockException &ex) {}
|
||||
virtual void onPlayResult(const SockException &ex) {}
|
||||
@@ -146,18 +145,12 @@ public:
|
||||
m_pMediaSrc = src;
|
||||
}
|
||||
|
||||
virtual int getTrackCount() const override{
|
||||
if (m_parser) {
|
||||
return m_parser->getTrackCount();
|
||||
}
|
||||
return PlayerBase::getTrackCount();
|
||||
}
|
||||
virtual Track::Ptr getTrack(int index) const override{
|
||||
if (m_parser) {
|
||||
return m_parser->getTrack(index);
|
||||
}
|
||||
return PlayerBase::getTrack(index);
|
||||
}
|
||||
vector<Track::Ptr> getTracks() const override{
|
||||
if (m_parser) {
|
||||
return m_parser->getTracks();
|
||||
}
|
||||
return PlayerBase::getTracks();
|
||||
}
|
||||
protected:
|
||||
void onShutdown(const SockException &ex) override {
|
||||
if (m_shutdownCB) {
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
|
||||
class VideoTrack : public Track {
|
||||
public:
|
||||
typedef std::shared_ptr<VideoTrack> Ptr;
|
||||
|
||||
TrackType getTrackType() const override { return TrackVideo;};
|
||||
|
||||
/**
|
||||
@@ -49,6 +51,8 @@ public:
|
||||
|
||||
class AudioTrack : public Track {
|
||||
public:
|
||||
typedef std::shared_ptr<AudioTrack> Ptr;
|
||||
|
||||
TrackType getTrackType() const override { return TrackAudio;};
|
||||
|
||||
/**
|
||||
@@ -72,6 +76,7 @@ public:
|
||||
|
||||
class H264Track : public VideoTrack{
|
||||
public:
|
||||
typedef std::shared_ptr<H264Track> Ptr;
|
||||
|
||||
/**
|
||||
* 不指定sps pps构造h264类型的媒体
|
||||
@@ -162,7 +167,7 @@ public:
|
||||
* @param frame 数据帧
|
||||
* @param key_pos 是否为关键帧
|
||||
*/
|
||||
void inputFrame(const Frame::Ptr &frame,bool key_pos) override{
|
||||
bool inputFrame(const Frame::Ptr &frame,bool key_pos) override{
|
||||
int type = (*((uint8_t *)frame->data() + frame->prefixSize())) & 0x1F;
|
||||
switch (type){
|
||||
case 7:{
|
||||
@@ -209,6 +214,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
return type == 5;
|
||||
}
|
||||
private:
|
||||
/**
|
||||
@@ -228,6 +234,8 @@ private:
|
||||
|
||||
class AACTrack : public AudioTrack{
|
||||
public:
|
||||
typedef std::shared_ptr<AACTrack> Ptr;
|
||||
|
||||
/**
|
||||
* 构造aac类型的媒体
|
||||
* @param aac_cfg aac两个字节的配置信息
|
||||
|
||||
Reference in New Issue
Block a user