metadata: add libavcodec > 54 compatibility

libavcodec55 brings some API changes, including CodecID => AVCodecID.
Add a compatibility wrapper so we can build with libavcodec >= 55.
This commit is contained in:
Justin Maggard 2014-05-14 15:44:15 -07:00
parent 8e05f9b6f7
commit 361bc34f93
2 changed files with 40 additions and 19 deletions

21
libav.h
View File

@ -78,6 +78,27 @@
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
#endif #endif
#if LIBAVCODEC_VERSION_MAJOR < 55
#define AV_CODEC_ID_AAC CODEC_ID_AAC
#define AV_CODEC_ID_AC3 CODEC_ID_AC3
#define AV_CODEC_ID_ADPCM_IMA_QT CODEC_ID_ADPCM_IMA_QT
#define AV_CODEC_ID_AMR_NB CODEC_ID_AMR_NB
#define AV_CODEC_ID_DTS CODEC_ID_DTS
#define AV_CODEC_ID_H264 CODEC_ID_H264
#define AV_CODEC_ID_MP2 CODEC_ID_MP2
#define AV_CODEC_ID_MP3 CODEC_ID_MP3
#define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO
#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
#define AV_CODEC_ID_MSMPEG4V3 CODEC_ID_MSMPEG4V3
#define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE
#define AV_CODEC_ID_VC1 CODEC_ID_VC1
#define AV_CODEC_ID_WMAPRO CODEC_ID_WMAPRO
#define AV_CODEC_ID_WMAV1 CODEC_ID_WMAV1
#define AV_CODEC_ID_WMAV2 CODEC_ID_WMAV2
#define AV_CODEC_ID_WMV3 CODEC_ID_WMV3
#endif
#if LIBAVUTIL_VERSION_INT < ((50<<16)+(13<<8)+0) #if LIBAVUTIL_VERSION_INT < ((50<<16)+(13<<8)+0)
#define av_strerror(x, y, z) snprintf(y, z, "%d", x) #define av_strerror(x, y, z) snprintf(y, z, "%d", x)
#endif #endif

View File

@ -773,10 +773,10 @@ GetVideoMetadata(const char *path, char *name)
aac_object_type_t aac_type = AAC_INVALID; aac_object_type_t aac_type = AAC_INVALID;
switch( ac->codec_id ) switch( ac->codec_id )
{ {
case CODEC_ID_MP3: case AV_CODEC_ID_MP3:
audio_profile = PROFILE_AUDIO_MP3; audio_profile = PROFILE_AUDIO_MP3;
break; break;
case CODEC_ID_AAC: case AV_CODEC_ID_AAC:
if( !ac->extradata_size || if( !ac->extradata_size ||
!ac->extradata ) !ac->extradata )
{ {
@ -817,12 +817,12 @@ GetVideoMetadata(const char *path, char *name)
break; break;
} }
break; break;
case CODEC_ID_AC3: case AV_CODEC_ID_AC3:
case CODEC_ID_DTS: case AV_CODEC_ID_DTS:
audio_profile = PROFILE_AUDIO_AC3; audio_profile = PROFILE_AUDIO_AC3;
break; break;
case CODEC_ID_WMAV1: case AV_CODEC_ID_WMAV1:
case CODEC_ID_WMAV2: case AV_CODEC_ID_WMAV2:
/* WMA Baseline: stereo, up to 48 KHz, up to 192,999 bps */ /* WMA Baseline: stereo, up to 48 KHz, up to 192,999 bps */
if ( ac->bit_rate <= 193000 ) if ( ac->bit_rate <= 193000 )
audio_profile = PROFILE_AUDIO_WMA_BASE; audio_profile = PROFILE_AUDIO_WMA_BASE;
@ -831,19 +831,19 @@ GetVideoMetadata(const char *path, char *name)
audio_profile = PROFILE_AUDIO_WMA_FULL; audio_profile = PROFILE_AUDIO_WMA_FULL;
break; break;
#if LIBAVCODEC_VERSION_INT > ((51<<16)+(50<<8)+1) #if LIBAVCODEC_VERSION_INT > ((51<<16)+(50<<8)+1)
case CODEC_ID_WMAPRO: case AV_CODEC_ID_WMAPRO:
audio_profile = PROFILE_AUDIO_WMA_PRO; audio_profile = PROFILE_AUDIO_WMA_PRO;
break; break;
#endif #endif
case CODEC_ID_MP2: case AV_CODEC_ID_MP2:
audio_profile = PROFILE_AUDIO_MP2; audio_profile = PROFILE_AUDIO_MP2;
break; break;
case CODEC_ID_AMR_NB: case AV_CODEC_ID_AMR_NB:
audio_profile = PROFILE_AUDIO_AMR; audio_profile = PROFILE_AUDIO_AMR;
break; break;
default: default:
if( (ac->codec_id >= CODEC_ID_PCM_S16LE) && if( (ac->codec_id >= AV_CODEC_ID_PCM_S16LE) &&
(ac->codec_id < CODEC_ID_ADPCM_IMA_QT) ) (ac->codec_id < AV_CODEC_ID_ADPCM_IMA_QT) )
audio_profile = PROFILE_AUDIO_PCM; audio_profile = PROFILE_AUDIO_PCM;
else else
DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [0x%X]\n", ac->codec_id); DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [0x%X]\n", ac->codec_id);
@ -880,7 +880,7 @@ GetVideoMetadata(const char *path, char *name)
if( strcmp(ctx->iformat->name, "avi") == 0 ) if( strcmp(ctx->iformat->name, "avi") == 0 )
{ {
xasprintf(&m.mime, "video/x-msvideo"); xasprintf(&m.mime, "video/x-msvideo");
if( vc->codec_id == CODEC_ID_MPEG4 ) if( vc->codec_id == AV_CODEC_ID_MPEG4 )
{ {
fourcc[0] = vc->codec_tag & 0xff; fourcc[0] = vc->codec_tag & 0xff;
fourcc[1] = vc->codec_tag>>8 & 0xff; fourcc[1] = vc->codec_tag>>8 & 0xff;
@ -904,7 +904,7 @@ GetVideoMetadata(const char *path, char *name)
switch( vc->codec_id ) switch( vc->codec_id )
{ {
case CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG1VIDEO:
if( strcmp(ctx->iformat->name, "mpeg") == 0 ) if( strcmp(ctx->iformat->name, "mpeg") == 0 )
{ {
if( (vc->width == 352) && if( (vc->width == 352) &&
@ -915,7 +915,7 @@ GetVideoMetadata(const char *path, char *name)
xasprintf(&m.mime, "video/mpeg"); xasprintf(&m.mime, "video/mpeg");
} }
break; break;
case CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
m.dlna_pn = malloc(64); m.dlna_pn = malloc(64);
off = sprintf(m.dlna_pn, "MPEG_"); off = sprintf(m.dlna_pn, "MPEG_");
if( strcmp(ctx->iformat->name, "mpegts") == 0 ) if( strcmp(ctx->iformat->name, "mpegts") == 0 )
@ -988,7 +988,7 @@ GetVideoMetadata(const char *path, char *name)
m.dlna_pn = NULL; m.dlna_pn = NULL;
} }
break; break;
case CODEC_ID_H264: case AV_CODEC_ID_H264:
m.dlna_pn = malloc(128); m.dlna_pn = malloc(128);
off = sprintf(m.dlna_pn, "AVC_"); off = sprintf(m.dlna_pn, "AVC_");
@ -1299,7 +1299,7 @@ GetVideoMetadata(const char *path, char *name)
} }
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is h.264\n", video_stream, basepath); DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is h.264\n", video_stream, basepath);
break; break;
case CODEC_ID_MPEG4: case AV_CODEC_ID_MPEG4:
fourcc[0] = vc->codec_tag & 0xff; fourcc[0] = vc->codec_tag & 0xff;
fourcc[1] = vc->codec_tag>>8 & 0xff; fourcc[1] = vc->codec_tag>>8 & 0xff;
fourcc[2] = vc->codec_tag>>16 & 0xff; fourcc[2] = vc->codec_tag>>16 & 0xff;
@ -1362,7 +1362,7 @@ GetVideoMetadata(const char *path, char *name)
} }
} }
break; break;
case CODEC_ID_WMV3: case AV_CODEC_ID_WMV3:
/* I'm not 100% sure this is correct, but it works on everything I could get my hands on */ /* I'm not 100% sure this is correct, but it works on everything I could get my hands on */
if( vc->extradata_size > 0 ) if( vc->extradata_size > 0 )
{ {
@ -1371,7 +1371,7 @@ GetVideoMetadata(const char *path, char *name)
if( !((vc->extradata[0] >> 6) & 1) ) if( !((vc->extradata[0] >> 6) & 1) )
vc->profile = 0; vc->profile = 0;
} }
case CODEC_ID_VC1: case AV_CODEC_ID_VC1:
if( strcmp(ctx->iformat->name, "asf") != 0 ) if( strcmp(ctx->iformat->name, "asf") != 0 )
{ {
DPRINTF(E_DEBUG, L_METADATA, "Skipping DLNA parsing for non-ASF VC1 file %s\n", path); DPRINTF(E_DEBUG, L_METADATA, "Skipping DLNA parsing for non-ASF VC1 file %s\n", path);
@ -1470,7 +1470,7 @@ GetVideoMetadata(const char *path, char *name)
} }
} }
break; break;
case CODEC_ID_MSMPEG4V3: case AV_CODEC_ID_MSMPEG4V3:
xasprintf(&m.mime, "video/x-msvideo"); xasprintf(&m.mime, "video/x-msvideo");
default: default:
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s [type %d]\n", DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s [type %d]\n",