8 #include "input/input.h"
9 #include "stream/stream.h"
10 #include "libmpdemux/demuxer.h"
11 #include "libmpdemux/stheader.h"
12 #include "codec-cfg.h"
14 #include "libvo/sub.h"
16 #include "m_property.h"
19 #include "libmpcodecs/vf.h"
20 #include "libmpcodecs/vd.h"
22 #include "libvo/video_out.h"
23 #include "libvo/font_load.h"
25 #include "libao2/audio_out.h"
28 #include "libmpcodecs/dec_video.h"
33 #include "stream/tv.h"
36 #include "stream/stream_radio.h"
39 #include "stream/pvr.h"
41 #ifdef HAS_DVBIN_SUPPORT
42 #include "stream/dvbin.h"
45 #include "stream/stream_dvd.h"
48 #include "stream/stream_dvdnav.h"
51 #include "libass/ass.h"
52 #include "libass/ass_mp.h"
56 #include "libmenu/menu.h"
59 #include "gui/interface.h"
64 #include "libavutil/avstring.h"
66 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
70 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
71 double *dx
, double *dy
)
73 struct MPOpts
*opts
= &mpctx
->opts
;
74 struct vo
*vo
= mpctx
->video_out
;
75 //remove the borders, if any, and rescale to the range [0,1],[0,1]
76 if (vo_fs
) { //we are in full-screen mode
77 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
78 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
79 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
80 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
82 if (ix
< 0 || ix
> vo
->dwidth
) {
85 } //we are on one of the borders
86 if (iy
< 0 || iy
> vo
->dheight
) {
89 } //we are on one of the borders
92 *dx
= (double) ix
/ (double) vo
->dwidth
;
93 *dy
= (double) iy
/ (double) vo
->dheight
;
95 mp_msg(MSGT_CPLAYER
, MSGL_V
,
96 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
97 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
101 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
106 for (i
= 0; i
< SUB_SOURCES
; i
++) {
107 int j
= mpctx
->global_sub_indices
[i
];
108 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
116 static int sub_source(MPContext
*mpctx
)
118 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
122 * \brief Log the currently displayed subtitle to a file
124 * Logs the current or last displayed subtitle together with filename
125 * and time information to ~/.mplayer/subtitle_log
127 * Intended purpose is to allow convenient marking of bogus subtitles
128 * which need to be fixed while watching the movie.
131 static void log_sub(struct MPContext
*mpctx
)
137 if (subdata
== NULL
|| vo_sub_last
== NULL
)
139 fname
= get_path("subtitle_log");
140 f
= fopen(fname
, "a");
143 fprintf(f
, "----------------------------------------------------------\n");
144 if (subdata
->sub_uses_time
) {
146 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
147 mpctx
->filename
, vo_sub_last
->start
/ 360000,
148 (vo_sub_last
->start
/ 6000) % 60,
149 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
150 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
151 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
153 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
154 vo_sub_last
->start
, vo_sub_last
->end
);
156 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
157 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
163 /// \defgroup Properties
166 /// \defgroup GeneralProperties General properties
167 /// \ingroup Properties
171 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
174 return m_property_choice(prop
, action
, arg
, &osd_level
);
178 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
181 struct MPOpts
*opts
= &mpctx
->opts
;
183 case M_PROPERTY_PRINT
:
184 if (!arg
) return M_PROPERTY_ERROR
;
185 if (opts
->loop_times
< 0)
186 *(char**)arg
= strdup("off");
187 else if (opts
->loop_times
== 0)
188 *(char**)arg
= strdup("inf");
191 return M_PROPERTY_OK
;
193 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
196 /// Playback speed (RW)
197 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
198 void *arg
, MPContext
*mpctx
)
200 struct MPOpts
*opts
= &mpctx
->opts
;
204 return M_PROPERTY_ERROR
;
205 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
206 opts
->playback_speed
= *(float *) arg
;
207 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
208 return M_PROPERTY_OK
;
209 case M_PROPERTY_STEP_UP
:
210 case M_PROPERTY_STEP_DOWN
:
211 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
212 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
213 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
214 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
215 return M_PROPERTY_OK
;
217 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
220 /// filename with path (RO)
221 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
224 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
227 /// filename without path (RO)
228 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
232 if (!mpctx
->filename
)
233 return M_PROPERTY_UNAVAILABLE
;
234 if (((f
= strrchr(mpctx
->filename
, '/'))
235 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
239 return m_property_string_ro(prop
, action
, arg
, f
);
242 /// Demuxer name (RO)
243 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
247 return M_PROPERTY_UNAVAILABLE
;
248 return m_property_string_ro(prop
, action
, arg
,
249 (char *) mpctx
->demuxer
->desc
->name
);
252 /// Position in the stream (RW)
253 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
256 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
257 return M_PROPERTY_UNAVAILABLE
;
259 return M_PROPERTY_ERROR
;
262 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
263 return M_PROPERTY_OK
;
265 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
266 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
267 return M_PROPERTY_OK
;
269 return M_PROPERTY_NOT_IMPLEMENTED
;
272 /// Stream start offset (RO)
273 static int mp_property_stream_start(m_option_t
*prop
, int action
,
274 void *arg
, MPContext
*mpctx
)
276 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
277 return M_PROPERTY_UNAVAILABLE
;
280 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
281 return M_PROPERTY_OK
;
283 return M_PROPERTY_NOT_IMPLEMENTED
;
286 /// Stream end offset (RO)
287 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
290 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
291 return M_PROPERTY_UNAVAILABLE
;
294 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
295 return M_PROPERTY_OK
;
297 return M_PROPERTY_NOT_IMPLEMENTED
;
300 /// Stream length (RO)
301 static int mp_property_stream_length(m_option_t
*prop
, int action
,
302 void *arg
, MPContext
*mpctx
)
304 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
305 return M_PROPERTY_UNAVAILABLE
;
309 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
310 return M_PROPERTY_OK
;
312 return M_PROPERTY_NOT_IMPLEMENTED
;
315 /// Media length in seconds (RO)
316 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
321 if (!mpctx
->demuxer
||
322 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
323 return M_PROPERTY_UNAVAILABLE
;
325 return m_property_time_ro(prop
, action
, arg
, len
);
328 /// Current position in percent (RW)
329 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
330 void *arg
, MPContext
*mpctx
) {
334 return M_PROPERTY_UNAVAILABLE
;
338 if(!arg
) return M_PROPERTY_ERROR
;
339 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
342 case M_PROPERTY_STEP_UP
:
343 case M_PROPERTY_STEP_DOWN
:
344 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
345 pos
+= (arg
? *(int*)arg
: 10) *
346 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
347 M_PROPERTY_CLAMP(prop
, pos
);
350 return m_property_int_ro(prop
, action
, arg
,
351 demuxer_get_percent_pos(mpctx
->demuxer
));
354 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
355 mpctx
->rel_seek_secs
= pos
/ 100.0;
356 return M_PROPERTY_OK
;
359 /// Current position in seconds (RW)
360 static int mp_property_time_pos(m_option_t
*prop
, int action
,
361 void *arg
, MPContext
*mpctx
) {
362 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
363 return M_PROPERTY_UNAVAILABLE
;
367 if(!arg
) return M_PROPERTY_ERROR
;
368 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
369 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
370 mpctx
->rel_seek_secs
= *(double*)arg
;
371 return M_PROPERTY_OK
;
372 case M_PROPERTY_STEP_UP
:
373 case M_PROPERTY_STEP_DOWN
:
374 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
375 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
376 return M_PROPERTY_OK
;
378 return m_property_time_ro(prop
, action
, arg
,
379 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
380 playing_audio_pts(mpctx
));
383 /// Current chapter (RW)
384 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
391 char *chapter_name
= NULL
;
393 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
395 return M_PROPERTY_UNAVAILABLE
;
400 return M_PROPERTY_ERROR
;
401 *(int *) arg
= chapter
;
402 return M_PROPERTY_OK
;
403 case M_PROPERTY_PRINT
: {
405 return M_PROPERTY_ERROR
;
406 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
408 return M_PROPERTY_UNAVAILABLE
;
409 *(char **) arg
= chapter_name
;
410 return M_PROPERTY_OK
;
414 return M_PROPERTY_ERROR
;
415 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
416 step_all
= *(int *)arg
- (chapter
+ 1);
419 case M_PROPERTY_STEP_UP
:
420 case M_PROPERTY_STEP_DOWN
: {
421 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
422 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
429 return M_PROPERTY_NOT_IMPLEMENTED
;
431 mpctx
->rel_seek_secs
= 0;
432 mpctx
->abs_seek_pos
= 0;
433 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
434 &next_pts
, &chapter_num
, &chapter_name
);
436 if (next_pts
> -1.0) {
437 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
438 mpctx
->rel_seek_secs
= next_pts
;
441 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
442 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
444 else if (step_all
> 0)
445 mpctx
->rel_seek_secs
= 1000000000.;
447 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
448 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
451 return M_PROPERTY_OK
;
454 /// Current dvd angle (RW)
455 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
460 char *angle_name
= NULL
;
462 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
464 return M_PROPERTY_UNAVAILABLE
;
465 angles
= demuxer_angles_count(mpctx
->demuxer
);
467 return M_PROPERTY_UNAVAILABLE
;
472 return M_PROPERTY_ERROR
;
473 *(int *) arg
= angle
;
474 return M_PROPERTY_OK
;
475 case M_PROPERTY_PRINT
: {
477 return M_PROPERTY_ERROR
;
478 angle_name
= calloc(1, 64);
480 return M_PROPERTY_UNAVAILABLE
;
481 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
482 *(char **) arg
= angle_name
;
483 return M_PROPERTY_OK
;
487 return M_PROPERTY_ERROR
;
489 M_PROPERTY_CLAMP(prop
, angle
);
491 case M_PROPERTY_STEP_UP
:
492 case M_PROPERTY_STEP_DOWN
: {
498 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
500 if (angle
< 1) //cycle
505 return M_PROPERTY_NOT_IMPLEMENTED
;
507 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
508 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
509 MSGTR_OSDAngle
, angle
, angles
);
512 return M_PROPERTY_OK
;
515 /// Demuxer meta data
516 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
518 m_property_action_t
* ka
;
520 static const m_option_t key_type
=
521 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
523 return M_PROPERTY_UNAVAILABLE
;
527 if(!arg
) return M_PROPERTY_ERROR
;
528 *(char***)arg
= mpctx
->demuxer
->info
;
529 return M_PROPERTY_OK
;
530 case M_PROPERTY_KEY_ACTION
:
531 if(!arg
) return M_PROPERTY_ERROR
;
533 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
534 return M_PROPERTY_UNKNOWN
;
537 if(!ka
->arg
) return M_PROPERTY_ERROR
;
538 *(char**)ka
->arg
= meta
;
539 return M_PROPERTY_OK
;
540 case M_PROPERTY_GET_TYPE
:
541 if(!ka
->arg
) return M_PROPERTY_ERROR
;
542 *(m_option_t
**)ka
->arg
= &key_type
;
543 return M_PROPERTY_OK
;
546 return M_PROPERTY_NOT_IMPLEMENTED
;
552 /// \defgroup AudioProperties Audio properties
553 /// \ingroup Properties
557 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
561 if (!mpctx
->sh_audio
)
562 return M_PROPERTY_UNAVAILABLE
;
567 return M_PROPERTY_ERROR
;
568 mixer_getbothvolume(&mpctx
->mixer
, arg
);
569 return M_PROPERTY_OK
;
570 case M_PROPERTY_PRINT
:{
573 return M_PROPERTY_ERROR
;
574 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
575 return m_property_float_range(prop
, action
, arg
, &vol
);
577 case M_PROPERTY_STEP_UP
:
578 case M_PROPERTY_STEP_DOWN
:
582 return M_PROPERTY_NOT_IMPLEMENTED
;
585 if (mpctx
->edl_muted
)
586 return M_PROPERTY_DISABLED
;
587 mpctx
->user_muted
= 0;
592 return M_PROPERTY_ERROR
;
593 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
594 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
595 return M_PROPERTY_OK
;
596 case M_PROPERTY_STEP_UP
:
597 if (arg
&& *(float *) arg
<= 0)
598 mixer_decvolume(&mpctx
->mixer
);
600 mixer_incvolume(&mpctx
->mixer
);
601 return M_PROPERTY_OK
;
602 case M_PROPERTY_STEP_DOWN
:
603 if (arg
&& *(float *) arg
<= 0)
604 mixer_incvolume(&mpctx
->mixer
);
606 mixer_decvolume(&mpctx
->mixer
);
607 return M_PROPERTY_OK
;
609 return M_PROPERTY_NOT_IMPLEMENTED
;
613 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
617 if (!mpctx
->sh_audio
)
618 return M_PROPERTY_UNAVAILABLE
;
622 if (mpctx
->edl_muted
)
623 return M_PROPERTY_DISABLED
;
625 return M_PROPERTY_ERROR
;
626 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
627 mixer_mute(&mpctx
->mixer
);
628 mpctx
->user_muted
= mpctx
->mixer
.muted
;
629 return M_PROPERTY_OK
;
630 case M_PROPERTY_STEP_UP
:
631 case M_PROPERTY_STEP_DOWN
:
632 if (mpctx
->edl_muted
)
633 return M_PROPERTY_DISABLED
;
634 mixer_mute(&mpctx
->mixer
);
635 mpctx
->user_muted
= mpctx
->mixer
.muted
;
636 return M_PROPERTY_OK
;
637 case M_PROPERTY_PRINT
:
639 return M_PROPERTY_ERROR
;
640 if (mpctx
->edl_muted
) {
641 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
642 return M_PROPERTY_OK
;
645 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
651 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
652 void *arg
, MPContext
*mpctx
)
654 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
655 return M_PROPERTY_UNAVAILABLE
;
658 case M_PROPERTY_STEP_UP
:
659 case M_PROPERTY_STEP_DOWN
: {
661 float delay
= audio_delay
;
662 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
663 if (ret
!= M_PROPERTY_OK
)
666 mpctx
->delay
-= audio_delay
- delay
;
668 return M_PROPERTY_OK
;
670 return m_property_delay(prop
, action
, arg
, &audio_delay
);
674 /// Audio codec tag (RO)
675 static int mp_property_audio_format(m_option_t
*prop
, int action
,
676 void *arg
, MPContext
*mpctx
)
678 if (!mpctx
->sh_audio
)
679 return M_PROPERTY_UNAVAILABLE
;
680 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
683 /// Audio codec name (RO)
684 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
685 void *arg
, MPContext
*mpctx
)
687 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
688 return M_PROPERTY_UNAVAILABLE
;
689 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
692 /// Audio bitrate (RO)
693 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
694 void *arg
, MPContext
*mpctx
)
696 if (!mpctx
->sh_audio
)
697 return M_PROPERTY_UNAVAILABLE
;
698 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
702 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
705 if (!mpctx
->sh_audio
)
706 return M_PROPERTY_UNAVAILABLE
;
708 case M_PROPERTY_PRINT
:
709 if(!arg
) return M_PROPERTY_ERROR
;
710 *(char**)arg
= malloc(16);
711 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
712 return M_PROPERTY_OK
;
714 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
717 /// Number of channels (RO)
718 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
721 if (!mpctx
->sh_audio
)
722 return M_PROPERTY_UNAVAILABLE
;
724 case M_PROPERTY_PRINT
:
726 return M_PROPERTY_ERROR
;
727 switch (mpctx
->sh_audio
->channels
) {
729 *(char **) arg
= strdup("mono");
732 *(char **) arg
= strdup("stereo");
735 *(char **) arg
= malloc(32);
736 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
738 return M_PROPERTY_OK
;
740 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
744 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
749 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
750 return M_PROPERTY_UNAVAILABLE
;
755 return M_PROPERTY_ERROR
;
756 mixer_getbalance(&mpctx
->mixer
, arg
);
757 return M_PROPERTY_OK
;
758 case M_PROPERTY_PRINT
: {
761 return M_PROPERTY_ERROR
;
762 mixer_getbalance(&mpctx
->mixer
, &bal
);
764 *str
= strdup("center");
765 else if (bal
== -1.f
)
766 *str
= strdup("left only");
768 *str
= strdup("right only");
770 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
771 *str
= malloc(sizeof("left xxx%, right xxx%"));
772 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
774 return M_PROPERTY_OK
;
776 case M_PROPERTY_STEP_UP
:
777 case M_PROPERTY_STEP_DOWN
:
778 mixer_getbalance(&mpctx
->mixer
, &bal
);
779 bal
+= (arg
? *(float*)arg
: .1f
) *
780 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
781 M_PROPERTY_CLAMP(prop
, bal
);
782 mixer_setbalance(&mpctx
->mixer
, bal
);
783 return M_PROPERTY_OK
;
786 return M_PROPERTY_ERROR
;
787 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
788 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
789 return M_PROPERTY_OK
;
791 return M_PROPERTY_NOT_IMPLEMENTED
;
794 /// Selected audio id (RW)
795 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
798 struct MPOpts
*opts
= &mpctx
->opts
;
799 int current_id
= -1, tmp
;
803 if (!mpctx
->sh_audio
)
804 return M_PROPERTY_UNAVAILABLE
;
806 return M_PROPERTY_ERROR
;
807 *(int *) arg
= opts
->audio_id
;
808 return M_PROPERTY_OK
;
809 case M_PROPERTY_PRINT
:
810 if (!mpctx
->sh_audio
)
811 return M_PROPERTY_UNAVAILABLE
;
813 return M_PROPERTY_ERROR
;
815 if (opts
->audio_id
< 0)
816 *(char **) arg
= strdup(MSGTR_Disabled
);
818 char lang
[40] = MSGTR_Unknown
;
819 sh_audio_t
* sh
= mpctx
->sh_audio
;
821 av_strlcpy(lang
, sh
->lang
, 40);
822 #ifdef CONFIG_DVDREAD
823 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
824 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
834 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
835 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
837 *(char **) arg
= malloc(64);
838 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
840 return M_PROPERTY_OK
;
842 case M_PROPERTY_STEP_UP
:
844 if (action
== M_PROPERTY_SET
&& arg
)
845 tmp
= *((int *) arg
);
848 current_id
= mpctx
->demuxer
->audio
->id
;
849 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
850 if (opts
->audio_id
== -2
851 || (opts
->audio_id
> -1
852 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
853 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
854 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
856 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
858 sh2
->ds
= mpctx
->demuxer
->audio
;
859 mpctx
->sh_audio
= sh2
;
860 reinit_audio_chain(mpctx
);
863 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
864 return M_PROPERTY_OK
;
866 return M_PROPERTY_NOT_IMPLEMENTED
;
871 /// Selected video id (RW)
872 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
875 struct MPOpts
*opts
= &mpctx
->opts
;
876 int current_id
= -1, tmp
;
880 if (!mpctx
->sh_video
)
881 return M_PROPERTY_UNAVAILABLE
;
883 return M_PROPERTY_ERROR
;
884 *(int *) arg
= opts
->video_id
;
885 return M_PROPERTY_OK
;
886 case M_PROPERTY_PRINT
:
887 if (!mpctx
->sh_video
)
888 return M_PROPERTY_UNAVAILABLE
;
890 return M_PROPERTY_ERROR
;
892 if (opts
->video_id
< 0)
893 *(char **) arg
= strdup(MSGTR_Disabled
);
895 char lang
[40] = MSGTR_Unknown
;
896 *(char **) arg
= malloc(64);
897 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
899 return M_PROPERTY_OK
;
901 case M_PROPERTY_STEP_UP
:
903 current_id
= mpctx
->demuxer
->video
->id
;
904 if (action
== M_PROPERTY_SET
&& arg
)
905 tmp
= *((int *) arg
);
908 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
909 if (opts
->video_id
== -2
910 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
911 && current_id
!= -2))
912 uninit_player(mpctx
, INITIALIZED_VCODEC
|
913 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
914 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
916 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
918 sh2
->ds
= mpctx
->demuxer
->video
;
919 mpctx
->sh_video
= sh2
;
920 reinit_video_chain(mpctx
);
923 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
924 return M_PROPERTY_OK
;
927 return M_PROPERTY_NOT_IMPLEMENTED
;
931 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
934 demux_program_t prog
;
937 case M_PROPERTY_STEP_UP
:
939 if (action
== M_PROPERTY_SET
&& arg
)
940 prog
.progid
= *((int *) arg
);
944 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
945 &prog
) == DEMUXER_CTRL_NOTIMPL
)
946 return M_PROPERTY_ERROR
;
948 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
949 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
950 return M_PROPERTY_OK
;
953 return M_PROPERTY_NOT_IMPLEMENTED
;
959 /// \defgroup VideoProperties Video properties
960 /// \ingroup Properties
963 /// Fullscreen state (RW)
964 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
968 if (!mpctx
->video_out
)
969 return M_PROPERTY_UNAVAILABLE
;
974 return M_PROPERTY_ERROR
;
975 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
976 if (vo_fs
== !!*(int *) arg
)
977 return M_PROPERTY_OK
;
978 case M_PROPERTY_STEP_UP
:
979 case M_PROPERTY_STEP_DOWN
:
982 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
985 if (mpctx
->video_out
->config_ok
)
986 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
987 return M_PROPERTY_OK
;
989 return m_property_flag(prop
, action
, arg
, &vo_fs
);
993 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
994 void *arg
, MPContext
*mpctx
)
998 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
999 return M_PROPERTY_UNAVAILABLE
;
1000 vf
= mpctx
->sh_video
->vfilter
;
1002 case M_PROPERTY_GET
:
1004 return M_PROPERTY_ERROR
;
1005 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1006 return M_PROPERTY_OK
;
1007 case M_PROPERTY_SET
:
1009 return M_PROPERTY_ERROR
;
1010 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1011 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1012 return M_PROPERTY_OK
;
1013 case M_PROPERTY_STEP_UP
:
1014 case M_PROPERTY_STEP_DOWN
:
1015 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1016 deinterlace
= !deinterlace
;
1017 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1018 return M_PROPERTY_OK
;
1020 return M_PROPERTY_NOT_IMPLEMENTED
;
1024 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1028 if (!mpctx
->video_out
1029 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1030 return M_PROPERTY_UNAVAILABLE
;
1033 case M_PROPERTY_SET
:
1035 return M_PROPERTY_ERROR
;
1036 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1037 vo_panscan
= *(float *) arg
;
1038 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1039 return M_PROPERTY_OK
;
1040 case M_PROPERTY_STEP_UP
:
1041 case M_PROPERTY_STEP_DOWN
:
1042 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1043 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1046 else if (vo_panscan
< 0)
1048 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1049 return M_PROPERTY_OK
;
1051 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1055 /// Helper to set vo flags.
1056 /** \ingroup PropertyImplHelper
1058 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1059 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1062 if (!mpctx
->video_out
)
1063 return M_PROPERTY_UNAVAILABLE
;
1066 case M_PROPERTY_SET
:
1068 return M_PROPERTY_ERROR
;
1069 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1070 if (*vo_var
== !!*(int *) arg
)
1071 return M_PROPERTY_OK
;
1072 case M_PROPERTY_STEP_UP
:
1073 case M_PROPERTY_STEP_DOWN
:
1074 if (mpctx
->video_out
->config_ok
)
1075 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1076 return M_PROPERTY_OK
;
1078 return m_property_flag(prop
, action
, arg
, vo_var
);
1082 /// Window always on top (RW)
1083 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1086 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1087 &mpctx
->opts
.vo_ontop
, mpctx
);
1090 /// Display in the root window (RW)
1091 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1094 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1095 &vo_rootwin
, mpctx
);
1098 /// Show window borders (RW)
1099 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1102 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1106 /// Framedropping state (RW)
1107 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1108 void *arg
, MPContext
*mpctx
)
1111 if (!mpctx
->sh_video
)
1112 return M_PROPERTY_UNAVAILABLE
;
1115 case M_PROPERTY_PRINT
:
1117 return M_PROPERTY_ERROR
;
1118 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1119 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1121 return M_PROPERTY_OK
;
1123 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1127 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1128 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1131 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1134 if (!mpctx
->sh_video
)
1135 return M_PROPERTY_UNAVAILABLE
;
1137 if (gamma
[0] == 1000) {
1139 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1143 case M_PROPERTY_SET
:
1145 return M_PROPERTY_ERROR
;
1146 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1147 *gamma
= *(int *) arg
;
1148 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1152 case M_PROPERTY_GET
:
1153 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1155 return M_PROPERTY_ERROR
;
1157 return M_PROPERTY_OK
;
1160 case M_PROPERTY_STEP_UP
:
1161 case M_PROPERTY_STEP_DOWN
:
1162 *gamma
+= (arg
? *(int *) arg
: 1) *
1163 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1164 M_PROPERTY_CLAMP(prop
, *gamma
);
1165 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1170 return M_PROPERTY_NOT_IMPLEMENTED
;
1174 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1175 int l
= strlen(prop
->name
);
1176 char tv_prop
[3 + l
+ 1];
1177 sprintf(tv_prop
, "tv_%s", prop
->name
);
1178 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1182 return M_PROPERTY_UNAVAILABLE
;
1186 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1189 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1192 /// Video codec tag (RO)
1193 static int mp_property_video_format(m_option_t
*prop
, int action
,
1194 void *arg
, MPContext
*mpctx
)
1197 if (!mpctx
->sh_video
)
1198 return M_PROPERTY_UNAVAILABLE
;
1200 case M_PROPERTY_PRINT
:
1202 return M_PROPERTY_ERROR
;
1203 switch(mpctx
->sh_video
->format
) {
1205 meta
= strdup ("mpeg1"); break;
1207 meta
= strdup ("mpeg2"); break;
1209 meta
= strdup ("mpeg4"); break;
1211 meta
= strdup ("h264"); break;
1213 if(mpctx
->sh_video
->format
>= 0x20202020) {
1215 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1218 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1221 *(char**)arg
= meta
;
1222 return M_PROPERTY_OK
;
1224 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1227 /// Video codec name (RO)
1228 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1229 void *arg
, MPContext
*mpctx
)
1231 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1232 return M_PROPERTY_UNAVAILABLE
;
1233 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1237 /// Video bitrate (RO)
1238 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1239 void *arg
, MPContext
*mpctx
)
1241 if (!mpctx
->sh_video
)
1242 return M_PROPERTY_UNAVAILABLE
;
1243 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1246 /// Video display width (RO)
1247 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1250 if (!mpctx
->sh_video
)
1251 return M_PROPERTY_UNAVAILABLE
;
1252 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1255 /// Video display height (RO)
1256 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1259 if (!mpctx
->sh_video
)
1260 return M_PROPERTY_UNAVAILABLE
;
1261 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1265 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1268 if (!mpctx
->sh_video
)
1269 return M_PROPERTY_UNAVAILABLE
;
1270 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1273 /// Video aspect (RO)
1274 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1277 if (!mpctx
->sh_video
)
1278 return M_PROPERTY_UNAVAILABLE
;
1279 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1284 /// \defgroup SubProprties Subtitles properties
1285 /// \ingroup Properties
1288 /// Text subtitle position (RW)
1289 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1292 if (!mpctx
->sh_video
)
1293 return M_PROPERTY_UNAVAILABLE
;
1296 case M_PROPERTY_SET
:
1298 return M_PROPERTY_ERROR
;
1299 case M_PROPERTY_STEP_UP
:
1300 case M_PROPERTY_STEP_DOWN
:
1301 vo_osd_changed(OSDTYPE_SUBTITLE
);
1303 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1307 /// Selected subtitles (RW)
1308 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1311 struct MPOpts
*opts
= &mpctx
->opts
;
1312 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1313 const int global_sub_size
= mpctx
->global_sub_size
;
1314 int source
= -1, reset_spu
= 0;
1317 if (global_sub_size
<= 0)
1318 return M_PROPERTY_UNAVAILABLE
;
1321 case M_PROPERTY_GET
:
1323 return M_PROPERTY_ERROR
;
1324 *(int *) arg
= mpctx
->global_sub_pos
;
1325 return M_PROPERTY_OK
;
1326 case M_PROPERTY_PRINT
:
1328 return M_PROPERTY_ERROR
;
1329 *(char **) arg
= malloc(64);
1330 (*(char **) arg
)[63] = 0;
1333 sub_name
= subdata
->filename
;
1335 if (ass_track
&& ass_track
->name
)
1336 sub_name
= ass_track
->name
;
1341 if ((tmp2
= strrchr(tmp
, '/')))
1344 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1345 mpctx
->set_of_sub_pos
+ 1,
1346 strlen(tmp
) < 20 ? "" : "...",
1347 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1348 return M_PROPERTY_OK
;
1350 #ifdef CONFIG_DVDNAV
1351 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1352 if (vo_spudec
&& opts
->sub_id
>= 0) {
1353 unsigned char lang
[3];
1354 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1355 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1356 return M_PROPERTY_OK
;
1362 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1363 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1364 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1365 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1366 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1367 if (!lang
) lang
= MSGTR_Unknown
;
1368 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1369 return M_PROPERTY_OK
;
1372 if (vo_vobsub
&& vobsub_id
>= 0) {
1373 const char *language
= MSGTR_Unknown
;
1374 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1375 snprintf(*(char **) arg
, 63, "(%d) %s",
1376 vobsub_id
, language
? language
: MSGTR_Unknown
);
1377 return M_PROPERTY_OK
;
1379 #ifdef CONFIG_DVDREAD
1380 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1381 && opts
->sub_id
>= 0) {
1383 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1384 lang
[0] = code
>> 8;
1387 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1388 return M_PROPERTY_OK
;
1391 if (opts
->sub_id
>= 0) {
1392 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, MSGTR_Unknown
);
1393 return M_PROPERTY_OK
;
1395 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1396 return M_PROPERTY_OK
;
1398 case M_PROPERTY_SET
:
1400 return M_PROPERTY_ERROR
;
1401 if (*(int *) arg
< -1)
1403 else if (*(int *) arg
>= global_sub_size
)
1404 *(int *) arg
= global_sub_size
- 1;
1405 mpctx
->global_sub_pos
= *(int *) arg
;
1407 case M_PROPERTY_STEP_UP
:
1408 mpctx
->global_sub_pos
+= 2;
1409 mpctx
->global_sub_pos
=
1410 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1412 case M_PROPERTY_STEP_DOWN
:
1413 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1414 mpctx
->global_sub_pos
=
1415 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1418 return M_PROPERTY_NOT_IMPLEMENTED
;
1421 if (mpctx
->global_sub_pos
>= 0)
1422 source
= sub_source(mpctx
);
1424 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1425 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1427 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1428 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1429 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1430 mpctx
->global_sub_pos
, source
);
1432 mpctx
->set_of_sub_pos
= -1;
1446 if (source
== SUB_SOURCE_VOBSUB
) {
1447 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1448 } else if (source
== SUB_SOURCE_SUBS
) {
1449 mpctx
->set_of_sub_pos
=
1450 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1452 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1453 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1457 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1458 vo_osd_changed(OSDTYPE_SUBTITLE
);
1460 } else if (source
== SUB_SOURCE_DEMUX
) {
1462 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1463 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1465 // default: assume 1:1 mapping of sid and stream id
1466 d_sub
->id
= opts
->sub_id
;
1467 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1468 ds_free_packs(d_sub
);
1469 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1470 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1471 if (sh
&& sh
->sid
== opts
->sub_id
) {
1477 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1478 sh_sub_t
*sh
= d_sub
->sh
;
1479 if (sh
->type
== 'v')
1480 init_vo_spudec(mpctx
);
1482 else if (ass_enabled
)
1483 ass_track
= sh
->ass_track
;
1491 #ifdef CONFIG_DVDREAD
1493 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1494 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1495 && opts
->sub_id
< 0 && reset_spu
) {
1497 d_sub
->id
= opts
->sub_id
;
1500 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1502 return M_PROPERTY_OK
;
1505 /// Selected sub source (RW)
1506 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1510 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1511 return M_PROPERTY_UNAVAILABLE
;
1514 case M_PROPERTY_GET
:
1516 return M_PROPERTY_ERROR
;
1517 *(int *) arg
= sub_source(mpctx
);
1518 return M_PROPERTY_OK
;
1519 case M_PROPERTY_PRINT
:
1521 return M_PROPERTY_ERROR
;
1522 *(char **) arg
= malloc(64);
1523 (*(char **) arg
)[63] = 0;
1524 switch (sub_source(mpctx
))
1526 case SUB_SOURCE_SUBS
:
1527 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1529 case SUB_SOURCE_VOBSUB
:
1530 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1532 case SUB_SOURCE_DEMUX
:
1533 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1536 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1538 return M_PROPERTY_OK
;
1539 case M_PROPERTY_SET
:
1541 return M_PROPERTY_ERROR
;
1542 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1543 if (*(int *) arg
< 0)
1544 mpctx
->global_sub_pos
= -1;
1545 else if (*(int *) arg
!= sub_source(mpctx
)) {
1546 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1547 return M_PROPERTY_UNAVAILABLE
;
1548 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1551 case M_PROPERTY_STEP_UP
:
1552 case M_PROPERTY_STEP_DOWN
: {
1553 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1554 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1555 int step
= (step_all
> 0) ? 1 : -1;
1556 int cur_source
= sub_source(mpctx
);
1557 source
= cur_source
;
1560 if (source
>= SUB_SOURCES
)
1562 else if (source
< -1)
1563 source
= SUB_SOURCES
- 1;
1564 if (source
== cur_source
|| source
== -1 ||
1565 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1568 if (source
== cur_source
)
1569 return M_PROPERTY_OK
;
1571 mpctx
->global_sub_pos
= -1;
1573 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1577 return M_PROPERTY_NOT_IMPLEMENTED
;
1579 --mpctx
->global_sub_pos
;
1580 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1583 /// Selected subtitles from specific source (RW)
1584 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1587 int source
, is_cur_source
, offset
;
1588 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1589 return M_PROPERTY_UNAVAILABLE
;
1591 if (!strcmp(prop
->name
, "sub_file"))
1592 source
= SUB_SOURCE_SUBS
;
1593 else if (!strcmp(prop
->name
, "sub_vob"))
1594 source
= SUB_SOURCE_VOBSUB
;
1595 else if (!strcmp(prop
->name
, "sub_demux"))
1596 source
= SUB_SOURCE_DEMUX
;
1598 return M_PROPERTY_ERROR
;
1600 offset
= mpctx
->global_sub_indices
[source
];
1601 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1602 return M_PROPERTY_UNAVAILABLE
;
1604 is_cur_source
= sub_source(mpctx
) == source
;
1606 case M_PROPERTY_GET
:
1608 return M_PROPERTY_ERROR
;
1609 if (is_cur_source
) {
1610 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1611 if (source
== SUB_SOURCE_VOBSUB
)
1612 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1616 return M_PROPERTY_OK
;
1617 case M_PROPERTY_PRINT
:
1619 return M_PROPERTY_ERROR
;
1621 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1622 *(char **) arg
= malloc(64);
1623 (*(char **) arg
)[63] = 0;
1624 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1625 return M_PROPERTY_OK
;
1626 case M_PROPERTY_SET
:
1628 return M_PROPERTY_ERROR
;
1629 if (*(int *) arg
>= 0) {
1630 int index
= *(int *)arg
;
1631 if (source
== SUB_SOURCE_VOBSUB
)
1632 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1633 mpctx
->global_sub_pos
= offset
+ index
;
1634 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1635 || sub_source(mpctx
) != source
) {
1636 mpctx
->global_sub_pos
= -1;
1641 mpctx
->global_sub_pos
= -1;
1643 case M_PROPERTY_STEP_UP
:
1644 case M_PROPERTY_STEP_DOWN
: {
1645 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1646 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1647 int step
= (step_all
> 0) ? 1 : -1;
1648 int max_sub_pos_for_source
= -1;
1650 mpctx
->global_sub_pos
= -1;
1652 if (mpctx
->global_sub_pos
== -1) {
1654 mpctx
->global_sub_pos
= offset
;
1655 else if (max_sub_pos_for_source
== -1) {
1656 // Find max pos for specific source
1657 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1658 while (mpctx
->global_sub_pos
>= 0
1659 && sub_source(mpctx
) != source
)
1660 --mpctx
->global_sub_pos
;
1663 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1666 mpctx
->global_sub_pos
+= step
;
1667 if (mpctx
->global_sub_pos
< offset
||
1668 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1669 sub_source(mpctx
) != source
)
1670 mpctx
->global_sub_pos
= -1;
1677 return M_PROPERTY_NOT_IMPLEMENTED
;
1679 --mpctx
->global_sub_pos
;
1680 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1683 /// Subtitle delay (RW)
1684 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1687 if (!mpctx
->sh_video
)
1688 return M_PROPERTY_UNAVAILABLE
;
1689 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1692 /// Alignment of text subtitles (RW)
1693 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1694 void *arg
, MPContext
*mpctx
)
1696 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1698 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1699 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1700 return M_PROPERTY_UNAVAILABLE
;
1703 case M_PROPERTY_PRINT
:
1705 return M_PROPERTY_ERROR
;
1706 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1707 *(char **) arg
= strdup(name
[sub_alignment
]);
1708 return M_PROPERTY_OK
;
1709 case M_PROPERTY_SET
:
1711 return M_PROPERTY_ERROR
;
1712 case M_PROPERTY_STEP_UP
:
1713 case M_PROPERTY_STEP_DOWN
:
1714 vo_osd_changed(OSDTYPE_SUBTITLE
);
1716 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1720 /// Subtitle visibility (RW)
1721 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1722 void *arg
, MPContext
*mpctx
)
1724 if (!mpctx
->sh_video
)
1725 return M_PROPERTY_UNAVAILABLE
;
1728 case M_PROPERTY_SET
:
1730 return M_PROPERTY_ERROR
;
1731 case M_PROPERTY_STEP_UP
:
1732 case M_PROPERTY_STEP_DOWN
:
1733 vo_osd_changed(OSDTYPE_SUBTITLE
);
1735 vo_osd_changed(OSDTYPE_SPU
);
1737 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1742 /// Use margins for libass subtitles (RW)
1743 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1744 void *arg
, MPContext
*mpctx
)
1746 if (!mpctx
->sh_video
)
1747 return M_PROPERTY_UNAVAILABLE
;
1750 case M_PROPERTY_SET
:
1752 return M_PROPERTY_ERROR
;
1753 case M_PROPERTY_STEP_UP
:
1754 case M_PROPERTY_STEP_DOWN
:
1755 ass_force_reload
= 1;
1757 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1762 /// Show only forced subtitles (RW)
1763 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1764 void *arg
, MPContext
*mpctx
)
1767 return M_PROPERTY_UNAVAILABLE
;
1770 case M_PROPERTY_SET
:
1772 return M_PROPERTY_ERROR
;
1773 case M_PROPERTY_STEP_UP
:
1774 case M_PROPERTY_STEP_DOWN
:
1775 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1776 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1777 return M_PROPERTY_OK
;
1779 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1784 #ifdef HAVE_FREETYPE
1785 /// Subtitle scale (RW)
1786 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1791 case M_PROPERTY_SET
:
1793 return M_PROPERTY_ERROR
;
1794 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1797 ass_font_scale
= *(float *) arg
;
1798 ass_force_reload
= 1;
1801 text_font_scale_factor
= *(float *) arg
;
1802 force_load_font
= 1;
1803 return M_PROPERTY_OK
;
1804 case M_PROPERTY_STEP_UP
:
1805 case M_PROPERTY_STEP_DOWN
:
1808 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1809 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1810 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1811 ass_force_reload
= 1;
1814 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1815 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1816 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1817 force_load_font
= 1;
1818 return M_PROPERTY_OK
;
1822 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1825 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1832 /// \defgroup TVProperties TV properties
1833 /// \ingroup Properties
1838 /// TV color settings (RW)
1839 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1843 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1844 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1845 return M_PROPERTY_UNAVAILABLE
;
1848 case M_PROPERTY_SET
:
1850 return M_PROPERTY_ERROR
;
1851 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1852 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1853 case M_PROPERTY_GET
:
1854 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1855 case M_PROPERTY_STEP_UP
:
1856 case M_PROPERTY_STEP_DOWN
:
1857 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1859 return M_PROPERTY_ERROR
;
1860 val
+= (arg
? *(int *) arg
: 1) *
1861 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1862 M_PROPERTY_CLAMP(prop
, val
);
1863 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1865 return M_PROPERTY_ERROR
;
1867 return M_PROPERTY_NOT_IMPLEMENTED
;
1872 #ifdef HAVE_TV_TELETEXT
1873 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1877 int base_ioctl
=(int)prop
->priv
;
1879 for teletext's GET,SET,STEP ioctls this is not 0
1883 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1884 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1885 return M_PROPERTY_UNAVAILABLE
;
1887 return M_PROPERTY_ERROR
;
1890 case M_PROPERTY_GET
:
1892 return M_PROPERTY_ERROR
;
1893 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1895 case M_PROPERTY_SET
:
1897 return M_PROPERTY_ERROR
;
1898 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1899 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1901 case M_PROPERTY_STEP_UP
:
1902 case M_PROPERTY_STEP_DOWN
:
1903 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1904 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1905 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1908 return M_PROPERTY_NOT_IMPLEMENTED
;
1911 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1914 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1917 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1921 //with tvh==NULL will fail too
1922 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1923 if(result
!=M_PROPERTY_OK
)
1926 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1927 mp_input_set_section(mpctx
->input
, "teletext");
1929 mp_input_set_section(mpctx
->input
, "tv");
1930 return M_PROPERTY_OK
;
1933 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1936 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1940 case M_PROPERTY_STEP_UP
:
1941 case M_PROPERTY_STEP_DOWN
:
1942 //This should be handled separately
1943 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1944 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1947 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1953 #endif /* HAVE_TV_TELETEXT */
1957 /// All properties available in MPlayer.
1958 /** \ingroup Properties
1960 static const m_option_t mp_properties
[] = {
1962 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1963 M_OPT_RANGE
, 0, 3, NULL
},
1964 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1965 M_OPT_MIN
, -1, 0, NULL
},
1966 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1967 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1968 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1970 { "path", mp_property_path
, CONF_TYPE_STRING
,
1972 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1974 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1975 M_OPT_MIN
, 0, 0, NULL
},
1976 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1977 M_OPT_MIN
, 0, 0, NULL
},
1978 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1979 M_OPT_MIN
, 0, 0, NULL
},
1980 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1981 M_OPT_MIN
, 0, 0, NULL
},
1982 { "length", mp_property_length
, CONF_TYPE_TIME
,
1983 M_OPT_MIN
, 0, 0, NULL
},
1984 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1985 M_OPT_RANGE
, 0, 100, NULL
},
1986 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1987 M_OPT_MIN
, 0, 0, NULL
},
1988 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1989 M_OPT_MIN
, 1, 0, NULL
},
1990 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1991 CONF_RANGE
, -2, 10, NULL
},
1992 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1996 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1997 M_OPT_RANGE
, 0, 100, NULL
},
1998 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1999 M_OPT_RANGE
, 0, 1, NULL
},
2000 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2001 M_OPT_RANGE
, -100, 100, NULL
},
2002 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2004 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2006 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2008 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2010 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2012 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2013 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2014 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2015 M_OPT_RANGE
, -1, 1, NULL
},
2018 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2019 M_OPT_RANGE
, 0, 1, NULL
},
2020 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2021 M_OPT_RANGE
, 0, 1, NULL
},
2022 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2023 M_OPT_RANGE
, 0, 1, NULL
},
2024 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2025 M_OPT_RANGE
, 0, 1, NULL
},
2026 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2027 M_OPT_RANGE
, 0, 1, NULL
},
2028 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2029 M_OPT_RANGE
, 0, 2, NULL
},
2030 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2031 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2032 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2033 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2034 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2035 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2036 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2037 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2038 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2039 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2040 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2041 M_OPT_RANGE
, 0, 1, NULL
},
2042 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2043 M_OPT_RANGE
, 0, 1, NULL
},
2044 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2046 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2048 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2050 { "width", mp_property_width
, CONF_TYPE_INT
,
2052 { "height", mp_property_height
, CONF_TYPE_INT
,
2054 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2056 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2058 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2059 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2060 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2061 CONF_RANGE
, -1, 65535, NULL
},
2064 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2065 M_OPT_MIN
, -1, 0, NULL
},
2066 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2067 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2068 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2069 M_OPT_MIN
, -1, 0, NULL
},
2070 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2071 M_OPT_MIN
, -1, 0, NULL
},
2072 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2073 M_OPT_MIN
, -1, 0, NULL
},
2074 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2076 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2077 M_OPT_RANGE
, 0, 100, NULL
},
2078 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, 0, 2, NULL
},
2080 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2081 M_OPT_RANGE
, 0, 1, NULL
},
2082 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2083 M_OPT_RANGE
, 0, 1, NULL
},
2084 #ifdef HAVE_FREETYPE
2085 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2086 M_OPT_RANGE
, 0, 100, NULL
},
2089 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2090 M_OPT_RANGE
, 0, 1, NULL
},
2094 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2095 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2096 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2097 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2098 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2099 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2100 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2101 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2104 #ifdef HAVE_TV_TELETEXT
2105 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2106 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2107 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2108 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2109 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2110 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2111 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2112 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2113 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2114 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2117 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2121 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2123 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2126 char* mp_property_print(const char *name
, void* ctx
)
2129 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2134 char *property_expand_string(MPContext
*mpctx
, char *str
)
2136 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2139 void property_print_help(void)
2141 m_properties_print_help_list(mp_properties
);
2150 * \defgroup Command2Property Command to property bridge
2152 * It is used to handle most commands that just set a property
2153 * and optionally display something on the OSD.
2154 * Two kinds of commands are handled: adjust or toggle.
2156 * Adjust commands take 1 or 2 parameters: <value> <abs>
2157 * If <abs> is non-zero the property is set to the given value
2158 * otherwise it is adjusted.
2160 * Toggle commands take 0 or 1 parameters. With no parameter
2161 * or a value less than the property minimum it just steps the
2162 * property to its next value. Otherwise it sets it to the given
2168 /// List of the commands that can be handled by setting a property.
2174 /// set/adjust or toggle command
2176 /// progressbar type
2178 /// osd msg id if it must be shared
2180 /// osd msg template
2181 const char *osd_msg
;
2182 } set_prop_cmd
[] = {
2184 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2185 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2186 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2188 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2189 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2190 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2191 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2192 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2194 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2195 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2196 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2197 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2198 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2199 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2200 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2201 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2202 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2203 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2204 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2205 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2207 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2208 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2209 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2210 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2211 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2212 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2213 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2214 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2215 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2216 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2217 #ifdef HAVE_FREETYPE
2218 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2221 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2224 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2225 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2226 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2227 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2229 { NULL
, 0, 0, 0, -1, NULL
}
2233 /// Handle commands that set a property.
2234 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2240 // look for the command
2241 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2242 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2244 if (!(pname
= set_prop_cmd
[i
].name
))
2247 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2251 if (set_prop_cmd
[i
].toggle
) {
2253 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2254 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2256 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2257 } else if (cmd
->args
[1].v
.i
) //set
2258 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2260 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2265 if (set_prop_cmd
[i
].osd_progbar
) {
2266 if (prop
->type
== CONF_TYPE_INT
) {
2267 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2268 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2269 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2270 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2272 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2273 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2274 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2276 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2277 "Property use an unsupported type.\n");
2281 if (set_prop_cmd
[i
].osd_msg
) {
2282 char *val
= mp_property_print(pname
, mpctx
);
2284 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2285 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2286 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2293 #ifdef CONFIG_DVDNAV
2294 static const struct {
2296 const mp_command_type cmd
;
2297 } mp_dvdnav_bindings
[] = {
2298 { "up", MP_CMD_DVDNAV_UP
},
2299 { "down", MP_CMD_DVDNAV_DOWN
},
2300 { "left", MP_CMD_DVDNAV_LEFT
},
2301 { "right", MP_CMD_DVDNAV_RIGHT
},
2302 { "menu", MP_CMD_DVDNAV_MENU
},
2303 { "select", MP_CMD_DVDNAV_SELECT
},
2304 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2305 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2308 * keep old dvdnav sub-command options for a while in order not to
2309 * break slave-mode API too suddenly.
2311 { "1", MP_CMD_DVDNAV_UP
},
2312 { "2", MP_CMD_DVDNAV_DOWN
},
2313 { "3", MP_CMD_DVDNAV_LEFT
},
2314 { "4", MP_CMD_DVDNAV_RIGHT
},
2315 { "5", MP_CMD_DVDNAV_MENU
},
2316 { "6", MP_CMD_DVDNAV_SELECT
},
2317 { "7", MP_CMD_DVDNAV_PREVMENU
},
2318 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2323 int run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2325 struct MPOpts
*opts
= &mpctx
->opts
;
2326 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2327 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2329 if (!set_property_command(mpctx
, cmd
))
2335 mpctx
->osd_show_percentage
= sh_video
->fps
;
2336 v
= cmd
->args
[0].v
.f
;
2337 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2338 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2339 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2341 mpctx
->osd_function
=
2342 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2343 mpctx
->rel_seek_secs
= v
;
2344 } else if (abs
) { /* Absolute seek by percentage */
2345 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2347 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2348 mpctx
->rel_seek_secs
= v
/ 100.0;
2350 mpctx
->rel_seek_secs
+= v
;
2351 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2357 case MP_CMD_SET_PROPERTY
:{
2358 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2359 cmd
->args
[1].v
.s
, mpctx
);
2360 if (r
== M_PROPERTY_UNKNOWN
)
2361 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2362 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2364 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2365 "Failed to set property '%s' to '%s'.\n",
2366 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2370 case MP_CMD_STEP_PROPERTY
:{
2375 if (cmd
->args
[1].v
.f
) {
2377 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2378 M_PROPERTY_GET_TYPE
,
2379 &prop
, mpctx
)) <= 0)
2381 if(prop
->type
== CONF_TYPE_INT
||
2382 prop
->type
== CONF_TYPE_FLAG
)
2383 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2384 else if(prop
->type
== CONF_TYPE_FLOAT
)
2385 arg
= &cmd
->args
[1].v
.f
;
2386 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2387 prop
->type
== CONF_TYPE_TIME
)
2388 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2389 else if(prop
->type
== CONF_TYPE_POSITION
)
2390 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2392 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2393 "Ignoring step size stepping property '%s'.\n",
2396 r
= mp_property_do(cmd
->args
[0].v
.s
,
2397 cmd
->args
[2].v
.i
< 0 ?
2398 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2401 if (r
== M_PROPERTY_UNKNOWN
)
2402 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2403 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2405 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2406 "Failed to increment property '%s' by %f.\n",
2407 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2411 case MP_CMD_GET_PROPERTY
:{
2413 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2414 &tmp
, mpctx
) <= 0) {
2415 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2416 "Failed to get value of property '%s'.\n",
2420 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2421 cmd
->args
[0].v
.s
, tmp
);
2426 case MP_CMD_EDL_MARK
:
2428 float v
= sh_video
? sh_video
->pts
:
2429 playing_audio_pts(mpctx
);
2430 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2431 mpctx
->begin_skip
= v
;
2432 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2434 if (mpctx
->begin_skip
> v
)
2435 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2437 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2438 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2440 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2445 case MP_CMD_SWITCH_RATIO
:
2446 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2447 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2449 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2450 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2453 case MP_CMD_SPEED_INCR
:{
2454 float v
= cmd
->args
[0].v
.f
;
2455 opts
->playback_speed
+= v
;
2456 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2457 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2458 opts
->playback_speed
);
2461 case MP_CMD_SPEED_MULT
:{
2462 float v
= cmd
->args
[0].v
.f
;
2463 opts
->playback_speed
*= v
;
2464 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2465 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2466 opts
->playback_speed
);
2469 case MP_CMD_SPEED_SET
:{
2470 float v
= cmd
->args
[0].v
.f
;
2471 opts
->playback_speed
= v
;
2472 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2473 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2474 opts
->playback_speed
);
2477 case MP_CMD_FRAME_STEP
:
2483 case MP_CMD_FILE_FILTER
:
2484 file_filter
= cmd
->args
[0].v
.i
;
2488 exit_player_with_rc(mpctx
, MSGTR_Exit_quit
,
2489 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2491 case MP_CMD_PLAY_TREE_STEP
:{
2492 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2493 int force
= cmd
->args
[1].v
.i
;
2499 for (i
= 0; i
< n
; i
++)
2502 for (i
= 0; i
< -1 * n
; i
++)
2507 if (!force
&& mpctx
->playtree_iter
) {
2508 play_tree_iter_t
*i
=
2509 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2510 if (play_tree_iter_step(i
, n
, 0) ==
2511 PLAY_TREE_ITER_ENTRY
)
2513 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2514 play_tree_iter_free(i
);
2516 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2518 mpctx
->play_tree_step
= n
;
2524 case MP_CMD_PLAY_TREE_UP_STEP
:{
2525 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2526 int force
= cmd
->args
[1].v
.i
;
2528 if (!force
&& mpctx
->playtree_iter
) {
2529 play_tree_iter_t
*i
=
2530 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2531 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2532 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2533 play_tree_iter_free(i
);
2535 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2540 case MP_CMD_PLAY_ALT_SRC_STEP
:
2541 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2542 int v
= cmd
->args
[0].v
.i
;
2544 && mpctx
->playtree_iter
->file
<
2545 mpctx
->playtree_iter
->num_files
)
2546 mpctx
->eof
= PT_NEXT_SRC
;
2547 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2548 mpctx
->eof
= PT_PREV_SRC
;
2553 case MP_CMD_SUB_STEP
:
2555 int movement
= cmd
->args
[0].v
.i
;
2556 step_sub(subdata
, sh_video
->pts
, movement
);
2560 ass_step_sub(ass_track
,
2562 sub_delay
) * 1000 + .5, movement
) / 1000.;
2564 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2565 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2569 case MP_CMD_SUB_LOG
:
2574 int v
= cmd
->args
[0].v
.i
;
2576 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2577 if (osd_level
> max
)
2580 osd_level
= (osd_level
+ 1) % (max
+ 1);
2582 osd_level
= v
> max
? max
: v
;
2583 /* Show OSD state when disabled, but not when an explicit
2584 argument is given to the OSD command, i.e. in slave mode. */
2585 if (v
== -1 && osd_level
<= 1)
2586 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2588 osd_level
? MSGTR_OSDenabled
:
2591 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2595 case MP_CMD_OSD_SHOW_TEXT
:
2596 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2598 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2599 "%-.63s", cmd
->args
[0].v
.s
);
2602 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2603 char *txt
= m_properties_expand_string(mp_properties
,
2606 /* if no argument supplied take default osd_duration, else <arg> ms. */
2608 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2610 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2617 case MP_CMD_LOADFILE
:{
2618 play_tree_t
*e
= play_tree_new();
2619 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2621 if (cmd
->args
[1].v
.i
) // append
2622 play_tree_append_entry(mpctx
->playtree
, e
);
2624 // Go back to the starting point.
2625 while (play_tree_iter_up_step
2626 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2628 play_tree_free_list(mpctx
->playtree
->child
, 1);
2629 play_tree_set_child(mpctx
->playtree
, e
);
2630 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2631 mpctx
->eof
= PT_NEXT_SRC
;
2637 case MP_CMD_LOADLIST
:{
2638 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2640 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2641 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2643 if (cmd
->args
[1].v
.i
) // append
2644 play_tree_append_entry(mpctx
->playtree
, e
);
2646 // Go back to the starting point.
2647 while (play_tree_iter_up_step
2648 (mpctx
->playtree_iter
, 0, 1)
2649 != PLAY_TREE_ITER_END
)
2651 play_tree_free_list(mpctx
->playtree
->child
, 1);
2652 play_tree_set_child(mpctx
->playtree
, e
);
2653 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2654 mpctx
->eof
= PT_NEXT_SRC
;
2662 mpctx
->eof
= PT_STOP
;
2667 case MP_CMD_RADIO_STEP_CHANNEL
:
2668 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2669 int v
= cmd
->args
[0].v
.i
;
2671 radio_step_channel(mpctx
->demuxer
->stream
,
2672 RADIO_CHANNEL_HIGHER
);
2674 radio_step_channel(mpctx
->demuxer
->stream
,
2675 RADIO_CHANNEL_LOWER
);
2676 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2677 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2679 radio_get_channel_name(mpctx
->demuxer
->stream
));
2684 case MP_CMD_RADIO_SET_CHANNEL
:
2685 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2686 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2687 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2688 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2690 radio_get_channel_name(mpctx
->demuxer
->stream
));
2695 case MP_CMD_RADIO_SET_FREQ
:
2696 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2697 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2700 case MP_CMD_RADIO_STEP_FREQ
:
2701 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2702 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2707 case MP_CMD_TV_START_SCAN
:
2708 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2709 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2711 case MP_CMD_TV_SET_FREQ
:
2712 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2713 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2714 cmd
->args
[0].v
.f
* 16.0);
2716 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2717 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2718 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2719 pvr_get_current_channelname (mpctx
->stream
),
2720 pvr_get_current_stationname (mpctx
->stream
));
2722 #endif /* HAVE_PVR */
2725 case MP_CMD_TV_STEP_FREQ
:
2726 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2727 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2728 cmd
->args
[0].v
.f
* 16.0);
2730 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2731 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2732 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2733 pvr_get_current_channelname (mpctx
->stream
),
2734 pvr_get_current_frequency (mpctx
->stream
));
2736 #endif /* HAVE_PVR */
2739 case MP_CMD_TV_SET_NORM
:
2740 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2741 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2745 case MP_CMD_TV_STEP_CHANNEL
:{
2746 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2747 int v
= cmd
->args
[0].v
.i
;
2749 tv_step_channel((tvi_handle_t
*) (mpctx
->
2753 tv_step_channel((tvi_handle_t
*) (mpctx
->
2757 if (tv_channel_list
) {
2758 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2759 MSGTR_OSDChannel
, tv_channel_current
->name
);
2760 //vo_osd_changed(OSDTYPE_SUBTITLE);
2764 else if (mpctx
->stream
&&
2765 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2766 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2767 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2768 pvr_get_current_channelname (mpctx
->stream
),
2769 pvr_get_current_stationname (mpctx
->stream
));
2771 #endif /* HAVE_PVR */
2773 #ifdef HAS_DVBIN_SUPPORT
2774 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2776 int v
= cmd
->args
[0].v
.i
;
2778 mpctx
->last_dvb_step
= v
;
2780 dir
= DVB_CHANNEL_HIGHER
;
2782 dir
= DVB_CHANNEL_LOWER
;
2785 if (dvb_step_channel(mpctx
->stream
, dir
))
2786 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2788 #endif /* HAS_DVBIN_SUPPORT */
2791 case MP_CMD_TV_SET_CHANNEL
:
2792 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2793 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2795 if (tv_channel_list
) {
2796 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2797 MSGTR_OSDChannel
, tv_channel_current
->name
);
2798 //vo_osd_changed(OSDTYPE_SUBTITLE);
2802 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2803 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2804 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2805 pvr_get_current_channelname (mpctx
->stream
),
2806 pvr_get_current_stationname (mpctx
->stream
));
2808 #endif /* HAVE_PVR */
2811 #ifdef HAS_DVBIN_SUPPORT
2812 case MP_CMD_DVB_SET_CHANNEL
:
2813 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2814 mpctx
->last_dvb_step
= 1;
2817 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2818 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2821 #endif /* HAS_DVBIN_SUPPORT */
2823 case MP_CMD_TV_LAST_CHANNEL
:
2824 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2825 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2826 if (tv_channel_list
) {
2827 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2828 MSGTR_OSDChannel
, tv_channel_current
->name
);
2829 //vo_osd_changed(OSDTYPE_SUBTITLE);
2833 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2834 pvr_set_lastchannel (mpctx
->stream
);
2835 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2836 pvr_get_current_channelname (mpctx
->stream
),
2837 pvr_get_current_stationname (mpctx
->stream
));
2839 #endif /* HAVE_PVR */
2842 case MP_CMD_TV_STEP_NORM
:
2843 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2844 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2847 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2848 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2849 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2851 #ifdef HAVE_TV_TELETEXT
2852 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2854 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2855 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2856 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2859 case MP_CMD_TV_TELETEXT_GO_LINK
:
2861 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2862 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2863 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2866 #endif /* HAVE_TV_TELETEXT */
2867 #endif /* CONFIG_TV */
2869 case MP_CMD_SUB_LOAD
:
2871 int n
= mpctx
->set_of_sub_size
;
2872 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2873 if (n
!= mpctx
->set_of_sub_size
) {
2874 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2875 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2876 mpctx
->global_sub_size
;
2877 ++mpctx
->global_sub_size
;
2882 case MP_CMD_SUB_REMOVE
:
2884 int v
= cmd
->args
[0].v
.i
;
2887 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2888 subd
= mpctx
->set_of_subtitles
[v
];
2889 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2890 MSGTR_RemovedSubtitleFile
, v
+ 1,
2891 filename_recode(subd
->filename
));
2893 mpctx
->set_of_subtitles
[v
] = NULL
;
2895 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2896 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2897 mpctx
->set_of_sub_size
= 0;
2898 if (mpctx
->set_of_sub_pos
>= 0) {
2899 mpctx
->global_sub_pos
= -2;
2901 mp_input_queue_cmd(mpctx
->input
,
2902 mp_input_parse_cmd("sub_select"));
2904 } else if (v
< mpctx
->set_of_sub_size
) {
2905 subd
= mpctx
->set_of_subtitles
[v
];
2906 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2907 MSGTR_RemovedSubtitleFile
, v
+ 1,
2908 filename_recode(subd
->filename
));
2910 if (mpctx
->set_of_sub_pos
== v
) {
2911 mpctx
->global_sub_pos
= -2;
2913 mp_input_queue_cmd(mpctx
->input
,
2914 mp_input_parse_cmd("sub_select"));
2915 } else if (mpctx
->set_of_sub_pos
> v
) {
2916 --mpctx
->set_of_sub_pos
;
2917 --mpctx
->global_sub_pos
;
2919 while (++v
< mpctx
->set_of_sub_size
)
2920 mpctx
->set_of_subtitles
[v
- 1] =
2921 mpctx
->set_of_subtitles
[v
];
2922 --mpctx
->set_of_sub_size
;
2923 --mpctx
->global_sub_size
;
2924 if (mpctx
->set_of_sub_size
<= 0)
2925 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2926 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2931 case MP_CMD_GET_SUB_VISIBILITY
:
2933 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2934 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2938 case MP_CMD_SCREENSHOT
:
2939 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2940 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2942 ((vf_instance_t
*) sh_video
->vfilter
)->
2943 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2945 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2949 case MP_CMD_VF_CHANGE_RECTANGLE
:
2950 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2953 case MP_CMD_GET_TIME_LENGTH
:{
2954 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2955 demuxer_get_time_length(mpctx
->demuxer
));
2959 case MP_CMD_GET_FILENAME
:{
2960 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2961 get_metadata(mpctx
, META_NAME
));
2965 case MP_CMD_GET_VIDEO_CODEC
:{
2966 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
2969 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2974 case MP_CMD_GET_VIDEO_BITRATE
:{
2975 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
2978 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2983 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2984 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
2987 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2988 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2993 case MP_CMD_GET_AUDIO_CODEC
:{
2994 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
2997 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3002 case MP_CMD_GET_AUDIO_BITRATE
:{
3003 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3006 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3011 case MP_CMD_GET_AUDIO_SAMPLES
:{
3012 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3015 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3020 case MP_CMD_GET_META_TITLE
:{
3021 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3024 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3029 case MP_CMD_GET_META_ARTIST
:{
3030 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3033 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3038 case MP_CMD_GET_META_ALBUM
:{
3039 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3042 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3047 case MP_CMD_GET_META_YEAR
:{
3048 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3051 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3056 case MP_CMD_GET_META_COMMENT
:{
3057 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3060 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3065 case MP_CMD_GET_META_TRACK
:{
3066 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3069 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3074 case MP_CMD_GET_META_GENRE
:{
3075 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3078 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3083 case MP_CMD_GET_VO_FULLSCREEN
:
3084 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3085 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3088 case MP_CMD_GET_PERCENT_POS
:
3089 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3090 demuxer_get_percent_pos(mpctx
->demuxer
));
3093 case MP_CMD_GET_TIME_POS
:{
3096 pos
= sh_video
->pts
;
3097 else if (sh_audio
&& mpctx
->audio_out
)
3098 pos
= playing_audio_pts(mpctx
);
3099 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3106 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3112 case MP_CMD_KEYDOWN_EVENTS
:
3113 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3116 case MP_CMD_SET_MOUSE_POS
:{
3117 int pointer_x
, pointer_y
;
3119 pointer_x
= cmd
->args
[0].v
.i
;
3120 pointer_y
= cmd
->args
[1].v
.i
;
3121 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3122 #ifdef CONFIG_DVDNAV
3123 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3124 && dx
> 0.0 && dy
> 0.0) {
3126 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3127 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3128 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3129 pointer_x
, pointer_y
, &button
);
3130 if (osd_level
> 1 && button
> 0)
3131 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3132 "Selected button number %d", button
);
3136 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3137 menu_update_mouse_pos(dx
, dy
);
3142 #ifdef CONFIG_DVDNAV
3143 case MP_CMD_DVDNAV
:{
3146 mp_command_type command
= 0;
3147 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3150 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3151 if (cmd
->args
[0].v
.s
&&
3152 !strcasecmp (cmd
->args
[0].v
.s
,
3153 mp_dvdnav_bindings
[i
].name
))
3154 command
= mp_dvdnav_bindings
[i
].cmd
;
3156 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3157 if (osd_level
> 1 && button
> 0)
3158 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3159 "Selected button number %d", button
);
3163 case MP_CMD_SWITCH_TITLE
:
3164 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3165 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3172 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3173 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3176 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3177 "Received unknown cmd %s\n", cmd
->name
);
3180 switch (cmd
->pausing
) {
3181 case 1: // "pausing"
3182 mpctx
->osd_function
= OSD_PAUSE
;
3184 case 3: // "pausing_toggle"
3185 mpctx
->was_paused
= !mpctx
->was_paused
;
3186 if (mpctx
->was_paused
)
3187 mpctx
->osd_function
= OSD_PAUSE
;
3188 else if (mpctx
->osd_function
== OSD_PAUSE
)
3189 mpctx
->osd_function
= OSD_PLAY
;
3191 case 2: // "pausing_keep"
3192 if (mpctx
->was_paused
)
3193 mpctx
->osd_function
= OSD_PAUSE
;