if (X & 0x30) data++; // T/K
}
- if (S && PID == 0) {
+ if (S && (PID == 0)) {
return __IS_VP8_KEY_FRAME(*data);
} else {
+ if (PID > 0) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PID: %d\n", PID);
return 0;
}
}
uint8_t decoder_init;
switch_buffer_t *vpx_packet_buffer;
int got_key_frame;
- switch_size_t last_received_timestamp;
+ uint32_t last_received_timestamp;
switch_bool_t last_received_complete_picture;
int need_key_frame;
int need_encoder_reset;
if (!switch_buffer_inuse(context->vpx_packet_buffer) && !S) {
if (context->got_key_frame > 0) {
context->got_key_frame = 0;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "packet loss?\n");
}
return SWITCH_STATUS_MORE_DATA;
}
if (S) {
switch_buffer_zero(context->vpx_packet_buffer);
+ context->last_received_timestamp = frame->timestamp;
}
len = frame->datalen - (data - (uint8_t *)frame->data);
return SWITCH_STATUS_RESTART;
}
+ if (context->last_received_timestamp != frame->timestamp) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "wrong timestamp %u, expect %u, packet loss?\n", frame->timestamp, context->last_received_timestamp);
+ switch_buffer_zero(context->vpx_packet_buffer);
+ return SWITCH_STATUS_RESTART;
+ }
+
switch_buffer_write(context->vpx_packet_buffer, data, len);
return SWITCH_STATUS_SUCCESS;
}
is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
}
+ // if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
+
if (context->need_decoder_reset != 0) {
vpx_codec_destroy(&context->decoder);
context->decoder_init = 0;
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "len: %d ts: %u mark:%d\n", frame->datalen, frame->timestamp, frame->m);
- context->last_received_timestamp = frame->timestamp;
+ // context->last_received_timestamp = frame->timestamp;
context->last_received_complete_picture = frame->m ? SWITCH_TRUE : SWITCH_FALSE;
if (is_keyframe) {
}
} else if (context->got_key_frame <= 0) {
if ((--context->got_key_frame % 200) == 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Waiting for key frame\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Waiting for key frame %d\n", context->got_key_frame);
}
switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
}