mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 22:55:52 +08:00
可自定义codec
This commit is contained in:
parent
7acc2bbbc5
commit
41f1df3acf
@ -16,8 +16,9 @@ using namespace toolkit;
|
|||||||
|
|
||||||
namespace mediakit{
|
namespace mediakit{
|
||||||
|
|
||||||
RtpDecoder::RtpDecoder() {
|
RtpDecoder::RtpDecoder(const char *codec) {
|
||||||
_buffer = std::make_shared<BufferRaw>();
|
_buffer = std::make_shared<BufferRaw>();
|
||||||
|
_codec = codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtpDecoder::~RtpDecoder() {
|
RtpDecoder::~RtpDecoder() {
|
||||||
@ -46,7 +47,7 @@ void RtpDecoder::decodeRtp(const void *data, int bytes) {
|
|||||||
|
|
||||||
uint8_t rtp_type = 0x7F & ((uint8_t *) data)[1];
|
uint8_t rtp_type = 0x7F & ((uint8_t *) data)[1];
|
||||||
InfoL << "rtp type:" << (int) rtp_type;
|
InfoL << "rtp type:" << (int) rtp_type;
|
||||||
_rtp_decoder = rtp_payload_decode_create(rtp_type, "MP2P", &s_func, this);
|
_rtp_decoder = rtp_payload_decode_create(rtp_type, _codec.data(), &s_func, this);
|
||||||
if (!_rtp_decoder) {
|
if (!_rtp_decoder) {
|
||||||
WarnL << "unsupported rtp type:" << (int) rtp_type << ",size:" << bytes << ",hexdump" << hexdump(data, bytes > 16 ? 16 : bytes);
|
WarnL << "unsupported rtp type:" << (int) rtp_type << ",size:" << bytes << ",hexdump" << hexdump(data, bytes > 16 ? 16 : bytes);
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,15 @@ namespace mediakit{
|
|||||||
|
|
||||||
class RtpDecoder {
|
class RtpDecoder {
|
||||||
public:
|
public:
|
||||||
RtpDecoder();
|
RtpDecoder(const char *codec = "MP2P");
|
||||||
virtual ~RtpDecoder();
|
virtual ~RtpDecoder();
|
||||||
protected:
|
|
||||||
void decodeRtp(const void *data, int bytes);
|
void decodeRtp(const void *data, int bytes);
|
||||||
|
protected:
|
||||||
virtual void onRtpDecode(const uint8_t *packet, int bytes, uint32_t timestamp, int flags) = 0;
|
virtual void onRtpDecode(const uint8_t *packet, int bytes, uint32_t timestamp, int flags) = 0;
|
||||||
private:
|
private:
|
||||||
void *_rtp_decoder = nullptr;
|
void *_rtp_decoder = nullptr;
|
||||||
BufferRaw::Ptr _buffer;
|
BufferRaw::Ptr _buffer;
|
||||||
|
string _codec;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
Loading…
Reference in New Issue
Block a user