1 /*
2 * RTP parser for AC3 payload format (RFC 4184)
3 * Copyright (c) 2015 Gilles Chanteperdrix <gch@xenomai.org>
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
25
26 #define RTP_AC3_PAYLOAD_HEADER_SIZE 2
27
33 };
34
36 {
38 }
39
44 {
45 unsigned frame_type;
46 unsigned nr_frames;
47 int err;
48
52 }
53
54 frame_type = buf[0] & 0x3;
55 nr_frames = buf[1];
58
59 switch (frame_type) {
60 case 0: /* One or more complete frames */
61 if (!nr_frames) {
64 }
68 }
69
71 memcpy(pkt->
data, buf, len);
72 return 0;
73
74 case 1:
75 case 2: /* First fragment */
77
81 if (err < 0)
82 return err;
83
87
88 case 3: /* Fragment other than first */
91 "Received packet without a start fragment; dropping.\n");
93 }
99 }
100
103 }
104
107
113 }
114
116 if (err < 0) {
118 "Error occurred when getting fragment buffer.\n");
119 return err;
120 }
121
122 return 0;
123 }
124
133 };