vp8rtpfmt.h 3.16 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
/*
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>
25
#include <mediastreamer2/msfilter.h>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#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,
41
		Vp8RtpFmtIncompleteFrame = -2,
42 43 44
		Vp8RtpFmtIncompletePartition = -3,
		Vp8RtpFmtInvalidFrame = -4,
		Vp8RtpFmtInvalidPartition = -5
45 46
	} Vp8RtpFmtErrorCode;

47
	typedef struct Vp8RtpFmtPayloadDescriptor {
48 49 50 51 52 53 54 55 56 57 58 59 60
		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;
61
	} Vp8RtpFmtPayloadDescriptor;
62 63 64

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

71 72 73 74
	typedef struct Vp8RtpFmtPartition {
		MSList *packets_list;
		Vp8RtpFmtErrorCode error;
		mblk_t *m;
75 76
		bool_t last_partition_of_frame;
		bool_t outputted;
77 78
	} Vp8RtpFmtPartition;

79 80 81 82 83 84 85
	typedef struct Vp8RtpFmtFrame {
		MSList *partitions_list;
		Vp8RtpFmtErrorCode error;
		bool_t outputted;
		bool_t discarded;
	} Vp8RtpFmtFrame;

86

87
	typedef struct Vp8RtpFmtUnpackerCtx {
88
		MSFilter *filter;
89
		MSList *frames_list;
90
		MSQueue output_queue;
91 92
		uint32_t last_ts;
		uint32_t ref_cseq;
93
		bool_t initialized_last_ts;
94 95 96 97
		bool_t initialized_ref_cseq;
	} Vp8RtpFmtUnpackerCtx;

	typedef struct Vp8RtpFmtPackerCtx {
98
		MSQueue *output_queue;
99 100 101
	} Vp8RtpFmtPackerCtx;


102
	void vp8rtpfmt_packer_init(Vp8RtpFmtPackerCtx *ctx);
103
	void vp8rtpfmt_packer_uninit(Vp8RtpFmtPackerCtx *ctx);
104
	void vp8rtpfmt_packer_process(Vp8RtpFmtPackerCtx *ctx, MSList *in, MSQueue *out);
105

106
	void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f);
107
	void vp8rtpfmt_unpacker_uninit(Vp8RtpFmtUnpackerCtx *ctx);
108
	void vp8rtpfmt_unpacker_process(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *inout);
109
	uint32_t vp8rtpfmt_unpacker_calc_extended_cseq(Vp8RtpFmtUnpackerCtx *ctx, uint16_t cseq);
110 111 112 113 114 115

#ifdef __cplusplus
}
#endif

#endif /* VP8RTPFMT_H */