64 int packet_types_received[32];
68 #define MAGIC_COOKIE (0xdeadbeef)
69 #define DEAD_COOKIE (0xdeaddead)
74 char *attr,
char *value)
78 assert(h264_data !=
NULL);
80 if (!strcmp(attr,
"packetization-mode")) {
91 "Interleaved RTP mode is not supported yet.");
92 }
else if (!strcmp(attr,
"profile-level-id")) {
93 if (strlen(value) == 6) {
100 buffer[0] = value[0]; buffer[1] = value[1]; buffer[2] =
'\0';
101 profile_idc = strtol(buffer,
NULL, 16);
102 buffer[0] = value[2]; buffer[1] = value[3];
103 profile_iop = strtol(buffer,
NULL, 16);
104 buffer[0] = value[4]; buffer[1] = value[5];
105 level_idc = strtol(buffer,
NULL, 16);
109 "RTP Profile IDC: %x Profile IOP: %x Level: %x\n",
110 profile_idc, profile_iop, level_idc);
115 }
else if (!strcmp(attr,
"sprop-parameter-sets")) {
116 uint8_t start_sequence[]= { 0, 0, 1 };
121 char base64packet[1024];
122 uint8_t decoded_packet[1024];
124 char *dst = base64packet;
126 while (*value && *value !=
','
127 && (dst - base64packet) <
sizeof(base64packet) - 1) {
135 packet_size=
av_base64_decode(decoded_packet, base64packet,
sizeof(decoded_packet));
136 if (packet_size > 0) {
137 uint8_t *dest =
av_malloc(packet_size +
sizeof(start_sequence) +
149 memcpy(dest+codec->
extradata_size, start_sequence,
sizeof(start_sequence));
150 memcpy(dest+codec->
extradata_size+
sizeof(start_sequence), decoded_packet, packet_size);
172 uint32_t * timestamp,
176 uint8_t nal = buf[0];
177 uint8_t type = (nal & 0x1f);
179 uint8_t start_sequence[]= {0, 0, 1};
187 if (type >= 1 && type <= 23)
193 memcpy(pkt->
data, start_sequence,
sizeof(start_sequence));
194 memcpy(pkt->
data+
sizeof(start_sequence), buf, len);
196 data->packet_types_received[nal & 0x1f]++;
210 for(pass= 0; pass<2; pass++) {
211 const uint8_t *src= buf;
215 uint16_t nal_size =
AV_RB16(src);
221 if (nal_size <= src_len) {
224 total_length+=
sizeof(start_sequence)+nal_size;
228 memcpy(dst, start_sequence,
sizeof(start_sequence));
229 dst+=
sizeof(start_sequence);
230 memcpy(dst, src, nal_size);
232 data->packet_types_received[*src & 0x1f]++;
238 "nal size exceeds length: %d %d\n", nal_size, src_len);
247 "Consumed more bytes than we got! (%d)\n", src_len);
248 }
while (src_len > 2);
255 assert(dst-pkt->
data==total_length);
266 "Unhandled type (%d) (See RFC for implementation details\n",
276 uint8_t fu_indicator = nal;
277 uint8_t fu_header = *buf;
278 uint8_t start_bit = fu_header >> 7;
280 uint8_t nal_type = (fu_header & 0x1f);
281 uint8_t reconstructed_nal;
284 reconstructed_nal = fu_indicator & (0xe0);
285 reconstructed_nal |= nal_type;
293 data->packet_types_received[nal_type]++;
298 memcpy(pkt->
data, start_sequence,
sizeof(start_sequence));
299 pkt->
data[
sizeof(start_sequence)]= reconstructed_nal;
300 memcpy(pkt->
data+
sizeof(start_sequence)+
sizeof(nal), buf, len);
303 memcpy(pkt->
data, buf, len);
340 for (ii = 0; ii < 32; ii++) {
341 if (data->packet_types_received[ii])
343 data->packet_types_received[ii], ii);
362 const char *p = line;
371 while (*p && *p ==
' ') p++;
372 while (*p && *p !=
' ') p++;
373 while (*p && *p ==
' ') p++;
374 while (*p && *p !=
'-' && (dst - buf1) <
sizeof(buf1) - 1) {
381 codec->
width = atoi(buf1);
382 codec->
height = atoi(p + 1);