summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_lavf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpdemux/demux_lavf.c')
-rw-r--r--libmpdemux/demux_lavf.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index a7da1a9b36..310ec83c09 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -140,12 +140,6 @@ static int lavf_check_file(demuxer_t *demuxer){
av_register_all();
- if(stream_read(demuxer->stream, buf, PROBE_BUF_SIZE)!=PROBE_BUF_SIZE)
- return 0;
- avpd.filename= demuxer->stream->url;
- avpd.buf= buf;
- avpd.buf_size= PROBE_BUF_SIZE;
-
if (opt_format) {
if (strcmp(opt_format, "help") == 0) {
list_formats();
@@ -159,6 +153,13 @@ static int lavf_check_file(demuxer_t *demuxer){
mp_msg(MSGT_DEMUX,MSGL_INFO,"Forced lavf %s demuxer\n", priv->avif->long_name);
return DEMUXER_TYPE_LAVF;
}
+
+ if(stream_read(demuxer->stream, buf, PROBE_BUF_SIZE)!=PROBE_BUF_SIZE)
+ return 0;
+ avpd.filename= demuxer->stream->url;
+ avpd.buf= buf;
+ avpd.buf_size= PROBE_BUF_SIZE;
+
priv->avif= av_probe_input_format(&avpd, 1);
if(!priv->avif){
mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: no clue about this gibberish!\n");
@@ -169,7 +170,7 @@ static int lavf_check_file(demuxer_t *demuxer){
return DEMUXER_TYPE_LAVF;
}
-static const char *preferred_list[] = {
+static const char * const preferred_list[] = {
"dxa",
"wv",
"nuv",
@@ -186,7 +187,7 @@ static const char *preferred_list[] = {
static int lavf_check_preferred_file(demuxer_t *demuxer){
if (lavf_check_file(demuxer)) {
- char **p = preferred_list;
+ const char * const *p = preferred_list;
lavf_priv_t *priv = demuxer->priv;
while (*p) {
if (strcmp(*p, priv->avif->name) == 0)
@@ -218,21 +219,21 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
lavf_priv_t *priv= demuxer->priv;
AVStream *st= avfc->streams[i];
AVCodecContext *codec= st->codec;
+ AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0);
int g;
switch(codec->codec_type){
case CODEC_TYPE_AUDIO:{
int override_tag;
- WAVEFORMATEX *wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
+ WAVEFORMATEX *wf;
sh_audio_t* sh_audio;
- if(priv->audio_streams >= MAX_A_STREAMS)
- break;
sh_audio=new_sh_audio(demuxer, i);
mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "lavf", i);
if(!sh_audio)
break;
priv->astreams[priv->audio_streams] = i;
priv->audio_streams++;
+ wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
// For some formats (like PCM) always trust CODEC_ID_* more than codec_tag
override_tag= av_codec_get_tag(mp_wav_override_taglists, codec->codec_id);
if (override_tag)
@@ -289,8 +290,10 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
sh_audio->format = 0x7;
break;
}
- if (st->language)
- sh_audio->lang = strdup(st->language);
+ if (lang && lang->value) {
+ sh_audio->lang = strdup(lang->value);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", i, sh_audio->lang);
+ }
if (st->disposition & AV_DISPOSITION_DEFAULT)
sh_audio->default_track = 1;
if(mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf, MSGL_V);
@@ -305,8 +308,6 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
case CODEC_TYPE_VIDEO:{
sh_video_t* sh_video;
BITMAPINFOHEADER *bih;
- if(priv->video_streams >= MAX_V_STREAMS)
- break;
sh_video=new_sh_video(demuxer, i);
mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Video stream found, -vid %d\n", "lavf", i);
if(!sh_video) break;
@@ -374,8 +375,6 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
case CODEC_TYPE_SUBTITLE:{
sh_sub_t* sh_sub;
char type;
- if(priv->sub_streams >= MAX_S_STREAMS)
- break;
/* only support text subtitles for now */
if(codec->codec_id == CODEC_ID_TEXT)
type = 't';
@@ -397,8 +396,10 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
memcpy(sh_sub->extradata, codec->extradata, codec->extradata_size);
sh_sub->extradata_len = codec->extradata_size;
}
- if (st->language)
- sh_sub->lang = strdup(st->language);
+ if (lang && lang->value) {
+ sh_sub->lang = strdup(lang->value);
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", priv->sub_streams, sh_sub->lang);
+ }
if (st->disposition & AV_DISPOSITION_DEFAULT)
sh_sub->default_track = 1;
priv->sub_streams++;
@@ -476,7 +477,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
return NULL;
}
- if(avfc->title [0]) demux_info_add(demuxer, "name" , avfc->title );
+ if(avfc->title [0]) demux_info_add(demuxer, "title" , avfc->title );
if(avfc->author [0]) demux_info_add(demuxer, "author" , avfc->author );
if(avfc->copyright[0]) demux_info_add(demuxer, "copyright", avfc->copyright);
if(avfc->comment [0]) demux_info_add(demuxer, "comments" , avfc->comment );