9 #include "input/input.h"
10 #include "stream/stream.h"
11 #include "libmpdemux/demuxer.h"
12 #include "libmpdemux/stheader.h"
13 #include "codec-cfg.h"
15 #include "libvo/sub.h"
17 #include "m_property.h"
20 #include "libmpcodecs/vf.h"
21 #include "libmpcodecs/vd.h"
23 #include "libvo/video_out.h"
24 #include "libvo/font_load.h"
26 #include "libao2/audio_out.h"
29 #include "libmpcodecs/dec_video.h"
34 #include "stream/tv.h"
37 #include "stream/stream_radio.h"
40 #include "stream/pvr.h"
43 #include "stream/dvbin.h"
46 #include "stream/stream_dvd.h"
49 #include "stream/stream_dvdnav.h"
52 #include "libass/ass.h"
53 #include "libass/ass_mp.h"
57 #include "libmenu/menu.h"
60 #include "gui/interface.h"
65 #include "libavutil/avstring.h"
67 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
71 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
72 double *dx
, double *dy
)
74 struct MPOpts
*opts
= &mpctx
->opts
;
75 struct vo
*vo
= mpctx
->video_out
;
76 //remove the borders, if any, and rescale to the range [0,1],[0,1]
77 if (vo_fs
) { //we are in full-screen mode
78 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
79 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
80 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
81 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
83 if (ix
< 0 || ix
> vo
->dwidth
) {
86 } //we are on one of the borders
87 if (iy
< 0 || iy
> vo
->dheight
) {
90 } //we are on one of the borders
93 *dx
= (double) ix
/ (double) vo
->dwidth
;
94 *dy
= (double) iy
/ (double) vo
->dheight
;
96 mp_msg(MSGT_CPLAYER
, MSGL_V
,
97 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
98 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
102 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
107 for (i
= 0; i
< SUB_SOURCES
; i
++) {
108 int j
= mpctx
->global_sub_indices
[i
];
109 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
117 static int sub_source(MPContext
*mpctx
)
119 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
123 * \brief Log the currently displayed subtitle to a file
125 * Logs the current or last displayed subtitle together with filename
126 * and time information to ~/.mplayer/subtitle_log
128 * Intended purpose is to allow convenient marking of bogus subtitles
129 * which need to be fixed while watching the movie.
132 static void log_sub(struct MPContext
*mpctx
)
138 if (subdata
== NULL
|| vo_sub_last
== NULL
)
140 fname
= get_path("subtitle_log");
141 f
= fopen(fname
, "a");
144 fprintf(f
, "----------------------------------------------------------\n");
145 if (subdata
->sub_uses_time
) {
147 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
148 mpctx
->filename
, vo_sub_last
->start
/ 360000,
149 (vo_sub_last
->start
/ 6000) % 60,
150 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
151 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
152 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
154 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
155 vo_sub_last
->start
, vo_sub_last
->end
);
157 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
158 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
164 /// \defgroup Properties
167 /// \defgroup GeneralProperties General properties
168 /// \ingroup Properties
172 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
175 return m_property_choice(prop
, action
, arg
, &osd_level
);
179 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
182 struct MPOpts
*opts
= &mpctx
->opts
;
184 case M_PROPERTY_PRINT
:
185 if (!arg
) return M_PROPERTY_ERROR
;
186 if (opts
->loop_times
< 0)
187 *(char**)arg
= strdup("off");
188 else if (opts
->loop_times
== 0)
189 *(char**)arg
= strdup("inf");
192 return M_PROPERTY_OK
;
194 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
197 /// Playback speed (RW)
198 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
199 void *arg
, MPContext
*mpctx
)
201 struct MPOpts
*opts
= &mpctx
->opts
;
205 return M_PROPERTY_ERROR
;
206 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
207 opts
->playback_speed
= *(float *) arg
;
208 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
209 return M_PROPERTY_OK
;
210 case M_PROPERTY_STEP_UP
:
211 case M_PROPERTY_STEP_DOWN
:
212 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
213 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
214 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
215 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
216 return M_PROPERTY_OK
;
218 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
221 /// filename with path (RO)
222 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
225 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
228 /// filename without path (RO)
229 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
233 if (!mpctx
->filename
)
234 return M_PROPERTY_UNAVAILABLE
;
235 if (((f
= strrchr(mpctx
->filename
, '/'))
236 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
240 return m_property_string_ro(prop
, action
, arg
, f
);
243 /// Demuxer name (RO)
244 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
248 return M_PROPERTY_UNAVAILABLE
;
249 return m_property_string_ro(prop
, action
, arg
,
250 (char *) mpctx
->demuxer
->desc
->name
);
253 /// Position in the stream (RW)
254 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
257 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
258 return M_PROPERTY_UNAVAILABLE
;
260 return M_PROPERTY_ERROR
;
263 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
264 return M_PROPERTY_OK
;
266 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
267 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
268 return M_PROPERTY_OK
;
270 return M_PROPERTY_NOT_IMPLEMENTED
;
273 /// Stream start offset (RO)
274 static int mp_property_stream_start(m_option_t
*prop
, int action
,
275 void *arg
, MPContext
*mpctx
)
277 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
278 return M_PROPERTY_UNAVAILABLE
;
281 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
282 return M_PROPERTY_OK
;
284 return M_PROPERTY_NOT_IMPLEMENTED
;
287 /// Stream end offset (RO)
288 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
291 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
292 return M_PROPERTY_UNAVAILABLE
;
295 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
296 return M_PROPERTY_OK
;
298 return M_PROPERTY_NOT_IMPLEMENTED
;
301 /// Stream length (RO)
302 static int mp_property_stream_length(m_option_t
*prop
, int action
,
303 void *arg
, MPContext
*mpctx
)
305 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
306 return M_PROPERTY_UNAVAILABLE
;
310 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
311 return M_PROPERTY_OK
;
313 return M_PROPERTY_NOT_IMPLEMENTED
;
316 /// Media length in seconds (RO)
317 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
322 if (!mpctx
->demuxer
||
323 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
324 return M_PROPERTY_UNAVAILABLE
;
326 return m_property_time_ro(prop
, action
, arg
, len
);
329 /// Current position in percent (RW)
330 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
331 void *arg
, MPContext
*mpctx
) {
335 return M_PROPERTY_UNAVAILABLE
;
339 if(!arg
) return M_PROPERTY_ERROR
;
340 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
343 case M_PROPERTY_STEP_UP
:
344 case M_PROPERTY_STEP_DOWN
:
345 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
346 pos
+= (arg
? *(int*)arg
: 10) *
347 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
348 M_PROPERTY_CLAMP(prop
, pos
);
351 return m_property_int_ro(prop
, action
, arg
,
352 demuxer_get_percent_pos(mpctx
->demuxer
));
355 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
356 mpctx
->rel_seek_secs
= pos
/ 100.0;
357 return M_PROPERTY_OK
;
360 /// Current position in seconds (RW)
361 static int mp_property_time_pos(m_option_t
*prop
, int action
,
362 void *arg
, MPContext
*mpctx
) {
363 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
364 return M_PROPERTY_UNAVAILABLE
;
368 if(!arg
) return M_PROPERTY_ERROR
;
369 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
370 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
371 mpctx
->rel_seek_secs
= *(double*)arg
;
372 return M_PROPERTY_OK
;
373 case M_PROPERTY_STEP_UP
:
374 case M_PROPERTY_STEP_DOWN
:
375 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
376 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
377 return M_PROPERTY_OK
;
379 return m_property_time_ro(prop
, action
, arg
,
380 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
381 playing_audio_pts(mpctx
));
384 /// Current chapter (RW)
385 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
392 char *chapter_name
= NULL
;
395 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
397 return M_PROPERTY_UNAVAILABLE
;
402 return M_PROPERTY_ERROR
;
403 *(int *) arg
= chapter
;
404 return M_PROPERTY_OK
;
405 case M_PROPERTY_PRINT
: {
407 return M_PROPERTY_ERROR
;
408 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
410 return M_PROPERTY_UNAVAILABLE
;
411 *(char **) arg
= chapter_name
;
412 return M_PROPERTY_OK
;
416 return M_PROPERTY_ERROR
;
417 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
418 step_all
= *(int *)arg
- (chapter
+ 1);
421 case M_PROPERTY_STEP_UP
:
422 case M_PROPERTY_STEP_DOWN
: {
423 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
424 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
431 return M_PROPERTY_NOT_IMPLEMENTED
;
433 mpctx
->rel_seek_secs
= 0;
434 mpctx
->abs_seek_pos
= 0;
435 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
436 &next_pts
, &chapter_num
, &chapter_name
);
438 if (next_pts
> -1.0) {
439 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
440 mpctx
->rel_seek_secs
= next_pts
;
443 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
444 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
446 else if (step_all
> 0)
447 mpctx
->rel_seek_secs
= 1000000000.;
449 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
450 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
453 return M_PROPERTY_OK
;
456 /// Number of chapters in file
457 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
461 return M_PROPERTY_UNAVAILABLE
;
462 if (mpctx
->demuxer
->num_chapters
== 0)
463 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
464 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
467 /// Current dvd angle (RW)
468 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
473 char *angle_name
= NULL
;
476 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
478 return M_PROPERTY_UNAVAILABLE
;
479 angles
= demuxer_angles_count(mpctx
->demuxer
);
481 return M_PROPERTY_UNAVAILABLE
;
486 return M_PROPERTY_ERROR
;
487 *(int *) arg
= angle
;
488 return M_PROPERTY_OK
;
489 case M_PROPERTY_PRINT
: {
491 return M_PROPERTY_ERROR
;
492 angle_name
= calloc(1, 64);
494 return M_PROPERTY_UNAVAILABLE
;
495 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
496 *(char **) arg
= angle_name
;
497 return M_PROPERTY_OK
;
501 return M_PROPERTY_ERROR
;
503 M_PROPERTY_CLAMP(prop
, angle
);
505 case M_PROPERTY_STEP_UP
:
506 case M_PROPERTY_STEP_DOWN
: {
512 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
514 if (angle
< 1) //cycle
519 return M_PROPERTY_NOT_IMPLEMENTED
;
521 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
522 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
523 MSGTR_OSDAngle
, angle
, angles
);
526 return M_PROPERTY_OK
;
529 /// Demuxer meta data
530 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
532 m_property_action_t
* ka
;
534 static const m_option_t key_type
=
535 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
537 return M_PROPERTY_UNAVAILABLE
;
541 if(!arg
) return M_PROPERTY_ERROR
;
542 *(char***)arg
= mpctx
->demuxer
->info
;
543 return M_PROPERTY_OK
;
544 case M_PROPERTY_KEY_ACTION
:
545 if(!arg
) return M_PROPERTY_ERROR
;
547 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
548 return M_PROPERTY_UNKNOWN
;
551 if(!ka
->arg
) return M_PROPERTY_ERROR
;
552 *(char**)ka
->arg
= meta
;
553 return M_PROPERTY_OK
;
554 case M_PROPERTY_GET_TYPE
:
555 if(!ka
->arg
) return M_PROPERTY_ERROR
;
556 *(m_option_t
**)ka
->arg
= &key_type
;
557 return M_PROPERTY_OK
;
560 return M_PROPERTY_NOT_IMPLEMENTED
;
563 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
566 MPContext
*mpctx
= ctx
;
571 return M_PROPERTY_ERROR
;
572 if (mpctx
->paused
== (bool)*(int *) arg
)
573 return M_PROPERTY_OK
;
574 case M_PROPERTY_STEP_UP
:
575 case M_PROPERTY_STEP_DOWN
:
577 unpause_player(mpctx
);
580 return M_PROPERTY_OK
;
582 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
589 /// \defgroup AudioProperties Audio properties
590 /// \ingroup Properties
594 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
598 if (!mpctx
->sh_audio
)
599 return M_PROPERTY_UNAVAILABLE
;
604 return M_PROPERTY_ERROR
;
605 mixer_getbothvolume(&mpctx
->mixer
, arg
);
606 return M_PROPERTY_OK
;
607 case M_PROPERTY_PRINT
:{
610 return M_PROPERTY_ERROR
;
611 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
612 return m_property_float_range(prop
, action
, arg
, &vol
);
614 case M_PROPERTY_STEP_UP
:
615 case M_PROPERTY_STEP_DOWN
:
619 return M_PROPERTY_NOT_IMPLEMENTED
;
622 if (mpctx
->edl_muted
)
623 return M_PROPERTY_DISABLED
;
624 mpctx
->user_muted
= 0;
629 return M_PROPERTY_ERROR
;
630 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
631 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
632 return M_PROPERTY_OK
;
633 case M_PROPERTY_STEP_UP
:
634 if (arg
&& *(float *) arg
<= 0)
635 mixer_decvolume(&mpctx
->mixer
);
637 mixer_incvolume(&mpctx
->mixer
);
638 return M_PROPERTY_OK
;
639 case M_PROPERTY_STEP_DOWN
:
640 if (arg
&& *(float *) arg
<= 0)
641 mixer_incvolume(&mpctx
->mixer
);
643 mixer_decvolume(&mpctx
->mixer
);
644 return M_PROPERTY_OK
;
646 return M_PROPERTY_NOT_IMPLEMENTED
;
650 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
654 if (!mpctx
->sh_audio
)
655 return M_PROPERTY_UNAVAILABLE
;
659 if (mpctx
->edl_muted
)
660 return M_PROPERTY_DISABLED
;
662 return M_PROPERTY_ERROR
;
663 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
664 mixer_mute(&mpctx
->mixer
);
665 mpctx
->user_muted
= mpctx
->mixer
.muted
;
666 return M_PROPERTY_OK
;
667 case M_PROPERTY_STEP_UP
:
668 case M_PROPERTY_STEP_DOWN
:
669 if (mpctx
->edl_muted
)
670 return M_PROPERTY_DISABLED
;
671 mixer_mute(&mpctx
->mixer
);
672 mpctx
->user_muted
= mpctx
->mixer
.muted
;
673 return M_PROPERTY_OK
;
674 case M_PROPERTY_PRINT
:
676 return M_PROPERTY_ERROR
;
677 if (mpctx
->edl_muted
) {
678 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
679 return M_PROPERTY_OK
;
682 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
688 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
689 void *arg
, MPContext
*mpctx
)
691 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
692 return M_PROPERTY_UNAVAILABLE
;
695 case M_PROPERTY_STEP_UP
:
696 case M_PROPERTY_STEP_DOWN
: {
698 float delay
= audio_delay
;
699 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
700 if (ret
!= M_PROPERTY_OK
)
703 mpctx
->delay
-= audio_delay
- delay
;
705 return M_PROPERTY_OK
;
707 return m_property_delay(prop
, action
, arg
, &audio_delay
);
711 /// Audio codec tag (RO)
712 static int mp_property_audio_format(m_option_t
*prop
, int action
,
713 void *arg
, MPContext
*mpctx
)
715 if (!mpctx
->sh_audio
)
716 return M_PROPERTY_UNAVAILABLE
;
717 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
720 /// Audio codec name (RO)
721 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
722 void *arg
, MPContext
*mpctx
)
724 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
725 return M_PROPERTY_UNAVAILABLE
;
726 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
729 /// Audio bitrate (RO)
730 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
731 void *arg
, MPContext
*mpctx
)
733 if (!mpctx
->sh_audio
)
734 return M_PROPERTY_UNAVAILABLE
;
735 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
739 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
742 if (!mpctx
->sh_audio
)
743 return M_PROPERTY_UNAVAILABLE
;
745 case M_PROPERTY_PRINT
:
746 if(!arg
) return M_PROPERTY_ERROR
;
747 *(char**)arg
= malloc(16);
748 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
749 return M_PROPERTY_OK
;
751 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
754 /// Number of channels (RO)
755 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
758 if (!mpctx
->sh_audio
)
759 return M_PROPERTY_UNAVAILABLE
;
761 case M_PROPERTY_PRINT
:
763 return M_PROPERTY_ERROR
;
764 switch (mpctx
->sh_audio
->channels
) {
766 *(char **) arg
= strdup("mono");
769 *(char **) arg
= strdup("stereo");
772 *(char **) arg
= malloc(32);
773 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
775 return M_PROPERTY_OK
;
777 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
781 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
786 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
787 return M_PROPERTY_UNAVAILABLE
;
792 return M_PROPERTY_ERROR
;
793 mixer_getbalance(&mpctx
->mixer
, arg
);
794 return M_PROPERTY_OK
;
795 case M_PROPERTY_PRINT
: {
798 return M_PROPERTY_ERROR
;
799 mixer_getbalance(&mpctx
->mixer
, &bal
);
801 *str
= strdup("center");
802 else if (bal
== -1.f
)
803 *str
= strdup("left only");
805 *str
= strdup("right only");
807 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
808 *str
= malloc(sizeof("left xxx%, right xxx%"));
809 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
811 return M_PROPERTY_OK
;
813 case M_PROPERTY_STEP_UP
:
814 case M_PROPERTY_STEP_DOWN
:
815 mixer_getbalance(&mpctx
->mixer
, &bal
);
816 bal
+= (arg
? *(float*)arg
: .1f
) *
817 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
818 M_PROPERTY_CLAMP(prop
, bal
);
819 mixer_setbalance(&mpctx
->mixer
, bal
);
820 return M_PROPERTY_OK
;
823 return M_PROPERTY_ERROR
;
824 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
825 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
826 return M_PROPERTY_OK
;
828 return M_PROPERTY_NOT_IMPLEMENTED
;
831 /// Selected audio id (RW)
832 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
835 struct MPOpts
*opts
= &mpctx
->opts
;
836 int current_id
= -1, tmp
;
840 if (!mpctx
->sh_audio
)
841 return M_PROPERTY_UNAVAILABLE
;
843 return M_PROPERTY_ERROR
;
844 *(int *) arg
= opts
->audio_id
;
845 return M_PROPERTY_OK
;
846 case M_PROPERTY_PRINT
:
847 if (!mpctx
->sh_audio
)
848 return M_PROPERTY_UNAVAILABLE
;
850 return M_PROPERTY_ERROR
;
852 if (opts
->audio_id
< 0)
853 *(char **) arg
= strdup(MSGTR_Disabled
);
855 char lang
[40] = MSGTR_Unknown
;
856 sh_audio_t
* sh
= mpctx
->sh_audio
;
858 av_strlcpy(lang
, sh
->lang
, 40);
859 #ifdef CONFIG_DVDREAD
860 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
861 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
871 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
872 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
874 *(char **) arg
= malloc(64);
875 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
877 return M_PROPERTY_OK
;
879 case M_PROPERTY_STEP_UP
:
882 return M_PROPERTY_UNAVAILABLE
;
883 if (action
== M_PROPERTY_SET
&& arg
)
884 tmp
= *((int *) arg
);
887 current_id
= mpctx
->demuxer
->audio
->id
;
888 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
889 if (opts
->audio_id
== -2
890 || (opts
->audio_id
> -1
891 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
892 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
893 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
895 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
897 sh2
->ds
= mpctx
->demuxer
->audio
;
898 mpctx
->sh_audio
= sh2
;
899 reinit_audio_chain(mpctx
);
902 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
903 return M_PROPERTY_OK
;
905 return M_PROPERTY_NOT_IMPLEMENTED
;
910 /// Selected video id (RW)
911 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
914 struct MPOpts
*opts
= &mpctx
->opts
;
915 int current_id
= -1, tmp
;
919 if (!mpctx
->sh_video
)
920 return M_PROPERTY_UNAVAILABLE
;
922 return M_PROPERTY_ERROR
;
923 *(int *) arg
= opts
->video_id
;
924 return M_PROPERTY_OK
;
925 case M_PROPERTY_PRINT
:
926 if (!mpctx
->sh_video
)
927 return M_PROPERTY_UNAVAILABLE
;
929 return M_PROPERTY_ERROR
;
931 if (opts
->video_id
< 0)
932 *(char **) arg
= strdup(MSGTR_Disabled
);
934 char lang
[40] = MSGTR_Unknown
;
935 *(char **) arg
= malloc(64);
936 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
938 return M_PROPERTY_OK
;
940 case M_PROPERTY_STEP_UP
:
942 current_id
= mpctx
->demuxer
->video
->id
;
943 if (action
== M_PROPERTY_SET
&& arg
)
944 tmp
= *((int *) arg
);
947 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
948 if (opts
->video_id
== -2
949 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
950 && current_id
!= -2))
951 uninit_player(mpctx
, INITIALIZED_VCODEC
|
952 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
953 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
955 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
957 sh2
->ds
= mpctx
->demuxer
->video
;
958 mpctx
->sh_video
= sh2
;
959 reinit_video_chain(mpctx
);
962 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
963 return M_PROPERTY_OK
;
966 return M_PROPERTY_NOT_IMPLEMENTED
;
970 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
973 demux_program_t prog
;
976 case M_PROPERTY_STEP_UP
:
978 if (action
== M_PROPERTY_SET
&& arg
)
979 prog
.progid
= *((int *) arg
);
983 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
984 &prog
) == DEMUXER_CTRL_NOTIMPL
)
985 return M_PROPERTY_ERROR
;
987 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
988 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
989 return M_PROPERTY_OK
;
992 return M_PROPERTY_NOT_IMPLEMENTED
;
998 /// \defgroup VideoProperties Video properties
999 /// \ingroup Properties
1002 /// Fullscreen state (RW)
1003 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1007 if (!mpctx
->video_out
)
1008 return M_PROPERTY_UNAVAILABLE
;
1011 case M_PROPERTY_SET
:
1013 return M_PROPERTY_ERROR
;
1014 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1015 if (vo_fs
== !!*(int *) arg
)
1016 return M_PROPERTY_OK
;
1017 case M_PROPERTY_STEP_UP
:
1018 case M_PROPERTY_STEP_DOWN
:
1021 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
1024 if (mpctx
->video_out
->config_ok
)
1025 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1026 return M_PROPERTY_OK
;
1028 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1032 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1033 void *arg
, MPContext
*mpctx
)
1037 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1038 return M_PROPERTY_UNAVAILABLE
;
1039 vf
= mpctx
->sh_video
->vfilter
;
1041 case M_PROPERTY_GET
:
1043 return M_PROPERTY_ERROR
;
1044 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1045 return M_PROPERTY_OK
;
1046 case M_PROPERTY_SET
:
1048 return M_PROPERTY_ERROR
;
1049 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1050 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1051 return M_PROPERTY_OK
;
1052 case M_PROPERTY_STEP_UP
:
1053 case M_PROPERTY_STEP_DOWN
:
1054 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1055 deinterlace
= !deinterlace
;
1056 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1057 return M_PROPERTY_OK
;
1059 return M_PROPERTY_NOT_IMPLEMENTED
;
1063 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1067 if (!mpctx
->video_out
1068 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1069 return M_PROPERTY_UNAVAILABLE
;
1072 case M_PROPERTY_SET
:
1074 return M_PROPERTY_ERROR
;
1075 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1076 vo_panscan
= *(float *) arg
;
1077 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1078 return M_PROPERTY_OK
;
1079 case M_PROPERTY_STEP_UP
:
1080 case M_PROPERTY_STEP_DOWN
:
1081 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1082 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1085 else if (vo_panscan
< 0)
1087 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1088 return M_PROPERTY_OK
;
1090 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1094 /// Helper to set vo flags.
1095 /** \ingroup PropertyImplHelper
1097 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1098 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1101 if (!mpctx
->video_out
)
1102 return M_PROPERTY_UNAVAILABLE
;
1105 case M_PROPERTY_SET
:
1107 return M_PROPERTY_ERROR
;
1108 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1109 if (*vo_var
== !!*(int *) arg
)
1110 return M_PROPERTY_OK
;
1111 case M_PROPERTY_STEP_UP
:
1112 case M_PROPERTY_STEP_DOWN
:
1113 if (mpctx
->video_out
->config_ok
)
1114 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1115 return M_PROPERTY_OK
;
1117 return m_property_flag(prop
, action
, arg
, vo_var
);
1121 /// Window always on top (RW)
1122 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1125 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1126 &mpctx
->opts
.vo_ontop
, mpctx
);
1129 /// Display in the root window (RW)
1130 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1133 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1134 &vo_rootwin
, mpctx
);
1137 /// Show window borders (RW)
1138 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1141 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1145 /// Framedropping state (RW)
1146 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1147 void *arg
, MPContext
*mpctx
)
1150 if (!mpctx
->sh_video
)
1151 return M_PROPERTY_UNAVAILABLE
;
1154 case M_PROPERTY_PRINT
:
1156 return M_PROPERTY_ERROR
;
1157 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1158 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1160 return M_PROPERTY_OK
;
1162 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1166 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1167 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1170 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1173 if (!mpctx
->sh_video
)
1174 return M_PROPERTY_UNAVAILABLE
;
1176 if (gamma
[0] == 1000) {
1178 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1182 case M_PROPERTY_SET
:
1184 return M_PROPERTY_ERROR
;
1185 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1186 *gamma
= *(int *) arg
;
1187 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1191 case M_PROPERTY_GET
:
1192 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1194 return M_PROPERTY_ERROR
;
1196 return M_PROPERTY_OK
;
1199 case M_PROPERTY_STEP_UP
:
1200 case M_PROPERTY_STEP_DOWN
:
1201 *gamma
+= (arg
? *(int *) arg
: 1) *
1202 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1203 M_PROPERTY_CLAMP(prop
, *gamma
);
1204 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1209 return M_PROPERTY_NOT_IMPLEMENTED
;
1213 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1214 int l
= strlen(prop
->name
);
1215 char tv_prop
[3 + l
+ 1];
1216 sprintf(tv_prop
, "tv_%s", prop
->name
);
1217 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1221 return M_PROPERTY_UNAVAILABLE
;
1225 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1228 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1231 /// Video codec tag (RO)
1232 static int mp_property_video_format(m_option_t
*prop
, int action
,
1233 void *arg
, MPContext
*mpctx
)
1236 if (!mpctx
->sh_video
)
1237 return M_PROPERTY_UNAVAILABLE
;
1239 case M_PROPERTY_PRINT
:
1241 return M_PROPERTY_ERROR
;
1242 switch(mpctx
->sh_video
->format
) {
1244 meta
= strdup ("mpeg1"); break;
1246 meta
= strdup ("mpeg2"); break;
1248 meta
= strdup ("mpeg4"); break;
1250 meta
= strdup ("h264"); break;
1252 if(mpctx
->sh_video
->format
>= 0x20202020) {
1254 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1257 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1260 *(char**)arg
= meta
;
1261 return M_PROPERTY_OK
;
1263 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1266 /// Video codec name (RO)
1267 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1268 void *arg
, MPContext
*mpctx
)
1270 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1271 return M_PROPERTY_UNAVAILABLE
;
1272 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1276 /// Video bitrate (RO)
1277 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1278 void *arg
, MPContext
*mpctx
)
1280 if (!mpctx
->sh_video
)
1281 return M_PROPERTY_UNAVAILABLE
;
1282 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1285 /// Video display width (RO)
1286 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1289 if (!mpctx
->sh_video
)
1290 return M_PROPERTY_UNAVAILABLE
;
1291 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1294 /// Video display height (RO)
1295 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1298 if (!mpctx
->sh_video
)
1299 return M_PROPERTY_UNAVAILABLE
;
1300 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1304 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1307 if (!mpctx
->sh_video
)
1308 return M_PROPERTY_UNAVAILABLE
;
1309 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1312 /// Video aspect (RO)
1313 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1316 if (!mpctx
->sh_video
)
1317 return M_PROPERTY_UNAVAILABLE
;
1318 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1323 /// \defgroup SubProprties Subtitles properties
1324 /// \ingroup Properties
1327 /// Text subtitle position (RW)
1328 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1331 if (!mpctx
->sh_video
)
1332 return M_PROPERTY_UNAVAILABLE
;
1335 case M_PROPERTY_SET
:
1337 return M_PROPERTY_ERROR
;
1338 case M_PROPERTY_STEP_UP
:
1339 case M_PROPERTY_STEP_DOWN
:
1340 vo_osd_changed(OSDTYPE_SUBTITLE
);
1342 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1346 /// Selected subtitles (RW)
1347 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1350 struct MPOpts
*opts
= &mpctx
->opts
;
1351 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1352 const int global_sub_size
= mpctx
->global_sub_size
;
1353 int source
= -1, reset_spu
= 0;
1356 if (global_sub_size
<= 0)
1357 return M_PROPERTY_UNAVAILABLE
;
1360 case M_PROPERTY_GET
:
1362 return M_PROPERTY_ERROR
;
1363 *(int *) arg
= mpctx
->global_sub_pos
;
1364 return M_PROPERTY_OK
;
1365 case M_PROPERTY_PRINT
:
1367 return M_PROPERTY_ERROR
;
1368 *(char **) arg
= malloc(64);
1369 (*(char **) arg
)[63] = 0;
1372 sub_name
= subdata
->filename
;
1374 if (ass_track
&& ass_track
->name
)
1375 sub_name
= ass_track
->name
;
1380 if ((tmp2
= strrchr(tmp
, '/')))
1383 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1384 mpctx
->set_of_sub_pos
+ 1,
1385 strlen(tmp
) < 20 ? "" : "...",
1386 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1387 return M_PROPERTY_OK
;
1389 #ifdef CONFIG_DVDNAV
1390 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1391 if (vo_spudec
&& opts
->sub_id
>= 0) {
1392 unsigned char lang
[3];
1393 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1394 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1395 return M_PROPERTY_OK
;
1401 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1402 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1403 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1404 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1405 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1406 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1407 if (!lang
) lang
= MSGTR_Unknown
;
1408 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1409 return M_PROPERTY_OK
;
1412 if (vo_vobsub
&& vobsub_id
>= 0) {
1413 const char *language
= MSGTR_Unknown
;
1414 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1415 snprintf(*(char **) arg
, 63, "(%d) %s",
1416 vobsub_id
, language
? language
: MSGTR_Unknown
);
1417 return M_PROPERTY_OK
;
1419 #ifdef CONFIG_DVDREAD
1420 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1421 && opts
->sub_id
>= 0) {
1423 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1424 lang
[0] = code
>> 8;
1427 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1428 return M_PROPERTY_OK
;
1431 if (opts
->sub_id
>= 0) {
1432 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, MSGTR_Unknown
);
1433 return M_PROPERTY_OK
;
1435 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1436 return M_PROPERTY_OK
;
1438 case M_PROPERTY_SET
:
1440 return M_PROPERTY_ERROR
;
1441 if (*(int *) arg
< -1)
1443 else if (*(int *) arg
>= global_sub_size
)
1444 *(int *) arg
= global_sub_size
- 1;
1445 mpctx
->global_sub_pos
= *(int *) arg
;
1447 case M_PROPERTY_STEP_UP
:
1448 mpctx
->global_sub_pos
+= 2;
1449 mpctx
->global_sub_pos
=
1450 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1452 case M_PROPERTY_STEP_DOWN
:
1453 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1454 mpctx
->global_sub_pos
=
1455 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1458 return M_PROPERTY_NOT_IMPLEMENTED
;
1461 if (mpctx
->global_sub_pos
>= 0)
1462 source
= sub_source(mpctx
);
1464 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1465 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1467 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1468 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1469 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1470 mpctx
->global_sub_pos
, source
);
1472 mpctx
->set_of_sub_pos
= -1;
1486 if (source
== SUB_SOURCE_VOBSUB
) {
1487 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1488 } else if (source
== SUB_SOURCE_SUBS
) {
1489 mpctx
->set_of_sub_pos
=
1490 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1492 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1493 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1497 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1498 vo_osd_changed(OSDTYPE_SUBTITLE
);
1500 } else if (source
== SUB_SOURCE_DEMUX
) {
1502 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1503 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1505 // default: assume 1:1 mapping of sid and stream id
1506 d_sub
->id
= opts
->sub_id
;
1507 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1508 ds_free_packs(d_sub
);
1509 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1510 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1511 if (sh
&& sh
->sid
== opts
->sub_id
) {
1517 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1518 sh_sub_t
*sh
= d_sub
->sh
;
1519 if (sh
->type
== 'v')
1520 init_vo_spudec(mpctx
);
1522 else if (ass_enabled
)
1523 ass_track
= sh
->ass_track
;
1531 #ifdef CONFIG_DVDREAD
1533 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1534 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1535 && opts
->sub_id
< 0 && reset_spu
) {
1537 d_sub
->id
= opts
->sub_id
;
1540 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1542 return M_PROPERTY_OK
;
1545 /// Selected sub source (RW)
1546 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1550 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1551 return M_PROPERTY_UNAVAILABLE
;
1554 case M_PROPERTY_GET
:
1556 return M_PROPERTY_ERROR
;
1557 *(int *) arg
= sub_source(mpctx
);
1558 return M_PROPERTY_OK
;
1559 case M_PROPERTY_PRINT
:
1561 return M_PROPERTY_ERROR
;
1562 *(char **) arg
= malloc(64);
1563 (*(char **) arg
)[63] = 0;
1564 switch (sub_source(mpctx
))
1566 case SUB_SOURCE_SUBS
:
1567 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1569 case SUB_SOURCE_VOBSUB
:
1570 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1572 case SUB_SOURCE_DEMUX
:
1573 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1576 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1578 return M_PROPERTY_OK
;
1579 case M_PROPERTY_SET
:
1581 return M_PROPERTY_ERROR
;
1582 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1583 if (*(int *) arg
< 0)
1584 mpctx
->global_sub_pos
= -1;
1585 else if (*(int *) arg
!= sub_source(mpctx
)) {
1586 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1587 return M_PROPERTY_UNAVAILABLE
;
1588 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1591 case M_PROPERTY_STEP_UP
:
1592 case M_PROPERTY_STEP_DOWN
: {
1593 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1594 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1595 int step
= (step_all
> 0) ? 1 : -1;
1596 int cur_source
= sub_source(mpctx
);
1597 source
= cur_source
;
1600 if (source
>= SUB_SOURCES
)
1602 else if (source
< -1)
1603 source
= SUB_SOURCES
- 1;
1604 if (source
== cur_source
|| source
== -1 ||
1605 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1608 if (source
== cur_source
)
1609 return M_PROPERTY_OK
;
1611 mpctx
->global_sub_pos
= -1;
1613 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1617 return M_PROPERTY_NOT_IMPLEMENTED
;
1619 --mpctx
->global_sub_pos
;
1620 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1623 /// Selected subtitles from specific source (RW)
1624 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1627 int source
, is_cur_source
, offset
;
1628 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1629 return M_PROPERTY_UNAVAILABLE
;
1631 if (!strcmp(prop
->name
, "sub_file"))
1632 source
= SUB_SOURCE_SUBS
;
1633 else if (!strcmp(prop
->name
, "sub_vob"))
1634 source
= SUB_SOURCE_VOBSUB
;
1635 else if (!strcmp(prop
->name
, "sub_demux"))
1636 source
= SUB_SOURCE_DEMUX
;
1638 return M_PROPERTY_ERROR
;
1640 offset
= mpctx
->global_sub_indices
[source
];
1641 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1642 return M_PROPERTY_UNAVAILABLE
;
1644 is_cur_source
= sub_source(mpctx
) == source
;
1646 case M_PROPERTY_GET
:
1648 return M_PROPERTY_ERROR
;
1649 if (is_cur_source
) {
1650 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1651 if (source
== SUB_SOURCE_VOBSUB
)
1652 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1656 return M_PROPERTY_OK
;
1657 case M_PROPERTY_PRINT
:
1659 return M_PROPERTY_ERROR
;
1661 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1662 *(char **) arg
= malloc(64);
1663 (*(char **) arg
)[63] = 0;
1664 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1665 return M_PROPERTY_OK
;
1666 case M_PROPERTY_SET
:
1668 return M_PROPERTY_ERROR
;
1669 if (*(int *) arg
>= 0) {
1670 int index
= *(int *)arg
;
1671 if (source
== SUB_SOURCE_VOBSUB
)
1672 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1673 mpctx
->global_sub_pos
= offset
+ index
;
1674 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1675 || sub_source(mpctx
) != source
) {
1676 mpctx
->global_sub_pos
= -1;
1681 mpctx
->global_sub_pos
= -1;
1683 case M_PROPERTY_STEP_UP
:
1684 case M_PROPERTY_STEP_DOWN
: {
1685 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1686 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1687 int step
= (step_all
> 0) ? 1 : -1;
1688 int max_sub_pos_for_source
= -1;
1690 mpctx
->global_sub_pos
= -1;
1692 if (mpctx
->global_sub_pos
== -1) {
1694 mpctx
->global_sub_pos
= offset
;
1695 else if (max_sub_pos_for_source
== -1) {
1696 // Find max pos for specific source
1697 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1698 while (mpctx
->global_sub_pos
>= 0
1699 && sub_source(mpctx
) != source
)
1700 --mpctx
->global_sub_pos
;
1703 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1706 mpctx
->global_sub_pos
+= step
;
1707 if (mpctx
->global_sub_pos
< offset
||
1708 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1709 sub_source(mpctx
) != source
)
1710 mpctx
->global_sub_pos
= -1;
1717 return M_PROPERTY_NOT_IMPLEMENTED
;
1719 --mpctx
->global_sub_pos
;
1720 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1723 /// Subtitle delay (RW)
1724 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1727 if (!mpctx
->sh_video
)
1728 return M_PROPERTY_UNAVAILABLE
;
1729 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1732 /// Alignment of text subtitles (RW)
1733 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1734 void *arg
, MPContext
*mpctx
)
1736 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1738 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1739 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1740 return M_PROPERTY_UNAVAILABLE
;
1743 case M_PROPERTY_PRINT
:
1745 return M_PROPERTY_ERROR
;
1746 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1747 *(char **) arg
= strdup(name
[sub_alignment
]);
1748 return M_PROPERTY_OK
;
1749 case M_PROPERTY_SET
:
1751 return M_PROPERTY_ERROR
;
1752 case M_PROPERTY_STEP_UP
:
1753 case M_PROPERTY_STEP_DOWN
:
1754 vo_osd_changed(OSDTYPE_SUBTITLE
);
1756 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1760 /// Subtitle visibility (RW)
1761 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1762 void *arg
, MPContext
*mpctx
)
1764 if (!mpctx
->sh_video
)
1765 return M_PROPERTY_UNAVAILABLE
;
1768 case M_PROPERTY_SET
:
1770 return M_PROPERTY_ERROR
;
1771 case M_PROPERTY_STEP_UP
:
1772 case M_PROPERTY_STEP_DOWN
:
1773 vo_osd_changed(OSDTYPE_SUBTITLE
);
1775 vo_osd_changed(OSDTYPE_SPU
);
1777 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1782 /// Use margins for libass subtitles (RW)
1783 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1784 void *arg
, MPContext
*mpctx
)
1786 if (!mpctx
->sh_video
)
1787 return M_PROPERTY_UNAVAILABLE
;
1790 case M_PROPERTY_SET
:
1792 return M_PROPERTY_ERROR
;
1793 case M_PROPERTY_STEP_UP
:
1794 case M_PROPERTY_STEP_DOWN
:
1795 ass_force_reload
= 1;
1797 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1802 /// Show only forced subtitles (RW)
1803 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1804 void *arg
, MPContext
*mpctx
)
1807 return M_PROPERTY_UNAVAILABLE
;
1810 case M_PROPERTY_SET
:
1812 return M_PROPERTY_ERROR
;
1813 case M_PROPERTY_STEP_UP
:
1814 case M_PROPERTY_STEP_DOWN
:
1815 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1816 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1817 return M_PROPERTY_OK
;
1819 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1824 #ifdef CONFIG_FREETYPE
1825 /// Subtitle scale (RW)
1826 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1831 case M_PROPERTY_SET
:
1833 return M_PROPERTY_ERROR
;
1834 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1837 ass_font_scale
= *(float *) arg
;
1838 ass_force_reload
= 1;
1841 text_font_scale_factor
= *(float *) arg
;
1842 force_load_font
= 1;
1843 return M_PROPERTY_OK
;
1844 case M_PROPERTY_STEP_UP
:
1845 case M_PROPERTY_STEP_DOWN
:
1848 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1849 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1850 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1851 ass_force_reload
= 1;
1854 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1855 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1856 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1857 force_load_font
= 1;
1858 return M_PROPERTY_OK
;
1862 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1865 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1872 /// \defgroup TVProperties TV properties
1873 /// \ingroup Properties
1878 /// TV color settings (RW)
1879 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1883 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1884 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1885 return M_PROPERTY_UNAVAILABLE
;
1888 case M_PROPERTY_SET
:
1890 return M_PROPERTY_ERROR
;
1891 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1892 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1893 case M_PROPERTY_GET
:
1894 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1895 case M_PROPERTY_STEP_UP
:
1896 case M_PROPERTY_STEP_DOWN
:
1897 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1899 return M_PROPERTY_ERROR
;
1900 val
+= (arg
? *(int *) arg
: 1) *
1901 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1902 M_PROPERTY_CLAMP(prop
, val
);
1903 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1905 return M_PROPERTY_ERROR
;
1907 return M_PROPERTY_NOT_IMPLEMENTED
;
1912 #ifdef CONFIG_TV_TELETEXT
1913 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1917 int base_ioctl
=(int)prop
->priv
;
1919 for teletext's GET,SET,STEP ioctls this is not 0
1923 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1924 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1925 return M_PROPERTY_UNAVAILABLE
;
1927 return M_PROPERTY_ERROR
;
1930 case M_PROPERTY_GET
:
1932 return M_PROPERTY_ERROR
;
1933 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1935 case M_PROPERTY_SET
:
1937 return M_PROPERTY_ERROR
;
1938 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1939 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1941 case M_PROPERTY_STEP_UP
:
1942 case M_PROPERTY_STEP_DOWN
:
1943 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1944 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1945 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1948 return M_PROPERTY_NOT_IMPLEMENTED
;
1951 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1954 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1957 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1961 //with tvh==NULL will fail too
1962 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1963 if(result
!=M_PROPERTY_OK
)
1966 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1967 mp_input_set_section(mpctx
->input
, "teletext");
1969 mp_input_set_section(mpctx
->input
, "tv");
1970 return M_PROPERTY_OK
;
1973 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1976 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1979 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1980 return M_PROPERTY_UNAVAILABLE
;
1982 case M_PROPERTY_STEP_UP
:
1983 case M_PROPERTY_STEP_DOWN
:
1984 //This should be handled separately
1985 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1986 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1989 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1995 #endif /* CONFIG_TV_TELETEXT */
1999 /// All properties available in MPlayer.
2000 /** \ingroup Properties
2002 static const m_option_t mp_properties
[] = {
2004 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2005 M_OPT_RANGE
, 0, 3, NULL
},
2006 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2007 M_OPT_MIN
, -1, 0, NULL
},
2008 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2009 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2010 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2012 { "path", mp_property_path
, CONF_TYPE_STRING
,
2014 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2016 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2017 M_OPT_MIN
, 0, 0, NULL
},
2018 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2019 M_OPT_MIN
, 0, 0, NULL
},
2020 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2021 M_OPT_MIN
, 0, 0, NULL
},
2022 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2023 M_OPT_MIN
, 0, 0, NULL
},
2024 { "length", mp_property_length
, CONF_TYPE_TIME
,
2025 M_OPT_MIN
, 0, 0, NULL
},
2026 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2027 M_OPT_RANGE
, 0, 100, NULL
},
2028 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2029 M_OPT_MIN
, 0, 0, NULL
},
2030 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2031 M_OPT_MIN
, 1, 0, NULL
},
2032 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2034 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2035 CONF_RANGE
, -2, 10, NULL
},
2036 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2038 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2039 M_OPT_RANGE
, 0, 1, NULL
},
2042 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2043 M_OPT_RANGE
, 0, 100, NULL
},
2044 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2045 M_OPT_RANGE
, 0, 1, NULL
},
2046 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2047 M_OPT_RANGE
, -100, 100, NULL
},
2048 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2050 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2052 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2054 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2056 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2058 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2059 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2060 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2061 M_OPT_RANGE
, -1, 1, NULL
},
2064 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2065 M_OPT_RANGE
, 0, 1, NULL
},
2066 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2067 M_OPT_RANGE
, 0, 1, NULL
},
2068 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2069 M_OPT_RANGE
, 0, 1, NULL
},
2070 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2071 M_OPT_RANGE
, 0, 1, NULL
},
2072 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2073 M_OPT_RANGE
, 0, 1, NULL
},
2074 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2075 M_OPT_RANGE
, 0, 2, NULL
},
2076 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2077 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2078 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2080 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2081 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2082 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2083 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2084 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2085 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2086 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2087 M_OPT_RANGE
, 0, 1, NULL
},
2088 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2089 M_OPT_RANGE
, 0, 1, NULL
},
2090 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2092 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2094 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2096 { "width", mp_property_width
, CONF_TYPE_INT
,
2098 { "height", mp_property_height
, CONF_TYPE_INT
,
2100 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2102 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2104 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2105 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2106 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2107 CONF_RANGE
, -1, 65535, NULL
},
2110 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2111 M_OPT_MIN
, -1, 0, NULL
},
2112 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2114 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2115 M_OPT_MIN
, -1, 0, NULL
},
2116 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2117 M_OPT_MIN
, -1, 0, NULL
},
2118 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2119 M_OPT_MIN
, -1, 0, NULL
},
2120 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2122 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2123 M_OPT_RANGE
, 0, 100, NULL
},
2124 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2125 M_OPT_RANGE
, 0, 2, NULL
},
2126 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2127 M_OPT_RANGE
, 0, 1, NULL
},
2128 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2129 M_OPT_RANGE
, 0, 1, NULL
},
2130 #ifdef CONFIG_FREETYPE
2131 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2132 M_OPT_RANGE
, 0, 100, NULL
},
2135 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2136 M_OPT_RANGE
, 0, 1, NULL
},
2140 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2141 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2142 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2143 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2144 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2145 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2146 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2147 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2150 #ifdef CONFIG_TV_TELETEXT
2151 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2152 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2153 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2154 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2155 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2156 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2157 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2158 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2159 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2160 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2163 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2167 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2169 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2172 char* mp_property_print(const char *name
, void* ctx
)
2175 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2180 char *property_expand_string(MPContext
*mpctx
, char *str
)
2182 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2185 void property_print_help(void)
2187 m_properties_print_help_list(mp_properties
);
2196 * \defgroup Command2Property Command to property bridge
2198 * It is used to handle most commands that just set a property
2199 * and optionally display something on the OSD.
2200 * Two kinds of commands are handled: adjust or toggle.
2202 * Adjust commands take 1 or 2 parameters: <value> <abs>
2203 * If <abs> is non-zero the property is set to the given value
2204 * otherwise it is adjusted.
2206 * Toggle commands take 0 or 1 parameters. With no parameter
2207 * or a value less than the property minimum it just steps the
2208 * property to its next value. Otherwise it sets it to the given
2214 /// List of the commands that can be handled by setting a property.
2220 /// set/adjust or toggle command
2222 /// progressbar type
2224 /// osd msg id if it must be shared
2226 /// osd msg template
2227 const char *osd_msg
;
2228 } set_prop_cmd
[] = {
2230 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2231 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2232 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2233 { "pause", MP_CMD_PAUSE
, 0, 0, -1, NULL
},
2235 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2236 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2237 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2238 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2239 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2241 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2242 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2243 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2244 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2245 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2246 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2247 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2248 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2249 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2250 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2251 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2252 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2254 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2255 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2256 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2257 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2258 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2259 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2260 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2261 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2262 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2263 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2264 #ifdef CONFIG_FREETYPE
2265 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2268 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2271 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2272 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2273 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2274 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2276 { NULL
, 0, 0, 0, -1, NULL
}
2280 /// Handle commands that set a property.
2281 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2287 // look for the command
2288 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2289 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2291 if (!(pname
= set_prop_cmd
[i
].name
))
2294 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2298 if (set_prop_cmd
[i
].toggle
) {
2300 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2301 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2303 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2304 } else if (cmd
->args
[1].v
.i
) //set
2305 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2307 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2312 if (set_prop_cmd
[i
].osd_progbar
) {
2313 if (prop
->type
== CONF_TYPE_INT
) {
2314 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2315 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2316 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2317 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2319 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2320 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2321 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2323 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2324 "Property use an unsupported type.\n");
2328 if (set_prop_cmd
[i
].osd_msg
) {
2329 char *val
= mp_property_print(pname
, mpctx
);
2331 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2332 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2333 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2340 #ifdef CONFIG_DVDNAV
2341 static const struct {
2343 const mp_command_type cmd
;
2344 } mp_dvdnav_bindings
[] = {
2345 { "up", MP_CMD_DVDNAV_UP
},
2346 { "down", MP_CMD_DVDNAV_DOWN
},
2347 { "left", MP_CMD_DVDNAV_LEFT
},
2348 { "right", MP_CMD_DVDNAV_RIGHT
},
2349 { "menu", MP_CMD_DVDNAV_MENU
},
2350 { "select", MP_CMD_DVDNAV_SELECT
},
2351 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2352 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2355 * keep old dvdnav sub-command options for a while in order not to
2356 * break slave-mode API too suddenly.
2358 { "1", MP_CMD_DVDNAV_UP
},
2359 { "2", MP_CMD_DVDNAV_DOWN
},
2360 { "3", MP_CMD_DVDNAV_LEFT
},
2361 { "4", MP_CMD_DVDNAV_RIGHT
},
2362 { "5", MP_CMD_DVDNAV_MENU
},
2363 { "6", MP_CMD_DVDNAV_SELECT
},
2364 { "7", MP_CMD_DVDNAV_PREVMENU
},
2365 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2370 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2372 struct MPOpts
*opts
= &mpctx
->opts
;
2373 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2374 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2375 if (!set_property_command(mpctx
, cmd
))
2381 mpctx
->osd_show_percentage
= sh_video
->fps
;
2382 v
= cmd
->args
[0].v
.f
;
2383 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2384 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2385 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2387 mpctx
->osd_function
=
2388 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2389 mpctx
->rel_seek_secs
= v
;
2390 } else if (abs
) { /* Absolute seek by percentage */
2391 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2393 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2394 mpctx
->rel_seek_secs
= v
/ 100.0;
2396 mpctx
->rel_seek_secs
+= v
;
2397 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2402 case MP_CMD_SET_PROPERTY
:{
2403 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2404 cmd
->args
[1].v
.s
, mpctx
);
2405 if (r
== M_PROPERTY_UNKNOWN
)
2406 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2407 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2409 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2410 "Failed to set property '%s' to '%s'.\n",
2411 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2415 case MP_CMD_STEP_PROPERTY
:{
2420 if (cmd
->args
[1].v
.f
) {
2422 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2423 M_PROPERTY_GET_TYPE
,
2424 &prop
, mpctx
)) <= 0)
2426 if(prop
->type
== CONF_TYPE_INT
||
2427 prop
->type
== CONF_TYPE_FLAG
)
2428 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2429 else if(prop
->type
== CONF_TYPE_FLOAT
)
2430 arg
= &cmd
->args
[1].v
.f
;
2431 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2432 prop
->type
== CONF_TYPE_TIME
)
2433 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2434 else if(prop
->type
== CONF_TYPE_POSITION
)
2435 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2437 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2438 "Ignoring step size stepping property '%s'.\n",
2441 r
= mp_property_do(cmd
->args
[0].v
.s
,
2442 cmd
->args
[2].v
.i
< 0 ?
2443 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2446 if (r
== M_PROPERTY_UNKNOWN
)
2447 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2448 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2450 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2451 "Failed to increment property '%s' by %f.\n",
2452 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2456 case MP_CMD_GET_PROPERTY
:{
2458 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2459 &tmp
, mpctx
) <= 0) {
2460 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2461 "Failed to get value of property '%s'.\n",
2465 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2466 cmd
->args
[0].v
.s
, tmp
);
2471 case MP_CMD_EDL_MARK
:
2473 float v
= sh_video
? sh_video
->pts
:
2474 playing_audio_pts(mpctx
);
2475 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2476 mpctx
->begin_skip
= v
;
2477 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2479 if (mpctx
->begin_skip
> v
)
2480 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2482 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2483 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2485 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2490 case MP_CMD_SWITCH_RATIO
:
2491 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2492 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2494 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2495 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2498 case MP_CMD_SPEED_INCR
:{
2499 float v
= cmd
->args
[0].v
.f
;
2500 opts
->playback_speed
+= v
;
2501 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2502 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2503 opts
->playback_speed
);
2506 case MP_CMD_SPEED_MULT
:{
2507 float v
= cmd
->args
[0].v
.f
;
2508 opts
->playback_speed
*= v
;
2509 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2510 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2511 opts
->playback_speed
);
2514 case MP_CMD_SPEED_SET
:{
2515 float v
= cmd
->args
[0].v
.f
;
2516 opts
->playback_speed
= v
;
2517 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2518 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2519 opts
->playback_speed
);
2522 case MP_CMD_FRAME_STEP
:
2523 mpctx
->step_frames
++;
2524 unpause_player(mpctx
);
2527 case MP_CMD_FILE_FILTER
:
2528 file_filter
= cmd
->args
[0].v
.i
;
2532 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2533 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2535 case MP_CMD_PLAY_TREE_STEP
:{
2536 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2537 int force
= cmd
->args
[1].v
.i
;
2543 for (i
= 0; i
< n
; i
++)
2546 for (i
= 0; i
< -1 * n
; i
++)
2551 if (!force
&& mpctx
->playtree_iter
) {
2552 play_tree_iter_t
*i
=
2553 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2554 if (play_tree_iter_step(i
, n
, 0) ==
2555 PLAY_TREE_ITER_ENTRY
)
2557 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2558 play_tree_iter_free(i
);
2560 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2561 if (mpctx
->stop_play
)
2562 mpctx
->play_tree_step
= n
;
2567 case MP_CMD_PLAY_TREE_UP_STEP
:{
2568 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2569 int force
= cmd
->args
[1].v
.i
;
2571 if (!force
&& mpctx
->playtree_iter
) {
2572 play_tree_iter_t
*i
=
2573 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2574 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2575 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2576 play_tree_iter_free(i
);
2578 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2582 case MP_CMD_PLAY_ALT_SRC_STEP
:
2583 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2584 int v
= cmd
->args
[0].v
.i
;
2586 && mpctx
->playtree_iter
->file
<
2587 mpctx
->playtree_iter
->num_files
)
2588 mpctx
->stop_play
= PT_NEXT_SRC
;
2589 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2590 mpctx
->stop_play
= PT_PREV_SRC
;
2594 case MP_CMD_SUB_STEP
:
2596 int movement
= cmd
->args
[0].v
.i
;
2597 step_sub(subdata
, sh_video
->pts
, movement
);
2601 ass_step_sub(ass_track
,
2603 sub_delay
) * 1000 + .5, movement
) / 1000.;
2605 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2606 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2610 case MP_CMD_SUB_LOG
:
2615 int v
= cmd
->args
[0].v
.i
;
2617 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2618 if (osd_level
> max
)
2621 osd_level
= (osd_level
+ 1) % (max
+ 1);
2623 osd_level
= v
> max
? max
: v
;
2624 /* Show OSD state when disabled, but not when an explicit
2625 argument is given to the OSD command, i.e. in slave mode. */
2626 if (v
== -1 && osd_level
<= 1)
2627 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2629 osd_level
? MSGTR_OSDenabled
:
2632 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2636 case MP_CMD_OSD_SHOW_TEXT
:
2637 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2639 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2640 "%-.63s", cmd
->args
[0].v
.s
);
2643 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2644 char *txt
= m_properties_expand_string(mp_properties
,
2647 /* if no argument supplied take default osd_duration, else <arg> ms. */
2649 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2651 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2658 case MP_CMD_LOADFILE
:{
2659 play_tree_t
*e
= play_tree_new();
2660 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2662 if (cmd
->args
[1].v
.i
) // append
2663 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2665 // Go back to the starting point.
2666 while (play_tree_iter_up_step
2667 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2669 play_tree_free_list(mpctx
->playtree
->child
, 1);
2670 play_tree_set_child(mpctx
->playtree
, e
);
2671 pt_iter_goto_head(mpctx
->playtree_iter
);
2672 mpctx
->stop_play
= PT_NEXT_SRC
;
2677 case MP_CMD_LOADLIST
:{
2678 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2680 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2681 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2683 if (cmd
->args
[1].v
.i
) // append
2684 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2686 // Go back to the starting point.
2687 while (play_tree_iter_up_step
2688 (mpctx
->playtree_iter
, 0, 1)
2689 != PLAY_TREE_ITER_END
)
2691 play_tree_free_list(mpctx
->playtree
->child
, 1);
2692 play_tree_set_child(mpctx
->playtree
, e
);
2693 pt_iter_goto_head(mpctx
->playtree_iter
);
2694 mpctx
->stop_play
= PT_NEXT_SRC
;
2701 // Go back to the starting point.
2702 while (play_tree_iter_up_step
2703 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2705 mpctx
->stop_play
= PT_STOP
;
2709 case MP_CMD_RADIO_STEP_CHANNEL
:
2710 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2711 int v
= cmd
->args
[0].v
.i
;
2713 radio_step_channel(mpctx
->demuxer
->stream
,
2714 RADIO_CHANNEL_HIGHER
);
2716 radio_step_channel(mpctx
->demuxer
->stream
,
2717 RADIO_CHANNEL_LOWER
);
2718 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2719 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2721 radio_get_channel_name(mpctx
->demuxer
->stream
));
2726 case MP_CMD_RADIO_SET_CHANNEL
:
2727 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2728 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2729 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2730 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2732 radio_get_channel_name(mpctx
->demuxer
->stream
));
2737 case MP_CMD_RADIO_SET_FREQ
:
2738 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2739 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2742 case MP_CMD_RADIO_STEP_FREQ
:
2743 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2744 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2749 case MP_CMD_TV_START_SCAN
:
2750 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2751 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2753 case MP_CMD_TV_SET_FREQ
:
2754 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2755 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2756 cmd
->args
[0].v
.f
* 16.0);
2758 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2759 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2760 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2761 pvr_get_current_channelname (mpctx
->stream
),
2762 pvr_get_current_stationname (mpctx
->stream
));
2764 #endif /* CONFIG_PVR */
2767 case MP_CMD_TV_STEP_FREQ
:
2768 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2769 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2770 cmd
->args
[0].v
.f
* 16.0);
2772 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2773 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2774 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2775 pvr_get_current_channelname (mpctx
->stream
),
2776 pvr_get_current_frequency (mpctx
->stream
));
2778 #endif /* CONFIG_PVR */
2781 case MP_CMD_TV_SET_NORM
:
2782 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2783 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2787 case MP_CMD_TV_STEP_CHANNEL
:{
2788 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2789 int v
= cmd
->args
[0].v
.i
;
2791 tv_step_channel((tvi_handle_t
*) (mpctx
->
2795 tv_step_channel((tvi_handle_t
*) (mpctx
->
2799 if (tv_channel_list
) {
2800 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2801 MSGTR_OSDChannel
, tv_channel_current
->name
);
2802 //vo_osd_changed(OSDTYPE_SUBTITLE);
2806 else if (mpctx
->stream
&&
2807 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2808 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2809 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2810 pvr_get_current_channelname (mpctx
->stream
),
2811 pvr_get_current_stationname (mpctx
->stream
));
2813 #endif /* CONFIG_PVR */
2816 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2818 int v
= cmd
->args
[0].v
.i
;
2820 mpctx
->last_dvb_step
= v
;
2822 dir
= DVB_CHANNEL_HIGHER
;
2824 dir
= DVB_CHANNEL_LOWER
;
2827 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2828 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2829 mpctx
->dvbin_reopen
= 1;
2832 #endif /* CONFIG_DVBIN */
2835 case MP_CMD_TV_SET_CHANNEL
:
2836 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2837 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2839 if (tv_channel_list
) {
2840 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2841 MSGTR_OSDChannel
, tv_channel_current
->name
);
2842 //vo_osd_changed(OSDTYPE_SUBTITLE);
2846 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2847 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2848 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2849 pvr_get_current_channelname (mpctx
->stream
),
2850 pvr_get_current_stationname (mpctx
->stream
));
2852 #endif /* CONFIG_PVR */
2856 case MP_CMD_DVB_SET_CHANNEL
:
2857 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2858 mpctx
->last_dvb_step
= 1;
2860 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2861 cmd
->args
[0].v
.i
)) {
2862 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2863 mpctx
->dvbin_reopen
= 1;
2867 #endif /* CONFIG_DVBIN */
2869 case MP_CMD_TV_LAST_CHANNEL
:
2870 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2871 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2872 if (tv_channel_list
) {
2873 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2874 MSGTR_OSDChannel
, tv_channel_current
->name
);
2875 //vo_osd_changed(OSDTYPE_SUBTITLE);
2879 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2880 pvr_set_lastchannel (mpctx
->stream
);
2881 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2882 pvr_get_current_channelname (mpctx
->stream
),
2883 pvr_get_current_stationname (mpctx
->stream
));
2885 #endif /* CONFIG_PVR */
2888 case MP_CMD_TV_STEP_NORM
:
2889 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2890 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2893 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2894 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2895 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2897 #ifdef CONFIG_TV_TELETEXT
2898 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2900 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2901 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2902 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2905 case MP_CMD_TV_TELETEXT_GO_LINK
:
2907 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2908 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2909 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2912 #endif /* CONFIG_TV_TELETEXT */
2913 #endif /* CONFIG_TV */
2915 case MP_CMD_SUB_LOAD
:
2917 int n
= mpctx
->set_of_sub_size
;
2918 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2919 if (n
!= mpctx
->set_of_sub_size
) {
2920 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2921 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2922 mpctx
->global_sub_size
;
2923 ++mpctx
->global_sub_size
;
2928 case MP_CMD_SUB_REMOVE
:
2930 int v
= cmd
->args
[0].v
.i
;
2933 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2934 subd
= mpctx
->set_of_subtitles
[v
];
2935 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2936 MSGTR_RemovedSubtitleFile
, v
+ 1,
2937 filename_recode(subd
->filename
));
2939 mpctx
->set_of_subtitles
[v
] = NULL
;
2941 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2942 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2943 mpctx
->set_of_sub_size
= 0;
2944 if (mpctx
->set_of_sub_pos
>= 0) {
2945 mpctx
->global_sub_pos
= -2;
2947 mp_input_queue_cmd(mpctx
->input
,
2948 mp_input_parse_cmd("sub_select"));
2950 } else if (v
< mpctx
->set_of_sub_size
) {
2951 subd
= mpctx
->set_of_subtitles
[v
];
2952 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2953 MSGTR_RemovedSubtitleFile
, v
+ 1,
2954 filename_recode(subd
->filename
));
2956 if (mpctx
->set_of_sub_pos
== v
) {
2957 mpctx
->global_sub_pos
= -2;
2959 mp_input_queue_cmd(mpctx
->input
,
2960 mp_input_parse_cmd("sub_select"));
2961 } else if (mpctx
->set_of_sub_pos
> v
) {
2962 --mpctx
->set_of_sub_pos
;
2963 --mpctx
->global_sub_pos
;
2965 while (++v
< mpctx
->set_of_sub_size
)
2966 mpctx
->set_of_subtitles
[v
- 1] =
2967 mpctx
->set_of_subtitles
[v
];
2968 --mpctx
->set_of_sub_size
;
2969 --mpctx
->global_sub_size
;
2970 if (mpctx
->set_of_sub_size
<= 0)
2971 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2972 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2977 case MP_CMD_GET_SUB_VISIBILITY
:
2979 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2980 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2984 case MP_CMD_SCREENSHOT
:
2985 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2986 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2988 ((vf_instance_t
*) sh_video
->vfilter
)->
2989 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2991 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2995 case MP_CMD_VF_CHANGE_RECTANGLE
:
2996 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2999 case MP_CMD_GET_TIME_LENGTH
:{
3000 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
3001 demuxer_get_time_length(mpctx
->demuxer
));
3005 case MP_CMD_GET_FILENAME
:{
3006 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3007 get_metadata(mpctx
, META_NAME
));
3011 case MP_CMD_GET_VIDEO_CODEC
:{
3012 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3015 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3020 case MP_CMD_GET_VIDEO_BITRATE
:{
3021 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3024 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3029 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3030 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3033 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3034 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3039 case MP_CMD_GET_AUDIO_CODEC
:{
3040 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3043 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3048 case MP_CMD_GET_AUDIO_BITRATE
:{
3049 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3052 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3057 case MP_CMD_GET_AUDIO_SAMPLES
:{
3058 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3061 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3066 case MP_CMD_GET_META_TITLE
:{
3067 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3070 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3075 case MP_CMD_GET_META_ARTIST
:{
3076 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3079 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3084 case MP_CMD_GET_META_ALBUM
:{
3085 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3088 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3093 case MP_CMD_GET_META_YEAR
:{
3094 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3097 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3102 case MP_CMD_GET_META_COMMENT
:{
3103 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3106 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3111 case MP_CMD_GET_META_TRACK
:{
3112 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3115 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3120 case MP_CMD_GET_META_GENRE
:{
3121 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3124 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3129 case MP_CMD_GET_VO_FULLSCREEN
:
3130 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3131 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3134 case MP_CMD_GET_PERCENT_POS
:
3135 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3136 demuxer_get_percent_pos(mpctx
->demuxer
));
3139 case MP_CMD_GET_TIME_POS
:{
3142 pos
= sh_video
->pts
;
3143 else if (sh_audio
&& mpctx
->audio_out
)
3144 pos
= playing_audio_pts(mpctx
);
3145 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3152 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3158 case MP_CMD_KEYDOWN_EVENTS
:
3159 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3162 case MP_CMD_SET_MOUSE_POS
:{
3163 int pointer_x
, pointer_y
;
3165 pointer_x
= cmd
->args
[0].v
.i
;
3166 pointer_y
= cmd
->args
[1].v
.i
;
3167 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3168 #ifdef CONFIG_DVDNAV
3169 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3170 && dx
> 0.0 && dy
> 0.0) {
3172 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3173 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3174 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3175 pointer_x
, pointer_y
, &button
);
3176 if (osd_level
> 1 && button
> 0)
3177 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3178 "Selected button number %d", button
);
3182 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3183 menu_update_mouse_pos(dx
, dy
);
3188 #ifdef CONFIG_DVDNAV
3189 case MP_CMD_DVDNAV
:{
3192 mp_command_type command
= 0;
3193 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3196 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3197 if (cmd
->args
[0].v
.s
&&
3198 !strcasecmp (cmd
->args
[0].v
.s
,
3199 mp_dvdnav_bindings
[i
].name
))
3200 command
= mp_dvdnav_bindings
[i
].cmd
;
3202 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3203 if (osd_level
> 1 && button
> 0)
3204 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3205 "Selected button number %d", button
);
3209 case MP_CMD_SWITCH_TITLE
:
3210 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3211 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3218 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3219 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3222 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3223 "Received unknown cmd %s\n", cmd
->name
);
3226 switch (cmd
->pausing
) {
3227 case 1: // "pausing"
3228 pause_player(mpctx
);
3230 case 3: // "pausing_toggle"
3232 unpause_player(mpctx
);
3234 pause_player(mpctx
);