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"
33 #include "stream/tv.h"
36 #include "stream/stream_radio.h"
39 #include "stream/pvr.h"
41 #ifdef HAS_DVBIN_SUPPORT
42 #include "stream/dvbin.h"
45 #include "stream/stream_dvd.h"
48 #include "stream/stream_dvdnav.h"
51 #include "libass/ass.h"
52 #include "libass/ass_mp.h"
55 #include "gui/interface.h"
61 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
63 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
65 //remove the borders, if any, and rescale to the range [0,1],[0,1]
66 if (vo_fs
) { //we are in full-screen mode
67 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
68 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
69 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
70 iy
-= (vo_screenheight
- vo_dheight
) / 2;
72 if (ix
< 0 || ix
> vo_dwidth
) {
75 } //we are on one of the borders
76 if (iy
< 0 || iy
> vo_dheight
) {
79 } //we are on one of the borders
82 *dx
= (double) ix
/ (double) vo_dwidth
;
83 *dy
= (double) iy
/ (double) vo_dheight
;
85 mp_msg(MSGT_CPLAYER
, MSGL_V
,
86 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
87 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
91 static int sub_source(MPContext
* mpctx
)
96 for (i
= 0; i
< SUB_SOURCES
; i
++) {
97 int j
= mpctx
->global_sub_indices
[i
];
98 if ((j
>= 0) && (j
> top
) && (mpctx
->global_sub_pos
>= j
)) {
107 * \brief Log the currently displayed subtitle to a file
109 * Logs the current or last displayed subtitle together with filename
110 * and time information to ~/.mplayer/subtitle_log
112 * Intended purpose is to allow convenient marking of bogus subtitles
113 * which need to be fixed while watching the movie.
116 static void log_sub(void)
122 if (subdata
== NULL
|| vo_sub_last
== NULL
)
124 fname
= get_path("subtitle_log");
125 f
= fopen(fname
, "a");
128 fprintf(f
, "----------------------------------------------------------\n");
129 if (subdata
->sub_uses_time
) {
131 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
132 filename
, vo_sub_last
->start
/ 360000,
133 (vo_sub_last
->start
/ 6000) % 60,
134 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
135 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
136 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
138 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
141 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
142 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
148 /// \defgroup Properties
151 /// \defgroup GeneralProperties General properties
152 /// \ingroup Properties
156 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
159 return m_property_choice(prop
, action
, arg
, &osd_level
);
163 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
167 case M_PROPERTY_PRINT
:
168 if (!arg
) return M_PROPERTY_ERROR
;
169 if (mpctx
->loop_times
< 0)
170 *(char**)arg
= strdup("off");
171 else if (mpctx
->loop_times
== 0)
172 *(char**)arg
= strdup("inf");
175 return M_PROPERTY_OK
;
177 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
180 /// Playback speed (RW)
181 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
182 void *arg
, MPContext
* mpctx
)
187 return M_PROPERTY_ERROR
;
188 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
189 playback_speed
= *(float *) arg
;
190 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
191 return M_PROPERTY_OK
;
192 case M_PROPERTY_STEP_UP
:
193 case M_PROPERTY_STEP_DOWN
:
194 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
195 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
196 M_PROPERTY_CLAMP(prop
, playback_speed
);
197 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
198 return M_PROPERTY_OK
;
200 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
203 /// filename with path (RO)
204 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
207 return m_property_string_ro(prop
, action
, arg
, filename
);
210 /// filename without path (RO)
211 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
216 return M_PROPERTY_UNAVAILABLE
;
217 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
221 return m_property_string_ro(prop
, action
, arg
, f
);
224 /// Demuxer name (RO)
225 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
229 return M_PROPERTY_UNAVAILABLE
;
230 return m_property_string_ro(prop
, action
, arg
,
231 (char *) mpctx
->demuxer
->desc
->name
);
234 /// Position in the stream (RW)
235 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
238 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
239 return M_PROPERTY_UNAVAILABLE
;
241 return M_PROPERTY_ERROR
;
244 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
245 return M_PROPERTY_OK
;
247 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
248 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
249 return M_PROPERTY_OK
;
251 return M_PROPERTY_NOT_IMPLEMENTED
;
254 /// Stream start offset (RO)
255 static int mp_property_stream_start(m_option_t
* prop
, int action
,
256 void *arg
, MPContext
* mpctx
)
258 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
259 return M_PROPERTY_UNAVAILABLE
;
262 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
263 return M_PROPERTY_OK
;
265 return M_PROPERTY_NOT_IMPLEMENTED
;
268 /// Stream end offset (RO)
269 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
272 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
273 return M_PROPERTY_UNAVAILABLE
;
276 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
277 return M_PROPERTY_OK
;
279 return M_PROPERTY_NOT_IMPLEMENTED
;
282 /// Stream length (RO)
283 static int mp_property_stream_length(m_option_t
* prop
, int action
,
284 void *arg
, MPContext
* mpctx
)
286 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
287 return M_PROPERTY_UNAVAILABLE
;
291 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
292 return M_PROPERTY_OK
;
294 return M_PROPERTY_NOT_IMPLEMENTED
;
297 /// Media length in seconds (RO)
298 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
303 if (!mpctx
->demuxer
||
304 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
305 return M_PROPERTY_UNAVAILABLE
;
307 return m_property_time_ro(prop
, action
, arg
, len
);
310 /// Current position in percent (RW)
311 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
312 void *arg
, MPContext
* mpctx
) {
316 return M_PROPERTY_UNAVAILABLE
;
320 if(!arg
) return M_PROPERTY_ERROR
;
321 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
324 case M_PROPERTY_STEP_UP
:
325 case M_PROPERTY_STEP_DOWN
:
326 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
327 pos
+= (arg
? *(int*)arg
: 10) *
328 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
329 M_PROPERTY_CLAMP(prop
, pos
);
332 return m_property_int_ro(prop
, action
, arg
,
333 demuxer_get_percent_pos(mpctx
->demuxer
));
337 rel_seek_secs
= pos
/ 100.0;
338 return M_PROPERTY_OK
;
341 /// Current position in seconds (RW)
342 static int mp_property_time_pos(m_option_t
* prop
, int action
,
343 void *arg
, MPContext
* mpctx
) {
344 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
345 return M_PROPERTY_UNAVAILABLE
;
349 if(!arg
) return M_PROPERTY_ERROR
;
350 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
352 rel_seek_secs
= *(double*)arg
;
353 return M_PROPERTY_OK
;
354 case M_PROPERTY_STEP_UP
:
355 case M_PROPERTY_STEP_DOWN
:
356 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
357 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
358 return M_PROPERTY_OK
;
360 return m_property_time_ro(prop
, action
, arg
,
361 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
362 playing_audio_pts(mpctx
->sh_audio
,
367 /// Demuxer meta data
368 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
370 m_property_action_t
* ka
;
372 static m_option_t key_type
=
373 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
375 return M_PROPERTY_UNAVAILABLE
;
379 if(!arg
) return M_PROPERTY_ERROR
;
380 *(char***)arg
= mpctx
->demuxer
->info
;
381 return M_PROPERTY_OK
;
382 case M_PROPERTY_KEY_ACTION
:
383 if(!arg
) return M_PROPERTY_ERROR
;
385 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
386 return M_PROPERTY_UNKNOWN
;
389 if(!ka
->arg
) return M_PROPERTY_ERROR
;
390 *(char**)ka
->arg
= meta
;
391 return M_PROPERTY_OK
;
392 case M_PROPERTY_GET_TYPE
:
393 if(!ka
->arg
) return M_PROPERTY_ERROR
;
394 *(m_option_t
**)ka
->arg
= &key_type
;
395 return M_PROPERTY_OK
;
398 return M_PROPERTY_NOT_IMPLEMENTED
;
404 /// \defgroup AudioProperties Audio properties
405 /// \ingroup Properties
409 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
413 if (!mpctx
->sh_audio
)
414 return M_PROPERTY_UNAVAILABLE
;
419 return M_PROPERTY_ERROR
;
420 mixer_getbothvolume(&mpctx
->mixer
, arg
);
421 return M_PROPERTY_OK
;
422 case M_PROPERTY_PRINT
:{
425 return M_PROPERTY_ERROR
;
426 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
427 return m_property_float_range(prop
, action
, arg
, &vol
);
429 case M_PROPERTY_STEP_UP
:
430 case M_PROPERTY_STEP_DOWN
:
434 return M_PROPERTY_NOT_IMPLEMENTED
;
437 if (mpctx
->edl_muted
)
438 return M_PROPERTY_DISABLED
;
439 mpctx
->user_muted
= 0;
444 return M_PROPERTY_ERROR
;
445 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
446 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
447 return M_PROPERTY_OK
;
448 case M_PROPERTY_STEP_UP
:
449 if (arg
&& *(float *) arg
<= 0)
450 mixer_decvolume(&mpctx
->mixer
);
452 mixer_incvolume(&mpctx
->mixer
);
453 return M_PROPERTY_OK
;
454 case M_PROPERTY_STEP_DOWN
:
455 if (arg
&& *(float *) arg
<= 0)
456 mixer_incvolume(&mpctx
->mixer
);
458 mixer_decvolume(&mpctx
->mixer
);
459 return M_PROPERTY_OK
;
461 return M_PROPERTY_NOT_IMPLEMENTED
;
465 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
469 if (!mpctx
->sh_audio
)
470 return M_PROPERTY_UNAVAILABLE
;
474 if (mpctx
->edl_muted
)
475 return M_PROPERTY_DISABLED
;
477 return M_PROPERTY_ERROR
;
478 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
479 mixer_mute(&mpctx
->mixer
);
480 mpctx
->user_muted
= mpctx
->mixer
.muted
;
481 return M_PROPERTY_OK
;
482 case M_PROPERTY_STEP_UP
:
483 case M_PROPERTY_STEP_DOWN
:
484 if (mpctx
->edl_muted
)
485 return M_PROPERTY_DISABLED
;
486 mixer_mute(&mpctx
->mixer
);
487 mpctx
->user_muted
= mpctx
->mixer
.muted
;
488 return M_PROPERTY_OK
;
489 case M_PROPERTY_PRINT
:
491 return M_PROPERTY_ERROR
;
492 if (mpctx
->edl_muted
) {
493 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
494 return M_PROPERTY_OK
;
497 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
503 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
504 void *arg
, MPContext
* mpctx
)
506 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
507 return M_PROPERTY_UNAVAILABLE
;
510 case M_PROPERTY_STEP_UP
:
511 case M_PROPERTY_STEP_DOWN
:
513 return M_PROPERTY_ERROR
;
515 float delay
= audio_delay
;
516 m_property_delay(prop
, action
, arg
, &audio_delay
);
518 mpctx
->delay
-= audio_delay
- delay
;
520 return M_PROPERTY_OK
;
522 return m_property_delay(prop
, action
, arg
, &audio_delay
);
526 /// Audio codec tag (RO)
527 static int mp_property_audio_format(m_option_t
* prop
, int action
,
528 void *arg
, MPContext
* mpctx
)
530 if (!mpctx
->sh_audio
)
531 return M_PROPERTY_UNAVAILABLE
;
532 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
535 /// Audio codec name (RO)
536 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
537 void *arg
, MPContext
* mpctx
)
539 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
540 return M_PROPERTY_UNAVAILABLE
;
541 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
544 /// Audio bitrate (RO)
545 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
546 void *arg
, MPContext
* mpctx
)
548 if (!mpctx
->sh_audio
)
549 return M_PROPERTY_UNAVAILABLE
;
550 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
554 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
557 if (!mpctx
->sh_audio
)
558 return M_PROPERTY_UNAVAILABLE
;
560 case M_PROPERTY_PRINT
:
561 if(!arg
) return M_PROPERTY_ERROR
;
562 *(char**)arg
= malloc(16);
563 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
564 return M_PROPERTY_OK
;
566 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
569 /// Number of channels (RO)
570 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
573 if (!mpctx
->sh_audio
)
574 return M_PROPERTY_UNAVAILABLE
;
576 case M_PROPERTY_PRINT
:
578 return M_PROPERTY_ERROR
;
579 switch (mpctx
->sh_audio
->channels
) {
581 *(char **) arg
= strdup("mono");
584 *(char **) arg
= strdup("stereo");
587 *(char **) arg
= malloc(32);
588 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
590 return M_PROPERTY_OK
;
592 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
596 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
601 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
602 return M_PROPERTY_UNAVAILABLE
;
607 return M_PROPERTY_ERROR
;
608 mixer_getbalance(&mpctx
->mixer
, arg
);
609 return M_PROPERTY_OK
;
610 case M_PROPERTY_PRINT
: {
613 return M_PROPERTY_ERROR
;
614 mixer_getbalance(&mpctx
->mixer
, &bal
);
616 *str
= strdup("center");
617 else if (bal
== -1.f
)
618 *str
= strdup("left only");
620 *str
= strdup("right only");
622 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
623 *str
= malloc(sizeof("left xxx%, right xxx%"));
624 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
626 return M_PROPERTY_OK
;
628 case M_PROPERTY_STEP_UP
:
629 case M_PROPERTY_STEP_DOWN
:
630 mixer_getbalance(&mpctx
->mixer
, &bal
);
631 bal
+= (arg
? *(float*)arg
: .1f
) *
632 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
633 M_PROPERTY_CLAMP(prop
, bal
);
634 mixer_setbalance(&mpctx
->mixer
, bal
);
635 return M_PROPERTY_OK
;
638 return M_PROPERTY_ERROR
;
639 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
640 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
641 return M_PROPERTY_OK
;
643 return M_PROPERTY_NOT_IMPLEMENTED
;
646 /// Selected audio id (RW)
647 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
650 int current_id
= -1, tmp
;
654 if (!mpctx
->sh_audio
)
655 return M_PROPERTY_UNAVAILABLE
;
657 return M_PROPERTY_ERROR
;
658 *(int *) arg
= audio_id
;
659 return M_PROPERTY_OK
;
660 case M_PROPERTY_PRINT
:
661 if (!mpctx
->sh_audio
)
662 return M_PROPERTY_UNAVAILABLE
;
664 return M_PROPERTY_ERROR
;
667 *(char **) arg
= strdup(MSGTR_Disabled
);
669 char lang
[40] = MSGTR_Unknown
;
670 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
671 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
673 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
674 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
684 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
685 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
687 *(char **) arg
= malloc(64);
688 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
690 return M_PROPERTY_OK
;
692 case M_PROPERTY_STEP_UP
:
694 if (action
== M_PROPERTY_SET
&& arg
)
695 tmp
= *((int *) arg
);
698 current_id
= mpctx
->demuxer
->audio
->id
;
699 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
702 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
703 uninit_player(INITED_AO
| INITED_ACODEC
);
704 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
706 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
708 sh2
->ds
= mpctx
->demuxer
->audio
;
709 mpctx
->sh_audio
= sh2
;
710 reinit_audio_chain();
713 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
714 return M_PROPERTY_OK
;
716 return M_PROPERTY_NOT_IMPLEMENTED
;
721 /// Selected video id (RW)
722 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
725 int current_id
= -1, tmp
;
729 if (!mpctx
->sh_video
)
730 return M_PROPERTY_UNAVAILABLE
;
732 return M_PROPERTY_ERROR
;
733 *(int *) arg
= video_id
;
734 return M_PROPERTY_OK
;
735 case M_PROPERTY_PRINT
:
736 if (!mpctx
->sh_video
)
737 return M_PROPERTY_UNAVAILABLE
;
739 return M_PROPERTY_ERROR
;
742 *(char **) arg
= strdup(MSGTR_Disabled
);
744 char lang
[40] = MSGTR_Unknown
;
745 *(char **) arg
= malloc(64);
746 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
748 return M_PROPERTY_OK
;
750 case M_PROPERTY_STEP_UP
:
752 current_id
= mpctx
->demuxer
->video
->id
;
753 if (action
== M_PROPERTY_SET
&& arg
)
754 tmp
= *((int *) arg
);
757 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
759 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
760 && current_id
!= -2))
761 uninit_player(INITED_VCODEC
|
762 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
763 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
765 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
767 sh2
->ds
= mpctx
->demuxer
->video
;
768 mpctx
->sh_video
= sh2
;
769 reinit_video_chain();
772 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
773 return M_PROPERTY_OK
;
776 return M_PROPERTY_NOT_IMPLEMENTED
;
780 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
783 demux_program_t prog
;
786 case M_PROPERTY_STEP_UP
:
788 if (action
== M_PROPERTY_SET
&& arg
)
789 prog
.progid
= *((int *) arg
);
793 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
794 &prog
) == DEMUXER_CTRL_NOTIMPL
)
795 return M_PROPERTY_ERROR
;
797 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
798 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
799 return M_PROPERTY_OK
;
802 return M_PROPERTY_NOT_IMPLEMENTED
;
808 /// \defgroup VideoProperties Video properties
809 /// \ingroup Properties
812 /// Fullscreen state (RW)
813 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
817 if (!mpctx
->video_out
)
818 return M_PROPERTY_UNAVAILABLE
;
823 return M_PROPERTY_ERROR
;
824 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
825 if (vo_fs
== !!*(int *) arg
)
826 return M_PROPERTY_OK
;
827 case M_PROPERTY_STEP_UP
:
828 case M_PROPERTY_STEP_DOWN
:
831 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
835 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
836 return M_PROPERTY_OK
;
838 return m_property_flag(prop
, action
, arg
, &vo_fs
);
842 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
843 void *arg
, MPContext
* mpctx
)
847 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
848 return M_PROPERTY_UNAVAILABLE
;
849 vf
= mpctx
->sh_video
->vfilter
;
853 return M_PROPERTY_ERROR
;
854 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
855 return M_PROPERTY_OK
;
858 return M_PROPERTY_ERROR
;
859 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
860 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
861 return M_PROPERTY_OK
;
862 case M_PROPERTY_STEP_UP
:
863 case M_PROPERTY_STEP_DOWN
:
864 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
865 deinterlace
= !deinterlace
;
866 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
867 return M_PROPERTY_OK
;
869 return M_PROPERTY_NOT_IMPLEMENTED
;
873 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
877 if (!mpctx
->video_out
878 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
879 return M_PROPERTY_UNAVAILABLE
;
884 return M_PROPERTY_ERROR
;
885 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
886 vo_panscan
= *(float *) arg
;
887 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
888 return M_PROPERTY_OK
;
889 case M_PROPERTY_STEP_UP
:
890 case M_PROPERTY_STEP_DOWN
:
891 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
892 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
895 else if (vo_panscan
< 0)
897 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
898 return M_PROPERTY_OK
;
900 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
904 /// Helper to set vo flags.
905 /** \ingroup PropertyImplHelper
907 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
908 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
911 if (!mpctx
->video_out
)
912 return M_PROPERTY_UNAVAILABLE
;
917 return M_PROPERTY_ERROR
;
918 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
919 if (*vo_var
== !!*(int *) arg
)
920 return M_PROPERTY_OK
;
921 case M_PROPERTY_STEP_UP
:
922 case M_PROPERTY_STEP_DOWN
:
924 mpctx
->video_out
->control(vo_ctrl
, 0);
925 return M_PROPERTY_OK
;
927 return m_property_flag(prop
, action
, arg
, vo_var
);
931 /// Window always on top (RW)
932 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
935 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
939 /// Display in the root window (RW)
940 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
943 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
947 /// Show window borders (RW)
948 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
951 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
955 /// Framedropping state (RW)
956 static int mp_property_framedropping(m_option_t
* prop
, int action
,
957 void *arg
, MPContext
* mpctx
)
960 if (!mpctx
->sh_video
)
961 return M_PROPERTY_UNAVAILABLE
;
964 case M_PROPERTY_PRINT
:
966 return M_PROPERTY_ERROR
;
967 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
968 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
970 return M_PROPERTY_OK
;
972 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
976 /// Color settings, try to use vf/vo then fall back on TV. (RW)
977 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
980 int *gamma
= prop
->priv
, r
;
982 if (!mpctx
->sh_video
)
983 return M_PROPERTY_UNAVAILABLE
;
985 if (gamma
[0] == 1000) {
987 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
993 return M_PROPERTY_ERROR
;
994 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
995 *gamma
= *(int *) arg
;
996 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1000 case M_PROPERTY_GET
:
1002 return M_PROPERTY_ERROR
;
1003 r
= get_video_colors(mpctx
->sh_video
, prop
->name
, arg
);
1007 case M_PROPERTY_STEP_UP
:
1008 case M_PROPERTY_STEP_DOWN
:
1009 *gamma
+= (arg
? *(int *) arg
: 1) *
1010 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1011 M_PROPERTY_CLAMP(prop
, *gamma
);
1012 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1017 return M_PROPERTY_NOT_IMPLEMENTED
;
1021 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1022 int l
= strlen(prop
->name
);
1023 char tv_prop
[3 + l
+ 1];
1024 sprintf(tv_prop
, "tv_%s", prop
->name
);
1025 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1029 return M_PROPERTY_UNAVAILABLE
;
1033 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1036 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1039 /// Video codec tag (RO)
1040 static int mp_property_video_format(m_option_t
* prop
, int action
,
1041 void *arg
, MPContext
* mpctx
)
1044 if (!mpctx
->sh_video
)
1045 return M_PROPERTY_UNAVAILABLE
;
1047 case M_PROPERTY_PRINT
:
1049 return M_PROPERTY_ERROR
;
1050 switch(mpctx
->sh_video
->format
) {
1052 meta
= strdup ("mpeg1"); break;
1054 meta
= strdup ("mpeg2"); break;
1056 meta
= strdup ("mpeg4"); break;
1058 meta
= strdup ("h264"); break;
1060 if(mpctx
->sh_video
->format
>= 0x20202020) {
1062 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1065 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1068 *(char**)arg
= meta
;
1069 return M_PROPERTY_OK
;
1071 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1074 /// Video codec name (RO)
1075 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1076 void *arg
, MPContext
* mpctx
)
1078 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1079 return M_PROPERTY_UNAVAILABLE
;
1080 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1084 /// Video bitrate (RO)
1085 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1086 void *arg
, MPContext
* mpctx
)
1088 if (!mpctx
->sh_video
)
1089 return M_PROPERTY_UNAVAILABLE
;
1090 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1093 /// Video display width (RO)
1094 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1097 if (!mpctx
->sh_video
)
1098 return M_PROPERTY_UNAVAILABLE
;
1099 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1102 /// Video display height (RO)
1103 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1106 if (!mpctx
->sh_video
)
1107 return M_PROPERTY_UNAVAILABLE
;
1108 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1112 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1115 if (!mpctx
->sh_video
)
1116 return M_PROPERTY_UNAVAILABLE
;
1117 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1120 /// Video aspect (RO)
1121 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1124 if (!mpctx
->sh_video
)
1125 return M_PROPERTY_UNAVAILABLE
;
1126 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1131 /// \defgroup SubProprties Subtitles properties
1132 /// \ingroup Properties
1135 /// Text subtitle position (RW)
1136 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1139 if (!mpctx
->sh_video
)
1140 return M_PROPERTY_UNAVAILABLE
;
1143 case M_PROPERTY_SET
:
1145 return M_PROPERTY_ERROR
;
1146 case M_PROPERTY_STEP_UP
:
1147 case M_PROPERTY_STEP_DOWN
:
1148 vo_osd_changed(OSDTYPE_SUBTITLE
);
1150 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1154 char *demux_lavf_sub_lang(demuxer_t
*demuxer
, int track_num
);
1156 /// Selected subtitles (RW)
1157 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1160 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1161 const int global_sub_size
= mpctx
->global_sub_size
;
1162 int source
= -1, reset_spu
= 0;
1165 if (global_sub_size
<= 0)
1166 return M_PROPERTY_UNAVAILABLE
;
1169 case M_PROPERTY_GET
:
1171 return M_PROPERTY_ERROR
;
1172 *(int *) arg
= mpctx
->global_sub_pos
;
1173 return M_PROPERTY_OK
;
1174 case M_PROPERTY_PRINT
:
1176 return M_PROPERTY_ERROR
;
1177 *(char **) arg
= malloc(64);
1178 (*(char **) arg
)[63] = 0;
1181 sub_name
= subdata
->filename
;
1183 if (ass_track
&& ass_track
->name
)
1184 sub_name
= ass_track
->name
;
1189 if ((tmp2
= strrchr(tmp
, '/')))
1192 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1193 mpctx
->set_of_sub_pos
+ 1,
1194 strlen(tmp
) < 20 ? "" : "...",
1195 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1196 return M_PROPERTY_OK
;
1199 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1200 if (vo_spudec
&& dvdsub_id
>= 0) {
1201 unsigned char lang
[3];
1202 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1203 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1204 return M_PROPERTY_OK
;
1210 #ifdef USE_LIBAVFORMAT
1211 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
&& dvdsub_id
>= 0) {
1212 char *lang
= demux_lavf_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1213 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1214 return M_PROPERTY_OK
;
1217 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1218 char lang
[40] = MSGTR_Unknown
;
1219 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1220 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1221 return M_PROPERTY_OK
;
1223 #ifdef HAVE_OGGVORBIS
1224 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1225 char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1227 lang
= MSGTR_Unknown
;
1228 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1229 return M_PROPERTY_OK
;
1232 if (vo_vobsub
&& vobsub_id
>= 0) {
1233 const char *language
= MSGTR_Unknown
;
1234 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1235 snprintf(*(char **) arg
, 63, "(%d) %s",
1236 vobsub_id
, language
? language
: MSGTR_Unknown
);
1237 return M_PROPERTY_OK
;
1240 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1241 && dvdsub_id
>= 0) {
1243 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1244 lang
[0] = code
>> 8;
1247 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1248 return M_PROPERTY_OK
;
1251 if (dvdsub_id
>= 0) {
1252 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1253 return M_PROPERTY_OK
;
1255 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1256 return M_PROPERTY_OK
;
1258 case M_PROPERTY_SET
:
1260 return M_PROPERTY_ERROR
;
1261 if (*(int *) arg
< -1)
1263 else if (*(int *) arg
>= global_sub_size
)
1264 *(int *) arg
= global_sub_size
- 1;
1265 mpctx
->global_sub_pos
= *(int *) arg
;
1267 case M_PROPERTY_STEP_UP
:
1268 mpctx
->global_sub_pos
+= 2;
1269 mpctx
->global_sub_pos
=
1270 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1272 case M_PROPERTY_STEP_DOWN
:
1273 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1274 mpctx
->global_sub_pos
=
1275 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1278 return M_PROPERTY_NOT_IMPLEMENTED
;
1281 if (mpctx
->global_sub_pos
>= 0)
1282 source
= sub_source(mpctx
);
1284 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1285 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1287 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1288 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1289 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1290 mpctx
->global_sub_pos
, source
);
1292 mpctx
->set_of_sub_pos
= -1;
1306 if (source
== SUB_SOURCE_VOBSUB
) {
1308 mpctx
->global_sub_pos
-
1309 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
];
1310 } else if (source
== SUB_SOURCE_SUBS
) {
1311 mpctx
->set_of_sub_pos
=
1312 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1314 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1315 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1319 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1320 vo_osd_changed(OSDTYPE_SUBTITLE
);
1322 } else if (source
== SUB_SOURCE_DEMUX
) {
1324 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1325 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1327 // default: assume 1:1 mapping of sid and stream id
1328 d_sub
->id
= dvdsub_id
;
1329 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1330 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1331 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1332 if (sh
&& sh
->sid
== dvdsub_id
) {
1338 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1339 sh_sub_t
*sh
= d_sub
->sh
;
1340 if (sh
->type
== 'v')
1343 else if (ass_enabled
&& sh
->type
== 'a')
1344 ass_track
= sh
->ass_track
;
1354 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1355 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1356 && dvdsub_id
< 0 && reset_spu
) {
1358 d_sub
->id
= dvdsub_id
;
1361 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1363 return M_PROPERTY_OK
;
1366 /// Subtitle delay (RW)
1367 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1370 if (!mpctx
->sh_video
)
1371 return M_PROPERTY_UNAVAILABLE
;
1372 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1375 /// Alignment of text subtitles (RW)
1376 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1377 void *arg
, MPContext
* mpctx
)
1379 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1381 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1382 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1383 return M_PROPERTY_UNAVAILABLE
;
1386 case M_PROPERTY_PRINT
:
1388 return M_PROPERTY_ERROR
;
1389 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1390 *(char **) arg
= strdup(name
[sub_alignment
]);
1391 return M_PROPERTY_OK
;
1392 case M_PROPERTY_SET
:
1394 return M_PROPERTY_ERROR
;
1395 case M_PROPERTY_STEP_UP
:
1396 case M_PROPERTY_STEP_DOWN
:
1397 vo_osd_changed(OSDTYPE_SUBTITLE
);
1399 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1403 /// Subtitle visibility (RW)
1404 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1405 void *arg
, MPContext
* mpctx
)
1407 if (!mpctx
->sh_video
)
1408 return M_PROPERTY_UNAVAILABLE
;
1411 case M_PROPERTY_SET
:
1413 return M_PROPERTY_ERROR
;
1414 case M_PROPERTY_STEP_UP
:
1415 case M_PROPERTY_STEP_DOWN
:
1416 vo_osd_changed(OSDTYPE_SUBTITLE
);
1418 vo_osd_changed(OSDTYPE_SPU
);
1420 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1424 /// Show only forced subtitles (RW)
1425 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1426 void *arg
, MPContext
* mpctx
)
1429 return M_PROPERTY_UNAVAILABLE
;
1432 case M_PROPERTY_SET
:
1434 return M_PROPERTY_ERROR
;
1435 case M_PROPERTY_STEP_UP
:
1436 case M_PROPERTY_STEP_DOWN
:
1437 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1438 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1439 return M_PROPERTY_OK
;
1441 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1446 #ifdef HAVE_FREETYPE
1447 /// Subtitle scale (RW)
1448 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1453 case M_PROPERTY_SET
:
1455 return M_PROPERTY_ERROR
;
1456 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1457 text_font_scale_factor
= *(float *) arg
;
1458 force_load_font
= 1;
1459 return M_PROPERTY_OK
;
1460 case M_PROPERTY_STEP_UP
:
1461 case M_PROPERTY_STEP_DOWN
:
1462 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1463 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1464 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1465 force_load_font
= 1;
1466 return M_PROPERTY_OK
;
1468 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1475 /// \defgroup TVProperties TV properties
1476 /// \ingroup Properties
1481 /// TV color settings (RW)
1482 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1486 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1487 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1488 return M_PROPERTY_UNAVAILABLE
;
1491 case M_PROPERTY_SET
:
1493 return M_PROPERTY_ERROR
;
1494 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1495 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1496 case M_PROPERTY_GET
:
1497 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1498 case M_PROPERTY_STEP_UP
:
1499 case M_PROPERTY_STEP_DOWN
:
1500 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1502 return M_PROPERTY_ERROR
;
1503 val
+= (arg
? *(int *) arg
: 1) *
1504 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1505 M_PROPERTY_CLAMP(prop
, val
);
1506 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1508 return M_PROPERTY_ERROR
;
1510 return M_PROPERTY_NOT_IMPLEMENTED
;
1515 #ifdef HAVE_TV_TELETEXT
1516 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1520 int base_ioctl
=(int)prop
->priv
;
1522 for teletext's GET,SET,STEP ioctls this is not 0
1526 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1527 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1528 return M_PROPERTY_UNAVAILABLE
;
1530 return M_PROPERTY_ERROR
;
1533 case M_PROPERTY_GET
:
1535 return M_PROPERTY_ERROR
;
1536 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1538 case M_PROPERTY_SET
:
1540 return M_PROPERTY_ERROR
;
1541 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1542 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1544 case M_PROPERTY_STEP_UP
:
1545 case M_PROPERTY_STEP_DOWN
:
1546 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1547 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1548 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1551 return M_PROPERTY_NOT_IMPLEMENTED
;
1554 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1557 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1560 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1564 //with tvh==NULL will fail too
1565 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1566 if(result
!=M_PROPERTY_OK
)
1569 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1570 mp_input_set_section("teletext");
1572 mp_input_set_section("tv");
1573 return M_PROPERTY_OK
;
1576 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1579 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1583 case M_PROPERTY_STEP_UP
:
1584 case M_PROPERTY_STEP_DOWN
:
1585 //This should be handled separately
1586 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1587 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1590 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1596 #endif /* HAVE_TV_TELETEXT */
1600 /// All properties available in MPlayer.
1601 /** \ingroup Properties
1603 static m_option_t mp_properties
[] = {
1605 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1606 M_OPT_RANGE
, 0, 3, NULL
},
1607 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1608 M_OPT_MIN
, -1, 0, NULL
},
1609 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1610 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1611 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1613 { "path", mp_property_path
, CONF_TYPE_STRING
,
1615 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1617 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1618 M_OPT_MIN
, 0, 0, NULL
},
1619 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1620 M_OPT_MIN
, 0, 0, NULL
},
1621 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1622 M_OPT_MIN
, 0, 0, NULL
},
1623 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1624 M_OPT_MIN
, 0, 0, NULL
},
1625 { "length", mp_property_length
, CONF_TYPE_TIME
,
1626 M_OPT_MIN
, 0, 0, NULL
},
1627 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1628 M_OPT_RANGE
, 0, 100, NULL
},
1629 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1630 M_OPT_MIN
, 0, 0, NULL
},
1631 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1635 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1636 M_OPT_RANGE
, 0, 100, NULL
},
1637 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1638 M_OPT_RANGE
, 0, 1, NULL
},
1639 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1640 M_OPT_RANGE
, -100, 100, NULL
},
1641 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1643 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1645 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1647 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1649 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1651 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1652 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1653 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
1654 M_OPT_RANGE
, -1, 1, NULL
},
1657 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1658 M_OPT_RANGE
, 0, 1, NULL
},
1659 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1660 M_OPT_RANGE
, 0, 1, NULL
},
1661 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1662 M_OPT_RANGE
, 0, 1, NULL
},
1663 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1664 M_OPT_RANGE
, 0, 1, NULL
},
1665 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1666 M_OPT_RANGE
, 0, 1, NULL
},
1667 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1668 M_OPT_RANGE
, 0, 2, NULL
},
1669 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1670 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1671 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1672 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1673 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1674 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1675 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
1676 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
1677 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
1678 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
1679 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
1680 M_OPT_RANGE
, 0, 1, NULL
},
1681 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
1682 M_OPT_RANGE
, 0, 1, NULL
},
1683 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
1685 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
1687 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
1689 { "width", mp_property_width
, CONF_TYPE_INT
,
1691 { "height", mp_property_height
, CONF_TYPE_INT
,
1693 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
1695 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
1697 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
1698 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
1699 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
1700 CONF_RANGE
, -1, 65535, NULL
},
1703 { "sub", mp_property_sub
, CONF_TYPE_INT
,
1704 M_OPT_MIN
, -1, 0, NULL
},
1705 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
1707 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
1708 M_OPT_RANGE
, 0, 100, NULL
},
1709 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
1710 M_OPT_RANGE
, 0, 2, NULL
},
1711 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
1712 M_OPT_RANGE
, 0, 1, NULL
},
1713 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
1714 M_OPT_RANGE
, 0, 1, NULL
},
1715 #ifdef HAVE_FREETYPE
1716 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
1717 M_OPT_RANGE
, 0, 100, NULL
},
1721 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
1722 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
1723 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
1724 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
1725 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
1726 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
1727 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
1728 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
1731 #ifdef HAVE_TV_TELETEXT
1732 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
1733 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
1734 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
1735 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
1736 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
1737 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
1738 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
1739 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
1740 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
1741 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
1744 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
1748 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
1750 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
1753 char* mp_property_print(const char *name
, void* ctx
)
1756 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
1761 char *property_expand_string(MPContext
* mpctx
, char *str
)
1763 return m_properties_expand_string(mp_properties
, str
, mpctx
);
1766 void property_print_help(void)
1768 m_properties_print_help_list(mp_properties
);
1777 * \defgroup Command2Property Command to property bridge
1779 * It is used to handle most commands that just set a property
1780 * and optionally display something on the OSD.
1781 * Two kinds of commands are handled: adjust or toggle.
1783 * Adjust commands take 1 or 2 parameters: <value> <abs>
1784 * If <abs> is non-zero the property is set to the given value
1785 * otherwise it is adjusted.
1787 * Toggle commands take 0 or 1 parameters. With no parameter
1788 * or a value less than the property minimum it just steps the
1789 * property to its next value. Otherwise it sets it to the given
1795 /// List of the commands that can be handled by setting a property.
1801 /// set/adjust or toggle command
1803 /// progressbar type
1805 /// osd msg id if it must be shared
1807 /// osd msg template
1808 const char *osd_msg
;
1809 } set_prop_cmd
[] = {
1811 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
1813 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
1814 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
1815 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
1816 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
1817 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
1819 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
1820 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
1821 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
1822 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
1823 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
1824 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
1825 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
1826 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1827 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1828 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1829 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1830 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
1832 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
1833 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
1834 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
1835 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
1836 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
1837 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
1838 #ifdef HAVE_FREETYPE
1839 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
1842 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1843 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1844 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1845 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1847 { NULL
, 0, 0, 0, -1, NULL
}
1851 /// Handle commands that set a property.
1852 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1858 // look for the command
1859 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
1860 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
1862 if (!(pname
= set_prop_cmd
[i
].name
))
1865 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
1869 if (set_prop_cmd
[i
].toggle
) {
1871 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
1872 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
1874 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1875 } else if (cmd
->args
[1].v
.i
) //set
1876 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
1878 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
1883 if (set_prop_cmd
[i
].osd_progbar
) {
1884 if (prop
->type
== CONF_TYPE_INT
) {
1885 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
1886 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1887 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
1888 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
1890 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
1891 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1892 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
1894 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
1895 "Property use an unsupported type.\n");
1899 if (set_prop_cmd
[i
].osd_msg
) {
1900 char *val
= mp_property_print(pname
, mpctx
);
1902 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
1903 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
1904 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
1912 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1914 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
1915 sh_video_t
* const sh_video
= mpctx
->sh_video
;
1917 if (!set_property_command(mpctx
, cmd
))
1923 mpctx
->osd_show_percentage
= sh_video
->fps
;
1924 v
= cmd
->args
[0].v
.f
;
1925 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
1926 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
1929 mpctx
->osd_function
=
1930 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
1932 } else if (abs
) { /* Absolute seek by percentage */
1935 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
1936 rel_seek_secs
= v
/ 100.0;
1939 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
1945 case MP_CMD_SET_PROPERTY
:{
1946 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
1947 cmd
->args
[1].v
.s
, mpctx
);
1948 if (r
== M_PROPERTY_UNKNOWN
)
1949 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1950 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1952 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1953 "Failed to set property '%s' to '%s'.\n",
1954 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
1958 case MP_CMD_STEP_PROPERTY
:{
1963 if (cmd
->args
[1].v
.f
) {
1965 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
1966 M_PROPERTY_GET_TYPE
,
1967 &prop
, mpctx
)) <= 0)
1969 if(prop
->type
== CONF_TYPE_INT
||
1970 prop
->type
== CONF_TYPE_FLAG
)
1971 i
= cmd
->args
[1].v
.f
, arg
= &i
;
1972 else if(prop
->type
== CONF_TYPE_FLOAT
)
1973 arg
= &cmd
->args
[1].v
.f
;
1974 else if(prop
->type
== CONF_TYPE_DOUBLE
||
1975 prop
->type
== CONF_TYPE_TIME
)
1976 d
= cmd
->args
[1].v
.f
, arg
= &d
;
1977 else if(prop
->type
== CONF_TYPE_POSITION
)
1978 o
= cmd
->args
[1].v
.f
, arg
= &o
;
1980 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1981 "Ignoring step size stepping property '%s'.\n",
1984 r
= mp_property_do(cmd
->args
[0].v
.s
,
1985 cmd
->args
[2].v
.i
< 0 ?
1986 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
1989 if (r
== M_PROPERTY_UNKNOWN
)
1990 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1991 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1993 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1994 "Failed to increment property '%s' by %f.\n",
1995 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
1999 case MP_CMD_GET_PROPERTY
:{
2001 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2002 &tmp
, mpctx
) <= 0) {
2003 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2004 "Failed to get value of property '%s'.\n",
2008 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2009 cmd
->args
[0].v
.s
, tmp
);
2014 case MP_CMD_EDL_MARK
:
2016 float v
= sh_video
? sh_video
->pts
:
2017 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2020 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2021 mpctx
->begin_skip
= v
;
2022 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2024 if (mpctx
->begin_skip
> v
)
2025 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2027 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2028 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2030 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2035 case MP_CMD_SWITCH_RATIO
:
2036 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2037 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2039 movie_aspect
= cmd
->args
[0].v
.f
;
2040 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2043 case MP_CMD_SPEED_INCR
:{
2044 float v
= cmd
->args
[0].v
.f
;
2045 playback_speed
+= v
;
2046 build_afilter_chain(sh_audio
, &ao_data
);
2047 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2051 case MP_CMD_SPEED_MULT
:{
2052 float v
= cmd
->args
[0].v
.f
;
2053 playback_speed
*= v
;
2054 build_afilter_chain(sh_audio
, &ao_data
);
2055 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2059 case MP_CMD_SPEED_SET
:{
2060 float v
= cmd
->args
[0].v
.f
;
2062 build_afilter_chain(sh_audio
, &ao_data
);
2063 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2067 case MP_CMD_FRAME_STEP
:
2073 case MP_CMD_FILE_FILTER
:
2074 file_filter
= cmd
->args
[0].v
.i
;
2078 exit_player_with_rc(MSGTR_Exit_quit
,
2079 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2081 case MP_CMD_PLAY_TREE_STEP
:{
2082 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2083 int force
= cmd
->args
[1].v
.i
;
2089 for (i
= 0; i
< n
; i
++)
2092 for (i
= 0; i
< -1 * n
; i
++)
2097 if (!force
&& mpctx
->playtree_iter
) {
2098 play_tree_iter_t
*i
=
2099 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2100 if (play_tree_iter_step(i
, n
, 0) ==
2101 PLAY_TREE_ITER_ENTRY
)
2103 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2104 play_tree_iter_free(i
);
2106 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2108 mpctx
->play_tree_step
= n
;
2114 case MP_CMD_PLAY_TREE_UP_STEP
:{
2115 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2116 int force
= cmd
->args
[1].v
.i
;
2118 if (!force
&& mpctx
->playtree_iter
) {
2119 play_tree_iter_t
*i
=
2120 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2121 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2122 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2123 play_tree_iter_free(i
);
2125 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2130 case MP_CMD_PLAY_ALT_SRC_STEP
:
2131 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2132 int v
= cmd
->args
[0].v
.i
;
2134 && mpctx
->playtree_iter
->file
<
2135 mpctx
->playtree_iter
->num_files
)
2136 mpctx
->eof
= PT_NEXT_SRC
;
2137 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2138 mpctx
->eof
= PT_PREV_SRC
;
2143 case MP_CMD_SUB_STEP
:
2145 int movement
= cmd
->args
[0].v
.i
;
2146 step_sub(subdata
, sh_video
->pts
, movement
);
2150 ass_step_sub(ass_track
,
2152 sub_delay
) * 1000 + .5, movement
) / 1000.;
2154 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2155 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2159 case MP_CMD_SUB_LOG
:
2164 int v
= cmd
->args
[0].v
.i
;
2166 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2167 if (osd_level
> max
)
2170 osd_level
= (osd_level
+ 1) % (max
+ 1);
2172 osd_level
= v
> max
? max
: v
;
2173 /* Show OSD state when disabled, but not when an explicit
2174 argument is given to the OSD command, i.e. in slave mode. */
2175 if (v
== -1 && osd_level
<= 1)
2176 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2178 osd_level
? MSGTR_OSDenabled
:
2181 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2185 case MP_CMD_OSD_SHOW_TEXT
:
2186 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2188 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2189 "%-.63s", cmd
->args
[0].v
.s
);
2192 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2193 char *txt
= m_properties_expand_string(mp_properties
,
2196 /* if no argument supplied take default osd_duration, else <arg> ms. */
2198 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2200 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2207 case MP_CMD_LOADFILE
:{
2208 play_tree_t
*e
= play_tree_new();
2209 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2211 if (cmd
->args
[1].v
.i
) // append
2212 play_tree_append_entry(mpctx
->playtree
, e
);
2214 // Go back to the starting point.
2215 while (play_tree_iter_up_step
2216 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2218 play_tree_free_list(mpctx
->playtree
->child
, 1);
2219 play_tree_set_child(mpctx
->playtree
, e
);
2220 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2221 mpctx
->eof
= PT_NEXT_SRC
;
2227 case MP_CMD_LOADLIST
:{
2228 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2230 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2231 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2233 if (cmd
->args
[1].v
.i
) // append
2234 play_tree_append_entry(mpctx
->playtree
, e
);
2236 // Go back to the starting point.
2237 while (play_tree_iter_up_step
2238 (mpctx
->playtree_iter
, 0, 1)
2239 != PLAY_TREE_ITER_END
)
2241 play_tree_free_list(mpctx
->playtree
->child
, 1);
2242 play_tree_set_child(mpctx
->playtree
, e
);
2243 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2244 mpctx
->eof
= PT_NEXT_SRC
;
2252 case MP_CMD_RADIO_STEP_CHANNEL
:
2253 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2254 int v
= cmd
->args
[0].v
.i
;
2256 radio_step_channel(mpctx
->demuxer
->stream
,
2257 RADIO_CHANNEL_HIGHER
);
2259 radio_step_channel(mpctx
->demuxer
->stream
,
2260 RADIO_CHANNEL_LOWER
);
2261 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2262 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2264 radio_get_channel_name(mpctx
->demuxer
->stream
));
2269 case MP_CMD_RADIO_SET_CHANNEL
:
2270 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2271 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2272 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2273 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2275 radio_get_channel_name(mpctx
->demuxer
->stream
));
2280 case MP_CMD_RADIO_SET_FREQ
:
2281 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2282 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2285 case MP_CMD_RADIO_STEP_FREQ
:
2286 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2287 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2292 case MP_CMD_TV_START_SCAN
:
2293 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2294 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2296 case MP_CMD_TV_SET_FREQ
:
2297 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2298 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2299 cmd
->args
[0].v
.f
* 16.0);
2301 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2302 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2303 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2304 pvr_get_current_channelname (mpctx
->stream
),
2305 pvr_get_current_stationname (mpctx
->stream
));
2307 #endif /* HAVE_PVR */
2310 case MP_CMD_TV_STEP_FREQ
:
2311 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2312 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2313 cmd
->args
[0].v
.f
* 16.0);
2315 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2316 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2317 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2318 pvr_get_current_channelname (mpctx
->stream
),
2319 pvr_get_current_frequency (mpctx
->stream
));
2321 #endif /* HAVE_PVR */
2324 case MP_CMD_TV_SET_NORM
:
2325 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2326 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2330 case MP_CMD_TV_STEP_CHANNEL
:{
2331 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2332 int v
= cmd
->args
[0].v
.i
;
2334 tv_step_channel((tvi_handle_t
*) (mpctx
->
2338 tv_step_channel((tvi_handle_t
*) (mpctx
->
2342 if (tv_channel_list
) {
2343 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2344 MSGTR_OSDChannel
, tv_channel_current
->name
);
2345 //vo_osd_changed(OSDTYPE_SUBTITLE);
2349 else if (mpctx
->stream
&&
2350 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2351 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2352 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2353 pvr_get_current_channelname (mpctx
->stream
),
2354 pvr_get_current_stationname (mpctx
->stream
));
2356 #endif /* HAVE_PVR */
2358 #ifdef HAS_DVBIN_SUPPORT
2359 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2360 && mpctx
->stream
->priv
) {
2361 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2364 int v
= cmd
->args
[0].v
.i
;
2366 mpctx
->last_dvb_step
= v
;
2368 dir
= DVB_CHANNEL_HIGHER
;
2370 dir
= DVB_CHANNEL_LOWER
;
2373 if (dvb_step_channel(priv
, dir
))
2374 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2377 #endif /* HAS_DVBIN_SUPPORT */
2380 case MP_CMD_TV_SET_CHANNEL
:
2381 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2382 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2384 if (tv_channel_list
) {
2385 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2386 MSGTR_OSDChannel
, tv_channel_current
->name
);
2387 //vo_osd_changed(OSDTYPE_SUBTITLE);
2391 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2392 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2393 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2394 pvr_get_current_channelname (mpctx
->stream
),
2395 pvr_get_current_stationname (mpctx
->stream
));
2397 #endif /* HAVE_PVR */
2400 #ifdef HAS_DVBIN_SUPPORT
2401 case MP_CMD_DVB_SET_CHANNEL
:
2402 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2403 && mpctx
->stream
->priv
) {
2404 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2406 if (priv
->list
->current
<= cmd
->args
[0].v
.i
)
2407 mpctx
->last_dvb_step
= 1;
2409 mpctx
->last_dvb_step
= -1;
2412 (priv
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2413 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2417 #endif /* HAS_DVBIN_SUPPORT */
2419 case MP_CMD_TV_LAST_CHANNEL
:
2420 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2421 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2422 if (tv_channel_list
) {
2423 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2424 MSGTR_OSDChannel
, tv_channel_current
->name
);
2425 //vo_osd_changed(OSDTYPE_SUBTITLE);
2429 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2430 pvr_set_lastchannel (mpctx
->stream
);
2431 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2432 pvr_get_current_channelname (mpctx
->stream
),
2433 pvr_get_current_stationname (mpctx
->stream
));
2435 #endif /* HAVE_PVR */
2438 case MP_CMD_TV_STEP_NORM
:
2439 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2440 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2443 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2444 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2445 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2447 #ifdef HAVE_TV_TELETEXT
2448 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2450 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2451 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2452 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2455 case MP_CMD_TV_TELETEXT_GO_LINK
:
2457 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2458 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2459 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2462 #endif /* HAVE_TV_TELETEXT */
2465 case MP_CMD_SUB_LOAD
:
2467 int n
= mpctx
->set_of_sub_size
;
2468 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2469 if (n
!= mpctx
->set_of_sub_size
) {
2470 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2471 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2472 mpctx
->global_sub_size
;
2473 ++mpctx
->global_sub_size
;
2478 case MP_CMD_SUB_REMOVE
:
2480 int v
= cmd
->args
[0].v
.i
;
2483 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2484 subd
= mpctx
->set_of_subtitles
[v
];
2485 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2486 MSGTR_RemovedSubtitleFile
, v
+ 1,
2487 filename_recode(subd
->filename
));
2489 mpctx
->set_of_subtitles
[v
] = NULL
;
2491 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2492 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2493 mpctx
->set_of_sub_size
= 0;
2494 if (mpctx
->set_of_sub_pos
>= 0) {
2495 mpctx
->global_sub_pos
= -2;
2497 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2499 } else if (v
< mpctx
->set_of_sub_size
) {
2500 subd
= mpctx
->set_of_subtitles
[v
];
2501 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2502 MSGTR_RemovedSubtitleFile
, v
+ 1,
2503 filename_recode(subd
->filename
));
2505 if (mpctx
->set_of_sub_pos
== v
) {
2506 mpctx
->global_sub_pos
= -2;
2508 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2509 } else if (mpctx
->set_of_sub_pos
> v
) {
2510 --mpctx
->set_of_sub_pos
;
2511 --mpctx
->global_sub_pos
;
2513 while (++v
< mpctx
->set_of_sub_size
)
2514 mpctx
->set_of_subtitles
[v
- 1] =
2515 mpctx
->set_of_subtitles
[v
];
2516 --mpctx
->set_of_sub_size
;
2517 --mpctx
->global_sub_size
;
2518 if (mpctx
->set_of_sub_size
<= 0)
2519 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2520 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2525 case MP_CMD_GET_SUB_VISIBILITY
:
2527 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2528 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2532 case MP_CMD_SCREENSHOT
:
2533 if (vo_config_count
) {
2534 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2536 ((vf_instance_t
*) sh_video
->vfilter
)->
2537 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2539 mpctx
->video_out
->control(VOCTRL_SCREENSHOT
, NULL
);
2543 case MP_CMD_VF_CHANGE_RECTANGLE
:
2544 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2547 case MP_CMD_GET_TIME_LENGTH
:{
2548 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2549 demuxer_get_time_length(mpctx
->demuxer
));
2553 case MP_CMD_GET_FILENAME
:{
2554 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2555 get_metadata(META_NAME
));
2559 case MP_CMD_GET_VIDEO_CODEC
:{
2560 char *inf
= get_metadata(META_VIDEO_CODEC
);
2563 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2568 case MP_CMD_GET_VIDEO_BITRATE
:{
2569 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2572 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2577 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2578 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2581 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2582 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2587 case MP_CMD_GET_AUDIO_CODEC
:{
2588 char *inf
= get_metadata(META_AUDIO_CODEC
);
2591 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2596 case MP_CMD_GET_AUDIO_BITRATE
:{
2597 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2600 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2605 case MP_CMD_GET_AUDIO_SAMPLES
:{
2606 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2609 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2614 case MP_CMD_GET_META_TITLE
:{
2615 char *inf
= get_metadata(META_INFO_TITLE
);
2618 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2623 case MP_CMD_GET_META_ARTIST
:{
2624 char *inf
= get_metadata(META_INFO_ARTIST
);
2627 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2632 case MP_CMD_GET_META_ALBUM
:{
2633 char *inf
= get_metadata(META_INFO_ALBUM
);
2636 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2641 case MP_CMD_GET_META_YEAR
:{
2642 char *inf
= get_metadata(META_INFO_YEAR
);
2645 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2650 case MP_CMD_GET_META_COMMENT
:{
2651 char *inf
= get_metadata(META_INFO_COMMENT
);
2654 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2659 case MP_CMD_GET_META_TRACK
:{
2660 char *inf
= get_metadata(META_INFO_TRACK
);
2663 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2668 case MP_CMD_GET_META_GENRE
:{
2669 char *inf
= get_metadata(META_INFO_GENRE
);
2672 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
2677 case MP_CMD_GET_VO_FULLSCREEN
:
2678 if (mpctx
->video_out
&& vo_config_count
)
2679 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
2682 case MP_CMD_GET_PERCENT_POS
:
2683 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
2684 demuxer_get_percent_pos(mpctx
->demuxer
));
2687 case MP_CMD_GET_TIME_POS
:{
2690 pos
= sh_video
->pts
;
2691 else if (sh_audio
&& mpctx
->audio_out
)
2693 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2695 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
2702 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
2708 case MP_CMD_KEYDOWN_EVENTS
:
2709 mplayer_put_key(cmd
->args
[0].v
.i
);
2712 case MP_CMD_SEEK_CHAPTER
:{
2713 int seek
= cmd
->args
[0].v
.i
;
2714 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2723 demuxer_seek_chapter(mpctx
->demuxer
, seek
, abs
,
2724 &next_pts
, &num_chapters
,
2727 if (next_pts
> -1.0) {
2729 rel_seek_secs
= next_pts
;
2732 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2733 MSGTR_OSDChapter
, chap
+ 1, chapter_name
);
2738 rel_seek_secs
= 1000000000.;
2740 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2741 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
2747 case MP_CMD_SET_MOUSE_POS
:{
2748 int pointer_x
, pointer_y
;
2750 pointer_x
= cmd
->args
[0].v
.i
;
2751 pointer_y
= cmd
->args
[1].v
.i
;
2752 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
2754 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
2755 && dx
> 0.0 && dy
> 0.0) {
2757 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
2758 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
2759 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
2760 pointer_x
, pointer_y
, &button
);
2762 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2763 "Selected button number %d", button
);
2770 case MP_CMD_DVDNAV
:{
2772 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
2775 if (mp_dvdnav_handle_input
2776 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
2777 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
2778 (fixed_vo
? INITED_VO
: 0)));
2780 } else if (button
> 0)
2781 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2782 "Selected button number %d", button
);
2789 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
2790 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
2793 mp_msg(MSGT_CPLAYER
, MSGL_V
,
2794 "Received unknown cmd %s\n", cmd
->name
);
2797 switch (cmd
->pausing
) {
2798 case 1: // "pausing"
2799 mpctx
->osd_function
= OSD_PAUSE
;
2801 case 3: // "pausing_toggle"
2802 mpctx
->was_paused
= !mpctx
->was_paused
;
2804 case 2: // "pausing_keep"
2805 if (mpctx
->was_paused
)
2806 mpctx
->osd_function
= OSD_PAUSE
;