Commit 62da3247 by xiongziliang

ps rtp推流支持4个字节的头

parent d986b1d3
...@@ -12,20 +12,27 @@ ...@@ -12,20 +12,27 @@
#include "RtpSplitter.h" #include "RtpSplitter.h"
namespace mediakit{ namespace mediakit{
RtpSplitter::RtpSplitter() { RtpSplitter::RtpSplitter() {}
}
RtpSplitter::~RtpSplitter() { RtpSplitter::~RtpSplitter() {}
}
const char *RtpSplitter::onSearchPacketTail(const char *data, int len) { const char *RtpSplitter::onSearchPacketTail(const char *data, int len) {
if (data[0] == '$') {
//可能是4个字节的rtp头
return onSearchPacketTail_l(data + 2, len - 2);
}
//两个字节的rtp头
return onSearchPacketTail_l(data, len);
}
const char *RtpSplitter::onSearchPacketTail_l(const char *data, int len) {
//这是rtp包 //这是rtp包
if(len < 2){ if (len < 2) {
//数据不够 //数据不够
return nullptr; return nullptr;
} }
uint16_t length = (((uint8_t *)data)[0] << 8) | ((uint8_t *)data)[1]; uint16_t length = (((uint8_t *) data)[0] << 8) | ((uint8_t *) data)[1];
if(len < length + 2){ if (len < length + 2) {
//数据不够 //数据不够
return nullptr; return nullptr;
} }
......
...@@ -20,15 +20,16 @@ class RtpSplitter : public HttpRequestSplitter{ ...@@ -20,15 +20,16 @@ class RtpSplitter : public HttpRequestSplitter{
public: public:
RtpSplitter(); RtpSplitter();
virtual ~RtpSplitter(); virtual ~RtpSplitter();
protected: protected:
/** /**
* 收到rtp包回调 * 收到rtp包回调
* @param data
* @param len
*/ */
virtual void onRtpPacket(const char *data,uint64_t len) = 0; virtual void onRtpPacket(const char *data,uint64_t len) = 0;
protected: protected:
const char *onSearchPacketTail(const char *data,int len) override ; const char *onSearchPacketTail(const char *data,int len) override ;
const char *onSearchPacketTail_l(const char *data,int len);
int64_t onRecvHeader(const char *data,uint64_t len) override; int64_t onRecvHeader(const char *data,uint64_t len) override;
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论