29 #define RTP_HEVC_PAYLOAD_HEADER_SIZE 2
30 #define RTP_HEVC_FU_HEADER_SIZE 1
31 #define RTP_HEVC_DONL_FIELD_SIZE 2
32 #define HEVC_SPECIFIED_NAL_UNIT_TYPES 48
57 av_dlog(ctx,
"hevc_init() for stream %d\n", st_index);
70 char *attr,
char *
value)
74 if (!strcmp(attr,
"profile-id")) {
91 if (!strcmp(attr,
"sprop-vps") || !strcmp(attr,
"sprop-sps") ||
92 !strcmp(attr,
"sprop-pps") || !strcmp(attr,
"sprop-sei")) {
95 if (!strcmp(attr,
"sprop-vps")) {
96 data_ptr = &hevc_data->
vps;
98 }
else if (!strcmp(attr,
"sprop-sps")) {
99 data_ptr = &hevc_data->
sps;
101 }
else if (!strcmp(attr,
"sprop-pps")) {
102 data_ptr = &hevc_data->
pps;
104 }
else if (!strcmp(attr,
"sprop-sei")) {
105 data_ptr = &hevc_data->
sei;
110 char base64packet[1024];
112 int decoded_packet_size;
113 char *dst = base64packet;
115 while (*value && *value !=
',' &&
116 (dst - base64packet) <
sizeof(base64packet) - 1) {
125 sizeof(decoded_packet));
126 if (decoded_packet_size > 0) {
131 "Unable to allocate memory for extradata!\n");
139 decoded_packet, decoded_packet_size);
156 if (!strcmp(attr,
"sprop-max-don-diff")) {
159 av_dlog(s,
"Found sprop-max-don-diff in SDP, DON field usage is: %d\n",
164 if (!strcmp(attr,
"sprop-depack-buf-nalus")) {
167 av_dlog(s,
"Found sprop-depack-buf-nalus in SDP, DON field usage is: %d\n",
186 const char *sdp_line_ptr = line;
191 current_stream = ctx->
streams[st_index];
192 codec = current_stream->
codec;
194 if (
av_strstart(sdp_line_ptr,
"framesize:", &sdp_line_ptr)) {
195 char str_video_width[50];
196 char *str_video_width_ptr = str_video_width;
203 while (*sdp_line_ptr && *sdp_line_ptr ==
' ')
206 while (*sdp_line_ptr && *sdp_line_ptr !=
' ')
209 while (*sdp_line_ptr && *sdp_line_ptr ==
' ')
212 while (*sdp_line_ptr && *sdp_line_ptr !=
'-' &&
213 (str_video_width_ptr - str_video_width) <
sizeof(str_video_width) - 1)
214 *str_video_width_ptr++ = *sdp_line_ptr++;
216 *str_video_width_ptr =
'\0';
219 codec->
width = atoi(str_video_width);
221 codec->
height = atoi(sdp_line_ptr + 1);
222 }
else if (
av_strstart(sdp_line_ptr,
"fmtp:", &sdp_line_ptr)) {
269 int tid, lid, nal_type;
270 int first_fragment, last_fragment, fu_type;
294 nal_type = (buf[0] >> 1) & 0x3f;
295 lid = ((buf[0] << 5) & 0x20) | ((buf[1] >> 3) & 0x1f);
344 "Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",
376 first_fragment = buf[0] & 0x80;
377 last_fragment = buf[0] & 0x40;
378 fu_type = buf[0] & 0x3f;
390 av_dlog(ctx,
" FU type %d with %d bytes\n", fu_type, len);
394 new_nal_header[0] = (rtp_pl[0] & 0x81) | (fu_type << 1);
395 new_nal_header[1] = rtp_pl[1];
398 if (first_fragment) {
399 if (!last_fragment) {
418 memcpy(pkt->
data, buf, len);
423 "Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",