mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
删除冗余设计
This commit is contained in:
parent
8b23f01509
commit
761a665b1b
@ -40,8 +40,6 @@ AACFrame::Ptr AACRtmpDecoder::obtainFrame() {
|
||||
}
|
||||
|
||||
bool AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt, bool key_pos) {
|
||||
RtmpCodec::inputRtmp(pkt, false);
|
||||
|
||||
if (pkt->isCfgFrame()) {
|
||||
_aac_cfg = pkt->getAacCfg();
|
||||
return false;
|
||||
@ -79,8 +77,6 @@ AACRtmpEncoder::AACRtmpEncoder(const Track::Ptr &track) {
|
||||
}
|
||||
|
||||
void AACRtmpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
RtmpCodec::inputFrame(frame);
|
||||
|
||||
if(_aac_cfg.empty()){
|
||||
if(frame->prefixSize() >= 7){
|
||||
//包含adts头,从adts头获取aac配置信息
|
||||
|
@ -40,8 +40,6 @@ AACRtpEncoder::AACRtpEncoder(uint32_t ui32Ssrc,
|
||||
}
|
||||
|
||||
void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
RtpCodec::inputFrame(frame);
|
||||
|
||||
GET_CONFIG(uint32_t, cycleMS, Rtp::kCycleMS);
|
||||
auto uiStamp = frame->stamp();
|
||||
auto pcData = frame->data() + frame->prefixSize();
|
||||
@ -102,8 +100,6 @@ AACFrame::Ptr AACRtpDecoder::obtainFrame() {
|
||||
}
|
||||
|
||||
bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
|
||||
RtpCodec::inputRtp(rtppack, false);
|
||||
|
||||
// 获取rtp数据长度
|
||||
int length = rtppack->size() - rtppack->offset;
|
||||
|
||||
|
@ -41,9 +41,7 @@ H264Frame::Ptr H264RtmpDecoder::obtainFrame() {
|
||||
}
|
||||
|
||||
bool H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) {
|
||||
key_pos = decodeRtmp(rtmp);
|
||||
RtmpCodec::inputRtmp(rtmp, key_pos);
|
||||
return key_pos;
|
||||
return decodeRtmp(rtmp);
|
||||
}
|
||||
|
||||
bool H264RtmpDecoder::decodeRtmp(const RtmpPacket::Ptr &pkt) {
|
||||
@ -105,8 +103,6 @@ H264RtmpEncoder::H264RtmpEncoder(const Track::Ptr &track) {
|
||||
}
|
||||
|
||||
void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
RtmpCodec::inputFrame(frame);
|
||||
|
||||
auto pcData = frame->data() + frame->prefixSize();
|
||||
auto iLen = frame->size() - frame->prefixSize();
|
||||
auto type = H264_TYPE(((uint8_t*)pcData)[0]);
|
||||
|
@ -76,9 +76,7 @@ H264Frame::Ptr H264RtpDecoder::obtainFrame() {
|
||||
}
|
||||
|
||||
bool H264RtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) {
|
||||
key_pos = decodeRtp(rtp);
|
||||
RtpCodec::inputRtp(rtp, key_pos);
|
||||
return key_pos;
|
||||
return decodeRtp(rtp);
|
||||
}
|
||||
|
||||
bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
|
||||
@ -232,8 +230,6 @@ H264RtpEncoder::H264RtpEncoder(uint32_t ui32Ssrc,
|
||||
}
|
||||
|
||||
void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
RtpCodec::inputFrame(frame);
|
||||
|
||||
GET_CONFIG(uint32_t,cycleMS,Rtp::kCycleMS);
|
||||
auto pcData = frame->data() + frame->prefixSize();
|
||||
auto uiStamp = frame->stamp();
|
||||
|
@ -76,9 +76,7 @@ H265Frame::Ptr H265RtpDecoder::obtainFrame() {
|
||||
}
|
||||
|
||||
bool H265RtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) {
|
||||
key_pos = decodeRtp(rtp);
|
||||
RtpCodec::inputRtp(rtp, key_pos);
|
||||
return key_pos;
|
||||
return decodeRtp(rtp);
|
||||
}
|
||||
|
||||
bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
|
||||
@ -167,8 +165,6 @@ H265RtpEncoder::H265RtpEncoder(uint32_t ui32Ssrc,
|
||||
}
|
||||
|
||||
void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
RtpCodec::inputFrame(frame);
|
||||
|
||||
GET_CONFIG(uint32_t,cycleMS,Rtp::kCycleMS);
|
||||
uint8_t *pcData = (uint8_t*)frame->data() + frame->prefixSize();
|
||||
auto uiStamp = frame->stamp();
|
||||
|
@ -34,25 +34,29 @@ using namespace toolkit;
|
||||
|
||||
namespace mediakit{
|
||||
|
||||
class RtmpRingInterface {
|
||||
class RtmpRing{
|
||||
public:
|
||||
typedef std::shared_ptr<RtmpRing> Ptr;
|
||||
typedef RingBuffer<RtmpPacket::Ptr> RingType;
|
||||
typedef std::shared_ptr<RtmpRingInterface> Ptr;
|
||||
|
||||
RtmpRingInterface(){}
|
||||
virtual ~RtmpRingInterface(){}
|
||||
RtmpRing(){}
|
||||
virtual ~RtmpRing(){}
|
||||
|
||||
/**
|
||||
* 获取rtmp环形缓存
|
||||
* @return
|
||||
*/
|
||||
virtual RingType::Ptr getRtmpRing() const = 0;
|
||||
virtual RingType::Ptr getRtmpRing() const{
|
||||
return _rtmpRing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置rtmp环形缓存
|
||||
* @param ring
|
||||
*/
|
||||
virtual void setRtmpRing(const RingType::Ptr &ring) = 0;
|
||||
virtual void setRtmpRing(const RingType::Ptr &ring){
|
||||
_rtmpRing = ring;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入rtmp包
|
||||
@ -60,26 +64,7 @@ public:
|
||||
* @param key_pos 是否为关键帧
|
||||
* @return 是否为关键帧
|
||||
*/
|
||||
virtual bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) = 0;
|
||||
};
|
||||
|
||||
class RtmpRing : public RtmpRingInterface {
|
||||
public:
|
||||
typedef std::shared_ptr<RtmpRing> Ptr;
|
||||
|
||||
RtmpRing(){
|
||||
}
|
||||
virtual ~RtmpRing(){}
|
||||
|
||||
RingType::Ptr getRtmpRing() const override {
|
||||
return _rtmpRing;
|
||||
}
|
||||
|
||||
void setRtmpRing(const RingType::Ptr &ring) override {
|
||||
_rtmpRing = ring;
|
||||
}
|
||||
|
||||
bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) override{
|
||||
virtual bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos){
|
||||
if(_rtmpRing){
|
||||
_rtmpRing->write(rtmp,key_pos);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ RtmpMuxer::RtmpMuxer(const TitleMeta::Ptr &title) {
|
||||
}else{
|
||||
_metadata = title->getMetadata();
|
||||
}
|
||||
_rtmpRing = std::make_shared<RtmpRingInterface::RingType>();
|
||||
_rtmpRing = std::make_shared<RtmpRing::RingType>();
|
||||
}
|
||||
|
||||
void RtmpMuxer::addTrack(const Track::Ptr &track) {
|
||||
@ -82,7 +82,7 @@ const AMFValue &RtmpMuxer::getMetadata() const {
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
RtmpRingInterface::RingType::Ptr RtmpMuxer::getRtmpRing() const {
|
||||
RtmpRing::RingType::Ptr RtmpMuxer::getRtmpRing() const {
|
||||
return _rtmpRing;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
* 获取rtmp环形缓存
|
||||
* @return
|
||||
*/
|
||||
RtmpRingInterface::RingType::Ptr getRtmpRing() const;
|
||||
RtmpRing::RingType::Ptr getRtmpRing() const;
|
||||
|
||||
/**
|
||||
* 添加ready状态的track
|
||||
@ -72,7 +72,7 @@ public:
|
||||
*/
|
||||
void resetTracks() override ;
|
||||
private:
|
||||
RtmpRingInterface::RingType::Ptr _rtmpRing;
|
||||
RtmpRing::RingType::Ptr _rtmpRing;
|
||||
AMFValue _metadata;
|
||||
RtmpCodec::Ptr _encoder[TrackMax];
|
||||
};
|
||||
|
@ -34,25 +34,29 @@ using namespace toolkit;
|
||||
|
||||
namespace mediakit{
|
||||
|
||||
class RtpRingInterface {
|
||||
class RtpRing{
|
||||
public:
|
||||
typedef std::shared_ptr<RtpRing> Ptr;
|
||||
typedef RingBuffer<RtpPacket::Ptr> RingType;
|
||||
typedef std::shared_ptr<RtpRingInterface> Ptr;
|
||||
|
||||
RtpRingInterface(){}
|
||||
virtual ~RtpRingInterface(){}
|
||||
RtpRing(){}
|
||||
virtual ~RtpRing(){}
|
||||
|
||||
/**
|
||||
* 获取rtp环形缓存
|
||||
* @return
|
||||
*/
|
||||
virtual RingType::Ptr getRtpRing() const = 0;
|
||||
virtual RingType::Ptr getRtpRing() const {
|
||||
return _rtpRing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置rtp环形缓存
|
||||
* @param ring
|
||||
*/
|
||||
virtual void setRtpRing(const RingType::Ptr &ring) = 0;
|
||||
virtual void setRtpRing(const RingType::Ptr &ring){
|
||||
_rtpRing = ring;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入rtp包
|
||||
@ -60,26 +64,7 @@ public:
|
||||
* @param key_pos 是否为关键帧第一个rtp包
|
||||
* @return 是否为关键帧第一个rtp包
|
||||
*/
|
||||
virtual bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) = 0;
|
||||
};
|
||||
|
||||
class RtpRing : public RtpRingInterface {
|
||||
public:
|
||||
typedef std::shared_ptr<RtpRing> Ptr;
|
||||
|
||||
RtpRing(){
|
||||
}
|
||||
virtual ~RtpRing(){}
|
||||
|
||||
RingType::Ptr getRtpRing() const override {
|
||||
return _rtpRing;
|
||||
}
|
||||
|
||||
void setRtpRing(const RingType::Ptr &ring) override {
|
||||
_rtpRing = ring;
|
||||
}
|
||||
|
||||
bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) override{
|
||||
virtual bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos){
|
||||
if(_rtpRing){
|
||||
_rtpRing->write(rtp,key_pos);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title){
|
||||
} else{
|
||||
_sdp = title->getSdp();
|
||||
}
|
||||
_rtpRing = std::make_shared<RtpRingInterface::RingType>();
|
||||
_rtpRing = std::make_shared<RtpRing::RingType>();
|
||||
}
|
||||
|
||||
void RtspMuxer::addTrack(const Track::Ptr &track) {
|
||||
@ -69,7 +69,7 @@ string RtspMuxer::getSdp() {
|
||||
return _sdp;
|
||||
}
|
||||
|
||||
RtpRingInterface::RingType::Ptr RtspMuxer::getRtpRing() const {
|
||||
RtpRing::RingType::Ptr RtspMuxer::getRtpRing() const {
|
||||
return _rtpRing;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
* 获取rtp环形缓存
|
||||
* @return
|
||||
*/
|
||||
RtpRingInterface::RingType::Ptr getRtpRing() const;
|
||||
RtpRing::RingType::Ptr getRtpRing() const;
|
||||
|
||||
/**
|
||||
* 添加ready状态的track
|
||||
@ -76,7 +76,7 @@ public:
|
||||
private:
|
||||
string _sdp;
|
||||
RtpCodec::Ptr _encoder[TrackMax];
|
||||
RtpRingInterface::RingType::Ptr _rtpRing;
|
||||
RtpRing::RingType::Ptr _rtpRing;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user