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
46 {
49 int packing_scheme, has_payload_desc, has_packet_info, alen,
51
54
65 }
67 }
68
69 /**
70 * The RTP payload is described in:
71 * http://developer.apple.com/quicktime/icefloe/dispatch026.html
72 */
75
76 if (len < 4)
78
80 if ((packing_scheme =
get_bits(&gb, 2)) == 0)
86 skip_bits(&gb, 23);
// reserved:7, cache payload info:1, payload ID:15
87
88 if (has_payload_desc) {
89 int data_len, pos, is_start, is_finish;
91
93 if (pos + 12 > len)
95
96 skip_bits(&gb, 2);
// has non-I frames:1, is sparse:1
99 if (!is_start || !is_finish) {
101 "split over several packets");
103 }
106
110 tag !=
MKTAG(
'v',
'i',
'd',
'e')) ||
112 tag !=
MKTAG(
's',
'o',
'u',
'n')))
115
116 if (pos + data_len > len)
118 /* TLVs */
119 while (
avio_tell(&pb) + 4 < pos + data_len) {
122 if (
avio_tell(&pb) + tlv_len > pos + data_len)
124
125 #define MKTAG16(a,b) MKTAG(a,b,0,0)
126 switch (tag) {
132 if (!mc)
136 if (!msc) {
140 }
141 /* ff_mov_read_stsd_entries updates stream s->nb_streams-1,
142 * so set it temporarily to indicate which stream to update. */
150 break;
151 }
152 default:
154 break;
155 }
156 }
157
158 /* 32-bit alignment */
160 } else
162
163 if (has_packet_info) {
166 }
167
169 if (alen <= 0)
171
172 switch (packing_scheme) {
173 case 3: /* one data packet spread over 1 or multiple RTP packets */
175 int err;
179 return err;
180 }
181 } else {
189 }
192 if (has_marker_bit) {
194 if (ret < 0)
196
202 return 0;
203 }
205
206 case 1: /* constant packet size, multiple packets per RTP packet */
222 }
228 return 1;
229 }
230 return 0;
231
232 default: /* unimplemented */
235 }
236 }
237
239 {
241 }
242
244 {
247 }
248
249 #define RTP_QT_HANDLER(m, n, s, t) \
250 RTPDynamicProtocolHandler ff_ ## m ## _rtp_ ## n ## _handler = { \
251 .enc_name = s, \
252 .codec_type = t, \
253 .codec_id = AV_CODEC_ID_NONE, \
254 .alloc = qt_rtp_new, \
255 .free = qt_rtp_free, \
256 .parse_packet = qt_rtp_parse_packet, \
257 }
258