@@ -781,3 +781,67 @@ bool KMP_read_ack(KMP_session_t *context,uint64_t* frame_id)
781
781
}
782
782
return false;
783
783
}
784
+
785
+ static const char * hex = "0123456789ABCDEF" ;
786
+
787
+ int KMP_log_mediainfo (KMP_session_t * context ,
788
+ const char * category , int level ,
789
+ transcode_mediaInfo_t * transcodeMediaInfo ) {
790
+
791
+ AVCodecParameters * params = transcodeMediaInfo -> codecParams ;
792
+
793
+ if (!params ){
794
+ return -1 ;
795
+ }
796
+
797
+ char * ex = NULL ;
798
+ if (params -> extradata_size > 0 ){
799
+ ex = av_malloc (2 * params -> extradata_size + 1 );
800
+ char * walk = ex ;
801
+ for (int i = 0 ; i < params -> extradata_size ; i ++ ) {
802
+ * walk ++ = hex [params -> extradata [i ] >> 4 ];
803
+ * walk ++ = hex [params -> extradata [i ] & 0x0f ];
804
+ }
805
+ * walk = '\0' ;
806
+ }
807
+
808
+ if (params -> codec_type == AVMEDIA_TYPE_AUDIO ) {
809
+
810
+ LOGGER (category ,level ,"[%s] KMP_PACKET_MEDIA_INFO type=audio"
811
+ " codec_id=%s (0x%x) samplerate=%d bps=%d channels=%d channel_layout=%d"
812
+ " bitrate=%.3f kbps timescale=%d:%d"
813
+ " extra_data=%s" ,
814
+ context -> sessionName ,
815
+ avcodec_get_name (params -> codec_id ),
816
+ params -> codec_tag ,
817
+ params -> sample_rate ,
818
+ params -> bits_per_coded_sample ,
819
+ params -> channels ,
820
+ params -> channel_layout ,
821
+ params -> bit_rate / 1000.0 , transcodeMediaInfo -> timeScale .num , transcodeMediaInfo -> timeScale .den ,
822
+ ex );
823
+ }
824
+ else if (params -> codec_type == AVMEDIA_TYPE_VIDEO ) {
825
+
826
+ LOGGER (category ,level ,"[%s] KMP_PACKET_MEDIA_INFO type=video"
827
+ " codec_id=%s (0x%x) width=%d height=%d frame_rate=%d:%d"
828
+ " bitrate=%.3f kbps timescale=%d:%d"
829
+ " cc=%s extra_data=%s" ,
830
+ context -> sessionName ,
831
+ avcodec_get_name (params -> codec_id ),
832
+ params -> codec_tag ,
833
+ params -> width ,
834
+ params -> height ,
835
+ transcodeMediaInfo -> frameRate .num , transcodeMediaInfo -> frameRate .den ,
836
+ params -> bit_rate / 1000.0 , transcodeMediaInfo -> timeScale .num , transcodeMediaInfo -> timeScale .den ,
837
+ transcodeMediaInfo -> closed_captions ? "yes" : "no" ,
838
+ ex );
839
+ }
840
+
841
+ if (ex ) {
842
+ av_free (ex );
843
+ }
844
+
845
+ return 0 ;
846
+ }
847
+
0 commit comments