Skip to content

Commit

Permalink
options: remove deprecated --record-file option
Browse files Browse the repository at this point in the history
No wonder wm4 wanted to get rid of this. This option requires touching a
bunch of crap in the core player code. --stream-record works perfectly
fine and is a lot nicer so there's no need for this to exist anymore.
  • Loading branch information
Dudemanguy committed Sep 20, 2023
1 parent fd30f32 commit 73d1b58
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 127 deletions.
10 changes: 0 additions & 10 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7204,16 +7204,6 @@ Miscellaneous
This does not affect playlist expansion, redirection, or other loading of
referenced files like with ordered chapters.

``--record-file=<file>``
Deprecated, use ``--stream-record``, or the ``dump-cache`` command.

Record the current stream to the given target file. The target file will
always be overwritten without asking.

This was deprecated because it isn't very nice to use. For one, seeking
while this is enabled will be directly reflected in the output, which was
not useful and annoying.

``--stream-record=<file>``
Write received/read data from the demuxer to the given output file. The
output file will always be overwritten without asking. The output format
Expand Down
3 changes: 0 additions & 3 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,6 @@ static const m_option_t mp_opts[] = {
.flags = M_OPT_FILE},
{"screenshot-sw", OPT_BOOL(screenshot_sw)},

{"record-file", OPT_STRING(record_file), .flags = M_OPT_FILE,
.deprecation_message = "use --stream-record or the dump-cache command"},

{"", OPT_SUBSTRUCT(resample_opts, resample_conf)},

{"", OPT_SUBSTRUCT(input_opts, input_config)},
Expand Down
1 change: 0 additions & 1 deletion options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ typedef struct MPOpts {

bool untimed;
char *stream_dump;
char *record_file;
bool stop_playback_on_init_failure;
int loop_times;
int loop_file;
Expand Down
3 changes: 0 additions & 3 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -7042,9 +7042,6 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
mp_wakeup_core(mpctx);
}

if (opt_ptr == &opts->record_file)
open_recorder(mpctx, false);

if (opt_ptr == &opts->vf_settings)
set_filters(mpctx, STREAM_VIDEO, opts->vf_settings);

Expand Down
8 changes: 0 additions & 8 deletions player/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ struct track {
struct vo_chain *vo_c;
struct ao_chain *ao_c;
struct mp_pin *sink;

// For stream recording (remuxing mode).
struct mp_recorder_sink *remux_sink;
};

// Summarizes video filtering and output.
Expand Down Expand Up @@ -425,8 +422,6 @@ typedef struct MPContext {
// playback rate. Used to avoid showing it multiple times.
bool drop_message_shown;

struct mp_recorder *recorder;

struct screenshot_ctx *screenshot_ctx;
struct command_ctx *command_ctx;
struct encode_lavc_context *encode_lavc_ctx;
Expand Down Expand Up @@ -539,9 +534,6 @@ void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel);
struct track *select_default_track(struct MPContext *mpctx, int order,
enum stream_type type);
void prefetch_next(struct MPContext *mpctx);
void close_recorder(struct MPContext *mpctx);
void close_recorder_and_error(struct MPContext *mpctx);
void open_recorder(struct MPContext *mpctx, bool on_init);
void update_lavfi_complex(struct MPContext *mpctx);

// main.c
Expand Down
99 changes: 0 additions & 99 deletions player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "options/m_property.h"
#include "common/common.h"
#include "common/encode.h"
#include "common/recorder.h"
#include "common/stats.h"
#include "input/input.h"
#include "misc/language.h"
Expand Down Expand Up @@ -217,7 +216,6 @@ static void uninit_demuxer(struct MPContext *mpctx)
assert(!track->dec && !track->d_sub);
assert(!track->vo_c && !track->ao_c);
assert(!track->sink);
assert(!track->remux_sink);

// Demuxers can be added in any order (if they appear mid-stream), and
// we can't know which tracks uses which, so here's some O(n^2) trash.
Expand Down Expand Up @@ -797,8 +795,6 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type
uninit_sub(mpctx, current);

if (current) {
if (current->remux_sink)
close_recorder_and_error(mpctx);
current->selected = false;
reselect_demux_stream(mpctx, current, false);
}
Expand Down Expand Up @@ -1832,8 +1828,6 @@ static void play_current_file(struct MPContext *mpctx)

update_internal_pause_state(mpctx);

open_recorder(mpctx, true);

playback_start = mp_time_sec();
mpctx->error_playing = 0;
mpctx->in_playloop = true;
Expand All @@ -1860,8 +1854,6 @@ static void play_current_file(struct MPContext *mpctx)

process_hooks(mpctx, "on_unload");

close_recorder(mpctx);

// time to uninit all, except global stuff:
reinit_complex_filters(mpctx, true);
uninit_audio_chain(mpctx);
Expand Down Expand Up @@ -2073,94 +2065,3 @@ void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e)
mpctx->stop_play = e ? PT_CURRENT_ENTRY : PT_STOP;
mp_wakeup_core(mpctx);
}

static void set_track_recorder_sink(struct track *track,
struct mp_recorder_sink *sink)
{
if (track->d_sub)
sub_set_recorder_sink(track->d_sub, sink);
if (track->dec)
track->dec->recorder_sink = sink;
track->remux_sink = sink;
}

void close_recorder(struct MPContext *mpctx)
{
if (!mpctx->recorder)
return;

for (int n = 0; n < mpctx->num_tracks; n++)
set_track_recorder_sink(mpctx->tracks[n], NULL);

mp_recorder_destroy(mpctx->recorder);
mpctx->recorder = NULL;
}

// Like close_recorder(), but also unset the option. Intended for use on errors.
void close_recorder_and_error(struct MPContext *mpctx)
{
close_recorder(mpctx);
talloc_free(mpctx->opts->record_file);
mpctx->opts->record_file = NULL;
m_config_notify_change_opt_ptr(mpctx->mconfig, &mpctx->opts->record_file);
MP_ERR(mpctx, "Disabling stream recording.\n");
}

void open_recorder(struct MPContext *mpctx, bool on_init)
{
if (!mpctx->playback_initialized)
return;

close_recorder(mpctx);

char *target = mpctx->opts->record_file;
if (!target || !target[0])
return;

struct sh_stream **streams = NULL;
int num_streams = 0;

for (int n = 0; n < mpctx->num_tracks; n++) {
struct track *track = mpctx->tracks[n];
if (track->stream && track->selected && (track->d_sub || track->dec))
MP_TARRAY_APPEND(NULL, streams, num_streams, track->stream);
}

struct demux_attachment **attachments = talloc_array(NULL, struct demux_attachment*, mpctx->demuxer->num_attachments);
for (int n = 0; n < mpctx->demuxer->num_attachments; n++) {
attachments[n] = &mpctx->demuxer->attachments[n];
}

mpctx->recorder = mp_recorder_create(mpctx->global, mpctx->opts->record_file,
streams, num_streams,
attachments, mpctx->demuxer->num_attachments);

if (!mpctx->recorder) {
talloc_free(streams);
talloc_free(attachments);
close_recorder_and_error(mpctx);
return;
}

if (!on_init)
mp_recorder_mark_discontinuity(mpctx->recorder);

int n_stream = 0;
for (int n = 0; n < mpctx->num_tracks; n++) {
struct track *track = mpctx->tracks[n];
if (n_stream >= num_streams)
break;
// (We expect track->stream not to be reused on other tracks.)
if (track->stream == streams[n_stream]) {
struct mp_recorder_sink * sink =
mp_recorder_get_sink(mpctx->recorder, streams[n_stream]);
assert(sink);
set_track_recorder_sink(track, sink);
n_stream++;
}
}

talloc_free(streams);
talloc_free(attachments);
}

3 changes: 0 additions & 3 deletions player/playloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "common/encode.h"
#include "common/msg.h"
#include "common/playlist.h"
#include "common/recorder.h"
#include "common/stats.h"
#include "demux/demux.h"
#include "filters/f_decoder_wrapper.h"
Expand Down Expand Up @@ -373,8 +372,6 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek)
clear_audio_output_buffers(mpctx);

reset_playback_state(mpctx);
if (mpctx->recorder)
mp_recorder_mark_discontinuity(mpctx->recorder);

demux_block_reading(mpctx->demuxer, false);
for (int t = 0; t < mpctx->num_tracks; t++) {
Expand Down

0 comments on commit 73d1b58

Please sign in to comment.