summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-11 21:10:42 +0200
committerwm4 <wm4@nowhere>2013-07-12 21:56:40 +0200
commit52c3eb69765a0d1070bf240353095c8ff546765b (patch)
treedb654a9798f4941dbc3b57c8569fcdeb0b21d24a /core
parentd17d2fdc7c536821b3fea8c4a37c0ad09fc487db (diff)
downloadmpv-52c3eb69765a0d1070bf240353095c8ff546765b.tar.bz2
mpv-52c3eb69765a0d1070bf240353095c8ff546765b.tar.xz
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.
Diffstat (limited to 'core')
-rw-r--r--core/asxparser.c3
-rw-r--r--core/encode_lavc.c2
-rw-r--r--core/input/input.c2
-rw-r--r--core/mplayer.c34
-rw-r--r--core/playlist_parser.c5
-rw-r--r--core/timeline/tl_cue.c7
-rw-r--r--core/timeline/tl_edl.c7
-rw-r--r--core/timeline/tl_matroska.c17
8 files changed, 17 insertions, 60 deletions
diff --git a/core/asxparser.c b/core/asxparser.c
index 17ce6b3e8c..0fc10eb059 100644
--- a/core/asxparser.c
+++ b/core/asxparser.c
@@ -451,7 +451,6 @@ asx_parse_ref(ASX_Parser_t* parser, char** attribs) {
static void asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) {
char *href;
stream_t* stream;
- int f=DEMUXER_TYPE_UNKNOWN;
if(parser->deep > 0)
return;
@@ -461,7 +460,7 @@ static void asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs
asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" );
return;
}
- stream=open_stream(href,0,&f);
+ stream=stream_open(href, NULL);
if(!stream) {
mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href);
free(href);
diff --git a/core/encode_lavc.c b/core/encode_lavc.c
index 9fada7de58..75e57a2443 100644
--- a/core/encode_lavc.c
+++ b/core/encode_lavc.c
@@ -397,7 +397,7 @@ static void encode_2pass_prepare(struct encode_lavc_context *ctx,
buf[sizeof(buf) - 1] = 0;
if (value_has_flag(de ? de->value : "", "pass2")) {
- if (!(*bytebuf = open_stream(buf, NULL, NULL))) {
+ if (!(*bytebuf = stream_open(buf, NULL))) {
mp_msg(MSGT_ENCODE, MSGL_WARN, "%s: could not open '%s', "
"disabling 2-pass encoding at pass 2\n", prefix, buf);
stream->codec->flags &= ~CODEC_FLAG_PASS2;
diff --git a/core/input/input.c b/core/input/input.c
index e87d9bb560..e736c6486d 100644
--- a/core/input/input.c
+++ b/core/input/input.c
@@ -1969,7 +1969,7 @@ static int parse_config_file(struct input_ctx *ictx, char *file, bool warn)
"Input config file %s not found.\n", file);
return 0;
}
- stream_t *s = open_stream(file, NULL, NULL);
+ stream_t *s = stream_open(file, NULL);
if (!s) {
mp_msg(MSGT_INPUT, MSGL_ERR, "Can't open input config file %s.\n", file);
return 0;
diff --git a/core/mplayer.c b/core/mplayer.c
index 026af6a989..73108d8d34 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -3882,11 +3882,10 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
struct MPOpts *opts = &mpctx->opts;
if (!filename)
return NULL;
- int format = 0;
char *disp_filename = filename;
if (strncmp(disp_filename, "memory://", 9) == 0)
disp_filename = "memory://"; // avoid noise
- struct stream *stream = open_stream(filename, &mpctx->opts, &format);
+ struct stream *stream = stream_open(filename, &mpctx->opts);
if (!stream)
goto err_out;
stream_enable_cache_percent(&stream, stream_cache,
@@ -3896,8 +3895,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
.ass_library = mpctx->ass_library, // demux_libass requires it
};
struct demuxer *demuxer =
- demux_open_withparams(&mpctx->opts, stream, format, demuxer_name,
- filename, &params);
+ demux_open(stream, demuxer_name, &params, &mpctx->opts);
if (!demuxer) {
free_stream(stream);
goto err_out;
@@ -4156,36 +4154,13 @@ static void play_current_file(struct MPContext *mpctx)
}
stream_filename = mpctx->resolve_result->url;
}
- int file_format = DEMUXER_TYPE_UNKNOWN;
- mpctx->stream = open_stream(stream_filename, opts, &file_format);
+ mpctx->stream = stream_open(stream_filename, opts);
if (!mpctx->stream) { // error...
demux_was_interrupted(mpctx);
goto terminate_playback;
}
mpctx->initialized_flags |= INITIALIZED_STREAM;
- if (file_format == DEMUXER_TYPE_PLAYLIST) {
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "\nThis looks like a playlist, but "
- "playlist support will not be used automatically.\n"
- "mpv's playlist code is unsafe and should only be used with "
- "trusted sources.\nPlayback will probably fail.\n\n");
-#if 0
- // Handle playlist
- mp_msg(MSGT_CPLAYER, MSGL_WARN, "Parsing playlist %s...\n",
- mpctx->filename);
- bool empty = true;
- struct playlist *pl = playlist_parse(mpctx->stream);
- if (pl) {
- empty = pl->first == NULL;
- playlist_transfer_entries(mpctx->playlist, pl);
- talloc_free(pl);
- }
- if (empty)
- mp_msg(MSGT_CPLAYER, MSGL_ERR, "Playlist was invalid or empty!\n");
- mpctx->stop_play = PT_NEXT_ENTRY;
- goto terminate_playback;
-#endif
- }
mpctx->stream->start_pos += opts->seek_to_byte;
if (opts->stream_dump && opts->stream_dump[0]) {
@@ -4212,8 +4187,7 @@ goto_reopen_demuxer: ;
mpctx->audio_delay = opts->audio_delay;
- mpctx->demuxer = demux_open(opts, mpctx->stream, file_format,
- mpctx->filename);
+ mpctx->demuxer = demux_open(mpctx->stream, NULL, NULL, opts);
mpctx->master_demuxer = mpctx->demuxer;
if (!mpctx->demuxer) {
diff --git a/core/playlist_parser.c b/core/playlist_parser.c
index 67d58024c1..59d5123be6 100644
--- a/core/playlist_parser.c
+++ b/core/playlist_parser.c
@@ -699,10 +699,7 @@ err_out:
struct playlist *playlist_parse_file(const char *file)
{
- stream_t *stream;
- int f=DEMUXER_TYPE_PLAYLIST;
-
- stream = open_stream(file, 0, &f);
+ stream_t *stream = stream_open(file, NULL);
if(!stream) {
mp_msg(MSGT_PLAYTREE,MSGL_ERR,
"Error while opening playlist file %s: %s\n",
diff --git a/core/timeline/tl_cue.c b/core/timeline/tl_cue.c
index a965cfd877..1953f46116 100644
--- a/core/timeline/tl_cue.c
+++ b/core/timeline/tl_cue.c
@@ -188,11 +188,10 @@ static bool try_open(struct MPContext *mpctx, char *filename)
|| bstrcasecmp(bstr0(mpctx->demuxer->filename), bfilename) == 0)
return false;
- int format = 0;
- struct stream *s = open_stream(filename, &mpctx->opts, &format);
+ struct stream *s = stream_open(filename, &mpctx->opts);
if (!s)
return false;
- struct demuxer *d = demux_open(&mpctx->opts, s, format, filename);
+ struct demuxer *d = demux_open(s, NULL, NULL, &mpctx->opts);
// Since .bin files are raw PCM data with no headers, we have to explicitly
// open them. Also, try to avoid to open files that are most likely not .bin
// files, as that would only play noise. Checking the file extension is
@@ -201,7 +200,7 @@ static bool try_open(struct MPContext *mpctx, char *filename)
// CD sector size (2352 bytes)
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n");
- d = demux_open(&mpctx->opts, s, DEMUXER_TYPE_RAWAUDIO, filename);
+ d = demux_open(s, "rawaudio", NULL, &mpctx->opts);
}
if (d) {
add_source(mpctx, d);
diff --git a/core/timeline/tl_edl.c b/core/timeline/tl_edl.c
index 0303956513..6096d03b6a 100644
--- a/core/timeline/tl_edl.c
+++ b/core/timeline/tl_edl.c
@@ -354,13 +354,10 @@ void build_edl_timeline(struct MPContext *mpctx)
mpctx->num_sources = 1;
for (int i = 0; i < num_sources; i++) {
- int format = 0;
- struct stream *s = open_stream(edl_ids[i].filename, &mpctx->opts,
- &format);
+ struct stream *s = stream_open(edl_ids[i].filename, &mpctx->opts);
if (!s)
goto openfail;
- struct demuxer *d = demux_open(&mpctx->opts, s, format,
- edl_ids[i].filename);
+ struct demuxer *d = demux_open(s, NULL, NULL, &mpctx->opts);
if (!d) {
free_stream(s);
openfail:
diff --git a/core/timeline/tl_matroska.c b/core/timeline/tl_matroska.c
index 6752b5ff4c..614ce0d6b7 100644
--- a/core/timeline/tl_matroska.c
+++ b/core/timeline/tl_matroska.c
@@ -113,13 +113,6 @@ static char **find_files(const char *original_file, const char *suffix)
return results;
}
-static struct demuxer *open_demuxer(struct stream *stream,
- struct MPContext *mpctx, char *filename, struct demuxer_params *params)
-{
- return demux_open_withparams(&mpctx->opts, stream,
- DEMUXER_TYPE_MATROSKA, NULL, filename, params);
-}
-
static int enable_cache(struct MPContext *mpctx, struct stream **stream,
struct demuxer **demuxer, struct demuxer_params *params)
{
@@ -133,8 +126,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream,
free_demuxer(*demuxer);
free_stream(*stream);
- int format = 0;
- *stream = open_stream(filename, &mpctx->opts, &format);
+ *stream = stream_open(filename, &mpctx->opts);
if (!*stream) {
talloc_free(filename);
return -1;
@@ -145,7 +137,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream,
opts->stream_cache_min_percent,
opts->stream_cache_seek_min_percent);
- *demuxer = open_demuxer(*stream, mpctx, filename, params);
+ *demuxer = demux_open(*stream, "mkv", params, &mpctx->opts);
if (!*demuxer) {
talloc_free(filename);
free_stream(*stream);
@@ -167,11 +159,10 @@ static bool check_file_seg(struct MPContext *mpctx, struct demuxer **sources,
.matroska_wanted_segment = segment,
.matroska_was_valid = &was_valid,
};
- int format = 0;
- struct stream *s = open_stream(filename, &mpctx->opts, &format);
+ struct stream *s = stream_open(filename, &mpctx->opts);
if (!s)
return false;
- struct demuxer *d = open_demuxer(s, mpctx, filename, &params);
+ struct demuxer *d = demux_open(s, "mkv", &params, &mpctx->opts);
if (!d) {
free_stream(s);