整理和精简代码

This commit is contained in:
xiongziliang 2020-05-11 22:33:10 +08:00
parent 41f1df3acf
commit 625d7e30c0
23 changed files with 326 additions and 564 deletions

View File

@ -163,7 +163,9 @@ void DevChannel::inputG711(const char *data, int len, uint32_t dts){
if (dts == 0) { if (dts == 0) {
dts = (uint32_t)_aTicker[1].elapsedTime(); dts = (uint32_t)_aTicker[1].elapsedTime();
} }
inputFrame(std::make_shared<G711FrameNoCacheAble>(_audio->codecId, (char*)data, len, dts, 0)); auto frame = std::make_shared<G711FrameNoCacheAble>((char*)data, len, dts, 0);
frame->setCodec(_audio->codecId);
inputFrame(frame);
} }
void DevChannel::initVideo(const VideoInfo &info) { void DevChannel::initVideo(const VideoInfo &info) {

View File

@ -18,20 +18,12 @@ namespace mediakit{
class AACFrame; class AACFrame;
unsigned const samplingFrequencyTable[16] = { 96000, 88200, unsigned const samplingFrequencyTable[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 };
64000, 48000,
44100, 32000,
24000, 22050,
16000, 12000,
11025, 8000,
7350, 0, 0, 0 };
void makeAdtsHeader(const string &strAudioCfg,AACFrame &adts); void makeAdtsHeader(const string &strAudioCfg,AACFrame &adts);
void writeAdtsHeader(const AACFrame &adts, uint8_t *pcAdts) ; void writeAdtsHeader(const AACFrame &adts, uint8_t *pcAdts) ;
string makeAdtsConfig(const uint8_t *pcAdts); string makeAdtsConfig(const uint8_t *pcAdts);
void getAACInfo(const AACFrame &adts,int &iSampleRate,int &iChannel); void getAACInfo(const AACFrame &adts,int &iSampleRate,int &iChannel);
/** /**
* aac帧adts头 * aac帧adts头
*/ */
@ -46,14 +38,10 @@ public:
return aac_frame_length; return aac_frame_length;
} }
uint32_t dts() const override { uint32_t dts() const override {
return timeStamp; return _dts;
} }
uint32_t prefixSize() const override{ uint32_t prefixSize() const override{
return iPrefixSize; return _prefix_size;
}
TrackType getTrackType() const override{
return TrackAudio;
} }
CodecId getCodecId() const override{ CodecId getCodecId() const override{
@ -88,11 +76,11 @@ public:
//表示说ADTS帧中有一个AAC数据块并不是说没有。(一个AAC原始帧包含一段时间内1024个采样及相关数据) //表示说ADTS帧中有一个AAC数据块并不是说没有。(一个AAC原始帧包含一段时间内1024个采样及相关数据)
unsigned int no_raw_data_blocks_in_frame; //2 uimsfb unsigned int no_raw_data_blocks_in_frame; //2 uimsfb
unsigned char buffer[2 * 1024 + 7]; unsigned char buffer[2 * 1024 + 7];
uint32_t timeStamp; uint32_t _dts;
uint32_t iPrefixSize = 7; uint32_t _prefix_size = 7;
}; };
class AACFrameNoCacheAble : public FrameNoCacheAble { class AACFrameNoCacheAble : public FrameFromPtr {
public: public:
typedef std::shared_ptr<AACFrameNoCacheAble> Ptr; typedef std::shared_ptr<AACFrameNoCacheAble> Ptr;
@ -100,11 +88,7 @@ public:
_ptr = ptr; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
_prefixSize = prefixeSize; _prefix_size = prefixeSize;
}
TrackType getTrackType() const override{
return TrackAudio;
} }
CodecId getCodecId() const override{ CodecId getCodecId() const override{
@ -120,7 +104,6 @@ public:
} }
}; };
/** /**
* aac音频通道 * aac音频通道
*/ */
@ -173,7 +156,6 @@ public:
/** /**
* aac两个字节的配置 * aac两个字节的配置
* @return
*/ */
const string &getAacCfg() const{ const string &getAacCfg() const{
return _cfg; return _cfg;
@ -181,7 +163,6 @@ public:
/** /**
* *
* @return
*/ */
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecAAC; return CodecAAC;
@ -189,30 +170,27 @@ public:
/** /**
* aac_cfg前是无效的Track * aac_cfg前是无效的Track
* @return
*/ */
bool ready() override { bool ready() override {
return !_cfg.empty(); return !_cfg.empty();
} }
/** /**
* *
* @return
*/ */
int getAudioSampleRate() const override{ int getAudioSampleRate() const override{
return _sampleRate; return _sampleRate;
} }
/** /**
* 168 * 168
* @return
*/ */
int getAudioSampleBit() const override{ int getAudioSampleBit() const override{
return _sampleBit; return _sampleBit;
} }
/** /**
* *
* @return
*/ */
int getAudioChannel() const override{ int getAudioChannel() const override{
return _channel; return _channel;
@ -247,6 +225,7 @@ private:
makeAdtsHeader(_cfg,aacFrame); makeAdtsHeader(_cfg,aacFrame);
getAACInfo(aacFrame,_sampleRate,_channel); getAACInfo(aacFrame,_sampleRate,_channel);
} }
Track::Ptr clone() override { Track::Ptr clone() override {
return std::make_shared<std::remove_reference<decltype(*this)>::type >(*this); return std::make_shared<std::remove_reference<decltype(*this)>::type >(*this);
} }
@ -260,15 +239,13 @@ private:
int _channel = 0; int _channel = 0;
}; };
/** /**
* aac类型SDP * aac类型SDP
*/ */
class AACSdp : public Sdp { class AACSdp : public Sdp {
public: public:
/** /**
* *
* @param aac_cfg aac两个字节的配置描述 * @param aac_cfg aac两个字节的配置描述
* @param sample_rate * @param sample_rate
* @param playload_type rtp playload type 98 * @param playload_type rtp playload type 98
@ -288,16 +265,13 @@ public:
_printer << "a=fmtp:" << playload_type << " streamtype=5;profile-level-id=1;mode=AAC-hbr;" _printer << "a=fmtp:" << playload_type << " streamtype=5;profile-level-id=1;mode=AAC-hbr;"
<< "sizelength=13;indexlength=3;indexdeltalength=3;config=" << "sizelength=13;indexlength=3;indexdeltalength=3;config="
<< configStr << "\r\n"; << configStr << "\r\n";
_printer << "a=control:trackID=" << getTrackType() << "\r\n"; _printer << "a=control:trackID=" << (int)TrackAudio << "\r\n";
} }
string getSdp() const override { string getSdp() const override {
return _printer; return _printer;
} }
TrackType getTrackType() const override {
return TrackAudio;
}
CodecId getCodecId() const override { CodecId getCodecId() const override {
return CodecAAC; return CodecAAC;
} }
@ -306,6 +280,4 @@ private:
}; };
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_AAC_H #endif //ZLMEDIAKIT_AAC_H

View File

@ -21,7 +21,7 @@ AACFrame::Ptr AACRtmpDecoder::obtainFrame() {
//从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象 //从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象
auto frame = ResourcePoolHelper<AACFrame>::obtainObj(); auto frame = ResourcePoolHelper<AACFrame>::obtainObj();
frame->aac_frame_length = 7; frame->aac_frame_length = 7;
frame->iPrefixSize = 7; frame->_prefix_size = 7;
return frame; return frame;
} }
@ -63,7 +63,7 @@ void AACRtmpDecoder::onGetAAC(const char* pcData, int iLen, uint32_t ui32TimeSta
//拷贝aac负载 //拷贝aac负载
memcpy(_adts->buffer + 7, pcData, iLen); memcpy(_adts->buffer + 7, pcData, iLen);
_adts->aac_frame_length = 7 + iLen; _adts->aac_frame_length = 7 + iLen;
_adts->timeStamp = ui32TimeStamp; _adts->_dts = ui32TimeStamp;
//adts结构头转成头7个字节 //adts结构头转成头7个字节
writeAdtsHeader(*_adts, _adts->buffer); writeAdtsHeader(*_adts, _adts->buffer);

View File

@ -33,10 +33,6 @@ public:
*/ */
bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override; bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override;
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecAAC; return CodecAAC;
} }

View File

@ -78,7 +78,7 @@ AACFrame::Ptr AACRtpDecoder::obtainFrame() {
//从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象 //从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象
auto frame = ResourcePoolHelper<AACFrame>::obtainObj(); auto frame = ResourcePoolHelper<AACFrame>::obtainObj();
frame->aac_frame_length = ADTS_HEADER_LEN; frame->aac_frame_length = ADTS_HEADER_LEN;
frame->iPrefixSize = ADTS_HEADER_LEN; frame->_prefix_size = ADTS_HEADER_LEN;
if(frame->syncword == 0 && !_aac_cfg.empty()) { if(frame->syncword == 0 && !_aac_cfg.empty()) {
makeAdtsHeader(_aac_cfg,*frame); makeAdtsHeader(_aac_cfg,*frame);
} }
@ -109,7 +109,7 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
//追加aac数据 //追加aac数据
memcpy(_adts->buffer + _adts->aac_frame_length, ptr, size); memcpy(_adts->buffer + _adts->aac_frame_length, ptr, size);
_adts->aac_frame_length += size; _adts->aac_frame_length += size;
_adts->timeStamp = rtppack->timeStamp; _adts->_dts = rtppack->timeStamp;
ptr += size; ptr += size;
} }

View File

@ -31,9 +31,6 @@ public:
*/ */
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = false) override; bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = false) override;
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecAAC; return CodecAAC;
} }

View File

@ -15,6 +15,59 @@ using namespace toolkit;
namespace mediakit{ namespace mediakit{
/**
*
*/
class FrameCacheAble : public FrameFromPtr {
public:
typedef std::shared_ptr<FrameCacheAble> Ptr;
FrameCacheAble(const Frame::Ptr &frame){
if(frame->cacheAble()){
_frame = frame;
_ptr = frame->data();
}else{
_buffer = std::make_shared<BufferRaw>();
_buffer->assign(frame->data(),frame->size());
_ptr = _buffer->data();
}
_size = frame->size();
_dts = frame->dts();
_pts = frame->pts();
_prefix_size = frame->prefixSize();
_codecid = frame->getCodecId();
_key = frame->keyFrame();
_config = frame->configFrame();
}
virtual ~FrameCacheAble() = default;
/**
*
*/
bool cacheAble() const override {
return true;
}
CodecId getCodecId() const override{
return _codecid;
}
bool keyFrame() const override{
return _key;
}
bool configFrame() const override{
return _config;
}
private:
Frame::Ptr _frame;
BufferRaw::Ptr _buffer;
CodecId _codecid;
bool _key;
bool _config;
};
Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){ Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){
if(frame->cacheAble()){ if(frame->cacheAble()){
return frame; return frame;
@ -30,10 +83,21 @@ const char *CodecInfo::getCodecName() {
SWITCH_CASE(CodecAAC); SWITCH_CASE(CodecAAC);
SWITCH_CASE(CodecG711A); SWITCH_CASE(CodecG711A);
SWITCH_CASE(CodecG711U); SWITCH_CASE(CodecG711U);
default: SWITCH_CASE(CodecOpus);
return "unknown codec"; default : return "unknown codec";
}
}
TrackType CodecInfo::getTrackType(){
switch (getCodecId()){
case CodecH264:
case CodecH265: return TrackVideo;
case CodecAAC:
case CodecG711A:
case CodecG711U:
case CodecOpus: return TrackAudio;
default: return TrackInvalid;
} }
} }
}//namespace mediakit }//namespace mediakit

View File

@ -28,6 +28,7 @@ typedef enum {
CodecAAC, CodecAAC,
CodecG711A, CodecG711A,
CodecG711U, CodecG711U,
CodecOpus,
CodecMax = 0x7FFF CodecMax = 0x7FFF
} CodecId; } CodecId;
@ -49,11 +50,6 @@ public:
CodecInfo(){} CodecInfo(){}
virtual ~CodecInfo(){} virtual ~CodecInfo(){}
/**
*
*/
virtual TrackType getTrackType() const = 0;
/** /**
* *
*/ */
@ -61,9 +57,13 @@ public:
/** /**
* *
* @return
*/ */
const char *getCodecName(); const char *getCodecName();
/**
*
*/
TrackType getTrackType();
}; };
/** /**
@ -76,15 +76,11 @@ public:
/** /**
* *
* @return
*/ */
virtual uint32_t dts() const = 0; virtual uint32_t dts() const = 0;
/** /**
* *
* @return
*/ */
virtual uint32_t pts() const { virtual uint32_t pts() const {
return dts(); return dts();
@ -98,13 +94,11 @@ public:
/** /**
* *
* @return
*/ */
virtual bool keyFrame() const = 0; virtual bool keyFrame() const = 0;
/** /**
* sps pps vps * sps pps vps
* @return
*/ */
virtual bool configFrame() const = 0; virtual bool configFrame() const = 0;
@ -115,14 +109,77 @@ public:
/** /**
* frame * frame
* @return
*/ */
static Ptr getCacheAbleFrame(const Ptr &frame); static Ptr getCacheAbleFrame(const Ptr &frame);
}; };
class FrameImp : public Frame {
public:
typedef std::shared_ptr<FrameImp> Ptr;
char *data() const override{
return (char *)_buffer.data();
}
uint32_t size() const override {
return _buffer.size();
}
uint32_t dts() const override {
return _dts;
}
uint32_t pts() const override{
return _pts ? _pts : _dts;
}
uint32_t prefixSize() const override{
return _prefix_size;
}
CodecId getCodecId() const override{
return _codecid;
}
bool keyFrame() const override {
return false;
}
bool configFrame() const override{
return false;
}
public:
CodecId _codecid = CodecInvalid;
string _buffer;
uint32_t _dts = 0;
uint32_t _pts = 0;
uint32_t _prefix_size = 0;
};
/**
* Frame类中可以有多个帧 0x 00 00 01
* ZLMediaKit会先把这种复合帧split成单个帧然后再处理
* Frame
*
*/
template<typename Parent>
class FrameInternal : public Parent{
public:
typedef std::shared_ptr<FrameInternal> Ptr;
FrameInternal(const Frame::Ptr &parent_frame, char *ptr, uint32_t size, int prefix_size)
: Parent(ptr, size, parent_frame->dts(), parent_frame->pts(), prefix_size) {
_parent_frame = parent_frame;
}
bool cacheAble() const override {
return _parent_frame->cacheAble();
}
private:
Frame::Ptr _parent_frame;
};
/** /**
* *
* @tparam T
*/ */
template <typename T> template <typename T>
class ResourcePoolHelper{ class ResourcePoolHelper{
@ -140,17 +197,16 @@ private:
}; };
/** /**
* *
*/ */
class FrameWriterInterface { class FrameWriterInterface {
public: public:
typedef std::shared_ptr<FrameWriterInterface> Ptr; typedef std::shared_ptr<FrameWriterInterface> Ptr;
FrameWriterInterface(){} FrameWriterInterface(){}
virtual ~FrameWriterInterface(){} virtual ~FrameWriterInterface(){}
/** /**
* *
* @param frame
*/ */
virtual void inputFrame(const Frame::Ptr &frame) = 0; virtual void inputFrame(const Frame::Ptr &frame) = 0;
}; };
@ -165,15 +221,15 @@ public:
/** /**
* inputFrame后触发onWriteFrame回调 * inputFrame后触发onWriteFrame回调
* @param cb
*/ */
FrameWriterInterfaceHelper(const onWriteFrame& cb){ FrameWriterInterfaceHelper(const onWriteFrame& cb){
_writeCallback = cb; _writeCallback = cb;
} }
virtual ~FrameWriterInterfaceHelper(){} virtual ~FrameWriterInterfaceHelper(){}
/** /**
* *
* @param frame
*/ */
void inputFrame(const Frame::Ptr &frame) override { void inputFrame(const Frame::Ptr &frame) override {
_writeCallback(frame); _writeCallback(frame);
@ -182,7 +238,6 @@ private:
onWriteFrame _writeCallback; onWriteFrame _writeCallback;
}; };
/** /**
* *
*/ */
@ -193,6 +248,9 @@ public:
FrameDispatcher(){} FrameDispatcher(){}
virtual ~FrameDispatcher(){} virtual ~FrameDispatcher(){}
/**
*
*/
void addDelegate(const FrameWriterInterface::Ptr &delegate){ void addDelegate(const FrameWriterInterface::Ptr &delegate){
//_delegates_write可能多线程同时操作 //_delegates_write可能多线程同时操作
lock_guard<mutex> lck(_mtx); lock_guard<mutex> lck(_mtx);
@ -200,6 +258,9 @@ public:
_need_update = true; _need_update = true;
} }
/**
*
*/
void delDelegate(void *ptr){ void delDelegate(void *ptr){
//_delegates_write可能多线程同时操作 //_delegates_write可能多线程同时操作
lock_guard<mutex> lck(_mtx); lock_guard<mutex> lck(_mtx);
@ -208,8 +269,7 @@ public:
} }
/** /**
* *
* @param frame
*/ */
void inputFrame(const Frame::Ptr &frame) override{ void inputFrame(const Frame::Ptr &frame) override{
if(_need_update){ if(_need_update){
@ -223,7 +283,13 @@ public:
for(auto &pr : _delegates_read){ for(auto &pr : _delegates_read){
pr.second->inputFrame(frame); pr.second->inputFrame(frame);
} }
}
/**
*
*/
int size() const {
return _delegates_write.size();
} }
private: private:
mutex _mtx; mutex _mtx;
@ -250,105 +316,23 @@ public:
} }
uint32_t pts() const override{ uint32_t pts() const override{
if(_pts){ return _pts ? _pts : dts();
return _pts;
}
return dts();
} }
uint32_t prefixSize() const override{ uint32_t prefixSize() const override{
return _prefixSize; return _prefix_size;
}
bool cacheAble() const override {
return false;
} }
protected: protected:
char *_ptr; char *_ptr;
uint32_t _size; uint32_t _size;
uint32_t _dts; uint32_t _dts;
uint32_t _pts = 0; uint32_t _pts = 0;
uint32_t _prefixSize; uint32_t _prefix_size;
}; };
/**
* DevChannel类中有用到
* 使
* ZLMediaKit是同步对帧数据进行使用和处理的
*
* Frame::getCacheAbleFrame方法拷贝一个可缓存的帧
*/
class FrameNoCacheAble : public FrameFromPtr{
public:
typedef std::shared_ptr<FrameNoCacheAble> Ptr;
/**
*
* @return
*/
bool cacheAble() const override {
return false;
}
};
/**
*
* @see FrameNoCacheAble
*/
class FrameCacheAble : public FrameFromPtr {
public:
typedef std::shared_ptr<FrameCacheAble> Ptr;
FrameCacheAble(const Frame::Ptr &frame){
if(frame->cacheAble()){
_frame = frame;
_ptr = frame->data();
}else{
_buffer = std::make_shared<BufferRaw>();
_buffer->assign(frame->data(),frame->size());
_ptr = _buffer->data();
}
_size = frame->size();
_dts = frame->dts();
_pts = frame->pts();
_prefixSize = frame->prefixSize();
_trackType = frame->getTrackType();
_codec = frame->getCodecId();
_key = frame->keyFrame();
_config = frame->configFrame();
}
virtual ~FrameCacheAble() = default;
/**
*
* @return
*/
bool cacheAble() const override {
return true;
}
TrackType getTrackType() const override{
return _trackType;
}
CodecId getCodecId() const override{
return _codec;
}
bool keyFrame() const override{
return _key;
}
bool configFrame() const override{
return _config;
}
private:
Frame::Ptr _frame;
BufferRaw::Ptr _buffer;
TrackType _trackType;
CodecId _codec;
bool _key;
bool _config;
};
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_FRAME_H #endif //ZLMEDIAKIT_FRAME_H

View File

@ -19,76 +19,28 @@ namespace mediakit{
/** /**
* G711帧 * G711帧
*/ */
class G711Frame : public Frame { class G711Frame : public FrameImp {
public: public:
typedef std::shared_ptr<G711Frame> Ptr; G711Frame(){
_codecid = CodecG711A;
char *data() const override{
return (char *)buffer.data();
} }
uint32_t size() const override {
return buffer.size();
}
uint32_t dts() const override {
return timeStamp;
}
uint32_t prefixSize() const override{
return 0;
}
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{
return _codecId;
}
bool keyFrame() const override {
return false;
}
bool configFrame() const override{
return false;
}
public:
CodecId _codecId = CodecG711A;
string buffer;
uint32_t timeStamp;
}; };
class G711FrameNoCacheAble : public FrameNoCacheAble { class G711FrameNoCacheAble : public FrameFromPtr {
public: public:
typedef std::shared_ptr<G711FrameNoCacheAble> Ptr; typedef std::shared_ptr<G711FrameNoCacheAble> Ptr;
//兼容通用接口 G711FrameNoCacheAble(char *ptr,uint32_t size,uint32_t dts, uint32_t pts = 0,int prefix_size = 0){
G711FrameNoCacheAble(char *ptr,uint32_t size,uint32_t dts, uint32_t pts = 0,int prefixeSize = 0){
_ptr = ptr; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
_prefixSize = prefixeSize; _prefix_size = prefix_size;
} }
//兼容通用接口
void setCodec(CodecId codecId){ void setCodec(CodecId codecId){
_codecId = codecId; _codecId = codecId;
} }
G711FrameNoCacheAble(CodecId codecId, char *ptr,uint32_t size,uint32_t dts,int prefixeSize = 0){
_codecId = codecId;
_ptr = ptr;
_size = size;
_dts = dts;
_prefixSize = prefixeSize;
}
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return _codecId; return _codecId;
} }
@ -108,67 +60,18 @@ private:
/** /**
* G711音频通道 * G711音频通道
*/ */
class G711Track : public AudioTrack{ class G711Track : public AudioTrackImp{
public: public:
typedef std::shared_ptr<G711Track> Ptr; typedef std::shared_ptr<G711Track> Ptr;
G711Track(CodecId codecId,int sample_rate, int channels, int sample_bit) : AudioTrackImp(codecId,sample_rate,channels,sample_bit){}
/**
* G711A G711U
*/
G711Track(CodecId codecId,int sample_rate, int channels, int sample_bit){
_codecid = codecId;
_sample_rate = sample_rate;
_channels = channels;
_sample_bit = sample_bit;
}
/**
*
*/
CodecId getCodecId() const override{
return _codecid;
}
/**
*
*/
bool ready() override {
return true;
}
/**
*
*/
int getAudioSampleRate() const override{
return _sample_rate;
}
/**
* 168
*/
int getAudioSampleBit() const override{
return _sample_bit;
}
/**
*
*/
int getAudioChannel() const override{
return _channels;
}
private: private:
//克隆该Track
Track::Ptr clone() override { Track::Ptr clone() override {
return std::make_shared<std::remove_reference<decltype(*this)>::type >(*this); return std::make_shared<std::remove_reference<decltype(*this)>::type >(*this);
} }
//生成sdp //生成sdp
Sdp::Ptr getSdp() override ; Sdp::Ptr getSdp() override ;
private:
CodecId _codecid;
int _sample_rate;
int _channels;
int _sample_bit;
}; };
/** /**
@ -190,27 +93,20 @@ public:
int bitrate = 128) : Sdp(sample_rate,playload_type), _codecId(codecId){ int bitrate = 128) : Sdp(sample_rate,playload_type), _codecId(codecId){
_printer << "m=audio 0 RTP/AVP " << playload_type << "\r\n"; _printer << "m=audio 0 RTP/AVP " << playload_type << "\r\n";
_printer << "a=rtpmap:" << playload_type << (codecId == CodecG711A ? " PCMA/" : " PCMU/") << sample_rate << "/" << channels << "\r\n"; _printer << "a=rtpmap:" << playload_type << (codecId == CodecG711A ? " PCMA/" : " PCMU/") << sample_rate << "/" << channels << "\r\n";
_printer << "a=control:trackID=" << getTrackType() << "\r\n"; _printer << "a=control:trackID=" << (int)TrackAudio << "\r\n";
} }
string getSdp() const override { string getSdp() const override {
return _printer; return _printer;
} }
TrackType getTrackType() const override {
return TrackAudio;
}
CodecId getCodecId() const override { CodecId getCodecId() const override {
return _codecId; return _codecId;
} }
private: private:
_StrPrinter _printer; _StrPrinter _printer;
CodecId _codecId; CodecId _codecId;
}; };
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_G711_H
#endif //ZLMEDIAKIT_AAC_H

View File

@ -20,15 +20,15 @@ G711RtmpDecoder::G711RtmpDecoder(CodecId codecId) {
G711Frame::Ptr G711RtmpDecoder::obtainFrame() { G711Frame::Ptr G711RtmpDecoder::obtainFrame() {
//从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象 //从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象
auto frame = ResourcePoolHelper<G711Frame>::obtainObj(); auto frame = ResourcePoolHelper<G711Frame>::obtainObj();
frame->buffer.clear(); frame->_buffer.clear();
frame->_codecId = _codecId; frame->_codecid = _codecId;
return frame; return frame;
} }
bool G711RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt, bool) { bool G711RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt, bool) {
//拷贝G711负载 //拷贝G711负载
_frame->buffer.assign(pkt->strBuf.data() + 1, pkt->strBuf.size() - 1); _frame->_buffer.assign(pkt->strBuf.data() + 1, pkt->strBuf.size() - 1);
_frame->timeStamp = pkt->timeStamp; _frame->_dts = pkt->timeStamp;
//写入环形缓存 //写入环形缓存
RtmpCodec::inputFrame(_frame); RtmpCodec::inputFrame(_frame);
_frame = obtainFrame(); _frame = obtainFrame();

View File

@ -33,10 +33,6 @@ public:
*/ */
bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override; bool inputRtmp(const RtmpPacket::Ptr &Rtmp, bool key_pos = false) override;
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return _codecId; return _codecId;
} }

View File

@ -20,9 +20,9 @@ G711RtpDecoder::G711RtpDecoder(const Track::Ptr &track){
G711Frame::Ptr G711RtpDecoder::obtainFrame() { G711Frame::Ptr G711RtpDecoder::obtainFrame() {
//从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象 //从缓存池重新申请对象,防止覆盖已经写入环形缓存的对象
auto frame = ResourcePoolHelper<G711Frame>::obtainObj(); auto frame = ResourcePoolHelper<G711Frame>::obtainObj();
frame->buffer.clear(); frame->_buffer.clear();
frame->_codecId = _codecid; frame->_codecid = _codecid;
frame->timeStamp = 0; frame->_dts = 0;
return frame; return frame;
} }
@ -32,17 +32,17 @@ bool G711RtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool) {
// 获取rtp数据 // 获取rtp数据
const char *rtp_packet_buf = rtppack->data() + rtppack->offset; const char *rtp_packet_buf = rtppack->data() + rtppack->offset;
if (rtppack->timeStamp != _frame->timeStamp) { if (rtppack->timeStamp != _frame->_dts) {
//时间戳变更,清空上一帧 //时间戳变更,清空上一帧
onGetG711(_frame); onGetG711(_frame);
} }
//追加数据 //追加数据
_frame->buffer.append(rtp_packet_buf, length); _frame->_buffer.append(rtp_packet_buf, length);
//赋值时间戳 //赋值时间戳
_frame->timeStamp = rtppack->timeStamp; _frame->_dts = rtppack->timeStamp;
if (rtppack->mark || _frame->buffer.size() > 10 * 1024) { if (rtppack->mark || _frame->_buffer.size() > 10 * 1024) {
//标记为mark时或者内存快溢出时我们认为这是该帧最后一个包 //标记为mark时或者内存快溢出时我们认为这是该帧最后一个包
onGetG711(_frame); onGetG711(_frame);
} }
@ -50,7 +50,7 @@ bool G711RtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool) {
} }
void G711RtpDecoder::onGetG711(const G711Frame::Ptr &frame) { void G711RtpDecoder::onGetG711(const G711Frame::Ptr &frame) {
if(!frame->buffer.empty()){ if(!frame->_buffer.empty()){
//写入环形缓存 //写入环形缓存
RtpCodec::inputFrame(frame); RtpCodec::inputFrame(frame);
_frame = obtainFrame(); _frame = obtainFrame();
@ -96,6 +96,3 @@ void G711RtpEncoder::makeG711Rtp(const void *data, unsigned int len, bool mark,
} }
}//namespace mediakit }//namespace mediakit

View File

@ -31,10 +31,6 @@ public:
*/ */
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = false) override; bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = false) override;
TrackType getTrackType() const override{
return TrackAudio;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return _codecid; return _codecid;
} }

View File

@ -25,7 +25,7 @@ void splitH264(const char *ptr, int len, int prefix, const std::function<void(co
/** /**
* 264 * 264
*/ */
class H264Frame : public Frame { class H264Frame : public FrameImp {
public: public:
typedef std::shared_ptr<H264Frame> Ptr; typedef std::shared_ptr<H264Frame> Ptr;
@ -36,30 +36,8 @@ public:
NAL_SEI = 6, NAL_SEI = 6,
} NalType; } NalType;
char *data() const override{ H264Frame(){
return (char *)_buffer.data(); _codecid = CodecH264;
}
uint32_t size() const override {
return _buffer.size();
}
uint32_t dts() const override {
return _dts;
}
uint32_t pts() const override {
return _pts ? _pts : _dts;
}
uint32_t prefixSize() const override{
return _prefix_size;
}
TrackType getTrackType() const override{
return TrackVideo;
}
CodecId getCodecId() const override{
return CodecH264;
} }
bool keyFrame() const override { bool keyFrame() const override {
@ -69,39 +47,27 @@ public:
bool configFrame() const override{ bool configFrame() const override{
switch(H264_TYPE(_buffer[_prefix_size]) ){ switch(H264_TYPE(_buffer[_prefix_size]) ){
case H264Frame::NAL_SPS: case H264Frame::NAL_SPS:
case H264Frame::NAL_PPS: case H264Frame::NAL_PPS:return true;
return true; default:return false;
default:
return false;
} }
} }
public:
uint32_t _dts = 0;
uint32_t _pts = 0;
uint32_t _prefix_size = 4;
string _buffer;
}; };
/** /**
* H264类 * H264类
* Frame类 * Frame类
* DevChannel中有使用 * DevChannel中有使用
*/ */
class H264FrameNoCacheAble : public FrameNoCacheAble { class H264FrameNoCacheAble : public FrameFromPtr {
public: public:
typedef std::shared_ptr<H264FrameNoCacheAble> Ptr; typedef std::shared_ptr<H264FrameNoCacheAble> Ptr;
H264FrameNoCacheAble(char *ptr,uint32_t size,uint32_t dts , uint32_t pts ,int prefixeSize = 4){ H264FrameNoCacheAble(char *ptr,uint32_t size,uint32_t dts , uint32_t pts ,int prefix_size = 4){
_ptr = ptr; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
_pts = pts; _pts = pts;
_prefixSize = prefixeSize; _prefix_size = prefix_size;
}
TrackType getTrackType() const override{
return TrackVideo;
} }
CodecId getCodecId() const override{ CodecId getCodecId() const override{
@ -109,43 +75,18 @@ public:
} }
bool keyFrame() const override { bool keyFrame() const override {
return H264_TYPE(_ptr[_prefixSize]) == H264Frame::NAL_IDR; return H264_TYPE(_ptr[_prefix_size]) == H264Frame::NAL_IDR;
} }
bool configFrame() const override{ bool configFrame() const override{
switch(H264_TYPE(_ptr[_prefixSize])){ switch(H264_TYPE(_ptr[_prefix_size])){
case H264Frame::NAL_SPS: case H264Frame::NAL_SPS:
case H264Frame::NAL_PPS: case H264Frame::NAL_PPS:return true;
return true; default:return false;
default:
return false;
} }
} }
}; };
/**
* H264Frame类中可以有多个帧 0x 00 00 01
* ZLMediaKit会先把这种复合帧split成单个帧然后再处理
* H264FrameSubFrame
*
*/
template<typename Parent>
class FrameInternal : public Parent{
public:
typedef std::shared_ptr<FrameInternal> Ptr;
FrameInternal(const Frame::Ptr &parent_frame,
char *ptr,
uint32_t size,
int prefixeSize) : Parent(ptr,size,parent_frame->dts(),parent_frame->pts(),prefixeSize){
_parent_frame = parent_frame;
}
bool cacheAble() const override {
return _parent_frame->cacheAble();
}
private:
Frame::Ptr _parent_frame;
};
typedef FrameInternal<H264FrameNoCacheAble> H264FrameInternal; typedef FrameInternal<H264FrameNoCacheAble> H264FrameInternal;
/** /**
@ -334,13 +275,11 @@ private:
bool _last_frame_is_idr = false; bool _last_frame_is_idr = false;
}; };
/** /**
* h264类型sdp * h264类型sdp
*/ */
class H264Sdp : public Sdp { class H264Sdp : public Sdp {
public: public:
/** /**
* *
* @param sps 264 sps,0x00000001 * @param sps 264 sps,0x00000001
@ -375,17 +314,13 @@ public:
memset(strTemp, 0, 100); memset(strTemp, 0, 100);
av_base64_encode(strTemp, 100, (uint8_t *) strPPS.data(), strPPS.size()); av_base64_encode(strTemp, 100, (uint8_t *) strPPS.data(), strPPS.size());
_printer << strTemp << "\r\n"; _printer << strTemp << "\r\n";
_printer << "a=control:trackID=" << getTrackType() << "\r\n"; _printer << "a=control:trackID=" << (int)TrackVideo << "\r\n";
} }
string getSdp() const override { string getSdp() const override {
return _printer; return _printer;
} }
TrackType getTrackType() const override {
return TrackVideo;
}
CodecId getCodecId() const override { CodecId getCodecId() const override {
return CodecH264; return CodecH264;
} }
@ -393,8 +328,5 @@ private:
_StrPrinter _printer; _StrPrinter _printer;
}; };
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_H264_H #endif //ZLMEDIAKIT_H264_H

View File

@ -36,10 +36,6 @@ public:
*/ */
bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos = true) override; bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos = true) override;
TrackType getTrackType() const override{
return TrackVideo;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecH264; return CodecH264;
} }

View File

@ -38,10 +38,6 @@ public:
*/ */
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = true) override; bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = true) override;
TrackType getTrackType() const override{
return TrackVideo;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecH264; return CodecH264;
} }

View File

@ -25,7 +25,7 @@ bool getHEVCInfo(const string &strVps, const string &strSps, int &iVideoWidth, i
/** /**
* 265 * 265
*/ */
class H265Frame : public Frame { class H265Frame : public FrameImp {
public: public:
typedef std::shared_ptr<H265Frame> Ptr; typedef std::shared_ptr<H265Frame> Ptr;
@ -60,32 +60,8 @@ public:
NAL_SEI_SUFFIX = 40, NAL_SEI_SUFFIX = 40,
} NaleType; } NaleType;
char *data() const override { H265Frame(){
return (char *) _buffer.data(); _codecid = CodecH265;
}
uint32_t size() const override {
return _buffer.size();
}
uint32_t dts() const override {
return _dts;
}
uint32_t pts() const override {
return _pts ? _pts : _dts;
}
uint32_t prefixSize() const override {
return _prefix_size;
}
TrackType getTrackType() const override {
return TrackVideo;
}
CodecId getCodecId() const override {
return CodecH265;
} }
bool keyFrame() const override { bool keyFrame() const override {
@ -96,39 +72,26 @@ public:
switch(H265_TYPE(_buffer[_prefix_size])){ switch(H265_TYPE(_buffer[_prefix_size])){
case H265Frame::NAL_VPS: case H265Frame::NAL_VPS:
case H265Frame::NAL_SPS: case H265Frame::NAL_SPS:
case H265Frame::NAL_PPS: case H265Frame::NAL_PPS : return true;
return true; default : return false;
default:
return false;
} }
} }
static bool isKeyFrame(int type) { static bool isKeyFrame(int type) {
return type >= NAL_BLA_W_LP && type <= NAL_RSV_IRAP_VCL23; return type >= NAL_BLA_W_LP && type <= NAL_RSV_IRAP_VCL23;
} }
public:
uint32_t _dts = 0;
uint32_t _pts = 0;
uint32_t _prefix_size = 4;
string _buffer;
}; };
class H265FrameNoCacheAble : public FrameFromPtr {
class H265FrameNoCacheAble : public FrameNoCacheAble {
public: public:
typedef std::shared_ptr<H265FrameNoCacheAble> Ptr; typedef std::shared_ptr<H265FrameNoCacheAble> Ptr;
H265FrameNoCacheAble(char *ptr, uint32_t size, uint32_t dts,uint32_t pts, int prefixeSize = 4) { H265FrameNoCacheAble(char *ptr, uint32_t size, uint32_t dts,uint32_t pts, int prefix_size = 4) {
_ptr = ptr; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
_pts = pts; _pts = pts;
_prefixSize = prefixeSize; _prefix_size = prefix_size;
}
TrackType getTrackType() const override {
return TrackVideo;
} }
CodecId getCodecId() const override { CodecId getCodecId() const override {
@ -136,17 +99,15 @@ public:
} }
bool keyFrame() const override { bool keyFrame() const override {
return H265Frame::isKeyFrame(H265_TYPE(((uint8_t *) _ptr)[_prefixSize])); return H265Frame::isKeyFrame(H265_TYPE(((uint8_t *) _ptr)[_prefix_size]));
} }
bool configFrame() const override{ bool configFrame() const override{
switch(H265_TYPE(((uint8_t *) _ptr)[_prefixSize])){ switch(H265_TYPE(((uint8_t *) _ptr)[_prefix_size])){
case H265Frame::NAL_VPS: case H265Frame::NAL_VPS:
case H265Frame::NAL_SPS: case H265Frame::NAL_SPS:
case H265Frame::NAL_PPS: case H265Frame::NAL_PPS:return true;
return true; default:return false;
default:
return false;
} }
} }
}; };
@ -184,7 +145,6 @@ public:
/** /**
* 0x00 00 00 01vps * 0x00 00 00 01vps
* @return
*/ */
const string &getVps() const { const string &getVps() const {
return _vps; return _vps;
@ -192,7 +152,6 @@ public:
/** /**
* 0x00 00 00 01sps * 0x00 00 00 01sps
* @return
*/ */
const string &getSps() const { const string &getSps() const {
return _sps; return _sps;
@ -200,7 +159,6 @@ public:
/** /**
* 0x00 00 00 01pps * 0x00 00 00 01pps
* @return
*/ */
const string &getPps() const { const string &getPps() const {
return _pps; return _pps;
@ -212,7 +170,6 @@ public:
/** /**
* *
* @return
*/ */
int getVideoHeight() const override{ int getVideoHeight() const override{
return _height ; return _height ;
@ -220,7 +177,6 @@ public:
/** /**
* *
* @return
*/ */
int getVideoWidth() const override{ int getVideoWidth() const override{
return _width; return _width;
@ -228,7 +184,6 @@ public:
/** /**
* fps * fps
* @return
*/ */
float getVideoFps() const override{ float getVideoFps() const override{
return _fps; return _fps;
@ -238,7 +193,6 @@ public:
return !_vps.empty() && !_sps.empty() && !_pps.empty(); return !_vps.empty() && !_sps.empty() && !_pps.empty();
} }
/** /**
* ,sps pps * ,sps pps
* @param frame * @param frame
@ -352,15 +306,13 @@ private:
bool _last_frame_is_idr = false; bool _last_frame_is_idr = false;
}; };
/** /**
* h265类型sdp * h265类型sdp
*/ */
class H265Sdp : public Sdp { class H265Sdp : public Sdp {
public: public:
/** /**
* *
* @param sps 265 sps,0x00000001 * @param sps 265 sps,0x00000001
* @param pps 265 pps,0x00000001 * @param pps 265 pps,0x00000001
* @param playload_type rtp playload type 96 * @param playload_type rtp playload type 96
@ -382,17 +334,13 @@ public:
_printer << encodeBase64(strSPS) << "; "; _printer << encodeBase64(strSPS) << "; ";
_printer << "sprop-pps="; _printer << "sprop-pps=";
_printer << encodeBase64(strPPS) << "\r\n"; _printer << encodeBase64(strPPS) << "\r\n";
_printer << "a=control:trackID=" << getTrackType() << "\r\n"; _printer << "a=control:trackID=" << (int)TrackVideo << "\r\n";
} }
string getSdp() const override { string getSdp() const override {
return _printer; return _printer;
} }
TrackType getTrackType() const override {
return TrackVideo;
}
CodecId getCodecId() const override { CodecId getCodecId() const override {
return CodecH265; return CodecH265;
} }
@ -400,9 +348,5 @@ private:
_StrPrinter _printer; _StrPrinter _printer;
}; };
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_H265_H #endif //ZLMEDIAKIT_H265_H

View File

@ -36,10 +36,6 @@ public:
*/ */
bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos = true) override; bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos = true) override;
TrackType getTrackType() const override{
return TrackVideo;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecH265; return CodecH265;
} }

View File

@ -39,10 +39,6 @@ public:
*/ */
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = true) override; bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos = true) override;
TrackType getTrackType() const override{
return TrackVideo;
}
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecH265; return CodecH265;
} }

View File

@ -65,8 +65,6 @@ class VideoTrack : public Track {
public: public:
typedef std::shared_ptr<VideoTrack> Ptr; typedef std::shared_ptr<VideoTrack> Ptr;
TrackType getTrackType() const override { return TrackVideo;};
/** /**
* *
* @return * @return
@ -93,8 +91,6 @@ class AudioTrack : public Track {
public: public:
typedef std::shared_ptr<AudioTrack> Ptr; typedef std::shared_ptr<AudioTrack> Ptr;
TrackType getTrackType() const override { return TrackAudio;};
/** /**
* *
* @return * @return
@ -114,6 +110,64 @@ public:
virtual int getAudioChannel() const {return 0;}; virtual int getAudioChannel() const {return 0;};
}; };
class AudioTrackImp : public AudioTrack{
public:
typedef std::shared_ptr<AudioTrackImp> Ptr;
/**
*
* @param codecId
* @param sample_rate (HZ)
* @param channels
* @param sample_bit 16
*/
AudioTrackImp(CodecId codecId,int sample_rate, int channels, int sample_bit){
_codecid = codecId;
_sample_rate = sample_rate;
_channels = channels;
_sample_bit = sample_bit;
}
/**
*
*/
CodecId getCodecId() const override{
return _codecid;
}
/**
*
*/
bool ready() override {
return true;
}
/**
*
*/
int getAudioSampleRate() const override{
return _sample_rate;
}
/**
* 168
*/
int getAudioSampleBit() const override{
return _sample_bit;
}
/**
*
*/
int getAudioChannel() const override{
return _channels;
}
private:
CodecId _codecid;
int _sample_rate;
int _channels;
int _sample_bit;
};
class TrackSource{ class TrackSource{
public: public:
@ -123,7 +177,6 @@ public:
/** /**
* Track * Track
* @param trackReady Track * @param trackReady Track
* @return
*/ */
virtual vector<Track::Ptr> getTracks(bool trackReady = true) const = 0; virtual vector<Track::Ptr> getTracks(bool trackReady = true) const = 0;
@ -131,7 +184,6 @@ public:
* Track * Track
* @param type track类型 * @param type track类型
* @param trackReady Track * @param trackReady Track
* @return
*/ */
Track::Ptr getTrack(TrackType type , bool trackReady = true) const { Track::Ptr getTrack(TrackType type , bool trackReady = true) const {
auto tracks = getTracks(trackReady); auto tracks = getTracks(trackReady);
@ -145,5 +197,4 @@ public:
}; };
}//namespace mediakit }//namespace mediakit
#endif //ZLMEDIAKIT_TRACK_H #endif //ZLMEDIAKIT_TRACK_H

View File

@ -242,18 +242,6 @@ public:
} }
} }
/**
*
* @return
*/
TrackType getTrackType() const override {
return TrackTitle;
}
/**
* id
* @return
*/
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecInvalid; return CodecInvalid;
} }
@ -266,18 +254,6 @@ public:
VideoMeta(const VideoTrack::Ptr &video,int datarate = 5000); VideoMeta(const VideoTrack::Ptr &video,int datarate = 5000);
virtual ~VideoMeta(){} virtual ~VideoMeta(){}
/**
*
* @return
*/
TrackType getTrackType() const override {
return TrackVideo;
}
/**
* id
* @return
*/
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return _codecId; return _codecId;
} }
@ -294,18 +270,6 @@ public:
virtual ~AudioMeta(){} virtual ~AudioMeta(){}
/**
*
* @return
*/
TrackType getTrackType() const override {
return TrackAudio;
}
/**
* id
* @return
*/
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return _codecId; return _codecId;
} }
@ -317,7 +281,4 @@ private:
uint8_t getAudioRtmpFlags(const Track::Ptr &track); uint8_t getAudioRtmpFlags(const Track::Ptr &track);
}//namespace mediakit }//namespace mediakit
#endif//__rtmp_h
#endif

View File

@ -319,7 +319,9 @@ void RtpProcess::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
WarnP(this) << "audio track change to G711 from codecid:" << getCodecName(_codecid_audio); WarnP(this) << "audio track change to G711 from codecid:" << getCodecName(_codecid_audio);
return; return;
} }
_muxer->inputFrame(std::make_shared<G711FrameNoCacheAble>(codec, (char *) data, bytes, dts)); auto frame = std::make_shared<G711FrameNoCacheAble>((char *) data, bytes, dts);
frame->setCodec(codec);
_muxer->inputFrame(frame);
break; break;
} }
default: default:

View File

@ -263,18 +263,7 @@ public:
string getSdp() const override { string getSdp() const override {
return _printer; return _printer;
} }
/**
*
* @return
*/
TrackType getTrackType() const override {
return TrackTitle;
}
/**
* id
* @return
*/
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecInvalid; return CodecInvalid;
} }
@ -283,5 +272,4 @@ private:
}; };
} //namespace mediakit } //namespace mediakit
#endif //RTSP_RTSP_H_ #endif //RTSP_RTSP_H_