Commit 1e0db964 by xiongziliang

完善Rtmp复用器

parent 186f4e46
...@@ -116,6 +116,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { ...@@ -116,6 +116,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
auto iLen = frame->size() - frame->prefixSize(); auto iLen = frame->size() - frame->prefixSize();
auto type = ((uint8_t*)pcData)[0] & 0x1F; auto type = ((uint8_t*)pcData)[0] & 0x1F;
if(!_gotSpsPps){
//尝试从frame中获取sps pps //尝试从frame中获取sps pps
switch (type){ switch (type){
case 7:{ case 7:{
...@@ -148,10 +149,15 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { ...@@ -148,10 +149,15 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_pps = _track->getPps(); _pps = _track->getPps();
makeVideoConfigPkt(); makeVideoConfigPkt();
} }
}
switch (type){ switch (type){
case 1: case 5:
case 5:{ //在IDR帧之前插入config包
if(_gotSpsPps){
makeVideoConfigPkt();
}
case 1:{
//I or P or B frame //I or P or B frame
int8_t flags = 7; //h.264 int8_t flags = 7; //h.264
bool is_config = false; bool is_config = false;
...@@ -184,6 +190,8 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { ...@@ -184,6 +190,8 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
void H264RtmpEncoder::makeVideoConfigPkt() { void H264RtmpEncoder::makeVideoConfigPkt() {
_gotSpsPps = true;
int8_t flags = 7; //h.264 int8_t flags = 7; //h.264
flags |= (FLV_KEY_FRAME << 4); flags |= (FLV_KEY_FRAME << 4);
bool is_config = true; bool is_config = true;
......
...@@ -93,6 +93,7 @@ private: ...@@ -93,6 +93,7 @@ private:
void makeVideoConfigPkt(); void makeVideoConfigPkt();
private: private:
H264Track::Ptr _track; H264Track::Ptr _track;
bool _gotSpsPps = false;
}; };
}//namespace mediakit }//namespace mediakit
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论