summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/recorder.c14
-rw-r--r--common/recorder.h3
-rw-r--r--demux/demux.c5
-rw-r--r--player/loadfile.c2
4 files changed, 16 insertions, 8 deletions
diff --git a/common/recorder.c b/common/recorder.c
index ad9c34e24c..1af736a71d 100644
--- a/common/recorder.c
+++ b/common/recorder.c
@@ -328,11 +328,17 @@ void mp_recorder_mark_discontinuity(struct mp_recorder *priv)
}
// Get a stream for writing. The pointer is valid until mp_recorder is
-// destroyed. The stream is the index referencing the stream passed to
-// mp_recorder_create().
-struct mp_recorder_sink *mp_recorder_get_sink(struct mp_recorder *r, int stream)
+// destroyed. The stream ptr. is the same as one passed to
+// mp_recorder_create() (returns NULL if it wasn't).
+struct mp_recorder_sink *mp_recorder_get_sink(struct mp_recorder *r,
+ struct sh_stream *stream)
{
- return stream >= 0 && stream < r->num_streams ? r->streams[stream] : NULL;
+ for (int n = 0; n < r->num_streams; n++) {
+ struct mp_recorder_sink *rst = r->streams[n];
+ if (rst->sh == stream)
+ return rst;
+ }
+ return NULL;
}
// Pass a packet to the given stream. The function does not own the packet, but
diff --git a/common/recorder.h b/common/recorder.h
index a6c8635c01..c0b1e36495 100644
--- a/common/recorder.h
+++ b/common/recorder.h
@@ -14,7 +14,8 @@ struct mp_recorder *mp_recorder_create(struct mpv_global *global,
void mp_recorder_destroy(struct mp_recorder *r);
void mp_recorder_mark_discontinuity(struct mp_recorder *r);
-struct mp_recorder_sink *mp_recorder_get_sink(struct mp_recorder *r, int stream);
+struct mp_recorder_sink *mp_recorder_get_sink(struct mp_recorder *r,
+ struct sh_stream *stream);
void mp_recorder_feed_packet(struct mp_recorder_sink *s,
struct demux_packet *pkt);
diff --git a/demux/demux.c b/demux/demux.c
index 277bccb2a6..06ac255336 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1907,7 +1907,8 @@ static void write_dump_packet(struct demux_internal *in, struct demux_packet *dp
assert(in->dumper);
assert(in->dumper_status == CONTROL_TRUE);
- struct mp_recorder_sink *sink = mp_recorder_get_sink(in->dumper, dp->stream);
+ struct mp_recorder_sink *sink =
+ mp_recorder_get_sink(in->dumper, in->streams[dp->stream]);
if (sink) {
mp_recorder_feed_packet(sink, dp);
} else {
@@ -1935,7 +1936,7 @@ static void record_packet(struct demux_internal *in, struct demux_packet *dp)
if (in->recorder) {
struct mp_recorder_sink *sink =
- mp_recorder_get_sink(in->recorder, dp->stream);
+ mp_recorder_get_sink(in->recorder, in->streams[dp->stream]);
if (sink) {
mp_recorder_feed_packet(sink, dp);
} else {
diff --git a/player/loadfile.c b/player/loadfile.c
index 47b3d7a66e..8f0d091b29 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1874,7 +1874,7 @@ void open_recorder(struct MPContext *mpctx, bool on_init)
// (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, n_stream);
+ mp_recorder_get_sink(mpctx->recorder, streams[n_stream]);
assert(sink);
set_track_recorder_sink(track, sink);
n_stream++;