summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-21 17:19:01 +0100
committerwm4 <wm4@nowhere>2017-01-21 17:19:01 +0100
commit73858bb0ccac91b6a529c8dd4b825f47aa28c4b7 (patch)
tree2baf1e7a267976e51ecbb2a08e02b0c430ea8d59 /player
parent085dfdea3246e4d0e984f9f3ccba2959df89842d (diff)
downloadmpv-73858bb0ccac91b6a529c8dd4b825f47aa28c4b7.tar.bz2
mpv-73858bb0ccac91b6a529c8dd4b825f47aa28c4b7.tar.xz
player: remove --stream-capture option/property
This was excessively useless, and I want my time back that was needed to explain users why they don't want to use it. It captured the byte stream only, and even for types of streams it was designed for (like transport streams), it was rather questionable. As part of the removal, un-inline demux_run_on_thread() (which has only 1 call-site now), and sort of reimplement --stream-dump to write the data directly instead of using the removed capture code. (--stream-dump is also very useless, and I struggled coming up with an explanation for it in the manpage.)
Diffstat (limited to 'player')
-rw-r--r--player/command.c24
-rw-r--r--player/loadfile.c1
-rw-r--r--player/misc.c22
3 files changed, 18 insertions, 29 deletions
diff --git a/player/command.c b/player/command.c
index e837cf9ad3..0c5b3fa21b 100644
--- a/player/command.c
+++ b/player/command.c
@@ -515,29 +515,6 @@ static int mp_property_stream_path(void *ctx, struct m_property *prop,
return m_property_strdup_ro(action, arg, mpctx->demuxer->filename);
}
-struct change_stream_capture_args {
- char *filename;
- struct demuxer *demux;
-};
-
-static void do_change_stream_capture(void *p)
-{
- struct change_stream_capture_args *args = p;
- stream_set_capture_file(args->demux->stream, args->filename);
-}
-
-static int mp_property_stream_capture(void *ctx, struct m_property *prop,
- int action, void *arg)
-{
- MPContext *mpctx = ctx;
- if (mpctx->demuxer && action == M_PROPERTY_SET) {
- struct change_stream_capture_args args = {*(char **)arg, mpctx->demuxer};
- demux_run_on_thread(mpctx->demuxer, do_change_stream_capture, &args);
- // fall through to mp_property_generic_option
- }
- return mp_property_generic_option(mpctx, prop, action, arg);
-}
-
/// Demuxer name (RO)
static int mp_property_demuxer(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -3789,7 +3766,6 @@ static const struct m_property mp_properties_base[] = {
{"path", mp_property_path},
{"media-title", mp_property_media_title},
{"stream-path", mp_property_stream_path},
- {"stream-capture", mp_property_stream_capture},
{"current-demuxer", mp_property_demuxer},
{"file-format", mp_property_file_format},
{"stream-pos", mp_property_stream_pos},
diff --git a/player/loadfile.c b/player/loadfile.c
index 69647d8929..524ff8f1b2 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -796,7 +796,6 @@ static void *open_demux_thread(void *ctx)
struct demuxer_params p = {
.force_format = mpctx->open_format,
- .allow_capture = true,
.stream_flags = mpctx->open_url_flags,
.initial_readahead = true,
};
diff --git a/player/misc.c b/player/misc.c
index 2c160aef73..6762f8a518 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -17,6 +17,7 @@
#include <stddef.h>
#include <stdbool.h>
+#include <errno.h>
#include <assert.h>
#include "config.h"
@@ -212,21 +213,34 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
int64_t size = stream_get_size(stream);
- stream_set_capture_file(stream, opts->stream_dump);
+ FILE *dest = fopen(opts->stream_dump, "wb");
+ if (!dest) {
+ MP_ERR(mpctx, "Error opening dump file: %s\n", mp_strerror(errno));
+ return -1;
+ }
+
+ bool ok = true;
- while (mpctx->stop_play == KEEP_PLAYING && !stream->eof) {
+ while (mpctx->stop_play == KEEP_PLAYING && ok) {
if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) {
uint64_t pos = stream->pos;
MP_MSG(mpctx, MSGL_STATUS, "Dumping %lld/%lld...",
(long long int)pos, (long long int)size);
}
- stream_fill_buffer(stream);
+ bstr data = stream_peek(stream, STREAM_MAX_BUFFER_SIZE);
+ if (data.len == 0) {
+ ok &= stream->eof;
+ break;
+ }
+ ok &= fwrite(data.start, data.len, 1, dest) == 1;
+ stream_skip(stream, data.len);
mp_wakeup_core(mpctx); // don't actually sleep
mp_idle(mpctx); // but process input
}
+ ok &= fclose(dest) == 0;
free_stream(stream);
- return 0;
+ return ok ? 0 : -1;
}
void merge_playlist_files(struct playlist *pl)