support newer ffmpeg versions

Origin commit data
------------------
Branch: master
Commit: 752e1e4368
Author: martii <you@example.com>
Date: 2012-07-13 (Fri, 13 Jul 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2012-07-13 16:22:19 +02:00
parent 1048c08e40
commit 122fd5afa9
3 changed files with 93 additions and 0 deletions

View File

@@ -171,7 +171,9 @@ static char* Codec2Encoding(enum CodecID id, int* version)
case CODEC_ID_VC1: case CODEC_ID_VC1:
return "V_VC1"; return "V_VC1";
case CODEC_ID_H264: case CODEC_ID_H264:
#ifdef CODEC_ID_FFH264
case CODEC_ID_FFH264: case CODEC_ID_FFH264:
#endif
return "V_MPEG4/ISO/AVC"; return "V_MPEG4/ISO/AVC";
case CODEC_ID_AVS: case CODEC_ID_AVS:
return "V_AVS"; return "V_AVS";
@@ -272,16 +274,28 @@ float getDurationFromSSALine(unsigned char* line){
/* search for metatdata in context and stream /* search for metatdata in context and stream
* and map it to our metadata. * and map it to our metadata.
*/ */
#if LIBAVFORMAT_VERSION_MAJOR > 53
static char* searchMeta(AVDictionary *metadata, char* ourTag)
#else
static char* searchMeta(AVMetadata *metadata, char* ourTag) static char* searchMeta(AVMetadata *metadata, char* ourTag)
#endif
{ {
#if LIBAVFORMAT_VERSION_MAJOR > 53
AVDictionaryEntry *tag = NULL;
#else
AVMetadataTag *tag = NULL; AVMetadataTag *tag = NULL;
#endif
int i = 0; int i = 0;
while (metadata_map[i] != NULL) while (metadata_map[i] != NULL)
{ {
if (strcmp(ourTag, metadata_map[i]) == 0) if (strcmp(ourTag, metadata_map[i]) == 0)
{ {
#if LIBAVFORMAT_VERSION_MAJOR > 53
while ((tag = av_dict_get(metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
#else
while ((tag = av_metadata_get(metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) while ((tag = av_metadata_get(metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
#endif
{ {
if (strcmp(tag->key, metadata_map[ i + 1 ]) == 0) if (strcmp(tag->key, metadata_map[ i + 1 ]) == 0)
{ {
@@ -421,7 +435,11 @@ if(!context->playback->BackWard && audioMute)
} }
else else
{ {
#if LIBAVFORMAT_VERSION_MAJOR > 53
lastSeek = currentReadPosition = avio_tell(avContext->pb);
#else
lastSeek = currentReadPosition = url_ftell(avContext->pb); lastSeek = currentReadPosition = url_ftell(avContext->pb);
#endif
gotlastPts = 1; gotlastPts = 1;
#ifndef use_sec_to_seek #ifndef use_sec_to_seek
@@ -462,7 +480,11 @@ if(!context->playback->BackWard && audioMute)
int index = packet.stream_index; int index = packet.stream_index;
#if LIBAVFORMAT_VERSION_MAJOR > 53
currentReadPosition = avio_tell(avContext->pb);
#else
currentReadPosition = url_ftell(avContext->pb); currentReadPosition = url_ftell(avContext->pb);
#endif
if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0) if (context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack) < 0)
ffmpeg_err("error getting video track\n"); ffmpeg_err("error getting video track\n");
@@ -564,7 +586,11 @@ if(!context->playback->BackWard && audioMute)
avOut.len = decoded_data_size; avOut.len = decoded_data_size;
avOut.pts = pts; avOut.pts = pts;
#if LIBAVFORMAT_VERSION_MAJOR > 53
avOut.extradata = (unsigned char *) &extradata;
#else
avOut.extradata = &extradata; avOut.extradata = &extradata;
#endif
avOut.extralen = sizeof(extradata); avOut.extralen = sizeof(extradata);
avOut.frameRate = 0; avOut.frameRate = 0;
avOut.timeScale = 0; avOut.timeScale = 0;
@@ -725,7 +751,11 @@ if(!context->playback->BackWard && audioMute)
SubtitleData_t data; SubtitleData_t data;
data.data = line; data.data = line;
data.len = strlen((char*)line); data.len = strlen((char*)line);
#if LIBAVFORMAT_VERSION_MAJOR > 53
data.extradata = (unsigned char *) DEFAULT_ASS_HEAD;
#else
data.extradata = DEFAULT_ASS_HEAD; data.extradata = DEFAULT_ASS_HEAD;
#endif
data.extralen = strlen(DEFAULT_ASS_HEAD); data.extralen = strlen(DEFAULT_ASS_HEAD);
data.pts = pts; data.pts = pts;
data.duration = duration; data.duration = duration;
@@ -797,7 +827,11 @@ int container_ffmpeg_init(Context_t *context, char * filename)
avcodec_register_all(); avcodec_register_all();
av_register_all(); av_register_all();
#if LIBAVFORMAT_VERSION_MAJOR > 53
if ((err = avformat_open_input(&avContext, filename, NULL, 0)) != 0) {
#else
if ((err = av_open_input_file(&avContext, filename, NULL, 0, NULL)) != 0) { if ((err = av_open_input_file(&avContext, filename, NULL, 0, NULL)) != 0) {
#endif
char error[512]; char error[512];
ffmpeg_err("av_open_input_file failed %d (%s)\n", err, filename); ffmpeg_err("av_open_input_file failed %d (%s)\n", err, filename);
@@ -827,7 +861,11 @@ int container_ffmpeg_init(Context_t *context, char * filename)
ffmpeg_printf(20, "dump format\n"); ffmpeg_printf(20, "dump format\n");
#if LIBAVFORMAT_VERSION_MAJOR > 53
av_dump_format(avContext, 0, filename, 0);
#else
dump_format(avContext, 0, filename, 0); dump_format(avContext, 0, filename, 0);
#endif
ffmpeg_printf(1, "number streams %d\n", avContext->nb_streams); ffmpeg_printf(1, "number streams %d\n", avContext->nb_streams);
@@ -1277,7 +1315,11 @@ static int container_ffmpeg_stop(Context_t *context) {
static int container_ffmpeg_seek_bytes(off_t pos) { static int container_ffmpeg_seek_bytes(off_t pos) {
int flag = AVSEEK_FLAG_BYTE; int flag = AVSEEK_FLAG_BYTE;
#if LIBAVFORMAT_VERSION_MAJOR > 53
off_t current_pos = avio_tell(avContext->pb);
#else
off_t current_pos = url_ftell(avContext->pb); off_t current_pos = url_ftell(avContext->pb);
#endif
ffmpeg_printf(20, "seeking to position %lld (bytes)\n", pos); ffmpeg_printf(20, "seeking to position %lld (bytes)\n", pos);
@@ -1290,7 +1332,11 @@ static int container_ffmpeg_seek_bytes(off_t pos) {
return cERR_CONTAINER_FFMPEG_ERR; return cERR_CONTAINER_FFMPEG_ERR;
} }
#if LIBAVFORMAT_VERSION_MAJOR > 53
ffmpeg_printf(30, "current_pos after seek %lld\n", avio_tell(avContext->pb));
#else
ffmpeg_printf(30, "current_pos after seek %lld\n", url_ftell(avContext->pb)); ffmpeg_printf(30, "current_pos after seek %lld\n", url_ftell(avContext->pb));
#endif
return cERR_CONTAINER_FFMPEG_NO_ERROR; return cERR_CONTAINER_FFMPEG_NO_ERROR;
} }
@@ -1299,7 +1345,11 @@ static int container_ffmpeg_seek_bytes(off_t pos) {
static int container_ffmpeg_seek_bytes_rel(off_t start, off_t bytes) { static int container_ffmpeg_seek_bytes_rel(off_t start, off_t bytes) {
int flag = AVSEEK_FLAG_BYTE; int flag = AVSEEK_FLAG_BYTE;
off_t newpos; off_t newpos;
#if LIBAVFORMAT_VERSION_MAJOR > 53
off_t current_pos = avio_tell(avContext->pb);
#else
off_t current_pos = url_ftell(avContext->pb); off_t current_pos = url_ftell(avContext->pb);
#endif
if (start == -1) if (start == -1)
start = current_pos; start = current_pos;
@@ -1328,7 +1378,11 @@ static int container_ffmpeg_seek_bytes_rel(off_t start, off_t bytes) {
return cERR_CONTAINER_FFMPEG_ERR; return cERR_CONTAINER_FFMPEG_ERR;
} }
#if LIBAVFORMAT_VERSION_MAJOR > 53
ffmpeg_printf(30, "current_pos after seek %lld\n", avio_tell(avContext->pb));
#else
ffmpeg_printf(30, "current_pos after seek %lld\n", url_ftell(avContext->pb)); ffmpeg_printf(30, "current_pos after seek %lld\n", url_ftell(avContext->pb));
#endif
return cERR_CONTAINER_FFMPEG_NO_ERROR; return cERR_CONTAINER_FFMPEG_NO_ERROR;
} }
@@ -1357,7 +1411,11 @@ static int container_ffmpeg_seek_rel(Context_t *context, off_t pos, long long in
if (pos == -1) if (pos == -1)
{ {
#if LIBAVFORMAT_VERSION_MAJOR > 53
pos = avio_tell(avContext->pb);
#else
pos = url_ftell(avContext->pb); pos = url_ftell(avContext->pb);
#endif
} }
if (pts == -1) if (pts == -1)
@@ -1483,7 +1541,11 @@ static int container_ffmpeg_seek(Context_t *context, float sec) {
* about 10 seconds, backward does not work. * about 10 seconds, backward does not work.
*/ */
#if LIBAVFORMAT_VERSION_MAJOR > 53
off_t pos = avio_tell(avContext->pb);
#else
off_t pos = url_ftell(avContext->pb); off_t pos = url_ftell(avContext->pb);
#endif
ffmpeg_printf(10, "pos %lld %d\n", pos, avContext->bit_rate); ffmpeg_printf(10, "pos %lld %d\n", pos, avContext->bit_rate);

View File

@@ -24,6 +24,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
// >>> MARTII
#include <libavformat/avformat.h>
// <<< MARTII
#include "manager.h" #include "manager.h"
#include "common.h" #include "common.h"
@@ -214,6 +217,17 @@ static int Command(void *_context, ManagerCmd_t command, void * argument) {
case MANAGER_SET: { case MANAGER_SET: {
int id = *((int*)argument); int id = *((int*)argument);
// >>> MARTII
// What's the argument supposed to be? apid or local index? --martii
if (id >= TrackCount) {
int apid = id;
for (id = 0; id < TrackCount; id++) {
if (((AVStream *) (Tracks[id].stream))->id == apid)
break;
}
}
// <<< MARTII
audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, id); audio_mgr_printf(20, "%s::%s MANAGER_SET id=%d\n", FILENAME, __FUNCTION__, id);
if (id < TrackCount) if (id < TrackCount)

View File

@@ -16,8 +16,13 @@ static AVFormatContext* avContext = NULL;
void dump_metadata() void dump_metadata()
{ {
#if LIBAVFORMAT_VERSION_MAJOR > 53
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(avContext->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
#else
AVMetadataTag *tag = NULL; AVMetadataTag *tag = NULL;
while ((tag = av_metadata_get(avContext->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) while ((tag = av_metadata_get(avContext->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
#endif
printf("%s: %s\n", tag->key, tag->value); printf("%s: %s\n", tag->key, tag->value);
} }
@@ -42,7 +47,11 @@ int main(int argc,char* argv[])
av_register_all(); av_register_all();
#if LIBAVFORMAT_VERSION_MAJOR > 53
if ((err = avformat_open_input(&avContext, file, NULL, 0)) != 0) {
#else
if ((err = av_open_input_file(&avContext, file, NULL, 0, NULL)) != 0) { if ((err = av_open_input_file(&avContext, file, NULL, 0, NULL)) != 0) {
#endif
char error[512]; char error[512];
printf("av_open_input_file failed %d (%s)\n", err, file); printf("av_open_input_file failed %d (%s)\n", err, file);
@@ -67,10 +76,18 @@ int main(int argc,char* argv[])
if (stream) if (stream)
{ {
#if LIBAVFORMAT_VERSION_MAJOR > 53
AVDictionaryEntry *tag = NULL;
#else
AVMetadataTag *tag = NULL; AVMetadataTag *tag = NULL;
#endif
if (stream->metadata != NULL) if (stream->metadata != NULL)
#if LIBAVFORMAT_VERSION_MAJOR > 53
while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
#else
while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
#endif
printf("%s: %s\n", tag->key, tag->value); printf("%s: %s\n", tag->key, tag->value);
} }
} }