mirror of
https://github.com/mpv-player/mpv
synced 2025-01-02 21:12:23 +00:00
dvd: move angle switching code
No need to provide a "nice" API for it; just do this stuff directly in the command code.
This commit is contained in:
parent
0cc3594623
commit
de71b50249
@ -732,42 +732,3 @@ double demuxer_get_time_length(struct demuxer *demuxer)
|
||||
return len;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int demuxer_angles_count(demuxer_t *demuxer)
|
||||
{
|
||||
int ris, angles = -1;
|
||||
|
||||
ris = stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_ANGLES, &angles);
|
||||
if (ris == STREAM_UNSUPPORTED)
|
||||
return -1;
|
||||
return angles;
|
||||
}
|
||||
|
||||
int demuxer_get_current_angle(demuxer_t *demuxer)
|
||||
{
|
||||
int ris, curr_angle = -1;
|
||||
ris = stream_control(demuxer->stream, STREAM_CTRL_GET_ANGLE, &curr_angle);
|
||||
if (ris == STREAM_UNSUPPORTED)
|
||||
return -1;
|
||||
return curr_angle;
|
||||
}
|
||||
|
||||
|
||||
int demuxer_set_angle(demuxer_t *demuxer, int angle)
|
||||
{
|
||||
int ris, angles = -1;
|
||||
|
||||
angles = demuxer_angles_count(demuxer);
|
||||
if ((angles < 1) || (angle > angles))
|
||||
return -1;
|
||||
|
||||
demux_flush(demuxer);
|
||||
|
||||
ris = stream_control(demuxer->stream, STREAM_CTRL_SET_ANGLE, &angle);
|
||||
if (ris == STREAM_UNSUPPORTED)
|
||||
return -1;
|
||||
|
||||
demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL);
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
@ -263,13 +263,6 @@ int demuxer_add_chapter(struct demuxer *demuxer, struct bstr name,
|
||||
|
||||
double demuxer_get_time_length(struct demuxer *demuxer);
|
||||
|
||||
/// Get current angle index.
|
||||
int demuxer_get_current_angle(struct demuxer *demuxer);
|
||||
/// Set angle.
|
||||
int demuxer_set_angle(struct demuxer *demuxer, int angle);
|
||||
/// Get number of angles.
|
||||
int demuxer_angles_count(struct demuxer *demuxer);
|
||||
|
||||
struct sh_stream *demuxer_stream_by_demuxer_id(struct demuxer *d,
|
||||
enum stream_type t, int id);
|
||||
|
||||
|
@ -864,15 +864,20 @@ static int mp_property_angle(void *ctx, struct m_property *prop,
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
struct demuxer *demuxer = mpctx->master_demuxer;
|
||||
int angle = -1;
|
||||
int angles;
|
||||
|
||||
if (demuxer)
|
||||
angle = demuxer_get_current_angle(demuxer);
|
||||
if (angle < 0)
|
||||
if (!demuxer)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
angles = demuxer_angles_count(demuxer);
|
||||
if (angles <= 1)
|
||||
|
||||
int ris, angles = -1, angle = 1;
|
||||
|
||||
ris = stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_ANGLES, &angles);
|
||||
if (ris == STREAM_UNSUPPORTED)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
ris = stream_control(demuxer->stream, STREAM_CTRL_GET_ANGLE, &angle);
|
||||
if (ris == STREAM_UNSUPPORTED)
|
||||
return -1;
|
||||
|
||||
if (angle < 0 || angles <= 1)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
switch (action) {
|
||||
@ -884,14 +889,23 @@ static int mp_property_angle(void *ctx, struct m_property *prop,
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
case M_PROPERTY_SET:
|
||||
angle = demuxer_set_angle(demuxer, *(int *)arg);
|
||||
if (angle >= 0) {
|
||||
if (mpctx->d_video)
|
||||
video_reset_decoding(mpctx->d_video);
|
||||
angle = *(int *)arg;
|
||||
if (angle < 0 || angle > angles)
|
||||
return M_PROPERTY_ERROR;
|
||||
demux_flush(demuxer);
|
||||
|
||||
ris = stream_control(demuxer->stream, STREAM_CTRL_SET_ANGLE, &angle);
|
||||
if (ris != STREAM_OK)
|
||||
return M_PROPERTY_ERROR;
|
||||
|
||||
demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL);
|
||||
|
||||
if (mpctx->d_video)
|
||||
video_reset_decoding(mpctx->d_video);
|
||||
|
||||
if (mpctx->d_audio)
|
||||
audio_reset_decoding(mpctx->d_audio);
|
||||
|
||||
if (mpctx->d_audio)
|
||||
audio_reset_decoding(mpctx->d_audio);
|
||||
}
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_GET_TYPE: {
|
||||
struct m_option opt = {
|
||||
|
Loading…
Reference in New Issue
Block a user