mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 15:22:09 +00:00
stream_concat, stream_memory: more stream_origin stuff
Make concat streams use the "worst" origin of its parts, which may or may not be what makes sense. stream_memory has no natural way to do this, so just add a vague comment.
This commit is contained in:
parent
ba45b67370
commit
af6652004d
@ -87,6 +87,18 @@ static void s_close(struct stream *s)
|
|||||||
free_stream(p->streams[n]);
|
free_stream(p->streams[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the "worst" origin value of the two. cur can be 0 to mean unset.
|
||||||
|
static int combine_origin(int cur, int new)
|
||||||
|
{
|
||||||
|
if (cur == STREAM_ORIGIN_UNSAFE || new == STREAM_ORIGIN_UNSAFE)
|
||||||
|
return STREAM_ORIGIN_UNSAFE;
|
||||||
|
if (cur == STREAM_ORIGIN_NET || new == STREAM_ORIGIN_NET)
|
||||||
|
return STREAM_ORIGIN_NET;
|
||||||
|
if (cur == STREAM_ORIGIN_FS || new == STREAM_ORIGIN_FS)
|
||||||
|
return STREAM_ORIGIN_FS;
|
||||||
|
return new; // including cur==0
|
||||||
|
}
|
||||||
|
|
||||||
static int open2(struct stream *stream, struct stream_open_args *args)
|
static int open2(struct stream *stream, struct stream_open_args *args)
|
||||||
{
|
{
|
||||||
struct priv *p = talloc_zero(stream, struct priv);
|
struct priv *p = talloc_zero(stream, struct priv);
|
||||||
@ -104,6 +116,8 @@ static int open2(struct stream *stream, struct stream_open_args *args)
|
|||||||
return STREAM_ERROR;
|
return STREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stream->stream_origin = 0;
|
||||||
|
|
||||||
for (int n = 0; n < list->num_streams; n++) {
|
for (int n = 0; n < list->num_streams; n++) {
|
||||||
struct stream *sub = list->streams[n];
|
struct stream *sub = list->streams[n];
|
||||||
|
|
||||||
@ -119,6 +133,9 @@ static int open2(struct stream *stream, struct stream_open_args *args)
|
|||||||
if (!sub->seekable)
|
if (!sub->seekable)
|
||||||
stream->seekable = false;
|
stream->seekable = false;
|
||||||
|
|
||||||
|
stream->stream_origin =
|
||||||
|
combine_origin(stream->stream_origin, sub->stream_origin);
|
||||||
|
|
||||||
MP_TARRAY_APPEND(p, p->streams, p->num_streams, sub);
|
MP_TARRAY_APPEND(p, p->streams, p->num_streams, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,8 @@ const stream_info_t stream_info_memory = {
|
|||||||
.protocols = (const char*const[]){ "memory", "hex", NULL },
|
.protocols = (const char*const[]){ "memory", "hex", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The data is copied.
|
||||||
|
// Caller may need to set stream.stream_origin correctly.
|
||||||
struct stream *stream_memory_open(struct mpv_global *global, void *data, int len)
|
struct stream *stream_memory_open(struct mpv_global *global, void *data, int len)
|
||||||
{
|
{
|
||||||
assert(len >= 0);
|
assert(len >= 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user