mirror of
https://github.com/mpv-player/mpv
synced 2025-01-29 19:22:48 +00:00
command, demux: remove program property
The "program" property could switch between TS programs. It was rather complex and rather obscure (even if you deal with TS captures, you usually don't need it). If anyone actually needs it (did anyone ever attempt to even use it?), it should be rewritten. The demuxer should export a program list, and the frontend should handle the "cycling" logic.
This commit is contained in:
parent
ddcbe66768
commit
a75b249b0b
@ -84,6 +84,7 @@ Interface changes
|
||||
properties. dvd:// does not support title ranges anymore.
|
||||
- Remove all "tv-..." options and properties, along with the classic Linux
|
||||
analog TV support.
|
||||
- remove "program" property (no replacement)
|
||||
--- mpv 0.29.0 ---
|
||||
- drop --opensles-sample-rate, as --audio-samplerate should be used if desired
|
||||
- drop deprecated --videotoolbox-format, --ff-aid, --ff-vid, --ff-sid,
|
||||
|
@ -1811,9 +1811,6 @@ Property list
|
||||
``osd-par``
|
||||
Last known OSD display pixel aspect (can be 0).
|
||||
|
||||
``program`` (W)
|
||||
Switch TS program (write-only).
|
||||
|
||||
``sub-text``
|
||||
Return the current subtitle text. Formatting is stripped. If a subtitle
|
||||
is selected, but no text is currently visible, or the subtitle is not
|
||||
|
@ -244,11 +244,6 @@ typedef struct demuxer {
|
||||
struct stream *stream;
|
||||
} demuxer_t;
|
||||
|
||||
typedef struct {
|
||||
int progid; //program id
|
||||
int aid, vid, sid; //audio, video and subtitle id
|
||||
} demux_program_t;
|
||||
|
||||
void demux_free(struct demuxer *demuxer);
|
||||
void demux_cancel_and_free(struct demuxer *demuxer);
|
||||
|
||||
|
@ -210,7 +210,6 @@ typedef struct lavf_priv {
|
||||
AVIOContext *pb;
|
||||
struct sh_stream **streams; // NULL for unknown streams
|
||||
int num_streams;
|
||||
int cur_program;
|
||||
char *mime_type;
|
||||
double seek_delay;
|
||||
bool optical_crap_hack;
|
||||
@ -1181,74 +1180,8 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
|
||||
switch (cmd) {
|
||||
case DEMUXER_CTRL_SWITCHED_TRACKS:
|
||||
{
|
||||
select_tracks(demuxer, 0);
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case DEMUXER_CTRL_IDENTIFY_PROGRAM:
|
||||
{
|
||||
demux_program_t *prog = arg;
|
||||
AVProgram *program;
|
||||
int p, i;
|
||||
int start;
|
||||
|
||||
add_new_streams(demuxer);
|
||||
|
||||
prog->vid = prog->aid = prog->sid = -2;
|
||||
if (priv->avfc->nb_programs < 1)
|
||||
return CONTROL_FALSE;
|
||||
|
||||
if (prog->progid == -1) {
|
||||
p = 0;
|
||||
while (p < priv->avfc->nb_programs && priv->avfc->programs[p]->id != priv->cur_program)
|
||||
p++;
|
||||
p = (p + 1) % priv->avfc->nb_programs;
|
||||
} else {
|
||||
for (i = 0; i < priv->avfc->nb_programs; i++)
|
||||
if (priv->avfc->programs[i]->id == prog->progid)
|
||||
break;
|
||||
if (i == priv->avfc->nb_programs)
|
||||
return CONTROL_FALSE;
|
||||
p = i;
|
||||
}
|
||||
start = p;
|
||||
redo:
|
||||
prog->vid = prog->aid = prog->sid = -2;
|
||||
program = priv->avfc->programs[p];
|
||||
for (i = 0; i < program->nb_stream_indexes; i++) {
|
||||
struct sh_stream *stream = priv->streams[program->stream_index[i]];
|
||||
if (stream) {
|
||||
switch (stream->type) {
|
||||
case STREAM_VIDEO:
|
||||
if (prog->vid == -2)
|
||||
prog->vid = stream->demuxer_id;
|
||||
break;
|
||||
case STREAM_AUDIO:
|
||||
if (prog->aid == -2)
|
||||
prog->aid = stream->demuxer_id;
|
||||
break;
|
||||
case STREAM_SUB:
|
||||
if (prog->sid == -2)
|
||||
prog->sid = stream->demuxer_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prog->progid == -1 && prog->vid == -2 && prog->aid == -2) {
|
||||
p = (p + 1) % priv->avfc->nb_programs;
|
||||
if (p == start)
|
||||
return CONTROL_FALSE;
|
||||
goto redo;
|
||||
}
|
||||
priv->cur_program = prog->progid = program->id;
|
||||
|
||||
mp_tags_copy_from_av_dictionary(demuxer->metadata, priv->avfc->programs[p]->metadata);
|
||||
update_metadata(demuxer);
|
||||
// Enforce metadata update even if no explicit METADATA_UPDATED since we switched program.
|
||||
demux_metadata_changed(demuxer);
|
||||
|
||||
return CONTROL_OK;
|
||||
}
|
||||
case DEMUXER_CTRL_REPLACE_STREAM:
|
||||
if (priv->own_stream)
|
||||
free_stream(priv->stream);
|
||||
|
@ -2113,63 +2113,6 @@ static int mp_property_video(void *ctx, struct m_property *prop,
|
||||
return property_switch_track(prop, action, arg, ctx, 0, STREAM_VIDEO);
|
||||
}
|
||||
|
||||
static struct track *find_track_by_demuxer_id(MPContext *mpctx,
|
||||
enum stream_type type,
|
||||
int demuxer_id)
|
||||
{
|
||||
for (int n = 0; n < mpctx->num_tracks; n++) {
|
||||
struct track *track = mpctx->tracks[n];
|
||||
if (track->type == type && track->demuxer_id == demuxer_id)
|
||||
return track;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int mp_property_program(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
demux_program_t prog = {0};
|
||||
|
||||
struct demuxer *demuxer = mpctx->demuxer;
|
||||
if (!demuxer || !mpctx->playback_initialized)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
switch (action) {
|
||||
case M_PROPERTY_SWITCH:
|
||||
case M_PROPERTY_SET:
|
||||
if (action == M_PROPERTY_SET && arg)
|
||||
prog.progid = *((int *) arg);
|
||||
else
|
||||
prog.progid = -1;
|
||||
if (demux_control(demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) ==
|
||||
CONTROL_UNKNOWN)
|
||||
return M_PROPERTY_ERROR;
|
||||
|
||||
if (prog.aid < 0 && prog.vid < 0) {
|
||||
MP_ERR(mpctx, "Selected program contains no audio or video streams!\n");
|
||||
return M_PROPERTY_ERROR;
|
||||
}
|
||||
mp_switch_track(mpctx, STREAM_VIDEO,
|
||||
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.vid), 0);
|
||||
mp_switch_track(mpctx, STREAM_AUDIO,
|
||||
find_track_by_demuxer_id(mpctx, STREAM_AUDIO, prog.aid), 0);
|
||||
mp_switch_track(mpctx, STREAM_SUB,
|
||||
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.sid), 0);
|
||||
print_track_list(mpctx, "Program switched:");
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_GET_TYPE:
|
||||
*(struct m_option *)arg = (struct m_option){
|
||||
.type = CONF_TYPE_INT,
|
||||
.flags = CONF_RANGE,
|
||||
.min = -1,
|
||||
.max = (1 << 16) - 1,
|
||||
};
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int mp_property_hwdec(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
@ -3553,7 +3496,6 @@ static const struct m_property mp_properties_base[] = {
|
||||
{"estimated-vf-fps", mp_property_vf_fps},
|
||||
{"video-aspect", mp_property_aspect},
|
||||
{"vid", mp_property_video},
|
||||
{"program", mp_property_program},
|
||||
{"hwdec", mp_property_hwdec},
|
||||
{"hwdec-current", mp_property_hwdec_current},
|
||||
{"hwdec-interop", mp_property_hwdec_interop},
|
||||
|
Loading…
Reference in New Issue
Block a user