vp8rtpfmt.h 3.24 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006  Simon MORLAT (simon.morlat@linphone.org)

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.
*/


#ifndef VP8RTPFMT_H
#define VP8RTPFMT_H

#include <mediastreamer2/mscommon.h>
#include <mediastreamer2/msqueue.h>

/**
 * This file declares an API useful to pack/unpack a VP8 stream in RTP packets
 * as described in draft-ietf-payload-vp8-11
 * (http://tools.ietf.org/html/draft-ietf-payload-vp8-11)
 */

#ifdef __cplusplus
extern "C"{
#endif

	typedef enum Vp8RtpFmtErrorCode {
		Vp8RtpFmtOk = 0,
		Vp8RtpFmtInvalidPayloadDescriptor = -1,
40
		Vp8RtpFmtIncompleteFrame = -2,
41 42 43
		Vp8RtpFmtIncompletePartition = -3,
		Vp8RtpFmtInvalidFrame = -4,
		Vp8RtpFmtInvalidPartition = -5
44 45
	} Vp8RtpFmtErrorCode;

46
	typedef struct Vp8RtpFmtPayloadDescriptor {
47 48 49 50 51 52 53 54 55 56 57 58 59
		uint16_t pictureid;
		uint8_t pid;
		uint8_t tl0picidx;
		uint8_t tid;
		uint8_t keyidx;
		bool_t extended_control_bits_present;
		bool_t non_reference_frame;
		bool_t start_of_partition;
		bool_t pictureid_present;
		bool_t tl0picidx_present;
		bool_t tid_present;
		bool_t keyidx_present;
		bool_t layer_sync;
60
	} Vp8RtpFmtPayloadDescriptor;
61 62 63

	typedef struct Vp8RtpFmtPacket {
		mblk_t *m;
64
		Vp8RtpFmtPayloadDescriptor *pd;
65 66 67
		uint32_t extended_cseq;
		Vp8RtpFmtErrorCode error;
		bool_t processed;
68
		bool_t last_packet_of_frame;
69 70
	} Vp8RtpFmtPacket;

71 72 73 74 75 76 77 78 79 80 81 82 83
	typedef struct Vp8RtpFmtFrame {
		MSList *packets_list;
		MSList *partitions_list;
		Vp8RtpFmtErrorCode error;
	} Vp8RtpFmtFrame;

	typedef struct Vp8RtpFmtPartition {
		MSList *packets_list;
		Vp8RtpFmtErrorCode error;
		bool_t last_partition_of_frame;
		mblk_t *m;
	} Vp8RtpFmtPartition;

84

85
	typedef struct Vp8RtpFmtUnpackerCtx {
86 87 88 89
		MSList *packets_list;
		MSList *frames_list;
		MSList *output_list;
		Vp8RtpFmtFrame *current_frame;
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
		uint32_t last_ts;
		uint32_t last_cseq;
		uint32_t ref_cseq;
		bool_t initialized_ref_cseq;
	} Vp8RtpFmtUnpackerCtx;

	typedef struct Vp8RtpFmtPackerCtx {
		MSQueue output_queue;
		uint8_t nb_partitions;
	} Vp8RtpFmtPackerCtx;


	void vp8rtpfmt_packer_init(Vp8RtpFmtPackerCtx *ctx, uint8_t nb_partitions);
	void vp8rtpfmt_packer_uninit(Vp8RtpFmtPackerCtx *ctx);
	void vp8rtpfmt_packer_process(Vp8RtpFmtPackerCtx *ctx, MSList *in);

	void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx);
	void vp8rtpfmt_unpacker_uninit(Vp8RtpFmtUnpackerCtx *ctx);
108 109
	void vp8rtpfmt_unpacker_unpack(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *in);
	void vp8rtpfmt_unpacker_decode(Vp8RtpFmtUnpackerCtx *ctx, MSIterate2Func func, void *userdata);
110
	uint32_t vp8rtpfmt_unpacker_calc_extended_cseq(Vp8RtpFmtUnpackerCtx *ctx, uint16_t cseq);
111 112 113 114 115 116

#ifdef __cplusplus
}
#endif

#endif /* VP8RTPFMT_H */