Skip to content

Commit

Permalink
pass correct context to KMP_log_mediainfo
Browse files Browse the repository at this point in the history
  • Loading branch information
igorshevach committed Sep 12, 2024
1 parent 81e9e37 commit 5a35aea
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion nginx-kmp-out-module/src/ngx_kmp_out_track.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,61 @@ ngx_kmp_out_track_write(ngx_kmp_out_track_t *track, u_char *data,
return ngx_kmp_out_track_write_chain(track, &in, data);
}

static ngx_int_t
ngx_kmp_out_track_log_media_info(ngx_kmp_out_track_t *track)
{
u_char *buf = NULL,
*p;

if(track->extra_data.len > 0)
{
buf = ngx_pnalloc(track->pool, 2 * track->extra_data.len + 1);
if(!buf)
{
ngx_log_error(NGX_LOG_ERR, &track->log, 0,
"ngx_kmp_out_track_log_media_info:"
"failed to allocate buffer for extra data size %uD",
2 * track->extra_data.len + 1);
return NGX_ERROR;
}

p = ngx_hex_dump(buf, track->extra_data.data, track->extra_data.len);
*p = 0;
}

ngx_log_error(NGX_LOG_INFO, &track->log, 0,
"ngx_kmp_out_track_log_media_info:"
" media_type: %uD codec_id: %uD"
" timescale: %uD bitrate: %uD"
" extra_data: %s",
track->media_info.media_type, track->media_info.codec_id,
track->media_info.timescale, track->media_info.bitrate, buf);
switch(track->media_info.media_type)
{
case KMP_MEDIA_VIDEO:
ngx_log_error(NGX_LOG_INFO, &track->log, 0,
"ngx_kmp_out_track_log_media_info: video"
" width: %uD height: %uD frame_rate: %uD/%uD cea_captions: %s",
track->media_info.u.video.width, track->media_info.u.video.height,
track->media_info.u.video.frame_rate.num, track->media_info.u.video.frame_rate.denom,
track->media_info.u.video.cea_captions ? "true" : "false");
break;
case KMP_MEDIA_AUDIO:
ngx_log_error(NGX_LOG_INFO, &track->log, 0,
"ngx_kmp_out_track_write_media_info: audio"
" channels: %uD bits_per_sample: %uD sample_rate: %uD channel_layout: %uD",
track->media_info.u.audio.channels, track->media_info.u.audio.bits_per_sample,
track->media_info.u.audio.sample_rate, track->media_info.u.audio.channel_layout);
break;
};

if(buf)
{
ngx_pfree(track->pool, buf);
}

return NGX_OK;
}

ngx_int_t
ngx_kmp_out_track_write_media_info(ngx_kmp_out_track_t *track)
Expand Down Expand Up @@ -1238,10 +1293,11 @@ ngx_kmp_out_track_write_media_info(ngx_kmp_out_track_t *track)
return NGX_ERROR;
}

ngx_kmp_out_track_log_media_info(track);

return NGX_OK;
}


static void
ngx_kmp_out_track_chain_md5_hex(u_char dst[32], ngx_chain_t *in, u_char *p)
{
Expand Down

0 comments on commit 5a35aea

Please sign in to comment.