Commit adfef28c authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Send PLI on VP8 decoding errors.

parent ede0855b
......@@ -179,11 +179,13 @@ typedef enum _MSRecorderState MSRecorderState;
/** Interface definitions for video decoders */
#define MS_VIDEO_DECODER_DECODING_ERRORS \
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,0)
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,0)
#define MS_VIDEO_DECODER_FIRST_IMAGE_DECODED \
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,1)
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,1)
#define MS_VIDEO_DECODER_SEND_PLI \
MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface, 2)
#define MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION \
MS_FILTER_METHOD_NO_ARG(MSFilterVideoDecoderInterface, 0)
MS_FILTER_METHOD_NO_ARG(MSFilterVideoDecoderInterface, 0)
/** Interface definitions for video capture */
#define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \
......
......@@ -434,7 +434,7 @@ static void dec_init(MSFilter *f) {
if(vpx_codec_dec_init(&s->codec, interface, NULL, flags))
ms_error("Failed to initialize decoder");
vp8rtpfmt_unpacker_init(&s->unpacker);
vp8rtpfmt_unpacker_init(&s->unpacker, f);
s->curframe = NULL;
s->last_error_reported_time = 0;
s->yuv_width = 0;
......
......@@ -23,7 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "vp8rtpfmt.h"
#define VP8RTPFMT_DEBUG
//#define VP8RTPFMT_DEBUG
#define VP8RTPFMT_OUTPUT_INCOMPLETE_FRAMES
#ifdef VP8RTPFMT_DEBUG
......@@ -318,6 +319,7 @@ static void output_valid_partitions(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out) {
frame->outputted = TRUE;
} else if (is_frame_marker_present(frame) == TRUE) {
if (is_first_partition_present_in_frame(frame) == TRUE) {
#ifdef VP8RTPFMT_OUTPUT_INCOMPLETE_FRAMES
/* Output the valid partitions of the frame. */
nb_partitions = ms_list_size(frame->partitions_list);
for (i = 0; i < nb_partitions; i++) {
......@@ -330,17 +332,24 @@ static void output_valid_partitions(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out) {
}
}
frame->outputted = TRUE;
#else
/* Drop the frame for which some partitions are missing/invalid. */
frame->discarded = TRUE;
#endif
ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_SEND_PLI);
} else {
/* Drop the frame for which the first partition is missing. */
ms_error("VP8 frame without first partition.");
ms_warning("VP8 frame without first partition.");
frame->discarded = TRUE;
ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_SEND_PLI);
}
} else {
/* The last packet of the frame has not been received.
* Wait for the next iteration of the filter to see if we have it then. */
ms_error("VP8 frame without last packet.");
ms_warning("VP8 frame without last packet.");
// TODO: Try to get the missing packets at the next iteration of the filter.
frame->discarded = TRUE;
ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_SEND_PLI);
}
}
}
......@@ -431,7 +440,8 @@ static Vp8RtpFmtErrorCode parse_payload_descriptor(Vp8RtpFmtPacket *packet) {
}
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx) {
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f) {
ctx->filter = f;
ctx->frames_list = NULL;
ms_queue_init(&ctx->output_queue);
ctx->initialized_last_ts = FALSE;
......@@ -475,7 +485,7 @@ void vp8rtpfmt_unpacker_process(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *inout) {
ms_list_free(ctx->frames_list);
ctx->frames_list = NULL;
} else {
ms_error("VP8 frames are remaining for next iteration of the filter.");
ms_message("VP8 frames are remaining for next iteration of the filter.");
}
}
......
......@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VP8RTPFMT_H
#include <mediastreamer2/mscommon.h>
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msqueue.h>
/**
......@@ -85,6 +86,7 @@ extern "C"{
typedef struct Vp8RtpFmtUnpackerCtx {
MSFilter *filter;
MSList *frames_list;
MSQueue output_queue;
uint32_t last_ts;
......@@ -103,7 +105,7 @@ extern "C"{
void vp8rtpfmt_packer_uninit(Vp8RtpFmtPackerCtx *ctx);
void vp8rtpfmt_packer_process(Vp8RtpFmtPackerCtx *ctx, MSList *in);
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx);
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f);
void vp8rtpfmt_unpacker_uninit(Vp8RtpFmtUnpackerCtx *ctx);
void vp8rtpfmt_unpacker_process(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *inout);
uint32_t vp8rtpfmt_unpacker_calc_extended_cseq(Vp8RtpFmtUnpackerCtx *ctx, uint16_t cseq);
......
......@@ -527,6 +527,10 @@ static void video_stream_event_cb(void *user_pointer, const MSFilter *f, const u
ms_warning("Video decoding error");
video_stream_send_pli(md->video);
break;
case MS_VIDEO_DECODER_SEND_PLI:
ms_message("Send PLI");
video_stream_send_pli(md->video);
break;
case MS_VIDEO_DECODER_FIRST_IMAGE_DECODED:
ms_message("First video frame decoded successfully");
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment