diff libmpdemux/demux_lavf.c @ 19598:4cff22c91b39

added lavfdopts to pass options to libavformat
author nicodvb
date Wed, 30 Aug 2006 22:25:40 +0000
parents c636a4e9565a
children 27c747718955
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Wed Aug 30 22:25:26 2006 +0000
+++ b/libmpdemux/demux_lavf.c	Wed Aug 30 22:25:40 2006 +0000
@@ -27,17 +27,27 @@
 #include "stream.h"
 #include "demuxer.h"
 #include "stheader.h"
+#include "m_option.h"
 
 #ifdef USE_LIBAVFORMAT_SO
 #include <ffmpeg/avformat.h>
+#include <ffmpeg/opt.h>
 #else
 #include "avformat.h"
 #include "avi.h"
+#include "opt.h"
 #endif
 
 #define PROBE_BUF_SIZE 2048
 
 extern char *audio_lang;
+static unsigned int opt_probesize = 0;
+
+m_option_t lavfdopts_conf[] = {
+	{"probesize", &(opt_probesize), CONF_TYPE_INT, CONF_RANGE, 32, INT_MAX, NULL},
+	{NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
 
 typedef struct lavf_priv_t{
     AVInputFormat *avif;
@@ -136,6 +146,7 @@
 static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
     AVFormatContext *avfc;
     AVFormatParameters ap;
+    AVOption *opt;
     lavf_priv_t *priv= demuxer->priv;
     int i,g;
     char mp_filename[256]="mp:";
@@ -146,6 +157,14 @@
 
     register_protocol(&mp_protocol);
 
+    avfc = av_alloc_format_context();
+    ap.prealloced_context = 1;
+    if(opt_probesize) {
+        double d = (double) opt_probesize;
+        opt = av_set_double(avfc, "probesize", opt_probesize);
+        if(!opt) mp_msg(MSGT_HEADER,MSGL_ERR, "demux_lavf, couldn't set option probesize to %.3f\r\n", d);
+    }
+
     if(demuxer->stream->url)
         strncpy(mp_filename + 3, demuxer->stream->url, sizeof(mp_filename)-3);
     else