feed av_log() through mp_msg()

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20757 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
michael 2006-11-07 19:52:47 +00:00
parent 1052ab502a
commit 3c49701490
1 changed files with 49 additions and 0 deletions

View File

@ -167,6 +167,54 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){
return CONTROL_UNKNOWN;
}
void mp_msp_av_log_callback(void* ptr, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
int type= MSGT_FIXME;
int mp_level;
char buf[256];
if(ptr){
if(!strcmp(avc->class_name, "AVCodecContext")){
AVCodecContext * s= ptr;
if(s->codec){
if(s->codec->type == CODEC_TYPE_AUDIO){
if(s->codec->decode)
type= MSGT_DECAUDIO;
}else if(s->codec->type == CODEC_TYPE_VIDEO){
if(s->codec->decode)
type= MSGT_DECVIDEO;
}
//FIXME subtitles, encoders (what msgt for them? there is no appropiate ...)
}
}else if(!strcmp(avc->class_name, "AVFormatContext")){
#if 0 //needs libavformat include FIXME iam too lazy to do this cleanly,probably the whole should be moved out of this file ...
AVFormatContext * s= ptr;
if(s->iformat)
type= MSGT_DEMUXER;
else if(s->oformat)
type= MSGT_MUXER;
#endif
}
}
switch(level){
case AV_LOG_DEBUG: mp_level= MSGL_V ; break;
case AV_LOG_INFO : mp_level= MSGL_INFO; break;
case AV_LOG_ERROR: mp_level= MSGL_ERR ; break;
default : mp_level= MSGL_ERR ; break;
}
if(print_prefix && avc) {
mp_msg(type, mp_level, "[%s @ %p]", avc->item_name(ptr), avc);
}
print_prefix= strstr(fmt, "\n") != NULL;
vsnprintf(buf, sizeof(buf), fmt, vl);
mp_msg(type, mp_level, buf);
}
// init driver
static int init(sh_video_t *sh){
AVCodecContext *avctx;
@ -179,6 +227,7 @@ static int init(sh_video_t *sh){
avcodec_init();
avcodec_register_all();
avcodec_inited=1;
av_log_set_callback(mp_msp_av_log_callback);
}
ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx));