annotate rtpdec_mpeg4.c @ 6191:7884ec350d88 libavformat

rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer Patch by Josh Allmann, joshua dot allmann at gmail
author mstorsjo
date Mon, 28 Jun 2010 11:30:44 +0000
parents 83978c1b9739
children b93d7a25cd6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
1 /**
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
2 * Common code for the RTP depacketization of MPEG-4 formats.
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
3 * Copyright (c) 2010 Fabrice Bellard
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
4 * Romain Degez
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
5 *
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
6 * This file is part of FFmpeg.
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
7 *
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
12 *
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
16 * Lesser General Public License for more details.
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
17 *
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
21 */
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
22
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
23 /**
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
24 * @file
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
25 * @brief MPEG4 / RTP Code
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
26 * @author Fabrice Bellard
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
27 * @author Romain Degez
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
28 */
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
29
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
30 #include "rtpdec_mpeg4.h"
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
31 #include "libavutil/avstring.h"
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
32 #include "libavcodec/get_bits.h"
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
33 #include <strings.h>
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
34
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
35 /** Structure listing useful vars to parse RTP packet payload*/
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
36 struct PayloadContext
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
37 {
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
38 int sizelength;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
39 int indexlength;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
40 int indexdeltalength;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
41 int profile_level_id;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
42 int streamtype;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
43 int objecttype;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
44 char *mode;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
45
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
46 /** mpeg 4 AU headers */
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
47 struct AUHeaders {
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
48 int size;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
49 int index;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
50 int cts_flag;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
51 int cts;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
52 int dts_flag;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
53 int dts;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
54 int rap_flag;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
55 int streamstate;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
56 } *au_headers;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
57 int au_headers_allocated;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
58 int nb_au_headers;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
59 int au_headers_length_bytes;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
60 int cur_au_index;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
61 };
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
62
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
63 /* return the length and optionally the data */
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
64 static int hex_to_data(uint8_t *data, const char *p)
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
65 {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
66 int c, len, v;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
67
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
68 len = 0;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
69 v = 1;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
70 for (;;) {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
71 p += strspn(p, SPACE_CHARS);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
72 if (*p == '\0')
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
73 break;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
74 c = toupper((unsigned char) *p++);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
75 if (c >= '0' && c <= '9')
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
76 c = c - '0';
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
77 else if (c >= 'A' && c <= 'F')
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
78 c = c - 'A' + 10;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
79 else
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
80 break;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
81 v = (v << 4) | c;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
82 if (v & 0x100) {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
83 if (data)
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
84 data[len] = v;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
85 len++;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
86 v = 1;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
87 }
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
88 }
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
89 return len;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
90 }
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
91
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
92 typedef struct {
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
93 const char *str;
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
94 uint16_t type;
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
95 uint32_t offset;
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
96 } AttrNameMap;
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
97
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
98 /* All known fmtp parameters and the corresponding RTPAttrTypeEnum */
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
99 #define ATTR_NAME_TYPE_INT 0
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
100 #define ATTR_NAME_TYPE_STR 1
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
101 static const AttrNameMap attr_names[]=
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
102 {
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
103 { "SizeLength", ATTR_NAME_TYPE_INT,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
104 offsetof(PayloadContext, sizelength) },
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
105 { "IndexLength", ATTR_NAME_TYPE_INT,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
106 offsetof(PayloadContext, indexlength) },
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
107 { "IndexDeltaLength", ATTR_NAME_TYPE_INT,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
108 offsetof(PayloadContext, indexdeltalength) },
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
109 { "profile-level-id", ATTR_NAME_TYPE_INT,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
110 offsetof(PayloadContext, profile_level_id) },
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
111 { "StreamType", ATTR_NAME_TYPE_INT,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
112 offsetof(PayloadContext, streamtype) },
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
113 { "mode", ATTR_NAME_TYPE_STR,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
114 offsetof(PayloadContext, mode) },
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
115 { NULL, -1, -1 },
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
116 };
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
117
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
118 static PayloadContext *new_context(void)
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
119 {
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
120 return av_mallocz(sizeof(PayloadContext));
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
121 }
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
122
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
123 static void free_context(PayloadContext * data)
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
124 {
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
125 int i;
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
126 for (i = 0; i < data->nb_au_headers; i++) {
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
127 /* according to rtp_parse_mp4_au, we treat multiple
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
128 * au headers as one, so nb_au_headers is always 1.
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
129 * loop anyway in case this changes.
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
130 * (note: changes done carelessly might lead to a double free)
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
131 */
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
132 av_free(&data->au_headers[i]);
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
133 }
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
134 av_free(data->mode);
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
135 av_free(data);
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
136 }
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
137
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
138 static int parse_fmtp_config(AVCodecContext * codec, char *value)
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
139 {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
140 /* decode the hexa encoded parameter */
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
141 int len = hex_to_data(NULL, value);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
142 if (codec->extradata)
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
143 av_free(codec->extradata);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
144 codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
145 if (!codec->extradata)
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
146 return AVERROR(ENOMEM);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
147 codec->extradata_size = len;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
148 hex_to_data(codec->extradata, value);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
149 return 0;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
150 }
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
151
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
152 static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf)
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
153 {
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
154 int au_headers_length, au_header_size, i;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
155 GetBitContext getbitcontext;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
156
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
157 /* decode the first 2 bytes where the AUHeader sections are stored
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
158 length in bits */
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
159 au_headers_length = AV_RB16(buf);
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
160
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
161 if (au_headers_length > RTP_MAX_PACKET_LENGTH)
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
162 return -1;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
163
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
164 data->au_headers_length_bytes = (au_headers_length + 7) / 8;
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
165
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
166 /* skip AU headers length section (2 bytes) */
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
167 buf += 2;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
168
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
169 init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8);
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
170
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
171 /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
172 au_header_size = data->sizelength + data->indexlength;
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
173 if (au_header_size <= 0 || (au_headers_length % au_header_size != 0))
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
174 return -1;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
175
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
176 data->nb_au_headers = au_headers_length / au_header_size;
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
177 if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) {
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
178 av_free(data->au_headers);
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
179 data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers);
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
180 data->au_headers_allocated = data->nb_au_headers;
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
181 }
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
182
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
183 /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving)
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
184 In my test, the FAAD decoder does not behave correctly when sending each AU one by one
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
185 but does when sending the whole as one big packet... */
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
186 data->au_headers[0].size = 0;
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
187 data->au_headers[0].index = 0;
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
188 for (i = 0; i < data->nb_au_headers; ++i) {
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
189 data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength);
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
190 data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength);
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
191 }
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
192
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
193 data->nb_au_headers = 1;
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
194
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
195 return 0;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
196 }
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
197
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
198
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
199 /* Follows RFC 3640 */
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
200 static int aac_parse_packet(AVFormatContext *ctx,
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
201 PayloadContext *data,
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
202 AVStream *st,
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
203 AVPacket *pkt,
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
204 uint32_t *timestamp,
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
205 const uint8_t *buf, int len, int flags)
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
206 {
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
207 if (rtp_parse_mp4_au(data, buf))
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
208 return -1;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
209
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
210 buf += data->au_headers_length_bytes + 2;
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
211 len -= data->au_headers_length_bytes + 2;
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
212
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
213 /* XXX: Fixme we only handle the case where rtp_parse_mp4_au define
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
214 one au_header */
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
215 av_new_packet(pkt, data->au_headers[0].size);
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
216 memcpy(pkt->data, buf, data->au_headers[0].size);
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
217
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
218 pkt->stream_index = st->index;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
219 return 0;
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
220 }
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
221
6191
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
222 static int parse_fmtp(AVStream *stream, PayloadContext *data,
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
223 char *attr, char *value)
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
224 {
6191
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
225 AVCodecContext *codec = stream->codec;
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
226 int res, i;
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
227
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
228 if (!strcmp(attr, "config")) {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
229 res = parse_fmtp_config(codec, value);
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
230
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
231 if (res < 0)
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
232 return res;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
233 }
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
234
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
235 if (codec->codec_id == CODEC_ID_AAC) {
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
236 /* Looking for a known attribute */
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
237 for (i = 0; attr_names[i].str; ++i) {
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
238 if (!strcasecmp(attr, attr_names[i].str)) {
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
239 if (attr_names[i].type == ATTR_NAME_TYPE_INT) {
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
240 *(int *)((char *)data+
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
241 attr_names[i].offset) = atoi(value);
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
242 } else if (attr_names[i].type == ATTR_NAME_TYPE_STR)
6180
5c977bb6aea7 rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
mstorsjo
parents: 6179
diff changeset
243 *(char **)((char *)data+
6177
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
244 attr_names[i].offset) = av_strdup(value);
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
245 }
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
246 }
3a0c63aea9e9 RTSP: Move more SDP/FMTP stuff from rtsp.c to rtpdec_mpeg4.c
mstorsjo
parents: 6176
diff changeset
247 }
6191
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
248 return 0;
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
249 }
6191
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
250
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
251 static int parse_sdp_line(AVFormatContext *s, int st_index,
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
252 PayloadContext *data, const char *line)
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
253 {
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
254 const char *p;
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
255
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
256 if (av_strstart(line, "fmtp:", &p))
7884ec350d88 rtpdec: Clean up FMTP parsing code in MPEG-4/AAC RTP depacketizer
mstorsjo
parents: 6186
diff changeset
257 return ff_parse_fmtp(s->streams[st_index], data, p, parse_fmtp);
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
258
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
259 return 0;
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
260 }
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
261
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
262 RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler = {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
263 .enc_name = "MP4V-ES",
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
264 .codec_type = AVMEDIA_TYPE_VIDEO,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
265 .codec_id = CODEC_ID_MPEG4,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
266 .parse_sdp_a_line = parse_sdp_line,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
267 .open = NULL,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
268 .close = NULL,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
269 .parse_packet = NULL
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
270 };
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
271
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
272 RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = {
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
273 .enc_name = "mpeg4-generic",
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
274 .codec_type = AVMEDIA_TYPE_AUDIO,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
275 .codec_id = CODEC_ID_AAC,
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
276 .parse_sdp_a_line = parse_sdp_line,
6179
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
277 .open = new_context,
736165b749f8 RTSP, rtpdec: Move RTPPayloadData into rtpdec_mpeg4 and remove all references to rtp_payload_data in rtpdec and rtsp
mstorsjo
parents: 6178
diff changeset
278 .close = free_context,
6178
7aca26f37b02 rtpdec: Move AAC depacketization code in rtpdec to a proper payload handler
mstorsjo
parents: 6177
diff changeset
279 .parse_packet = aac_parse_packet
6176
5708c6d4223d RTSP: Decouple MPEG-4 and AAC specific parts from rtsp.c
mstorsjo
parents:
diff changeset
280 };