正在显示
1 个修改的文件
包含
14 行增加
和
0 行删除
| @@ -1366,6 +1366,11 @@ int srs_write_h264_raw_frame(Context* context, | @@ -1366,6 +1366,11 @@ int srs_write_h264_raw_frame(Context* context, | ||
| 1366 | char* frame, int frame_size, u_int32_t dts, u_int32_t pts | 1366 | char* frame, int frame_size, u_int32_t dts, u_int32_t pts |
| 1367 | ) { | 1367 | ) { |
| 1368 | int ret = ERROR_SUCCESS; | 1368 | int ret = ERROR_SUCCESS; |
| 1369 | + | ||
| 1370 | + // empty frame. | ||
| 1371 | + if (frame_size <= 0) { | ||
| 1372 | + return ret; | ||
| 1373 | + } | ||
| 1369 | 1374 | ||
| 1370 | // for sps | 1375 | // for sps |
| 1371 | if (context->avc_raw.is_sps(frame, frame_size)) { | 1376 | if (context->avc_raw.is_sps(frame, frame_size)) { |
| @@ -1399,6 +1404,15 @@ int srs_write_h264_raw_frame(Context* context, | @@ -1399,6 +1404,15 @@ int srs_write_h264_raw_frame(Context* context, | ||
| 1399 | return ret; | 1404 | return ret; |
| 1400 | } | 1405 | } |
| 1401 | 1406 | ||
| 1407 | + // ignore others. | ||
| 1408 | + // 5bits, 7.3.1 NAL unit syntax, | ||
| 1409 | + // H.264-AVC-ISO_IEC_14496-10.pdf, page 44. | ||
| 1410 | + // 7: SPS, 8: PPS, 5: I Frame, 1: P Frame | ||
| 1411 | + SrsAvcNaluType nut = (SrsAvcNaluType)(frame[0] & 0x1f); | ||
| 1412 | + if (nut != SrsAvcNaluTypeSPS && nut != SrsAvcNaluTypePPS && nut != SrsAvcNaluTypeIDR && nut != SrsAvcNaluTypeNonIDR) { | ||
| 1413 | + return ret; | ||
| 1414 | + } | ||
| 1415 | + | ||
| 1402 | // send pps+sps before ipb frames when sps/pps changed. | 1416 | // send pps+sps before ipb frames when sps/pps changed. |
| 1403 | if ((ret = srs_write_h264_sps_pps(context, dts, pts)) != ERROR_SUCCESS) { | 1417 | if ((ret = srs_write_h264_sps_pps(context, dts, pts)) != ERROR_SUCCESS) { |
| 1404 | return ret; | 1418 | return ret; |
-
请 注册 或 登录 后发表评论