1 /*
2 * RTP/Quicktime support.
3 * Copyright (c) 2009 Ronald S. Bultje
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * @brief Quicktime-style RTP support
25 * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
26 */
27
35
40 };
41
44 {
48
49 return 0;
50 }
51
54 uint32_t *timestamp, const uint8_t *buf,
56 {
60 int packing_scheme, has_payload_desc, has_packet_info, alen,
63
66
77 }
79 }
80
81 /**
82 * The RTP payload is described in:
83 * http://developer.apple.com/quicktime/icefloe/dispatch026.html
84 */
89
92
94 if ((packing_scheme =
get_bits(&gb, 2)) == 0)
99 skip_bits(&gb, 23);
// reserved:7, cache payload info:1, payload ID:15
100
101 if (has_payload_desc) {
102 int data_len,
pos, is_start, is_finish;
104
108
109 skip_bits(&gb, 2);
// has non-I-frames:1, is sparse:1
112 if (!is_start || !is_finish) {
114 "split over several packets");
116 }
119
128
131 /* TLVs */
137
138 #define MKTAG16(a,b) MKTAG(a,b,0,0)
149 if (!msc) {
153 }
154 /* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
155 * so set it temporarily to indicate which stream to update. */
156 s->nb_streams = st->
index + 1;
163 break;
164 }
165 default:
167 break;
168 }
169 }
170
171 /* 32-bit alignment */
173 } else
175
176 if (has_packet_info) {
179 }
180
182 if (alen <= 0)
184
185 switch (packing_scheme) {
186 case 3: /* one data packet spread over 1 or multiple RTP packets */
188 int err;
192 return err;
193 }
194 } else {
202 }
205 if (has_marker_bit) {
209
215 return 0;
216 }
218
219 case 1: /* constant packet size, multiple packets per RTP packet */
235 }
241 return 1;
242 }
243 return 0;
244
245 default: /* unimplemented */
248 }
249 }
250
252 {
255 }
256
257 #define RTP_QT_HANDLER(m, n, s, t) \
258 const RTPDynamicProtocolHandler ff_ ## m ## _rtp_ ## n ## _handler = { \
259 .enc_name = s, \
260 .codec_type = t, \
261 .codec_id = AV_CODEC_ID_NONE, \
262 .priv_data_size = sizeof(PayloadContext), \
263 .init = qt_rtp_init, \
264 .close = qt_rtp_close, \
265 .parse_packet = qt_rtp_parse_packet, \
266 }
267