2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "input/input.h"
29 #include "stream/stream.h"
30 #include "libmpdemux/demuxer.h"
31 #include "libmpdemux/stheader.h"
32 #include "codec-cfg.h"
35 #include "sub/dec_sub.h"
37 #include "m_property.h"
40 #include "libmpcodecs/vf.h"
41 #include "libmpcodecs/vd.h"
43 #include "libvo/video_out.h"
44 #include "libvo/csputils.h"
46 #include "libao2/audio_out.h"
49 #include "libmpcodecs/dec_video.h"
50 #include "libmpcodecs/dec_audio.h"
51 #include "libmpcodecs/dec_teletext.h"
52 #include "osdep/strsep.h"
53 #include "sub/vobsub.h"
54 #include "sub/spudec.h"
56 #include "sub/ass_mp.h"
57 #include "stream/tv.h"
58 #include "stream/stream_radio.h"
59 #include "stream/pvr.h"
61 #include "stream/dvbin.h"
64 #include "stream/stream_dvd.h"
66 #include "stream/stream_dvdnav.h"
68 #include "screenshot.h"
72 #include "libavutil/avstring.h"
74 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
75 double *dx
, double *dy
)
77 struct MPOpts
*opts
= &mpctx
->opts
;
78 struct vo
*vo
= mpctx
->video_out
;
79 //remove the borders, if any, and rescale to the range [0,1],[0,1]
80 if (vo_fs
) { //we are in full-screen mode
81 if (opts
->vo_screenwidth
> vo
->dwidth
)
82 // there are borders along the x axis
83 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
84 if (opts
->vo_screenheight
> vo
->dheight
)
85 // there are borders along the y axis (usual way)
86 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
88 if (ix
< 0 || ix
> vo
->dwidth
) {
91 } //we are on one of the borders
92 if (iy
< 0 || iy
> vo
->dheight
) {
95 } //we are on one of the borders
98 *dx
= (double) ix
/ (double) vo
->dwidth
;
99 *dy
= (double) iy
/ (double) vo
->dheight
;
101 mp_msg(MSGT_CPLAYER
, MSGL_V
,
102 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
103 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
107 static int sub_pos_by_source(MPContext
*mpctx
, int src
)
110 if (src
>= SUB_SOURCES
|| mpctx
->sub_counts
[src
] == 0)
112 for (i
= 0; i
< src
; i
++)
113 cnt
+= mpctx
->sub_counts
[i
];
117 static int sub_source_and_index_by_pos(MPContext
*mpctx
, int *pos
)
121 for (i
= 0; i
< SUB_SOURCES
; i
++) {
122 int cnt
= mpctx
->sub_counts
[i
];
123 if (*pos
>= start
&& *pos
< start
+ cnt
) {
133 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
135 return sub_source_and_index_by_pos(mpctx
, &pos
);
138 static int sub_source_pos(MPContext
*mpctx
)
140 int pos
= mpctx
->global_sub_pos
;
141 sub_source_and_index_by_pos(mpctx
, &pos
);
145 static int sub_source(MPContext
*mpctx
)
147 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
150 static void update_global_sub_size(MPContext
*mpctx
)
152 struct MPOpts
*opts
= &mpctx
->opts
;
156 // update number of demuxer sub streams
157 for (i
= 0; i
< MAX_S_STREAMS
; i
++)
158 if (mpctx
->d_sub
->demuxer
->s_streams
[i
])
160 if (cnt
> mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
161 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
] = cnt
;
163 // update global size
164 mpctx
->global_sub_size
= 0;
165 for (i
= 0; i
< SUB_SOURCES
; i
++)
166 mpctx
->global_sub_size
+= mpctx
->sub_counts
[i
];
168 // update global_sub_pos if we auto-detected a demuxer sub
169 if (mpctx
->global_sub_pos
== -1) {
171 if (mpctx
->demuxer
->sub
)
172 sub_id
= mpctx
->demuxer
->sub
->id
;
174 sub_id
= opts
->sub_id
;
175 if (sub_id
>= 0 && sub_id
< mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
176 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, SUB_SOURCE_DEMUX
) +
182 * \brief Log the currently displayed subtitle to a file
184 * Logs the current or last displayed subtitle together with filename
185 * and time information to ~/.mplayer/subtitle_log
187 * Intended purpose is to allow convenient marking of bogus subtitles
188 * which need to be fixed while watching the movie.
191 static void log_sub(struct MPContext
*mpctx
)
196 struct subtitle
*vo_sub_last
= mpctx
->vo_sub_last
;
198 if (mpctx
->subdata
== NULL
|| vo_sub_last
== NULL
)
200 fname
= get_path("subtitle_log");
201 f
= fopen(fname
, "a");
204 fprintf(f
, "----------------------------------------------------------\n");
205 if (mpctx
->subdata
->sub_uses_time
) {
207 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
208 mpctx
->filename
, vo_sub_last
->start
/ 360000,
209 (vo_sub_last
->start
/ 6000) % 60,
210 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
211 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
212 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
214 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
215 vo_sub_last
->start
, vo_sub_last
->end
);
217 for (i
= 0; i
< vo_sub_last
->lines
; i
++)
218 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
223 static int mp_property_generic_option(struct m_option
*prop
, int action
,
224 void *arg
, MPContext
*mpctx
)
226 char *optname
= prop
->priv
;
227 const struct m_option
*opt
= m_config_get_option(mpctx
->mconfig
,
229 void *valptr
= m_option_get_ptr(opt
, &mpctx
->opts
);
232 case M_PROPERTY_GET_TYPE
:
233 *(const struct m_option
**)arg
= opt
;
234 return M_PROPERTY_OK
;
236 m_option_copy(opt
, arg
, valptr
);
237 return M_PROPERTY_OK
;
239 m_option_copy(opt
, valptr
, arg
);
240 return M_PROPERTY_OK
;
241 case M_PROPERTY_STEP
:
242 if (opt
->type
== &m_option_type_choice
) {
243 int v
= *(int *) valptr
;
245 struct m_opt_choice_alternatives
*alt
;
246 for (alt
= opt
->priv
; alt
->name
; alt
++)
247 if ((unsigned) alt
->value
- v
- 1 < (unsigned) best
- v
- 1)
249 *(int *) valptr
= best
;
250 return M_PROPERTY_OK
;
254 return M_PROPERTY_NOT_IMPLEMENTED
;
258 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
261 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
265 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
268 struct MPOpts
*opts
= &mpctx
->opts
;
270 case M_PROPERTY_PRINT
:
272 return M_PROPERTY_ERROR
;
273 if (opts
->loop_times
< 0)
274 *(char **)arg
= talloc_strdup(NULL
, "off");
275 else if (opts
->loop_times
== 0)
276 *(char **)arg
= talloc_strdup(NULL
, "inf");
279 return M_PROPERTY_OK
;
281 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
284 /// Playback speed (RW)
285 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
286 void *arg
, MPContext
*mpctx
)
288 struct MPOpts
*opts
= &mpctx
->opts
;
289 double orig_speed
= opts
->playback_speed
;
293 return M_PROPERTY_ERROR
;
294 opts
->playback_speed
= *(float *) arg
;
296 case M_PROPERTY_STEP
:
297 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1);
299 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
300 if (opts
->playback_speed
== orig_speed
)
301 return M_PROPERTY_OK
;
302 // Adjust time until next frame flip for nosound mode
303 mpctx
->time_frame
*= orig_speed
/ opts
->playback_speed
;
304 if (mpctx
->sh_audio
) {
305 double a
= ao_get_delay(mpctx
->ao
);
306 mpctx
->delay
+= (opts
->playback_speed
- orig_speed
) * a
;
308 reinit_audio_chain(mpctx
);
309 return M_PROPERTY_OK
;
311 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
314 /// filename with path (RO)
315 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
318 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
321 /// filename without path (RO)
322 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
326 if (!mpctx
->filename
)
327 return M_PROPERTY_UNAVAILABLE
;
328 f
= (char *)mp_basename(mpctx
->filename
);
331 return m_property_string_ro(prop
, action
, arg
, f
);
334 /// Demuxer name (RO)
335 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
339 return M_PROPERTY_UNAVAILABLE
;
340 return m_property_string_ro(prop
, action
, arg
,
341 (char *) mpctx
->demuxer
->desc
->name
);
344 /// Position in the stream (RW)
345 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
348 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
349 return M_PROPERTY_UNAVAILABLE
;
351 return M_PROPERTY_ERROR
;
354 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
355 return M_PROPERTY_OK
;
357 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
358 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
359 return M_PROPERTY_OK
;
361 return M_PROPERTY_NOT_IMPLEMENTED
;
364 /// Stream start offset (RO)
365 static int mp_property_stream_start(m_option_t
*prop
, int action
,
366 void *arg
, MPContext
*mpctx
)
368 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
369 return M_PROPERTY_UNAVAILABLE
;
372 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
373 return M_PROPERTY_OK
;
375 return M_PROPERTY_NOT_IMPLEMENTED
;
378 /// Stream end offset (RO)
379 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
382 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
383 return M_PROPERTY_UNAVAILABLE
;
386 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
387 return M_PROPERTY_OK
;
389 return M_PROPERTY_NOT_IMPLEMENTED
;
392 /// Stream length (RO)
393 static int mp_property_stream_length(m_option_t
*prop
, int action
,
394 void *arg
, MPContext
*mpctx
)
396 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
397 return M_PROPERTY_UNAVAILABLE
;
401 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
402 return M_PROPERTY_OK
;
404 return M_PROPERTY_NOT_IMPLEMENTED
;
407 /// Current stream position in seconds (RO)
408 static int mp_property_stream_time_pos(m_option_t
*prop
, int action
,
409 void *arg
, MPContext
*mpctx
)
411 if (!mpctx
->demuxer
|| mpctx
->demuxer
->stream_pts
== MP_NOPTS_VALUE
)
412 return M_PROPERTY_UNAVAILABLE
;
414 return m_property_time_ro(prop
, action
, arg
, mpctx
->demuxer
->stream_pts
);
418 /// Media length in seconds (RO)
419 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
424 if (!mpctx
->demuxer
||
425 !(int) (len
= get_time_length(mpctx
)))
426 return M_PROPERTY_UNAVAILABLE
;
428 return m_property_time_ro(prop
, action
, arg
, len
);
431 /// Current position in percent (RW)
432 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
433 void *arg
, MPContext
*mpctx
)
438 return M_PROPERTY_UNAVAILABLE
;
443 return M_PROPERTY_ERROR
;
444 M_PROPERTY_CLAMP(prop
, *(int *)arg
);
447 case M_PROPERTY_STEP
:
448 pos
= get_percent_pos(mpctx
);
449 pos
+= (arg
? *(int *)arg
: 10);
450 M_PROPERTY_CLAMP(prop
, pos
);
453 return m_property_int_ro(prop
, action
, arg
, get_percent_pos(mpctx
));
456 queue_seek(mpctx
, MPSEEK_FACTOR
, pos
/ 100.0, 0);
457 return M_PROPERTY_OK
;
460 /// Current position in seconds (RW)
461 static int mp_property_time_pos(m_option_t
*prop
, int action
,
462 void *arg
, MPContext
*mpctx
)
464 if (!(mpctx
->sh_video
|| mpctx
->sh_audio
))
465 return M_PROPERTY_UNAVAILABLE
;
470 return M_PROPERTY_ERROR
;
471 M_PROPERTY_CLAMP(prop
, *(double *)arg
);
472 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, *(double *)arg
, 0);
473 return M_PROPERTY_OK
;
474 case M_PROPERTY_STEP
:
475 queue_seek(mpctx
, MPSEEK_RELATIVE
, (arg
? *(double *)arg
: 10.0), 0);
476 return M_PROPERTY_OK
;
478 return m_property_time_ro(prop
, action
, arg
, get_current_time(mpctx
));
481 /// Current chapter (RW)
482 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
485 struct MPOpts
*opts
= &mpctx
->opts
;
488 char *chapter_name
= NULL
;
491 chapter
= get_current_chapter(mpctx
);
493 return M_PROPERTY_UNAVAILABLE
;
498 return M_PROPERTY_ERROR
;
499 *(int *) arg
= chapter
;
500 return M_PROPERTY_OK
;
501 case M_PROPERTY_PRINT
: {
503 return M_PROPERTY_ERROR
;
504 chapter_name
= chapter_display_name(mpctx
, chapter
);
506 return M_PROPERTY_UNAVAILABLE
;
507 *(char **) arg
= chapter_name
;
508 return M_PROPERTY_OK
;
512 return M_PROPERTY_ERROR
;
513 M_PROPERTY_CLAMP(prop
, *(int *)arg
);
514 step_all
= *(int *)arg
- chapter
;
517 case M_PROPERTY_STEP
: {
518 step_all
= (arg
&& *(int *)arg
!= 0 ? *(int *)arg
: 1);
525 return M_PROPERTY_NOT_IMPLEMENTED
;
529 queue_seek(mpctx
, MPSEEK_NONE
, 0, 0);
530 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
);
533 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, next_pts
, 0);
534 chapter_name
= chapter_display_name(mpctx
, chapter
);
535 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
536 "Chapter: %s", chapter_name
);
537 } else if (step_all
> 0)
538 queue_seek(mpctx
, MPSEEK_RELATIVE
, 1000000000, 0);
540 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
541 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
542 talloc_free(chapter_name
);
543 return M_PROPERTY_OK
;
546 /// Number of chapters in file
547 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
551 return M_PROPERTY_UNAVAILABLE
;
552 int count
= get_chapter_count(mpctx
);
553 return m_property_int_ro(prop
, action
, arg
, count
);
556 /// Current dvd angle (RW)
557 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
560 struct MPOpts
*opts
= &mpctx
->opts
;
565 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
567 return M_PROPERTY_UNAVAILABLE
;
568 angles
= demuxer_angles_count(mpctx
->demuxer
);
570 return M_PROPERTY_UNAVAILABLE
;
575 return M_PROPERTY_ERROR
;
576 *(int *) arg
= angle
;
577 return M_PROPERTY_OK
;
578 case M_PROPERTY_PRINT
: {
580 return M_PROPERTY_ERROR
;
581 *(char **) arg
= talloc_asprintf(NULL
, "%d/%d", angle
, angles
);
582 return M_PROPERTY_OK
;
586 return M_PROPERTY_ERROR
;
588 M_PROPERTY_CLAMP(prop
, angle
);
590 case M_PROPERTY_STEP
: {
597 if (angle
< 1) //cycle
599 else if (angle
> angles
)
604 return M_PROPERTY_NOT_IMPLEMENTED
;
606 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
608 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
610 resync_video_stream(sh_video
);
612 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
614 resync_audio_stream(sh_audio
);
617 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
618 "Angle: %d/%d", angle
, angles
);
619 return M_PROPERTY_OK
;
622 /// Demuxer meta data
623 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
626 m_property_action_t
*ka
;
628 static const m_option_t key_type
=
630 "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
633 return M_PROPERTY_UNAVAILABLE
;
638 return M_PROPERTY_ERROR
;
639 *(char ***)arg
= mpctx
->demuxer
->info
;
640 return M_PROPERTY_OK
;
641 case M_PROPERTY_KEY_ACTION
:
643 return M_PROPERTY_ERROR
;
645 if (!(meta
= demux_info_get(mpctx
->demuxer
, ka
->key
)))
646 return M_PROPERTY_UNKNOWN
;
647 switch (ka
->action
) {
650 return M_PROPERTY_ERROR
;
651 *(char **)ka
->arg
= meta
;
652 return M_PROPERTY_OK
;
653 case M_PROPERTY_GET_TYPE
:
655 return M_PROPERTY_ERROR
;
656 *(const m_option_t
**)ka
->arg
= &key_type
;
657 return M_PROPERTY_OK
;
660 return M_PROPERTY_NOT_IMPLEMENTED
;
663 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
666 MPContext
*mpctx
= ctx
;
671 return M_PROPERTY_ERROR
;
672 if (mpctx
->paused
== (bool) * (int *)arg
)
673 return M_PROPERTY_OK
;
674 case M_PROPERTY_STEP
:
676 unpause_player(mpctx
);
680 return M_PROPERTY_OK
;
682 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
688 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
692 if (!mpctx
->sh_audio
)
693 return M_PROPERTY_UNAVAILABLE
;
698 return M_PROPERTY_ERROR
;
699 mixer_getbothvolume(&mpctx
->mixer
, arg
);
700 return M_PROPERTY_OK
;
701 case M_PROPERTY_PRINT
: {
704 return M_PROPERTY_ERROR
;
705 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
706 return m_property_float_range(prop
, action
, arg
, &vol
);
710 return M_PROPERTY_ERROR
;
711 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
712 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
713 return M_PROPERTY_OK
;
714 case M_PROPERTY_STEP
:
715 if (arg
&& *(float *) arg
<= 0)
716 mixer_decvolume(&mpctx
->mixer
);
718 mixer_incvolume(&mpctx
->mixer
);
719 return M_PROPERTY_OK
;
721 return M_PROPERTY_NOT_IMPLEMENTED
;
726 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
730 if (!mpctx
->sh_audio
)
731 return M_PROPERTY_UNAVAILABLE
;
736 return M_PROPERTY_ERROR
;
737 mixer_setmute(&mpctx
->mixer
, *(int *) arg
);
738 return M_PROPERTY_OK
;
739 case M_PROPERTY_STEP
:
740 mixer_setmute(&mpctx
->mixer
, !mixer_getmute(&mpctx
->mixer
));
741 return M_PROPERTY_OK
;
743 return m_property_flag_ro(prop
, action
, arg
,
744 mixer_getmute(&mpctx
->mixer
));
749 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
750 void *arg
, MPContext
*mpctx
)
752 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
753 return M_PROPERTY_UNAVAILABLE
;
756 case M_PROPERTY_STEP
: {
758 float delay
= audio_delay
;
759 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
760 if (ret
!= M_PROPERTY_OK
)
763 mpctx
->delay
-= audio_delay
- delay
;
765 return M_PROPERTY_OK
;
767 return m_property_delay(prop
, action
, arg
, &audio_delay
);
771 /// Audio codec tag (RO)
772 static int mp_property_audio_format(m_option_t
*prop
, int action
,
773 void *arg
, MPContext
*mpctx
)
775 if (!mpctx
->sh_audio
)
776 return M_PROPERTY_UNAVAILABLE
;
777 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
780 /// Audio codec name (RO)
781 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
782 void *arg
, MPContext
*mpctx
)
784 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
785 return M_PROPERTY_UNAVAILABLE
;
786 return m_property_string_ro(prop
, action
, arg
,
787 mpctx
->sh_audio
->codec
->name
);
790 /// Audio bitrate (RO)
791 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
792 void *arg
, MPContext
*mpctx
)
794 if (!mpctx
->sh_audio
)
795 return M_PROPERTY_UNAVAILABLE
;
796 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
800 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
803 if (!mpctx
->sh_audio
)
804 return M_PROPERTY_UNAVAILABLE
;
806 case M_PROPERTY_PRINT
:
808 return M_PROPERTY_ERROR
;
809 *(char **)arg
= talloc_asprintf(NULL
, "%d kHz",
810 mpctx
->sh_audio
->samplerate
/ 1000);
811 return M_PROPERTY_OK
;
813 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
816 /// Number of channels (RO)
817 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
820 if (!mpctx
->sh_audio
)
821 return M_PROPERTY_UNAVAILABLE
;
823 case M_PROPERTY_PRINT
:
825 return M_PROPERTY_ERROR
;
826 switch (mpctx
->sh_audio
->channels
) {
828 *(char **) arg
= talloc_strdup(NULL
, "mono");
831 *(char **) arg
= talloc_strdup(NULL
, "stereo");
834 *(char **) arg
= talloc_asprintf(NULL
, "%d channels",
835 mpctx
->sh_audio
->channels
);
837 return M_PROPERTY_OK
;
839 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
843 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
851 return M_PROPERTY_ERROR
;
852 mixer_getbalance(&mpctx
->mixer
, arg
);
853 return M_PROPERTY_OK
;
854 case M_PROPERTY_PRINT
: {
857 return M_PROPERTY_ERROR
;
858 mixer_getbalance(&mpctx
->mixer
, &bal
);
860 *str
= talloc_strdup(NULL
, "center");
861 else if (bal
== -1.f
)
862 *str
= talloc_strdup(NULL
, "left only");
864 *str
= talloc_strdup(NULL
, "right only");
866 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
867 *str
= talloc_asprintf(NULL
, "left %d%%, right %d%%",
870 return M_PROPERTY_OK
;
872 case M_PROPERTY_STEP
:
873 mixer_getbalance(&mpctx
->mixer
, &bal
);
874 bal
+= (arg
? *(float *)arg
: .1f
);
875 M_PROPERTY_CLAMP(prop
, bal
);
876 mixer_setbalance(&mpctx
->mixer
, bal
);
877 return M_PROPERTY_OK
;
880 return M_PROPERTY_ERROR
;
881 M_PROPERTY_CLAMP(prop
, *(float *)arg
);
882 mixer_setbalance(&mpctx
->mixer
, *(float *)arg
);
883 return M_PROPERTY_OK
;
885 return M_PROPERTY_NOT_IMPLEMENTED
;
888 /// Selected audio id (RW)
889 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
893 if (!mpctx
->demuxer
|| !mpctx
->d_audio
)
894 return M_PROPERTY_UNAVAILABLE
;
895 struct sh_audio
*sh
= mpctx
->sh_audio
;
896 current_id
= sh
? sh
->aid
: -2;
901 return M_PROPERTY_ERROR
;
902 *(int *) arg
= current_id
;
903 return M_PROPERTY_OK
;
904 case M_PROPERTY_PRINT
:
906 return M_PROPERTY_ERROR
;
909 *(char **) arg
= talloc_strdup(NULL
, mp_gtext("disabled"));
910 else if (sh
&& (sh
->lang
|| sh
->title
)) {
911 char *lang
= sh
->lang
? sh
->lang
: mp_gtext("unknown");
913 *(char **)arg
= talloc_asprintf(NULL
, "(%d) %s (\"%s\")",
914 current_id
, lang
, sh
->title
);
916 *(char **)arg
= talloc_asprintf(NULL
, "(%d) %s", current_id
,
920 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
922 #ifdef CONFIG_DVDREAD
923 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
924 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
934 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
935 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
937 *(char **)arg
= talloc_asprintf(NULL
, "(%d) %s", current_id
, lang
);
939 return M_PROPERTY_OK
;
941 case M_PROPERTY_STEP
:
943 if (action
== M_PROPERTY_SET
&& arg
)
944 tmp
= *((int *) arg
);
947 int new_id
= demuxer_switch_audio(mpctx
->d_audio
->demuxer
, tmp
);
948 if (new_id
!= current_id
)
949 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
950 if (new_id
!= current_id
&& new_id
>= 0) {
952 sh2
= mpctx
->d_audio
->demuxer
->a_streams
[mpctx
->d_audio
->id
];
953 sh2
->ds
= mpctx
->d_audio
;
954 mpctx
->sh_audio
= sh2
;
955 reinit_audio_chain(mpctx
);
957 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
958 return M_PROPERTY_OK
;
960 return M_PROPERTY_NOT_IMPLEMENTED
;
965 /// Selected video id (RW)
966 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
969 struct MPOpts
*opts
= &mpctx
->opts
;
971 if (!mpctx
->demuxer
|| !mpctx
->d_video
)
972 return M_PROPERTY_UNAVAILABLE
;
973 current_id
= mpctx
->sh_video
? mpctx
->sh_video
->vid
: -2;
978 return M_PROPERTY_ERROR
;
979 *(int *) arg
= current_id
;
980 return M_PROPERTY_OK
;
981 case M_PROPERTY_PRINT
:
983 return M_PROPERTY_ERROR
;
986 *(char **) arg
= talloc_strdup(NULL
, mp_gtext("disabled"));
988 *(char **) arg
= talloc_asprintf(NULL
, "(%d) %s", current_id
,
989 mp_gtext("unknown"));
991 return M_PROPERTY_OK
;
993 case M_PROPERTY_STEP
:
995 if (action
== M_PROPERTY_SET
&& arg
)
996 tmp
= *((int *) arg
);
999 int new_id
= demuxer_switch_video(mpctx
->d_video
->demuxer
, tmp
);
1000 if (new_id
!= current_id
)
1001 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1002 (opts
->fixed_vo
&& new_id
>= 0 ? 0 : INITIALIZED_VO
));
1003 if (new_id
!= current_id
&& new_id
>= 0) {
1005 sh2
= mpctx
->d_video
->demuxer
->v_streams
[mpctx
->d_video
->id
];
1006 sh2
->ds
= mpctx
->d_video
;
1007 mpctx
->sh_video
= sh2
;
1008 reinit_video_chain(mpctx
);
1010 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", new_id
);
1011 return M_PROPERTY_OK
;
1014 return M_PROPERTY_NOT_IMPLEMENTED
;
1018 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1021 demux_program_t prog
;
1024 case M_PROPERTY_STEP
:
1025 case M_PROPERTY_SET
:
1026 if (action
== M_PROPERTY_SET
&& arg
)
1027 prog
.progid
= *((int *) arg
);
1030 if (demux_control(mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1031 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1032 return M_PROPERTY_ERROR
;
1034 if (prog
.aid
< 0 && prog
.vid
< 0) {
1035 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
1036 "Selected program contains no audio or video streams!\n");
1037 return M_PROPERTY_ERROR
;
1039 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1040 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1041 return M_PROPERTY_OK
;
1044 return M_PROPERTY_NOT_IMPLEMENTED
;
1049 /// Fullscreen state (RW)
1050 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1054 if (!mpctx
->video_out
)
1055 return M_PROPERTY_UNAVAILABLE
;
1058 case M_PROPERTY_SET
:
1060 return M_PROPERTY_ERROR
;
1061 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1062 if (vo_fs
== !!*(int *) arg
)
1063 return M_PROPERTY_OK
;
1064 case M_PROPERTY_STEP
:
1065 if (mpctx
->video_out
->config_ok
)
1066 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1067 mpctx
->opts
.fullscreen
= vo_fs
;
1068 return M_PROPERTY_OK
;
1070 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1074 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1075 void *arg
, MPContext
*mpctx
)
1079 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1080 return M_PROPERTY_UNAVAILABLE
;
1081 vf
= mpctx
->sh_video
->vfilter
;
1083 case M_PROPERTY_GET
:
1085 return M_PROPERTY_ERROR
;
1086 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1087 return M_PROPERTY_OK
;
1088 case M_PROPERTY_SET
:
1090 return M_PROPERTY_ERROR
;
1091 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1092 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1093 return M_PROPERTY_OK
;
1094 case M_PROPERTY_STEP
:
1095 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1096 deinterlace
= !deinterlace
;
1097 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1098 return M_PROPERTY_OK
;
1101 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1102 return m_property_flag_ro(prop
, action
, arg
, value
);
1105 static int colormatrix_property_helper(m_option_t
*prop
, int action
,
1106 void *arg
, MPContext
*mpctx
)
1108 int r
= mp_property_generic_option(prop
, action
, arg
, mpctx
);
1109 // testing for an actual change is too much effort
1111 case M_PROPERTY_SET
:
1112 case M_PROPERTY_STEP
:
1113 if (mpctx
->sh_video
)
1114 set_video_colorspace(mpctx
->sh_video
);
1120 static int mp_property_colormatrix(m_option_t
*prop
, int action
, void *arg
,
1123 struct MPOpts
*opts
= &mpctx
->opts
;
1125 case M_PROPERTY_PRINT
:
1127 return M_PROPERTY_ERROR
;
1128 struct mp_csp_details actual
= { .format
= -1 };
1129 char *req_csp
= mp_csp_names
[opts
->requested_colorspace
];
1130 char *real_csp
= NULL
;
1131 if (mpctx
->sh_video
) {
1132 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1133 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &actual
) == true) {
1134 real_csp
= mp_csp_names
[actual
.format
];
1136 real_csp
= "Unknown";
1140 if (opts
->requested_colorspace
== MP_CSP_AUTO
&& real_csp
) {
1141 // Caveat: doesn't handle the case when the autodetected colorspace
1142 // is different from the actual colorspace as used by the
1143 // VO - the OSD will display the VO colorspace without
1144 // indication that it doesn't match the requested colorspace.
1145 res
= talloc_asprintf(NULL
, "Auto (%s)", real_csp
);
1146 } else if (opts
->requested_colorspace
== actual
.format
|| !real_csp
) {
1147 res
= talloc_strdup(NULL
, req_csp
);
1149 res
= talloc_asprintf(NULL
, mp_gtext("%s, but %s used"),
1151 *(char **)arg
= res
;
1152 return M_PROPERTY_OK
;
1154 return colormatrix_property_helper(prop
, action
, arg
, mpctx
);
1158 static int levels_property_helper(int offset
, m_option_t
*prop
, int action
,
1159 void *arg
, MPContext
*mpctx
)
1161 char *optname
= prop
->priv
;
1162 const struct m_option
*opt
= m_config_get_option(mpctx
->mconfig
,
1164 int *valptr
= (int *)m_option_get_ptr(opt
, &mpctx
->opts
);
1167 case M_PROPERTY_PRINT
:
1169 return M_PROPERTY_ERROR
;
1170 struct mp_csp_details actual
= {0};
1171 int actual_level
= -1;
1172 char *req_level
= m_option_print(opt
, valptr
);
1173 char *real_level
= NULL
;
1174 if (mpctx
->sh_video
) {
1175 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1176 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &actual
) == true) {
1177 actual_level
= *(enum mp_csp_levels
*)(((char *)&actual
) + offset
);
1178 real_level
= m_option_print(opt
, &actual_level
);
1180 real_level
= talloc_strdup(NULL
, "Unknown");
1184 if (*valptr
== MP_CSP_LEVELS_AUTO
&& real_level
) {
1185 res
= talloc_asprintf(NULL
, "Auto (%s)", real_level
);
1186 } else if (*valptr
== actual_level
|| !real_level
) {
1187 res
= talloc_strdup(NULL
, real_level
);
1189 res
= talloc_asprintf(NULL
, mp_gtext("%s, but %s used"),
1190 req_level
, real_level
);
1191 talloc_free(req_level
);
1192 talloc_free(real_level
);
1193 *(char **)arg
= res
;
1194 return M_PROPERTY_OK
;
1196 return colormatrix_property_helper(prop
, action
, arg
, mpctx
);
1200 static int mp_property_colormatrix_input_range(m_option_t
*prop
, int action
,
1201 void *arg
, MPContext
*mpctx
)
1203 return levels_property_helper(offsetof(struct mp_csp_details
, levels_in
),
1204 prop
, action
, arg
, mpctx
);
1207 static int mp_property_colormatrix_output_range(m_option_t
*prop
, int action
,
1208 void *arg
, MPContext
*mpctx
)
1210 return levels_property_helper(offsetof(struct mp_csp_details
, levels_out
),
1211 prop
, action
, arg
, mpctx
);
1214 static int mp_property_capture(m_option_t
*prop
, int action
,
1215 void *arg
, MPContext
*mpctx
)
1217 struct MPOpts
*opts
= &mpctx
->opts
;
1220 return M_PROPERTY_UNAVAILABLE
;
1222 if (!opts
->capture_dump
) {
1223 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1224 "Capturing not enabled (forgot -capture parameter?)\n");
1225 return M_PROPERTY_ERROR
;
1228 int capturing
= !!mpctx
->stream
->capture_file
;
1230 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1231 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1233 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1234 if (!mpctx
->stream
->capture_file
) {
1235 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1236 "Error opening capture file: %s\n", strerror(errno
));
1237 ret
= M_PROPERTY_ERROR
;
1240 fclose(mpctx
->stream
->capture_file
);
1241 mpctx
->stream
->capture_file
= NULL
;
1249 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1253 if (!mpctx
->video_out
1254 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1255 return M_PROPERTY_UNAVAILABLE
;
1258 case M_PROPERTY_SET
:
1260 return M_PROPERTY_ERROR
;
1261 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1262 vo_panscan
= *(float *) arg
;
1263 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1264 return M_PROPERTY_OK
;
1265 case M_PROPERTY_STEP
:
1266 vo_panscan
+= (arg
? *(float *) arg
: 0.1);
1269 else if (vo_panscan
< 0)
1271 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1272 return M_PROPERTY_OK
;
1274 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1278 /// Helper to set vo flags.
1279 /** \ingroup PropertyImplHelper
1281 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1282 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1285 if (!mpctx
->video_out
)
1286 return M_PROPERTY_UNAVAILABLE
;
1289 case M_PROPERTY_SET
:
1291 return M_PROPERTY_ERROR
;
1292 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1293 if (*vo_var
== !!*(int *) arg
)
1294 return M_PROPERTY_OK
;
1295 case M_PROPERTY_STEP
:
1296 if (mpctx
->video_out
->config_ok
)
1297 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1298 return M_PROPERTY_OK
;
1300 return m_property_flag(prop
, action
, arg
, vo_var
);
1304 /// Window always on top (RW)
1305 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1308 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1309 &mpctx
->opts
.vo_ontop
, mpctx
);
1312 /// Display in the root window (RW)
1313 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1316 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1317 &vo_rootwin
, mpctx
);
1320 /// Show window borders (RW)
1321 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1324 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1328 /// Framedropping state (RW)
1329 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1330 void *arg
, MPContext
*mpctx
)
1333 if (!mpctx
->sh_video
)
1334 return M_PROPERTY_UNAVAILABLE
;
1337 case M_PROPERTY_PRINT
:
1339 return M_PROPERTY_ERROR
;
1340 *(char **) arg
= talloc_strdup(NULL
, frame_dropping
== 1 ?
1341 mp_gtext("enabled") :
1342 (frame_dropping
== 2 ? mp_gtext("hard") :
1343 mp_gtext("disabled")));
1344 return M_PROPERTY_OK
;
1346 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1350 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1351 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1354 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1357 if (!mpctx
->sh_video
)
1358 return M_PROPERTY_UNAVAILABLE
;
1360 if (gamma
[0] == 1000) {
1362 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1366 case M_PROPERTY_SET
:
1368 return M_PROPERTY_ERROR
;
1369 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1370 *gamma
= *(int *) arg
;
1371 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1375 case M_PROPERTY_GET
:
1376 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1378 return M_PROPERTY_ERROR
;
1380 return M_PROPERTY_OK
;
1383 case M_PROPERTY_STEP
:
1384 *gamma
+= (arg
? *(int *) arg
: 1);
1385 M_PROPERTY_CLAMP(prop
, *gamma
);
1386 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1391 return M_PROPERTY_NOT_IMPLEMENTED
;
1395 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1396 int l
= strlen(prop
->name
);
1397 char tv_prop
[3 + l
+ 1];
1398 sprintf(tv_prop
, "tv_%s", prop
->name
);
1399 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1403 return M_PROPERTY_UNAVAILABLE
;
1407 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1410 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1413 /// Video codec tag (RO)
1414 static int mp_property_video_format(m_option_t
*prop
, int action
,
1415 void *arg
, MPContext
*mpctx
)
1418 if (!mpctx
->sh_video
)
1419 return M_PROPERTY_UNAVAILABLE
;
1421 case M_PROPERTY_PRINT
:
1423 return M_PROPERTY_ERROR
;
1424 switch (mpctx
->sh_video
->format
) {
1426 meta
= talloc_strdup(NULL
, "mpeg1");
1429 meta
= talloc_strdup(NULL
, "mpeg2");
1432 meta
= talloc_strdup(NULL
, "mpeg4");
1435 meta
= talloc_strdup(NULL
, "h264");
1438 if (mpctx
->sh_video
->format
>= 0x20202020) {
1439 meta
= talloc_asprintf(NULL
, "%.4s",
1440 (char *) &mpctx
->sh_video
->format
);
1442 meta
= talloc_asprintf(NULL
, "0x%08X", mpctx
->sh_video
->format
);
1444 *(char **)arg
= meta
;
1445 return M_PROPERTY_OK
;
1447 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1450 /// Video codec name (RO)
1451 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1452 void *arg
, MPContext
*mpctx
)
1454 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1455 return M_PROPERTY_UNAVAILABLE
;
1456 return m_property_string_ro(prop
, action
, arg
,
1457 mpctx
->sh_video
->codec
->name
);
1461 /// Video bitrate (RO)
1462 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1463 void *arg
, MPContext
*mpctx
)
1465 if (!mpctx
->sh_video
)
1466 return M_PROPERTY_UNAVAILABLE
;
1467 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1470 /// Video display width (RO)
1471 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1474 if (!mpctx
->sh_video
)
1475 return M_PROPERTY_UNAVAILABLE
;
1476 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1479 /// Video display height (RO)
1480 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1483 if (!mpctx
->sh_video
)
1484 return M_PROPERTY_UNAVAILABLE
;
1485 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1489 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1492 if (!mpctx
->sh_video
)
1493 return M_PROPERTY_UNAVAILABLE
;
1494 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1497 /// Video aspect (RO)
1498 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1501 if (!mpctx
->sh_video
)
1502 return M_PROPERTY_UNAVAILABLE
;
1503 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1507 /// Text subtitle position (RW)
1508 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1512 case M_PROPERTY_SET
:
1514 return M_PROPERTY_ERROR
;
1515 case M_PROPERTY_STEP
:
1516 vo_osd_changed(OSDTYPE_SUBTITLE
);
1518 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1522 /// Selected subtitles (RW)
1523 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1526 struct MPOpts
*opts
= &mpctx
->opts
;
1527 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1528 int source
= -1, reset_spu av_unused
= 0; // used under CONFIG_DVDREAD
1529 int source_pos
= -1;
1531 update_global_sub_size(mpctx
);
1532 const int global_sub_size
= mpctx
->global_sub_size
;
1534 if (global_sub_size
<= 0)
1535 return M_PROPERTY_UNAVAILABLE
;
1538 case M_PROPERTY_GET
:
1540 return M_PROPERTY_ERROR
;
1541 *(int *) arg
= mpctx
->global_sub_pos
;
1542 return M_PROPERTY_OK
;
1543 case M_PROPERTY_PRINT
:
1545 return M_PROPERTY_ERROR
;
1546 char *sub_name
= NULL
;
1548 sub_name
= mpctx
->subdata
->filename
;
1549 if (sub_source(mpctx
) == SUB_SOURCE_SUBS
&& mpctx
->osd
->sh_sub
)
1550 sub_name
= mpctx
->osd
->sh_sub
->title
;
1551 if (!sub_name
&& mpctx
->subdata
)
1552 sub_name
= mpctx
->subdata
->filename
;
1554 const char *tmp
= mp_basename(sub_name
);
1556 *(char **) arg
= talloc_asprintf(NULL
, "(%d) %s%s",
1557 mpctx
->set_of_sub_pos
+ 1,
1558 strlen(tmp
) < 20 ? "" : "...",
1559 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1560 return M_PROPERTY_OK
;
1562 #ifdef CONFIG_DVDNAV
1563 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1564 if (vo_spudec
&& opts
->sub_id
>= 0) {
1565 unsigned char lang
[3];
1566 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
,
1568 *(char **) arg
= talloc_asprintf(NULL
, "(%d) %s",
1569 opts
->sub_id
, lang
);
1570 return M_PROPERTY_OK
;
1576 if ((d_sub
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1577 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF
1578 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1579 || d_sub
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1580 && d_sub
->sh
&& opts
->sub_id
>= 0) {
1581 struct sh_sub
*sh
= d_sub
->sh
;
1582 char *lang
= sh
->lang
? sh
->lang
: mp_gtext("unknown");
1584 *(char **)arg
= talloc_asprintf(NULL
, "(%d) %s (\"%s\")",
1585 opts
->sub_id
, lang
, sh
->title
);
1587 *(char **)arg
= talloc_asprintf(NULL
, "(%d) %s",
1588 opts
->sub_id
, lang
);
1589 return M_PROPERTY_OK
;
1592 if (vo_vobsub
&& vobsub_id
>= 0) {
1593 const char *language
= mp_gtext("unknown");
1594 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1595 *(char **) arg
= talloc_asprintf(NULL
, "(%d) %s",
1596 vobsub_id
, language
? language
: mp_gtext("unknown"));
1597 return M_PROPERTY_OK
;
1599 #ifdef CONFIG_DVDREAD
1600 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1601 && opts
->sub_id
>= 0) {
1603 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1604 lang
[0] = code
>> 8;
1607 *(char **) arg
= talloc_asprintf(NULL
, "(%d) %s",
1608 opts
->sub_id
, lang
);
1609 return M_PROPERTY_OK
;
1612 if (opts
->sub_id
>= 0) {
1613 *(char **) arg
= talloc_asprintf(NULL
, "(%d) %s", opts
->sub_id
,
1614 mp_gtext("unknown"));
1615 return M_PROPERTY_OK
;
1617 *(char **) arg
= talloc_strdup(NULL
, mp_gtext("disabled"));
1618 return M_PROPERTY_OK
;
1620 case M_PROPERTY_SET
:
1622 return M_PROPERTY_ERROR
;
1623 if (*(int *) arg
< -1)
1625 else if (*(int *) arg
>= global_sub_size
)
1626 *(int *) arg
= global_sub_size
- 1;
1627 mpctx
->global_sub_pos
= *(int *) arg
;
1629 case M_PROPERTY_STEP
:
1630 if (!arg
|| *(int *)arg
>= 0) {
1631 mpctx
->global_sub_pos
+= 2;
1632 mpctx
->global_sub_pos
=
1633 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1635 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1636 mpctx
->global_sub_pos
=
1637 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1641 return M_PROPERTY_NOT_IMPLEMENTED
;
1644 if (mpctx
->global_sub_pos
>= 0) {
1645 source
= sub_source(mpctx
);
1646 source_pos
= sub_source_pos(mpctx
);
1649 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1650 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1652 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1653 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1654 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1655 mpctx
->global_sub_pos
, source
);
1657 mpctx
->set_of_sub_pos
= -1;
1658 mpctx
->subdata
= NULL
;
1667 uninit_player(mpctx
, INITIALIZED_SUB
);
1669 if (source
== SUB_SOURCE_VOBSUB
)
1670 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1671 else if (source
== SUB_SOURCE_SUBS
) {
1672 mpctx
->set_of_sub_pos
= source_pos
;
1673 if (opts
->ass_enabled
1674 && mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
]) {
1675 sub_init(mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
],
1677 mpctx
->initialized_flags
|= INITIALIZED_SUB
;
1679 mpctx
->subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1680 vo_osd_changed(OSDTYPE_SUBTITLE
);
1681 } else if (source
== SUB_SOURCE_DEMUX
) {
1682 opts
->sub_id
= source_pos
;
1683 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1685 // default: assume 1:1 mapping of sid and stream id
1686 d_sub
->id
= opts
->sub_id
;
1687 d_sub
->sh
= mpctx
->d_sub
->demuxer
->s_streams
[d_sub
->id
];
1688 ds_free_packs(d_sub
);
1689 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1690 sh_sub_t
*sh
= mpctx
->d_sub
->demuxer
->s_streams
[i
];
1691 if (sh
&& sh
->sid
== opts
->sub_id
) {
1697 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1698 sh_sub_t
*sh
= d_sub
->sh
;
1699 if (sh
->type
== 'v')
1700 init_vo_spudec(mpctx
);
1702 sub_init(sh
, mpctx
->osd
);
1703 mpctx
->initialized_flags
|= INITIALIZED_SUB
;
1711 #ifdef CONFIG_DVDREAD
1713 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1714 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1715 && opts
->sub_id
< 0 && reset_spu
) {
1721 update_subtitles(mpctx
, 0, true);
1723 return M_PROPERTY_OK
;
1726 /// Selected sub source (RW)
1727 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1731 update_global_sub_size(mpctx
);
1732 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1733 return M_PROPERTY_UNAVAILABLE
;
1736 case M_PROPERTY_GET
:
1738 return M_PROPERTY_ERROR
;
1739 *(int *) arg
= sub_source(mpctx
);
1740 return M_PROPERTY_OK
;
1741 case M_PROPERTY_PRINT
:
1743 return M_PROPERTY_ERROR
;
1745 switch (sub_source(mpctx
)) {
1746 case SUB_SOURCE_SUBS
:
1747 sourcename
= mp_gtext("file");
1749 case SUB_SOURCE_VOBSUB
:
1750 sourcename
= mp_gtext("vobsub");
1752 case SUB_SOURCE_DEMUX
:
1753 sourcename
= mp_gtext("embedded");
1756 sourcename
= mp_gtext("disabled");
1758 *(char **)arg
= talloc_strdup(NULL
, sourcename
);
1759 return M_PROPERTY_OK
;
1760 case M_PROPERTY_SET
:
1762 return M_PROPERTY_ERROR
;
1763 M_PROPERTY_CLAMP(prop
, *(int *)arg
);
1764 if (*(int *) arg
< 0)
1765 mpctx
->global_sub_pos
= -1;
1766 else if (*(int *) arg
!= sub_source(mpctx
)) {
1767 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1769 return M_PROPERTY_UNAVAILABLE
;
1770 mpctx
->global_sub_pos
= new_pos
;
1773 case M_PROPERTY_STEP
: {
1774 int step_all
= (arg
&& *(int *)arg
!= 0 ? *(int *)arg
: 1);
1775 int step
= (step_all
> 0) ? 1 : -1;
1776 int cur_source
= sub_source(mpctx
);
1777 source
= cur_source
;
1780 if (source
>= SUB_SOURCES
)
1782 else if (source
< -1)
1783 source
= SUB_SOURCES
- 1;
1784 if (source
== cur_source
|| source
== -1 ||
1785 mpctx
->sub_counts
[source
])
1788 if (source
== cur_source
)
1789 return M_PROPERTY_OK
;
1791 mpctx
->global_sub_pos
= -1;
1793 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1797 return M_PROPERTY_NOT_IMPLEMENTED
;
1799 --mpctx
->global_sub_pos
;
1800 return mp_property_sub(prop
, M_PROPERTY_STEP
, NULL
, mpctx
);
1803 /// Selected subtitles from specific source (RW)
1804 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1807 int source
, is_cur_source
, offset
, new_pos
;
1808 update_global_sub_size(mpctx
);
1809 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1810 return M_PROPERTY_UNAVAILABLE
;
1812 if (!strcmp(prop
->name
, "sub_file"))
1813 source
= SUB_SOURCE_SUBS
;
1814 else if (!strcmp(prop
->name
, "sub_vob"))
1815 source
= SUB_SOURCE_VOBSUB
;
1816 else if (!strcmp(prop
->name
, "sub_demux"))
1817 source
= SUB_SOURCE_DEMUX
;
1819 return M_PROPERTY_ERROR
;
1821 offset
= sub_pos_by_source(mpctx
, source
);
1823 return M_PROPERTY_UNAVAILABLE
;
1825 is_cur_source
= sub_source(mpctx
) == source
;
1826 new_pos
= mpctx
->global_sub_pos
;
1828 case M_PROPERTY_GET
:
1830 return M_PROPERTY_ERROR
;
1831 if (is_cur_source
) {
1832 *(int *) arg
= sub_source_pos(mpctx
);
1833 if (source
== SUB_SOURCE_VOBSUB
)
1834 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1837 return M_PROPERTY_OK
;
1838 case M_PROPERTY_PRINT
:
1840 return M_PROPERTY_ERROR
;
1842 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1843 *(char **) arg
= talloc_strdup(NULL
, mp_gtext("disabled"));
1844 return M_PROPERTY_OK
;
1845 case M_PROPERTY_SET
:
1847 return M_PROPERTY_ERROR
;
1848 if (*(int *) arg
>= 0) {
1849 int index
= *(int *)arg
;
1850 if (source
== SUB_SOURCE_VOBSUB
)
1851 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1852 new_pos
= offset
+ index
;
1853 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1860 case M_PROPERTY_STEP
: {
1861 int step_all
= (arg
&& *(int *)arg
!= 0 ? *(int *)arg
: 1);
1862 int step
= (step_all
> 0) ? 1 : -1;
1863 int max_sub_pos_for_source
= -1;
1867 if (new_pos
== -1) {
1870 else if (max_sub_pos_for_source
== -1) {
1871 // Find max pos for specific source
1872 new_pos
= mpctx
->global_sub_size
- 1;
1873 while (new_pos
>= 0 && sub_source(mpctx
) != source
)
1876 new_pos
= max_sub_pos_for_source
;
1879 if (new_pos
< offset
||
1880 new_pos
>= mpctx
->global_sub_size
||
1881 sub_source(mpctx
) != source
)
1889 return M_PROPERTY_NOT_IMPLEMENTED
;
1891 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1894 /// Subtitle delay (RW)
1895 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1898 if (!mpctx
->sh_video
)
1899 return M_PROPERTY_UNAVAILABLE
;
1900 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1903 /// Alignment of text subtitles (RW)
1904 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1905 void *arg
, MPContext
*mpctx
)
1908 _("top"), _("center"), _("bottom")
1911 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1912 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1913 return M_PROPERTY_UNAVAILABLE
;
1916 case M_PROPERTY_PRINT
:
1918 return M_PROPERTY_ERROR
;
1919 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1920 *(char **) arg
= talloc_strdup(NULL
, mp_gtext(name
[sub_alignment
]));
1921 return M_PROPERTY_OK
;
1922 case M_PROPERTY_SET
:
1924 return M_PROPERTY_ERROR
;
1925 case M_PROPERTY_STEP
:
1926 vo_osd_changed(OSDTYPE_SUBTITLE
);
1928 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1932 /// Subtitle visibility (RW)
1933 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1934 void *arg
, MPContext
*mpctx
)
1936 struct MPOpts
*opts
= &mpctx
->opts
;
1938 if (!mpctx
->sh_video
)
1939 return M_PROPERTY_UNAVAILABLE
;
1942 case M_PROPERTY_SET
:
1944 return M_PROPERTY_ERROR
;
1945 case M_PROPERTY_STEP
:
1946 vo_osd_changed(OSDTYPE_SUBTITLE
);
1948 vo_osd_changed(OSDTYPE_SPU
);
1950 return m_property_flag(prop
, action
, arg
, &opts
->sub_visibility
);
1955 /// Use margins for libass subtitles (RW)
1956 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1957 void *arg
, MPContext
*mpctx
)
1959 struct MPOpts
*opts
= &mpctx
->opts
;
1960 if (!mpctx
->sh_video
)
1961 return M_PROPERTY_UNAVAILABLE
;
1964 case M_PROPERTY_SET
:
1966 return M_PROPERTY_ERROR
;
1967 case M_PROPERTY_STEP
:
1968 vo_osd_changed(OSDTYPE_SUBTITLE
);
1970 return m_property_flag(prop
, action
, arg
, &opts
->ass_use_margins
);
1974 static int mp_property_ass_vsfilter_aspect_compat(m_option_t
*prop
, int action
,
1975 void *arg
, MPContext
*mpctx
)
1977 if (!mpctx
->sh_video
)
1978 return M_PROPERTY_UNAVAILABLE
;
1981 case M_PROPERTY_SET
:
1983 return M_PROPERTY_ERROR
;
1984 case M_PROPERTY_STEP
:
1985 vo_osd_changed(OSDTYPE_SUBTITLE
);
1987 return m_property_flag(prop
, action
, arg
,
1988 &mpctx
->opts
.ass_vsfilter_aspect_compat
);
1994 /// Show only forced subtitles (RW)
1995 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1996 void *arg
, MPContext
*mpctx
)
1999 return M_PROPERTY_UNAVAILABLE
;
2002 case M_PROPERTY_SET
:
2004 return M_PROPERTY_ERROR
;
2005 case M_PROPERTY_STEP
:
2006 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
2007 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
2008 return M_PROPERTY_OK
;
2010 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
2015 /// Subtitle scale (RW)
2016 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
2019 struct MPOpts
*opts
= &mpctx
->opts
;
2022 case M_PROPERTY_SET
:
2024 return M_PROPERTY_ERROR
;
2025 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
2026 if (opts
->ass_enabled
)
2027 opts
->ass_font_scale
= *(float *) arg
;
2028 text_font_scale_factor
= *(float *) arg
;
2029 vo_osd_changed(OSDTYPE_SUBTITLE
);
2030 return M_PROPERTY_OK
;
2031 case M_PROPERTY_STEP
:
2032 if (opts
->ass_enabled
) {
2033 opts
->ass_font_scale
+= (arg
? *(float *) arg
: 0.1);
2034 M_PROPERTY_CLAMP(prop
, opts
->ass_font_scale
);
2036 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1);
2037 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2038 vo_osd_changed(OSDTYPE_SUBTITLE
);
2039 return M_PROPERTY_OK
;
2041 if (opts
->ass_enabled
)
2042 return m_property_float_ro(prop
, action
, arg
, opts
->ass_font_scale
);
2044 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2051 /// TV color settings (RW)
2052 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2056 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2057 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2058 return M_PROPERTY_UNAVAILABLE
;
2061 case M_PROPERTY_SET
:
2063 return M_PROPERTY_ERROR
;
2064 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2065 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2066 case M_PROPERTY_GET
:
2067 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2068 case M_PROPERTY_STEP
:
2069 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2071 return M_PROPERTY_ERROR
;
2072 val
+= (arg
? *(int *) arg
: 1);
2073 M_PROPERTY_CLAMP(prop
, val
);
2074 return tv_set_color_options(tvh
, prop
->offset
, val
);
2076 return M_PROPERTY_ERROR
;
2078 return M_PROPERTY_NOT_IMPLEMENTED
;
2083 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2087 int base_ioctl
= prop
->offset
;
2089 for teletext's GET,SET,STEP ioctls this is not 0
2093 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2094 return M_PROPERTY_UNAVAILABLE
;
2096 return M_PROPERTY_ERROR
;
2099 case M_PROPERTY_GET
:
2101 return M_PROPERTY_ERROR
;
2102 result
= teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2104 case M_PROPERTY_SET
:
2106 return M_PROPERTY_ERROR
;
2107 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2108 result
= teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+ 1,
2111 case M_PROPERTY_STEP
:
2112 result
= teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2113 val
+= (arg
? *(int *) arg
: 1);
2114 result
= teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+ 1,
2118 return M_PROPERTY_NOT_IMPLEMENTED
;
2121 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2124 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2130 //with tvh==NULL will fail too
2131 result
= mp_property_teletext_common(prop
, action
, arg
, mpctx
);
2132 if (result
!= M_PROPERTY_OK
)
2135 if (teletext_control(mpctx
->demuxer
->teletext
,
2136 prop
->offset
, &val
) == VBI_CONTROL_TRUE
&& val
)
2137 mp_input_set_section(mpctx
->input
, "teletext");
2139 mp_input_set_section(mpctx
->input
, "tv");
2140 return M_PROPERTY_OK
;
2143 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2148 if (!mpctx
->demuxer
->teletext
)
2149 return M_PROPERTY_UNAVAILABLE
;
2151 case M_PROPERTY_STEP
:
2152 //This should be handled separately
2153 val
= (arg
? *(int *) arg
: 1);
2154 result
= teletext_control(mpctx
->demuxer
->teletext
,
2155 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2158 result
= mp_property_teletext_common(prop
, action
, arg
, mpctx
);
2164 /// All properties available in MPlayer.
2165 /** \ingroup Properties
2167 static const m_option_t mp_properties
[] = {
2169 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2170 M_OPT_RANGE
, 0, 3, NULL
},
2171 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2172 M_OPT_MIN
, -1, 0, NULL
},
2173 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2174 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2175 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2177 { "path", mp_property_path
, CONF_TYPE_STRING
,
2179 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2181 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2182 M_OPT_MIN
, 0, 0, NULL
},
2183 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2184 M_OPT_MIN
, 0, 0, NULL
},
2185 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2186 M_OPT_MIN
, 0, 0, NULL
},
2187 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2188 M_OPT_MIN
, 0, 0, NULL
},
2189 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2190 M_OPT_MIN
, 0, 0, NULL
},
2191 { "length", mp_property_length
, CONF_TYPE_TIME
,
2192 M_OPT_MIN
, 0, 0, NULL
},
2193 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2194 M_OPT_RANGE
, 0, 100, NULL
},
2195 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2196 M_OPT_MIN
, 0, 0, NULL
},
2197 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2198 M_OPT_MIN
, 0, 0, NULL
},
2199 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2201 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2202 CONF_RANGE
, -2, 10, NULL
},
2203 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2205 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2206 M_OPT_RANGE
, 0, 1, NULL
},
2207 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2208 M_OPT_RANGE
, 0, 1, NULL
},
2209 { "pts_association_mode", mp_property_generic_option
, &m_option_type_choice
,
2210 0, 0, 0, "pts-association-mode" },
2211 { "hr_seek", mp_property_generic_option
, &m_option_type_choice
,
2212 0, 0, 0, "hr-seek" },
2215 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2216 M_OPT_RANGE
, 0, 100, NULL
},
2217 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2218 M_OPT_RANGE
, 0, 1, NULL
},
2219 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2220 M_OPT_RANGE
, -100, 100, NULL
},
2221 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2223 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2225 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2227 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2229 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2231 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2232 CONF_RANGE
, -2, 65535, NULL
},
2233 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2234 M_OPT_RANGE
, -1, 1, NULL
},
2237 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2238 M_OPT_RANGE
, 0, 1, NULL
},
2239 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2240 M_OPT_RANGE
, 0, 1, NULL
},
2241 { "colormatrix", mp_property_colormatrix
, &m_option_type_choice
,
2242 0, 0, 0, "colormatrix" },
2243 { "colormatrix_input_range", mp_property_colormatrix_input_range
, &m_option_type_choice
,
2244 0, 0, 0, "colormatrix-input-range" },
2245 { "colormatrix_output_range", mp_property_colormatrix_output_range
, &m_option_type_choice
,
2246 0, 0, 0, "colormatrix-output-range" },
2247 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2248 M_OPT_RANGE
, 0, 1, NULL
},
2249 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2250 M_OPT_RANGE
, 0, 1, NULL
},
2251 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2252 M_OPT_RANGE
, 0, 1, NULL
},
2253 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2254 M_OPT_RANGE
, 0, 2, NULL
},
2255 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2256 M_OPT_RANGE
, -100, 100, .offset
= offsetof(struct MPOpts
, vo_gamma_gamma
)},
2257 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2258 M_OPT_RANGE
, -100, 100, .offset
= offsetof(struct MPOpts
, vo_gamma_brightness
) },
2259 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2260 M_OPT_RANGE
, -100, 100, .offset
= offsetof(struct MPOpts
, vo_gamma_contrast
) },
2261 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2262 M_OPT_RANGE
, -100, 100, .offset
= offsetof(struct MPOpts
, vo_gamma_saturation
) },
2263 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2264 M_OPT_RANGE
, -100, 100, .offset
= offsetof(struct MPOpts
, vo_gamma_hue
) },
2265 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2266 M_OPT_RANGE
, 0, 1, NULL
},
2267 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2268 M_OPT_RANGE
, 0, 1, NULL
},
2269 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2271 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2273 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2275 { "width", mp_property_width
, CONF_TYPE_INT
,
2277 { "height", mp_property_height
, CONF_TYPE_INT
,
2279 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2281 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2283 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2284 CONF_RANGE
, -2, 65535, NULL
},
2285 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2286 CONF_RANGE
, -1, 65535, NULL
},
2289 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2290 M_OPT_MIN
, -1, 0, NULL
},
2291 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2292 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2293 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2294 M_OPT_MIN
, -1, 0, NULL
},
2295 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2296 M_OPT_MIN
, -1, 0, NULL
},
2297 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2298 M_OPT_MIN
, -1, 0, NULL
},
2299 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2301 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2302 M_OPT_RANGE
, 0, 100, NULL
},
2303 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2304 M_OPT_RANGE
, 0, 2, NULL
},
2305 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2306 M_OPT_RANGE
, 0, 1, NULL
},
2307 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2308 M_OPT_RANGE
, 0, 1, NULL
},
2309 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2310 M_OPT_RANGE
, 0, 100, NULL
},
2312 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2313 M_OPT_RANGE
, 0, 1, NULL
},
2314 { "ass_vsfilter_aspect_compat", mp_property_ass_vsfilter_aspect_compat
,
2315 CONF_TYPE_FLAG
, M_OPT_RANGE
, 0, 1, NULL
},
2319 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2320 M_OPT_RANGE
, -100, 100, .offset
= TV_COLOR_BRIGHTNESS
},
2321 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2322 M_OPT_RANGE
, -100, 100, .offset
= TV_COLOR_CONTRAST
},
2323 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2324 M_OPT_RANGE
, -100, 100, .offset
= TV_COLOR_SATURATION
},
2325 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2326 M_OPT_RANGE
, -100, 100, .offset
= TV_COLOR_HUE
},
2328 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2329 M_OPT_RANGE
, 100, 899, .offset
= TV_VBI_CONTROL_GET_PAGE
},
2330 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2331 M_OPT_RANGE
, 0, 64, .offset
= TV_VBI_CONTROL_GET_SUBPAGE
},
2332 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2333 M_OPT_RANGE
, 0, 1, .offset
= TV_VBI_CONTROL_GET_MODE
},
2334 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2335 M_OPT_RANGE
, 0, 3, .offset
= TV_VBI_CONTROL_GET_FORMAT
},
2336 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2337 M_OPT_RANGE
, 0, 2, .offset
= TV_VBI_CONTROL_GET_HALF_PAGE
},
2338 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2342 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2344 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2347 char *mp_property_print(const char *name
, void *ctx
)
2350 if (mp_property_do(name
, M_PROPERTY_PRINT
, &ret
, ctx
) <= 0)
2355 char *property_expand_string(MPContext
*mpctx
, char *str
)
2357 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2360 void property_print_help(void)
2362 m_properties_print_help_list(mp_properties
);
2366 /* List of default ways to show a property on OSD.
2368 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2369 * a bar showing the current position between min/max values of the
2370 * property. In this case osd_msg is only used for terminal output
2371 * if there is no video; it'll be a label shown together with percentage.
2373 * Otherwise setting osd_msg will show the string on OSD, formatted with
2374 * the text value of the property as argument.
2376 static struct property_osd_display
{
2379 /// progressbar type
2380 int osd_progbar
; // -1 is special value for seek indicators
2381 /// osd msg id if it must be shared
2383 /// osd msg template
2384 const char *osd_msg
;
2385 } property_osd_display
[] = {
2387 { "loop", 0, -1, _("Loop: %s") },
2388 { "chapter", -1, -1, NULL
},
2389 { "capturing", 0, -1, _("Capturing: %s") },
2390 { "pts_association_mode", 0, -1, "PTS association mode: %s" },
2391 { "hr_seek", 0, -1, "hr-seek: %s" },
2392 { "speed", 0, -1, _("Speed: x %6s") },
2394 { "volume", OSD_VOLUME
, -1, _("Volume") },
2395 { "mute", 0, -1, _("Mute: %s") },
2396 { "audio_delay", 0, -1, _("A-V delay: %s") },
2397 { "switch_audio", 0, -1, _("Audio: %s") },
2398 { "balance", OSD_BALANCE
, -1, _("Balance") },
2400 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2401 { "ontop", 0, -1, _("Stay on top: %s") },
2402 { "rootwin", 0, -1, _("Rootwin: %s") },
2403 { "border", 0, -1, _("Border: %s") },
2404 { "framedropping", 0, -1, _("Framedropping: %s") },
2405 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2406 { "colormatrix", 0, -1, _("YUV colormatrix: %s") },
2407 { "colormatrix_input_range", 0, -1, _("YUV input range: %s") },
2408 { "colormatrix_output_range", 0, -1, _("RGB output range: %s") },
2409 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2410 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2411 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2412 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2413 { "hue", OSD_HUE
, -1, _("Hue") },
2414 { "vsync", 0, -1, _("VSync: %s") },
2416 { "sub", 0, -1, _("Subtitles: %s") },
2417 { "sub_source", 0, -1, _("Sub source: %s") },
2418 { "sub_vob", 0, -1, _("Subtitles: %s") },
2419 { "sub_demux", 0, -1, _("Subtitles: %s") },
2420 { "sub_file", 0, -1, _("Subtitles: %s") },
2421 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2422 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2423 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2424 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2425 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2426 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2427 { "ass_vsfilter_aspect_compat", 0, -1,
2428 _("Subtitle VSFilter aspect compat: %s")},
2430 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2431 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2432 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2433 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2438 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2440 struct MPOpts
*opts
= &mpctx
->opts
;
2443 struct property_osd_display
*p
;
2445 // look for the command
2446 for (p
= property_osd_display
; p
->name
; p
++)
2447 if (!strcmp(p
->name
, pname
))
2453 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2456 if (p
->osd_progbar
== -1)
2457 mpctx
->add_osd_seek_info
= true;
2458 else if (p
->osd_progbar
) {
2459 if (prop
->type
== CONF_TYPE_INT
) {
2460 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2461 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2462 prop
->min
, prop
->max
, r
);
2463 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2465 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2466 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2467 prop
->min
, prop
->max
, f
);
2469 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2470 "Property use an unsupported type.\n");
2477 char *val
= mp_property_print(pname
, mpctx
);
2479 int index
= p
- property_osd_display
;
2480 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2481 1, opts
->osd_duration
, p
->osd_msg
, val
);
2490 * Command to property bridge
2492 * It is used to handle most commands that just set a property
2493 * and optionally display something on the OSD.
2494 * Two kinds of commands are handled: adjust or toggle.
2496 * Adjust commands take 1 or 2 parameters: <value> <abs>
2497 * If <abs> is non-zero the property is set to the given value
2498 * otherwise it is adjusted.
2500 * Toggle commands take 0 or 1 parameters. With no parameter
2501 * or a value less than the property minimum it just steps the
2502 * property to its next or previous value respectively.
2503 * Otherwise it sets it to the given value.
2506 /// List of the commands that can be handled by setting a property.
2512 /// set/adjust or toggle command
2514 } set_prop_cmd
[] = {
2516 { "loop", MP_CMD_LOOP
, 0},
2517 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2518 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2519 { "pause", MP_CMD_PAUSE
, 0},
2520 { "capturing", MP_CMD_CAPTURING
, 1},
2522 { "volume", MP_CMD_VOLUME
, 0},
2523 { "mute", MP_CMD_MUTE
, 1},
2524 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2525 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2526 { "balance", MP_CMD_BALANCE
, 0},
2528 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2529 { "panscan", MP_CMD_PANSCAN
, 0},
2530 { "ontop", MP_CMD_VO_ONTOP
, 1},
2531 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2532 { "border", MP_CMD_VO_BORDER
, 1},
2533 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2534 { "gamma", MP_CMD_GAMMA
, 0},
2535 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2536 { "contrast", MP_CMD_CONTRAST
, 0},
2537 { "saturation", MP_CMD_SATURATION
, 0},
2538 { "hue", MP_CMD_HUE
, 0},
2539 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2541 { "sub", MP_CMD_SUB_SELECT
, 1},
2542 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2543 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2544 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2545 { "sub_file", MP_CMD_SUB_FILE
, 1},
2546 { "sub_pos", MP_CMD_SUB_POS
, 0},
2547 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2548 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2549 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2550 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2551 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2553 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2556 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2557 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2558 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2559 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2564 /// Handle commands that set a property.
2565 static bool set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2571 // look for the command
2572 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2573 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2575 if (!(pname
= set_prop_cmd
[i
].name
))
2578 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2582 if (set_prop_cmd
[i
].toggle
) {
2584 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2585 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2590 r
= mp_property_do(pname
, M_PROPERTY_STEP
, &dir
, mpctx
);
2592 } else if (cmd
->args
[1].v
.i
) //set
2593 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2595 r
= mp_property_do(pname
, M_PROPERTY_STEP
, &cmd
->args
[0].v
, mpctx
);
2600 show_property_osd(mpctx
, pname
);
2605 #ifdef CONFIG_DVDNAV
2606 static const struct {
2608 const enum mp_command_type cmd
;
2609 } mp_dvdnav_bindings
[] = {
2610 { "up", MP_CMD_DVDNAV_UP
},
2611 { "down", MP_CMD_DVDNAV_DOWN
},
2612 { "left", MP_CMD_DVDNAV_LEFT
},
2613 { "right", MP_CMD_DVDNAV_RIGHT
},
2614 { "menu", MP_CMD_DVDNAV_MENU
},
2615 { "select", MP_CMD_DVDNAV_SELECT
},
2616 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2617 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2620 * keep old dvdnav sub-command options for a while in order not to
2621 * break slave-mode API too suddenly.
2623 { "1", MP_CMD_DVDNAV_UP
},
2624 { "2", MP_CMD_DVDNAV_DOWN
},
2625 { "3", MP_CMD_DVDNAV_LEFT
},
2626 { "4", MP_CMD_DVDNAV_RIGHT
},
2627 { "5", MP_CMD_DVDNAV_MENU
},
2628 { "6", MP_CMD_DVDNAV_SELECT
},
2629 { "7", MP_CMD_DVDNAV_PREVMENU
},
2630 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2635 static const char *property_error_string(int error_value
)
2637 switch (error_value
) {
2638 case M_PROPERTY_ERROR
:
2640 case M_PROPERTY_UNAVAILABLE
:
2641 return "PROPERTY_UNAVAILABLE";
2642 case M_PROPERTY_NOT_IMPLEMENTED
:
2643 return "NOT_IMPLEMENTED";
2644 case M_PROPERTY_UNKNOWN
:
2645 return "PROPERTY_UNKNOWN";
2646 case M_PROPERTY_DISABLED
:
2652 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2655 int end
= start
+ count
;
2656 int after
= mpctx
->set_of_sub_size
- end
;
2657 sub_data
**subs
= mpctx
->set_of_subtitles
;
2658 struct sh_sub
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2659 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2660 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2661 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2662 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2665 for (idx
= start
; idx
< end
; idx
++) {
2666 sub_data
*subd
= subs
[idx
];
2667 char *filename
= "";
2669 filename
= subd
->filename
;
2671 filename
= ass_tracks
[idx
]->title
;
2672 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2673 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2674 filename_recode(filename
));
2677 if (ass_tracks
[idx
]) {
2678 sub_switchoff(ass_tracks
[idx
], mpctx
->osd
);
2679 sub_uninit(ass_tracks
[idx
]);
2681 talloc_free(ass_tracks
[idx
]);
2682 ass_tracks
[idx
] = NULL
;
2685 mpctx
->global_sub_size
-= count
;
2686 mpctx
->set_of_sub_size
-= count
;
2687 if (mpctx
->set_of_sub_size
<= 0)
2688 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2690 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2691 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2692 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2693 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2695 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2696 mpctx
->global_sub_pos
= -2;
2697 mpctx
->subdata
= NULL
;
2698 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2699 } else if (mpctx
->set_of_sub_pos
>= end
) {
2700 mpctx
->set_of_sub_pos
-= count
;
2701 mpctx
->global_sub_pos
-= count
;
2705 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2707 struct MPOpts
*opts
= &mpctx
->opts
;
2708 sh_audio_t
*const sh_audio
= mpctx
->sh_audio
;
2709 sh_video_t
*const sh_video
= mpctx
->sh_video
;
2710 int osd_duration
= opts
->osd_duration
;
2711 int case_fallthrough_hack
= 0;
2712 if (set_property_command(mpctx
, cmd
))
2713 goto old_pause_hack
; // was handled already
2716 mpctx
->add_osd_seek_info
= true;
2717 float v
= cmd
->args
[0].v
.f
;
2718 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2719 int exact
= (cmd
->nargs
> 2) ? cmd
->args
[2].v
.i
: 0;
2720 if (abs
== 2) { // Absolute seek to a timestamp in seconds
2721 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, v
, exact
);
2722 mpctx
->osd_function
= v
> get_current_time(mpctx
) ?
2724 } else if (abs
) { /* Absolute seek by percentage */
2725 queue_seek(mpctx
, MPSEEK_FACTOR
, v
/ 100.0, exact
);
2726 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2728 queue_seek(mpctx
, MPSEEK_RELATIVE
, v
, exact
);
2729 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2734 case MP_CMD_SET_PROPERTY_OSD
:
2735 case_fallthrough_hack
= 1;
2737 case MP_CMD_SET_PROPERTY
: {
2738 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2739 cmd
->args
[1].v
.s
, mpctx
);
2740 if (r
== M_PROPERTY_UNKNOWN
)
2741 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2742 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2744 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2745 "Failed to set property '%s' to '%s'.\n",
2746 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2747 else if (case_fallthrough_hack
)
2748 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2750 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2751 "ANS_ERROR=%s\n", property_error_string(r
));
2755 case MP_CMD_STEP_PROPERTY_OSD
:
2756 case_fallthrough_hack
= 1;
2758 case MP_CMD_STEP_PROPERTY
: {
2763 if (cmd
->args
[1].v
.f
) {
2765 if ((r
= mp_property_do(cmd
->args
[0].v
.s
,
2766 M_PROPERTY_GET_TYPE
,
2767 &prop
, mpctx
)) <= 0)
2769 if (prop
->type
== CONF_TYPE_INT
||
2770 prop
->type
== CONF_TYPE_FLAG
)
2771 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2772 else if (prop
->type
== CONF_TYPE_FLOAT
)
2773 arg
= &cmd
->args
[1].v
.f
;
2774 else if (prop
->type
== CONF_TYPE_DOUBLE
||
2775 prop
->type
== CONF_TYPE_TIME
)
2776 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2777 else if (prop
->type
== CONF_TYPE_POSITION
)
2778 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2780 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2781 "Ignoring step size stepping property '%s'.\n",
2784 r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_STEP
,
2787 if (r
== M_PROPERTY_UNKNOWN
)
2788 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2789 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2791 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2792 "Failed to increment property '%s' by %f.\n",
2793 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2794 else if (case_fallthrough_hack
)
2795 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2797 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n",
2798 property_error_string(r
));
2802 case MP_CMD_GET_PROPERTY
: {
2804 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2807 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2808 "Failed to get value of property '%s'.\n",
2810 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n",
2811 property_error_string(r
));
2814 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2815 cmd
->args
[0].v
.s
, tmp
);
2820 case MP_CMD_EDL_MARK
:
2822 float v
= get_current_time(mpctx
);
2823 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2824 mpctx
->begin_skip
= v
;
2825 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
,
2826 "EDL skip start, press 'i' again to end block.\n");
2828 if (mpctx
->begin_skip
> v
)
2829 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
,
2830 "EDL skip canceled, last start > stop\n");
2832 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2833 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
,
2834 "EDL skip end, line written.\n");
2836 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2841 case MP_CMD_SWITCH_RATIO
:
2844 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2845 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2847 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2848 video_reset_aspect(sh_video
);
2851 case MP_CMD_SPEED_INCR
: {
2852 float v
= cmd
->args
[0].v
.f
;
2853 mp_property_do("speed", M_PROPERTY_STEP
, &v
, mpctx
);
2854 show_property_osd(mpctx
, "speed");
2858 case MP_CMD_SPEED_MULT
:
2859 case_fallthrough_hack
= true;
2861 case MP_CMD_SPEED_SET
: {
2862 float v
= cmd
->args
[0].v
.f
;
2863 if (case_fallthrough_hack
)
2864 v
*= mpctx
->opts
.playback_speed
;
2865 mp_property_do("speed", M_PROPERTY_SET
, &v
, mpctx
);
2866 show_property_osd(mpctx
, "speed");
2870 case MP_CMD_FRAME_STEP
:
2871 add_step_frame(mpctx
);
2875 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2876 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2878 case MP_CMD_PLAY_TREE_STEP
: {
2879 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2880 int force
= cmd
->args
[1].v
.i
;
2883 if (!force
&& mpctx
->playtree_iter
) {
2884 play_tree_iter_t
*i
=
2885 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2886 if (play_tree_iter_step(i
, n
, 0) ==
2887 PLAY_TREE_ITER_ENTRY
)
2889 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2890 play_tree_iter_free(i
);
2892 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2893 if (mpctx
->stop_play
)
2894 mpctx
->play_tree_step
= n
;
2899 case MP_CMD_PLAY_TREE_UP_STEP
: {
2900 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2901 int force
= cmd
->args
[1].v
.i
;
2903 if (!force
&& mpctx
->playtree_iter
) {
2904 play_tree_iter_t
*i
=
2905 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2906 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2907 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2908 play_tree_iter_free(i
);
2910 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2914 case MP_CMD_PLAY_ALT_SRC_STEP
:
2915 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2916 int v
= cmd
->args
[0].v
.i
;
2918 && mpctx
->playtree_iter
->file
<
2919 mpctx
->playtree_iter
->num_files
)
2920 mpctx
->stop_play
= PT_NEXT_SRC
;
2921 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2922 mpctx
->stop_play
= PT_PREV_SRC
;
2926 case MP_CMD_SUB_STEP
:
2928 int movement
= cmd
->args
[0].v
.i
;
2929 step_sub(mpctx
->subdata
, mpctx
->video_pts
, movement
);
2931 // currently not implemented with libass
2932 if (mpctx
->osd
->ass_track
)
2934 ass_step_sub(mpctx
->osd
->ass_track
,
2936 sub_delay
) * 1000 + .5, movement
) / 1000.;
2938 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2939 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2943 case MP_CMD_SUB_LOG
:
2948 int v
= cmd
->args
[0].v
.i
;
2949 int max
= (opts
->term_osd
2950 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2951 if (opts
->osd_level
> max
)
2952 opts
->osd_level
= max
;
2954 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2956 opts
->osd_level
= v
> max
? max
: v
;
2957 /* Show OSD state when disabled, but not when an explicit
2958 argument is given to the OSD command, i.e. in slave mode. */
2959 if (v
== -1 && opts
->osd_level
<= 1)
2960 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2962 opts
->osd_level
? mp_gtext("enabled") :
2963 mp_gtext("disabled"));
2965 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2969 case MP_CMD_OSD_SHOW_TEXT
:
2970 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2972 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2973 "%s", cmd
->args
[0].v
.s
);
2976 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
: {
2977 char *txt
= m_properties_expand_string(mp_properties
,
2980 // if no argument supplied use default osd_duration, else <arg> ms.
2982 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2984 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2991 case MP_CMD_LOADFILE
: {
2992 play_tree_t
*e
= play_tree_new();
2993 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2995 if (cmd
->args
[1].v
.i
) // append
2996 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2998 // Go back to the starting point.
2999 while (play_tree_iter_up_step(mpctx
->playtree_iter
, 0, 1)
3000 != PLAY_TREE_ITER_END
)
3002 play_tree_free_list(mpctx
->playtree
->child
, 1);
3003 play_tree_set_child(mpctx
->playtree
, e
);
3004 pt_iter_goto_head(mpctx
->playtree_iter
);
3005 mpctx
->stop_play
= PT_NEXT_SRC
;
3010 case MP_CMD_LOADLIST
: {
3011 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
,
3012 bstr(cmd
->args
[0].v
.s
));
3014 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
3015 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
3017 if (cmd
->args
[1].v
.i
) // append
3018 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3020 // Go back to the starting point.
3021 while (play_tree_iter_up_step(mpctx
->playtree_iter
, 0, 1)
3022 != PLAY_TREE_ITER_END
)
3024 play_tree_free_list(mpctx
->playtree
->child
, 1);
3025 play_tree_set_child(mpctx
->playtree
, e
);
3026 pt_iter_goto_head(mpctx
->playtree_iter
);
3027 mpctx
->stop_play
= PT_NEXT_SRC
;
3034 // Go back to the starting point.
3035 while (play_tree_iter_up_step(mpctx
->playtree_iter
, 0, 1) !=
3038 mpctx
->stop_play
= PT_STOP
;
3041 case MP_CMD_OSD_SHOW_PROGRESSION
: {
3042 set_osd_bar(mpctx
, 0, "Position", 0, 100, get_percent_pos(mpctx
));
3043 set_osd_progressmsg(OSD_MSG_TEXT
, 1, osd_duration
);
3048 case MP_CMD_RADIO_STEP_CHANNEL
:
3049 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3050 int v
= cmd
->args
[0].v
.i
;
3052 radio_step_channel(mpctx
->demuxer
->stream
,
3053 RADIO_CHANNEL_HIGHER
);
3055 radio_step_channel(mpctx
->demuxer
->stream
,
3056 RADIO_CHANNEL_LOWER
);
3057 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3058 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3060 radio_get_channel_name(mpctx
->demuxer
->stream
));
3065 case MP_CMD_RADIO_SET_CHANNEL
:
3066 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3067 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3068 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3069 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3071 radio_get_channel_name(mpctx
->demuxer
->stream
));
3076 case MP_CMD_RADIO_SET_FREQ
:
3077 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3078 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3081 case MP_CMD_RADIO_STEP_FREQ
:
3082 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3083 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3088 case MP_CMD_TV_START_SCAN
:
3089 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3090 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
), 1);
3092 case MP_CMD_TV_SET_FREQ
:
3093 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3094 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3095 cmd
->args
[0].v
.f
* 16.0);
3097 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3098 pvr_set_freq(mpctx
->stream
, ROUND(cmd
->args
[0].v
.f
));
3099 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3100 pvr_get_current_channelname(mpctx
->stream
),
3101 pvr_get_current_stationname(mpctx
->stream
));
3103 #endif /* CONFIG_PVR */
3106 case MP_CMD_TV_STEP_FREQ
:
3107 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3108 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3109 cmd
->args
[0].v
.f
* 16.0);
3111 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3112 pvr_force_freq_step(mpctx
->stream
, ROUND(cmd
->args
[0].v
.f
));
3113 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3114 pvr_get_current_channelname(mpctx
->stream
),
3115 pvr_get_current_frequency(mpctx
->stream
));
3117 #endif /* CONFIG_PVR */
3120 case MP_CMD_TV_SET_NORM
:
3121 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3122 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3126 case MP_CMD_TV_STEP_CHANNEL
:
3127 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3128 int v
= cmd
->args
[0].v
.i
;
3130 tv_step_channel((tvi_handle_t
*) (mpctx
->
3134 tv_step_channel((tvi_handle_t
*) (mpctx
->
3138 if (tv_channel_list
) {
3139 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3140 "Channel: %s", tv_channel_current
->name
);
3141 //vo_osd_changed(OSDTYPE_SUBTITLE);
3145 else if (mpctx
->stream
&&
3146 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3147 pvr_set_channel_step(mpctx
->stream
, cmd
->args
[0].v
.i
);
3148 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3149 pvr_get_current_channelname(mpctx
->stream
),
3150 pvr_get_current_stationname(mpctx
->stream
));
3152 #endif /* CONFIG_PVR */
3154 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3156 int v
= cmd
->args
[0].v
.i
;
3158 mpctx
->last_dvb_step
= v
;
3160 dir
= DVB_CHANNEL_HIGHER
;
3162 dir
= DVB_CHANNEL_LOWER
;
3165 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3166 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3167 mpctx
->dvbin_reopen
= 1;
3170 #endif /* CONFIG_DVBIN */
3173 case MP_CMD_TV_SET_CHANNEL
:
3174 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3175 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3177 if (tv_channel_list
) {
3178 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3179 "Channel: %s", tv_channel_current
->name
);
3180 //vo_osd_changed(OSDTYPE_SUBTITLE);
3184 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3185 pvr_set_channel(mpctx
->stream
, cmd
->args
[0].v
.s
);
3186 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3187 pvr_get_current_channelname(mpctx
->stream
),
3188 pvr_get_current_stationname(mpctx
->stream
));
3190 #endif /* CONFIG_PVR */
3194 case MP_CMD_DVB_SET_CHANNEL
:
3195 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3196 mpctx
->last_dvb_step
= 1;
3198 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3199 cmd
->args
[0].v
.i
)) {
3200 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3201 mpctx
->dvbin_reopen
= 1;
3205 #endif /* CONFIG_DVBIN */
3207 case MP_CMD_TV_LAST_CHANNEL
:
3208 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3209 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3210 if (tv_channel_list
) {
3211 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3212 "Channel: %s", tv_channel_current
->name
);
3213 //vo_osd_changed(OSDTYPE_SUBTITLE);
3217 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3218 pvr_set_lastchannel(mpctx
->stream
);
3219 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3220 pvr_get_current_channelname(mpctx
->stream
),
3221 pvr_get_current_stationname(mpctx
->stream
));
3223 #endif /* CONFIG_PVR */
3226 case MP_CMD_TV_STEP_NORM
:
3227 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3228 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3231 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3232 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3233 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3235 #endif /* CONFIG_TV */
3236 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3237 if (mpctx
->demuxer
->teletext
)
3238 teletext_control(mpctx
->demuxer
->teletext
, TV_VBI_CONTROL_ADD_DEC
,
3239 &(cmd
->args
[0].v
.s
));
3241 case MP_CMD_TV_TELETEXT_GO_LINK
:
3242 if (mpctx
->demuxer
->teletext
)
3243 teletext_control(mpctx
->demuxer
->teletext
, TV_VBI_CONTROL_GO_LINK
,
3244 &(cmd
->args
[0].v
.i
));
3247 case MP_CMD_SUB_LOAD
:
3249 int n
= mpctx
->set_of_sub_size
;
3250 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3251 if (n
!= mpctx
->set_of_sub_size
) {
3252 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3253 ++mpctx
->global_sub_size
;
3258 case MP_CMD_SUB_REMOVE
:
3260 int v
= cmd
->args
[0].v
.i
;
3262 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3263 else if (v
< mpctx
->set_of_sub_size
)
3264 remove_subtitle_range(mpctx
, v
, 1);
3268 case MP_CMD_GET_SUB_VISIBILITY
:
3270 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3271 "ANS_SUB_VISIBILITY=%d\n", opts
->sub_visibility
);
3275 case MP_CMD_SCREENSHOT
:
3276 screenshot_request(mpctx
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3279 case MP_CMD_VF_CHANGE_RECTANGLE
:
3282 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3285 case MP_CMD_GET_TIME_LENGTH
:
3286 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3287 get_time_length(mpctx
));
3290 case MP_CMD_GET_FILENAME
: {
3291 char *inf
= get_metadata(mpctx
, META_NAME
);
3292 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n", inf
);
3297 case MP_CMD_GET_VIDEO_CODEC
: {
3298 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3299 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3304 case MP_CMD_GET_VIDEO_BITRATE
: {
3305 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3306 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3311 case MP_CMD_GET_VIDEO_RESOLUTION
: {
3312 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3313 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3318 case MP_CMD_GET_AUDIO_CODEC
: {
3319 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3320 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3325 case MP_CMD_GET_AUDIO_BITRATE
: {
3326 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3327 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3332 case MP_CMD_GET_AUDIO_SAMPLES
: {
3333 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3334 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3339 case MP_CMD_GET_META_TITLE
: {
3340 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3341 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3346 case MP_CMD_GET_META_ARTIST
: {
3347 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3348 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3353 case MP_CMD_GET_META_ALBUM
: {
3354 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3355 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3360 case MP_CMD_GET_META_YEAR
: {
3361 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3362 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3367 case MP_CMD_GET_META_COMMENT
: {
3368 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3369 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3374 case MP_CMD_GET_META_TRACK
: {
3375 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3376 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3381 case MP_CMD_GET_META_GENRE
: {
3382 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3383 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3388 case MP_CMD_GET_VO_FULLSCREEN
:
3389 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3390 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3393 case MP_CMD_GET_PERCENT_POS
:
3394 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3395 get_percent_pos(mpctx
));
3398 case MP_CMD_GET_TIME_POS
: {
3399 float pos
= get_current_time(mpctx
);
3400 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3407 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3413 case MP_CMD_KEYDOWN_EVENTS
:
3414 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3417 case MP_CMD_SET_MOUSE_POS
: {
3418 int pointer_x
, pointer_y
;
3420 pointer_x
= cmd
->args
[0].v
.i
;
3421 pointer_y
= cmd
->args
[1].v
.i
;
3422 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3423 #ifdef CONFIG_DVDNAV
3424 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3425 && dx
> 0.0 && dy
> 0.0) {
3427 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3428 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3429 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3430 pointer_x
, pointer_y
, &button
);
3431 if (opts
->osd_level
> 1 && button
> 0)
3432 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3433 "Selected button number %d", button
);
3439 #ifdef CONFIG_DVDNAV
3440 case MP_CMD_DVDNAV
: {
3443 enum mp_command_type command
= 0;
3444 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3447 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3448 if (cmd
->args
[0].v
.s
&&
3449 !strcasecmp(cmd
->args
[0].v
.s
,
3450 mp_dvdnav_bindings
[i
].name
))
3451 command
= mp_dvdnav_bindings
[i
].cmd
;
3453 mp_dvdnav_handle_input(mpctx
->stream
, command
, &button
);
3454 if (opts
->osd_level
> 1 && button
> 0)
3455 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3456 "Selected button number %d", button
);
3460 case MP_CMD_SWITCH_TITLE
:
3461 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3462 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3467 case MP_CMD_AF_SWITCH
:
3469 af_uninit(mpctx
->mixer
.afilter
);
3470 af_init(mpctx
->mixer
.afilter
);
3473 case MP_CMD_AF_DEL
: {
3476 char *af_args
= strdup(cmd
->args
[0].v
.s
);
3477 char *af_commands
= af_args
;
3480 while ((af_command
= strsep(&af_commands
, ",")) != NULL
) {
3481 if (cmd
->id
== MP_CMD_AF_DEL
) {
3482 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3484 af_remove(mpctx
->mixer
.afilter
, af
);
3486 af_add(mpctx
->mixer
.afilter
, af_command
);
3488 reinit_audio_chain(mpctx
);
3495 af_uninit(mpctx
->mixer
.afilter
);
3496 af_init(mpctx
->mixer
.afilter
);
3497 reinit_audio_chain(mpctx
);
3499 case MP_CMD_AF_CMDLINE
:
3501 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3503 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3504 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3507 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3508 af_reinit(sh_audio
->afilter
, af
);
3513 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3514 "Received unknown cmd %s\n", cmd
->name
);
3518 switch (cmd
->pausing
) {
3519 case 1: // "pausing"
3520 pause_player(mpctx
);
3522 case 3: // "pausing_toggle"
3524 unpause_player(mpctx
);
3526 pause_player(mpctx
);