Mercurial > libavformat.hg
comparison rtpdec_mpeg4.c @ 6180:5c977bb6aea7 libavformat
rtpdec_mpeg4: Rename PayloadContext to be consistently 'data'
Patch by Josh Allmann, joshua dot allmann at gmail
author | mstorsjo |
---|---|
date | Fri, 25 Jun 2010 08:03:52 +0000 |
parents | 736165b749f8 |
children | 83978c1b9739 |
comparison
equal
deleted
inserted
replaced
6179:736165b749f8 | 6180:5c977bb6aea7 |
---|---|
148 codec->extradata_size = len; | 148 codec->extradata_size = len; |
149 hex_to_data(codec->extradata, value); | 149 hex_to_data(codec->extradata, value); |
150 return 0; | 150 return 0; |
151 } | 151 } |
152 | 152 |
153 static int rtp_parse_mp4_au(PayloadContext *infos, const uint8_t *buf) | 153 static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf) |
154 { | 154 { |
155 int au_headers_length, au_header_size, i; | 155 int au_headers_length, au_header_size, i; |
156 GetBitContext getbitcontext; | 156 GetBitContext getbitcontext; |
157 | 157 |
158 /* decode the first 2 bytes where the AUHeader sections are stored | 158 /* decode the first 2 bytes where the AUHeader sections are stored |
160 au_headers_length = AV_RB16(buf); | 160 au_headers_length = AV_RB16(buf); |
161 | 161 |
162 if (au_headers_length > RTP_MAX_PACKET_LENGTH) | 162 if (au_headers_length > RTP_MAX_PACKET_LENGTH) |
163 return -1; | 163 return -1; |
164 | 164 |
165 infos->au_headers_length_bytes = (au_headers_length + 7) / 8; | 165 data->au_headers_length_bytes = (au_headers_length + 7) / 8; |
166 | 166 |
167 /* skip AU headers length section (2 bytes) */ | 167 /* skip AU headers length section (2 bytes) */ |
168 buf += 2; | 168 buf += 2; |
169 | 169 |
170 init_get_bits(&getbitcontext, buf, infos->au_headers_length_bytes * 8); | 170 init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8); |
171 | 171 |
172 /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */ | 172 /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */ |
173 au_header_size = infos->sizelength + infos->indexlength; | 173 au_header_size = data->sizelength + data->indexlength; |
174 if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) | 174 if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) |
175 return -1; | 175 return -1; |
176 | 176 |
177 infos->nb_au_headers = au_headers_length / au_header_size; | 177 data->nb_au_headers = au_headers_length / au_header_size; |
178 if (!infos->au_headers || infos->au_headers_allocated < infos->nb_au_headers) { | 178 if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) { |
179 av_free(infos->au_headers); | 179 av_free(data->au_headers); |
180 infos->au_headers = av_malloc(sizeof(struct AUHeaders) * infos->nb_au_headers); | 180 data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers); |
181 infos->au_headers_allocated = infos->nb_au_headers; | 181 data->au_headers_allocated = data->nb_au_headers; |
182 } | 182 } |
183 | 183 |
184 /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving) | 184 /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving) |
185 In my test, the FAAD decoder does not behave correctly when sending each AU one by one | 185 In my test, the FAAD decoder does not behave correctly when sending each AU one by one |
186 but does when sending the whole as one big packet... */ | 186 but does when sending the whole as one big packet... */ |
187 infos->au_headers[0].size = 0; | 187 data->au_headers[0].size = 0; |
188 infos->au_headers[0].index = 0; | 188 data->au_headers[0].index = 0; |
189 for (i = 0; i < infos->nb_au_headers; ++i) { | 189 for (i = 0; i < data->nb_au_headers; ++i) { |
190 infos->au_headers[0].size += get_bits_long(&getbitcontext, infos->sizelength); | 190 data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength); |
191 infos->au_headers[0].index = get_bits_long(&getbitcontext, infos->indexlength); | 191 data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength); |
192 } | 192 } |
193 | 193 |
194 infos->nb_au_headers = 1; | 194 data->nb_au_headers = 1; |
195 | 195 |
196 return 0; | 196 return 0; |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 /* Follows RFC 3640 */ | 200 /* Follows RFC 3640 */ |
201 static int aac_parse_packet(AVFormatContext *ctx, | 201 static int aac_parse_packet(AVFormatContext *ctx, |
202 PayloadContext *infos, | 202 PayloadContext *data, |
203 AVStream *st, | 203 AVStream *st, |
204 AVPacket *pkt, | 204 AVPacket *pkt, |
205 uint32_t *timestamp, | 205 uint32_t *timestamp, |
206 const uint8_t *buf, int len, int flags) | 206 const uint8_t *buf, int len, int flags) |
207 { | 207 { |
208 if (rtp_parse_mp4_au(infos, buf)) | 208 if (rtp_parse_mp4_au(data, buf)) |
209 return -1; | 209 return -1; |
210 | 210 |
211 buf += infos->au_headers_length_bytes + 2; | 211 buf += data->au_headers_length_bytes + 2; |
212 len -= infos->au_headers_length_bytes + 2; | 212 len -= data->au_headers_length_bytes + 2; |
213 | 213 |
214 /* XXX: Fixme we only handle the case where rtp_parse_mp4_au define | 214 /* XXX: Fixme we only handle the case where rtp_parse_mp4_au define |
215 one au_header */ | 215 one au_header */ |
216 av_new_packet(pkt, infos->au_headers[0].size); | 216 av_new_packet(pkt, data->au_headers[0].size); |
217 memcpy(pkt->data, buf, infos->au_headers[0].size); | 217 memcpy(pkt->data, buf, data->au_headers[0].size); |
218 | 218 |
219 pkt->stream_index = st->index; | 219 pkt->stream_index = st->index; |
220 return 0; | 220 return 0; |
221 } | 221 } |
222 | 222 |
223 static int parse_sdp_line(AVFormatContext *s, int st_index, | 223 static int parse_sdp_line(AVFormatContext *s, int st_index, |
224 PayloadContext *rtp_payload_data, const char *line) | 224 PayloadContext *data, const char *line) |
225 { | 225 { |
226 const char *p; | 226 const char *p; |
227 char value[4096], attr[25]; | 227 char value[4096], attr[25]; |
228 int res = 0, i; | 228 int res = 0, i; |
229 AVStream *st = s->streams[st_index]; | 229 AVStream *st = s->streams[st_index]; |
248 if (codec->codec_id == CODEC_ID_AAC) { | 248 if (codec->codec_id == CODEC_ID_AAC) { |
249 /* Looking for a known attribute */ | 249 /* Looking for a known attribute */ |
250 for (i = 0; attr_names[i].str; ++i) { | 250 for (i = 0; attr_names[i].str; ++i) { |
251 if (!strcasecmp(attr, attr_names[i].str)) { | 251 if (!strcasecmp(attr, attr_names[i].str)) { |
252 if (attr_names[i].type == ATTR_NAME_TYPE_INT) { | 252 if (attr_names[i].type == ATTR_NAME_TYPE_INT) { |
253 *(int *)((char *)rtp_payload_data + | 253 *(int *)((char *)data+ |
254 attr_names[i].offset) = atoi(value); | 254 attr_names[i].offset) = atoi(value); |
255 } else if (attr_names[i].type == ATTR_NAME_TYPE_STR) | 255 } else if (attr_names[i].type == ATTR_NAME_TYPE_STR) |
256 *(char **)((char *)rtp_payload_data + | 256 *(char **)((char *)data+ |
257 attr_names[i].offset) = av_strdup(value); | 257 attr_names[i].offset) = av_strdup(value); |
258 } | 258 } |
259 } | 259 } |
260 } | 260 } |
261 } | 261 } |