10 #include "input/input.h"
11 #include "stream/stream.h"
12 #include "libmpdemux/demuxer.h"
13 #include "libmpdemux/stheader.h"
14 #include "codec-cfg.h"
16 #include "libvo/sub.h"
18 #include "m_property.h"
21 #include "libmpcodecs/vf.h"
22 #include "libmpcodecs/vd.h"
24 #include "libvo/video_out.h"
25 #include "libvo/font_load.h"
27 #include "libao2/audio_out.h"
30 #include "libmpcodecs/dec_video.h"
35 #include "stream/tv.h"
38 #include "stream/stream_radio.h"
41 #include "stream/pvr.h"
44 #include "stream/dvbin.h"
47 #include "stream/stream_dvd.h"
50 #include "stream/stream_dvdnav.h"
53 #include "libass/ass.h"
54 #include "libass/ass_mp.h"
58 #include "libmenu/menu.h"
63 #include "libavutil/avstring.h"
65 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
69 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
70 double *dx
, double *dy
)
72 struct MPOpts
*opts
= &mpctx
->opts
;
73 struct vo
*vo
= mpctx
->video_out
;
74 //remove the borders, if any, and rescale to the range [0,1],[0,1]
75 if (vo_fs
) { //we are in full-screen mode
76 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
77 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
78 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
79 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
81 if (ix
< 0 || ix
> vo
->dwidth
) {
84 } //we are on one of the borders
85 if (iy
< 0 || iy
> vo
->dheight
) {
88 } //we are on one of the borders
91 *dx
= (double) ix
/ (double) vo
->dwidth
;
92 *dy
= (double) iy
/ (double) vo
->dheight
;
94 mp_msg(MSGT_CPLAYER
, MSGL_V
,
95 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
96 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
100 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
105 for (i
= 0; i
< SUB_SOURCES
; i
++) {
106 int j
= mpctx
->global_sub_indices
[i
];
107 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
115 static int sub_source(MPContext
*mpctx
)
117 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
121 * \brief Log the currently displayed subtitle to a file
123 * Logs the current or last displayed subtitle together with filename
124 * and time information to ~/.mplayer/subtitle_log
126 * Intended purpose is to allow convenient marking of bogus subtitles
127 * which need to be fixed while watching the movie.
130 static void log_sub(struct MPContext
*mpctx
)
136 if (subdata
== NULL
|| vo_sub_last
== NULL
)
138 fname
= get_path("subtitle_log");
139 f
= fopen(fname
, "a");
142 fprintf(f
, "----------------------------------------------------------\n");
143 if (subdata
->sub_uses_time
) {
145 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
146 mpctx
->filename
, vo_sub_last
->start
/ 360000,
147 (vo_sub_last
->start
/ 6000) % 60,
148 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
149 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
150 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
152 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
153 vo_sub_last
->start
, vo_sub_last
->end
);
155 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
156 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
162 /// \defgroup Properties
165 /// \defgroup GeneralProperties General properties
166 /// \ingroup Properties
170 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
173 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
177 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
180 struct MPOpts
*opts
= &mpctx
->opts
;
182 case M_PROPERTY_PRINT
:
183 if (!arg
) return M_PROPERTY_ERROR
;
184 if (opts
->loop_times
< 0)
185 *(char**)arg
= strdup("off");
186 else if (opts
->loop_times
== 0)
187 *(char**)arg
= strdup("inf");
190 return M_PROPERTY_OK
;
192 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
195 /// Playback speed (RW)
196 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
197 void *arg
, MPContext
*mpctx
)
199 struct MPOpts
*opts
= &mpctx
->opts
;
203 return M_PROPERTY_ERROR
;
204 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
205 opts
->playback_speed
= *(float *) arg
;
206 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
207 return M_PROPERTY_OK
;
208 case M_PROPERTY_STEP_UP
:
209 case M_PROPERTY_STEP_DOWN
:
210 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
211 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
212 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
213 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
214 return M_PROPERTY_OK
;
216 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
219 /// filename with path (RO)
220 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
223 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
226 /// filename without path (RO)
227 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
231 if (!mpctx
->filename
)
232 return M_PROPERTY_UNAVAILABLE
;
233 if (((f
= strrchr(mpctx
->filename
, '/'))
234 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
238 return m_property_string_ro(prop
, action
, arg
, f
);
241 /// Demuxer name (RO)
242 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
246 return M_PROPERTY_UNAVAILABLE
;
247 return m_property_string_ro(prop
, action
, arg
,
248 (char *) mpctx
->demuxer
->desc
->name
);
251 /// Position in the stream (RW)
252 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
255 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
256 return M_PROPERTY_UNAVAILABLE
;
258 return M_PROPERTY_ERROR
;
261 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
262 return M_PROPERTY_OK
;
264 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
265 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
266 return M_PROPERTY_OK
;
268 return M_PROPERTY_NOT_IMPLEMENTED
;
271 /// Stream start offset (RO)
272 static int mp_property_stream_start(m_option_t
*prop
, int action
,
273 void *arg
, MPContext
*mpctx
)
275 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
276 return M_PROPERTY_UNAVAILABLE
;
279 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
280 return M_PROPERTY_OK
;
282 return M_PROPERTY_NOT_IMPLEMENTED
;
285 /// Stream end offset (RO)
286 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
289 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
290 return M_PROPERTY_UNAVAILABLE
;
293 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
294 return M_PROPERTY_OK
;
296 return M_PROPERTY_NOT_IMPLEMENTED
;
299 /// Stream length (RO)
300 static int mp_property_stream_length(m_option_t
*prop
, int action
,
301 void *arg
, MPContext
*mpctx
)
303 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
304 return M_PROPERTY_UNAVAILABLE
;
308 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
309 return M_PROPERTY_OK
;
311 return M_PROPERTY_NOT_IMPLEMENTED
;
314 /// Media length in seconds (RO)
315 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
320 if (!mpctx
->demuxer
||
321 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
322 return M_PROPERTY_UNAVAILABLE
;
324 return m_property_time_ro(prop
, action
, arg
, len
);
327 /// Current position in percent (RW)
328 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
329 void *arg
, MPContext
*mpctx
) {
333 return M_PROPERTY_UNAVAILABLE
;
337 if(!arg
) return M_PROPERTY_ERROR
;
338 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
341 case M_PROPERTY_STEP_UP
:
342 case M_PROPERTY_STEP_DOWN
:
343 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
344 pos
+= (arg
? *(int*)arg
: 10) *
345 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
346 M_PROPERTY_CLAMP(prop
, pos
);
349 return m_property_int_ro(prop
, action
, arg
,
350 demuxer_get_percent_pos(mpctx
->demuxer
));
353 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
354 mpctx
->rel_seek_secs
= pos
/ 100.0;
355 return M_PROPERTY_OK
;
358 /// Current position in seconds (RW)
359 static int mp_property_time_pos(m_option_t
*prop
, int action
,
360 void *arg
, MPContext
*mpctx
) {
361 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
362 return M_PROPERTY_UNAVAILABLE
;
366 if(!arg
) return M_PROPERTY_ERROR
;
367 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
368 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
369 mpctx
->rel_seek_secs
= *(double*)arg
;
370 return M_PROPERTY_OK
;
371 case M_PROPERTY_STEP_UP
:
372 case M_PROPERTY_STEP_DOWN
:
373 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
374 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
375 return M_PROPERTY_OK
;
377 return m_property_time_ro(prop
, action
, arg
,
378 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
379 playing_audio_pts(mpctx
));
382 /// Current chapter (RW)
383 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
386 struct MPOpts
*opts
= &mpctx
->opts
;
389 char *chapter_name
= NULL
;
392 chapter
= get_current_chapter(mpctx
);
394 return M_PROPERTY_UNAVAILABLE
;
399 return M_PROPERTY_ERROR
;
400 *(int *) arg
= chapter
;
401 return M_PROPERTY_OK
;
402 case M_PROPERTY_PRINT
: {
404 return M_PROPERTY_ERROR
;
405 chapter_name
= chapter_display_name(mpctx
, chapter
);
407 return M_PROPERTY_UNAVAILABLE
;
408 *(char **) arg
= chapter_name
;
409 return M_PROPERTY_OK
;
413 return M_PROPERTY_ERROR
;
414 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
415 step_all
= *(int *)arg
- chapter
;
418 case M_PROPERTY_STEP_UP
:
419 case M_PROPERTY_STEP_DOWN
: {
420 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
421 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
428 return M_PROPERTY_NOT_IMPLEMENTED
;
432 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
433 mpctx
->rel_seek_secs
= 0;
434 mpctx
->abs_seek_pos
= 0;
436 if (next_pts
> -1.0) {
437 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
438 mpctx
->rel_seek_secs
= next_pts
;
441 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
442 _("Chapter: (%d) %s"), chapter
+ 1, chapter_name
);
444 else if (step_all
> 0)
445 mpctx
->rel_seek_secs
= 1000000000.;
447 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
448 _("Chapter: (%d) %s"), 0, _("unknown"));
450 talloc_free(chapter_name
);
451 return M_PROPERTY_OK
;
454 /// Number of chapters in file
455 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
459 return M_PROPERTY_UNAVAILABLE
;
460 if (mpctx
->demuxer
->num_chapters
== 0)
461 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
462 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
465 /// Current dvd angle (RW)
466 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
469 struct MPOpts
*opts
= &mpctx
->opts
;
472 char *angle_name
= NULL
;
475 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
477 return M_PROPERTY_UNAVAILABLE
;
478 angles
= demuxer_angles_count(mpctx
->demuxer
);
480 return M_PROPERTY_UNAVAILABLE
;
485 return M_PROPERTY_ERROR
;
486 *(int *) arg
= angle
;
487 return M_PROPERTY_OK
;
488 case M_PROPERTY_PRINT
: {
490 return M_PROPERTY_ERROR
;
491 angle_name
= calloc(1, 64);
493 return M_PROPERTY_UNAVAILABLE
;
494 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
495 *(char **) arg
= angle_name
;
496 return M_PROPERTY_OK
;
500 return M_PROPERTY_ERROR
;
502 M_PROPERTY_CLAMP(prop
, angle
);
504 case M_PROPERTY_STEP_UP
:
505 case M_PROPERTY_STEP_DOWN
: {
511 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
513 if (angle
< 1) //cycle
518 return M_PROPERTY_NOT_IMPLEMENTED
;
520 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
521 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
522 _("Angle: %d/%d"), angle
, angles
);
525 return M_PROPERTY_OK
;
528 /// Demuxer meta data
529 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
531 m_property_action_t
* ka
;
533 static const m_option_t key_type
=
534 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
536 return M_PROPERTY_UNAVAILABLE
;
540 if(!arg
) return M_PROPERTY_ERROR
;
541 *(char***)arg
= mpctx
->demuxer
->info
;
542 return M_PROPERTY_OK
;
543 case M_PROPERTY_KEY_ACTION
:
544 if(!arg
) return M_PROPERTY_ERROR
;
546 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
547 return M_PROPERTY_UNKNOWN
;
550 if(!ka
->arg
) return M_PROPERTY_ERROR
;
551 *(char**)ka
->arg
= meta
;
552 return M_PROPERTY_OK
;
553 case M_PROPERTY_GET_TYPE
:
554 if(!ka
->arg
) return M_PROPERTY_ERROR
;
555 *(m_option_t
**)ka
->arg
= &key_type
;
556 return M_PROPERTY_OK
;
559 return M_PROPERTY_NOT_IMPLEMENTED
;
562 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
565 MPContext
*mpctx
= ctx
;
570 return M_PROPERTY_ERROR
;
571 if (mpctx
->paused
== (bool)*(int *) arg
)
572 return M_PROPERTY_OK
;
573 case M_PROPERTY_STEP_UP
:
574 case M_PROPERTY_STEP_DOWN
:
576 unpause_player(mpctx
);
577 mpctx
->osd_function
= OSD_PLAY
;
581 mpctx
->osd_function
= OSD_PAUSE
;
583 return M_PROPERTY_OK
;
585 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
592 /// \defgroup AudioProperties Audio properties
593 /// \ingroup Properties
597 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
601 if (!mpctx
->sh_audio
)
602 return M_PROPERTY_UNAVAILABLE
;
607 return M_PROPERTY_ERROR
;
608 mixer_getbothvolume(&mpctx
->mixer
, arg
);
609 return M_PROPERTY_OK
;
610 case M_PROPERTY_PRINT
:{
613 return M_PROPERTY_ERROR
;
614 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
615 return m_property_float_range(prop
, action
, arg
, &vol
);
617 case M_PROPERTY_STEP_UP
:
618 case M_PROPERTY_STEP_DOWN
:
622 return M_PROPERTY_NOT_IMPLEMENTED
;
625 if (mpctx
->edl_muted
)
626 return M_PROPERTY_DISABLED
;
627 mpctx
->user_muted
= 0;
632 return M_PROPERTY_ERROR
;
633 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
634 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
635 return M_PROPERTY_OK
;
636 case M_PROPERTY_STEP_UP
:
637 if (arg
&& *(float *) arg
<= 0)
638 mixer_decvolume(&mpctx
->mixer
);
640 mixer_incvolume(&mpctx
->mixer
);
641 return M_PROPERTY_OK
;
642 case M_PROPERTY_STEP_DOWN
:
643 if (arg
&& *(float *) arg
<= 0)
644 mixer_incvolume(&mpctx
->mixer
);
646 mixer_decvolume(&mpctx
->mixer
);
647 return M_PROPERTY_OK
;
649 return M_PROPERTY_NOT_IMPLEMENTED
;
653 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
657 if (!mpctx
->sh_audio
)
658 return M_PROPERTY_UNAVAILABLE
;
662 if (mpctx
->edl_muted
)
663 return M_PROPERTY_DISABLED
;
665 return M_PROPERTY_ERROR
;
666 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
667 mixer_mute(&mpctx
->mixer
);
668 mpctx
->user_muted
= mpctx
->mixer
.muted
;
669 return M_PROPERTY_OK
;
670 case M_PROPERTY_STEP_UP
:
671 case M_PROPERTY_STEP_DOWN
:
672 if (mpctx
->edl_muted
)
673 return M_PROPERTY_DISABLED
;
674 mixer_mute(&mpctx
->mixer
);
675 mpctx
->user_muted
= mpctx
->mixer
.muted
;
676 return M_PROPERTY_OK
;
677 case M_PROPERTY_PRINT
:
679 return M_PROPERTY_ERROR
;
680 if (mpctx
->edl_muted
) {
681 *(char **) arg
= strdup(_("enabled (EDL)"));
682 return M_PROPERTY_OK
;
685 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
691 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
692 void *arg
, MPContext
*mpctx
)
694 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
695 return M_PROPERTY_UNAVAILABLE
;
698 case M_PROPERTY_STEP_UP
:
699 case M_PROPERTY_STEP_DOWN
: {
701 float delay
= audio_delay
;
702 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
703 if (ret
!= M_PROPERTY_OK
)
706 mpctx
->delay
-= audio_delay
- delay
;
708 return M_PROPERTY_OK
;
710 return m_property_delay(prop
, action
, arg
, &audio_delay
);
714 /// Audio codec tag (RO)
715 static int mp_property_audio_format(m_option_t
*prop
, int action
,
716 void *arg
, MPContext
*mpctx
)
718 if (!mpctx
->sh_audio
)
719 return M_PROPERTY_UNAVAILABLE
;
720 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
723 /// Audio codec name (RO)
724 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
725 void *arg
, MPContext
*mpctx
)
727 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
728 return M_PROPERTY_UNAVAILABLE
;
729 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
732 /// Audio bitrate (RO)
733 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
734 void *arg
, MPContext
*mpctx
)
736 if (!mpctx
->sh_audio
)
737 return M_PROPERTY_UNAVAILABLE
;
738 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
742 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
745 if (!mpctx
->sh_audio
)
746 return M_PROPERTY_UNAVAILABLE
;
748 case M_PROPERTY_PRINT
:
749 if(!arg
) return M_PROPERTY_ERROR
;
750 *(char**)arg
= malloc(16);
751 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
752 return M_PROPERTY_OK
;
754 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
757 /// Number of channels (RO)
758 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
761 if (!mpctx
->sh_audio
)
762 return M_PROPERTY_UNAVAILABLE
;
764 case M_PROPERTY_PRINT
:
766 return M_PROPERTY_ERROR
;
767 switch (mpctx
->sh_audio
->channels
) {
769 *(char **) arg
= strdup("mono");
772 *(char **) arg
= strdup("stereo");
775 *(char **) arg
= malloc(32);
776 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
778 return M_PROPERTY_OK
;
780 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
784 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
789 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
790 return M_PROPERTY_UNAVAILABLE
;
795 return M_PROPERTY_ERROR
;
796 mixer_getbalance(&mpctx
->mixer
, arg
);
797 return M_PROPERTY_OK
;
798 case M_PROPERTY_PRINT
: {
801 return M_PROPERTY_ERROR
;
802 mixer_getbalance(&mpctx
->mixer
, &bal
);
804 *str
= strdup("center");
805 else if (bal
== -1.f
)
806 *str
= strdup("left only");
808 *str
= strdup("right only");
810 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
811 *str
= malloc(sizeof("left xxx%, right xxx%"));
812 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
814 return M_PROPERTY_OK
;
816 case M_PROPERTY_STEP_UP
:
817 case M_PROPERTY_STEP_DOWN
:
818 mixer_getbalance(&mpctx
->mixer
, &bal
);
819 bal
+= (arg
? *(float*)arg
: .1f
) *
820 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
821 M_PROPERTY_CLAMP(prop
, bal
);
822 mixer_setbalance(&mpctx
->mixer
, bal
);
823 return M_PROPERTY_OK
;
826 return M_PROPERTY_ERROR
;
827 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
828 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
829 return M_PROPERTY_OK
;
831 return M_PROPERTY_NOT_IMPLEMENTED
;
834 /// Selected audio id (RW)
835 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
838 struct MPOpts
*opts
= &mpctx
->opts
;
839 int current_id
= -1, tmp
;
843 if (!mpctx
->sh_audio
)
844 return M_PROPERTY_UNAVAILABLE
;
846 return M_PROPERTY_ERROR
;
847 *(int *) arg
= opts
->audio_id
;
848 return M_PROPERTY_OK
;
849 case M_PROPERTY_PRINT
:
850 if (!mpctx
->sh_audio
)
851 return M_PROPERTY_UNAVAILABLE
;
853 return M_PROPERTY_ERROR
;
855 if (opts
->audio_id
< 0)
856 *(char **) arg
= strdup(_("disabled"));
858 char lang
[40] = _("unknown");
859 sh_audio_t
* sh
= mpctx
->sh_audio
;
861 av_strlcpy(lang
, sh
->lang
, 40);
862 #ifdef CONFIG_DVDREAD
863 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
864 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
874 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
875 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
877 *(char **) arg
= malloc(64);
878 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
880 return M_PROPERTY_OK
;
882 case M_PROPERTY_STEP_UP
:
885 return M_PROPERTY_UNAVAILABLE
;
886 if (action
== M_PROPERTY_SET
&& arg
)
887 tmp
= *((int *) arg
);
890 current_id
= mpctx
->demuxer
->audio
->id
;
891 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
892 if (opts
->audio_id
== -2
893 || (opts
->audio_id
> -1
894 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
895 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
896 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
898 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
900 sh2
->ds
= mpctx
->demuxer
->audio
;
901 mpctx
->sh_audio
= sh2
;
902 reinit_audio_chain(mpctx
);
905 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
906 return M_PROPERTY_OK
;
908 return M_PROPERTY_NOT_IMPLEMENTED
;
913 /// Selected video id (RW)
914 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
917 struct MPOpts
*opts
= &mpctx
->opts
;
918 int current_id
= -1, tmp
;
922 if (!mpctx
->sh_video
)
923 return M_PROPERTY_UNAVAILABLE
;
925 return M_PROPERTY_ERROR
;
926 *(int *) arg
= opts
->video_id
;
927 return M_PROPERTY_OK
;
928 case M_PROPERTY_PRINT
:
929 if (!mpctx
->sh_video
)
930 return M_PROPERTY_UNAVAILABLE
;
932 return M_PROPERTY_ERROR
;
934 if (opts
->video_id
< 0)
935 *(char **) arg
= strdup(_("disabled"));
937 char lang
[40] = _("unknown");
938 *(char **) arg
= malloc(64);
939 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
941 return M_PROPERTY_OK
;
943 case M_PROPERTY_STEP_UP
:
945 current_id
= mpctx
->demuxer
->video
->id
;
946 if (action
== M_PROPERTY_SET
&& arg
)
947 tmp
= *((int *) arg
);
950 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
951 if (opts
->video_id
== -2
952 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
953 && current_id
!= -2))
954 uninit_player(mpctx
, INITIALIZED_VCODEC
|
955 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
956 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
958 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
960 sh2
->ds
= mpctx
->demuxer
->video
;
961 mpctx
->sh_video
= sh2
;
962 reinit_video_chain(mpctx
);
965 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
966 return M_PROPERTY_OK
;
969 return M_PROPERTY_NOT_IMPLEMENTED
;
973 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
976 demux_program_t prog
;
979 case M_PROPERTY_STEP_UP
:
981 if (action
== M_PROPERTY_SET
&& arg
)
982 prog
.progid
= *((int *) arg
);
986 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
987 &prog
) == DEMUXER_CTRL_NOTIMPL
)
988 return M_PROPERTY_ERROR
;
990 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
991 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
992 return M_PROPERTY_OK
;
995 return M_PROPERTY_NOT_IMPLEMENTED
;
1001 /// \defgroup VideoProperties Video properties
1002 /// \ingroup Properties
1005 /// Fullscreen state (RW)
1006 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1010 if (!mpctx
->video_out
)
1011 return M_PROPERTY_UNAVAILABLE
;
1014 case M_PROPERTY_SET
:
1016 return M_PROPERTY_ERROR
;
1017 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1018 if (vo_fs
== !!*(int *) arg
)
1019 return M_PROPERTY_OK
;
1020 case M_PROPERTY_STEP_UP
:
1021 case M_PROPERTY_STEP_DOWN
:
1022 if (mpctx
->video_out
->config_ok
)
1023 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1024 mpctx
->opts
.fullscreen
= vo_fs
;
1025 return M_PROPERTY_OK
;
1027 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1031 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1032 void *arg
, MPContext
*mpctx
)
1036 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1037 return M_PROPERTY_UNAVAILABLE
;
1038 vf
= mpctx
->sh_video
->vfilter
;
1040 case M_PROPERTY_GET
:
1042 return M_PROPERTY_ERROR
;
1043 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1044 return M_PROPERTY_OK
;
1045 case M_PROPERTY_SET
:
1047 return M_PROPERTY_ERROR
;
1048 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1049 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1050 return M_PROPERTY_OK
;
1051 case M_PROPERTY_STEP_UP
:
1052 case M_PROPERTY_STEP_DOWN
:
1053 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1054 deinterlace
= !deinterlace
;
1055 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1056 return M_PROPERTY_OK
;
1058 return M_PROPERTY_NOT_IMPLEMENTED
;
1062 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1066 if (!mpctx
->video_out
1067 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1068 return M_PROPERTY_UNAVAILABLE
;
1071 case M_PROPERTY_SET
:
1073 return M_PROPERTY_ERROR
;
1074 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1075 vo_panscan
= *(float *) arg
;
1076 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1077 return M_PROPERTY_OK
;
1078 case M_PROPERTY_STEP_UP
:
1079 case M_PROPERTY_STEP_DOWN
:
1080 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1081 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1084 else if (vo_panscan
< 0)
1086 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1087 return M_PROPERTY_OK
;
1089 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1093 /// Helper to set vo flags.
1094 /** \ingroup PropertyImplHelper
1096 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1097 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1100 if (!mpctx
->video_out
)
1101 return M_PROPERTY_UNAVAILABLE
;
1104 case M_PROPERTY_SET
:
1106 return M_PROPERTY_ERROR
;
1107 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1108 if (*vo_var
== !!*(int *) arg
)
1109 return M_PROPERTY_OK
;
1110 case M_PROPERTY_STEP_UP
:
1111 case M_PROPERTY_STEP_DOWN
:
1112 if (mpctx
->video_out
->config_ok
)
1113 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1114 return M_PROPERTY_OK
;
1116 return m_property_flag(prop
, action
, arg
, vo_var
);
1120 /// Window always on top (RW)
1121 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1124 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1125 &mpctx
->opts
.vo_ontop
, mpctx
);
1128 /// Display in the root window (RW)
1129 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1132 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1133 &vo_rootwin
, mpctx
);
1136 /// Show window borders (RW)
1137 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1140 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1144 /// Framedropping state (RW)
1145 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1146 void *arg
, MPContext
*mpctx
)
1149 if (!mpctx
->sh_video
)
1150 return M_PROPERTY_UNAVAILABLE
;
1153 case M_PROPERTY_PRINT
:
1155 return M_PROPERTY_ERROR
;
1156 *(char **) arg
= strdup(frame_dropping
== 1 ? _("enabled") :
1157 (frame_dropping
== 2 ? _("hard") :
1159 return M_PROPERTY_OK
;
1161 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1165 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1166 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1169 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1172 if (!mpctx
->sh_video
)
1173 return M_PROPERTY_UNAVAILABLE
;
1175 if (gamma
[0] == 1000) {
1177 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1181 case M_PROPERTY_SET
:
1183 return M_PROPERTY_ERROR
;
1184 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1185 *gamma
= *(int *) arg
;
1186 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1190 case M_PROPERTY_GET
:
1191 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1193 return M_PROPERTY_ERROR
;
1195 return M_PROPERTY_OK
;
1198 case M_PROPERTY_STEP_UP
:
1199 case M_PROPERTY_STEP_DOWN
:
1200 *gamma
+= (arg
? *(int *) arg
: 1) *
1201 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1202 M_PROPERTY_CLAMP(prop
, *gamma
);
1203 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1208 return M_PROPERTY_NOT_IMPLEMENTED
;
1212 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1213 int l
= strlen(prop
->name
);
1214 char tv_prop
[3 + l
+ 1];
1215 sprintf(tv_prop
, "tv_%s", prop
->name
);
1216 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1220 return M_PROPERTY_UNAVAILABLE
;
1224 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1227 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1230 /// Video codec tag (RO)
1231 static int mp_property_video_format(m_option_t
*prop
, int action
,
1232 void *arg
, MPContext
*mpctx
)
1235 if (!mpctx
->sh_video
)
1236 return M_PROPERTY_UNAVAILABLE
;
1238 case M_PROPERTY_PRINT
:
1240 return M_PROPERTY_ERROR
;
1241 switch(mpctx
->sh_video
->format
) {
1243 meta
= strdup ("mpeg1"); break;
1245 meta
= strdup ("mpeg2"); break;
1247 meta
= strdup ("mpeg4"); break;
1249 meta
= strdup ("h264"); break;
1251 if(mpctx
->sh_video
->format
>= 0x20202020) {
1253 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1256 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1259 *(char**)arg
= meta
;
1260 return M_PROPERTY_OK
;
1262 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1265 /// Video codec name (RO)
1266 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1267 void *arg
, MPContext
*mpctx
)
1269 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1270 return M_PROPERTY_UNAVAILABLE
;
1271 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1275 /// Video bitrate (RO)
1276 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1277 void *arg
, MPContext
*mpctx
)
1279 if (!mpctx
->sh_video
)
1280 return M_PROPERTY_UNAVAILABLE
;
1281 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1284 /// Video display width (RO)
1285 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1288 if (!mpctx
->sh_video
)
1289 return M_PROPERTY_UNAVAILABLE
;
1290 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1293 /// Video display height (RO)
1294 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1297 if (!mpctx
->sh_video
)
1298 return M_PROPERTY_UNAVAILABLE
;
1299 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1303 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1306 if (!mpctx
->sh_video
)
1307 return M_PROPERTY_UNAVAILABLE
;
1308 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1311 /// Video aspect (RO)
1312 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1315 if (!mpctx
->sh_video
)
1316 return M_PROPERTY_UNAVAILABLE
;
1317 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1322 /// \defgroup SubProprties Subtitles properties
1323 /// \ingroup Properties
1326 /// Text subtitle position (RW)
1327 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1330 if (!mpctx
->sh_video
)
1331 return M_PROPERTY_UNAVAILABLE
;
1334 case M_PROPERTY_SET
:
1336 return M_PROPERTY_ERROR
;
1337 case M_PROPERTY_STEP_UP
:
1338 case M_PROPERTY_STEP_DOWN
:
1339 vo_osd_changed(OSDTYPE_SUBTITLE
);
1341 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1345 /// Selected subtitles (RW)
1346 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1349 struct MPOpts
*opts
= &mpctx
->opts
;
1350 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1351 const int global_sub_size
= mpctx
->global_sub_size
;
1352 int source
= -1, reset_spu
= 0;
1355 if (!mpctx
->sh_video
|| global_sub_size
<= 0)
1356 return M_PROPERTY_UNAVAILABLE
;
1359 case M_PROPERTY_GET
:
1361 return M_PROPERTY_ERROR
;
1362 *(int *) arg
= mpctx
->global_sub_pos
;
1363 return M_PROPERTY_OK
;
1364 case M_PROPERTY_PRINT
:
1366 return M_PROPERTY_ERROR
;
1367 *(char **) arg
= malloc(64);
1368 (*(char **) arg
)[63] = 0;
1371 sub_name
= subdata
->filename
;
1373 if (ass_track
&& ass_track
->name
)
1374 sub_name
= ass_track
->name
;
1379 if ((tmp2
= strrchr(tmp
, '/')))
1382 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1383 mpctx
->set_of_sub_pos
+ 1,
1384 strlen(tmp
) < 20 ? "" : "...",
1385 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1386 return M_PROPERTY_OK
;
1388 #ifdef CONFIG_DVDNAV
1389 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1390 if (vo_spudec
&& opts
->sub_id
>= 0) {
1391 unsigned char lang
[3];
1392 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1393 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1394 return M_PROPERTY_OK
;
1400 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1401 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1402 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1403 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1404 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1405 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1406 if (!lang
) lang
= _("unknown");
1407 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1408 return M_PROPERTY_OK
;
1411 if (vo_vobsub
&& vobsub_id
>= 0) {
1412 const char *language
= _("unknown");
1413 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1414 snprintf(*(char **) arg
, 63, "(%d) %s",
1415 vobsub_id
, language
? language
: _("unknown"));
1416 return M_PROPERTY_OK
;
1418 #ifdef CONFIG_DVDREAD
1419 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1420 && opts
->sub_id
>= 0) {
1422 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1423 lang
[0] = code
>> 8;
1426 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1427 return M_PROPERTY_OK
;
1430 if (opts
->sub_id
>= 0) {
1431 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, _("unknown"));
1432 return M_PROPERTY_OK
;
1434 snprintf(*(char **) arg
, 63, _("disabled"));
1435 return M_PROPERTY_OK
;
1437 case M_PROPERTY_SET
:
1439 return M_PROPERTY_ERROR
;
1440 if (*(int *) arg
< -1)
1442 else if (*(int *) arg
>= global_sub_size
)
1443 *(int *) arg
= global_sub_size
- 1;
1444 mpctx
->global_sub_pos
= *(int *) arg
;
1446 case M_PROPERTY_STEP_UP
:
1447 mpctx
->global_sub_pos
+= 2;
1448 mpctx
->global_sub_pos
=
1449 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1451 case M_PROPERTY_STEP_DOWN
:
1452 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1453 mpctx
->global_sub_pos
=
1454 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1457 return M_PROPERTY_NOT_IMPLEMENTED
;
1460 if (mpctx
->global_sub_pos
>= 0)
1461 source
= sub_source(mpctx
);
1463 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1464 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1466 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1467 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1468 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1469 mpctx
->global_sub_pos
, source
);
1471 mpctx
->set_of_sub_pos
= -1;
1485 if (source
== SUB_SOURCE_VOBSUB
) {
1486 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1487 } else if (source
== SUB_SOURCE_SUBS
) {
1488 mpctx
->set_of_sub_pos
=
1489 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1491 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1492 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1496 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1497 vo_osd_changed(OSDTYPE_SUBTITLE
);
1499 } else if (source
== SUB_SOURCE_DEMUX
) {
1501 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1502 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1504 // default: assume 1:1 mapping of sid and stream id
1505 d_sub
->id
= opts
->sub_id
;
1506 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1507 ds_free_packs(d_sub
);
1508 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1509 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1510 if (sh
&& sh
->sid
== opts
->sub_id
) {
1516 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1517 sh_sub_t
*sh
= d_sub
->sh
;
1518 if (sh
->type
== 'v')
1519 init_vo_spudec(mpctx
);
1521 else if (ass_enabled
)
1522 ass_track
= sh
->ass_track
;
1530 #ifdef CONFIG_DVDREAD
1532 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1533 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1534 && opts
->sub_id
< 0 && reset_spu
) {
1536 d_sub
->id
= opts
->sub_id
;
1539 update_subtitles(mpctx
->sh_video
, d_sub
, 0, 1);
1541 return M_PROPERTY_OK
;
1544 /// Selected sub source (RW)
1545 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1549 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1550 return M_PROPERTY_UNAVAILABLE
;
1553 case M_PROPERTY_GET
:
1555 return M_PROPERTY_ERROR
;
1556 *(int *) arg
= sub_source(mpctx
);
1557 return M_PROPERTY_OK
;
1558 case M_PROPERTY_PRINT
:
1560 return M_PROPERTY_ERROR
;
1561 *(char **) arg
= malloc(64);
1562 (*(char **) arg
)[63] = 0;
1563 switch (sub_source(mpctx
))
1565 case SUB_SOURCE_SUBS
:
1566 snprintf(*(char **) arg
, 63, _("file"));
1568 case SUB_SOURCE_VOBSUB
:
1569 snprintf(*(char **) arg
, 63, _("vobsub"));
1571 case SUB_SOURCE_DEMUX
:
1572 snprintf(*(char **) arg
, 63, _("embedded"));
1575 snprintf(*(char **) arg
, 63, _("disabled"));
1577 return M_PROPERTY_OK
;
1578 case M_PROPERTY_SET
:
1580 return M_PROPERTY_ERROR
;
1581 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1582 if (*(int *) arg
< 0)
1583 mpctx
->global_sub_pos
= -1;
1584 else if (*(int *) arg
!= sub_source(mpctx
)) {
1585 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1586 return M_PROPERTY_UNAVAILABLE
;
1587 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1590 case M_PROPERTY_STEP_UP
:
1591 case M_PROPERTY_STEP_DOWN
: {
1592 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1593 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1594 int step
= (step_all
> 0) ? 1 : -1;
1595 int cur_source
= sub_source(mpctx
);
1596 source
= cur_source
;
1599 if (source
>= SUB_SOURCES
)
1601 else if (source
< -1)
1602 source
= SUB_SOURCES
- 1;
1603 if (source
== cur_source
|| source
== -1 ||
1604 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1607 if (source
== cur_source
)
1608 return M_PROPERTY_OK
;
1610 mpctx
->global_sub_pos
= -1;
1612 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1616 return M_PROPERTY_NOT_IMPLEMENTED
;
1618 --mpctx
->global_sub_pos
;
1619 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1622 /// Selected subtitles from specific source (RW)
1623 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1626 int source
, is_cur_source
, offset
;
1627 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1628 return M_PROPERTY_UNAVAILABLE
;
1630 if (!strcmp(prop
->name
, "sub_file"))
1631 source
= SUB_SOURCE_SUBS
;
1632 else if (!strcmp(prop
->name
, "sub_vob"))
1633 source
= SUB_SOURCE_VOBSUB
;
1634 else if (!strcmp(prop
->name
, "sub_demux"))
1635 source
= SUB_SOURCE_DEMUX
;
1637 return M_PROPERTY_ERROR
;
1639 offset
= mpctx
->global_sub_indices
[source
];
1640 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1641 return M_PROPERTY_UNAVAILABLE
;
1643 is_cur_source
= sub_source(mpctx
) == source
;
1645 case M_PROPERTY_GET
:
1647 return M_PROPERTY_ERROR
;
1648 if (is_cur_source
) {
1649 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1650 if (source
== SUB_SOURCE_VOBSUB
)
1651 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1655 return M_PROPERTY_OK
;
1656 case M_PROPERTY_PRINT
:
1658 return M_PROPERTY_ERROR
;
1660 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1661 *(char **) arg
= malloc(64);
1662 (*(char **) arg
)[63] = 0;
1663 snprintf(*(char **) arg
, 63, _("disabled"));
1664 return M_PROPERTY_OK
;
1665 case M_PROPERTY_SET
:
1667 return M_PROPERTY_ERROR
;
1668 if (*(int *) arg
>= 0) {
1669 int index
= *(int *)arg
;
1670 if (source
== SUB_SOURCE_VOBSUB
)
1671 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1672 mpctx
->global_sub_pos
= offset
+ index
;
1673 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1674 || sub_source(mpctx
) != source
) {
1675 mpctx
->global_sub_pos
= -1;
1680 mpctx
->global_sub_pos
= -1;
1682 case M_PROPERTY_STEP_UP
:
1683 case M_PROPERTY_STEP_DOWN
: {
1684 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1685 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1686 int step
= (step_all
> 0) ? 1 : -1;
1687 int max_sub_pos_for_source
= -1;
1689 mpctx
->global_sub_pos
= -1;
1691 if (mpctx
->global_sub_pos
== -1) {
1693 mpctx
->global_sub_pos
= offset
;
1694 else if (max_sub_pos_for_source
== -1) {
1695 // Find max pos for specific source
1696 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1697 while (mpctx
->global_sub_pos
>= 0
1698 && sub_source(mpctx
) != source
)
1699 --mpctx
->global_sub_pos
;
1702 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1705 mpctx
->global_sub_pos
+= step
;
1706 if (mpctx
->global_sub_pos
< offset
||
1707 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1708 sub_source(mpctx
) != source
)
1709 mpctx
->global_sub_pos
= -1;
1716 return M_PROPERTY_NOT_IMPLEMENTED
;
1718 --mpctx
->global_sub_pos
;
1719 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1722 /// Subtitle delay (RW)
1723 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1726 if (!mpctx
->sh_video
)
1727 return M_PROPERTY_UNAVAILABLE
;
1728 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1731 /// Alignment of text subtitles (RW)
1732 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1733 void *arg
, MPContext
*mpctx
)
1735 char *name
[] = { _("top"), _("center"), _("bottom") };
1737 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1738 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1739 return M_PROPERTY_UNAVAILABLE
;
1742 case M_PROPERTY_PRINT
:
1744 return M_PROPERTY_ERROR
;
1745 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1746 *(char **) arg
= strdup(name
[sub_alignment
]);
1747 return M_PROPERTY_OK
;
1748 case M_PROPERTY_SET
:
1750 return M_PROPERTY_ERROR
;
1751 case M_PROPERTY_STEP_UP
:
1752 case M_PROPERTY_STEP_DOWN
:
1753 vo_osd_changed(OSDTYPE_SUBTITLE
);
1755 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1759 /// Subtitle visibility (RW)
1760 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1761 void *arg
, MPContext
*mpctx
)
1763 if (!mpctx
->sh_video
)
1764 return M_PROPERTY_UNAVAILABLE
;
1767 case M_PROPERTY_SET
:
1769 return M_PROPERTY_ERROR
;
1770 case M_PROPERTY_STEP_UP
:
1771 case M_PROPERTY_STEP_DOWN
:
1772 vo_osd_changed(OSDTYPE_SUBTITLE
);
1774 vo_osd_changed(OSDTYPE_SPU
);
1776 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1781 /// Use margins for libass subtitles (RW)
1782 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1783 void *arg
, MPContext
*mpctx
)
1785 if (!mpctx
->sh_video
)
1786 return M_PROPERTY_UNAVAILABLE
;
1789 case M_PROPERTY_SET
:
1791 return M_PROPERTY_ERROR
;
1792 case M_PROPERTY_STEP_UP
:
1793 case M_PROPERTY_STEP_DOWN
:
1794 ass_force_reload
= 1;
1796 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1801 /// Show only forced subtitles (RW)
1802 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1803 void *arg
, MPContext
*mpctx
)
1806 return M_PROPERTY_UNAVAILABLE
;
1809 case M_PROPERTY_SET
:
1811 return M_PROPERTY_ERROR
;
1812 case M_PROPERTY_STEP_UP
:
1813 case M_PROPERTY_STEP_DOWN
:
1814 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1815 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1816 return M_PROPERTY_OK
;
1818 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1823 #ifdef CONFIG_FREETYPE
1824 /// Subtitle scale (RW)
1825 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1830 case M_PROPERTY_SET
:
1832 return M_PROPERTY_ERROR
;
1833 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1836 ass_font_scale
= *(float *) arg
;
1837 ass_force_reload
= 1;
1840 text_font_scale_factor
= *(float *) arg
;
1841 force_load_font
= 1;
1842 return M_PROPERTY_OK
;
1843 case M_PROPERTY_STEP_UP
:
1844 case M_PROPERTY_STEP_DOWN
:
1847 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1848 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1849 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1850 ass_force_reload
= 1;
1853 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1854 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1855 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1856 force_load_font
= 1;
1857 return M_PROPERTY_OK
;
1861 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1864 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1871 /// \defgroup TVProperties TV properties
1872 /// \ingroup Properties
1877 /// TV color settings (RW)
1878 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1882 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1883 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1884 return M_PROPERTY_UNAVAILABLE
;
1887 case M_PROPERTY_SET
:
1889 return M_PROPERTY_ERROR
;
1890 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1891 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1892 case M_PROPERTY_GET
:
1893 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1894 case M_PROPERTY_STEP_UP
:
1895 case M_PROPERTY_STEP_DOWN
:
1896 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1898 return M_PROPERTY_ERROR
;
1899 val
+= (arg
? *(int *) arg
: 1) *
1900 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1901 M_PROPERTY_CLAMP(prop
, val
);
1902 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1904 return M_PROPERTY_ERROR
;
1906 return M_PROPERTY_NOT_IMPLEMENTED
;
1911 #ifdef CONFIG_TV_TELETEXT
1912 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1916 int base_ioctl
=(int)prop
->priv
;
1918 for teletext's GET,SET,STEP ioctls this is not 0
1922 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1923 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1924 return M_PROPERTY_UNAVAILABLE
;
1926 return M_PROPERTY_ERROR
;
1929 case M_PROPERTY_GET
:
1931 return M_PROPERTY_ERROR
;
1932 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1934 case M_PROPERTY_SET
:
1936 return M_PROPERTY_ERROR
;
1937 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1938 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1940 case M_PROPERTY_STEP_UP
:
1941 case M_PROPERTY_STEP_DOWN
:
1942 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1943 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1944 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1947 return M_PROPERTY_NOT_IMPLEMENTED
;
1950 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1953 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1956 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1960 //with tvh==NULL will fail too
1961 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1962 if(result
!=M_PROPERTY_OK
)
1965 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1966 mp_input_set_section(mpctx
->input
, "teletext");
1968 mp_input_set_section(mpctx
->input
, "tv");
1969 return M_PROPERTY_OK
;
1972 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1975 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1978 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1979 return M_PROPERTY_UNAVAILABLE
;
1981 case M_PROPERTY_STEP_UP
:
1982 case M_PROPERTY_STEP_DOWN
:
1983 //This should be handled separately
1984 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1985 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1988 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1994 #endif /* CONFIG_TV_TELETEXT */
1998 /// All properties available in MPlayer.
1999 /** \ingroup Properties
2001 static const m_option_t mp_properties
[] = {
2003 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2004 M_OPT_RANGE
, 0, 3, NULL
},
2005 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2006 M_OPT_MIN
, -1, 0, NULL
},
2007 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2008 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2009 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2011 { "path", mp_property_path
, CONF_TYPE_STRING
,
2013 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2015 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2016 M_OPT_MIN
, 0, 0, NULL
},
2017 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2018 M_OPT_MIN
, 0, 0, NULL
},
2019 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2020 M_OPT_MIN
, 0, 0, NULL
},
2021 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2022 M_OPT_MIN
, 0, 0, NULL
},
2023 { "length", mp_property_length
, CONF_TYPE_TIME
,
2024 M_OPT_MIN
, 0, 0, NULL
},
2025 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2026 M_OPT_RANGE
, 0, 100, NULL
},
2027 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2028 M_OPT_MIN
, 0, 0, NULL
},
2029 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2030 M_OPT_MIN
, 0, 0, NULL
},
2031 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2033 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2034 CONF_RANGE
, -2, 10, NULL
},
2035 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2037 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2038 M_OPT_RANGE
, 0, 1, NULL
},
2041 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2042 M_OPT_RANGE
, 0, 100, NULL
},
2043 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2044 M_OPT_RANGE
, 0, 1, NULL
},
2045 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2046 M_OPT_RANGE
, -100, 100, NULL
},
2047 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2049 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2051 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2053 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2055 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2057 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2058 CONF_RANGE
, -2, 65535, NULL
},
2059 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2060 M_OPT_RANGE
, -1, 1, NULL
},
2063 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2064 M_OPT_RANGE
, 0, 1, NULL
},
2065 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2066 M_OPT_RANGE
, 0, 1, NULL
},
2067 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2068 M_OPT_RANGE
, 0, 1, NULL
},
2069 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2070 M_OPT_RANGE
, 0, 1, NULL
},
2071 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2072 M_OPT_RANGE
, 0, 1, NULL
},
2073 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2074 M_OPT_RANGE
, 0, 2, NULL
},
2075 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2076 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2077 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2078 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2079 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2080 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2081 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2082 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2083 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2084 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2085 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2086 M_OPT_RANGE
, 0, 1, NULL
},
2087 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2088 M_OPT_RANGE
, 0, 1, NULL
},
2089 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2091 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2093 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2095 { "width", mp_property_width
, CONF_TYPE_INT
,
2097 { "height", mp_property_height
, CONF_TYPE_INT
,
2099 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2101 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2103 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2104 CONF_RANGE
, -2, 65535, NULL
},
2105 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2106 CONF_RANGE
, -1, 65535, NULL
},
2109 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2110 M_OPT_MIN
, -1, 0, NULL
},
2111 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2112 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2113 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2114 M_OPT_MIN
, -1, 0, NULL
},
2115 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2116 M_OPT_MIN
, -1, 0, NULL
},
2117 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2118 M_OPT_MIN
, -1, 0, NULL
},
2119 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2121 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2122 M_OPT_RANGE
, 0, 100, NULL
},
2123 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2124 M_OPT_RANGE
, 0, 2, NULL
},
2125 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2126 M_OPT_RANGE
, 0, 1, NULL
},
2127 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2128 M_OPT_RANGE
, 0, 1, NULL
},
2129 #ifdef CONFIG_FREETYPE
2130 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2131 M_OPT_RANGE
, 0, 100, NULL
},
2134 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2135 M_OPT_RANGE
, 0, 1, NULL
},
2139 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2140 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2141 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2142 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2143 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2144 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2145 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2146 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2149 #ifdef CONFIG_TV_TELETEXT
2150 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2151 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2152 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2153 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2154 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2155 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2156 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2157 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2158 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2159 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2162 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2166 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2168 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2171 char* mp_property_print(const char *name
, void* ctx
)
2174 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2179 char *property_expand_string(MPContext
*mpctx
, char *str
)
2181 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2184 void property_print_help(void)
2186 m_properties_print_help_list(mp_properties
);
2195 * \defgroup Command2Property Command to property bridge
2197 * It is used to handle most commands that just set a property
2198 * and optionally display something on the OSD.
2199 * Two kinds of commands are handled: adjust or toggle.
2201 * Adjust commands take 1 or 2 parameters: <value> <abs>
2202 * If <abs> is non-zero the property is set to the given value
2203 * otherwise it is adjusted.
2205 * Toggle commands take 0 or 1 parameters. With no parameter
2206 * or a value less than the property minimum it just steps the
2207 * property to its next value. Otherwise it sets it to the given
2213 /// List of the commands that can be handled by setting a property.
2219 /// set/adjust or toggle command
2221 /// progressbar type
2222 int osd_progbar
; // -1 is special value for seek indicators
2223 /// osd msg id if it must be shared
2225 /// osd msg template
2226 const char *osd_msg
;
2227 } set_prop_cmd
[] = {
2229 { "loop", MP_CMD_LOOP
, 0, 0, -1, _("Loop: %s") },
2230 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, -1, -1, NULL
},
2231 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2232 { "pause", MP_CMD_PAUSE
, 0, 0, -1, NULL
},
2234 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, _("Volume") },
2235 { "mute", MP_CMD_MUTE
, 1, 0, -1, _("Mute: %s") },
2236 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, _("A-V delay: %s") },
2237 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, _("Audio: %s") },
2238 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, _("Balance") },
2240 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2241 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, _("Panscan") },
2242 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, _("Stay on top: %s") },
2243 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, _("Rootwin: %s") },
2244 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, _("Border: %s") },
2245 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, _("Framedropping: %s") },
2246 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, _("Gamma") },
2247 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, _("Brightness") },
2248 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, _("Contrast") },
2249 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, _("Saturation") },
2250 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, _("Hue") },
2251 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, _("VSync: %s") },
2253 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, _("Subtitles: %s") },
2254 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, _("Sub source: %s") },
2255 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, _("Subtitles: %s") },
2256 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, _("Subtitles: %s") },
2257 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, _("Subtitles: %s") },
2258 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, _("Sub position: %s/100") },
2259 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, _("Sub alignment: %s") },
2260 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2261 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, _("Subtitles: %s") },
2262 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, _("Forced sub only: %s") },
2263 #ifdef CONFIG_FREETYPE
2264 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, _("Sub Scale: %s")},
2267 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2270 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, _("Brightness") },
2271 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, _("Hue") },
2272 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, _("Saturation") },
2273 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, _("Contrast") },
2275 { NULL
, 0, 0, 0, -1, NULL
}
2279 /// Handle commands that set a property.
2280 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2282 struct MPOpts
*opts
= &mpctx
->opts
;
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
== -1)
2313 mpctx
->add_osd_seek_info
= true;
2314 else if (set_prop_cmd
[i
].osd_progbar
) {
2315 if (prop
->type
== CONF_TYPE_INT
) {
2316 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2317 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2318 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2319 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2321 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2322 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2323 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2325 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2326 "Property use an unsupported type.\n");
2330 if (set_prop_cmd
[i
].osd_msg
) {
2331 char *val
= mp_property_print(pname
, mpctx
);
2333 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2334 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2335 1, opts
->osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2342 #ifdef CONFIG_DVDNAV
2343 static const struct {
2345 const mp_command_type cmd
;
2346 } mp_dvdnav_bindings
[] = {
2347 { "up", MP_CMD_DVDNAV_UP
},
2348 { "down", MP_CMD_DVDNAV_DOWN
},
2349 { "left", MP_CMD_DVDNAV_LEFT
},
2350 { "right", MP_CMD_DVDNAV_RIGHT
},
2351 { "menu", MP_CMD_DVDNAV_MENU
},
2352 { "select", MP_CMD_DVDNAV_SELECT
},
2353 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2354 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2357 * keep old dvdnav sub-command options for a while in order not to
2358 * break slave-mode API too suddenly.
2360 { "1", MP_CMD_DVDNAV_UP
},
2361 { "2", MP_CMD_DVDNAV_DOWN
},
2362 { "3", MP_CMD_DVDNAV_LEFT
},
2363 { "4", MP_CMD_DVDNAV_RIGHT
},
2364 { "5", MP_CMD_DVDNAV_MENU
},
2365 { "6", MP_CMD_DVDNAV_SELECT
},
2366 { "7", MP_CMD_DVDNAV_PREVMENU
},
2367 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2372 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2374 struct MPOpts
*opts
= &mpctx
->opts
;
2375 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2376 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2377 int osd_duration
= opts
->osd_duration
;
2378 if (!set_property_command(mpctx
, cmd
))
2383 mpctx
->add_osd_seek_info
= true;
2384 v
= cmd
->args
[0].v
.f
;
2385 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2386 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2387 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2389 mpctx
->osd_function
=
2390 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2391 mpctx
->rel_seek_secs
= v
;
2392 } else if (abs
) { /* Absolute seek by percentage */
2393 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2395 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2396 mpctx
->rel_seek_secs
= v
/ 100.0;
2398 mpctx
->rel_seek_secs
+= v
;
2399 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2404 case MP_CMD_SET_PROPERTY
:{
2405 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2406 cmd
->args
[1].v
.s
, mpctx
);
2407 if (r
== M_PROPERTY_UNKNOWN
)
2408 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2409 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2411 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2412 "Failed to set property '%s' to '%s'.\n",
2413 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2417 case MP_CMD_STEP_PROPERTY
:{
2422 if (cmd
->args
[1].v
.f
) {
2424 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2425 M_PROPERTY_GET_TYPE
,
2426 &prop
, mpctx
)) <= 0)
2428 if(prop
->type
== CONF_TYPE_INT
||
2429 prop
->type
== CONF_TYPE_FLAG
)
2430 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2431 else if(prop
->type
== CONF_TYPE_FLOAT
)
2432 arg
= &cmd
->args
[1].v
.f
;
2433 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2434 prop
->type
== CONF_TYPE_TIME
)
2435 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2436 else if(prop
->type
== CONF_TYPE_POSITION
)
2437 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2439 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2440 "Ignoring step size stepping property '%s'.\n",
2443 r
= mp_property_do(cmd
->args
[0].v
.s
,
2444 cmd
->args
[2].v
.i
< 0 ?
2445 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2448 if (r
== M_PROPERTY_UNKNOWN
)
2449 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2450 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2452 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2453 "Failed to increment property '%s' by %f.\n",
2454 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2458 case MP_CMD_GET_PROPERTY
:{
2460 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2461 &tmp
, mpctx
) <= 0) {
2462 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2463 "Failed to get value of property '%s'.\n",
2467 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2468 cmd
->args
[0].v
.s
, tmp
);
2473 case MP_CMD_EDL_MARK
:
2475 float v
= sh_video
? sh_video
->pts
:
2476 playing_audio_pts(mpctx
);
2477 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2478 mpctx
->begin_skip
= v
;
2479 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2481 if (mpctx
->begin_skip
> v
)
2482 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2484 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2485 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2487 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2492 case MP_CMD_SWITCH_RATIO
:
2495 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2496 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2498 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2499 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2502 case MP_CMD_SPEED_INCR
:{
2503 float v
= cmd
->args
[0].v
.f
;
2504 opts
->playback_speed
+= v
;
2505 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2506 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2507 opts
->playback_speed
);
2510 case MP_CMD_SPEED_MULT
:{
2511 float v
= cmd
->args
[0].v
.f
;
2512 opts
->playback_speed
*= v
;
2513 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2514 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2515 opts
->playback_speed
);
2518 case MP_CMD_SPEED_SET
:{
2519 float v
= cmd
->args
[0].v
.f
;
2520 opts
->playback_speed
= v
;
2521 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2522 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2523 opts
->playback_speed
);
2526 case MP_CMD_FRAME_STEP
:
2527 add_step_frame(mpctx
);
2530 case MP_CMD_FILE_FILTER
:
2531 file_filter
= cmd
->args
[0].v
.i
;
2535 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2536 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2538 case MP_CMD_PLAY_TREE_STEP
:{
2539 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2540 int force
= cmd
->args
[1].v
.i
;
2543 if (!force
&& mpctx
->playtree_iter
) {
2544 play_tree_iter_t
*i
=
2545 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2546 if (play_tree_iter_step(i
, n
, 0) ==
2547 PLAY_TREE_ITER_ENTRY
)
2549 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2550 play_tree_iter_free(i
);
2552 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2553 if (mpctx
->stop_play
)
2554 mpctx
->play_tree_step
= n
;
2559 case MP_CMD_PLAY_TREE_UP_STEP
:{
2560 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2561 int force
= cmd
->args
[1].v
.i
;
2563 if (!force
&& mpctx
->playtree_iter
) {
2564 play_tree_iter_t
*i
=
2565 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2566 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2567 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2568 play_tree_iter_free(i
);
2570 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2574 case MP_CMD_PLAY_ALT_SRC_STEP
:
2575 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2576 int v
= cmd
->args
[0].v
.i
;
2578 && mpctx
->playtree_iter
->file
<
2579 mpctx
->playtree_iter
->num_files
)
2580 mpctx
->stop_play
= PT_NEXT_SRC
;
2581 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2582 mpctx
->stop_play
= PT_PREV_SRC
;
2586 case MP_CMD_SUB_STEP
:
2588 int movement
= cmd
->args
[0].v
.i
;
2589 step_sub(subdata
, sh_video
->pts
, movement
);
2593 ass_step_sub(ass_track
,
2595 sub_delay
) * 1000 + .5, movement
) / 1000.;
2597 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2598 _("Sub delay: %d ms"), ROUND(sub_delay
* 1000));
2602 case MP_CMD_SUB_LOG
:
2607 int v
= cmd
->args
[0].v
.i
;
2609 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2610 if (opts
->osd_level
> max
)
2611 opts
->osd_level
= max
;
2613 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2615 opts
->osd_level
= v
> max
? max
: v
;
2616 /* Show OSD state when disabled, but not when an explicit
2617 argument is given to the OSD command, i.e. in slave mode. */
2618 if (v
== -1 && opts
->osd_level
<= 1)
2619 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2621 opts
->osd_level
? _("enabled") :
2624 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2628 case MP_CMD_OSD_SHOW_TEXT
:
2629 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2631 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2632 "%-.63s", cmd
->args
[0].v
.s
);
2635 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2636 char *txt
= m_properties_expand_string(mp_properties
,
2639 /* if no argument supplied take default osd_duration, else <arg> ms. */
2641 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2643 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2650 case MP_CMD_LOADFILE
:{
2651 play_tree_t
*e
= play_tree_new();
2652 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2654 if (cmd
->args
[1].v
.i
) // append
2655 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2657 // Go back to the starting point.
2658 while (play_tree_iter_up_step
2659 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2661 play_tree_free_list(mpctx
->playtree
->child
, 1);
2662 play_tree_set_child(mpctx
->playtree
, e
);
2663 pt_iter_goto_head(mpctx
->playtree_iter
);
2664 mpctx
->stop_play
= PT_NEXT_SRC
;
2669 case MP_CMD_LOADLIST
:{
2670 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2672 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2673 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2675 if (cmd
->args
[1].v
.i
) // append
2676 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2678 // Go back to the starting point.
2679 while (play_tree_iter_up_step
2680 (mpctx
->playtree_iter
, 0, 1)
2681 != PLAY_TREE_ITER_END
)
2683 play_tree_free_list(mpctx
->playtree
->child
, 1);
2684 play_tree_set_child(mpctx
->playtree
, e
);
2685 pt_iter_goto_head(mpctx
->playtree_iter
);
2686 mpctx
->stop_play
= PT_NEXT_SRC
;
2693 // Go back to the starting point.
2694 while (play_tree_iter_up_step
2695 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2697 mpctx
->stop_play
= PT_STOP
;
2701 case MP_CMD_RADIO_STEP_CHANNEL
:
2702 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2703 int v
= cmd
->args
[0].v
.i
;
2705 radio_step_channel(mpctx
->demuxer
->stream
,
2706 RADIO_CHANNEL_HIGHER
);
2708 radio_step_channel(mpctx
->demuxer
->stream
,
2709 RADIO_CHANNEL_LOWER
);
2710 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2711 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2713 radio_get_channel_name(mpctx
->demuxer
->stream
));
2718 case MP_CMD_RADIO_SET_CHANNEL
:
2719 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2720 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2721 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2722 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2724 radio_get_channel_name(mpctx
->demuxer
->stream
));
2729 case MP_CMD_RADIO_SET_FREQ
:
2730 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2731 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2734 case MP_CMD_RADIO_STEP_FREQ
:
2735 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2736 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2741 case MP_CMD_TV_START_SCAN
:
2742 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2743 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2745 case MP_CMD_TV_SET_FREQ
:
2746 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2747 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2748 cmd
->args
[0].v
.f
* 16.0);
2750 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2751 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2752 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2753 pvr_get_current_channelname (mpctx
->stream
),
2754 pvr_get_current_stationname (mpctx
->stream
));
2756 #endif /* CONFIG_PVR */
2759 case MP_CMD_TV_STEP_FREQ
:
2760 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2761 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2762 cmd
->args
[0].v
.f
* 16.0);
2764 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2765 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2766 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2767 pvr_get_current_channelname (mpctx
->stream
),
2768 pvr_get_current_frequency (mpctx
->stream
));
2770 #endif /* CONFIG_PVR */
2773 case MP_CMD_TV_SET_NORM
:
2774 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2775 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2779 case MP_CMD_TV_STEP_CHANNEL
:{
2780 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2781 int v
= cmd
->args
[0].v
.i
;
2783 tv_step_channel((tvi_handle_t
*) (mpctx
->
2787 tv_step_channel((tvi_handle_t
*) (mpctx
->
2791 if (tv_channel_list
) {
2792 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2793 _("Channel: %s"), tv_channel_current
->name
);
2794 //vo_osd_changed(OSDTYPE_SUBTITLE);
2798 else if (mpctx
->stream
&&
2799 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2800 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2801 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2802 pvr_get_current_channelname (mpctx
->stream
),
2803 pvr_get_current_stationname (mpctx
->stream
));
2805 #endif /* CONFIG_PVR */
2808 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2810 int v
= cmd
->args
[0].v
.i
;
2812 mpctx
->last_dvb_step
= v
;
2814 dir
= DVB_CHANNEL_HIGHER
;
2816 dir
= DVB_CHANNEL_LOWER
;
2819 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2820 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2821 mpctx
->dvbin_reopen
= 1;
2824 #endif /* CONFIG_DVBIN */
2827 case MP_CMD_TV_SET_CHANNEL
:
2828 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2829 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2831 if (tv_channel_list
) {
2832 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2833 _("Channel: %s"), tv_channel_current
->name
);
2834 //vo_osd_changed(OSDTYPE_SUBTITLE);
2838 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2839 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2840 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2841 pvr_get_current_channelname (mpctx
->stream
),
2842 pvr_get_current_stationname (mpctx
->stream
));
2844 #endif /* CONFIG_PVR */
2848 case MP_CMD_DVB_SET_CHANNEL
:
2849 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2850 mpctx
->last_dvb_step
= 1;
2852 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2853 cmd
->args
[0].v
.i
)) {
2854 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2855 mpctx
->dvbin_reopen
= 1;
2859 #endif /* CONFIG_DVBIN */
2861 case MP_CMD_TV_LAST_CHANNEL
:
2862 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2863 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2864 if (tv_channel_list
) {
2865 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2866 _("Channel: %s"), tv_channel_current
->name
);
2867 //vo_osd_changed(OSDTYPE_SUBTITLE);
2871 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2872 pvr_set_lastchannel (mpctx
->stream
);
2873 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2874 pvr_get_current_channelname (mpctx
->stream
),
2875 pvr_get_current_stationname (mpctx
->stream
));
2877 #endif /* CONFIG_PVR */
2880 case MP_CMD_TV_STEP_NORM
:
2881 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2882 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2885 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2886 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2887 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2889 #ifdef CONFIG_TV_TELETEXT
2890 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2892 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2893 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2894 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2897 case MP_CMD_TV_TELETEXT_GO_LINK
:
2899 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2900 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2901 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2904 #endif /* CONFIG_TV_TELETEXT */
2905 #endif /* CONFIG_TV */
2907 case MP_CMD_SUB_LOAD
:
2909 int n
= mpctx
->set_of_sub_size
;
2910 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2911 if (n
!= mpctx
->set_of_sub_size
) {
2912 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2913 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2914 mpctx
->global_sub_size
;
2915 ++mpctx
->global_sub_size
;
2920 case MP_CMD_SUB_REMOVE
:
2922 int v
= cmd
->args
[0].v
.i
;
2925 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2926 subd
= mpctx
->set_of_subtitles
[v
];
2927 mp_tmsg(MSGT_CPLAYER
, MSGL_STATUS
,
2928 "SUB: Removed subtitle file (%d): %s\n", v
+ 1,
2929 filename_recode(subd
->filename
));
2931 mpctx
->set_of_subtitles
[v
] = NULL
;
2933 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2934 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2935 mpctx
->set_of_sub_size
= 0;
2936 if (mpctx
->set_of_sub_pos
>= 0) {
2937 mpctx
->global_sub_pos
= -2;
2939 mp_input_queue_cmd(mpctx
->input
,
2940 mp_input_parse_cmd("sub_select"));
2942 } else if (v
< mpctx
->set_of_sub_size
) {
2943 subd
= mpctx
->set_of_subtitles
[v
];
2944 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2945 "SUB: Removed subtitle file (%d): %s\n", v
+ 1,
2946 filename_recode(subd
->filename
));
2948 if (mpctx
->set_of_sub_pos
== v
) {
2949 mpctx
->global_sub_pos
= -2;
2951 mp_input_queue_cmd(mpctx
->input
,
2952 mp_input_parse_cmd("sub_select"));
2953 } else if (mpctx
->set_of_sub_pos
> v
) {
2954 --mpctx
->set_of_sub_pos
;
2955 --mpctx
->global_sub_pos
;
2957 while (++v
< mpctx
->set_of_sub_size
)
2958 mpctx
->set_of_subtitles
[v
- 1] =
2959 mpctx
->set_of_subtitles
[v
];
2960 --mpctx
->set_of_sub_size
;
2961 --mpctx
->global_sub_size
;
2962 if (mpctx
->set_of_sub_size
<= 0)
2963 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2964 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2969 case MP_CMD_GET_SUB_VISIBILITY
:
2971 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2972 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2976 case MP_CMD_SCREENSHOT
:
2977 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2978 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2980 ((vf_instance_t
*) sh_video
->vfilter
)->
2981 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2983 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2987 case MP_CMD_AF_EQ_SET
:{
2988 af_instance_t
* m1
=af_get(sh_audio
->afilter
, "equalizer");
2989 if (m1
) m1
->control( m1
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[0].v
.s
);
2990 else mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -af equalizer=0:0 ?)\n");
2994 case MP_CMD_VF_CHANGE_RECTANGLE
:
2997 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3000 case MP_CMD_GET_TIME_LENGTH
:{
3001 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
3002 demuxer_get_time_length(mpctx
->demuxer
));
3006 case MP_CMD_GET_FILENAME
:{
3007 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3008 get_metadata(mpctx
, META_NAME
));
3012 case MP_CMD_GET_VIDEO_CODEC
:{
3013 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3016 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3021 case MP_CMD_GET_VIDEO_BITRATE
:{
3022 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3025 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3030 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3031 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3034 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3035 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3040 case MP_CMD_GET_AUDIO_CODEC
:{
3041 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3044 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3049 case MP_CMD_GET_AUDIO_BITRATE
:{
3050 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3053 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3058 case MP_CMD_GET_AUDIO_SAMPLES
:{
3059 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3062 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3067 case MP_CMD_GET_META_TITLE
:{
3068 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3071 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3076 case MP_CMD_GET_META_ARTIST
:{
3077 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3080 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3085 case MP_CMD_GET_META_ALBUM
:{
3086 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3089 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3094 case MP_CMD_GET_META_YEAR
:{
3095 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3098 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3103 case MP_CMD_GET_META_COMMENT
:{
3104 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3107 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3112 case MP_CMD_GET_META_TRACK
:{
3113 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3116 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3121 case MP_CMD_GET_META_GENRE
:{
3122 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3125 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3130 case MP_CMD_GET_VO_FULLSCREEN
:
3131 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3132 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3135 case MP_CMD_GET_PERCENT_POS
:
3136 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3137 demuxer_get_percent_pos(mpctx
->demuxer
));
3140 case MP_CMD_GET_TIME_POS
:{
3143 pos
= sh_video
->pts
;
3144 else if (sh_audio
&& mpctx
->audio_out
)
3145 pos
= playing_audio_pts(mpctx
);
3146 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3153 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3159 case MP_CMD_KEYDOWN_EVENTS
:
3160 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3163 case MP_CMD_SET_MOUSE_POS
:{
3164 int pointer_x
, pointer_y
;
3166 pointer_x
= cmd
->args
[0].v
.i
;
3167 pointer_y
= cmd
->args
[1].v
.i
;
3168 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3169 #ifdef CONFIG_DVDNAV
3170 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3171 && dx
> 0.0 && dy
> 0.0) {
3173 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3174 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3175 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3176 pointer_x
, pointer_y
, &button
);
3177 if (opts
->osd_level
> 1 && button
> 0)
3178 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3179 "Selected button number %d", button
);
3183 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3184 menu_update_mouse_pos(dx
, dy
);
3189 #ifdef CONFIG_DVDNAV
3190 case MP_CMD_DVDNAV
:{
3193 mp_command_type command
= 0;
3194 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3197 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3198 if (cmd
->args
[0].v
.s
&&
3199 !strcasecmp (cmd
->args
[0].v
.s
,
3200 mp_dvdnav_bindings
[i
].name
))
3201 command
= mp_dvdnav_bindings
[i
].cmd
;
3203 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3204 if (opts
->osd_level
> 1 && button
> 0)
3205 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3206 "Selected button number %d", button
);
3210 case MP_CMD_SWITCH_TITLE
:
3211 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3212 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3218 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3219 "Received unknown cmd %s\n", cmd
->name
);
3222 switch (cmd
->pausing
) {
3223 case 1: // "pausing"
3224 pause_player(mpctx
);
3226 case 3: // "pausing_toggle"
3228 unpause_player(mpctx
);
3230 pause_player(mpctx
);