vp8rtpfmt.c 33.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
vp8rtpfmt.c

mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2011-2012 Belledonne Communications, Grenoble, France

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


#include "vp8rtpfmt.h"

25
#include <limits.h>
26

jehan's avatar
jehan committed
27
/*#define VP8RTPFMT_DEBUG*/
28

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
#define DECLARE_ALIGNED(n,typ,val)  typ val __attribute__ ((aligned (n)))
#elif defined(_MSC_VER)
#define DECLARE_ALIGNED(n,typ,val)  __declspec(align(n)) typ val
#else
#warning No alignment directives known for this compiler.
#define DECLARE_ALIGNED(n,typ,val)  typ val
#endif

typedef size_t VP8_BD_VALUE;

#define VP8_BD_VALUE_SIZE ((int)sizeof(VP8_BD_VALUE)*CHAR_BIT)

#define VP8_LOTS_OF_BITS (0x40000000)

#define MB_LVL_MAX 2
#define MB_FEATURE_TREE_PROBS 3
#define MAX_MB_SEGMENTS 4
#define MAX_REF_LF_DELTAS 4
#define MAX_MODE_LF_DELTAS 4

typedef void (vp8_decrypt_cb)(void *decrypt_state, const unsigned char *input,
                              unsigned char *output, int count);

typedef struct
{
    const unsigned char *user_buffer_end;
    const unsigned char *user_buffer;
    VP8_BD_VALUE         value;
    int                  count;
    unsigned int         range;
    vp8_decrypt_cb      *decrypt_cb;
    void                *decrypt_state;
} BOOL_DECODER;

typedef unsigned char vp8_prob;
#define vp8_prob_half ( (vp8_prob) 128)
#define vp8_read vp8dx_decode_bool
#define vp8_read_literal vp8_decode_value
#define vp8_read_bit(R) vp8_read(R, vp8_prob_half)

Simon Morlat's avatar
Simon Morlat committed
70
DECLARE_ALIGNED(16, static const unsigned char, vp8_norm[256]) =
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
{
    0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

static const int vp8_mb_feature_data_bits[MB_LVL_MAX] = {7, 6};

static void vp8dx_bool_decoder_fill(BOOL_DECODER *br)
{
    const unsigned char *bufptr = br->user_buffer;
    VP8_BD_VALUE value = br->value;
    int count = br->count;
    int shift = VP8_BD_VALUE_SIZE - 8 - (count + 8);
    size_t bytes_left = br->user_buffer_end - bufptr;
    size_t bits_left = bytes_left * CHAR_BIT;
    int x = (int)(shift + CHAR_BIT - bits_left);
    int loop_end = 0;
    unsigned char decrypted[sizeof(VP8_BD_VALUE) + 1];

    if (br->decrypt_cb) {
        size_t n = bytes_left > sizeof(decrypted) ? sizeof(decrypted) : bytes_left;
        br->decrypt_cb(br->decrypt_state, bufptr, decrypted, (int)n);
        bufptr = decrypted;
    }

    if(x >= 0)
    {
        count += VP8_LOTS_OF_BITS;
        loop_end = x;
    }

    if (x < 0 || bits_left)
    {
        while(shift >= loop_end)
        {
            count += CHAR_BIT;
            value |= (VP8_BD_VALUE)*bufptr << shift;
            ++bufptr;
            ++br->user_buffer;
            shift -= CHAR_BIT;
        }
    }

    br->value = value;
    br->count = count;
}

static int vp8dx_start_decode(BOOL_DECODER *br,
                       const unsigned char *source,
                       unsigned int source_sz,
                       vp8_decrypt_cb *decrypt_cb,
                       void *decrypt_state)
{
    br->user_buffer_end = source+source_sz;
    br->user_buffer     = source;
    br->value    = 0;
    br->count    = -8;
    br->range    = 255;
    br->decrypt_cb = decrypt_cb;
    br->decrypt_state = decrypt_state;

    if (source_sz && !source)
        return 1;

    /* Populate the buffer */
    vp8dx_bool_decoder_fill(br);

    return 0;
}

static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
    unsigned int bit = 0;
    VP8_BD_VALUE value;
    unsigned int split;
    VP8_BD_VALUE bigsplit;
    int count;
    unsigned int range;

    split = 1 + (((br->range - 1) * probability) >> 8);

    if(br->count < 0)
        vp8dx_bool_decoder_fill(br);

    value = br->value;
    count = br->count;

    bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);

    range = split;

    if (value >= bigsplit)
    {
        range = br->range - split;
        value = value - bigsplit;
        bit = 1;
    }

    {
        register unsigned int shift = vp8_norm[range];
        range <<= shift;
        value <<= shift;
        count -= shift;
    }
    br->value = value;
    br->count = count;
    br->range = range;

    return bit;
}

static int vp8_decode_value(BOOL_DECODER *br, int bits)
{
    int z = 0;
    int bit;

    for (bit = bits - 1; bit >= 0; bit--)
    {
        z |= (vp8dx_decode_bool(br, 0x80) << bit);
    }

    return z;
}

static mblk_t * concat_packets_of_partition(Vp8RtpFmtPartition *partition) {
	Vp8RtpFmtPacket *packet;
	int nb_packets = ms_list_size(partition->packets_list);
	int i;

	if (partition->m != NULL) return partition->m;
	for (i = 0; i < nb_packets; i++) {
		packet = ms_list_nth_data(partition->packets_list, i);
		if (partition->m == NULL) {
			partition->m = packet->m;
		} else {
			concatb(partition->m, packet->m);
		}
		packet->m = NULL;
	}
	if (partition->m != NULL) {
		msgpullup(partition->m, -1);
	}
	return partition->m;
}

static bool_t parse_frame_header(Vp8RtpFmtFrame *frame) {
	BOOL_DECODER bc;
	mblk_t *m = frame->partitions[0]->m;
	unsigned char *data;
	unsigned char *data_end;
	uint32_t size;
	uint32_t first_partition_length_in_bytes;
	uint32_t partition_size;
	bool_t segmentation_enabled;
	bool_t mode_ref_lf_delta_enabled;
	int i, j;
	int nb_partitions;

	if (m == NULL) {
		m = concat_packets_of_partition(frame->partitions[0]);
	}
	if (m == NULL) return FALSE;
	data = m->b_rptr;
	data_end = m->b_wptr;

	if (msgdsize(m) < 3) return FALSE;
	frame->keyframe = !(data[0] & 1);
	first_partition_length_in_bytes = (data[0] | (data[1] << 8) | (data[2] << 16)) >> 5;
	data += 3;
	if (frame->keyframe) {
		if (msgdsize(m) < 10) return FALSE;
		data += 7;
	}

	size = (unsigned int)(data_end - data);
	if (vp8dx_start_decode(&bc, data, size, NULL, NULL)) return FALSE;
	if (frame->keyframe) {
		(void)vp8_read_bit(&bc); /* color space */
		(void)vp8_read_bit(&bc); /* clamping type */
	}
	segmentation_enabled = vp8_read_bit(&bc);
	if (segmentation_enabled) {
		bool_t update_mb_segmentation_map = (bool_t)vp8_read_bit(&bc);
		bool_t update_mb_segmentation_data = (bool_t)vp8_read_bit(&bc);
		if (update_mb_segmentation_data) {
			(void)vp8_read_bit(&bc); /* segment feature mode */
			for (i = 0; i < MB_LVL_MAX; i++) {
				for (j = 0; j < MAX_MB_SEGMENTS; j++) {
					if (vp8_read_bit(&bc)) {
						(void)vp8_read_literal(&bc, vp8_mb_feature_data_bits[i]);
						(void)vp8_read_bit(&bc); /* sign */
					}
				}
			}
		}
		if (update_mb_segmentation_map) {
			for (i = 0; i < MB_FEATURE_TREE_PROBS; i++) {
				if (vp8_read_bit(&bc))
					(void)vp8_read_literal(&bc, 8);
            }
		}
	}
	(void)vp8_read_bit(&bc); /* filter type */
	(void)vp8_read_literal(&bc, 6); /* filter level */
	(void)vp8_read_literal(&bc, 3); /* sharpness level */
	mode_ref_lf_delta_enabled = (bool_t)vp8_read_bit(&bc);
	if (mode_ref_lf_delta_enabled) {
		bool_t mode_ref_lf_delta_update = (bool_t)vp8_read_bit(&bc);
		if (mode_ref_lf_delta_update) {
			for (i = 0; i < MAX_REF_LF_DELTAS; i++) {
				if (vp8_read_bit(&bc)) {
					(void)vp8_read_literal(&bc, 6);
					(void)vp8_read_bit(&bc); /* sign */
				}
			}
			for (i = 0; i < MAX_MODE_LF_DELTAS; i++) {
				if (vp8_read_bit(&bc)) {
					(void)vp8_read_literal(&bc, 6);
					(void)vp8_read_bit(&bc); /* sign */
				}
			}
		}
	}
	nb_partitions = (1 << vp8_read_literal(&bc, 2));
	if (nb_partitions > 8) return FALSE;
	frame->partitions_info.nb_partitions = nb_partitions;
310
	partition_size = (uint16_t)(data + first_partition_length_in_bytes - m->b_rptr + (3 * (nb_partitions - 1)));
311
	if (msgdsize(m) < partition_size) return FALSE;
312 313 314 315 316 317 318 319 320 321
	frame->partitions_info.partition_sizes[0] = partition_size;
	for (i = 1; i < nb_partitions; i++) {
		const unsigned char *partition_sizes = data + first_partition_length_in_bytes;
		const unsigned char *partition_size_ptr = partition_sizes + (i - 1) * 3;
		frame->partitions_info.partition_sizes[i] = partition_size_ptr[0] + (partition_size_ptr[1] << 8) + (partition_size_ptr[2] << 16);
	}
	return TRUE;
}


322

323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
#ifdef VP8RTPFMT_DEBUG
static uint16_t get_partition_pictureid(Vp8RtpFmtPartition *partition) {
	Vp8RtpFmtPacket *packet = ms_list_nth_data(partition->packets_list, 0);
	return packet->pd->pictureid;
}

static uint8_t get_partition_id(Vp8RtpFmtPartition *partition) {
	Vp8RtpFmtPacket *packet = ms_list_nth_data(partition->packets_list, 0);
	return packet->pd->pid;
}

static int is_partition_non_reference(Vp8RtpFmtPartition *partition) {
	Vp8RtpFmtPacket *packet = ms_list_nth_data(partition->packets_list, 0);
	return packet->pd->non_reference_frame;
}

static uint32_t get_partition_ts(Vp8RtpFmtPartition *partition) {
	return mblk_get_timestamp_info(partition->m);
}

static uint16_t get_frame_pictureid(Vp8RtpFmtFrame *frame) {
344
	return get_partition_pictureid(frame->partitions[0]);
345 346 347
}

static int is_frame_non_reference(Vp8RtpFmtFrame *frame) {
348
	return is_partition_non_reference(frame->partitions[0]);
349 350 351
}

static uint32_t get_frame_ts(Vp8RtpFmtFrame *frame) {
352
	return get_partition_ts(frame->partitions[0]);
353 354 355 356
}

static void print_packet(void *data) {
	Vp8RtpFmtPacket *packet = (Vp8RtpFmtPacket *)data;
Ghislain MARY's avatar
Ghislain MARY committed
357
	ms_message("\t\tS=%d\terror=%d", packet->pd->start_of_partition, packet->error);
358 359
}

360 361
static void print_partition(Vp8RtpFmtPartition *partition) {
	ms_message("\tpartition [%p]:\tpid=%d", partition, get_partition_id(partition));
362 363 364 365
	ms_list_for_each(partition->packets_list, print_packet);
}

static void print_frame(void *data) {
366
	uint8_t i;
367
	Vp8RtpFmtFrame *frame = (Vp8RtpFmtFrame *)data;
368
	ms_message("frame [%p]:\tts=%u\tpictureid=0x%04x\tN=%d\terror=%d",
369
		frame, get_frame_ts(frame), get_frame_pictureid(frame), is_frame_non_reference(frame), frame->error);
Ghislain MARY's avatar
Ghislain MARY committed
370
	for (i = 0; i < frame->partitions_info.nb_partitions; i++) {
371 372
		print_partition(frame->partitions[i]);
	}
373 374 375
}
#endif /* VP8RTPFMT_DEBUG */

376 377
static void free_packet(void *data) {
	Vp8RtpFmtPacket *packet = (Vp8RtpFmtPacket *)data;
378
	if (packet->m != NULL) {
379 380 381 382 383 384
		freemsg(packet->m);
	}
	ms_free(packet->pd);
	ms_free(packet);
}

385
static void free_partition(void *data) {
386
	Vp8RtpFmtPartition *partition = (Vp8RtpFmtPartition *)data;
387
	if ((partition->m != NULL) && (partition->outputted != TRUE)) {
388 389
		freemsg(partition->m);
	}
390 391 392 393
	if (partition->packets_list != NULL) {
		ms_list_for_each(partition->packets_list, free_packet);
		ms_list_free(partition->packets_list);
	}
394 395 396
	ms_free(partition);
}

397 398
static MSVideoSize get_size_from_key_frame(Vp8RtpFmtFrame *frame) {
	MSVideoSize vs;
399
	Vp8RtpFmtPartition *partition = frame->partitions[0];
400 401 402 403 404 405 406
	vs.width = ((partition->m->b_rptr[7] << 8) | (partition->m->b_rptr[6])) & 0x3FFF;
	vs.height = ((partition->m->b_rptr[9] << 8) | (partition->m->b_rptr[8])) & 0x3FFF;
	return vs;
}

static void send_pli(Vp8RtpFmtUnpackerCtx *ctx) {
	if (ctx->avpf_enabled == TRUE) {
407
		if(ctx->filter) ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_SEND_PLI);
408
	} else {
409
		if(ctx->filter) ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_DECODING_ERRORS);
410
		ctx->error_notified = TRUE;
411 412 413
	}
}

414
static void send_sli(Vp8RtpFmtUnpackerCtx *ctx, Vp8RtpFmtFrame *frame) {
415
	if (ctx->avpf_enabled == TRUE) {
416
		if (frame->pictureid_present == TRUE) {
417 418 419
			MSVideoCodecSLI sli;
			sli.first = 0;
			sli.number = (ctx->video_size.width * ctx->video_size.height) / (16 * 16);
420
			sli.picture_id = frame->pictureid & 0x3F;
421
			if(ctx->filter) ms_filter_notify(ctx->filter, MS_VIDEO_DECODER_SEND_SLI, &sli);
422 423
		} else {
			send_pli(ctx);
424 425
		}
	} else {
426
		if(ctx->filter) ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_DECODING_ERRORS);
427
		ctx->error_notified = TRUE;
428 429 430
	}
}

431
void vp8rtpfmt_send_rpsi(Vp8RtpFmtUnpackerCtx *ctx, uint16_t pictureid) {
432
	if (ctx->avpf_enabled == TRUE) {
433 434 435 436 437 438 439 440 441 442 443
		MSVideoCodecRPSI rpsi;
		uint16_t picture_id16;
		uint8_t picture_id8;
		if (pictureid & 0x8000) {
			picture_id16 = htons(pictureid);
			rpsi.bit_string = (uint8_t *)&picture_id16;
			rpsi.bit_string_len = 16;
		} else {
			picture_id8 = pictureid & 0xFF;
			rpsi.bit_string = (uint8_t *)&picture_id8;
			rpsi.bit_string_len = 8;
444
		}
445
		if(ctx->filter) ms_filter_notify(ctx->filter, MS_VIDEO_DECODER_SEND_RPSI, &rpsi);
446 447 448
	}
}

449 450 451 452 453
static Vp8RtpFmtPartition * create_empty_partition(void) {
	Vp8RtpFmtPartition *partition = ms_new0(Vp8RtpFmtPartition, 1);
	partition->m = allocb(0, 0);
	return partition;
}
454

455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
static void add_packet_to_frame(Vp8RtpFmtFrame *frame, Vp8RtpFmtPacket *packet) {
	uint8_t pid = packet->pd->pid;
	Vp8RtpFmtPartition *partition = frame->partitions[pid];
	if (!packet->pd->non_reference_frame) {
		frame->reference = TRUE;
	}
	if (packet->pd->pictureid_present) {
		frame->pictureid_present = TRUE;
		frame->pictureid = packet->pd->pictureid;
	}
	if (partition == NULL) {
		partition = frame->partitions[pid] = ms_new0(Vp8RtpFmtPartition, 1);
		partition->has_start = packet->pd->start_of_partition;
	}
	if (mblk_get_marker_info(packet->m)) {
		partition->has_marker = TRUE;
471
	}
472 473
	partition->packets_list = ms_list_append(partition->packets_list, (void *)packet);
	partition->size += msgdsize(packet->m);
474 475
}

476
static void generate_frame_partitions_list(Vp8RtpFmtFrame *frame, MSList *packets_list) {
477
	Vp8RtpFmtPacket *packet = NULL;
478 479
	MSList *it;
	
480
	frame->unnumbered_partitions = TRUE;
481 482
	for (it=packets_list;it!=NULL;it=it->next) {
		packet = (Vp8RtpFmtPacket *)it->data;
483 484 485 486 487
		if (packet->pd->pid != 0) {
			frame->unnumbered_partitions = FALSE;
			break;
		}
	}
488 489
	for (it=packets_list;it!=NULL;it=it->next) {
		packet = (Vp8RtpFmtPacket *)it->data;
490
		if (packet->error == Vp8RtpFmtOk) {
491
			add_packet_to_frame(frame, packet);
492
		} else {
493 494
			/* Malformed packet, ignore it. */
			free_packet(packet);
495
		}
496
	}
497 498
}

499 500
static void mark_frame_as_invalid(Vp8RtpFmtUnpackerCtx *ctx, Vp8RtpFmtFrame *frame) {
	frame->error = Vp8RtpFmtInvalidFrame;
501 502
	/*even if freeze_on_error is FALSE, if avpf is enabled it is preferable not to output an invalid frame.*/
	if (ctx->freeze_on_error || ctx->avpf_enabled) {
503 504
		ctx->waiting_for_reference_frame = TRUE;
	}
505 506
}

507 508
static void mark_frame_as_incomplete(Vp8RtpFmtUnpackerCtx *ctx, Vp8RtpFmtFrame *frame, uint8_t idx) {
	frame->error = Vp8RtpFmtIncompleteFrame;
509
	if (ctx->freeze_on_error == TRUE) {
510
		ctx->waiting_for_reference_frame = TRUE;
511 512 513
	}
}

Ghislain MARY's avatar
Ghislain MARY committed
514
static void check_frame_partitions_have_start(Vp8RtpFmtUnpackerCtx *ctx, Vp8RtpFmtFrame *frame) {
515 516 517 518 519 520 521 522 523
	Vp8RtpFmtPacket *packet;
	Vp8RtpFmtPartition *partition;
	int i;
	int j;

	if (frame->unnumbered_partitions == TRUE) return;

	for (i = 0; i <= frame->partitions_info.nb_partitions; i++) {
		partition = frame->partitions[i];
524 525
		if (partition == NULL) continue;
		for (j = 0; j < ms_list_size(partition->packets_list); j++) {
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
			packet = (Vp8RtpFmtPacket *)ms_list_nth_data(partition->packets_list, j);
			if ((j == 0) && !partition->has_start && !packet->cseq_inconsistency) {
				/**
				 * We have detected a partition does not start at the beginning of a packet.
				 * Do not output partitions but the entire frame. Also consider frame has
				 * unnumbered partitions to prevent checks on the partitions.
				 * WARNING: This is a workaround because the partitions are now built according
				 * to the partition id of the packet header. However a packet can contain parts of
				 * several partitions. In this case we should split the packet in several parts and
				 * put these parts in the corresponding partitions and check from the partition sizes
				 * that we get from parsing the frame header.
				 */
				frame->unnumbered_partitions = TRUE;
				ctx->output_partitions = FALSE;
			}
		}
	}
}

545
static bool_t has_sequence_inconsistency(const MSList *packets){
546
	Vp8RtpFmtPacket *packet;
547 548 549 550 551 552 553 554 555
	const MSList *elem;
	for(elem=packets;elem!=NULL;elem=elem->next){
		packet=(Vp8RtpFmtPacket*)elem->data;
		if (packet->cseq_inconsistency) return TRUE;
	}
	return FALSE;
}

static void check_frame_partitions_list(Vp8RtpFmtUnpackerCtx *ctx, Vp8RtpFmtFrame *frame) {
556 557 558 559 560 561 562 563 564 565 566
	Vp8RtpFmtPartition *partition;
	int i;

	if (frame->partitions[0] == NULL) {
		mark_frame_as_invalid(ctx, frame);
		return;
	}
	if ((frame->partitions[0] != NULL) && (!frame->partitions[0]->has_start)) {
		mark_frame_as_invalid(ctx, frame);
		return;
	}
567 568
	
	if (has_sequence_inconsistency(frame->partitions[0]->packets_list)) {
569 570 571 572 573 574 575
		mark_frame_as_invalid(ctx, frame);
		return;
	}
	if (parse_frame_header(frame) != TRUE) {
		mark_frame_as_invalid(ctx, frame);
		return;
	}
576

577 578
	check_frame_partitions_have_start(ctx, frame);

579 580 581
	/* Do not try to perform next checks if the partitions are not numbered. */
	if (frame->unnumbered_partitions == TRUE) return;

582 583 584 585 586 587 588 589 590 591 592
	/* The partition 0 has been validated, check the following ones. */
	for (i = 1; i < frame->partitions_info.nb_partitions; i++) {
		partition = frame->partitions[i];
		if (partition == NULL) {
			mark_frame_as_incomplete(ctx, frame, i);
			continue;
		}
		if (partition->size != frame->partitions_info.partition_sizes[i]) {
			mark_frame_as_incomplete(ctx, frame, i);
			continue;
		}
593 594
	}

595
	/* Check the last partition of the frame. */
596 597 598 599
	partition = frame->partitions[frame->partitions_info.nb_partitions];
	if ((partition == NULL) || !partition->has_start || !partition->has_marker) {
		mark_frame_as_incomplete(ctx, frame, frame->partitions_info.nb_partitions);
	} else {
600
		if (has_sequence_inconsistency(partition->packets_list)){
601
			mark_frame_as_incomplete(ctx, frame, frame->partitions_info.nb_partitions);
602 603
		}
	}
604 605
}

606 607 608 609 610 611 612 613 614
static void notify_frame_error_if_any(Vp8RtpFmtUnpackerCtx *ctx, Vp8RtpFmtFrame *frame) {
	switch (frame->error) {
		case Vp8RtpFmtInvalidFrame:
		case Vp8RtpFmtIncompleteFrame:
			send_sli(ctx, frame);
			break;
		case Vp8RtpFmtOk:
		default:
			break;
615 616 617
	}
}

618 619 620 621 622
static void add_frame(Vp8RtpFmtUnpackerCtx *ctx, MSList **packets_list) {
	Vp8RtpFmtFrame *frame;

	if (ms_list_size(*packets_list) > 0) {
		frame = ms_new0(Vp8RtpFmtFrame, 1);
623 624 625 626
		generate_frame_partitions_list(frame, *packets_list);
		check_frame_partitions_list(ctx, frame);
		notify_frame_error_if_any(ctx, frame);
		ctx->frames_list = ms_list_append(ctx->frames_list, (void *)frame);
627
	}
628 629
	ms_list_free(*packets_list);
	*packets_list = NULL;
630 631 632 633 634
}

static void generate_frames_list(Vp8RtpFmtUnpackerCtx *ctx, MSList *packets_list) {
	Vp8RtpFmtPacket *packet;
	MSList *frame_packets_list = NULL;
635
	MSList *it;
636
	uint32_t ts;
637

638
	/* If we have some packets from the previous iteration, put them in the frame_packets_list. */
639 640
	for (it=ctx->non_processed_packets_list; it!=NULL; it=it->next) {
		packet = (Vp8RtpFmtPacket*) it->data;
641 642 643 644 645 646
		frame_packets_list = ms_list_append(frame_packets_list, packet);
	}
	ms_list_free(ctx->non_processed_packets_list);
	ctx->non_processed_packets_list = NULL;

	/* Process newly received packets. */
647 648
	for (it=packets_list; it!=NULL; it=it->next) {
		packet = (Vp8RtpFmtPacket*) it->data;
649 650 651 652 653 654
		ts = mblk_get_timestamp_info(packet->m);

		if ((ctx->initialized_last_ts == TRUE) && (ts != ctx->last_ts)) {
			/* The current packet is from a frame different than the previous one
			* (that apparently is not complete). */
			add_frame(ctx, &frame_packets_list);
655
		}
656 657 658 659 660 661 662 663 664 665 666
		ctx->last_ts = ts;
		ctx->initialized_last_ts = TRUE;

		/* Add the current packet to the current frame. */
		frame_packets_list = ms_list_append(frame_packets_list, packet);

		if (mblk_get_marker_info(packet->m)) {
			/* The current packet is the last of the current frame. */
			add_frame(ctx, &frame_packets_list);
		}
	}
667

668
	/* If some packets are left, put them in a list for next iteration. */
669
	ctx->non_processed_packets_list=frame_packets_list;
670 671
}

672
static void output_frame(MSQueue *out, Vp8RtpFmtFrame *frame) {
673
	Vp8RtpFmtPartition *partition;
674
	mblk_t *om = NULL;
Simon Morlat's avatar
Simon Morlat committed
675
	mblk_t *curm = NULL;
676 677
	int i;

678 679
	for (i = 0; i <= frame->partitions_info.nb_partitions; i++) {
		partition = frame->partitions[i];
680
		if (partition == NULL) continue;
681 682
		if (om == NULL) {
			om = concat_packets_of_partition(partition);
683 684
			curm = om;
		} else {
685
			curm = concatb(curm, concat_packets_of_partition(partition));
686 687 688
		}
		partition->outputted = TRUE;
	}
689
	if (om != NULL) {
690
		if (om->b_cont) msgpullup(om, -1);
691 692 693
		mblk_set_marker_info(om, 1);
		ms_queue_put(out, (void *)om);
	}
694 695
}

696 697 698 699 700 701 702 703 704 705 706 707
static void output_partition(MSQueue *out, Vp8RtpFmtPartition **partition, bool_t last) {
	if (*partition == NULL) {
		*partition = create_empty_partition();
	}
	concat_packets_of_partition(*partition);
	if ((*partition)->has_marker || (last == TRUE)) {
		mblk_set_marker_info((*partition)->m, 1);
	}
	ms_queue_put(out, (void *)(*partition)->m);
	(*partition)->outputted = TRUE;
}

708
static void output_partitions_of_frame(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out, Vp8RtpFmtFrame *frame) {
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723
	int i;
	if (frame->unnumbered_partitions == TRUE) {
		output_frame(out, frame);
	} else {
#ifdef VP8RTPFMT_DEBUG
		if (frame->pictureid_present == TRUE) {
			ms_message("VP8 decoder: Output partitions of frame with pictureID=0x%04x", frame->pictureid);
		}
#endif
		for (i = 0; i <= frame->partitions_info.nb_partitions; i++) {
			output_partition(out, &frame->partitions[i], (i == frame->partitions_info.nb_partitions) ? TRUE : FALSE);
		}
	}
}

724
static int output_valid_partitions(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out) {
725 726 727
	Vp8RtpFmtFrame *frame;
	int nb_frames = ms_list_size(ctx->frames_list);

728
	if (nb_frames == 0) return -1;
729 730 731 732 733 734 735 736
	frame = (Vp8RtpFmtFrame *)ms_list_nth_data(ctx->frames_list, 0);
	switch (frame->error) {
		case Vp8RtpFmtOk:
			if (frame->keyframe == TRUE) {
				ctx->valid_keyframe_received = TRUE;
				ctx->video_size = get_size_from_key_frame(frame);
				ctx->waiting_for_reference_frame = FALSE;
				if (ctx->error_notified == TRUE) {
737
					if(ctx->filter) ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_RECOVERED_FROM_ERRORS);
738
					ctx->error_notified = FALSE;
739
				}
740 741 742 743 744 745 746
			}
			if ((ctx->avpf_enabled == TRUE) && (frame->reference == TRUE)) {
				ctx->waiting_for_reference_frame = FALSE;
			}
			if ((ctx->valid_keyframe_received == TRUE) && (ctx->waiting_for_reference_frame == FALSE)) {
				/* Output the complete valid frame if a reference frame has been received. */
				if (ctx->output_partitions == TRUE) {
747
					output_partitions_of_frame(ctx, out, frame);
748
				} else {
749
					/* Output the full frame in one mblk_t. */
750
					output_frame(out, frame);
751
				}
752 753 754 755 756 757 758 759 760 761
				frame->outputted = TRUE;
			} else {
				frame->discarded = TRUE;
				if (!ctx->valid_keyframe_received) send_pli(ctx);
				if (ctx->waiting_for_reference_frame == TRUE) {
					/* Do not decode frames while we are waiting for a reference frame. */
					if (frame->pictureid_present == TRUE)
						ms_warning("VP8 decoder: Drop frame because we are waiting for reference frame: pictureID=%i", (int)frame->pictureid);
					else
						ms_warning("VP8 decoder: Drop frame because we are waiting for reference frame.");
762
				} else {
763 764
					/* Drop frames until the first keyframe is successfully received. */
					ms_warning("VP8 frame dropped because keyframe has not been received yet.");
765
				}
766 767 768 769 770
			}
			break;
		case Vp8RtpFmtIncompleteFrame:
			if (frame->keyframe == TRUE) {
				/* Incomplete keyframe. */
771
				frame->discarded = TRUE;
772 773
			} else {
				if ((ctx->output_partitions == TRUE) && (ctx->valid_keyframe_received == TRUE) && (ctx->waiting_for_reference_frame == FALSE)) {
774
					output_partitions_of_frame(ctx, out, frame);
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
					frame->outputted = TRUE;
				} else {
					/* Drop the frame for which some partitions are missing/invalid. */
					if (frame->pictureid_present == TRUE)
						ms_warning("VP8 frame with some partitions missing/invalid: pictureID=%i", (int)frame->pictureid);
					else
						ms_warning("VP8 frame with some partitions missing/invalid.");
					frame->discarded = TRUE;
				}
			}
			break;
		default:
			/* Drop the invalid frame. */

			if (frame->pictureid_present == TRUE)
				ms_warning("VP8 invalid frame: pictureID=%i", (int)frame->pictureid);
			else
				ms_warning("VP8 invalid frame.");
			frame->discarded = TRUE;
			break;
795
	}
796

797 798
	if (frame->outputted == TRUE) return 0;
	return -1;
799 800
}

801
static void free_partitions_of_frame(void *data) {
802
	Vp8RtpFmtFrame *frame = (Vp8RtpFmtFrame *)data;
803 804 805 806 807 808
	int i;
	for (i = 0; i < 9; i++) {
		if (frame->partitions[i] != NULL) {
			free_partition(frame->partitions[i]);
			frame->partitions[i] = NULL;
		}
809 810 811
	}
}

812
static void clean_frame(Vp8RtpFmtUnpackerCtx *ctx) {
813
	if (ms_list_size(ctx->frames_list) > 0) {
814 815 816 817
		Vp8RtpFmtFrame *frame = ms_list_nth_data(ctx->frames_list, 0);
		free_partitions_of_frame(frame);
		ctx->frames_list = ms_list_remove(ctx->frames_list, frame);
		ms_free(frame);
818
	}
819 820
}

Ghislain MARY's avatar
Ghislain MARY committed
821 822 823 824 825 826
static void free_frame(void *data) {
	Vp8RtpFmtFrame *frame = (Vp8RtpFmtFrame *)data;
	free_partitions_of_frame(frame);
	ms_free(frame);
}

827 828
static Vp8RtpFmtErrorCode parse_payload_descriptor(Vp8RtpFmtPacket *packet) {
	uint8_t *h = packet->m->b_rptr;
829
	Vp8RtpFmtPayloadDescriptor *pd = packet->pd;
830
	unsigned int packet_size = (unsigned int)(packet->m->b_wptr - packet->m->b_rptr);
831 832 833
	uint8_t offset = 0;

	if (packet_size == 0) return Vp8RtpFmtInvalidPayloadDescriptor;
834

835
	memset(pd, 0, sizeof(Vp8RtpFmtPayloadDescriptor));
836 837

	/* Parse mandatory first octet of payload descriptor. */
838 839 840 841 842 843
	if (h[offset] & (1 << 7)) pd->extended_control_bits_present = TRUE;
	if (h[offset] & (1 << 5)) pd->non_reference_frame = TRUE;
	if (h[offset] & (1 << 4)) pd->start_of_partition = TRUE;
	pd->pid = (h[offset] & 0x07);
	offset++;
	if (offset >= packet_size) return Vp8RtpFmtInvalidPayloadDescriptor;
844 845
	/* Parse the first extension octet if needed. */
	if (pd->extended_control_bits_present == TRUE) {
846 847 848 849
		if (h[offset] & (1 << 7)) pd->pictureid_present = TRUE;
		if (h[offset] & (1 << 6)) pd->tl0picidx_present = TRUE;
		if (h[offset] & (1 << 5)) pd->tid_present = TRUE;
		if (h[offset] & (1 << 4)) pd->keyidx_present = TRUE;
850 851 852 853
		if ((pd->tl0picidx_present == TRUE) && (pd->tid_present != TRUE)) {
			/* Invalid payload descriptor. */
			return Vp8RtpFmtInvalidPayloadDescriptor;
		}
854 855
		offset++;
		if (offset >= packet_size) return Vp8RtpFmtInvalidPayloadDescriptor;
856 857 858
	}
	/* Parse the pictureID if needed. */
	if (pd->pictureid_present == TRUE) {
859
		if (h[offset] & (1 << 7)) {
860
			/* The pictureID is 16 bits long. */
861
			if ((unsigned int)(offset + 1) >= packet_size) return Vp8RtpFmtInvalidPayloadDescriptor;
862 863
			pd->pictureid = (h[offset] << 8) | h[offset + 1];
			offset += 2;
864 865
		} else {
			/* The pictureId is 8 bits long. */
866 867
			pd->pictureid = h[offset];
			offset++;
868
		}
869
		if (offset >= packet_size) return Vp8RtpFmtInvalidPayloadDescriptor;
870 871 872
	}
	/* Parse the tl0picidx if needed. */
	if (pd->tl0picidx_present == TRUE) {
873 874 875
		pd->tl0picidx = h[offset];
		offset++;
		if (offset >= packet_size) return Vp8RtpFmtInvalidPayloadDescriptor;
876 877 878
	}
	/* Parse the tid and/or keyidx if needed. */
	if (pd->tid_present == TRUE) {
879 880
		pd->tid = (h[offset] & 0xC0) >> 6;
		if (h[offset] & (1 << 5)) pd->layer_sync = TRUE;
881 882
	}
	if (pd->keyidx_present == TRUE) {
883
		pd->keyidx = (h[offset] & 0x1F);
884 885
	}
	if ((pd->tid_present == TRUE) || (pd->keyidx_present == TRUE)) {
886 887
		offset++;
		if (offset >= packet_size) return Vp8RtpFmtInvalidPayloadDescriptor;
888 889
	}

890
	packet->m->b_rptr = &h[offset];
891 892 893 894
	return Vp8RtpFmtOk;
}


895
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f, bool_t avpf_enabled, bool_t freeze_on_error, bool_t output_partitions) {
896
	ctx->filter = f;
897
	ctx->frames_list = NULL;
898
	ctx->non_processed_packets_list = NULL;
899
	ctx->avpf_enabled = avpf_enabled;
900
	ctx->freeze_on_error = freeze_on_error;
901 902
	ctx->output_partitions = output_partitions;
	ctx->valid_keyframe_received = FALSE;
903
	ctx->waiting_for_reference_frame = TRUE;
904
	ctx->error_notified = FALSE;
905
	ctx->initialized_last_ts = FALSE;
906 907 908
	ctx->initialized_ref_cseq = FALSE;
}

909
void vp8rtpfmt_unpacker_uninit(Vp8RtpFmtUnpackerCtx *ctx) {
Ghislain MARY's avatar
Ghislain MARY committed
910
	ms_list_for_each(ctx->frames_list, free_frame);
911
	ms_list_free(ctx->frames_list);
Ghislain MARY's avatar
Ghislain MARY committed
912
	ms_list_for_each(ctx->non_processed_packets_list, free_packet);
913
	ms_list_free(ctx->non_processed_packets_list);
914 915
}

916
void vp8rtpfmt_unpacker_feed(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *in) {
917
	MSList *packets_list = NULL;
918 919 920 921
	Vp8RtpFmtPacket *packet;
	mblk_t *m;

#ifdef VP8RTPFMT_DEBUG
922
	ms_message("vp8rtpfmt_unpacker_feed:");
923
#endif
924
	while ((m = ms_queue_get(in)) != NULL) {
925
		uint16_t cseq=mblk_get_cseq(m);
926
		packet = ms_new0(Vp8RtpFmtPacket, 1);
927
		packet->m = m;
928
		packet->pd = ms_new0(Vp8RtpFmtPayloadDescriptor, 1);
929 930 931

		if (m->b_cont) msgpullup(m, -1);
		packet->error = parse_payload_descriptor(packet);
932 933 934 935 936 937 938 939 940 941 942 943
		if (!ctx->initialized_ref_cseq){
			ctx->initialized_ref_cseq=TRUE;
			ctx->ref_cseq=cseq;
		}else{
			ctx->ref_cseq++;
			if (ctx->ref_cseq!=cseq){
				packet->cseq_inconsistency=TRUE;
				ms_message("sequence inconsistency detected (diff=%i)",(int)(cseq-ctx->ref_cseq));
				ctx->ref_cseq=cseq;
			}
		}
		packets_list=ms_list_append(packets_list,packet);
944
	}
945 946
	generate_frames_list(ctx, packets_list);
	ms_list_free(packets_list);
947
#ifdef VP8RTPFMT_DEBUG
948
	ms_list_for_each(ctx->frames_list, print_frame);
949
#endif /* VP8RTPFMT_DEBUG */
950
}
951

952 953 954 955 956 957
int vp8rtpfmt_unpacker_get_frame(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out, Vp8RtpFmtFrameInfo *frame_info) {
	int ret = output_valid_partitions(ctx, out);
	if (ret == 0) {
		Vp8RtpFmtFrame *frame = (Vp8RtpFmtFrame *)ms_list_nth_data(ctx->frames_list, 0);
		frame_info->pictureid_present = frame->pictureid_present;
		frame_info->pictureid = frame->pictureid;
958
		frame_info->keyframe = frame->keyframe;
959
	} else if (ms_list_size(ctx->non_processed_packets_list) >= 0) {
Simon Morlat's avatar
Simon Morlat committed
960
		ms_debug("VP8 packets are remaining for next iteration of the filter.");
961
	}
962
	clean_frame(ctx);
963
	return ret;
964 965
}

966

Sandrine Avakian's avatar
Sandrine Avakian committed
967
static void packer_process_frame_part(void *p, void *c, void *f) {
968 969
	Vp8RtpFmtPacket *packet = (Vp8RtpFmtPacket *)p;
	Vp8RtpFmtPackerCtx *ctx = (Vp8RtpFmtPackerCtx *)c;
Sandrine Avakian's avatar
Sandrine Avakian committed
970
	MSFactory* factory = (MSFactory*) f;
Ghislain MARY's avatar
Ghislain MARY committed
971 972
	mblk_t *pdm = NULL;
	mblk_t *dm = NULL;
973 974
	uint8_t *rptr;
	uint8_t pdsize = 1;
Sandrine Avakian's avatar
Sandrine Avakian committed
975
	int max_size = ms_factory_get_payload_max_size(factory);
976
	int dlen;
977
	bool_t marker_info = mblk_get_marker_info(packet->m);
978 979 980 981 982 983 984 985 986 987

	/* Calculate the payload descriptor size. */
	if (packet->pd->extended_control_bits_present == TRUE) pdsize++;
	if (packet->pd->pictureid_present == TRUE) {
		pdsize++;
		if (packet->pd->pictureid & 0x8000) pdsize++;
	}
	if (packet->pd->tl0picidx_present == TRUE) pdsize++;
	if ((packet->pd->tid_present == TRUE) || (packet->pd->keyidx_present == TRUE)) pdsize++;

Ghislain MARY's avatar
Ghislain MARY committed
988
	mblk_set_marker_info(packet->m, FALSE);
989 990 991 992 993
	for (rptr = packet->m->b_rptr; rptr < packet->m->b_wptr;) {
		/* Allocate the payload descriptor. */
		pdm = allocb(pdsize, 0);
		memset(pdm->b_wptr, 0, pdsize);
		mblk_set_timestamp_info(pdm, mblk_get_timestamp_info(packet->m));
994
		mblk_set_marker_info(pdm, FALSE);
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
		/* Fill the mandatory octet of the payload descriptor. */
		if (packet->pd->extended_control_bits_present == TRUE) *pdm->b_wptr |= (1 << 7);
		if (packet->pd->non_reference_frame == TRUE) *pdm->b_wptr |= (1 << 5);
		if (packet->pd->start_of_partition == TRUE) {
			if (packet->m->b_rptr == rptr) *pdm->b_wptr |= (1 << 4);
		}
		*pdm->b_wptr |= (packet->pd->pid & 0x07);
		pdm->b_wptr++;
		/* Fill the extension bit field octet of the payload descriptor. */
		if (packet->pd->extended_control_bits_present == TRUE) {
			if (packet->pd->pictureid_present == TRUE) *pdm->b_wptr |= (1 << 7);
			if (packet->pd->tl0picidx_present == TRUE) *pdm->b_wptr |= (1 << 6);
			if (packet->pd->tid_present == TRUE) *pdm->b_wptr |= (1 << 5);
			if (packet->pd->keyidx_present == TRUE) *pdm->b_wptr |= (1 << 4);
			pdm->b_wptr++;
		}
		/* Fill the pictureID field of the payload descriptor. */
		if (packet->pd->pictureid_present == TRUE) {
			if (packet->pd->pictureid & 0x8000) {
				*pdm->b_wptr |= ((packet->pd->pictureid >> 8) & 0xFF);
				pdm->b_wptr++;
			}
			*pdm->b_wptr |= (packet->pd->pictureid & 0xFF);
			pdm->b_wptr++;
		}
		/* Fill the tl0picidx octet of the payload descriptor. */
		if (packet->pd->tl0picidx_present == TRUE) {
			*pdm->b_wptr = packet->pd->tl0picidx;
			pdm->b_wptr++;
		}
		if ((packet->pd->tid_present == TRUE) || (packet->pd->keyidx_present == TRUE)) {
			if (packet->pd->tid_present == TRUE) {
				*pdm->b_wptr |= (packet->pd->tid & 0xC0);
				if (packet->pd->layer_sync == TRUE) *pdm->b_wptr |= (1 << 5);
			}
			if (packet->pd->keyidx_present == TRUE) {
				*pdm->b_wptr |= (packet->pd->keyidx & 0x1F);
			}
			pdm->b_wptr++;
		}

1036
		dlen = MIN((max_size - pdsize), (int)(packet->m->b_wptr - rptr));
1037 1038 1039 1040 1041 1042 1043
		dm = dupb(packet->m);
		dm->b_rptr = rptr;
		dm->b_wptr = rptr + dlen;
		dm->b_wptr = dm->b_rptr + dlen;
		pdm->b_cont = dm;
		rptr += dlen;

1044
		ms_queue_put(ctx->output_queue, pdm);
1045 1046
	}

1047
	/* Set marker bit on last packet if required. */
Ghislain MARY's avatar
Ghislain MARY committed
1048 1049
	if (pdm != NULL) mblk_set_marker_info(pdm, marker_info);
	if (dm != NULL) mblk_set_marker_info(dm, marker_info);
1050

1051 1052 1053 1054 1055
	freeb(packet->m);
	packet->m = NULL;
}


1056
void vp8rtpfmt_packer_init(Vp8RtpFmtPackerCtx *ctx) {
1057 1058 1059 1060 1061
}

void vp8rtpfmt_packer_uninit(Vp8RtpFmtPackerCtx *ctx) {
}

Sandrine Avakian's avatar
Sandrine Avakian committed
1062
void vp8rtpfmt_packer_process(Vp8RtpFmtPackerCtx *ctx, MSList *in, MSQueue *out, MSFactory *f) {
1063
	ctx->output_queue = out;
Sandrine Avakian's avatar
Sandrine Avakian committed
1064
	ms_list_for_each3(in, packer_process_frame_part, ctx, f);
1065 1066 1067
	ms_list_for_each(in, free_packet);
	ms_list_free(in);
}