7 #include "input/input.h"
8 #include "stream/stream.h"
9 #include "libmpdemux/demuxer.h"
10 #include "libmpdemux/stheader.h"
11 #include "codec-cfg.h"
13 #include "libvo/sub.h"
15 #include "m_property.h"
18 #include "libmpcodecs/mp_image.h"
19 #include "libmpcodecs/vf.h"
20 #include "libmpcodecs/vd.h"
21 #include "libvo/video_out.h"
22 #include "libvo/font_load.h"
24 #include "libao2/audio_out.h"
27 #include "libmpdemux/matroska.h"
28 #include "libmpcodecs/dec_video.h"
32 #include "stream/tv.h"
35 #include "stream/stream_radio.h"
38 #include "stream/pvr.h"
40 #ifdef HAS_DVBIN_SUPPORT
41 #include "stream/dvbin.h"
44 #include "stream/stream_dvd.h"
47 #include "stream/stream_dvdnav.h"
50 #include "libass/ass.h"
51 #include "libass/ass_mp.h"
54 #include "gui/interface.h"
59 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
61 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
63 //remove the borders, if any, and rescale to the range [0,1],[0,1]
64 if (vo_fs
) { //we are in full-screen mode
65 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
66 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
67 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
68 iy
-= (vo_screenheight
- vo_dheight
) / 2;
70 if (ix
< 0 || ix
> vo_dwidth
) {
73 } //we are on one of the borders
74 if (iy
< 0 || iy
> vo_dheight
) {
77 } //we are on one of the borders
80 *dx
= (double) ix
/ (double) vo_dwidth
;
81 *dy
= (double) iy
/ (double) vo_dheight
;
83 mp_msg(MSGT_CPLAYER
, MSGL_V
,
84 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
85 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
89 static int sub_source(MPContext
* mpctx
)
94 for (i
= 0; i
< SUB_SOURCES
; i
++) {
95 int j
= mpctx
->global_sub_indices
[i
];
96 if ((j
>= 0) && (j
> top
) && (mpctx
->global_sub_pos
>= j
)) {
105 * \brief Log the currently displayed subtitle to a file
107 * Logs the current or last displayed subtitle together with filename
108 * and time information to ~/.mplayer/subtitle_log
110 * Intended purpose is to allow convenient marking of bogus subtitles
111 * which need to be fixed while watching the movie.
114 static void log_sub(void)
120 if (subdata
== NULL
|| vo_sub_last
== NULL
)
122 fname
= get_path("subtitle_log");
123 f
= fopen(fname
, "a");
126 fprintf(f
, "----------------------------------------------------------\n");
127 if (subdata
->sub_uses_time
) {
129 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
130 filename
, vo_sub_last
->start
/ 360000,
131 (vo_sub_last
->start
/ 6000) % 60,
132 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
133 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
134 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
136 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
139 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
140 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
146 /// \defgroup Properties
149 /// \defgroup GeneralProperties General properties
150 /// \ingroup Properties
154 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
157 return m_property_choice(prop
, action
, arg
, &osd_level
);
161 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
165 case M_PROPERTY_PRINT
:
166 if (!arg
) return M_PROPERTY_ERROR
;
167 if (mpctx
->loop_times
< 0)
168 *(char**)arg
= strdup("off");
169 else if (mpctx
->loop_times
== 0)
170 *(char**)arg
= strdup("inf");
173 return M_PROPERTY_OK
;
175 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
178 /// Playback speed (RW)
179 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
180 void *arg
, MPContext
* mpctx
)
185 return M_PROPERTY_ERROR
;
186 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
187 playback_speed
= *(float *) arg
;
188 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
189 return M_PROPERTY_OK
;
190 case M_PROPERTY_STEP_UP
:
191 case M_PROPERTY_STEP_DOWN
:
192 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
193 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
194 M_PROPERTY_CLAMP(prop
, playback_speed
);
195 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
196 return M_PROPERTY_OK
;
198 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
201 /// filename with path (RO)
202 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
205 return m_property_string_ro(prop
, action
, arg
, filename
);
208 /// filename without path (RO)
209 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
214 return M_PROPERTY_UNAVAILABLE
;
215 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
219 return m_property_string_ro(prop
, action
, arg
, f
);
222 /// Demuxer name (RO)
223 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
227 return M_PROPERTY_UNAVAILABLE
;
228 return m_property_string_ro(prop
, action
, arg
,
229 (char *) mpctx
->demuxer
->desc
->name
);
232 /// Position in the stream (RW)
233 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
236 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
237 return M_PROPERTY_UNAVAILABLE
;
239 return M_PROPERTY_ERROR
;
242 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
243 return M_PROPERTY_OK
;
245 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
246 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
247 return M_PROPERTY_OK
;
249 return M_PROPERTY_NOT_IMPLEMENTED
;
252 /// Stream start offset (RO)
253 static int mp_property_stream_start(m_option_t
* prop
, int action
,
254 void *arg
, MPContext
* mpctx
)
256 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
257 return M_PROPERTY_UNAVAILABLE
;
260 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
261 return M_PROPERTY_OK
;
263 return M_PROPERTY_NOT_IMPLEMENTED
;
266 /// Stream end offset (RO)
267 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
270 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
271 return M_PROPERTY_UNAVAILABLE
;
274 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
275 return M_PROPERTY_OK
;
277 return M_PROPERTY_NOT_IMPLEMENTED
;
280 /// Stream length (RO)
281 static int mp_property_stream_length(m_option_t
* prop
, int action
,
282 void *arg
, MPContext
* mpctx
)
284 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
285 return M_PROPERTY_UNAVAILABLE
;
289 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
290 return M_PROPERTY_OK
;
292 return M_PROPERTY_NOT_IMPLEMENTED
;
295 /// Media length in seconds (RO)
296 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
301 if (!mpctx
->demuxer
||
302 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
303 return M_PROPERTY_UNAVAILABLE
;
305 return m_property_time_ro(prop
, action
, arg
, len
);
308 /// Current position in percent (RW)
309 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
310 void *arg
, MPContext
* mpctx
) {
314 return M_PROPERTY_UNAVAILABLE
;
318 if(!arg
) return M_PROPERTY_ERROR
;
319 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
322 case M_PROPERTY_STEP_UP
:
323 case M_PROPERTY_STEP_DOWN
:
324 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
325 pos
+= (arg
? *(int*)arg
: 10) *
326 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
327 M_PROPERTY_CLAMP(prop
, pos
);
330 return m_property_int_ro(prop
, action
, arg
,
331 demuxer_get_percent_pos(mpctx
->demuxer
));
335 rel_seek_secs
= pos
/ 100.0;
336 return M_PROPERTY_OK
;
339 /// Current position in seconds (RW)
340 static int mp_property_time_pos(m_option_t
* prop
, int action
,
341 void *arg
, MPContext
* mpctx
) {
342 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
343 return M_PROPERTY_UNAVAILABLE
;
347 if(!arg
) return M_PROPERTY_ERROR
;
348 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
350 rel_seek_secs
= *(double*)arg
;
351 return M_PROPERTY_OK
;
352 case M_PROPERTY_STEP_UP
:
353 case M_PROPERTY_STEP_DOWN
:
354 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
355 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
356 return M_PROPERTY_OK
;
358 return m_property_time_ro(prop
, action
, arg
,
359 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
360 playing_audio_pts(mpctx
->sh_audio
,
365 /// Demuxer meta data
366 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
368 m_property_action_t
* ka
;
370 static m_option_t key_type
=
371 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
373 return M_PROPERTY_UNAVAILABLE
;
377 if(!arg
) return M_PROPERTY_ERROR
;
378 *(char***)arg
= mpctx
->demuxer
->info
;
379 return M_PROPERTY_OK
;
380 case M_PROPERTY_KEY_ACTION
:
381 if(!arg
) return M_PROPERTY_ERROR
;
383 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
384 return M_PROPERTY_UNKNOWN
;
387 if(!ka
->arg
) return M_PROPERTY_ERROR
;
388 *(char**)ka
->arg
= meta
;
389 return M_PROPERTY_OK
;
390 case M_PROPERTY_GET_TYPE
:
391 if(!ka
->arg
) return M_PROPERTY_ERROR
;
392 *(m_option_t
**)ka
->arg
= &key_type
;
393 return M_PROPERTY_OK
;
396 return M_PROPERTY_NOT_IMPLEMENTED
;
402 /// \defgroup AudioProperties Audio properties
403 /// \ingroup Properties
407 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
411 if (!mpctx
->sh_audio
)
412 return M_PROPERTY_UNAVAILABLE
;
417 return M_PROPERTY_ERROR
;
418 mixer_getbothvolume(&mpctx
->mixer
, arg
);
419 return M_PROPERTY_OK
;
420 case M_PROPERTY_PRINT
:{
423 return M_PROPERTY_ERROR
;
424 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
425 return m_property_float_range(prop
, action
, arg
, &vol
);
427 case M_PROPERTY_STEP_UP
:
428 case M_PROPERTY_STEP_DOWN
:
432 return M_PROPERTY_NOT_IMPLEMENTED
;
435 if (mpctx
->edl_muted
)
436 return M_PROPERTY_DISABLED
;
437 mpctx
->user_muted
= 0;
442 return M_PROPERTY_ERROR
;
443 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
444 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
445 return M_PROPERTY_OK
;
446 case M_PROPERTY_STEP_UP
:
447 if (arg
&& *(float *) arg
<= 0)
448 mixer_decvolume(&mpctx
->mixer
);
450 mixer_incvolume(&mpctx
->mixer
);
451 return M_PROPERTY_OK
;
452 case M_PROPERTY_STEP_DOWN
:
453 if (arg
&& *(float *) arg
<= 0)
454 mixer_incvolume(&mpctx
->mixer
);
456 mixer_decvolume(&mpctx
->mixer
);
457 return M_PROPERTY_OK
;
459 return M_PROPERTY_NOT_IMPLEMENTED
;
463 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
467 if (!mpctx
->sh_audio
)
468 return M_PROPERTY_UNAVAILABLE
;
472 if (mpctx
->edl_muted
)
473 return M_PROPERTY_DISABLED
;
475 return M_PROPERTY_ERROR
;
476 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
477 mixer_mute(&mpctx
->mixer
);
478 mpctx
->user_muted
= mpctx
->mixer
.muted
;
479 return M_PROPERTY_OK
;
480 case M_PROPERTY_STEP_UP
:
481 case M_PROPERTY_STEP_DOWN
:
482 if (mpctx
->edl_muted
)
483 return M_PROPERTY_DISABLED
;
484 mixer_mute(&mpctx
->mixer
);
485 mpctx
->user_muted
= mpctx
->mixer
.muted
;
486 return M_PROPERTY_OK
;
487 case M_PROPERTY_PRINT
:
489 return M_PROPERTY_ERROR
;
490 if (mpctx
->edl_muted
) {
491 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
492 return M_PROPERTY_OK
;
495 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
501 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
502 void *arg
, MPContext
* mpctx
)
504 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
505 return M_PROPERTY_UNAVAILABLE
;
508 case M_PROPERTY_STEP_UP
:
509 case M_PROPERTY_STEP_DOWN
:
511 return M_PROPERTY_ERROR
;
513 float delay
= audio_delay
;
514 m_property_delay(prop
, action
, arg
, &audio_delay
);
516 mpctx
->delay
-= audio_delay
- delay
;
518 return M_PROPERTY_OK
;
520 return m_property_delay(prop
, action
, arg
, &audio_delay
);
524 /// Audio codec tag (RO)
525 static int mp_property_audio_format(m_option_t
* prop
, int action
,
526 void *arg
, MPContext
* mpctx
)
528 if (!mpctx
->sh_audio
)
529 return M_PROPERTY_UNAVAILABLE
;
530 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
533 /// Audio codec name (RO)
534 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
535 void *arg
, MPContext
* mpctx
)
537 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
538 return M_PROPERTY_UNAVAILABLE
;
539 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
542 /// Audio bitrate (RO)
543 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
544 void *arg
, MPContext
* mpctx
)
546 if (!mpctx
->sh_audio
)
547 return M_PROPERTY_UNAVAILABLE
;
548 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
552 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
555 if (!mpctx
->sh_audio
)
556 return M_PROPERTY_UNAVAILABLE
;
558 case M_PROPERTY_PRINT
:
559 if(!arg
) return M_PROPERTY_ERROR
;
560 *(char**)arg
= malloc(16);
561 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
562 return M_PROPERTY_OK
;
564 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
567 /// Number of channels (RO)
568 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
571 if (!mpctx
->sh_audio
)
572 return M_PROPERTY_UNAVAILABLE
;
574 case M_PROPERTY_PRINT
:
576 return M_PROPERTY_ERROR
;
577 switch (mpctx
->sh_audio
->channels
) {
579 *(char **) arg
= strdup("mono");
582 *(char **) arg
= strdup("stereo");
585 *(char **) arg
= malloc(32);
586 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
588 return M_PROPERTY_OK
;
590 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
594 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
599 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
600 return M_PROPERTY_UNAVAILABLE
;
605 return M_PROPERTY_ERROR
;
606 mixer_getbalance(&mpctx
->mixer
, arg
);
607 return M_PROPERTY_OK
;
608 case M_PROPERTY_PRINT
: {
611 return M_PROPERTY_ERROR
;
612 mixer_getbalance(&mpctx
->mixer
, &bal
);
614 *str
= strdup("center");
615 else if (bal
== -1.f
)
616 *str
= strdup("left only");
618 *str
= strdup("right only");
620 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
621 *str
= malloc(sizeof("left xxx%, right xxx%"));
622 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
624 return M_PROPERTY_OK
;
626 case M_PROPERTY_STEP_UP
:
627 case M_PROPERTY_STEP_DOWN
:
628 mixer_getbalance(&mpctx
->mixer
, &bal
);
629 bal
+= (arg
? *(float*)arg
: .1f
) *
630 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
631 M_PROPERTY_CLAMP(prop
, bal
);
632 mixer_setbalance(&mpctx
->mixer
, bal
);
633 return M_PROPERTY_OK
;
636 return M_PROPERTY_ERROR
;
637 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
638 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
639 return M_PROPERTY_OK
;
641 return M_PROPERTY_NOT_IMPLEMENTED
;
644 /// Selected audio id (RW)
645 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
648 int current_id
= -1, tmp
;
652 if (!mpctx
->sh_audio
)
653 return M_PROPERTY_UNAVAILABLE
;
655 return M_PROPERTY_ERROR
;
656 *(int *) arg
= audio_id
;
657 return M_PROPERTY_OK
;
658 case M_PROPERTY_PRINT
:
659 if (!mpctx
->sh_audio
)
660 return M_PROPERTY_UNAVAILABLE
;
662 return M_PROPERTY_ERROR
;
665 *(char **) arg
= strdup(MSGTR_Disabled
);
667 char lang
[40] = MSGTR_Unknown
;
668 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
669 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
671 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
672 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
682 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
683 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
685 *(char **) arg
= malloc(64);
686 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
688 return M_PROPERTY_OK
;
690 case M_PROPERTY_STEP_UP
:
692 if (action
== M_PROPERTY_SET
&& arg
)
693 tmp
= *((int *) arg
);
696 current_id
= mpctx
->demuxer
->audio
->id
;
697 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
700 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
701 uninit_player(INITED_AO
| INITED_ACODEC
);
702 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
704 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
706 sh2
->ds
= mpctx
->demuxer
->audio
;
707 mpctx
->sh_audio
= sh2
;
708 reinit_audio_chain();
711 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
712 return M_PROPERTY_OK
;
714 return M_PROPERTY_NOT_IMPLEMENTED
;
719 /// Selected video id (RW)
720 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
723 int current_id
= -1, tmp
;
727 if (!mpctx
->sh_video
)
728 return M_PROPERTY_UNAVAILABLE
;
730 return M_PROPERTY_ERROR
;
731 *(int *) arg
= video_id
;
732 return M_PROPERTY_OK
;
733 case M_PROPERTY_PRINT
:
734 if (!mpctx
->sh_video
)
735 return M_PROPERTY_UNAVAILABLE
;
737 return M_PROPERTY_ERROR
;
740 *(char **) arg
= strdup(MSGTR_Disabled
);
742 char lang
[40] = MSGTR_Unknown
;
743 *(char **) arg
= malloc(64);
744 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
746 return M_PROPERTY_OK
;
748 case M_PROPERTY_STEP_UP
:
750 current_id
= mpctx
->demuxer
->video
->id
;
751 if (action
== M_PROPERTY_SET
&& arg
)
752 tmp
= *((int *) arg
);
755 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
757 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
758 && current_id
!= -2))
759 uninit_player(INITED_VCODEC
|
760 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
761 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
763 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
765 sh2
->ds
= mpctx
->demuxer
->video
;
766 mpctx
->sh_video
= sh2
;
767 reinit_video_chain();
770 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
771 return M_PROPERTY_OK
;
774 return M_PROPERTY_NOT_IMPLEMENTED
;
778 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
781 demux_program_t prog
;
784 case M_PROPERTY_STEP_UP
:
786 if (action
== M_PROPERTY_SET
&& arg
)
787 prog
.progid
= *((int *) arg
);
791 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
792 &prog
) == DEMUXER_CTRL_NOTIMPL
)
793 return M_PROPERTY_ERROR
;
795 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
796 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
797 return M_PROPERTY_OK
;
800 return M_PROPERTY_NOT_IMPLEMENTED
;
806 /// \defgroup VideoProperties Video properties
807 /// \ingroup Properties
810 /// Fullscreen state (RW)
811 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
815 if (!mpctx
->video_out
)
816 return M_PROPERTY_UNAVAILABLE
;
821 return M_PROPERTY_ERROR
;
822 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
823 if (vo_fs
== !!*(int *) arg
)
824 return M_PROPERTY_OK
;
825 case M_PROPERTY_STEP_UP
:
826 case M_PROPERTY_STEP_DOWN
:
829 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
833 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
834 return M_PROPERTY_OK
;
836 return m_property_flag(prop
, action
, arg
, &vo_fs
);
840 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
841 void *arg
, MPContext
* mpctx
)
845 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
846 return M_PROPERTY_UNAVAILABLE
;
847 vf
= mpctx
->sh_video
->vfilter
;
851 return M_PROPERTY_ERROR
;
852 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
853 return M_PROPERTY_OK
;
856 return M_PROPERTY_ERROR
;
857 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
858 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
859 return M_PROPERTY_OK
;
860 case M_PROPERTY_STEP_UP
:
861 case M_PROPERTY_STEP_DOWN
:
862 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
863 deinterlace
= !deinterlace
;
864 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
865 return M_PROPERTY_OK
;
867 return M_PROPERTY_NOT_IMPLEMENTED
;
871 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
875 if (!mpctx
->video_out
876 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
877 return M_PROPERTY_UNAVAILABLE
;
882 return M_PROPERTY_ERROR
;
883 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
884 vo_panscan
= *(float *) arg
;
885 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
886 return M_PROPERTY_OK
;
887 case M_PROPERTY_STEP_UP
:
888 case M_PROPERTY_STEP_DOWN
:
889 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
890 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
893 else if (vo_panscan
< 0)
895 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
896 return M_PROPERTY_OK
;
898 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
902 /// Helper to set vo flags.
903 /** \ingroup PropertyImplHelper
905 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
906 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
909 if (!mpctx
->video_out
)
910 return M_PROPERTY_UNAVAILABLE
;
915 return M_PROPERTY_ERROR
;
916 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
917 if (*vo_var
== !!*(int *) arg
)
918 return M_PROPERTY_OK
;
919 case M_PROPERTY_STEP_UP
:
920 case M_PROPERTY_STEP_DOWN
:
922 mpctx
->video_out
->control(vo_ctrl
, 0);
923 return M_PROPERTY_OK
;
925 return m_property_flag(prop
, action
, arg
, vo_var
);
929 /// Window always on top (RW)
930 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
933 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
937 /// Display in the root window (RW)
938 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
941 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
945 /// Show window borders (RW)
946 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
949 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
953 /// Framedropping state (RW)
954 static int mp_property_framedropping(m_option_t
* prop
, int action
,
955 void *arg
, MPContext
* mpctx
)
958 if (!mpctx
->sh_video
)
959 return M_PROPERTY_UNAVAILABLE
;
962 case M_PROPERTY_PRINT
:
964 return M_PROPERTY_ERROR
;
965 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
966 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
968 return M_PROPERTY_OK
;
970 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
974 /// Color settings, try to use vf/vo then fall back on TV. (RW)
975 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
978 int *gamma
= prop
->priv
, r
;
980 if (!mpctx
->sh_video
)
981 return M_PROPERTY_UNAVAILABLE
;
983 if (gamma
[0] == 1000) {
985 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
991 return M_PROPERTY_ERROR
;
992 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
993 *gamma
= *(int *) arg
;
994 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1000 return M_PROPERTY_ERROR
;
1001 r
= get_video_colors(mpctx
->sh_video
, prop
->name
, arg
);
1005 case M_PROPERTY_STEP_UP
:
1006 case M_PROPERTY_STEP_DOWN
:
1007 *gamma
+= (arg
? *(int *) arg
: 1) *
1008 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1009 M_PROPERTY_CLAMP(prop
, *gamma
);
1010 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1015 return M_PROPERTY_NOT_IMPLEMENTED
;
1019 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1020 int l
= strlen(prop
->name
);
1021 char tv_prop
[3 + l
+ 1];
1022 sprintf(tv_prop
, "tv_%s", prop
->name
);
1023 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1027 return M_PROPERTY_UNAVAILABLE
;
1031 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1034 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1037 /// Video codec tag (RO)
1038 static int mp_property_video_format(m_option_t
* prop
, int action
,
1039 void *arg
, MPContext
* mpctx
)
1042 if (!mpctx
->sh_video
)
1043 return M_PROPERTY_UNAVAILABLE
;
1045 case M_PROPERTY_PRINT
:
1047 return M_PROPERTY_ERROR
;
1048 switch(mpctx
->sh_video
->format
) {
1050 meta
= strdup ("mpeg1"); break;
1052 meta
= strdup ("mpeg2"); break;
1054 meta
= strdup ("mpeg4"); break;
1056 meta
= strdup ("h264"); break;
1058 if(mpctx
->sh_video
->format
>= 0x20202020) {
1060 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1063 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1066 *(char**)arg
= meta
;
1067 return M_PROPERTY_OK
;
1069 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1072 /// Video codec name (RO)
1073 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1074 void *arg
, MPContext
* mpctx
)
1076 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1077 return M_PROPERTY_UNAVAILABLE
;
1078 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1082 /// Video bitrate (RO)
1083 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1084 void *arg
, MPContext
* mpctx
)
1086 if (!mpctx
->sh_video
)
1087 return M_PROPERTY_UNAVAILABLE
;
1088 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1091 /// Video display width (RO)
1092 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1095 if (!mpctx
->sh_video
)
1096 return M_PROPERTY_UNAVAILABLE
;
1097 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1100 /// Video display height (RO)
1101 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1104 if (!mpctx
->sh_video
)
1105 return M_PROPERTY_UNAVAILABLE
;
1106 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1110 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1113 if (!mpctx
->sh_video
)
1114 return M_PROPERTY_UNAVAILABLE
;
1115 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1118 /// Video aspect (RO)
1119 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1122 if (!mpctx
->sh_video
)
1123 return M_PROPERTY_UNAVAILABLE
;
1124 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1129 /// \defgroup SubProprties Subtitles properties
1130 /// \ingroup Properties
1133 /// Text subtitle position (RW)
1134 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1137 if (!mpctx
->sh_video
)
1138 return M_PROPERTY_UNAVAILABLE
;
1141 case M_PROPERTY_SET
:
1143 return M_PROPERTY_ERROR
;
1144 case M_PROPERTY_STEP_UP
:
1145 case M_PROPERTY_STEP_DOWN
:
1146 vo_osd_changed(OSDTYPE_SUBTITLE
);
1148 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1152 /// Selected subtitles (RW)
1153 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1156 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1157 const int global_sub_size
= mpctx
->global_sub_size
;
1158 int source
= -1, reset_spu
= 0;
1161 if (global_sub_size
<= 0)
1162 return M_PROPERTY_UNAVAILABLE
;
1165 case M_PROPERTY_GET
:
1167 return M_PROPERTY_ERROR
;
1168 *(int *) arg
= mpctx
->global_sub_pos
;
1169 return M_PROPERTY_OK
;
1170 case M_PROPERTY_PRINT
:
1172 return M_PROPERTY_ERROR
;
1173 *(char **) arg
= malloc(64);
1174 (*(char **) arg
)[63] = 0;
1177 sub_name
= subdata
->filename
;
1179 if (ass_track
&& ass_track
->name
)
1180 sub_name
= ass_track
->name
;
1185 if ((tmp2
= strrchr(tmp
, '/')))
1188 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1189 mpctx
->set_of_sub_pos
+ 1,
1190 strlen(tmp
) < 20 ? "" : "...",
1191 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1192 return M_PROPERTY_OK
;
1195 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1196 if (vo_spudec
&& dvdsub_id
>= 0) {
1197 unsigned char lang
[3];
1198 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1199 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1200 return M_PROPERTY_OK
;
1206 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1207 char lang
[40] = MSGTR_Unknown
;
1208 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1209 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1210 return M_PROPERTY_OK
;
1212 #ifdef HAVE_OGGVORBIS
1213 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1214 char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1216 lang
= MSGTR_Unknown
;
1217 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1218 return M_PROPERTY_OK
;
1221 if (vo_vobsub
&& vobsub_id
>= 0) {
1222 const char *language
= MSGTR_Unknown
;
1223 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1224 snprintf(*(char **) arg
, 63, "(%d) %s",
1225 vobsub_id
, language
? language
: MSGTR_Unknown
);
1226 return M_PROPERTY_OK
;
1229 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1230 && dvdsub_id
>= 0) {
1232 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1233 lang
[0] = code
>> 8;
1236 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1237 return M_PROPERTY_OK
;
1240 if (dvdsub_id
>= 0) {
1241 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1242 return M_PROPERTY_OK
;
1244 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1245 return M_PROPERTY_OK
;
1247 case M_PROPERTY_SET
:
1249 return M_PROPERTY_ERROR
;
1250 if (*(int *) arg
< -1)
1252 else if (*(int *) arg
>= global_sub_size
)
1253 *(int *) arg
= global_sub_size
- 1;
1254 mpctx
->global_sub_pos
= *(int *) arg
;
1256 case M_PROPERTY_STEP_UP
:
1257 mpctx
->global_sub_pos
+= 2;
1258 mpctx
->global_sub_pos
=
1259 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1261 case M_PROPERTY_STEP_DOWN
:
1262 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1263 mpctx
->global_sub_pos
=
1264 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1267 return M_PROPERTY_NOT_IMPLEMENTED
;
1270 if (mpctx
->global_sub_pos
>= 0)
1271 source
= sub_source(mpctx
);
1273 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1274 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1276 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1277 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1278 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1279 mpctx
->global_sub_pos
, source
);
1281 mpctx
->set_of_sub_pos
= -1;
1283 vo_sub_last
= vo_sub
= NULL
;
1296 if (source
== SUB_SOURCE_VOBSUB
) {
1298 mpctx
->global_sub_pos
-
1299 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
];
1300 } else if (source
== SUB_SOURCE_SUBS
) {
1301 mpctx
->set_of_sub_pos
=
1302 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1304 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1305 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1309 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1310 vo_osd_changed(OSDTYPE_SUBTITLE
);
1312 } else if (source
== SUB_SOURCE_DEMUX
) {
1314 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1315 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1317 // default: assume 1:1 mapping of sid and stream id
1318 d_sub
->id
= dvdsub_id
;
1319 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1320 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1321 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1322 if (sh
&& sh
->sid
== dvdsub_id
) {
1328 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1329 sh_sub_t
*sh
= d_sub
->sh
;
1330 if (sh
->type
== 'v')
1333 else if (ass_enabled
&& sh
->type
== 'a')
1334 ass_track
= sh
->ass_track
;
1341 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1342 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1343 && dvdsub_id
< 0 && reset_spu
) {
1345 d_sub
->id
= dvdsub_id
;
1348 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1350 return M_PROPERTY_OK
;
1353 /// Subtitle delay (RW)
1354 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1357 if (!mpctx
->sh_video
)
1358 return M_PROPERTY_UNAVAILABLE
;
1359 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1362 /// Alignment of text subtitles (RW)
1363 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1364 void *arg
, MPContext
* mpctx
)
1366 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1368 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1369 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1370 return M_PROPERTY_UNAVAILABLE
;
1373 case M_PROPERTY_PRINT
:
1375 return M_PROPERTY_ERROR
;
1376 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1377 *(char **) arg
= strdup(name
[sub_alignment
]);
1378 return M_PROPERTY_OK
;
1379 case M_PROPERTY_SET
:
1381 return M_PROPERTY_ERROR
;
1382 case M_PROPERTY_STEP_UP
:
1383 case M_PROPERTY_STEP_DOWN
:
1384 vo_osd_changed(OSDTYPE_SUBTITLE
);
1386 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1390 /// Subtitle visibility (RW)
1391 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1392 void *arg
, MPContext
* mpctx
)
1394 if (!mpctx
->sh_video
)
1395 return M_PROPERTY_UNAVAILABLE
;
1398 case M_PROPERTY_SET
:
1400 return M_PROPERTY_ERROR
;
1401 case M_PROPERTY_STEP_UP
:
1402 case M_PROPERTY_STEP_DOWN
:
1403 vo_osd_changed(OSDTYPE_SUBTITLE
);
1405 vo_osd_changed(OSDTYPE_SPU
);
1407 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1411 /// Show only forced subtitles (RW)
1412 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1413 void *arg
, MPContext
* mpctx
)
1416 return M_PROPERTY_UNAVAILABLE
;
1419 case M_PROPERTY_SET
:
1421 return M_PROPERTY_ERROR
;
1422 case M_PROPERTY_STEP_UP
:
1423 case M_PROPERTY_STEP_DOWN
:
1424 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1425 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1426 return M_PROPERTY_OK
;
1428 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1433 #ifdef HAVE_FREETYPE
1434 /// Subtitle scale (RW)
1435 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1440 case M_PROPERTY_SET
:
1442 return M_PROPERTY_ERROR
;
1443 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1444 text_font_scale_factor
= *(float *) arg
;
1445 force_load_font
= 1;
1446 return M_PROPERTY_OK
;
1447 case M_PROPERTY_STEP_UP
:
1448 case M_PROPERTY_STEP_DOWN
:
1449 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1450 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1451 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1452 force_load_font
= 1;
1453 return M_PROPERTY_OK
;
1455 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1462 /// \defgroup TVProperties TV properties
1463 /// \ingroup Properties
1468 /// TV color settings (RW)
1469 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1473 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1474 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1475 return M_PROPERTY_UNAVAILABLE
;
1478 case M_PROPERTY_SET
:
1480 return M_PROPERTY_ERROR
;
1481 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1482 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1483 case M_PROPERTY_GET
:
1484 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1485 case M_PROPERTY_STEP_UP
:
1486 case M_PROPERTY_STEP_DOWN
:
1487 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1489 return M_PROPERTY_ERROR
;
1490 val
+= (arg
? *(int *) arg
: 1) *
1491 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1492 M_PROPERTY_CLAMP(prop
, val
);
1493 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1495 return M_PROPERTY_ERROR
;
1497 return M_PROPERTY_NOT_IMPLEMENTED
;
1504 /// All properties available in MPlayer.
1505 /** \ingroup Properties
1507 static m_option_t mp_properties
[] = {
1509 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1510 M_OPT_RANGE
, 0, 3, NULL
},
1511 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1512 M_OPT_MIN
, -1, 0, NULL
},
1513 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1514 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1515 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1517 { "path", mp_property_path
, CONF_TYPE_STRING
,
1519 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1521 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1522 M_OPT_MIN
, 0, 0, NULL
},
1523 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1524 M_OPT_MIN
, 0, 0, NULL
},
1525 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1526 M_OPT_MIN
, 0, 0, NULL
},
1527 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1528 M_OPT_MIN
, 0, 0, NULL
},
1529 { "length", mp_property_length
, CONF_TYPE_TIME
,
1530 M_OPT_MIN
, 0, 0, NULL
},
1531 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1532 M_OPT_RANGE
, 0, 100, NULL
},
1533 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1534 M_OPT_MIN
, 0, 0, NULL
},
1535 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1539 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1540 M_OPT_RANGE
, 0, 100, NULL
},
1541 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1542 M_OPT_RANGE
, 0, 1, NULL
},
1543 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1544 M_OPT_RANGE
, -100, 100, NULL
},
1545 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1547 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1549 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1551 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1553 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1555 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1556 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1557 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
1558 M_OPT_RANGE
, -1, 1, NULL
},
1561 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1562 M_OPT_RANGE
, 0, 1, NULL
},
1563 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1564 M_OPT_RANGE
, 0, 1, NULL
},
1565 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1566 M_OPT_RANGE
, 0, 1, NULL
},
1567 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1568 M_OPT_RANGE
, 0, 1, NULL
},
1569 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1570 M_OPT_RANGE
, 0, 1, NULL
},
1571 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1572 M_OPT_RANGE
, 0, 2, NULL
},
1573 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1574 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1575 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1576 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1577 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1578 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1579 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
1580 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
1581 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
1582 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
1583 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
1584 M_OPT_RANGE
, 0, 1, NULL
},
1585 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
1586 M_OPT_RANGE
, 0, 1, NULL
},
1587 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
1589 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
1591 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
1593 { "width", mp_property_width
, CONF_TYPE_INT
,
1595 { "height", mp_property_height
, CONF_TYPE_INT
,
1597 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
1599 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
1601 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
1602 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
1603 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
1604 CONF_RANGE
, -1, 65535, NULL
},
1607 { "sub", mp_property_sub
, CONF_TYPE_INT
,
1608 M_OPT_MIN
, -1, 0, NULL
},
1609 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
1611 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
1612 M_OPT_RANGE
, 0, 100, NULL
},
1613 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
1614 M_OPT_RANGE
, 0, 2, NULL
},
1615 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
1616 M_OPT_RANGE
, 0, 1, NULL
},
1617 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
1618 M_OPT_RANGE
, 0, 1, NULL
},
1619 #ifdef HAVE_FREETYPE
1620 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
1621 M_OPT_RANGE
, 0, 100, NULL
},
1625 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
1626 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
1627 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
1628 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
1629 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
1630 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
1631 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
1632 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
1635 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
1639 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
1641 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
1644 char* mp_property_print(const char *name
, void* ctx
)
1647 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
1652 char *property_expand_string(MPContext
* mpctx
, char *str
)
1654 return m_properties_expand_string(mp_properties
, str
, mpctx
);
1657 void property_print_help(void)
1659 m_properties_print_help_list(mp_properties
);
1668 * \defgroup Command2Property Command to property bridge
1670 * It is used to handle most commands that just set a property
1671 * and optionally display something on the OSD.
1672 * Two kinds of commands are handled: adjust or toggle.
1674 * Adjust commands take 1 or 2 parameters: <value> <abs>
1675 * If <abs> is non-zero the property is set to the given value
1676 * otherwise it is adjusted.
1678 * Toggle commands take 0 or 1 parameters. With no parameter
1679 * or a value less than the property minimum it just steps the
1680 * property to its next value. Otherwise it sets it to the given
1686 /// List of the commands that can be handled by setting a property.
1692 /// set/adjust or toggle command
1694 /// progressbar type
1696 /// osd msg id if it must be shared
1698 /// osd msg template
1699 const char *osd_msg
;
1700 } set_prop_cmd
[] = {
1702 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
1704 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
1705 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
1706 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
1707 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
1708 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
1710 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
1711 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
1712 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
1713 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
1714 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
1715 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
1716 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
1717 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1718 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1719 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1720 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1721 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
1723 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
1724 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
1725 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
1726 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
1727 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
1728 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
1729 #ifdef HAVE_FREETYPE
1730 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
1733 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1734 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1735 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1736 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1738 { NULL
, 0, 0, 0, -1, NULL
}
1742 /// Handle commands that set a property.
1743 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1749 // look for the command
1750 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
1751 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
1753 if (!(pname
= set_prop_cmd
[i
].name
))
1756 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
1760 if (set_prop_cmd
[i
].toggle
) {
1762 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
1763 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
1765 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1766 } else if (cmd
->args
[1].v
.i
) //set
1767 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
1769 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
1774 if (set_prop_cmd
[i
].osd_progbar
) {
1775 if (prop
->type
== CONF_TYPE_INT
) {
1776 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
1777 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1778 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
1779 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
1781 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
1782 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1783 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
1785 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
1786 "Property use an unsupported type.\n");
1790 if (set_prop_cmd
[i
].osd_msg
) {
1791 char *val
= mp_property_print(pname
, mpctx
);
1793 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
1794 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
1795 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
1803 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1805 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
1806 sh_video_t
* const sh_video
= mpctx
->sh_video
;
1808 if (!set_property_command(mpctx
, cmd
))
1814 mpctx
->osd_show_percentage
= sh_video
->fps
;
1815 v
= cmd
->args
[0].v
.f
;
1816 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
1817 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
1820 mpctx
->osd_function
=
1821 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
1823 } else if (abs
) { /* Absolute seek by percentage */
1826 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
1827 rel_seek_secs
= v
/ 100.0;
1830 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
1836 case MP_CMD_SET_PROPERTY
:{
1837 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
1838 cmd
->args
[1].v
.s
, mpctx
);
1839 if (r
== M_PROPERTY_UNKNOWN
)
1840 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1841 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1843 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1844 "Failed to set property '%s' to '%s'.\n",
1845 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
1849 case MP_CMD_STEP_PROPERTY
:{
1854 if (cmd
->args
[1].v
.f
) {
1856 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
1857 M_PROPERTY_GET_TYPE
,
1858 &prop
, mpctx
)) <= 0)
1860 if(prop
->type
== CONF_TYPE_INT
||
1861 prop
->type
== CONF_TYPE_FLAG
)
1862 i
= cmd
->args
[1].v
.f
, arg
= &i
;
1863 else if(prop
->type
== CONF_TYPE_FLOAT
)
1864 arg
= &cmd
->args
[1].v
.f
;
1865 else if(prop
->type
== CONF_TYPE_DOUBLE
||
1866 prop
->type
== CONF_TYPE_TIME
)
1867 d
= cmd
->args
[1].v
.f
, arg
= &d
;
1868 else if(prop
->type
== CONF_TYPE_POSITION
)
1869 o
= cmd
->args
[1].v
.f
, arg
= &o
;
1871 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1872 "Ignoring step size stepping property '%s'.\n",
1875 r
= mp_property_do(cmd
->args
[0].v
.s
,
1876 cmd
->args
[2].v
.i
< 0 ?
1877 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
1880 if (r
== M_PROPERTY_UNKNOWN
)
1881 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1882 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1884 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1885 "Failed to increment property '%s' by %f.\n",
1886 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
1890 case MP_CMD_GET_PROPERTY
:{
1892 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
1893 &tmp
, mpctx
) <= 0) {
1894 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1895 "Failed to get value of property '%s'.\n",
1899 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
1900 cmd
->args
[0].v
.s
, tmp
);
1905 case MP_CMD_EDL_MARK
:
1907 float v
= sh_video
? sh_video
->pts
:
1908 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
1911 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
1912 mpctx
->begin_skip
= v
;
1913 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
1915 if (mpctx
->begin_skip
> v
)
1916 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
1918 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
1919 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
1921 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
1926 case MP_CMD_SWITCH_RATIO
:
1927 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
1928 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
1930 movie_aspect
= cmd
->args
[0].v
.f
;
1931 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
1934 case MP_CMD_SPEED_INCR
:{
1935 float v
= cmd
->args
[0].v
.f
;
1936 playback_speed
+= v
;
1937 build_afilter_chain(sh_audio
, &ao_data
);
1938 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
1942 case MP_CMD_SPEED_MULT
:{
1943 float v
= cmd
->args
[0].v
.f
;
1944 playback_speed
*= v
;
1945 build_afilter_chain(sh_audio
, &ao_data
);
1946 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
1950 case MP_CMD_SPEED_SET
:{
1951 float v
= cmd
->args
[0].v
.f
;
1953 build_afilter_chain(sh_audio
, &ao_data
);
1954 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
1958 case MP_CMD_FRAME_STEP
:
1964 case MP_CMD_FILE_FILTER
:
1965 file_filter
= cmd
->args
[0].v
.i
;
1969 exit_player_with_rc(MSGTR_Exit_quit
,
1970 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
1972 case MP_CMD_PLAY_TREE_STEP
:{
1973 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
1974 int force
= cmd
->args
[1].v
.i
;
1980 for (i
= 0; i
< n
; i
++)
1983 for (i
= 0; i
< -1 * n
; i
++)
1988 if (!force
&& mpctx
->playtree_iter
) {
1989 play_tree_iter_t
*i
=
1990 play_tree_iter_new_copy(mpctx
->playtree_iter
);
1991 if (play_tree_iter_step(i
, n
, 0) ==
1992 PLAY_TREE_ITER_ENTRY
)
1994 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
1995 play_tree_iter_free(i
);
1997 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
1999 mpctx
->play_tree_step
= n
;
2005 case MP_CMD_PLAY_TREE_UP_STEP
:{
2006 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2007 int force
= cmd
->args
[1].v
.i
;
2009 if (!force
&& mpctx
->playtree_iter
) {
2010 play_tree_iter_t
*i
=
2011 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2012 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2013 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2014 play_tree_iter_free(i
);
2016 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2021 case MP_CMD_PLAY_ALT_SRC_STEP
:
2022 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2023 int v
= cmd
->args
[0].v
.i
;
2025 && mpctx
->playtree_iter
->file
<
2026 mpctx
->playtree_iter
->num_files
)
2027 mpctx
->eof
= PT_NEXT_SRC
;
2028 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2029 mpctx
->eof
= PT_PREV_SRC
;
2034 case MP_CMD_SUB_STEP
:
2036 int movement
= cmd
->args
[0].v
.i
;
2037 step_sub(subdata
, sh_video
->pts
, movement
);
2041 ass_step_sub(ass_track
,
2043 sub_delay
) * 1000 + .5, movement
) / 1000.;
2045 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2046 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2050 case MP_CMD_SUB_LOG
:
2055 int v
= cmd
->args
[0].v
.i
;
2057 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2058 if (osd_level
> max
)
2061 osd_level
= (osd_level
+ 1) % (max
+ 1);
2063 osd_level
= v
> max
? max
: v
;
2064 /* Show OSD state when disabled, but not when an explicit
2065 argument is given to the OSD command, i.e. in slave mode. */
2066 if (v
== -1 && osd_level
<= 1)
2067 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2069 osd_level
? MSGTR_OSDenabled
:
2072 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2076 case MP_CMD_OSD_SHOW_TEXT
:
2077 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2079 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2080 "%-.63s", cmd
->args
[0].v
.s
);
2083 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2084 char *txt
= m_properties_expand_string(mp_properties
,
2087 /* if no argument supplied take default osd_duration, else <arg> ms. */
2089 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2091 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2098 case MP_CMD_LOADFILE
:{
2099 play_tree_t
*e
= play_tree_new();
2100 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2102 if (cmd
->args
[1].v
.i
) // append
2103 play_tree_append_entry(mpctx
->playtree
, e
);
2105 // Go back to the starting point.
2106 while (play_tree_iter_up_step
2107 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2109 play_tree_free_list(mpctx
->playtree
->child
, 1);
2110 play_tree_set_child(mpctx
->playtree
, e
);
2111 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2112 mpctx
->eof
= PT_NEXT_SRC
;
2118 case MP_CMD_LOADLIST
:{
2119 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2121 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2122 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2124 if (cmd
->args
[1].v
.i
) // append
2125 play_tree_append_entry(mpctx
->playtree
, e
);
2127 // Go back to the starting point.
2128 while (play_tree_iter_up_step
2129 (mpctx
->playtree_iter
, 0, 1)
2130 != PLAY_TREE_ITER_END
)
2132 play_tree_free_list(mpctx
->playtree
->child
, 1);
2133 play_tree_set_child(mpctx
->playtree
, e
);
2134 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2135 mpctx
->eof
= PT_NEXT_SRC
;
2143 case MP_CMD_RADIO_STEP_CHANNEL
:
2144 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2145 int v
= cmd
->args
[0].v
.i
;
2147 radio_step_channel(mpctx
->demuxer
->stream
,
2148 RADIO_CHANNEL_HIGHER
);
2150 radio_step_channel(mpctx
->demuxer
->stream
,
2151 RADIO_CHANNEL_LOWER
);
2152 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2153 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2155 radio_get_channel_name(mpctx
->demuxer
->stream
));
2160 case MP_CMD_RADIO_SET_CHANNEL
:
2161 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2162 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2163 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2164 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2166 radio_get_channel_name(mpctx
->demuxer
->stream
));
2171 case MP_CMD_RADIO_SET_FREQ
:
2172 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2173 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2176 case MP_CMD_RADIO_STEP_FREQ
:
2177 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2178 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2183 case MP_CMD_TV_SET_FREQ
:
2184 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2185 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2186 cmd
->args
[0].v
.f
* 16.0);
2188 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2189 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2190 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2191 pvr_get_current_channelname (mpctx
->stream
),
2192 pvr_get_current_stationname (mpctx
->stream
));
2194 #endif /* HAVE_PVR */
2197 case MP_CMD_TV_STEP_FREQ
:
2198 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2199 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2200 cmd
->args
[0].v
.f
* 16.0);
2202 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2203 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2204 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2205 pvr_get_current_channelname (mpctx
->stream
),
2206 pvr_get_current_frequency (mpctx
->stream
));
2208 #endif /* HAVE_PVR */
2211 case MP_CMD_TV_SET_NORM
:
2212 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2213 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2217 case MP_CMD_TV_STEP_CHANNEL
:{
2218 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2219 int v
= cmd
->args
[0].v
.i
;
2221 tv_step_channel((tvi_handle_t
*) (mpctx
->
2225 tv_step_channel((tvi_handle_t
*) (mpctx
->
2229 if (tv_channel_list
) {
2230 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2231 MSGTR_OSDChannel
, tv_channel_current
->name
);
2232 //vo_osd_changed(OSDTYPE_SUBTITLE);
2236 else if (mpctx
->stream
&&
2237 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2238 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2239 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2240 pvr_get_current_channelname (mpctx
->stream
),
2241 pvr_get_current_stationname (mpctx
->stream
));
2243 #endif /* HAVE_PVR */
2245 #ifdef HAS_DVBIN_SUPPORT
2246 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2247 && mpctx
->stream
->priv
) {
2248 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2251 int v
= cmd
->args
[0].v
.i
;
2253 mpctx
->last_dvb_step
= v
;
2255 dir
= DVB_CHANNEL_HIGHER
;
2257 dir
= DVB_CHANNEL_LOWER
;
2260 if (dvb_step_channel(priv
, dir
))
2261 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2264 #endif /* HAS_DVBIN_SUPPORT */
2267 case MP_CMD_TV_SET_CHANNEL
:
2268 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2269 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2271 if (tv_channel_list
) {
2272 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2273 MSGTR_OSDChannel
, tv_channel_current
->name
);
2274 //vo_osd_changed(OSDTYPE_SUBTITLE);
2278 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2279 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2280 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2281 pvr_get_current_channelname (mpctx
->stream
),
2282 pvr_get_current_stationname (mpctx
->stream
));
2284 #endif /* HAVE_PVR */
2287 #ifdef HAS_DVBIN_SUPPORT
2288 case MP_CMD_DVB_SET_CHANNEL
:
2289 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2290 && mpctx
->stream
->priv
) {
2291 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2293 if (priv
->list
->current
<= cmd
->args
[0].v
.i
)
2294 mpctx
->last_dvb_step
= 1;
2296 mpctx
->last_dvb_step
= -1;
2299 (priv
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2300 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2304 #endif /* HAS_DVBIN_SUPPORT */
2306 case MP_CMD_TV_LAST_CHANNEL
:
2307 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2308 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2309 if (tv_channel_list
) {
2310 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2311 MSGTR_OSDChannel
, tv_channel_current
->name
);
2312 //vo_osd_changed(OSDTYPE_SUBTITLE);
2316 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2317 pvr_set_lastchannel (mpctx
->stream
);
2318 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2319 pvr_get_current_channelname (mpctx
->stream
),
2320 pvr_get_current_stationname (mpctx
->stream
));
2322 #endif /* HAVE_PVR */
2325 case MP_CMD_TV_STEP_NORM
:
2326 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2327 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2330 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2331 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2332 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2336 case MP_CMD_SUB_LOAD
:
2338 int n
= mpctx
->set_of_sub_size
;
2339 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2340 if (n
!= mpctx
->set_of_sub_size
) {
2341 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2342 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2343 mpctx
->global_sub_size
;
2344 ++mpctx
->global_sub_size
;
2349 case MP_CMD_SUB_REMOVE
:
2351 int v
= cmd
->args
[0].v
.i
;
2354 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2355 subd
= mpctx
->set_of_subtitles
[v
];
2356 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2357 MSGTR_RemovedSubtitleFile
, v
+ 1,
2358 filename_recode(subd
->filename
));
2360 mpctx
->set_of_subtitles
[v
] = NULL
;
2362 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2363 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2364 mpctx
->set_of_sub_size
= 0;
2365 if (mpctx
->set_of_sub_pos
>= 0) {
2366 mpctx
->global_sub_pos
= -2;
2367 vo_sub_last
= vo_sub
= NULL
;
2368 vo_osd_changed(OSDTYPE_SUBTITLE
);
2369 vo_update_osd(sh_video
->disp_w
, sh_video
->disp_h
);
2370 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2372 } else if (v
< mpctx
->set_of_sub_size
) {
2373 subd
= mpctx
->set_of_subtitles
[v
];
2374 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2375 MSGTR_RemovedSubtitleFile
, v
+ 1,
2376 filename_recode(subd
->filename
));
2378 if (mpctx
->set_of_sub_pos
== v
) {
2379 mpctx
->global_sub_pos
= -2;
2380 vo_sub_last
= vo_sub
= NULL
;
2381 vo_osd_changed(OSDTYPE_SUBTITLE
);
2382 vo_update_osd(sh_video
->disp_w
, sh_video
->disp_h
);
2383 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2384 } else if (mpctx
->set_of_sub_pos
> v
) {
2385 --mpctx
->set_of_sub_pos
;
2386 --mpctx
->global_sub_pos
;
2388 while (++v
< mpctx
->set_of_sub_size
)
2389 mpctx
->set_of_subtitles
[v
- 1] =
2390 mpctx
->set_of_subtitles
[v
];
2391 --mpctx
->set_of_sub_size
;
2392 --mpctx
->global_sub_size
;
2393 if (mpctx
->set_of_sub_size
<= 0)
2394 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2395 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2400 case MP_CMD_GET_SUB_VISIBILITY
:
2402 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2403 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2407 case MP_CMD_SCREENSHOT
:
2408 if (vo_config_count
) {
2409 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2411 ((vf_instance_t
*) sh_video
->vfilter
)->
2412 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2414 mpctx
->video_out
->control(VOCTRL_SCREENSHOT
, NULL
);
2418 case MP_CMD_VF_CHANGE_RECTANGLE
:
2419 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2422 case MP_CMD_GET_TIME_LENGTH
:{
2423 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2424 demuxer_get_time_length(mpctx
->demuxer
));
2428 case MP_CMD_GET_FILENAME
:{
2429 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2430 get_metadata(META_NAME
));
2434 case MP_CMD_GET_VIDEO_CODEC
:{
2435 char *inf
= get_metadata(META_VIDEO_CODEC
);
2438 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2443 case MP_CMD_GET_VIDEO_BITRATE
:{
2444 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2447 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2452 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2453 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2456 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2457 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2462 case MP_CMD_GET_AUDIO_CODEC
:{
2463 char *inf
= get_metadata(META_AUDIO_CODEC
);
2466 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2471 case MP_CMD_GET_AUDIO_BITRATE
:{
2472 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2475 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2480 case MP_CMD_GET_AUDIO_SAMPLES
:{
2481 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2484 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2489 case MP_CMD_GET_META_TITLE
:{
2490 char *inf
= get_metadata(META_INFO_TITLE
);
2493 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2498 case MP_CMD_GET_META_ARTIST
:{
2499 char *inf
= get_metadata(META_INFO_ARTIST
);
2502 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2507 case MP_CMD_GET_META_ALBUM
:{
2508 char *inf
= get_metadata(META_INFO_ALBUM
);
2511 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2516 case MP_CMD_GET_META_YEAR
:{
2517 char *inf
= get_metadata(META_INFO_YEAR
);
2520 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2525 case MP_CMD_GET_META_COMMENT
:{
2526 char *inf
= get_metadata(META_INFO_COMMENT
);
2529 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2534 case MP_CMD_GET_META_TRACK
:{
2535 char *inf
= get_metadata(META_INFO_TRACK
);
2538 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2543 case MP_CMD_GET_META_GENRE
:{
2544 char *inf
= get_metadata(META_INFO_GENRE
);
2547 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
2552 case MP_CMD_GET_VO_FULLSCREEN
:
2553 if (mpctx
->video_out
&& vo_config_count
)
2554 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
2557 case MP_CMD_GET_PERCENT_POS
:
2558 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
2559 demuxer_get_percent_pos(mpctx
->demuxer
));
2562 case MP_CMD_GET_TIME_POS
:{
2565 pos
= sh_video
->pts
;
2566 else if (sh_audio
&& mpctx
->audio_out
)
2568 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2570 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
2577 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
2583 case MP_CMD_KEYDOWN_EVENTS
:
2584 mplayer_put_key(cmd
->args
[0].v
.i
);
2587 case MP_CMD_SEEK_CHAPTER
:{
2588 int seek
= cmd
->args
[0].v
.i
;
2589 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2598 demuxer_seek_chapter(mpctx
->demuxer
, seek
, abs
,
2599 &next_pts
, &num_chapters
,
2602 if (next_pts
> -1.0) {
2604 rel_seek_secs
= next_pts
;
2607 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2608 MSGTR_OSDChapter
, chap
+ 1, chapter_name
);
2613 rel_seek_secs
= 1000000000.;
2615 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2616 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
2622 case MP_CMD_SET_MOUSE_POS
:{
2623 int button
= -1, pointer_x
, pointer_y
;
2625 pointer_x
= cmd
->args
[0].v
.i
;
2626 pointer_y
= cmd
->args
[1].v
.i
;
2627 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
2629 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
2630 && dx
> 0.0 && dy
> 0.0) {
2631 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
2632 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
2633 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
2634 pointer_x
, pointer_y
, &button
);
2636 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2637 "Selected button number %d", button
);
2644 case MP_CMD_DVDNAV
:{
2646 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
2649 if (mp_dvdnav_handle_input
2650 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
2651 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
2652 (fixed_vo
? INITED_VO
: 0)));
2654 } else if (button
> 0)
2655 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2656 "Selected button number %d", button
);
2663 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
2664 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
2667 mp_msg(MSGT_CPLAYER
, MSGL_V
,
2668 "Received unknown cmd %s\n", cmd
->name
);
2671 switch (cmd
->pausing
) {
2672 case 1: // "pausing"
2673 mpctx
->osd_function
= OSD_PAUSE
;
2675 case 3: // "pausing_toggle"
2676 mpctx
->was_paused
= !mpctx
->was_paused
;
2678 case 2: // "pausing_keep"
2679 if (mpctx
->was_paused
)
2680 mpctx
->osd_function
= OSD_PAUSE
;