提交 8f7c2f9e authored 作者: Seven Du's avatar Seven Du

FS-7517 FS-7519 add H264 STAP-A packetizing support so it would work with FireFox

上级 5734b9b2
...@@ -187,6 +187,36 @@ static switch_status_t buffer_h264_nalu(h264_codec_context_t *context, switch_fr ...@@ -187,6 +187,36 @@ static switch_status_t buffer_h264_nalu(h264_codec_context_t *context, switch_fr
} }
switch_buffer_write(buffer, (void *)(data + 2), frame->datalen - 2); switch_buffer_write(buffer, (void *)(data + 2), frame->datalen - 2);
} else if (nalu_type == 24) { // 0x18 STAP-A
uint16_t nalu_size;
int left = frame->datalen - 1;
data++;
again:
if (left > 2) {
nalu_size = ntohs(*(uint16_t *)data);
data += 2;
left -= 2;
if (nalu_size > left) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID PACKET\n");
context->got_pps = 0;
switch_buffer_zero(buffer);
return SWITCH_STATUS_FALSE;
}
nalu_hdr = *data;
nalu_type = nalu_hdr & 0x1f;
if (context->got_pps <= 0 && nalu_type == 7) context->got_pps = 1;
switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes));
switch_buffer_write(buffer, (void *)data, nalu_size);
data += nalu_size;
left -= nalu_size;
goto again;
}
} else { } else {
switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes)); switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes));
switch_buffer_write(buffer, frame->data, frame->datalen); switch_buffer_write(buffer, frame->data, frame->datalen);
......
...@@ -246,6 +246,36 @@ static switch_size_t buffer_h264_nalu(h264_codec_context_t *context, switch_fram ...@@ -246,6 +246,36 @@ static switch_size_t buffer_h264_nalu(h264_codec_context_t *context, switch_fram
} }
size = switch_buffer_write(buffer, (void *)(data + 2), frame->datalen - 2); size = switch_buffer_write(buffer, (void *)(data + 2), frame->datalen - 2);
} else if (nalu_type == 24) { // 0x18 STAP-A
uint16_t nalu_size;
int left = frame->datalen - 1;
data++;
again:
if (left > 2) {
nalu_size = ntohs(*(uint16_t *)data);
data += 2;
left -= 2;
if (nalu_size > left) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID PACKET\n");
context->got_sps = 0;
switch_buffer_zero(buffer);
return SWITCH_STATUS_FALSE;
}
nalu_hdr = *data;
nalu_type = nalu_hdr & 0x1f;
if (context->got_sps <= 0 && nalu_type == 7) context->got_sps = 1;
size += switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes));
size += switch_buffer_write(buffer, (void *)data, nalu_size);
data += nalu_size;
left -= nalu_size;
goto again;
}
} else { } else {
size = switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes)); size = switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes));
size = switch_buffer_write(buffer, frame->data, frame->datalen); size = switch_buffer_write(buffer, frame->data, frame->datalen);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论