From 52c3eb69765a0d1070bf240353095c8ff546765b Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 11 Jul 2013 21:10:42 +0200 Subject: core: change open_stream and demux_open signature This removes the dependency on DEMUXER_TYPE_* and the file_format parameter from the stream open functions. Remove some of the playlist handling code. It looks like this was needed only for loading linked mov files with demux_mov (which was removed long ago). Delete a minor bit of dead network-related code from stream.c as well. --- stream/stream.c | 42 ++++++++++-------------------------------- stream/stream.h | 7 +++---- stream/stream_avdevice.c | 4 ++-- stream/stream_bluray.c | 3 +-- stream/stream_cdda.c | 4 ++-- stream/stream_dvb.c | 4 ++-- stream/stream_dvd.c | 7 ++++--- stream/stream_file.c | 3 ++- stream/stream_lavf.c | 10 +++++----- stream/stream_memory.c | 2 +- stream/stream_mf.c | 4 ++-- stream/stream_null.c | 3 ++- stream/stream_pvr.c | 2 +- stream/stream_radio.c | 5 +++-- stream/stream_smb.c | 3 ++- stream/stream_tv.c | 4 ++-- stream/stream_vcd.c | 5 +++-- 17 files changed, 47 insertions(+), 65 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index 3dc25d7880..32ae0047be 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -131,10 +131,8 @@ static stream_t *new_stream(size_t min_size); static int stream_seek_unbuffered(stream_t *s, int64_t newpos); static stream_t *open_stream_plugin(const stream_info_t *sinfo, - const char *filename, - int mode, struct MPOpts *options, - int *file_format, int *ret, - char **redirected_url) + const char *filename, int mode, + struct MPOpts *options, int *ret) { void *arg = NULL; stream_t *s; @@ -162,7 +160,7 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo, s->url = strdup(filename); s->flags = 0; s->mode = mode; - *ret = sinfo->open(s, mode, arg, file_format); + *ret = sinfo->open(s, mode, arg); if ((*ret) != STREAM_OK) { free(s->url); talloc_free(s); @@ -201,21 +199,14 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo, static stream_t *open_stream_full(const char *filename, int mode, - struct MPOpts *options, int *file_format) + struct MPOpts *options) { int i, j, l, r; const stream_info_t *sinfo; stream_t *s; - char *redirected_url = NULL; assert(filename); - int dummy; - if (!file_format) - file_format = &dummy; - - *file_format = DEMUXER_TYPE_UNKNOWN; - for (i = 0; auto_open_streams[i]; i++) { sinfo = auto_open_streams[i]; if (!sinfo->protocols) { @@ -230,22 +221,10 @@ static stream_t *open_stream_full(const char *filename, int mode, if ((l == 0 && !strstr(filename, "://")) || ((strncasecmp(sinfo->protocols[j], filename, l) == 0) && (strncmp("://", filename + l, 3) == 0))) { - *file_format = DEMUXER_TYPE_UNKNOWN; - s = - open_stream_plugin(sinfo, filename, mode, options, - file_format, - &r, - &redirected_url); + s = open_stream_plugin(sinfo, filename, mode, options, &r); if (s) return s; - if (r == STREAM_REDIRECTED && redirected_url) { - mp_msg(MSGT_OPEN, MSGL_V, "[%s] open %s redirected to %s\n", - sinfo->info, filename, redirected_url); - s = open_stream_full(redirected_url, mode, options, - file_format); - free(redirected_url); - return s; - } else if (r != STREAM_UNSUPPORTED) { + if (r != STREAM_UNSUPPORTED) { mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to open %s.\n", filename); return NULL; @@ -259,15 +238,14 @@ static stream_t *open_stream_full(const char *filename, int mode, return NULL; } -stream_t *open_stream(const char *filename, struct MPOpts *options, - int *file_format) +struct stream *stream_open(const char *filename, struct MPOpts *options) { - return open_stream_full(filename, STREAM_READ, options, file_format); + return open_stream_full(filename, STREAM_READ, options); } stream_t *open_output_stream(const char *filename, struct MPOpts *options) { - return open_stream_full(filename, STREAM_WRITE, options, NULL); + return open_stream_full(filename, STREAM_WRITE, options); } static int stream_reconnect(stream_t *s) @@ -655,7 +633,7 @@ int stream_check_interrupt(int time) stream_t *open_memory_stream(void *data, int len) { assert(len >= 0); - stream_t *s = open_stream("memory://", NULL, NULL); + stream_t *s = stream_open("memory://", NULL); assert(s); stream_control(s, STREAM_CTRL_SET_CONTENTS, &(bstr){data, len}); return s; diff --git a/stream/stream.h b/stream/stream.h index 149618ccd6..0d7e02ed4d 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -70,7 +70,6 @@ #define MP_STREAM_SEEK_FW 4 #define MP_STREAM_SEEK (MP_STREAM_SEEK_BW | MP_STREAM_SEEK_FW) -#define STREAM_REDIRECTED -2 #define STREAM_UNSUPPORTED -1 #define STREAM_ERROR 0 #define STREAM_OK 1 @@ -121,7 +120,7 @@ typedef struct stream_info_st { const char *author; const char *comment; // opts is set from ->opts - int (*open)(struct stream *st, int mode, void *opts, int *file_format); + int (*open)(struct stream *st, int mode, void *opts); const char *protocols[MAX_STREAM_PROTOCOLS]; const void *opts; int opts_url; /* If this is 1 we will parse the url as an option string @@ -158,6 +157,7 @@ typedef struct stream { void *priv; // used for DVD, TV, RTSP etc char *url; // strdup() of filename/url char *mime_type; // when HTTP streaming is used + char *demuxer; // request demuxer to be used char *lavf_type; // name of expected demuxer type for lavf struct MPOpts *opts; @@ -278,8 +278,7 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx, int stream_control(stream_t *s, int cmd, void *arg); void stream_update_size(stream_t *s); void free_stream(stream_t *s); -stream_t *open_stream(const char *filename, struct MPOpts *options, - int *file_format); +struct stream *stream_open(const char *filename, struct MPOpts *options); stream_t *open_output_stream(const char *filename, struct MPOpts *options); stream_t *open_memory_stream(void *data, int len); struct demux_stream; diff --git a/stream/stream_avdevice.c b/stream/stream_avdevice.c index e26d5a9060..bd342e1b10 100644 --- a/stream/stream_avdevice.c +++ b/stream/stream_avdevice.c @@ -26,15 +26,15 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) return -1; } -static int open_f(stream_t *stream, int mode, void *opts, int *file_format) +static int open_f(stream_t *stream, int mode, void *opts) { if (mode != STREAM_READ) return STREAM_ERROR; stream->fill_buffer = fill_buffer; stream->type = STREAMTYPE_AVDEVICE; + stream->demuxer = "lavf"; - *file_format = DEMUXER_TYPE_LAVF; return STREAM_OK; } diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 64d1856873..131813dbb2 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -291,8 +291,7 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg) return STREAM_UNSUPPORTED; } -static int bluray_stream_open(stream_t *s, int mode, - void *opts, int *file_format) +static int bluray_stream_open(stream_t *s, int mode, void *opts) { struct stream_priv_s *p = opts; struct bluray_priv_s *b; diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 4e45e51a07..f5b36a9419 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -333,7 +333,7 @@ static int control(stream_t *stream, int cmd, void *arg) return STREAM_UNSUPPORTED; } -static int open_cdda(stream_t *st, int m, void *opts, int *file_format) +static int open_cdda(stream_t *st, int m, void *opts) { struct cdda_params *p = (struct cdda_params *)opts; int mode = p->paranoia_mode; @@ -479,7 +479,7 @@ static int open_cdda(stream_t *st, int m, void *opts, int *file_format) st->control = control; st->close = close_cdda; - *file_format = DEMUXER_TYPE_RAWAUDIO; + st->demuxer = "rawaudio"; m_struct_free(&stream_opts, opts); diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index 77c0523eb2..8fabfb4fc1 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -659,7 +659,7 @@ static int dvb_streaming_start(stream_t *stream, struct stream_priv_s *opts, int -static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format) +static int dvb_open(stream_t *stream, int mode, void *opts) { // I don't force the file format bacause, although it's almost always TS, // there are some providers that stream an IP multicast with M$ Mpeg4 inside @@ -739,7 +739,7 @@ static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format) stream->close = dvbin_close; m_struct_free(&stream_opts, opts); - *file_format = DEMUXER_TYPE_LAVF; // TS + stream->demuxer = "lavf:mpegts"; return STREAM_OK; } diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index bf9cb9d4c7..b8161d16fa 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -745,7 +745,8 @@ static int control(stream_t *stream,int cmd,void* arg) } -static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { +static int open_s(stream_t *stream,int mode, void* opts) +{ struct stream_priv_s* p = (struct stream_priv_s*)opts; int k; @@ -1059,7 +1060,7 @@ fail: return STREAM_UNSUPPORTED; } -static int ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format) +static int ifo_stream_open (stream_t *stream, int mode, void *opts) { char* filename; struct stream_priv_s *spriv; @@ -1085,7 +1086,7 @@ static int ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_fo free(stream->url); stream->url=strdup("dvd://"); - return open_s(stream, mode, spriv, file_format); + return open_s(stream, mode, spriv); } const stream_info_t stream_info_dvd = { diff --git a/stream/stream_file.c b/stream/stream_file.c index 924eb31dad..79ebbb3eef 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -110,7 +110,8 @@ static int control(stream_t *s, int cmd, void *arg) { return STREAM_UNSUPPORTED; } -static int open_f(stream_t *stream,int mode, void* opts, int* file_format) { +static int open_f(stream_t *stream,int mode, void* opts) +{ int f; mode_t m = 0; int64_t len; diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index 48d5e9d173..8a146a986d 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -33,7 +33,7 @@ #include "core/bstr.h" #include "core/mp_talloc.h" -static int open_f(stream_t *stream, int mode, void *opts, int *file_format); +static int open_f(stream_t *stream, int mode, void *opts); static char **read_icy(stream_t *stream); static int fill_buffer(stream_t *s, char *buffer, int max_len) @@ -115,7 +115,7 @@ static int control(stream_t *s, int cmd, void *arg) // avio doesn't seem to support this - emulate it by reopening close_f(s); s->priv = NULL; - return open_f(s, STREAM_READ, NULL, &(int) {0}); + return open_f(s, STREAM_READ, NULL); } } return STREAM_UNSUPPORTED; @@ -132,7 +132,7 @@ static bool mp_avio_has_opts(AVIOContext *avio) static const char * const prefix[] = { "lavf://", "ffmpeg://" }; -static int open_f(stream_t *stream, int mode, void *opts, int *file_format) +static int open_f(stream_t *stream, int mode, void *opts) { int flags = 0; AVIOContext *avio = NULL; @@ -163,7 +163,7 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format) * stream layer. demux_lavf will do all the real work. */ stream->seek = NULL; - *file_format = DEMUXER_TYPE_LAVF; + stream->demuxer = "lavf"; stream->lavf_type = "rtsp"; return STREAM_OK; } @@ -216,7 +216,7 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format) char *rtmp[] = {"rtmp:", "rtmpt:", "rtmpe:", "rtmpte:", "rtmps:"}; for (int i = 0; i < FF_ARRAY_ELEMS(rtmp); i++) if (!strncmp(filename, rtmp[i], strlen(rtmp[i]))) { - *file_format = DEMUXER_TYPE_LAVF; + stream->demuxer = "lavf"; stream->lavf_type = "flv"; } stream->priv = avio; diff --git a/stream/stream_memory.c b/stream/stream_memory.c index 0994e0816f..3616972cc5 100644 --- a/stream/stream_memory.c +++ b/stream/stream_memory.c @@ -54,7 +54,7 @@ static int control(stream_t *s, int cmd, void *arg) return STREAM_UNSUPPORTED; } -static int open_f(stream_t *stream, int mode, void* opts, int* file_format) +static int open_f(stream_t *stream, int mode, void* opts) { stream->type = STREAMTYPE_MEMORY; diff --git a/stream/stream_mf.c b/stream/stream_mf.c index 9b8b47188a..eef5d6fc4d 100644 --- a/stream/stream_mf.c +++ b/stream/stream_mf.c @@ -29,10 +29,10 @@ #include "demux/demux.h" static int -mf_stream_open (stream_t *stream, int mode, void *opts, int *file_format) +mf_stream_open (stream_t *stream, int mode, void *opts) { stream->type = STREAMTYPE_MF; - *file_format = DEMUXER_TYPE_MF; + stream->demuxer = "lavf"; return STREAM_OK; } diff --git a/stream/stream_null.c b/stream/stream_null.c index 5465702be8..c1965e6bd0 100644 --- a/stream/stream_null.c +++ b/stream/stream_null.c @@ -23,7 +23,8 @@ #include "stream.h" -static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { +static int open_s(stream_t *stream,int mode, void* opts) +{ stream->type = STREAMTYPE_DUMMY; return 1; diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c index aeea46cf62..165a67ad37 100644 --- a/stream/stream_pvr.c +++ b/stream/stream_pvr.c @@ -1555,7 +1555,7 @@ pvr_stream_read (stream_t *stream, char *buffer, int size) } static int -pvr_stream_open (stream_t *stream, int mode, void *opts, int *file_format) +pvr_stream_open (stream_t *stream, int mode, void *opts) { struct v4l2_capability vcap; struct v4l2_ext_controls ctrls; diff --git a/stream/stream_radio.c b/stream/stream_radio.c index fae9be43d1..7e54cd4274 100644 --- a/stream/stream_radio.c +++ b/stream/stream_radio.c @@ -824,7 +824,8 @@ static const radio_driver_t* radio_drivers[]={ * Stream initialization * \return STREAM_OK if success, STREAM_ERROR otherwise */ -static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { +static int open_s(stream_t *stream,int mode, void* opts) +{ radio_priv_t* priv; float frequency=0; int i; @@ -875,7 +876,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { stream->type = STREAMTYPE_RADIO; /* using rawaudio demuxer */ - *file_format = DEMUXER_TYPE_RAWAUDIO; + stream->demuxer = "lavf"; stream->flags = STREAM_READ; priv->radio_fd=-1; diff --git a/stream/stream_smb.c b/stream/stream_smb.c index 33b13f7a11..b1ebaecd00 100644 --- a/stream/stream_smb.c +++ b/stream/stream_smb.c @@ -115,7 +115,8 @@ static void close_f(stream_t *s){ smbc_close(s->fd); } -static int open_f (stream_t *stream, int mode, void *opts, int* file_format) { +static int open_f (stream_t *stream, int mode, void *opts) +{ char *filename; mode_t m = 0; int64_t len; diff --git a/stream/stream_tv.c b/stream/stream_tv.c index 595657dc43..eacdabd705 100644 --- a/stream/stream_tv.c +++ b/stream/stream_tv.c @@ -97,13 +97,13 @@ tv_stream_close (stream_t *stream) stream->priv=NULL; } static int -tv_stream_open (stream_t *stream, int mode, void *opts, int *file_format) +tv_stream_open (stream_t *stream, int mode, void *opts) { stream->type = STREAMTYPE_TV; stream->priv = opts; stream->close=tv_stream_close; - *file_format = DEMUXER_TYPE_TV; + stream->demuxer = "tv"; return STREAM_OK; } diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c index a459d6c880..fbbae12266 100644 --- a/stream/stream_vcd.c +++ b/stream/stream_vcd.c @@ -133,7 +133,8 @@ static void close_s(stream_t *stream) { free(stream->priv); } -static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { +static int open_s(stream_t *stream,int mode, void* opts) +{ struct stream_priv_s* p = opts; int ret,ret2,f,sect,tmp; mp_vcd_priv_t* vcd; @@ -232,7 +233,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { stream->seek = seek; stream->control = control; stream->close = close_s; - *file_format = DEMUXER_TYPE_LAVF; // mpegps + stream->demuxer = "lavf"; // mpegps ( or "vcd"?) m_struct_free(&stream_opts,opts); return STREAM_OK; -- cgit v1.2.3