合并pr: #1391
This commit is contained in:
parent
96061f1d36
commit
bc583e80b5
|
|
@ -122,11 +122,12 @@ RtpCodec::Ptr Factory::getRtpEncoderBySdp(const Sdp::Ptr &sdp) {
|
||||||
case CodecL16 :
|
case CodecL16 :
|
||||||
case CodecOpus : return std::make_shared<CommonRtpEncoder>(codec_id, ssrc, mtu, sample_rate, pt, interleaved);
|
case CodecOpus : return std::make_shared<CommonRtpEncoder>(codec_id, ssrc, mtu, sample_rate, pt, interleaved);
|
||||||
case CodecG711A :
|
case CodecG711A :
|
||||||
case CodecG711U :
|
case CodecG711U : {
|
||||||
if (pt == Rtsp::PT_PCMA || pt == Rtsp::PT_PCMU) {
|
if (pt == Rtsp::PT_PCMA || pt == Rtsp::PT_PCMU) {
|
||||||
return std::make_shared<G711RtpEncoder>(codec_id, ssrc, mtu, sample_rate, pt, interleaved, 1);
|
return std::make_shared<G711RtpEncoder>(codec_id, ssrc, mtu, sample_rate, pt, interleaved, 1);
|
||||||
}
|
}
|
||||||
return std::make_shared<CommonRtpEncoder>(codec_id, ssrc, mtu, sample_rate, pt, interleaved);
|
return std::make_shared<CommonRtpEncoder>(codec_id, ssrc, mtu, sample_rate, pt, interleaved);
|
||||||
|
}
|
||||||
default : WarnL << "暂不支持该CodecId:" << codec_id; return nullptr;
|
default : WarnL << "暂不支持该CodecId:" << codec_id; return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
#include "G711Rtp.h"
|
#include "G711Rtp.h"
|
||||||
|
|
||||||
G711RtpEncoder::G711RtpEncoder(CodecId codec, uint32_t ssrc, uint32_t mtu_size,
|
namespace mediakit {
|
||||||
uint32_t sample_rate, uint8_t payload_type, uint8_t interleaved,uint32_t channels)
|
|
||||||
: CommonRtpDecoder(codec), RtpInfo(ssrc, mtu_size, sample_rate, payload_type, interleaved) {
|
G711RtpEncoder::G711RtpEncoder(
|
||||||
|
CodecId codec, uint32_t ssrc, uint32_t mtu_size, uint32_t sample_rate, uint8_t payload_type, uint8_t interleaved,
|
||||||
|
uint32_t channels)
|
||||||
|
: CommonRtpDecoder(codec)
|
||||||
|
, RtpInfo(ssrc, mtu_size, sample_rate, payload_type, interleaved) {
|
||||||
_cache_frame = FrameImp::create();
|
_cache_frame = FrameImp::create();
|
||||||
_cache_frame->_codec_id = codec;
|
_cache_frame->_codec_id = codec;
|
||||||
_channels = channels;
|
_channels = channels;
|
||||||
|
|
@ -44,3 +48,5 @@ bool G711RtpEncoder::inputFrame(const Frame::Ptr &frame){
|
||||||
_cache_frame->_pts += 20 * n;
|
_cache_frame->_pts += 20 * n;
|
||||||
return len > 0;
|
return len > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace mediakit
|
||||||
|
|
@ -17,15 +17,14 @@
|
||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* G711 rtp编码类
|
* G711 rtp编码类
|
||||||
*/
|
*/
|
||||||
class G711RtpEncoder : public CommonRtpDecoder, public RtpInfo {
|
class G711RtpEncoder : public CommonRtpDecoder, public RtpInfo {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr <G711RtpEncoder> Ptr;
|
using Ptr = std::shared_ptr<G711RtpEncoder>;
|
||||||
|
|
||||||
~G711RtpEncoder() override {}
|
~G711RtpEncoder() override = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造函数
|
* 构造函数
|
||||||
|
|
@ -36,15 +35,17 @@ public:
|
||||||
* @param payload_type pt类型
|
* @param payload_type pt类型
|
||||||
* @param interleaved rtsp interleaved 值
|
* @param interleaved rtsp interleaved 值
|
||||||
*/
|
*/
|
||||||
G711RtpEncoder(CodecId codec, uint32_t ssrc, uint32_t mtu_size, uint32_t sample_rate, uint8_t payload_type, uint8_t interleaved,uint32_t channels);
|
G711RtpEncoder(CodecId codec, uint32_t ssrc, uint32_t mtu_size, uint32_t sample_rate, uint8_t payload_type,
|
||||||
|
uint8_t interleaved, uint32_t channels);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输入帧数据并编码成rtp
|
* 输入帧数据并编码成rtp
|
||||||
*/
|
*/
|
||||||
bool inputFrame(const Frame::Ptr &frame) override;
|
bool inputFrame(const Frame::Ptr &frame) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FrameImp::Ptr _cache_frame;
|
|
||||||
uint32_t _channels = 1;
|
uint32_t _channels = 1;
|
||||||
|
FrameImp::Ptr _cache_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue