vp8rtpfmt.h 3.64 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
#include <mediastreamer2/msqueue.h>
27
#include <mediastreamer2/msvideo.h>
28 29 30 31 32 33 34 35 36 37 38 39 40 41

/**
 * 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,
42
		Vp8RtpFmtIncompleteFrame = -2,
43
		Vp8RtpFmtInvalidFrame = -3
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 68
		uint32_t extended_cseq;
		Vp8RtpFmtErrorCode error;
	} Vp8RtpFmtPacket;

69 70 71
	typedef struct Vp8RtpFmtPartition {
		MSList *packets_list;
		mblk_t *m;
72 73 74
		size_t size;
		bool_t has_start;
		bool_t has_marker;
75
		bool_t outputted;
76 77
	} Vp8RtpFmtPartition;

78 79 80 81 82
	typedef struct Vp8RtpFmtFramePartitionsInfo {
		uint32_t partition_sizes[8];
		uint8_t nb_partitions;
	} Vp8RtpFmtFramePartitionsInfo;

83
	typedef struct Vp8RtpFmtFrame {
84 85
		Vp8RtpFmtFramePartitionsInfo partitions_info;
		Vp8RtpFmtPartition *partitions[9];
86
		Vp8RtpFmtErrorCode error;
87 88 89 90
		uint16_t pictureid;
		bool_t pictureid_present;
		bool_t keyframe;
		bool_t reference;
91 92 93 94
		bool_t outputted;
		bool_t discarded;
	} Vp8RtpFmtFrame;

95

96
	typedef struct Vp8RtpFmtUnpackerCtx {
97
		MSFilter *filter;
98
		MSList *frames_list;
99
		MSList *non_processed_packets_list;
100
		MSQueue output_queue;
101
		MSVideoSize video_size;
102 103
		uint32_t last_ts;
		uint32_t ref_cseq;
104
		bool_t avpf_enabled;
105
		bool_t freeze_on_error;
106
		bool_t output_partitions;
107
		bool_t waiting_for_reference_frame;
108
		bool_t valid_keyframe_received;
109
		bool_t initialized_last_ts;
110 111 112 113
		bool_t initialized_ref_cseq;
	} Vp8RtpFmtUnpackerCtx;

	typedef struct Vp8RtpFmtPackerCtx {
114
		MSQueue *output_queue;
115 116 117
	} Vp8RtpFmtPackerCtx;


118
	void vp8rtpfmt_packer_init(Vp8RtpFmtPackerCtx *ctx);
119
	void vp8rtpfmt_packer_uninit(Vp8RtpFmtPackerCtx *ctx);
120
	void vp8rtpfmt_packer_process(Vp8RtpFmtPackerCtx *ctx, MSList *in, MSQueue *out);
121

122
	void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f, bool_t avpf_enabled, bool_t freeze_on_error, bool_t output_partitions);
123
	void vp8rtpfmt_unpacker_uninit(Vp8RtpFmtUnpackerCtx *ctx);
124
	void vp8rtpfmt_unpacker_process(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *inout);
125
	uint32_t vp8rtpfmt_unpacker_calc_extended_cseq(Vp8RtpFmtUnpackerCtx *ctx, uint16_t cseq);
126 127 128 129 130 131

#ifdef __cplusplus
}
#endif

#endif /* VP8RTPFMT_H */