mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
FS-7517 FS-7519 add H264 STAP-A packetizing support so it would work with FireFox
This commit is contained in:
parent
5734b9b2ce
commit
8f7c2f9ed9
@ -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);
|
||||
} 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 {
|
||||
switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes));
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
size = switch_buffer_write(buffer, sync_bytes, sizeof(sync_bytes));
|
||||
size = switch_buffer_write(buffer, frame->data, frame->datalen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user