正在显示
2 个修改的文件
包含
12 行增加
和
9 行删除
@@ -353,6 +353,7 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | @@ -353,6 +353,7 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | ||
353 | int ibpframe_size = avs->size() - avs->pos(); | 353 | int ibpframe_size = avs->size() - avs->pos(); |
354 | 354 | ||
355 | // send each frame. | 355 | // send each frame. |
356 | + bool got_sps_pps = false; | ||
356 | while (!avs->empty()) { | 357 | while (!avs->empty()) { |
357 | char* frame = NULL; | 358 | char* frame = NULL; |
358 | int frame_size = 0; | 359 | int frame_size = 0; |
@@ -369,6 +370,8 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | @@ -369,6 +370,8 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | ||
369 | 370 | ||
370 | // for sps | 371 | // for sps |
371 | if (avc->is_sps(frame, frame_size)) { | 372 | if (avc->is_sps(frame, frame_size)) { |
373 | + got_sps_pps = true; | ||
374 | + | ||
372 | std::string sps; | 375 | std::string sps; |
373 | if ((ret = avc->sps_demux(frame, frame_size, sps)) != ERROR_SUCCESS) { | 376 | if ((ret = avc->sps_demux(frame, frame_size, sps)) != ERROR_SUCCESS) { |
374 | return ret; | 377 | return ret; |
@@ -388,6 +391,8 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | @@ -388,6 +391,8 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | ||
388 | 391 | ||
389 | // for pps | 392 | // for pps |
390 | if (avc->is_pps(frame, frame_size)) { | 393 | if (avc->is_pps(frame, frame_size)) { |
394 | + got_sps_pps = true; | ||
395 | + | ||
391 | std::string pps; | 396 | std::string pps; |
392 | if ((ret = avc->pps_demux(frame, frame_size, pps)) != ERROR_SUCCESS) { | 397 | if ((ret = avc->pps_demux(frame, frame_size, pps)) != ERROR_SUCCESS) { |
393 | return ret; | 398 | return ret; |
@@ -404,18 +409,15 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | @@ -404,18 +409,15 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs) | ||
404 | } | 409 | } |
405 | continue; | 410 | continue; |
406 | } | 411 | } |
407 | - | ||
408 | - // regenerat the ibp frame. | ||
409 | - if (!avs->empty()) { | ||
410 | - ibpframe = avs->data() + avs->pos(); | ||
411 | - ibpframe_size = avs->size() - avs->pos(); | ||
412 | - } else { | ||
413 | - srs_info("mpegts: sps/pps frame consumed."); | ||
414 | - return ret; | ||
415 | - } | ||
416 | 412 | ||
417 | break; | 413 | break; |
418 | } | 414 | } |
415 | + | ||
416 | + // not ibp frame, ignore for already sent. | ||
417 | + if (got_sps_pps) { | ||
418 | + srs_info("mpegts: already send the sps/pps."); | ||
419 | + return ret; | ||
420 | + } | ||
419 | 421 | ||
420 | // ibp frame. | 422 | // ibp frame. |
421 | srs_info("mpegts: demux avc ibp frame size=%d, dts=%d", ibpframe_size, dts); | 423 | srs_info("mpegts: demux avc ibp frame size=%d, dts=%d", ibpframe_size, dts); |
@@ -103,6 +103,7 @@ int SrsFlvEncoder::write_header(char flv_header[9]) | @@ -103,6 +103,7 @@ int SrsFlvEncoder::write_header(char flv_header[9]) | ||
103 | return ret; | 103 | return ret; |
104 | } | 104 | } |
105 | 105 | ||
106 | + // previous tag size. | ||
106 | char pts[] = { (char)0x00, (char)0x00, (char)0x00, (char)0x00 }; | 107 | char pts[] = { (char)0x00, (char)0x00, (char)0x00, (char)0x00 }; |
107 | if ((ret = _fs->write(pts, 4, NULL)) != ERROR_SUCCESS) { | 108 | if ((ret = _fs->write(pts, 4, NULL)) != ERROR_SUCCESS) { |
108 | return ret; | 109 | return ret; |
-
请 注册 或 登录 后发表评论