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
);
578 mpctx
->osd_function
= OSD_PLAY
;
582 mpctx
->osd_function
= OSD_PAUSE
;
584 return M_PROPERTY_OK
;
586 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
593 /// \defgroup AudioProperties Audio properties
594 /// \ingroup Properties
598 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
602 if (!mpctx
->sh_audio
)
603 return M_PROPERTY_UNAVAILABLE
;
608 return M_PROPERTY_ERROR
;
609 mixer_getbothvolume(&mpctx
->mixer
, arg
);
610 return M_PROPERTY_OK
;
611 case M_PROPERTY_PRINT
:{
614 return M_PROPERTY_ERROR
;
615 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
616 return m_property_float_range(prop
, action
, arg
, &vol
);
618 case M_PROPERTY_STEP_UP
:
619 case M_PROPERTY_STEP_DOWN
:
623 return M_PROPERTY_NOT_IMPLEMENTED
;
626 if (mpctx
->edl_muted
)
627 return M_PROPERTY_DISABLED
;
628 mpctx
->user_muted
= 0;
633 return M_PROPERTY_ERROR
;
634 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
635 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
636 return M_PROPERTY_OK
;
637 case M_PROPERTY_STEP_UP
:
638 if (arg
&& *(float *) arg
<= 0)
639 mixer_decvolume(&mpctx
->mixer
);
641 mixer_incvolume(&mpctx
->mixer
);
642 return M_PROPERTY_OK
;
643 case M_PROPERTY_STEP_DOWN
:
644 if (arg
&& *(float *) arg
<= 0)
645 mixer_incvolume(&mpctx
->mixer
);
647 mixer_decvolume(&mpctx
->mixer
);
648 return M_PROPERTY_OK
;
650 return M_PROPERTY_NOT_IMPLEMENTED
;
654 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
658 if (!mpctx
->sh_audio
)
659 return M_PROPERTY_UNAVAILABLE
;
663 if (mpctx
->edl_muted
)
664 return M_PROPERTY_DISABLED
;
666 return M_PROPERTY_ERROR
;
667 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
668 mixer_mute(&mpctx
->mixer
);
669 mpctx
->user_muted
= mpctx
->mixer
.muted
;
670 return M_PROPERTY_OK
;
671 case M_PROPERTY_STEP_UP
:
672 case M_PROPERTY_STEP_DOWN
:
673 if (mpctx
->edl_muted
)
674 return M_PROPERTY_DISABLED
;
675 mixer_mute(&mpctx
->mixer
);
676 mpctx
->user_muted
= mpctx
->mixer
.muted
;
677 return M_PROPERTY_OK
;
678 case M_PROPERTY_PRINT
:
680 return M_PROPERTY_ERROR
;
681 if (mpctx
->edl_muted
) {
682 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
683 return M_PROPERTY_OK
;
686 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
692 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
693 void *arg
, MPContext
*mpctx
)
695 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
696 return M_PROPERTY_UNAVAILABLE
;
699 case M_PROPERTY_STEP_UP
:
700 case M_PROPERTY_STEP_DOWN
: {
702 float delay
= audio_delay
;
703 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
704 if (ret
!= M_PROPERTY_OK
)
707 mpctx
->delay
-= audio_delay
- delay
;
709 return M_PROPERTY_OK
;
711 return m_property_delay(prop
, action
, arg
, &audio_delay
);
715 /// Audio codec tag (RO)
716 static int mp_property_audio_format(m_option_t
*prop
, int action
,
717 void *arg
, MPContext
*mpctx
)
719 if (!mpctx
->sh_audio
)
720 return M_PROPERTY_UNAVAILABLE
;
721 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
724 /// Audio codec name (RO)
725 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
726 void *arg
, MPContext
*mpctx
)
728 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
729 return M_PROPERTY_UNAVAILABLE
;
730 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
733 /// Audio bitrate (RO)
734 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
735 void *arg
, MPContext
*mpctx
)
737 if (!mpctx
->sh_audio
)
738 return M_PROPERTY_UNAVAILABLE
;
739 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
743 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
746 if (!mpctx
->sh_audio
)
747 return M_PROPERTY_UNAVAILABLE
;
749 case M_PROPERTY_PRINT
:
750 if(!arg
) return M_PROPERTY_ERROR
;
751 *(char**)arg
= malloc(16);
752 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
753 return M_PROPERTY_OK
;
755 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
758 /// Number of channels (RO)
759 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
762 if (!mpctx
->sh_audio
)
763 return M_PROPERTY_UNAVAILABLE
;
765 case M_PROPERTY_PRINT
:
767 return M_PROPERTY_ERROR
;
768 switch (mpctx
->sh_audio
->channels
) {
770 *(char **) arg
= strdup("mono");
773 *(char **) arg
= strdup("stereo");
776 *(char **) arg
= malloc(32);
777 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
779 return M_PROPERTY_OK
;
781 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
785 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
790 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
791 return M_PROPERTY_UNAVAILABLE
;
796 return M_PROPERTY_ERROR
;
797 mixer_getbalance(&mpctx
->mixer
, arg
);
798 return M_PROPERTY_OK
;
799 case M_PROPERTY_PRINT
: {
802 return M_PROPERTY_ERROR
;
803 mixer_getbalance(&mpctx
->mixer
, &bal
);
805 *str
= strdup("center");
806 else if (bal
== -1.f
)
807 *str
= strdup("left only");
809 *str
= strdup("right only");
811 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
812 *str
= malloc(sizeof("left xxx%, right xxx%"));
813 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
815 return M_PROPERTY_OK
;
817 case M_PROPERTY_STEP_UP
:
818 case M_PROPERTY_STEP_DOWN
:
819 mixer_getbalance(&mpctx
->mixer
, &bal
);
820 bal
+= (arg
? *(float*)arg
: .1f
) *
821 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
822 M_PROPERTY_CLAMP(prop
, bal
);
823 mixer_setbalance(&mpctx
->mixer
, bal
);
824 return M_PROPERTY_OK
;
827 return M_PROPERTY_ERROR
;
828 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
829 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
830 return M_PROPERTY_OK
;
832 return M_PROPERTY_NOT_IMPLEMENTED
;
835 /// Selected audio id (RW)
836 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
839 struct MPOpts
*opts
= &mpctx
->opts
;
840 int current_id
= -1, tmp
;
844 if (!mpctx
->sh_audio
)
845 return M_PROPERTY_UNAVAILABLE
;
847 return M_PROPERTY_ERROR
;
848 *(int *) arg
= opts
->audio_id
;
849 return M_PROPERTY_OK
;
850 case M_PROPERTY_PRINT
:
851 if (!mpctx
->sh_audio
)
852 return M_PROPERTY_UNAVAILABLE
;
854 return M_PROPERTY_ERROR
;
856 if (opts
->audio_id
< 0)
857 *(char **) arg
= strdup(MSGTR_Disabled
);
859 char lang
[40] = MSGTR_Unknown
;
860 sh_audio_t
* sh
= mpctx
->sh_audio
;
862 av_strlcpy(lang
, sh
->lang
, 40);
863 #ifdef CONFIG_DVDREAD
864 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
865 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
875 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
876 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
878 *(char **) arg
= malloc(64);
879 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
881 return M_PROPERTY_OK
;
883 case M_PROPERTY_STEP_UP
:
886 return M_PROPERTY_UNAVAILABLE
;
887 if (action
== M_PROPERTY_SET
&& arg
)
888 tmp
= *((int *) arg
);
891 current_id
= mpctx
->demuxer
->audio
->id
;
892 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
893 if (opts
->audio_id
== -2
894 || (opts
->audio_id
> -1
895 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
896 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
897 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
899 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
901 sh2
->ds
= mpctx
->demuxer
->audio
;
902 mpctx
->sh_audio
= sh2
;
903 reinit_audio_chain(mpctx
);
906 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
907 return M_PROPERTY_OK
;
909 return M_PROPERTY_NOT_IMPLEMENTED
;
914 /// Selected video id (RW)
915 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
918 struct MPOpts
*opts
= &mpctx
->opts
;
919 int current_id
= -1, tmp
;
923 if (!mpctx
->sh_video
)
924 return M_PROPERTY_UNAVAILABLE
;
926 return M_PROPERTY_ERROR
;
927 *(int *) arg
= opts
->video_id
;
928 return M_PROPERTY_OK
;
929 case M_PROPERTY_PRINT
:
930 if (!mpctx
->sh_video
)
931 return M_PROPERTY_UNAVAILABLE
;
933 return M_PROPERTY_ERROR
;
935 if (opts
->video_id
< 0)
936 *(char **) arg
= strdup(MSGTR_Disabled
);
938 char lang
[40] = MSGTR_Unknown
;
939 *(char **) arg
= malloc(64);
940 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
942 return M_PROPERTY_OK
;
944 case M_PROPERTY_STEP_UP
:
946 current_id
= mpctx
->demuxer
->video
->id
;
947 if (action
== M_PROPERTY_SET
&& arg
)
948 tmp
= *((int *) arg
);
951 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
952 if (opts
->video_id
== -2
953 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
954 && current_id
!= -2))
955 uninit_player(mpctx
, INITIALIZED_VCODEC
|
956 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
957 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
959 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
961 sh2
->ds
= mpctx
->demuxer
->video
;
962 mpctx
->sh_video
= sh2
;
963 reinit_video_chain(mpctx
);
966 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
967 return M_PROPERTY_OK
;
970 return M_PROPERTY_NOT_IMPLEMENTED
;
974 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
977 demux_program_t prog
;
980 case M_PROPERTY_STEP_UP
:
982 if (action
== M_PROPERTY_SET
&& arg
)
983 prog
.progid
= *((int *) arg
);
987 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
988 &prog
) == DEMUXER_CTRL_NOTIMPL
)
989 return M_PROPERTY_ERROR
;
991 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
992 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
993 return M_PROPERTY_OK
;
996 return M_PROPERTY_NOT_IMPLEMENTED
;
1002 /// \defgroup VideoProperties Video properties
1003 /// \ingroup Properties
1006 /// Fullscreen state (RW)
1007 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1011 if (!mpctx
->video_out
)
1012 return M_PROPERTY_UNAVAILABLE
;
1015 case M_PROPERTY_SET
:
1017 return M_PROPERTY_ERROR
;
1018 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1019 if (vo_fs
== !!*(int *) arg
)
1020 return M_PROPERTY_OK
;
1021 case M_PROPERTY_STEP_UP
:
1022 case M_PROPERTY_STEP_DOWN
:
1025 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
1028 if (mpctx
->video_out
->config_ok
)
1029 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1030 return M_PROPERTY_OK
;
1032 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1036 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1037 void *arg
, MPContext
*mpctx
)
1041 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1042 return M_PROPERTY_UNAVAILABLE
;
1043 vf
= mpctx
->sh_video
->vfilter
;
1045 case M_PROPERTY_GET
:
1047 return M_PROPERTY_ERROR
;
1048 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1049 return M_PROPERTY_OK
;
1050 case M_PROPERTY_SET
:
1052 return M_PROPERTY_ERROR
;
1053 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1054 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1055 return M_PROPERTY_OK
;
1056 case M_PROPERTY_STEP_UP
:
1057 case M_PROPERTY_STEP_DOWN
:
1058 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1059 deinterlace
= !deinterlace
;
1060 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1061 return M_PROPERTY_OK
;
1063 return M_PROPERTY_NOT_IMPLEMENTED
;
1067 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1071 if (!mpctx
->video_out
1072 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1073 return M_PROPERTY_UNAVAILABLE
;
1076 case M_PROPERTY_SET
:
1078 return M_PROPERTY_ERROR
;
1079 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1080 vo_panscan
= *(float *) arg
;
1081 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1082 return M_PROPERTY_OK
;
1083 case M_PROPERTY_STEP_UP
:
1084 case M_PROPERTY_STEP_DOWN
:
1085 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1086 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1089 else if (vo_panscan
< 0)
1091 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1092 return M_PROPERTY_OK
;
1094 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1098 /// Helper to set vo flags.
1099 /** \ingroup PropertyImplHelper
1101 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1102 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1105 if (!mpctx
->video_out
)
1106 return M_PROPERTY_UNAVAILABLE
;
1109 case M_PROPERTY_SET
:
1111 return M_PROPERTY_ERROR
;
1112 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1113 if (*vo_var
== !!*(int *) arg
)
1114 return M_PROPERTY_OK
;
1115 case M_PROPERTY_STEP_UP
:
1116 case M_PROPERTY_STEP_DOWN
:
1117 if (mpctx
->video_out
->config_ok
)
1118 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1119 return M_PROPERTY_OK
;
1121 return m_property_flag(prop
, action
, arg
, vo_var
);
1125 /// Window always on top (RW)
1126 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1129 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1130 &mpctx
->opts
.vo_ontop
, mpctx
);
1133 /// Display in the root window (RW)
1134 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1137 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1138 &vo_rootwin
, mpctx
);
1141 /// Show window borders (RW)
1142 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1145 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1149 /// Framedropping state (RW)
1150 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1151 void *arg
, MPContext
*mpctx
)
1154 if (!mpctx
->sh_video
)
1155 return M_PROPERTY_UNAVAILABLE
;
1158 case M_PROPERTY_PRINT
:
1160 return M_PROPERTY_ERROR
;
1161 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1162 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1164 return M_PROPERTY_OK
;
1166 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1170 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1171 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1174 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1177 if (!mpctx
->sh_video
)
1178 return M_PROPERTY_UNAVAILABLE
;
1180 if (gamma
[0] == 1000) {
1182 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1186 case M_PROPERTY_SET
:
1188 return M_PROPERTY_ERROR
;
1189 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1190 *gamma
= *(int *) arg
;
1191 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1195 case M_PROPERTY_GET
:
1196 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1198 return M_PROPERTY_ERROR
;
1200 return M_PROPERTY_OK
;
1203 case M_PROPERTY_STEP_UP
:
1204 case M_PROPERTY_STEP_DOWN
:
1205 *gamma
+= (arg
? *(int *) arg
: 1) *
1206 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1207 M_PROPERTY_CLAMP(prop
, *gamma
);
1208 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1213 return M_PROPERTY_NOT_IMPLEMENTED
;
1217 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1218 int l
= strlen(prop
->name
);
1219 char tv_prop
[3 + l
+ 1];
1220 sprintf(tv_prop
, "tv_%s", prop
->name
);
1221 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1225 return M_PROPERTY_UNAVAILABLE
;
1229 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1232 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1235 /// Video codec tag (RO)
1236 static int mp_property_video_format(m_option_t
*prop
, int action
,
1237 void *arg
, MPContext
*mpctx
)
1240 if (!mpctx
->sh_video
)
1241 return M_PROPERTY_UNAVAILABLE
;
1243 case M_PROPERTY_PRINT
:
1245 return M_PROPERTY_ERROR
;
1246 switch(mpctx
->sh_video
->format
) {
1248 meta
= strdup ("mpeg1"); break;
1250 meta
= strdup ("mpeg2"); break;
1252 meta
= strdup ("mpeg4"); break;
1254 meta
= strdup ("h264"); break;
1256 if(mpctx
->sh_video
->format
>= 0x20202020) {
1258 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1261 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1264 *(char**)arg
= meta
;
1265 return M_PROPERTY_OK
;
1267 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1270 /// Video codec name (RO)
1271 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1272 void *arg
, MPContext
*mpctx
)
1274 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1275 return M_PROPERTY_UNAVAILABLE
;
1276 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1280 /// Video bitrate (RO)
1281 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1282 void *arg
, MPContext
*mpctx
)
1284 if (!mpctx
->sh_video
)
1285 return M_PROPERTY_UNAVAILABLE
;
1286 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1289 /// Video display width (RO)
1290 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1293 if (!mpctx
->sh_video
)
1294 return M_PROPERTY_UNAVAILABLE
;
1295 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1298 /// Video display height (RO)
1299 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1302 if (!mpctx
->sh_video
)
1303 return M_PROPERTY_UNAVAILABLE
;
1304 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1308 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1311 if (!mpctx
->sh_video
)
1312 return M_PROPERTY_UNAVAILABLE
;
1313 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1316 /// Video aspect (RO)
1317 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1320 if (!mpctx
->sh_video
)
1321 return M_PROPERTY_UNAVAILABLE
;
1322 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1327 /// \defgroup SubProprties Subtitles properties
1328 /// \ingroup Properties
1331 /// Text subtitle position (RW)
1332 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1335 if (!mpctx
->sh_video
)
1336 return M_PROPERTY_UNAVAILABLE
;
1339 case M_PROPERTY_SET
:
1341 return M_PROPERTY_ERROR
;
1342 case M_PROPERTY_STEP_UP
:
1343 case M_PROPERTY_STEP_DOWN
:
1344 vo_osd_changed(OSDTYPE_SUBTITLE
);
1346 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1350 /// Selected subtitles (RW)
1351 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1354 struct MPOpts
*opts
= &mpctx
->opts
;
1355 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1356 const int global_sub_size
= mpctx
->global_sub_size
;
1357 int source
= -1, reset_spu
= 0;
1360 if (global_sub_size
<= 0)
1361 return M_PROPERTY_UNAVAILABLE
;
1364 case M_PROPERTY_GET
:
1366 return M_PROPERTY_ERROR
;
1367 *(int *) arg
= mpctx
->global_sub_pos
;
1368 return M_PROPERTY_OK
;
1369 case M_PROPERTY_PRINT
:
1371 return M_PROPERTY_ERROR
;
1372 *(char **) arg
= malloc(64);
1373 (*(char **) arg
)[63] = 0;
1376 sub_name
= subdata
->filename
;
1378 if (ass_track
&& ass_track
->name
)
1379 sub_name
= ass_track
->name
;
1384 if ((tmp2
= strrchr(tmp
, '/')))
1387 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1388 mpctx
->set_of_sub_pos
+ 1,
1389 strlen(tmp
) < 20 ? "" : "...",
1390 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1391 return M_PROPERTY_OK
;
1393 #ifdef CONFIG_DVDNAV
1394 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1395 if (vo_spudec
&& opts
->sub_id
>= 0) {
1396 unsigned char lang
[3];
1397 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1398 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1399 return M_PROPERTY_OK
;
1405 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1406 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1407 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1408 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1409 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1410 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1411 if (!lang
) lang
= MSGTR_Unknown
;
1412 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1413 return M_PROPERTY_OK
;
1416 if (vo_vobsub
&& vobsub_id
>= 0) {
1417 const char *language
= MSGTR_Unknown
;
1418 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1419 snprintf(*(char **) arg
, 63, "(%d) %s",
1420 vobsub_id
, language
? language
: MSGTR_Unknown
);
1421 return M_PROPERTY_OK
;
1423 #ifdef CONFIG_DVDREAD
1424 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1425 && opts
->sub_id
>= 0) {
1427 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1428 lang
[0] = code
>> 8;
1431 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1432 return M_PROPERTY_OK
;
1435 if (opts
->sub_id
>= 0) {
1436 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, MSGTR_Unknown
);
1437 return M_PROPERTY_OK
;
1439 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1440 return M_PROPERTY_OK
;
1442 case M_PROPERTY_SET
:
1444 return M_PROPERTY_ERROR
;
1445 if (*(int *) arg
< -1)
1447 else if (*(int *) arg
>= global_sub_size
)
1448 *(int *) arg
= global_sub_size
- 1;
1449 mpctx
->global_sub_pos
= *(int *) arg
;
1451 case M_PROPERTY_STEP_UP
:
1452 mpctx
->global_sub_pos
+= 2;
1453 mpctx
->global_sub_pos
=
1454 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1456 case M_PROPERTY_STEP_DOWN
:
1457 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1458 mpctx
->global_sub_pos
=
1459 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1462 return M_PROPERTY_NOT_IMPLEMENTED
;
1465 if (mpctx
->global_sub_pos
>= 0)
1466 source
= sub_source(mpctx
);
1468 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1469 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1471 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1472 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1473 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1474 mpctx
->global_sub_pos
, source
);
1476 mpctx
->set_of_sub_pos
= -1;
1490 if (source
== SUB_SOURCE_VOBSUB
) {
1491 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1492 } else if (source
== SUB_SOURCE_SUBS
) {
1493 mpctx
->set_of_sub_pos
=
1494 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1496 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1497 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1501 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1502 vo_osd_changed(OSDTYPE_SUBTITLE
);
1504 } else if (source
== SUB_SOURCE_DEMUX
) {
1506 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1507 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1509 // default: assume 1:1 mapping of sid and stream id
1510 d_sub
->id
= opts
->sub_id
;
1511 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1512 ds_free_packs(d_sub
);
1513 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1514 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1515 if (sh
&& sh
->sid
== opts
->sub_id
) {
1521 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1522 sh_sub_t
*sh
= d_sub
->sh
;
1523 if (sh
->type
== 'v')
1524 init_vo_spudec(mpctx
);
1526 else if (ass_enabled
)
1527 ass_track
= sh
->ass_track
;
1535 #ifdef CONFIG_DVDREAD
1537 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1538 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1539 && opts
->sub_id
< 0 && reset_spu
) {
1541 d_sub
->id
= opts
->sub_id
;
1544 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1546 return M_PROPERTY_OK
;
1549 /// Selected sub source (RW)
1550 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1554 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1555 return M_PROPERTY_UNAVAILABLE
;
1558 case M_PROPERTY_GET
:
1560 return M_PROPERTY_ERROR
;
1561 *(int *) arg
= sub_source(mpctx
);
1562 return M_PROPERTY_OK
;
1563 case M_PROPERTY_PRINT
:
1565 return M_PROPERTY_ERROR
;
1566 *(char **) arg
= malloc(64);
1567 (*(char **) arg
)[63] = 0;
1568 switch (sub_source(mpctx
))
1570 case SUB_SOURCE_SUBS
:
1571 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1573 case SUB_SOURCE_VOBSUB
:
1574 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1576 case SUB_SOURCE_DEMUX
:
1577 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1580 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1582 return M_PROPERTY_OK
;
1583 case M_PROPERTY_SET
:
1585 return M_PROPERTY_ERROR
;
1586 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1587 if (*(int *) arg
< 0)
1588 mpctx
->global_sub_pos
= -1;
1589 else if (*(int *) arg
!= sub_source(mpctx
)) {
1590 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1591 return M_PROPERTY_UNAVAILABLE
;
1592 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1595 case M_PROPERTY_STEP_UP
:
1596 case M_PROPERTY_STEP_DOWN
: {
1597 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1598 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1599 int step
= (step_all
> 0) ? 1 : -1;
1600 int cur_source
= sub_source(mpctx
);
1601 source
= cur_source
;
1604 if (source
>= SUB_SOURCES
)
1606 else if (source
< -1)
1607 source
= SUB_SOURCES
- 1;
1608 if (source
== cur_source
|| source
== -1 ||
1609 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1612 if (source
== cur_source
)
1613 return M_PROPERTY_OK
;
1615 mpctx
->global_sub_pos
= -1;
1617 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1621 return M_PROPERTY_NOT_IMPLEMENTED
;
1623 --mpctx
->global_sub_pos
;
1624 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1627 /// Selected subtitles from specific source (RW)
1628 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1631 int source
, is_cur_source
, offset
;
1632 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1633 return M_PROPERTY_UNAVAILABLE
;
1635 if (!strcmp(prop
->name
, "sub_file"))
1636 source
= SUB_SOURCE_SUBS
;
1637 else if (!strcmp(prop
->name
, "sub_vob"))
1638 source
= SUB_SOURCE_VOBSUB
;
1639 else if (!strcmp(prop
->name
, "sub_demux"))
1640 source
= SUB_SOURCE_DEMUX
;
1642 return M_PROPERTY_ERROR
;
1644 offset
= mpctx
->global_sub_indices
[source
];
1645 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1646 return M_PROPERTY_UNAVAILABLE
;
1648 is_cur_source
= sub_source(mpctx
) == source
;
1650 case M_PROPERTY_GET
:
1652 return M_PROPERTY_ERROR
;
1653 if (is_cur_source
) {
1654 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1655 if (source
== SUB_SOURCE_VOBSUB
)
1656 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1660 return M_PROPERTY_OK
;
1661 case M_PROPERTY_PRINT
:
1663 return M_PROPERTY_ERROR
;
1665 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1666 *(char **) arg
= malloc(64);
1667 (*(char **) arg
)[63] = 0;
1668 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1669 return M_PROPERTY_OK
;
1670 case M_PROPERTY_SET
:
1672 return M_PROPERTY_ERROR
;
1673 if (*(int *) arg
>= 0) {
1674 int index
= *(int *)arg
;
1675 if (source
== SUB_SOURCE_VOBSUB
)
1676 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1677 mpctx
->global_sub_pos
= offset
+ index
;
1678 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1679 || sub_source(mpctx
) != source
) {
1680 mpctx
->global_sub_pos
= -1;
1685 mpctx
->global_sub_pos
= -1;
1687 case M_PROPERTY_STEP_UP
:
1688 case M_PROPERTY_STEP_DOWN
: {
1689 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1690 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1691 int step
= (step_all
> 0) ? 1 : -1;
1692 int max_sub_pos_for_source
= -1;
1694 mpctx
->global_sub_pos
= -1;
1696 if (mpctx
->global_sub_pos
== -1) {
1698 mpctx
->global_sub_pos
= offset
;
1699 else if (max_sub_pos_for_source
== -1) {
1700 // Find max pos for specific source
1701 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1702 while (mpctx
->global_sub_pos
>= 0
1703 && sub_source(mpctx
) != source
)
1704 --mpctx
->global_sub_pos
;
1707 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1710 mpctx
->global_sub_pos
+= step
;
1711 if (mpctx
->global_sub_pos
< offset
||
1712 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1713 sub_source(mpctx
) != source
)
1714 mpctx
->global_sub_pos
= -1;
1721 return M_PROPERTY_NOT_IMPLEMENTED
;
1723 --mpctx
->global_sub_pos
;
1724 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1727 /// Subtitle delay (RW)
1728 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1731 if (!mpctx
->sh_video
)
1732 return M_PROPERTY_UNAVAILABLE
;
1733 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1736 /// Alignment of text subtitles (RW)
1737 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1738 void *arg
, MPContext
*mpctx
)
1740 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1742 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1743 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1744 return M_PROPERTY_UNAVAILABLE
;
1747 case M_PROPERTY_PRINT
:
1749 return M_PROPERTY_ERROR
;
1750 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1751 *(char **) arg
= strdup(name
[sub_alignment
]);
1752 return M_PROPERTY_OK
;
1753 case M_PROPERTY_SET
:
1755 return M_PROPERTY_ERROR
;
1756 case M_PROPERTY_STEP_UP
:
1757 case M_PROPERTY_STEP_DOWN
:
1758 vo_osd_changed(OSDTYPE_SUBTITLE
);
1760 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1764 /// Subtitle visibility (RW)
1765 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1766 void *arg
, MPContext
*mpctx
)
1768 if (!mpctx
->sh_video
)
1769 return M_PROPERTY_UNAVAILABLE
;
1772 case M_PROPERTY_SET
:
1774 return M_PROPERTY_ERROR
;
1775 case M_PROPERTY_STEP_UP
:
1776 case M_PROPERTY_STEP_DOWN
:
1777 vo_osd_changed(OSDTYPE_SUBTITLE
);
1779 vo_osd_changed(OSDTYPE_SPU
);
1781 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1786 /// Use margins for libass subtitles (RW)
1787 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1788 void *arg
, MPContext
*mpctx
)
1790 if (!mpctx
->sh_video
)
1791 return M_PROPERTY_UNAVAILABLE
;
1794 case M_PROPERTY_SET
:
1796 return M_PROPERTY_ERROR
;
1797 case M_PROPERTY_STEP_UP
:
1798 case M_PROPERTY_STEP_DOWN
:
1799 ass_force_reload
= 1;
1801 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1806 /// Show only forced subtitles (RW)
1807 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1808 void *arg
, MPContext
*mpctx
)
1811 return M_PROPERTY_UNAVAILABLE
;
1814 case M_PROPERTY_SET
:
1816 return M_PROPERTY_ERROR
;
1817 case M_PROPERTY_STEP_UP
:
1818 case M_PROPERTY_STEP_DOWN
:
1819 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1820 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1821 return M_PROPERTY_OK
;
1823 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1828 #ifdef CONFIG_FREETYPE
1829 /// Subtitle scale (RW)
1830 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1835 case M_PROPERTY_SET
:
1837 return M_PROPERTY_ERROR
;
1838 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1841 ass_font_scale
= *(float *) arg
;
1842 ass_force_reload
= 1;
1845 text_font_scale_factor
= *(float *) arg
;
1846 force_load_font
= 1;
1847 return M_PROPERTY_OK
;
1848 case M_PROPERTY_STEP_UP
:
1849 case M_PROPERTY_STEP_DOWN
:
1852 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1853 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1854 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1855 ass_force_reload
= 1;
1858 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1859 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1860 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1861 force_load_font
= 1;
1862 return M_PROPERTY_OK
;
1866 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1869 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1876 /// \defgroup TVProperties TV properties
1877 /// \ingroup Properties
1882 /// TV color settings (RW)
1883 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1887 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1888 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1889 return M_PROPERTY_UNAVAILABLE
;
1892 case M_PROPERTY_SET
:
1894 return M_PROPERTY_ERROR
;
1895 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1896 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1897 case M_PROPERTY_GET
:
1898 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1899 case M_PROPERTY_STEP_UP
:
1900 case M_PROPERTY_STEP_DOWN
:
1901 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1903 return M_PROPERTY_ERROR
;
1904 val
+= (arg
? *(int *) arg
: 1) *
1905 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1906 M_PROPERTY_CLAMP(prop
, val
);
1907 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1909 return M_PROPERTY_ERROR
;
1911 return M_PROPERTY_NOT_IMPLEMENTED
;
1916 #ifdef CONFIG_TV_TELETEXT
1917 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1921 int base_ioctl
=(int)prop
->priv
;
1923 for teletext's GET,SET,STEP ioctls this is not 0
1927 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1928 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1929 return M_PROPERTY_UNAVAILABLE
;
1931 return M_PROPERTY_ERROR
;
1934 case M_PROPERTY_GET
:
1936 return M_PROPERTY_ERROR
;
1937 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1939 case M_PROPERTY_SET
:
1941 return M_PROPERTY_ERROR
;
1942 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1943 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1945 case M_PROPERTY_STEP_UP
:
1946 case M_PROPERTY_STEP_DOWN
:
1947 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1948 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1949 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1952 return M_PROPERTY_NOT_IMPLEMENTED
;
1955 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1958 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1961 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1965 //with tvh==NULL will fail too
1966 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1967 if(result
!=M_PROPERTY_OK
)
1970 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1971 mp_input_set_section(mpctx
->input
, "teletext");
1973 mp_input_set_section(mpctx
->input
, "tv");
1974 return M_PROPERTY_OK
;
1977 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1980 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1983 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1984 return M_PROPERTY_UNAVAILABLE
;
1986 case M_PROPERTY_STEP_UP
:
1987 case M_PROPERTY_STEP_DOWN
:
1988 //This should be handled separately
1989 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1990 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1993 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1999 #endif /* CONFIG_TV_TELETEXT */
2003 /// All properties available in MPlayer.
2004 /** \ingroup Properties
2006 static const m_option_t mp_properties
[] = {
2008 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2009 M_OPT_RANGE
, 0, 3, NULL
},
2010 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2011 M_OPT_MIN
, -1, 0, NULL
},
2012 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2013 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2014 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2016 { "path", mp_property_path
, CONF_TYPE_STRING
,
2018 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2020 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2021 M_OPT_MIN
, 0, 0, NULL
},
2022 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2023 M_OPT_MIN
, 0, 0, NULL
},
2024 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2025 M_OPT_MIN
, 0, 0, NULL
},
2026 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2027 M_OPT_MIN
, 0, 0, NULL
},
2028 { "length", mp_property_length
, CONF_TYPE_TIME
,
2029 M_OPT_MIN
, 0, 0, NULL
},
2030 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2031 M_OPT_RANGE
, 0, 100, NULL
},
2032 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2033 M_OPT_MIN
, 0, 0, NULL
},
2034 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2035 M_OPT_MIN
, 1, 0, NULL
},
2036 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2038 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2039 CONF_RANGE
, -2, 10, NULL
},
2040 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2042 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2043 M_OPT_RANGE
, 0, 1, NULL
},
2046 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2047 M_OPT_RANGE
, 0, 100, NULL
},
2048 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2049 M_OPT_RANGE
, 0, 1, NULL
},
2050 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2051 M_OPT_RANGE
, -100, 100, NULL
},
2052 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2054 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2056 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2058 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2060 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2062 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2063 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2064 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2065 M_OPT_RANGE
, -1, 1, NULL
},
2068 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2069 M_OPT_RANGE
, 0, 1, NULL
},
2070 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2071 M_OPT_RANGE
, 0, 1, NULL
},
2072 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2073 M_OPT_RANGE
, 0, 1, NULL
},
2074 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2075 M_OPT_RANGE
, 0, 1, NULL
},
2076 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2077 M_OPT_RANGE
, 0, 1, NULL
},
2078 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, 0, 2, NULL
},
2080 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2081 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2082 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2083 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2084 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2085 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2086 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2087 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2088 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2089 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2090 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2091 M_OPT_RANGE
, 0, 1, NULL
},
2092 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2093 M_OPT_RANGE
, 0, 1, NULL
},
2094 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2096 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2098 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2100 { "width", mp_property_width
, CONF_TYPE_INT
,
2102 { "height", mp_property_height
, CONF_TYPE_INT
,
2104 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2106 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2108 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2109 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2110 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2111 CONF_RANGE
, -1, 65535, NULL
},
2114 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2115 M_OPT_MIN
, -1, 0, NULL
},
2116 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2117 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2118 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2119 M_OPT_MIN
, -1, 0, NULL
},
2120 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2121 M_OPT_MIN
, -1, 0, NULL
},
2122 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2123 M_OPT_MIN
, -1, 0, NULL
},
2124 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2126 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2127 M_OPT_RANGE
, 0, 100, NULL
},
2128 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2129 M_OPT_RANGE
, 0, 2, NULL
},
2130 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2131 M_OPT_RANGE
, 0, 1, NULL
},
2132 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2133 M_OPT_RANGE
, 0, 1, NULL
},
2134 #ifdef CONFIG_FREETYPE
2135 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2136 M_OPT_RANGE
, 0, 100, NULL
},
2139 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2140 M_OPT_RANGE
, 0, 1, NULL
},
2144 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2145 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2146 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2147 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2148 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2149 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2150 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2151 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2154 #ifdef CONFIG_TV_TELETEXT
2155 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2156 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2157 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2158 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2159 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2160 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2161 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2162 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2163 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2164 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2167 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2171 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2173 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2176 char* mp_property_print(const char *name
, void* ctx
)
2179 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2184 char *property_expand_string(MPContext
*mpctx
, char *str
)
2186 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2189 void property_print_help(void)
2191 m_properties_print_help_list(mp_properties
);
2200 * \defgroup Command2Property Command to property bridge
2202 * It is used to handle most commands that just set a property
2203 * and optionally display something on the OSD.
2204 * Two kinds of commands are handled: adjust or toggle.
2206 * Adjust commands take 1 or 2 parameters: <value> <abs>
2207 * If <abs> is non-zero the property is set to the given value
2208 * otherwise it is adjusted.
2210 * Toggle commands take 0 or 1 parameters. With no parameter
2211 * or a value less than the property minimum it just steps the
2212 * property to its next value. Otherwise it sets it to the given
2218 /// List of the commands that can be handled by setting a property.
2224 /// set/adjust or toggle command
2226 /// progressbar type
2228 /// osd msg id if it must be shared
2230 /// osd msg template
2231 const char *osd_msg
;
2232 } set_prop_cmd
[] = {
2234 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2235 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2236 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2237 { "pause", MP_CMD_PAUSE
, 0, 0, -1, NULL
},
2239 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2240 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2241 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2242 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2243 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2245 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2246 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2247 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2248 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2249 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2250 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2251 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2252 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2253 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2254 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2255 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2256 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2258 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2259 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2260 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2261 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2262 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2263 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2264 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2265 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2266 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2267 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2268 #ifdef CONFIG_FREETYPE
2269 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2272 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2275 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2276 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2277 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2278 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2280 { NULL
, 0, 0, 0, -1, NULL
}
2284 /// Handle commands that set a property.
2285 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2291 // look for the command
2292 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2293 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2295 if (!(pname
= set_prop_cmd
[i
].name
))
2298 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2302 if (set_prop_cmd
[i
].toggle
) {
2304 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2305 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2307 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2308 } else if (cmd
->args
[1].v
.i
) //set
2309 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2311 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2316 if (set_prop_cmd
[i
].osd_progbar
) {
2317 if (prop
->type
== CONF_TYPE_INT
) {
2318 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2319 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2320 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2321 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2323 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2324 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2325 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2327 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2328 "Property use an unsupported type.\n");
2332 if (set_prop_cmd
[i
].osd_msg
) {
2333 char *val
= mp_property_print(pname
, mpctx
);
2335 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2336 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2337 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2344 #ifdef CONFIG_DVDNAV
2345 static const struct {
2347 const mp_command_type cmd
;
2348 } mp_dvdnav_bindings
[] = {
2349 { "up", MP_CMD_DVDNAV_UP
},
2350 { "down", MP_CMD_DVDNAV_DOWN
},
2351 { "left", MP_CMD_DVDNAV_LEFT
},
2352 { "right", MP_CMD_DVDNAV_RIGHT
},
2353 { "menu", MP_CMD_DVDNAV_MENU
},
2354 { "select", MP_CMD_DVDNAV_SELECT
},
2355 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2356 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2359 * keep old dvdnav sub-command options for a while in order not to
2360 * break slave-mode API too suddenly.
2362 { "1", MP_CMD_DVDNAV_UP
},
2363 { "2", MP_CMD_DVDNAV_DOWN
},
2364 { "3", MP_CMD_DVDNAV_LEFT
},
2365 { "4", MP_CMD_DVDNAV_RIGHT
},
2366 { "5", MP_CMD_DVDNAV_MENU
},
2367 { "6", MP_CMD_DVDNAV_SELECT
},
2368 { "7", MP_CMD_DVDNAV_PREVMENU
},
2369 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2374 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2376 struct MPOpts
*opts
= &mpctx
->opts
;
2377 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2378 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2379 if (!set_property_command(mpctx
, cmd
))
2385 mpctx
->osd_show_percentage
= sh_video
->fps
;
2386 v
= cmd
->args
[0].v
.f
;
2387 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2388 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2389 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2391 mpctx
->osd_function
=
2392 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2393 mpctx
->rel_seek_secs
= v
;
2394 } else if (abs
) { /* Absolute seek by percentage */
2395 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2397 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2398 mpctx
->rel_seek_secs
= v
/ 100.0;
2400 mpctx
->rel_seek_secs
+= v
;
2401 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2406 case MP_CMD_SET_PROPERTY
:{
2407 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2408 cmd
->args
[1].v
.s
, mpctx
);
2409 if (r
== M_PROPERTY_UNKNOWN
)
2410 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2411 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2413 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2414 "Failed to set property '%s' to '%s'.\n",
2415 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2419 case MP_CMD_STEP_PROPERTY
:{
2424 if (cmd
->args
[1].v
.f
) {
2426 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2427 M_PROPERTY_GET_TYPE
,
2428 &prop
, mpctx
)) <= 0)
2430 if(prop
->type
== CONF_TYPE_INT
||
2431 prop
->type
== CONF_TYPE_FLAG
)
2432 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2433 else if(prop
->type
== CONF_TYPE_FLOAT
)
2434 arg
= &cmd
->args
[1].v
.f
;
2435 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2436 prop
->type
== CONF_TYPE_TIME
)
2437 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2438 else if(prop
->type
== CONF_TYPE_POSITION
)
2439 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2441 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2442 "Ignoring step size stepping property '%s'.\n",
2445 r
= mp_property_do(cmd
->args
[0].v
.s
,
2446 cmd
->args
[2].v
.i
< 0 ?
2447 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2450 if (r
== M_PROPERTY_UNKNOWN
)
2451 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2452 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2454 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2455 "Failed to increment property '%s' by %f.\n",
2456 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2460 case MP_CMD_GET_PROPERTY
:{
2462 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2463 &tmp
, mpctx
) <= 0) {
2464 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2465 "Failed to get value of property '%s'.\n",
2469 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2470 cmd
->args
[0].v
.s
, tmp
);
2475 case MP_CMD_EDL_MARK
:
2477 float v
= sh_video
? sh_video
->pts
:
2478 playing_audio_pts(mpctx
);
2479 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2480 mpctx
->begin_skip
= v
;
2481 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2483 if (mpctx
->begin_skip
> v
)
2484 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2486 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2487 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2489 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2494 case MP_CMD_SWITCH_RATIO
:
2497 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2498 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2500 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2501 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2504 case MP_CMD_SPEED_INCR
:{
2505 float v
= cmd
->args
[0].v
.f
;
2506 opts
->playback_speed
+= v
;
2507 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2508 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2509 opts
->playback_speed
);
2512 case MP_CMD_SPEED_MULT
:{
2513 float v
= cmd
->args
[0].v
.f
;
2514 opts
->playback_speed
*= v
;
2515 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2516 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2517 opts
->playback_speed
);
2520 case MP_CMD_SPEED_SET
:{
2521 float v
= cmd
->args
[0].v
.f
;
2522 opts
->playback_speed
= v
;
2523 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2524 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2525 opts
->playback_speed
);
2528 case MP_CMD_FRAME_STEP
:
2529 add_step_frame(mpctx
);
2532 case MP_CMD_FILE_FILTER
:
2533 file_filter
= cmd
->args
[0].v
.i
;
2537 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2538 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2540 case MP_CMD_PLAY_TREE_STEP
:{
2541 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2542 int force
= cmd
->args
[1].v
.i
;
2548 for (i
= 0; i
< n
; i
++)
2551 for (i
= 0; i
< -1 * n
; i
++)
2556 if (!force
&& mpctx
->playtree_iter
) {
2557 play_tree_iter_t
*i
=
2558 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2559 if (play_tree_iter_step(i
, n
, 0) ==
2560 PLAY_TREE_ITER_ENTRY
)
2562 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2563 play_tree_iter_free(i
);
2565 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2566 if (mpctx
->stop_play
)
2567 mpctx
->play_tree_step
= n
;
2572 case MP_CMD_PLAY_TREE_UP_STEP
:{
2573 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2574 int force
= cmd
->args
[1].v
.i
;
2576 if (!force
&& mpctx
->playtree_iter
) {
2577 play_tree_iter_t
*i
=
2578 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2579 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2580 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2581 play_tree_iter_free(i
);
2583 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2587 case MP_CMD_PLAY_ALT_SRC_STEP
:
2588 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2589 int v
= cmd
->args
[0].v
.i
;
2591 && mpctx
->playtree_iter
->file
<
2592 mpctx
->playtree_iter
->num_files
)
2593 mpctx
->stop_play
= PT_NEXT_SRC
;
2594 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2595 mpctx
->stop_play
= PT_PREV_SRC
;
2599 case MP_CMD_SUB_STEP
:
2601 int movement
= cmd
->args
[0].v
.i
;
2602 step_sub(subdata
, sh_video
->pts
, movement
);
2606 ass_step_sub(ass_track
,
2608 sub_delay
) * 1000 + .5, movement
) / 1000.;
2610 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2611 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2615 case MP_CMD_SUB_LOG
:
2620 int v
= cmd
->args
[0].v
.i
;
2622 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2623 if (osd_level
> max
)
2626 osd_level
= (osd_level
+ 1) % (max
+ 1);
2628 osd_level
= v
> max
? max
: v
;
2629 /* Show OSD state when disabled, but not when an explicit
2630 argument is given to the OSD command, i.e. in slave mode. */
2631 if (v
== -1 && osd_level
<= 1)
2632 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2634 osd_level
? MSGTR_OSDenabled
:
2637 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2641 case MP_CMD_OSD_SHOW_TEXT
:
2642 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2644 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2645 "%-.63s", cmd
->args
[0].v
.s
);
2648 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2649 char *txt
= m_properties_expand_string(mp_properties
,
2652 /* if no argument supplied take default osd_duration, else <arg> ms. */
2654 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2656 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2663 case MP_CMD_LOADFILE
:{
2664 play_tree_t
*e
= play_tree_new();
2665 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2667 if (cmd
->args
[1].v
.i
) // append
2668 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2670 // Go back to the starting point.
2671 while (play_tree_iter_up_step
2672 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2674 play_tree_free_list(mpctx
->playtree
->child
, 1);
2675 play_tree_set_child(mpctx
->playtree
, e
);
2676 pt_iter_goto_head(mpctx
->playtree_iter
);
2677 mpctx
->stop_play
= PT_NEXT_SRC
;
2682 case MP_CMD_LOADLIST
:{
2683 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2685 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2686 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2688 if (cmd
->args
[1].v
.i
) // append
2689 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2691 // Go back to the starting point.
2692 while (play_tree_iter_up_step
2693 (mpctx
->playtree_iter
, 0, 1)
2694 != PLAY_TREE_ITER_END
)
2696 play_tree_free_list(mpctx
->playtree
->child
, 1);
2697 play_tree_set_child(mpctx
->playtree
, e
);
2698 pt_iter_goto_head(mpctx
->playtree_iter
);
2699 mpctx
->stop_play
= PT_NEXT_SRC
;
2706 // Go back to the starting point.
2707 while (play_tree_iter_up_step
2708 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2710 mpctx
->stop_play
= PT_STOP
;
2714 case MP_CMD_RADIO_STEP_CHANNEL
:
2715 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2716 int v
= cmd
->args
[0].v
.i
;
2718 radio_step_channel(mpctx
->demuxer
->stream
,
2719 RADIO_CHANNEL_HIGHER
);
2721 radio_step_channel(mpctx
->demuxer
->stream
,
2722 RADIO_CHANNEL_LOWER
);
2723 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2724 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2726 radio_get_channel_name(mpctx
->demuxer
->stream
));
2731 case MP_CMD_RADIO_SET_CHANNEL
:
2732 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2733 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2734 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2735 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2737 radio_get_channel_name(mpctx
->demuxer
->stream
));
2742 case MP_CMD_RADIO_SET_FREQ
:
2743 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2744 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2747 case MP_CMD_RADIO_STEP_FREQ
:
2748 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2749 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2754 case MP_CMD_TV_START_SCAN
:
2755 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2756 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2758 case MP_CMD_TV_SET_FREQ
:
2759 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2760 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2761 cmd
->args
[0].v
.f
* 16.0);
2763 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2764 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2765 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2766 pvr_get_current_channelname (mpctx
->stream
),
2767 pvr_get_current_stationname (mpctx
->stream
));
2769 #endif /* CONFIG_PVR */
2772 case MP_CMD_TV_STEP_FREQ
:
2773 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2774 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2775 cmd
->args
[0].v
.f
* 16.0);
2777 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2778 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2779 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2780 pvr_get_current_channelname (mpctx
->stream
),
2781 pvr_get_current_frequency (mpctx
->stream
));
2783 #endif /* CONFIG_PVR */
2786 case MP_CMD_TV_SET_NORM
:
2787 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2788 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2792 case MP_CMD_TV_STEP_CHANNEL
:{
2793 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2794 int v
= cmd
->args
[0].v
.i
;
2796 tv_step_channel((tvi_handle_t
*) (mpctx
->
2800 tv_step_channel((tvi_handle_t
*) (mpctx
->
2804 if (tv_channel_list
) {
2805 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2806 MSGTR_OSDChannel
, tv_channel_current
->name
);
2807 //vo_osd_changed(OSDTYPE_SUBTITLE);
2811 else if (mpctx
->stream
&&
2812 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2813 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2814 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2815 pvr_get_current_channelname (mpctx
->stream
),
2816 pvr_get_current_stationname (mpctx
->stream
));
2818 #endif /* CONFIG_PVR */
2821 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2823 int v
= cmd
->args
[0].v
.i
;
2825 mpctx
->last_dvb_step
= v
;
2827 dir
= DVB_CHANNEL_HIGHER
;
2829 dir
= DVB_CHANNEL_LOWER
;
2832 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2833 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2834 mpctx
->dvbin_reopen
= 1;
2837 #endif /* CONFIG_DVBIN */
2840 case MP_CMD_TV_SET_CHANNEL
:
2841 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2842 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2844 if (tv_channel_list
) {
2845 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2846 MSGTR_OSDChannel
, tv_channel_current
->name
);
2847 //vo_osd_changed(OSDTYPE_SUBTITLE);
2851 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2852 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2853 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2854 pvr_get_current_channelname (mpctx
->stream
),
2855 pvr_get_current_stationname (mpctx
->stream
));
2857 #endif /* CONFIG_PVR */
2861 case MP_CMD_DVB_SET_CHANNEL
:
2862 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2863 mpctx
->last_dvb_step
= 1;
2865 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2866 cmd
->args
[0].v
.i
)) {
2867 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2868 mpctx
->dvbin_reopen
= 1;
2872 #endif /* CONFIG_DVBIN */
2874 case MP_CMD_TV_LAST_CHANNEL
:
2875 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2876 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2877 if (tv_channel_list
) {
2878 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2879 MSGTR_OSDChannel
, tv_channel_current
->name
);
2880 //vo_osd_changed(OSDTYPE_SUBTITLE);
2884 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2885 pvr_set_lastchannel (mpctx
->stream
);
2886 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2887 pvr_get_current_channelname (mpctx
->stream
),
2888 pvr_get_current_stationname (mpctx
->stream
));
2890 #endif /* CONFIG_PVR */
2893 case MP_CMD_TV_STEP_NORM
:
2894 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2895 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2898 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2899 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2900 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2902 #ifdef CONFIG_TV_TELETEXT
2903 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2905 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2906 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2907 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2910 case MP_CMD_TV_TELETEXT_GO_LINK
:
2912 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2913 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2914 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2917 #endif /* CONFIG_TV_TELETEXT */
2918 #endif /* CONFIG_TV */
2920 case MP_CMD_SUB_LOAD
:
2922 int n
= mpctx
->set_of_sub_size
;
2923 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2924 if (n
!= mpctx
->set_of_sub_size
) {
2925 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2926 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2927 mpctx
->global_sub_size
;
2928 ++mpctx
->global_sub_size
;
2933 case MP_CMD_SUB_REMOVE
:
2935 int v
= cmd
->args
[0].v
.i
;
2938 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2939 subd
= mpctx
->set_of_subtitles
[v
];
2940 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2941 MSGTR_RemovedSubtitleFile
, v
+ 1,
2942 filename_recode(subd
->filename
));
2944 mpctx
->set_of_subtitles
[v
] = NULL
;
2946 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2947 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2948 mpctx
->set_of_sub_size
= 0;
2949 if (mpctx
->set_of_sub_pos
>= 0) {
2950 mpctx
->global_sub_pos
= -2;
2952 mp_input_queue_cmd(mpctx
->input
,
2953 mp_input_parse_cmd("sub_select"));
2955 } else if (v
< mpctx
->set_of_sub_size
) {
2956 subd
= mpctx
->set_of_subtitles
[v
];
2957 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2958 MSGTR_RemovedSubtitleFile
, v
+ 1,
2959 filename_recode(subd
->filename
));
2961 if (mpctx
->set_of_sub_pos
== v
) {
2962 mpctx
->global_sub_pos
= -2;
2964 mp_input_queue_cmd(mpctx
->input
,
2965 mp_input_parse_cmd("sub_select"));
2966 } else if (mpctx
->set_of_sub_pos
> v
) {
2967 --mpctx
->set_of_sub_pos
;
2968 --mpctx
->global_sub_pos
;
2970 while (++v
< mpctx
->set_of_sub_size
)
2971 mpctx
->set_of_subtitles
[v
- 1] =
2972 mpctx
->set_of_subtitles
[v
];
2973 --mpctx
->set_of_sub_size
;
2974 --mpctx
->global_sub_size
;
2975 if (mpctx
->set_of_sub_size
<= 0)
2976 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2977 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2982 case MP_CMD_GET_SUB_VISIBILITY
:
2984 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2985 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2989 case MP_CMD_SCREENSHOT
:
2990 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2991 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2993 ((vf_instance_t
*) sh_video
->vfilter
)->
2994 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2996 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3000 case MP_CMD_VF_CHANGE_RECTANGLE
:
3003 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3006 case MP_CMD_GET_TIME_LENGTH
:{
3007 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
3008 demuxer_get_time_length(mpctx
->demuxer
));
3012 case MP_CMD_GET_FILENAME
:{
3013 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3014 get_metadata(mpctx
, META_NAME
));
3018 case MP_CMD_GET_VIDEO_CODEC
:{
3019 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3022 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3027 case MP_CMD_GET_VIDEO_BITRATE
:{
3028 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3031 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3036 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3037 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3040 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3041 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3046 case MP_CMD_GET_AUDIO_CODEC
:{
3047 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3050 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3055 case MP_CMD_GET_AUDIO_BITRATE
:{
3056 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3059 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3064 case MP_CMD_GET_AUDIO_SAMPLES
:{
3065 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3068 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3073 case MP_CMD_GET_META_TITLE
:{
3074 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3077 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3082 case MP_CMD_GET_META_ARTIST
:{
3083 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3086 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3091 case MP_CMD_GET_META_ALBUM
:{
3092 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3095 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3100 case MP_CMD_GET_META_YEAR
:{
3101 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3104 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3109 case MP_CMD_GET_META_COMMENT
:{
3110 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3113 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3118 case MP_CMD_GET_META_TRACK
:{
3119 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3122 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3127 case MP_CMD_GET_META_GENRE
:{
3128 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3131 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3136 case MP_CMD_GET_VO_FULLSCREEN
:
3137 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3138 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3141 case MP_CMD_GET_PERCENT_POS
:
3142 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3143 demuxer_get_percent_pos(mpctx
->demuxer
));
3146 case MP_CMD_GET_TIME_POS
:{
3149 pos
= sh_video
->pts
;
3150 else if (sh_audio
&& mpctx
->audio_out
)
3151 pos
= playing_audio_pts(mpctx
);
3152 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3159 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3165 case MP_CMD_KEYDOWN_EVENTS
:
3166 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3169 case MP_CMD_SET_MOUSE_POS
:{
3170 int pointer_x
, pointer_y
;
3172 pointer_x
= cmd
->args
[0].v
.i
;
3173 pointer_y
= cmd
->args
[1].v
.i
;
3174 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3175 #ifdef CONFIG_DVDNAV
3176 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3177 && dx
> 0.0 && dy
> 0.0) {
3179 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3180 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3181 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3182 pointer_x
, pointer_y
, &button
);
3183 if (osd_level
> 1 && button
> 0)
3184 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3185 "Selected button number %d", button
);
3189 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3190 menu_update_mouse_pos(dx
, dy
);
3195 #ifdef CONFIG_DVDNAV
3196 case MP_CMD_DVDNAV
:{
3199 mp_command_type command
= 0;
3200 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3203 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3204 if (cmd
->args
[0].v
.s
&&
3205 !strcasecmp (cmd
->args
[0].v
.s
,
3206 mp_dvdnav_bindings
[i
].name
))
3207 command
= mp_dvdnav_bindings
[i
].cmd
;
3209 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3210 if (osd_level
> 1 && button
> 0)
3211 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3212 "Selected button number %d", button
);
3216 case MP_CMD_SWITCH_TITLE
:
3217 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3218 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3225 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3226 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3229 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3230 "Received unknown cmd %s\n", cmd
->name
);
3233 switch (cmd
->pausing
) {
3234 case 1: // "pausing"
3235 pause_player(mpctx
);
3237 case 3: // "pausing_toggle"
3239 unpause_player(mpctx
);
3241 pause_player(mpctx
);