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 char *demux_lavf_sub_lang(demuxer_t
*demuxer
, int track_num
);
1154 /// Selected subtitles (RW)
1155 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1158 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1159 const int global_sub_size
= mpctx
->global_sub_size
;
1160 int source
= -1, reset_spu
= 0;
1163 if (global_sub_size
<= 0)
1164 return M_PROPERTY_UNAVAILABLE
;
1167 case M_PROPERTY_GET
:
1169 return M_PROPERTY_ERROR
;
1170 *(int *) arg
= mpctx
->global_sub_pos
;
1171 return M_PROPERTY_OK
;
1172 case M_PROPERTY_PRINT
:
1174 return M_PROPERTY_ERROR
;
1175 *(char **) arg
= malloc(64);
1176 (*(char **) arg
)[63] = 0;
1179 sub_name
= subdata
->filename
;
1181 if (ass_track
&& ass_track
->name
)
1182 sub_name
= ass_track
->name
;
1187 if ((tmp2
= strrchr(tmp
, '/')))
1190 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1191 mpctx
->set_of_sub_pos
+ 1,
1192 strlen(tmp
) < 20 ? "" : "...",
1193 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1194 return M_PROPERTY_OK
;
1197 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1198 if (vo_spudec
&& dvdsub_id
>= 0) {
1199 unsigned char lang
[3];
1200 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1201 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1202 return M_PROPERTY_OK
;
1208 #ifdef USE_LIBAVFORMAT
1209 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
&& dvdsub_id
>= 0) {
1210 char *lang
= demux_lavf_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1211 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1212 return M_PROPERTY_OK
;
1215 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1216 char lang
[40] = MSGTR_Unknown
;
1217 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1218 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1219 return M_PROPERTY_OK
;
1221 #ifdef HAVE_OGGVORBIS
1222 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1223 char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1225 lang
= MSGTR_Unknown
;
1226 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1227 return M_PROPERTY_OK
;
1230 if (vo_vobsub
&& vobsub_id
>= 0) {
1231 const char *language
= MSGTR_Unknown
;
1232 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1233 snprintf(*(char **) arg
, 63, "(%d) %s",
1234 vobsub_id
, language
? language
: MSGTR_Unknown
);
1235 return M_PROPERTY_OK
;
1238 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1239 && dvdsub_id
>= 0) {
1241 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1242 lang
[0] = code
>> 8;
1245 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1246 return M_PROPERTY_OK
;
1249 if (dvdsub_id
>= 0) {
1250 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1251 return M_PROPERTY_OK
;
1253 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1254 return M_PROPERTY_OK
;
1256 case M_PROPERTY_SET
:
1258 return M_PROPERTY_ERROR
;
1259 if (*(int *) arg
< -1)
1261 else if (*(int *) arg
>= global_sub_size
)
1262 *(int *) arg
= global_sub_size
- 1;
1263 mpctx
->global_sub_pos
= *(int *) arg
;
1265 case M_PROPERTY_STEP_UP
:
1266 mpctx
->global_sub_pos
+= 2;
1267 mpctx
->global_sub_pos
=
1268 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1270 case M_PROPERTY_STEP_DOWN
:
1271 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1272 mpctx
->global_sub_pos
=
1273 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1276 return M_PROPERTY_NOT_IMPLEMENTED
;
1279 if (mpctx
->global_sub_pos
>= 0)
1280 source
= sub_source(mpctx
);
1282 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1283 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1285 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1286 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1287 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1288 mpctx
->global_sub_pos
, source
);
1290 mpctx
->set_of_sub_pos
= -1;
1304 if (source
== SUB_SOURCE_VOBSUB
) {
1306 mpctx
->global_sub_pos
-
1307 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
];
1308 } else if (source
== SUB_SOURCE_SUBS
) {
1309 mpctx
->set_of_sub_pos
=
1310 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1312 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1313 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1317 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1318 vo_osd_changed(OSDTYPE_SUBTITLE
);
1320 } else if (source
== SUB_SOURCE_DEMUX
) {
1322 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1323 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1325 // default: assume 1:1 mapping of sid and stream id
1326 d_sub
->id
= dvdsub_id
;
1327 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1328 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1329 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1330 if (sh
&& sh
->sid
== dvdsub_id
) {
1336 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1337 sh_sub_t
*sh
= d_sub
->sh
;
1338 if (sh
->type
== 'v')
1341 else if (ass_enabled
&& sh
->type
== 'a')
1342 ass_track
= sh
->ass_track
;
1352 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1353 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1354 && dvdsub_id
< 0 && reset_spu
) {
1356 d_sub
->id
= dvdsub_id
;
1359 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1361 return M_PROPERTY_OK
;
1364 /// Subtitle delay (RW)
1365 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1368 if (!mpctx
->sh_video
)
1369 return M_PROPERTY_UNAVAILABLE
;
1370 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1373 /// Alignment of text subtitles (RW)
1374 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1375 void *arg
, MPContext
* mpctx
)
1377 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1379 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1380 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1381 return M_PROPERTY_UNAVAILABLE
;
1384 case M_PROPERTY_PRINT
:
1386 return M_PROPERTY_ERROR
;
1387 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1388 *(char **) arg
= strdup(name
[sub_alignment
]);
1389 return M_PROPERTY_OK
;
1390 case M_PROPERTY_SET
:
1392 return M_PROPERTY_ERROR
;
1393 case M_PROPERTY_STEP_UP
:
1394 case M_PROPERTY_STEP_DOWN
:
1395 vo_osd_changed(OSDTYPE_SUBTITLE
);
1397 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1401 /// Subtitle visibility (RW)
1402 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1403 void *arg
, MPContext
* mpctx
)
1405 if (!mpctx
->sh_video
)
1406 return M_PROPERTY_UNAVAILABLE
;
1409 case M_PROPERTY_SET
:
1411 return M_PROPERTY_ERROR
;
1412 case M_PROPERTY_STEP_UP
:
1413 case M_PROPERTY_STEP_DOWN
:
1414 vo_osd_changed(OSDTYPE_SUBTITLE
);
1416 vo_osd_changed(OSDTYPE_SPU
);
1418 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1422 /// Show only forced subtitles (RW)
1423 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1424 void *arg
, MPContext
* mpctx
)
1427 return M_PROPERTY_UNAVAILABLE
;
1430 case M_PROPERTY_SET
:
1432 return M_PROPERTY_ERROR
;
1433 case M_PROPERTY_STEP_UP
:
1434 case M_PROPERTY_STEP_DOWN
:
1435 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1436 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1437 return M_PROPERTY_OK
;
1439 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1444 #ifdef HAVE_FREETYPE
1445 /// Subtitle scale (RW)
1446 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1451 case M_PROPERTY_SET
:
1453 return M_PROPERTY_ERROR
;
1454 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1455 text_font_scale_factor
= *(float *) arg
;
1456 force_load_font
= 1;
1457 return M_PROPERTY_OK
;
1458 case M_PROPERTY_STEP_UP
:
1459 case M_PROPERTY_STEP_DOWN
:
1460 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1461 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1462 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1463 force_load_font
= 1;
1464 return M_PROPERTY_OK
;
1466 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1473 /// \defgroup TVProperties TV properties
1474 /// \ingroup Properties
1479 /// TV color settings (RW)
1480 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1484 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1485 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1486 return M_PROPERTY_UNAVAILABLE
;
1489 case M_PROPERTY_SET
:
1491 return M_PROPERTY_ERROR
;
1492 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1493 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1494 case M_PROPERTY_GET
:
1495 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1496 case M_PROPERTY_STEP_UP
:
1497 case M_PROPERTY_STEP_DOWN
:
1498 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1500 return M_PROPERTY_ERROR
;
1501 val
+= (arg
? *(int *) arg
: 1) *
1502 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1503 M_PROPERTY_CLAMP(prop
, val
);
1504 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1506 return M_PROPERTY_ERROR
;
1508 return M_PROPERTY_NOT_IMPLEMENTED
;
1513 #ifdef HAVE_TV_TELETEXT
1514 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1518 int base_ioctl
=(int)prop
->priv
;
1520 for teletext's GET,SET,STEP ioctls this is not 0
1524 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1525 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1526 return M_PROPERTY_UNAVAILABLE
;
1528 return M_PROPERTY_ERROR
;
1531 case M_PROPERTY_GET
:
1533 return M_PROPERTY_ERROR
;
1534 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1536 case M_PROPERTY_SET
:
1538 return M_PROPERTY_ERROR
;
1539 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1540 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1542 case M_PROPERTY_STEP_UP
:
1543 case M_PROPERTY_STEP_DOWN
:
1544 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1545 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1546 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1549 return M_PROPERTY_NOT_IMPLEMENTED
;
1552 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1555 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1558 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1562 //with tvh==NULL will fail too
1563 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1564 if(result
!=M_PROPERTY_OK
)
1567 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1568 mp_input_set_section("teletext");
1570 mp_input_set_section("tv");
1571 return M_PROPERTY_OK
;
1574 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1577 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1581 case M_PROPERTY_STEP_UP
:
1582 case M_PROPERTY_STEP_DOWN
:
1583 //This should be handled separately
1584 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1585 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1588 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1594 #endif /* HAVE_TV_TELETEXT */
1598 /// All properties available in MPlayer.
1599 /** \ingroup Properties
1601 static m_option_t mp_properties
[] = {
1603 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1604 M_OPT_RANGE
, 0, 3, NULL
},
1605 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1606 M_OPT_MIN
, -1, 0, NULL
},
1607 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1608 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1609 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1611 { "path", mp_property_path
, CONF_TYPE_STRING
,
1613 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1615 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1616 M_OPT_MIN
, 0, 0, NULL
},
1617 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1618 M_OPT_MIN
, 0, 0, NULL
},
1619 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1620 M_OPT_MIN
, 0, 0, NULL
},
1621 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1622 M_OPT_MIN
, 0, 0, NULL
},
1623 { "length", mp_property_length
, CONF_TYPE_TIME
,
1624 M_OPT_MIN
, 0, 0, NULL
},
1625 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1626 M_OPT_RANGE
, 0, 100, NULL
},
1627 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1628 M_OPT_MIN
, 0, 0, NULL
},
1629 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1633 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1634 M_OPT_RANGE
, 0, 100, NULL
},
1635 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1636 M_OPT_RANGE
, 0, 1, NULL
},
1637 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1638 M_OPT_RANGE
, -100, 100, NULL
},
1639 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1641 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1643 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1645 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1647 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1649 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1650 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1651 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
1652 M_OPT_RANGE
, -1, 1, NULL
},
1655 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1656 M_OPT_RANGE
, 0, 1, NULL
},
1657 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1658 M_OPT_RANGE
, 0, 1, NULL
},
1659 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1660 M_OPT_RANGE
, 0, 1, NULL
},
1661 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1662 M_OPT_RANGE
, 0, 1, NULL
},
1663 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1664 M_OPT_RANGE
, 0, 1, NULL
},
1665 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1666 M_OPT_RANGE
, 0, 2, NULL
},
1667 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1668 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1669 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1670 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1671 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1672 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1673 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
1674 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
1675 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
1676 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
1677 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
1678 M_OPT_RANGE
, 0, 1, NULL
},
1679 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
1680 M_OPT_RANGE
, 0, 1, NULL
},
1681 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
1683 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
1685 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
1687 { "width", mp_property_width
, CONF_TYPE_INT
,
1689 { "height", mp_property_height
, CONF_TYPE_INT
,
1691 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
1693 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
1695 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
1696 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
1697 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
1698 CONF_RANGE
, -1, 65535, NULL
},
1701 { "sub", mp_property_sub
, CONF_TYPE_INT
,
1702 M_OPT_MIN
, -1, 0, NULL
},
1703 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
1705 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
1706 M_OPT_RANGE
, 0, 100, NULL
},
1707 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
1708 M_OPT_RANGE
, 0, 2, NULL
},
1709 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
1710 M_OPT_RANGE
, 0, 1, NULL
},
1711 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
1712 M_OPT_RANGE
, 0, 1, NULL
},
1713 #ifdef HAVE_FREETYPE
1714 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
1715 M_OPT_RANGE
, 0, 100, NULL
},
1719 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
1720 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
1721 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
1722 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
1723 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
1724 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
1725 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
1726 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
1729 #ifdef HAVE_TV_TELETEXT
1730 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
1731 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
1732 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
1733 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
1734 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
1735 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
1736 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
1737 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
1738 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
1739 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
1742 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
1746 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
1748 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
1751 char* mp_property_print(const char *name
, void* ctx
)
1754 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
1759 char *property_expand_string(MPContext
* mpctx
, char *str
)
1761 return m_properties_expand_string(mp_properties
, str
, mpctx
);
1764 void property_print_help(void)
1766 m_properties_print_help_list(mp_properties
);
1775 * \defgroup Command2Property Command to property bridge
1777 * It is used to handle most commands that just set a property
1778 * and optionally display something on the OSD.
1779 * Two kinds of commands are handled: adjust or toggle.
1781 * Adjust commands take 1 or 2 parameters: <value> <abs>
1782 * If <abs> is non-zero the property is set to the given value
1783 * otherwise it is adjusted.
1785 * Toggle commands take 0 or 1 parameters. With no parameter
1786 * or a value less than the property minimum it just steps the
1787 * property to its next value. Otherwise it sets it to the given
1793 /// List of the commands that can be handled by setting a property.
1799 /// set/adjust or toggle command
1801 /// progressbar type
1803 /// osd msg id if it must be shared
1805 /// osd msg template
1806 const char *osd_msg
;
1807 } set_prop_cmd
[] = {
1809 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
1811 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
1812 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
1813 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
1814 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
1815 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
1817 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
1818 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
1819 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
1820 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
1821 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
1822 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
1823 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
1824 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1825 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1826 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1827 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1828 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
1830 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
1831 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
1832 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
1833 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
1834 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
1835 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
1836 #ifdef HAVE_FREETYPE
1837 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
1840 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1841 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1842 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1843 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1845 { NULL
, 0, 0, 0, -1, NULL
}
1849 /// Handle commands that set a property.
1850 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1856 // look for the command
1857 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
1858 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
1860 if (!(pname
= set_prop_cmd
[i
].name
))
1863 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
1867 if (set_prop_cmd
[i
].toggle
) {
1869 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
1870 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
1872 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1873 } else if (cmd
->args
[1].v
.i
) //set
1874 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
1876 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
1881 if (set_prop_cmd
[i
].osd_progbar
) {
1882 if (prop
->type
== CONF_TYPE_INT
) {
1883 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
1884 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1885 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
1886 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
1888 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
1889 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1890 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
1892 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
1893 "Property use an unsupported type.\n");
1897 if (set_prop_cmd
[i
].osd_msg
) {
1898 char *val
= mp_property_print(pname
, mpctx
);
1900 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
1901 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
1902 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
1910 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1912 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
1913 sh_video_t
* const sh_video
= mpctx
->sh_video
;
1915 if (!set_property_command(mpctx
, cmd
))
1921 mpctx
->osd_show_percentage
= sh_video
->fps
;
1922 v
= cmd
->args
[0].v
.f
;
1923 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
1924 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
1927 mpctx
->osd_function
=
1928 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
1930 } else if (abs
) { /* Absolute seek by percentage */
1933 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
1934 rel_seek_secs
= v
/ 100.0;
1937 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
1943 case MP_CMD_SET_PROPERTY
:{
1944 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
1945 cmd
->args
[1].v
.s
, mpctx
);
1946 if (r
== M_PROPERTY_UNKNOWN
)
1947 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1948 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1950 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1951 "Failed to set property '%s' to '%s'.\n",
1952 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
1956 case MP_CMD_STEP_PROPERTY
:{
1961 if (cmd
->args
[1].v
.f
) {
1963 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
1964 M_PROPERTY_GET_TYPE
,
1965 &prop
, mpctx
)) <= 0)
1967 if(prop
->type
== CONF_TYPE_INT
||
1968 prop
->type
== CONF_TYPE_FLAG
)
1969 i
= cmd
->args
[1].v
.f
, arg
= &i
;
1970 else if(prop
->type
== CONF_TYPE_FLOAT
)
1971 arg
= &cmd
->args
[1].v
.f
;
1972 else if(prop
->type
== CONF_TYPE_DOUBLE
||
1973 prop
->type
== CONF_TYPE_TIME
)
1974 d
= cmd
->args
[1].v
.f
, arg
= &d
;
1975 else if(prop
->type
== CONF_TYPE_POSITION
)
1976 o
= cmd
->args
[1].v
.f
, arg
= &o
;
1978 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1979 "Ignoring step size stepping property '%s'.\n",
1982 r
= mp_property_do(cmd
->args
[0].v
.s
,
1983 cmd
->args
[2].v
.i
< 0 ?
1984 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
1987 if (r
== M_PROPERTY_UNKNOWN
)
1988 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1989 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1991 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1992 "Failed to increment property '%s' by %f.\n",
1993 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
1997 case MP_CMD_GET_PROPERTY
:{
1999 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2000 &tmp
, mpctx
) <= 0) {
2001 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2002 "Failed to get value of property '%s'.\n",
2006 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2007 cmd
->args
[0].v
.s
, tmp
);
2012 case MP_CMD_EDL_MARK
:
2014 float v
= sh_video
? sh_video
->pts
:
2015 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2018 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2019 mpctx
->begin_skip
= v
;
2020 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2022 if (mpctx
->begin_skip
> v
)
2023 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2025 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2026 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2028 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2033 case MP_CMD_SWITCH_RATIO
:
2034 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2035 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2037 movie_aspect
= cmd
->args
[0].v
.f
;
2038 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2041 case MP_CMD_SPEED_INCR
:{
2042 float v
= cmd
->args
[0].v
.f
;
2043 playback_speed
+= v
;
2044 build_afilter_chain(sh_audio
, &ao_data
);
2045 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2049 case MP_CMD_SPEED_MULT
:{
2050 float v
= cmd
->args
[0].v
.f
;
2051 playback_speed
*= v
;
2052 build_afilter_chain(sh_audio
, &ao_data
);
2053 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2057 case MP_CMD_SPEED_SET
:{
2058 float v
= cmd
->args
[0].v
.f
;
2060 build_afilter_chain(sh_audio
, &ao_data
);
2061 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2065 case MP_CMD_FRAME_STEP
:
2071 case MP_CMD_FILE_FILTER
:
2072 file_filter
= cmd
->args
[0].v
.i
;
2076 exit_player_with_rc(MSGTR_Exit_quit
,
2077 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2079 case MP_CMD_PLAY_TREE_STEP
:{
2080 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2081 int force
= cmd
->args
[1].v
.i
;
2087 for (i
= 0; i
< n
; i
++)
2090 for (i
= 0; i
< -1 * n
; i
++)
2095 if (!force
&& mpctx
->playtree_iter
) {
2096 play_tree_iter_t
*i
=
2097 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2098 if (play_tree_iter_step(i
, n
, 0) ==
2099 PLAY_TREE_ITER_ENTRY
)
2101 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2102 play_tree_iter_free(i
);
2104 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2106 mpctx
->play_tree_step
= n
;
2112 case MP_CMD_PLAY_TREE_UP_STEP
:{
2113 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2114 int force
= cmd
->args
[1].v
.i
;
2116 if (!force
&& mpctx
->playtree_iter
) {
2117 play_tree_iter_t
*i
=
2118 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2119 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2120 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2121 play_tree_iter_free(i
);
2123 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2128 case MP_CMD_PLAY_ALT_SRC_STEP
:
2129 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2130 int v
= cmd
->args
[0].v
.i
;
2132 && mpctx
->playtree_iter
->file
<
2133 mpctx
->playtree_iter
->num_files
)
2134 mpctx
->eof
= PT_NEXT_SRC
;
2135 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2136 mpctx
->eof
= PT_PREV_SRC
;
2141 case MP_CMD_SUB_STEP
:
2143 int movement
= cmd
->args
[0].v
.i
;
2144 step_sub(subdata
, sh_video
->pts
, movement
);
2148 ass_step_sub(ass_track
,
2150 sub_delay
) * 1000 + .5, movement
) / 1000.;
2152 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2153 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2157 case MP_CMD_SUB_LOG
:
2162 int v
= cmd
->args
[0].v
.i
;
2164 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2165 if (osd_level
> max
)
2168 osd_level
= (osd_level
+ 1) % (max
+ 1);
2170 osd_level
= v
> max
? max
: v
;
2171 /* Show OSD state when disabled, but not when an explicit
2172 argument is given to the OSD command, i.e. in slave mode. */
2173 if (v
== -1 && osd_level
<= 1)
2174 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2176 osd_level
? MSGTR_OSDenabled
:
2179 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2183 case MP_CMD_OSD_SHOW_TEXT
:
2184 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2186 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2187 "%-.63s", cmd
->args
[0].v
.s
);
2190 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2191 char *txt
= m_properties_expand_string(mp_properties
,
2194 /* if no argument supplied take default osd_duration, else <arg> ms. */
2196 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2198 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2205 case MP_CMD_LOADFILE
:{
2206 play_tree_t
*e
= play_tree_new();
2207 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2209 if (cmd
->args
[1].v
.i
) // append
2210 play_tree_append_entry(mpctx
->playtree
, e
);
2212 // Go back to the starting point.
2213 while (play_tree_iter_up_step
2214 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2216 play_tree_free_list(mpctx
->playtree
->child
, 1);
2217 play_tree_set_child(mpctx
->playtree
, e
);
2218 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2219 mpctx
->eof
= PT_NEXT_SRC
;
2225 case MP_CMD_LOADLIST
:{
2226 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2228 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2229 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2231 if (cmd
->args
[1].v
.i
) // append
2232 play_tree_append_entry(mpctx
->playtree
, e
);
2234 // Go back to the starting point.
2235 while (play_tree_iter_up_step
2236 (mpctx
->playtree_iter
, 0, 1)
2237 != PLAY_TREE_ITER_END
)
2239 play_tree_free_list(mpctx
->playtree
->child
, 1);
2240 play_tree_set_child(mpctx
->playtree
, e
);
2241 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2242 mpctx
->eof
= PT_NEXT_SRC
;
2250 case MP_CMD_RADIO_STEP_CHANNEL
:
2251 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2252 int v
= cmd
->args
[0].v
.i
;
2254 radio_step_channel(mpctx
->demuxer
->stream
,
2255 RADIO_CHANNEL_HIGHER
);
2257 radio_step_channel(mpctx
->demuxer
->stream
,
2258 RADIO_CHANNEL_LOWER
);
2259 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2260 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2262 radio_get_channel_name(mpctx
->demuxer
->stream
));
2267 case MP_CMD_RADIO_SET_CHANNEL
:
2268 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2269 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2270 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2271 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2273 radio_get_channel_name(mpctx
->demuxer
->stream
));
2278 case MP_CMD_RADIO_SET_FREQ
:
2279 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2280 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2283 case MP_CMD_RADIO_STEP_FREQ
:
2284 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2285 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2290 case MP_CMD_TV_SET_FREQ
:
2291 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2292 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2293 cmd
->args
[0].v
.f
* 16.0);
2295 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2296 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2297 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2298 pvr_get_current_channelname (mpctx
->stream
),
2299 pvr_get_current_stationname (mpctx
->stream
));
2301 #endif /* HAVE_PVR */
2304 case MP_CMD_TV_STEP_FREQ
:
2305 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2306 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2307 cmd
->args
[0].v
.f
* 16.0);
2309 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2310 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2311 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2312 pvr_get_current_channelname (mpctx
->stream
),
2313 pvr_get_current_frequency (mpctx
->stream
));
2315 #endif /* HAVE_PVR */
2318 case MP_CMD_TV_SET_NORM
:
2319 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2320 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2324 case MP_CMD_TV_STEP_CHANNEL
:{
2325 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2326 int v
= cmd
->args
[0].v
.i
;
2328 tv_step_channel((tvi_handle_t
*) (mpctx
->
2332 tv_step_channel((tvi_handle_t
*) (mpctx
->
2336 if (tv_channel_list
) {
2337 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2338 MSGTR_OSDChannel
, tv_channel_current
->name
);
2339 //vo_osd_changed(OSDTYPE_SUBTITLE);
2343 else if (mpctx
->stream
&&
2344 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2345 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2346 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2347 pvr_get_current_channelname (mpctx
->stream
),
2348 pvr_get_current_stationname (mpctx
->stream
));
2350 #endif /* HAVE_PVR */
2352 #ifdef HAS_DVBIN_SUPPORT
2353 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2354 && mpctx
->stream
->priv
) {
2355 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2358 int v
= cmd
->args
[0].v
.i
;
2360 mpctx
->last_dvb_step
= v
;
2362 dir
= DVB_CHANNEL_HIGHER
;
2364 dir
= DVB_CHANNEL_LOWER
;
2367 if (dvb_step_channel(priv
, dir
))
2368 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2371 #endif /* HAS_DVBIN_SUPPORT */
2374 case MP_CMD_TV_SET_CHANNEL
:
2375 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2376 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2378 if (tv_channel_list
) {
2379 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2380 MSGTR_OSDChannel
, tv_channel_current
->name
);
2381 //vo_osd_changed(OSDTYPE_SUBTITLE);
2385 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2386 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2387 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2388 pvr_get_current_channelname (mpctx
->stream
),
2389 pvr_get_current_stationname (mpctx
->stream
));
2391 #endif /* HAVE_PVR */
2394 #ifdef HAS_DVBIN_SUPPORT
2395 case MP_CMD_DVB_SET_CHANNEL
:
2396 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2397 && mpctx
->stream
->priv
) {
2398 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2400 if (priv
->list
->current
<= cmd
->args
[0].v
.i
)
2401 mpctx
->last_dvb_step
= 1;
2403 mpctx
->last_dvb_step
= -1;
2406 (priv
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2407 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2411 #endif /* HAS_DVBIN_SUPPORT */
2413 case MP_CMD_TV_LAST_CHANNEL
:
2414 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2415 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2416 if (tv_channel_list
) {
2417 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2418 MSGTR_OSDChannel
, tv_channel_current
->name
);
2419 //vo_osd_changed(OSDTYPE_SUBTITLE);
2423 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2424 pvr_set_lastchannel (mpctx
->stream
);
2425 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2426 pvr_get_current_channelname (mpctx
->stream
),
2427 pvr_get_current_stationname (mpctx
->stream
));
2429 #endif /* HAVE_PVR */
2432 case MP_CMD_TV_STEP_NORM
:
2433 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2434 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2437 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2438 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2439 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2441 #ifdef HAVE_TV_TELETEXT
2442 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2444 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2445 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2446 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2449 #endif /* HAVE_TV_TELETEXT */
2452 case MP_CMD_SUB_LOAD
:
2454 int n
= mpctx
->set_of_sub_size
;
2455 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2456 if (n
!= mpctx
->set_of_sub_size
) {
2457 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2458 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2459 mpctx
->global_sub_size
;
2460 ++mpctx
->global_sub_size
;
2465 case MP_CMD_SUB_REMOVE
:
2467 int v
= cmd
->args
[0].v
.i
;
2470 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2471 subd
= mpctx
->set_of_subtitles
[v
];
2472 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2473 MSGTR_RemovedSubtitleFile
, v
+ 1,
2474 filename_recode(subd
->filename
));
2476 mpctx
->set_of_subtitles
[v
] = NULL
;
2478 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2479 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2480 mpctx
->set_of_sub_size
= 0;
2481 if (mpctx
->set_of_sub_pos
>= 0) {
2482 mpctx
->global_sub_pos
= -2;
2484 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2486 } else if (v
< mpctx
->set_of_sub_size
) {
2487 subd
= mpctx
->set_of_subtitles
[v
];
2488 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2489 MSGTR_RemovedSubtitleFile
, v
+ 1,
2490 filename_recode(subd
->filename
));
2492 if (mpctx
->set_of_sub_pos
== v
) {
2493 mpctx
->global_sub_pos
= -2;
2495 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2496 } else if (mpctx
->set_of_sub_pos
> v
) {
2497 --mpctx
->set_of_sub_pos
;
2498 --mpctx
->global_sub_pos
;
2500 while (++v
< mpctx
->set_of_sub_size
)
2501 mpctx
->set_of_subtitles
[v
- 1] =
2502 mpctx
->set_of_subtitles
[v
];
2503 --mpctx
->set_of_sub_size
;
2504 --mpctx
->global_sub_size
;
2505 if (mpctx
->set_of_sub_size
<= 0)
2506 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2507 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2512 case MP_CMD_GET_SUB_VISIBILITY
:
2514 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2515 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2519 case MP_CMD_SCREENSHOT
:
2520 if (vo_config_count
) {
2521 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2523 ((vf_instance_t
*) sh_video
->vfilter
)->
2524 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2526 mpctx
->video_out
->control(VOCTRL_SCREENSHOT
, NULL
);
2530 case MP_CMD_VF_CHANGE_RECTANGLE
:
2531 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2534 case MP_CMD_GET_TIME_LENGTH
:{
2535 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2536 demuxer_get_time_length(mpctx
->demuxer
));
2540 case MP_CMD_GET_FILENAME
:{
2541 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2542 get_metadata(META_NAME
));
2546 case MP_CMD_GET_VIDEO_CODEC
:{
2547 char *inf
= get_metadata(META_VIDEO_CODEC
);
2550 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2555 case MP_CMD_GET_VIDEO_BITRATE
:{
2556 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2559 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2564 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2565 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2568 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2569 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2574 case MP_CMD_GET_AUDIO_CODEC
:{
2575 char *inf
= get_metadata(META_AUDIO_CODEC
);
2578 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2583 case MP_CMD_GET_AUDIO_BITRATE
:{
2584 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2587 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2592 case MP_CMD_GET_AUDIO_SAMPLES
:{
2593 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2596 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2601 case MP_CMD_GET_META_TITLE
:{
2602 char *inf
= get_metadata(META_INFO_TITLE
);
2605 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2610 case MP_CMD_GET_META_ARTIST
:{
2611 char *inf
= get_metadata(META_INFO_ARTIST
);
2614 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2619 case MP_CMD_GET_META_ALBUM
:{
2620 char *inf
= get_metadata(META_INFO_ALBUM
);
2623 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2628 case MP_CMD_GET_META_YEAR
:{
2629 char *inf
= get_metadata(META_INFO_YEAR
);
2632 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2637 case MP_CMD_GET_META_COMMENT
:{
2638 char *inf
= get_metadata(META_INFO_COMMENT
);
2641 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2646 case MP_CMD_GET_META_TRACK
:{
2647 char *inf
= get_metadata(META_INFO_TRACK
);
2650 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2655 case MP_CMD_GET_META_GENRE
:{
2656 char *inf
= get_metadata(META_INFO_GENRE
);
2659 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
2664 case MP_CMD_GET_VO_FULLSCREEN
:
2665 if (mpctx
->video_out
&& vo_config_count
)
2666 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
2669 case MP_CMD_GET_PERCENT_POS
:
2670 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
2671 demuxer_get_percent_pos(mpctx
->demuxer
));
2674 case MP_CMD_GET_TIME_POS
:{
2677 pos
= sh_video
->pts
;
2678 else if (sh_audio
&& mpctx
->audio_out
)
2680 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2682 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
2689 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
2695 case MP_CMD_KEYDOWN_EVENTS
:
2696 mplayer_put_key(cmd
->args
[0].v
.i
);
2699 case MP_CMD_SEEK_CHAPTER
:{
2700 int seek
= cmd
->args
[0].v
.i
;
2701 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2710 demuxer_seek_chapter(mpctx
->demuxer
, seek
, abs
,
2711 &next_pts
, &num_chapters
,
2714 if (next_pts
> -1.0) {
2716 rel_seek_secs
= next_pts
;
2719 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2720 MSGTR_OSDChapter
, chap
+ 1, chapter_name
);
2725 rel_seek_secs
= 1000000000.;
2727 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2728 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
2734 case MP_CMD_SET_MOUSE_POS
:{
2735 int button
= -1, pointer_x
, pointer_y
;
2737 pointer_x
= cmd
->args
[0].v
.i
;
2738 pointer_y
= cmd
->args
[1].v
.i
;
2739 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
2741 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
2742 && dx
> 0.0 && dy
> 0.0) {
2743 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
2744 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
2745 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
2746 pointer_x
, pointer_y
, &button
);
2748 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2749 "Selected button number %d", button
);
2756 case MP_CMD_DVDNAV
:{
2758 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
2761 if (mp_dvdnav_handle_input
2762 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
2763 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
2764 (fixed_vo
? INITED_VO
: 0)));
2766 } else if (button
> 0)
2767 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2768 "Selected button number %d", button
);
2775 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
2776 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
2779 mp_msg(MSGT_CPLAYER
, MSGL_V
,
2780 "Received unknown cmd %s\n", cmd
->name
);
2783 switch (cmd
->pausing
) {
2784 case 1: // "pausing"
2785 mpctx
->osd_function
= OSD_PAUSE
;
2787 case 3: // "pausing_toggle"
2788 mpctx
->was_paused
= !mpctx
->was_paused
;
2790 case 2: // "pausing_keep"
2791 if (mpctx
->was_paused
)
2792 mpctx
->osd_function
= OSD_PAUSE
;