| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Common code for the RTP depacketization of MPEG-4 formats. | 2 * Common code for the RTP depacketization of MPEG-4 formats. |
| 3 * Copyright (c) 2010 Fabrice Bellard | 3 * Copyright (c) 2010 Fabrice Bellard |
| 4 * Romain Degez | 4 * Romain Degez |
| 5 * | 5 * |
| 6 * This file is part of FFmpeg. | 6 * This file is part of FFmpeg. |
| 7 * | 7 * |
| 8 * FFmpeg is free software; you can redistribute it and/or | 8 * FFmpeg is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 int dts; | 54 int dts; |
| 55 int rap_flag; | 55 int rap_flag; |
| 56 int streamstate; | 56 int streamstate; |
| 57 } *au_headers; | 57 } *au_headers; |
| 58 int au_headers_allocated; | 58 int au_headers_allocated; |
| 59 int nb_au_headers; | 59 int nb_au_headers; |
| 60 int au_headers_length_bytes; | 60 int au_headers_length_bytes; |
| 61 int cur_au_index; | 61 int cur_au_index; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 /* return the length and optionally the data */ | |
| 65 static int hex_to_data(uint8_t *data, const char *p) | |
| 66 { | |
| 67 int c, len, v; | |
| 68 | |
| 69 len = 0; | |
| 70 v = 1; | |
| 71 for (;;) { | |
| 72 p += strspn(p, SPACE_CHARS); | |
| 73 if (*p == '\0') | |
| 74 break; | |
| 75 c = toupper((unsigned char) *p++); | |
| 76 if (c >= '0' && c <= '9') | |
| 77 c = c - '0'; | |
| 78 else if (c >= 'A' && c <= 'F') | |
| 79 c = c - 'A' + 10; | |
| 80 else | |
| 81 break; | |
| 82 v = (v << 4) | c; | |
| 83 if (v & 0x100) { | |
| 84 if (data) | |
| 85 data[len] = v; | |
| 86 len++; | |
| 87 v = 1; | |
| 88 } | |
| 89 } | |
| 90 return len; | |
| 91 } | |
| 92 | |
| 93 typedef struct { | 64 typedef struct { |
| 94 const char *str; | 65 const char *str; |
| 95 uint16_t type; | 66 uint16_t type; |
| 96 uint32_t offset; | 67 uint32_t offset; |
| 97 } AttrNameMap; | 68 } AttrNameMap; |
| 98 | 69 |
| 99 /* All known fmtp parameters and the corresponding RTPAttrTypeEnum */ | 70 /* All known fmtp parameters and the corresponding RTPAttrTypeEnum */ |
| 100 #define ATTR_NAME_TYPE_INT 0 | 71 #define ATTR_NAME_TYPE_INT 0 |
| 101 #define ATTR_NAME_TYPE_STR 1 | 72 #define ATTR_NAME_TYPE_STR 1 |
| 102 static const AttrNameMap attr_names[]= | 73 static const AttrNameMap attr_names[]= |
| (...skipping 29 matching lines...) Expand all Loading... |
| 132 */ | 103 */ |
| 133 av_free(&data->au_headers[i]); | 104 av_free(&data->au_headers[i]); |
| 134 } | 105 } |
| 135 av_free(data->mode); | 106 av_free(data->mode); |
| 136 av_free(data); | 107 av_free(data); |
| 137 } | 108 } |
| 138 | 109 |
| 139 static int parse_fmtp_config(AVCodecContext * codec, char *value) | 110 static int parse_fmtp_config(AVCodecContext * codec, char *value) |
| 140 { | 111 { |
| 141 /* decode the hexa encoded parameter */ | 112 /* decode the hexa encoded parameter */ |
| 142 int len = hex_to_data(NULL, value); | 113 int len = ff_hex_to_data(NULL, value); |
| 143 if (codec->extradata) | 114 if (codec->extradata) |
| 144 av_free(codec->extradata); | 115 av_free(codec->extradata); |
| 145 codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); | 116 codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); |
| 146 if (!codec->extradata) | 117 if (!codec->extradata) |
| 147 return AVERROR(ENOMEM); | 118 return AVERROR(ENOMEM); |
| 148 codec->extradata_size = len; | 119 codec->extradata_size = len; |
| 149 hex_to_data(codec->extradata, value); | 120 ff_hex_to_data(codec->extradata, value); |
| 150 return 0; | 121 return 0; |
| 151 } | 122 } |
| 152 | 123 |
| 153 static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf) | 124 static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf) |
| 154 { | 125 { |
| 155 int au_headers_length, au_header_size, i; | 126 int au_headers_length, au_header_size, i; |
| 156 GetBitContext getbitcontext; | 127 GetBitContext getbitcontext; |
| 157 | 128 |
| 158 /* decode the first 2 bytes where the AUHeader sections are stored | 129 /* decode the first 2 bytes where the AUHeader sections are stored |
| 159 length in bits */ | 130 length in bits */ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 243 |
| 273 RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = { | 244 RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = { |
| 274 .enc_name = "mpeg4-generic", | 245 .enc_name = "mpeg4-generic", |
| 275 .codec_type = AVMEDIA_TYPE_AUDIO, | 246 .codec_type = AVMEDIA_TYPE_AUDIO, |
| 276 .codec_id = CODEC_ID_AAC, | 247 .codec_id = CODEC_ID_AAC, |
| 277 .parse_sdp_a_line = parse_sdp_line, | 248 .parse_sdp_a_line = parse_sdp_line, |
| 278 .open = new_context, | 249 .open = new_context, |
| 279 .close = free_context, | 250 .close = free_context, |
| 280 .parse_packet = aac_parse_packet | 251 .parse_packet = aac_parse_packet |
| 281 }; | 252 }; |
| OLD | NEW |