summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/input.rst4
-rw-r--r--DOCS/man/options.rst19
-rw-r--r--demux/demux.c39
-rw-r--r--demux/demux.h3
-rw-r--r--options/options.c4
-rw-r--r--options/options.h1
-rw-r--r--player/command.c24
-rw-r--r--player/loadfile.c1
-rw-r--r--player/misc.c22
-rw-r--r--stream/stream.c34
-rw-r--r--stream/stream.h5
12 files changed, 38 insertions, 119 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index fa1ac13622..13b51ad4ba 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -31,6 +31,7 @@ Interface changes
- "drop-frame-count" to "decoder-frame-drop-count"
- "vo-drop-frame-count" to "frame-drop-count"
The old names still work, but are deprecated.
+ - remove the --stream-capture option and property. No replacement.
--- mpv 0.23.0 ---
- remove deprecated vf_vdpaurb (use "--hwdec=vdpau-copy" instead)
- the following properties now have new semantics:
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index dda049921d..1399ef74e1 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1552,10 +1552,6 @@ Property list
This property is experimental and might be removed in the future.
-``stream-capture`` (RW)
- A filename, see ``--stream-capture``. Setting this will start capture using
- the given filename. Setting it to an empty string will stop it.
-
``tv-brightness``, ``tv-contrast``, ``tv-saturation``, ``tv-hue`` (RW)
TV stuff.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index e2a5c286c0..2625c118a0 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4745,21 +4745,10 @@ Miscellaneous
Input file type for ``mf://`` (available: jpeg, png, tga, sgi). By default,
this is guessed from the file extension.
-``--stream-capture=<filename>``
- Allows capturing the primary stream (not additional audio tracks or other
- kind of streams) into the given file. Capturing can also be started and
- stopped by changing the filename with the ``stream-capture`` property.
- Generally this will not produce usable results for anything else than MPEG
- or raw streams, unless capturing includes the file headers and is not
- interrupted. Note that, due to cache latencies, captured data may begin and
- end somewhat delayed compared to what you see displayed.
-
- The destination file is always appended. (Before mpv 0.8.0, the file was
- overwritten.)
-
-``--stream-dump=<filename>``
- Same as ``--stream-capture``, but do not start playback. Instead, the entire
- file is dumped.
+``--stream-dump=<destination-filename>``
+ Instead of playing a file, read its byte stream and write it to the given
+ destination file. The destination is overwritten. Can be useful to test
+ network-related behavior.
``--stream-lavf-o=opt1=value1,opt2=value2,...``
Set AVOptions on streams opened with libavformat. Unknown or misspelled
diff --git a/demux/demux.c b/demux/demux.c
index 824e20d524..c4173f5965 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1398,12 +1398,6 @@ struct demuxer *demux_open_url(const char *url,
cancel, global);
if (!s)
return NULL;
- if (params->allow_capture) {
- char *f;
- mp_read_option_raw(global, "stream-capture", &m_option_type_string, &f);
- stream_set_capture_file(s, f);
- talloc_free(f);
- }
if (!params->disable_cache)
stream_enable_cache_defaults(&s);
struct demuxer *d = demux_open(s, params, global);
@@ -1740,6 +1734,7 @@ static void thread_demux_control(void *p)
int demux_control(demuxer_t *demuxer, int cmd, void *arg)
{
struct demux_internal *in = demuxer->in;
+ assert(demuxer == in->d_user);
if (in->threading) {
pthread_mutex_lock(&in->lock);
@@ -1751,37 +1746,29 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg)
int r = 0;
struct demux_control_args args = {demuxer, cmd, arg, &r};
- demux_run_on_thread(demuxer, thread_demux_control, &args);
-
- return r;
-}
-
-int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg)
-{
- struct demux_ctrl_stream_ctrl c = {ctrl, arg, STREAM_UNSUPPORTED};
- demux_control(demuxer, DEMUXER_CTRL_STREAM_CTRL, &c);
- return c.res;
-}
-
-void demux_run_on_thread(struct demuxer *demuxer, void (*fn)(void *), void *ctx)
-{
- struct demux_internal *in = demuxer->in;
- assert(demuxer == in->d_user);
-
if (in->threading) {
MP_VERBOSE(in, "blocking on demuxer thread\n");
pthread_mutex_lock(&in->lock);
while (in->run_fn)
pthread_cond_wait(&in->wakeup, &in->lock);
- in->run_fn = fn;
- in->run_fn_arg = ctx;
+ in->run_fn = thread_demux_control;
+ in->run_fn_arg = &args;
pthread_cond_signal(&in->wakeup);
while (in->run_fn)
pthread_cond_wait(&in->wakeup, &in->lock);
pthread_mutex_unlock(&in->lock);
} else {
- fn(ctx);
+ thread_demux_control(&args);
}
+
+ return r;
+}
+
+int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg)
+{
+ struct demux_ctrl_stream_ctrl c = {ctrl, arg, STREAM_UNSUPPORTED};
+ demux_control(demuxer, DEMUXER_CTRL_STREAM_CTRL, &c);
+ return c.res;
}
bool demux_cancel_test(struct demuxer *demuxer)
diff --git a/demux/demux.h b/demux/demux.h
index f9d98e5cef..44bd2b9766 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -165,7 +165,6 @@ struct demuxer_params {
bool initial_readahead;
// -- demux_open_url() only
int stream_flags;
- bool allow_capture;
bool disable_cache;
// result
bool demuxer_failed;
@@ -288,8 +287,6 @@ double demuxer_get_time_length(struct demuxer *demuxer);
int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg);
-void demux_run_on_thread(struct demuxer *demuxer, void (*fn)(void *), void *ctx);
-
void demux_changed(demuxer_t *demuxer, int events);
void demux_update(demuxer_t *demuxer);
diff --git a/options/options.c b/options/options.c
index cb2848e05b..71f5d79fa6 100644
--- a/options/options.c
+++ b/options/options.c
@@ -590,7 +590,6 @@ const m_option_t mp_opts[] = {
OPT_FLAG("untimed", untimed, 0),
- OPT_STRING("stream-capture", stream_capture, M_OPT_FILE),
OPT_STRING("stream-dump", stream_dump, M_OPT_FILE),
OPT_FLAG("stop-playback-on-init-failure", stop_playback_on_init_failure, 0),
@@ -713,7 +712,8 @@ const m_option_t mp_opts[] = {
OPT_REPLACED("ass", "sub-ass"),
OPT_REPLACED("audiofile", "audio-file"),
OPT_REMOVED("benchmark", "use --untimed (no stats)"),
- OPT_REMOVED("capture", "use --stream-capture=<filename>"),
+ OPT_REMOVED("capture", NULL),
+ OPT_REMOVED("stream-capture", NULL),
OPT_REMOVED("channels", "use --audio-channels (changed semantics)"),
OPT_REPLACED("cursor-autohide-delay", "cursor-autohide"),
OPT_REPLACED("delay", "audio-delay"),
diff --git a/options/options.h b/options/options.h
index d668832fea..f5d1a8a0a0 100644
--- a/options/options.h
+++ b/options/options.h
@@ -136,7 +136,6 @@ typedef struct MPOpts {
int video_osd;
int untimed;
- char *stream_capture;
char *stream_dump;
int stop_playback_on_init_failure;
int loop_times;
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)
diff --git a/stream/stream.c b/stream/stream.c
index 4c7aa04844..d2c2917d56 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -353,37 +353,6 @@ static bool stream_reconnect(stream_t *s)
return false;
}
-static void stream_capture_write(stream_t *s, void *buf, size_t len)
-{
- if (s->capture_file && len > 0) {
- if (fwrite(buf, len, 1, s->capture_file) < 1) {
- MP_ERR(s, "Error writing capture file: %s\n", mp_strerror(errno));
- stream_set_capture_file(s, NULL);
- }
- }
-}
-
-void stream_set_capture_file(stream_t *s, const char *filename)
-{
- if (!bstr_equals(bstr0(s->capture_filename), bstr0(filename))) {
- if (s->capture_file)
- fclose(s->capture_file);
- talloc_free(s->capture_filename);
- s->capture_file = NULL;
- s->capture_filename = NULL;
- if (filename) {
- s->capture_file = fopen(filename, "ab");
- if (s->capture_file) {
- s->capture_filename = talloc_strdup(NULL, filename);
- if (s->buf_pos < s->buf_len)
- stream_capture_write(s, s->buffer, s->buf_len);
- } else {
- MP_ERR(s, "Error opening capture file: %s\n", mp_strerror(errno));
- }
- }
- }
-}
-
// Read function bypassing the local stream buffer. This will not write into
// s->buffer, but into buf[0..len] instead.
// Returns 0 on error or EOF, and length of bytes read on success.
@@ -412,7 +381,6 @@ static int stream_read_unbuffered(stream_t *s, void *buf, int len)
// When reading succeeded we are obviously not at eof.
s->eof = 0;
s->pos += len;
- stream_capture_write(s, buf, len);
return len;
}
@@ -647,8 +615,6 @@ void free_stream(stream_t *s)
if (!s)
return;
- stream_set_capture_file(s, NULL);
-
if (s->close)
s->close(s);
free_stream(s->uncached_stream);
diff --git a/stream/stream.h b/stream/stream.h
index 7d44e30eae..f309ab1b86 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -203,9 +203,6 @@ typedef struct stream {
struct mp_cancel *cancel; // cancellation notification
- FILE *capture_file;
- char *capture_filename;
-
struct stream *uncached_stream; // underlying stream for cache wrapper
// Includes additional padding in case sizes get rounded up by sector size.
@@ -214,8 +211,6 @@ typedef struct stream {
int stream_fill_buffer(stream_t *s);
-void stream_set_capture_file(stream_t *s, const char *filename);
-
struct mp_cache_opts;
bool stream_wants_cache(stream_t *stream, struct mp_cache_opts *opts);
int stream_enable_cache_defaults(stream_t **stream);