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
, &mpctx
->opts
.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
,
388 struct MPOpts
*opts
= &mpctx
->opts
;
393 char *chapter_name
= NULL
;
396 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
398 return M_PROPERTY_UNAVAILABLE
;
403 return M_PROPERTY_ERROR
;
404 *(int *) arg
= chapter
;
405 return M_PROPERTY_OK
;
406 case M_PROPERTY_PRINT
: {
408 return M_PROPERTY_ERROR
;
409 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
411 return M_PROPERTY_UNAVAILABLE
;
412 *(char **) arg
= chapter_name
;
413 return M_PROPERTY_OK
;
417 return M_PROPERTY_ERROR
;
418 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
419 step_all
= *(int *)arg
- (chapter
+ 1);
422 case M_PROPERTY_STEP_UP
:
423 case M_PROPERTY_STEP_DOWN
: {
424 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
425 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
432 return M_PROPERTY_NOT_IMPLEMENTED
;
434 mpctx
->rel_seek_secs
= 0;
435 mpctx
->abs_seek_pos
= 0;
436 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
437 &next_pts
, &chapter_num
, &chapter_name
);
439 if (next_pts
> -1.0) {
440 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
441 mpctx
->rel_seek_secs
= next_pts
;
444 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
445 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
447 else if (step_all
> 0)
448 mpctx
->rel_seek_secs
= 1000000000.;
450 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
451 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
454 return M_PROPERTY_OK
;
457 /// Number of chapters in file
458 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
462 return M_PROPERTY_UNAVAILABLE
;
463 if (mpctx
->demuxer
->num_chapters
== 0)
464 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
465 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
468 /// Current dvd angle (RW)
469 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
472 struct MPOpts
*opts
= &mpctx
->opts
;
475 char *angle_name
= NULL
;
478 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
480 return M_PROPERTY_UNAVAILABLE
;
481 angles
= demuxer_angles_count(mpctx
->demuxer
);
483 return M_PROPERTY_UNAVAILABLE
;
488 return M_PROPERTY_ERROR
;
489 *(int *) arg
= angle
;
490 return M_PROPERTY_OK
;
491 case M_PROPERTY_PRINT
: {
493 return M_PROPERTY_ERROR
;
494 angle_name
= calloc(1, 64);
496 return M_PROPERTY_UNAVAILABLE
;
497 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
498 *(char **) arg
= angle_name
;
499 return M_PROPERTY_OK
;
503 return M_PROPERTY_ERROR
;
505 M_PROPERTY_CLAMP(prop
, angle
);
507 case M_PROPERTY_STEP_UP
:
508 case M_PROPERTY_STEP_DOWN
: {
514 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
516 if (angle
< 1) //cycle
521 return M_PROPERTY_NOT_IMPLEMENTED
;
523 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
524 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
525 MSGTR_OSDAngle
, angle
, angles
);
528 return M_PROPERTY_OK
;
531 /// Demuxer meta data
532 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
534 m_property_action_t
* ka
;
536 static const m_option_t key_type
=
537 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
539 return M_PROPERTY_UNAVAILABLE
;
543 if(!arg
) return M_PROPERTY_ERROR
;
544 *(char***)arg
= mpctx
->demuxer
->info
;
545 return M_PROPERTY_OK
;
546 case M_PROPERTY_KEY_ACTION
:
547 if(!arg
) return M_PROPERTY_ERROR
;
549 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
550 return M_PROPERTY_UNKNOWN
;
553 if(!ka
->arg
) return M_PROPERTY_ERROR
;
554 *(char**)ka
->arg
= meta
;
555 return M_PROPERTY_OK
;
556 case M_PROPERTY_GET_TYPE
:
557 if(!ka
->arg
) return M_PROPERTY_ERROR
;
558 *(m_option_t
**)ka
->arg
= &key_type
;
559 return M_PROPERTY_OK
;
562 return M_PROPERTY_NOT_IMPLEMENTED
;
565 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
568 MPContext
*mpctx
= ctx
;
573 return M_PROPERTY_ERROR
;
574 if (mpctx
->paused
== (bool)*(int *) arg
)
575 return M_PROPERTY_OK
;
576 case M_PROPERTY_STEP_UP
:
577 case M_PROPERTY_STEP_DOWN
:
579 unpause_player(mpctx
);
580 mpctx
->osd_function
= OSD_PLAY
;
584 mpctx
->osd_function
= OSD_PAUSE
;
586 return M_PROPERTY_OK
;
588 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
595 /// \defgroup AudioProperties Audio properties
596 /// \ingroup Properties
600 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
604 if (!mpctx
->sh_audio
)
605 return M_PROPERTY_UNAVAILABLE
;
610 return M_PROPERTY_ERROR
;
611 mixer_getbothvolume(&mpctx
->mixer
, arg
);
612 return M_PROPERTY_OK
;
613 case M_PROPERTY_PRINT
:{
616 return M_PROPERTY_ERROR
;
617 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
618 return m_property_float_range(prop
, action
, arg
, &vol
);
620 case M_PROPERTY_STEP_UP
:
621 case M_PROPERTY_STEP_DOWN
:
625 return M_PROPERTY_NOT_IMPLEMENTED
;
628 if (mpctx
->edl_muted
)
629 return M_PROPERTY_DISABLED
;
630 mpctx
->user_muted
= 0;
635 return M_PROPERTY_ERROR
;
636 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
637 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
638 return M_PROPERTY_OK
;
639 case M_PROPERTY_STEP_UP
:
640 if (arg
&& *(float *) arg
<= 0)
641 mixer_decvolume(&mpctx
->mixer
);
643 mixer_incvolume(&mpctx
->mixer
);
644 return M_PROPERTY_OK
;
645 case M_PROPERTY_STEP_DOWN
:
646 if (arg
&& *(float *) arg
<= 0)
647 mixer_incvolume(&mpctx
->mixer
);
649 mixer_decvolume(&mpctx
->mixer
);
650 return M_PROPERTY_OK
;
652 return M_PROPERTY_NOT_IMPLEMENTED
;
656 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
660 if (!mpctx
->sh_audio
)
661 return M_PROPERTY_UNAVAILABLE
;
665 if (mpctx
->edl_muted
)
666 return M_PROPERTY_DISABLED
;
668 return M_PROPERTY_ERROR
;
669 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
670 mixer_mute(&mpctx
->mixer
);
671 mpctx
->user_muted
= mpctx
->mixer
.muted
;
672 return M_PROPERTY_OK
;
673 case M_PROPERTY_STEP_UP
:
674 case M_PROPERTY_STEP_DOWN
:
675 if (mpctx
->edl_muted
)
676 return M_PROPERTY_DISABLED
;
677 mixer_mute(&mpctx
->mixer
);
678 mpctx
->user_muted
= mpctx
->mixer
.muted
;
679 return M_PROPERTY_OK
;
680 case M_PROPERTY_PRINT
:
682 return M_PROPERTY_ERROR
;
683 if (mpctx
->edl_muted
) {
684 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
685 return M_PROPERTY_OK
;
688 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
694 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
695 void *arg
, MPContext
*mpctx
)
697 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
698 return M_PROPERTY_UNAVAILABLE
;
701 case M_PROPERTY_STEP_UP
:
702 case M_PROPERTY_STEP_DOWN
: {
704 float delay
= audio_delay
;
705 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
706 if (ret
!= M_PROPERTY_OK
)
709 mpctx
->delay
-= audio_delay
- delay
;
711 return M_PROPERTY_OK
;
713 return m_property_delay(prop
, action
, arg
, &audio_delay
);
717 /// Audio codec tag (RO)
718 static int mp_property_audio_format(m_option_t
*prop
, int action
,
719 void *arg
, MPContext
*mpctx
)
721 if (!mpctx
->sh_audio
)
722 return M_PROPERTY_UNAVAILABLE
;
723 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
726 /// Audio codec name (RO)
727 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
728 void *arg
, MPContext
*mpctx
)
730 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
731 return M_PROPERTY_UNAVAILABLE
;
732 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
735 /// Audio bitrate (RO)
736 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
737 void *arg
, MPContext
*mpctx
)
739 if (!mpctx
->sh_audio
)
740 return M_PROPERTY_UNAVAILABLE
;
741 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
745 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
748 if (!mpctx
->sh_audio
)
749 return M_PROPERTY_UNAVAILABLE
;
751 case M_PROPERTY_PRINT
:
752 if(!arg
) return M_PROPERTY_ERROR
;
753 *(char**)arg
= malloc(16);
754 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
755 return M_PROPERTY_OK
;
757 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
760 /// Number of channels (RO)
761 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
764 if (!mpctx
->sh_audio
)
765 return M_PROPERTY_UNAVAILABLE
;
767 case M_PROPERTY_PRINT
:
769 return M_PROPERTY_ERROR
;
770 switch (mpctx
->sh_audio
->channels
) {
772 *(char **) arg
= strdup("mono");
775 *(char **) arg
= strdup("stereo");
778 *(char **) arg
= malloc(32);
779 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
781 return M_PROPERTY_OK
;
783 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
787 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
792 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
793 return M_PROPERTY_UNAVAILABLE
;
798 return M_PROPERTY_ERROR
;
799 mixer_getbalance(&mpctx
->mixer
, arg
);
800 return M_PROPERTY_OK
;
801 case M_PROPERTY_PRINT
: {
804 return M_PROPERTY_ERROR
;
805 mixer_getbalance(&mpctx
->mixer
, &bal
);
807 *str
= strdup("center");
808 else if (bal
== -1.f
)
809 *str
= strdup("left only");
811 *str
= strdup("right only");
813 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
814 *str
= malloc(sizeof("left xxx%, right xxx%"));
815 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
817 return M_PROPERTY_OK
;
819 case M_PROPERTY_STEP_UP
:
820 case M_PROPERTY_STEP_DOWN
:
821 mixer_getbalance(&mpctx
->mixer
, &bal
);
822 bal
+= (arg
? *(float*)arg
: .1f
) *
823 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
824 M_PROPERTY_CLAMP(prop
, bal
);
825 mixer_setbalance(&mpctx
->mixer
, bal
);
826 return M_PROPERTY_OK
;
829 return M_PROPERTY_ERROR
;
830 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
831 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
832 return M_PROPERTY_OK
;
834 return M_PROPERTY_NOT_IMPLEMENTED
;
837 /// Selected audio id (RW)
838 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
841 struct MPOpts
*opts
= &mpctx
->opts
;
842 int current_id
= -1, tmp
;
846 if (!mpctx
->sh_audio
)
847 return M_PROPERTY_UNAVAILABLE
;
849 return M_PROPERTY_ERROR
;
850 *(int *) arg
= opts
->audio_id
;
851 return M_PROPERTY_OK
;
852 case M_PROPERTY_PRINT
:
853 if (!mpctx
->sh_audio
)
854 return M_PROPERTY_UNAVAILABLE
;
856 return M_PROPERTY_ERROR
;
858 if (opts
->audio_id
< 0)
859 *(char **) arg
= strdup(MSGTR_Disabled
);
861 char lang
[40] = MSGTR_Unknown
;
862 sh_audio_t
* sh
= mpctx
->sh_audio
;
864 av_strlcpy(lang
, sh
->lang
, 40);
865 #ifdef CONFIG_DVDREAD
866 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
867 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
877 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
878 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
880 *(char **) arg
= malloc(64);
881 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
883 return M_PROPERTY_OK
;
885 case M_PROPERTY_STEP_UP
:
888 return M_PROPERTY_UNAVAILABLE
;
889 if (action
== M_PROPERTY_SET
&& arg
)
890 tmp
= *((int *) arg
);
893 current_id
= mpctx
->demuxer
->audio
->id
;
894 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
895 if (opts
->audio_id
== -2
896 || (opts
->audio_id
> -1
897 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
898 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
899 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
901 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
903 sh2
->ds
= mpctx
->demuxer
->audio
;
904 mpctx
->sh_audio
= sh2
;
905 reinit_audio_chain(mpctx
);
908 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
909 return M_PROPERTY_OK
;
911 return M_PROPERTY_NOT_IMPLEMENTED
;
916 /// Selected video id (RW)
917 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
920 struct MPOpts
*opts
= &mpctx
->opts
;
921 int current_id
= -1, tmp
;
925 if (!mpctx
->sh_video
)
926 return M_PROPERTY_UNAVAILABLE
;
928 return M_PROPERTY_ERROR
;
929 *(int *) arg
= opts
->video_id
;
930 return M_PROPERTY_OK
;
931 case M_PROPERTY_PRINT
:
932 if (!mpctx
->sh_video
)
933 return M_PROPERTY_UNAVAILABLE
;
935 return M_PROPERTY_ERROR
;
937 if (opts
->video_id
< 0)
938 *(char **) arg
= strdup(MSGTR_Disabled
);
940 char lang
[40] = MSGTR_Unknown
;
941 *(char **) arg
= malloc(64);
942 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
944 return M_PROPERTY_OK
;
946 case M_PROPERTY_STEP_UP
:
948 current_id
= mpctx
->demuxer
->video
->id
;
949 if (action
== M_PROPERTY_SET
&& arg
)
950 tmp
= *((int *) arg
);
953 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
954 if (opts
->video_id
== -2
955 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
956 && current_id
!= -2))
957 uninit_player(mpctx
, INITIALIZED_VCODEC
|
958 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
959 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
961 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
963 sh2
->ds
= mpctx
->demuxer
->video
;
964 mpctx
->sh_video
= sh2
;
965 reinit_video_chain(mpctx
);
968 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
969 return M_PROPERTY_OK
;
972 return M_PROPERTY_NOT_IMPLEMENTED
;
976 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
979 demux_program_t prog
;
982 case M_PROPERTY_STEP_UP
:
984 if (action
== M_PROPERTY_SET
&& arg
)
985 prog
.progid
= *((int *) arg
);
989 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
990 &prog
) == DEMUXER_CTRL_NOTIMPL
)
991 return M_PROPERTY_ERROR
;
993 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
994 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
995 return M_PROPERTY_OK
;
998 return M_PROPERTY_NOT_IMPLEMENTED
;
1004 /// \defgroup VideoProperties Video properties
1005 /// \ingroup Properties
1008 /// Fullscreen state (RW)
1009 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1013 if (!mpctx
->video_out
)
1014 return M_PROPERTY_UNAVAILABLE
;
1017 case M_PROPERTY_SET
:
1019 return M_PROPERTY_ERROR
;
1020 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1021 if (vo_fs
== !!*(int *) arg
)
1022 return M_PROPERTY_OK
;
1023 case M_PROPERTY_STEP_UP
:
1024 case M_PROPERTY_STEP_DOWN
:
1027 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
1030 if (mpctx
->video_out
->config_ok
)
1031 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1032 mpctx
->opts
.fullscreen
= vo_fs
;
1033 return M_PROPERTY_OK
;
1035 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1039 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1040 void *arg
, MPContext
*mpctx
)
1044 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1045 return M_PROPERTY_UNAVAILABLE
;
1046 vf
= mpctx
->sh_video
->vfilter
;
1048 case M_PROPERTY_GET
:
1050 return M_PROPERTY_ERROR
;
1051 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1052 return M_PROPERTY_OK
;
1053 case M_PROPERTY_SET
:
1055 return M_PROPERTY_ERROR
;
1056 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1057 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1058 return M_PROPERTY_OK
;
1059 case M_PROPERTY_STEP_UP
:
1060 case M_PROPERTY_STEP_DOWN
:
1061 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1062 deinterlace
= !deinterlace
;
1063 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1064 return M_PROPERTY_OK
;
1066 return M_PROPERTY_NOT_IMPLEMENTED
;
1070 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1074 if (!mpctx
->video_out
1075 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1076 return M_PROPERTY_UNAVAILABLE
;
1079 case M_PROPERTY_SET
:
1081 return M_PROPERTY_ERROR
;
1082 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1083 vo_panscan
= *(float *) arg
;
1084 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1085 return M_PROPERTY_OK
;
1086 case M_PROPERTY_STEP_UP
:
1087 case M_PROPERTY_STEP_DOWN
:
1088 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1089 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1092 else if (vo_panscan
< 0)
1094 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1095 return M_PROPERTY_OK
;
1097 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1101 /// Helper to set vo flags.
1102 /** \ingroup PropertyImplHelper
1104 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1105 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1108 if (!mpctx
->video_out
)
1109 return M_PROPERTY_UNAVAILABLE
;
1112 case M_PROPERTY_SET
:
1114 return M_PROPERTY_ERROR
;
1115 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1116 if (*vo_var
== !!*(int *) arg
)
1117 return M_PROPERTY_OK
;
1118 case M_PROPERTY_STEP_UP
:
1119 case M_PROPERTY_STEP_DOWN
:
1120 if (mpctx
->video_out
->config_ok
)
1121 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1122 return M_PROPERTY_OK
;
1124 return m_property_flag(prop
, action
, arg
, vo_var
);
1128 /// Window always on top (RW)
1129 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1132 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1133 &mpctx
->opts
.vo_ontop
, mpctx
);
1136 /// Display in the root window (RW)
1137 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1140 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1141 &vo_rootwin
, mpctx
);
1144 /// Show window borders (RW)
1145 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1148 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1152 /// Framedropping state (RW)
1153 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1154 void *arg
, MPContext
*mpctx
)
1157 if (!mpctx
->sh_video
)
1158 return M_PROPERTY_UNAVAILABLE
;
1161 case M_PROPERTY_PRINT
:
1163 return M_PROPERTY_ERROR
;
1164 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1165 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1167 return M_PROPERTY_OK
;
1169 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1173 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1174 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1177 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1180 if (!mpctx
->sh_video
)
1181 return M_PROPERTY_UNAVAILABLE
;
1183 if (gamma
[0] == 1000) {
1185 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1189 case M_PROPERTY_SET
:
1191 return M_PROPERTY_ERROR
;
1192 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1193 *gamma
= *(int *) arg
;
1194 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1198 case M_PROPERTY_GET
:
1199 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1201 return M_PROPERTY_ERROR
;
1203 return M_PROPERTY_OK
;
1206 case M_PROPERTY_STEP_UP
:
1207 case M_PROPERTY_STEP_DOWN
:
1208 *gamma
+= (arg
? *(int *) arg
: 1) *
1209 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1210 M_PROPERTY_CLAMP(prop
, *gamma
);
1211 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1216 return M_PROPERTY_NOT_IMPLEMENTED
;
1220 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1221 int l
= strlen(prop
->name
);
1222 char tv_prop
[3 + l
+ 1];
1223 sprintf(tv_prop
, "tv_%s", prop
->name
);
1224 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1228 return M_PROPERTY_UNAVAILABLE
;
1232 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1235 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1238 /// Video codec tag (RO)
1239 static int mp_property_video_format(m_option_t
*prop
, int action
,
1240 void *arg
, MPContext
*mpctx
)
1243 if (!mpctx
->sh_video
)
1244 return M_PROPERTY_UNAVAILABLE
;
1246 case M_PROPERTY_PRINT
:
1248 return M_PROPERTY_ERROR
;
1249 switch(mpctx
->sh_video
->format
) {
1251 meta
= strdup ("mpeg1"); break;
1253 meta
= strdup ("mpeg2"); break;
1255 meta
= strdup ("mpeg4"); break;
1257 meta
= strdup ("h264"); break;
1259 if(mpctx
->sh_video
->format
>= 0x20202020) {
1261 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1264 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1267 *(char**)arg
= meta
;
1268 return M_PROPERTY_OK
;
1270 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1273 /// Video codec name (RO)
1274 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1275 void *arg
, MPContext
*mpctx
)
1277 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1278 return M_PROPERTY_UNAVAILABLE
;
1279 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1283 /// Video bitrate (RO)
1284 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1285 void *arg
, MPContext
*mpctx
)
1287 if (!mpctx
->sh_video
)
1288 return M_PROPERTY_UNAVAILABLE
;
1289 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1292 /// Video display width (RO)
1293 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1296 if (!mpctx
->sh_video
)
1297 return M_PROPERTY_UNAVAILABLE
;
1298 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1301 /// Video display height (RO)
1302 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1305 if (!mpctx
->sh_video
)
1306 return M_PROPERTY_UNAVAILABLE
;
1307 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1311 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1314 if (!mpctx
->sh_video
)
1315 return M_PROPERTY_UNAVAILABLE
;
1316 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1319 /// Video aspect (RO)
1320 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1323 if (!mpctx
->sh_video
)
1324 return M_PROPERTY_UNAVAILABLE
;
1325 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1330 /// \defgroup SubProprties Subtitles properties
1331 /// \ingroup Properties
1334 /// Text subtitle position (RW)
1335 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1338 if (!mpctx
->sh_video
)
1339 return M_PROPERTY_UNAVAILABLE
;
1342 case M_PROPERTY_SET
:
1344 return M_PROPERTY_ERROR
;
1345 case M_PROPERTY_STEP_UP
:
1346 case M_PROPERTY_STEP_DOWN
:
1347 vo_osd_changed(OSDTYPE_SUBTITLE
);
1349 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1353 /// Selected subtitles (RW)
1354 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1357 struct MPOpts
*opts
= &mpctx
->opts
;
1358 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1359 const int global_sub_size
= mpctx
->global_sub_size
;
1360 int source
= -1, reset_spu
= 0;
1363 if (global_sub_size
<= 0)
1364 return M_PROPERTY_UNAVAILABLE
;
1367 case M_PROPERTY_GET
:
1369 return M_PROPERTY_ERROR
;
1370 *(int *) arg
= mpctx
->global_sub_pos
;
1371 return M_PROPERTY_OK
;
1372 case M_PROPERTY_PRINT
:
1374 return M_PROPERTY_ERROR
;
1375 *(char **) arg
= malloc(64);
1376 (*(char **) arg
)[63] = 0;
1379 sub_name
= subdata
->filename
;
1381 if (ass_track
&& ass_track
->name
)
1382 sub_name
= ass_track
->name
;
1387 if ((tmp2
= strrchr(tmp
, '/')))
1390 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1391 mpctx
->set_of_sub_pos
+ 1,
1392 strlen(tmp
) < 20 ? "" : "...",
1393 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1394 return M_PROPERTY_OK
;
1396 #ifdef CONFIG_DVDNAV
1397 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1398 if (vo_spudec
&& opts
->sub_id
>= 0) {
1399 unsigned char lang
[3];
1400 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1401 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1402 return M_PROPERTY_OK
;
1408 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1409 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1410 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1411 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1412 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1413 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1414 if (!lang
) lang
= MSGTR_Unknown
;
1415 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1416 return M_PROPERTY_OK
;
1419 if (vo_vobsub
&& vobsub_id
>= 0) {
1420 const char *language
= MSGTR_Unknown
;
1421 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1422 snprintf(*(char **) arg
, 63, "(%d) %s",
1423 vobsub_id
, language
? language
: MSGTR_Unknown
);
1424 return M_PROPERTY_OK
;
1426 #ifdef CONFIG_DVDREAD
1427 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1428 && opts
->sub_id
>= 0) {
1430 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1431 lang
[0] = code
>> 8;
1434 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1435 return M_PROPERTY_OK
;
1438 if (opts
->sub_id
>= 0) {
1439 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, MSGTR_Unknown
);
1440 return M_PROPERTY_OK
;
1442 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1443 return M_PROPERTY_OK
;
1445 case M_PROPERTY_SET
:
1447 return M_PROPERTY_ERROR
;
1448 if (*(int *) arg
< -1)
1450 else if (*(int *) arg
>= global_sub_size
)
1451 *(int *) arg
= global_sub_size
- 1;
1452 mpctx
->global_sub_pos
= *(int *) arg
;
1454 case M_PROPERTY_STEP_UP
:
1455 mpctx
->global_sub_pos
+= 2;
1456 mpctx
->global_sub_pos
=
1457 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1459 case M_PROPERTY_STEP_DOWN
:
1460 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1461 mpctx
->global_sub_pos
=
1462 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1465 return M_PROPERTY_NOT_IMPLEMENTED
;
1468 if (mpctx
->global_sub_pos
>= 0)
1469 source
= sub_source(mpctx
);
1471 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1472 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1474 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1475 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1476 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1477 mpctx
->global_sub_pos
, source
);
1479 mpctx
->set_of_sub_pos
= -1;
1493 if (source
== SUB_SOURCE_VOBSUB
) {
1494 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1495 } else if (source
== SUB_SOURCE_SUBS
) {
1496 mpctx
->set_of_sub_pos
=
1497 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1499 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1500 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1504 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1505 vo_osd_changed(OSDTYPE_SUBTITLE
);
1507 } else if (source
== SUB_SOURCE_DEMUX
) {
1509 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1510 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1512 // default: assume 1:1 mapping of sid and stream id
1513 d_sub
->id
= opts
->sub_id
;
1514 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1515 ds_free_packs(d_sub
);
1516 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1517 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1518 if (sh
&& sh
->sid
== opts
->sub_id
) {
1524 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1525 sh_sub_t
*sh
= d_sub
->sh
;
1526 if (sh
->type
== 'v')
1527 init_vo_spudec(mpctx
);
1529 else if (ass_enabled
)
1530 ass_track
= sh
->ass_track
;
1538 #ifdef CONFIG_DVDREAD
1540 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1541 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1542 && opts
->sub_id
< 0 && reset_spu
) {
1544 d_sub
->id
= opts
->sub_id
;
1547 update_subtitles(mpctx
->sh_video
, d_sub
, 0, 1);
1549 return M_PROPERTY_OK
;
1552 /// Selected sub source (RW)
1553 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1557 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1558 return M_PROPERTY_UNAVAILABLE
;
1561 case M_PROPERTY_GET
:
1563 return M_PROPERTY_ERROR
;
1564 *(int *) arg
= sub_source(mpctx
);
1565 return M_PROPERTY_OK
;
1566 case M_PROPERTY_PRINT
:
1568 return M_PROPERTY_ERROR
;
1569 *(char **) arg
= malloc(64);
1570 (*(char **) arg
)[63] = 0;
1571 switch (sub_source(mpctx
))
1573 case SUB_SOURCE_SUBS
:
1574 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1576 case SUB_SOURCE_VOBSUB
:
1577 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1579 case SUB_SOURCE_DEMUX
:
1580 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1583 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1585 return M_PROPERTY_OK
;
1586 case M_PROPERTY_SET
:
1588 return M_PROPERTY_ERROR
;
1589 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1590 if (*(int *) arg
< 0)
1591 mpctx
->global_sub_pos
= -1;
1592 else if (*(int *) arg
!= sub_source(mpctx
)) {
1593 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1594 return M_PROPERTY_UNAVAILABLE
;
1595 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1598 case M_PROPERTY_STEP_UP
:
1599 case M_PROPERTY_STEP_DOWN
: {
1600 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1601 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1602 int step
= (step_all
> 0) ? 1 : -1;
1603 int cur_source
= sub_source(mpctx
);
1604 source
= cur_source
;
1607 if (source
>= SUB_SOURCES
)
1609 else if (source
< -1)
1610 source
= SUB_SOURCES
- 1;
1611 if (source
== cur_source
|| source
== -1 ||
1612 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1615 if (source
== cur_source
)
1616 return M_PROPERTY_OK
;
1618 mpctx
->global_sub_pos
= -1;
1620 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1624 return M_PROPERTY_NOT_IMPLEMENTED
;
1626 --mpctx
->global_sub_pos
;
1627 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1630 /// Selected subtitles from specific source (RW)
1631 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1634 int source
, is_cur_source
, offset
;
1635 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1636 return M_PROPERTY_UNAVAILABLE
;
1638 if (!strcmp(prop
->name
, "sub_file"))
1639 source
= SUB_SOURCE_SUBS
;
1640 else if (!strcmp(prop
->name
, "sub_vob"))
1641 source
= SUB_SOURCE_VOBSUB
;
1642 else if (!strcmp(prop
->name
, "sub_demux"))
1643 source
= SUB_SOURCE_DEMUX
;
1645 return M_PROPERTY_ERROR
;
1647 offset
= mpctx
->global_sub_indices
[source
];
1648 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1649 return M_PROPERTY_UNAVAILABLE
;
1651 is_cur_source
= sub_source(mpctx
) == source
;
1653 case M_PROPERTY_GET
:
1655 return M_PROPERTY_ERROR
;
1656 if (is_cur_source
) {
1657 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1658 if (source
== SUB_SOURCE_VOBSUB
)
1659 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1663 return M_PROPERTY_OK
;
1664 case M_PROPERTY_PRINT
:
1666 return M_PROPERTY_ERROR
;
1668 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1669 *(char **) arg
= malloc(64);
1670 (*(char **) arg
)[63] = 0;
1671 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1672 return M_PROPERTY_OK
;
1673 case M_PROPERTY_SET
:
1675 return M_PROPERTY_ERROR
;
1676 if (*(int *) arg
>= 0) {
1677 int index
= *(int *)arg
;
1678 if (source
== SUB_SOURCE_VOBSUB
)
1679 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1680 mpctx
->global_sub_pos
= offset
+ index
;
1681 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1682 || sub_source(mpctx
) != source
) {
1683 mpctx
->global_sub_pos
= -1;
1688 mpctx
->global_sub_pos
= -1;
1690 case M_PROPERTY_STEP_UP
:
1691 case M_PROPERTY_STEP_DOWN
: {
1692 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1693 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1694 int step
= (step_all
> 0) ? 1 : -1;
1695 int max_sub_pos_for_source
= -1;
1697 mpctx
->global_sub_pos
= -1;
1699 if (mpctx
->global_sub_pos
== -1) {
1701 mpctx
->global_sub_pos
= offset
;
1702 else if (max_sub_pos_for_source
== -1) {
1703 // Find max pos for specific source
1704 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1705 while (mpctx
->global_sub_pos
>= 0
1706 && sub_source(mpctx
) != source
)
1707 --mpctx
->global_sub_pos
;
1710 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1713 mpctx
->global_sub_pos
+= step
;
1714 if (mpctx
->global_sub_pos
< offset
||
1715 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1716 sub_source(mpctx
) != source
)
1717 mpctx
->global_sub_pos
= -1;
1724 return M_PROPERTY_NOT_IMPLEMENTED
;
1726 --mpctx
->global_sub_pos
;
1727 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1730 /// Subtitle delay (RW)
1731 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1734 if (!mpctx
->sh_video
)
1735 return M_PROPERTY_UNAVAILABLE
;
1736 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1739 /// Alignment of text subtitles (RW)
1740 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1741 void *arg
, MPContext
*mpctx
)
1743 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1745 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1746 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1747 return M_PROPERTY_UNAVAILABLE
;
1750 case M_PROPERTY_PRINT
:
1752 return M_PROPERTY_ERROR
;
1753 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1754 *(char **) arg
= strdup(name
[sub_alignment
]);
1755 return M_PROPERTY_OK
;
1756 case M_PROPERTY_SET
:
1758 return M_PROPERTY_ERROR
;
1759 case M_PROPERTY_STEP_UP
:
1760 case M_PROPERTY_STEP_DOWN
:
1761 vo_osd_changed(OSDTYPE_SUBTITLE
);
1763 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1767 /// Subtitle visibility (RW)
1768 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1769 void *arg
, MPContext
*mpctx
)
1771 if (!mpctx
->sh_video
)
1772 return M_PROPERTY_UNAVAILABLE
;
1775 case M_PROPERTY_SET
:
1777 return M_PROPERTY_ERROR
;
1778 case M_PROPERTY_STEP_UP
:
1779 case M_PROPERTY_STEP_DOWN
:
1780 vo_osd_changed(OSDTYPE_SUBTITLE
);
1782 vo_osd_changed(OSDTYPE_SPU
);
1784 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1789 /// Use margins for libass subtitles (RW)
1790 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1791 void *arg
, MPContext
*mpctx
)
1793 if (!mpctx
->sh_video
)
1794 return M_PROPERTY_UNAVAILABLE
;
1797 case M_PROPERTY_SET
:
1799 return M_PROPERTY_ERROR
;
1800 case M_PROPERTY_STEP_UP
:
1801 case M_PROPERTY_STEP_DOWN
:
1802 ass_force_reload
= 1;
1804 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1809 /// Show only forced subtitles (RW)
1810 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1811 void *arg
, MPContext
*mpctx
)
1814 return M_PROPERTY_UNAVAILABLE
;
1817 case M_PROPERTY_SET
:
1819 return M_PROPERTY_ERROR
;
1820 case M_PROPERTY_STEP_UP
:
1821 case M_PROPERTY_STEP_DOWN
:
1822 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1823 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1824 return M_PROPERTY_OK
;
1826 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1831 #ifdef CONFIG_FREETYPE
1832 /// Subtitle scale (RW)
1833 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1838 case M_PROPERTY_SET
:
1840 return M_PROPERTY_ERROR
;
1841 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1844 ass_font_scale
= *(float *) arg
;
1845 ass_force_reload
= 1;
1848 text_font_scale_factor
= *(float *) arg
;
1849 force_load_font
= 1;
1850 return M_PROPERTY_OK
;
1851 case M_PROPERTY_STEP_UP
:
1852 case M_PROPERTY_STEP_DOWN
:
1855 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1856 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1857 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1858 ass_force_reload
= 1;
1861 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1862 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1863 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1864 force_load_font
= 1;
1865 return M_PROPERTY_OK
;
1869 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1872 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1879 /// \defgroup TVProperties TV properties
1880 /// \ingroup Properties
1885 /// TV color settings (RW)
1886 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1890 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1891 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1892 return M_PROPERTY_UNAVAILABLE
;
1895 case M_PROPERTY_SET
:
1897 return M_PROPERTY_ERROR
;
1898 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1899 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1900 case M_PROPERTY_GET
:
1901 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1902 case M_PROPERTY_STEP_UP
:
1903 case M_PROPERTY_STEP_DOWN
:
1904 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1906 return M_PROPERTY_ERROR
;
1907 val
+= (arg
? *(int *) arg
: 1) *
1908 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1909 M_PROPERTY_CLAMP(prop
, val
);
1910 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1912 return M_PROPERTY_ERROR
;
1914 return M_PROPERTY_NOT_IMPLEMENTED
;
1919 #ifdef CONFIG_TV_TELETEXT
1920 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1924 int base_ioctl
=(int)prop
->priv
;
1926 for teletext's GET,SET,STEP ioctls this is not 0
1930 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1931 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1932 return M_PROPERTY_UNAVAILABLE
;
1934 return M_PROPERTY_ERROR
;
1937 case M_PROPERTY_GET
:
1939 return M_PROPERTY_ERROR
;
1940 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1942 case M_PROPERTY_SET
:
1944 return M_PROPERTY_ERROR
;
1945 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1946 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1948 case M_PROPERTY_STEP_UP
:
1949 case M_PROPERTY_STEP_DOWN
:
1950 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1951 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1952 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1955 return M_PROPERTY_NOT_IMPLEMENTED
;
1958 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1961 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1964 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1968 //with tvh==NULL will fail too
1969 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1970 if(result
!=M_PROPERTY_OK
)
1973 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1974 mp_input_set_section(mpctx
->input
, "teletext");
1976 mp_input_set_section(mpctx
->input
, "tv");
1977 return M_PROPERTY_OK
;
1980 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1983 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1986 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1987 return M_PROPERTY_UNAVAILABLE
;
1989 case M_PROPERTY_STEP_UP
:
1990 case M_PROPERTY_STEP_DOWN
:
1991 //This should be handled separately
1992 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1993 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1996 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2002 #endif /* CONFIG_TV_TELETEXT */
2006 /// All properties available in MPlayer.
2007 /** \ingroup Properties
2009 static const m_option_t mp_properties
[] = {
2011 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2012 M_OPT_RANGE
, 0, 3, NULL
},
2013 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2014 M_OPT_MIN
, -1, 0, NULL
},
2015 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2016 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2017 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2019 { "path", mp_property_path
, CONF_TYPE_STRING
,
2021 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2023 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2024 M_OPT_MIN
, 0, 0, NULL
},
2025 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2026 M_OPT_MIN
, 0, 0, NULL
},
2027 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2028 M_OPT_MIN
, 0, 0, NULL
},
2029 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2030 M_OPT_MIN
, 0, 0, NULL
},
2031 { "length", mp_property_length
, CONF_TYPE_TIME
,
2032 M_OPT_MIN
, 0, 0, NULL
},
2033 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2034 M_OPT_RANGE
, 0, 100, NULL
},
2035 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2036 M_OPT_MIN
, 0, 0, NULL
},
2037 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2038 M_OPT_MIN
, 1, 0, NULL
},
2039 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2041 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2042 CONF_RANGE
, -2, 10, NULL
},
2043 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2045 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2046 M_OPT_RANGE
, 0, 1, NULL
},
2049 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2050 M_OPT_RANGE
, 0, 100, NULL
},
2051 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2052 M_OPT_RANGE
, 0, 1, NULL
},
2053 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2054 M_OPT_RANGE
, -100, 100, NULL
},
2055 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2057 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2059 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2061 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2063 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2065 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2066 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2067 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2068 M_OPT_RANGE
, -1, 1, NULL
},
2071 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2072 M_OPT_RANGE
, 0, 1, NULL
},
2073 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2074 M_OPT_RANGE
, 0, 1, NULL
},
2075 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2076 M_OPT_RANGE
, 0, 1, NULL
},
2077 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2078 M_OPT_RANGE
, 0, 1, NULL
},
2079 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2080 M_OPT_RANGE
, 0, 1, NULL
},
2081 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2082 M_OPT_RANGE
, 0, 2, NULL
},
2083 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2084 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2085 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2086 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2087 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2088 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2089 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2090 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2091 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2092 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2093 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2094 M_OPT_RANGE
, 0, 1, NULL
},
2095 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2096 M_OPT_RANGE
, 0, 1, NULL
},
2097 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2099 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2101 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2103 { "width", mp_property_width
, CONF_TYPE_INT
,
2105 { "height", mp_property_height
, CONF_TYPE_INT
,
2107 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2109 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2111 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2112 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2113 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2114 CONF_RANGE
, -1, 65535, NULL
},
2117 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2118 M_OPT_MIN
, -1, 0, NULL
},
2119 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2120 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2121 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2122 M_OPT_MIN
, -1, 0, NULL
},
2123 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2124 M_OPT_MIN
, -1, 0, NULL
},
2125 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2126 M_OPT_MIN
, -1, 0, NULL
},
2127 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2129 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2130 M_OPT_RANGE
, 0, 100, NULL
},
2131 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2132 M_OPT_RANGE
, 0, 2, NULL
},
2133 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2134 M_OPT_RANGE
, 0, 1, NULL
},
2135 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2136 M_OPT_RANGE
, 0, 1, NULL
},
2137 #ifdef CONFIG_FREETYPE
2138 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2139 M_OPT_RANGE
, 0, 100, NULL
},
2142 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2143 M_OPT_RANGE
, 0, 1, NULL
},
2147 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2148 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2149 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2150 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2151 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2152 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2153 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2154 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2157 #ifdef CONFIG_TV_TELETEXT
2158 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2159 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2160 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2161 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2162 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2163 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2164 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2165 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2166 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2167 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2170 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2174 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2176 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2179 char* mp_property_print(const char *name
, void* ctx
)
2182 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2187 char *property_expand_string(MPContext
*mpctx
, char *str
)
2189 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2192 void property_print_help(void)
2194 m_properties_print_help_list(mp_properties
);
2203 * \defgroup Command2Property Command to property bridge
2205 * It is used to handle most commands that just set a property
2206 * and optionally display something on the OSD.
2207 * Two kinds of commands are handled: adjust or toggle.
2209 * Adjust commands take 1 or 2 parameters: <value> <abs>
2210 * If <abs> is non-zero the property is set to the given value
2211 * otherwise it is adjusted.
2213 * Toggle commands take 0 or 1 parameters. With no parameter
2214 * or a value less than the property minimum it just steps the
2215 * property to its next value. Otherwise it sets it to the given
2221 /// List of the commands that can be handled by setting a property.
2227 /// set/adjust or toggle command
2229 /// progressbar type
2230 int osd_progbar
; // -1 is special value for seek indicators
2231 /// osd msg id if it must be shared
2233 /// osd msg template
2234 const char *osd_msg
;
2235 } set_prop_cmd
[] = {
2237 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2238 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, -1, -1, NULL
},
2239 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2240 { "pause", MP_CMD_PAUSE
, 0, 0, -1, NULL
},
2242 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2243 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2244 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2245 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2246 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2248 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2249 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2250 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2251 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2252 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2253 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2254 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2255 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2256 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2257 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2258 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2259 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2261 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2262 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2263 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2264 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2265 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2266 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2267 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2268 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2269 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2270 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2271 #ifdef CONFIG_FREETYPE
2272 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2275 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2278 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2279 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2280 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2281 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2283 { NULL
, 0, 0, 0, -1, NULL
}
2287 /// Handle commands that set a property.
2288 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2290 struct MPOpts
*opts
= &mpctx
->opts
;
2295 // look for the command
2296 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2297 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2299 if (!(pname
= set_prop_cmd
[i
].name
))
2302 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2306 if (set_prop_cmd
[i
].toggle
) {
2308 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2309 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2311 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2312 } else if (cmd
->args
[1].v
.i
) //set
2313 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2315 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2320 if (set_prop_cmd
[i
].osd_progbar
== -1)
2321 mpctx
->add_osd_seek_info
= true;
2322 else if (set_prop_cmd
[i
].osd_progbar
) {
2323 if (prop
->type
== CONF_TYPE_INT
) {
2324 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2325 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2326 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2327 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2329 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2330 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2331 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2333 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2334 "Property use an unsupported type.\n");
2338 if (set_prop_cmd
[i
].osd_msg
) {
2339 char *val
= mp_property_print(pname
, mpctx
);
2341 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2342 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2343 1, opts
->osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2350 #ifdef CONFIG_DVDNAV
2351 static const struct {
2353 const mp_command_type cmd
;
2354 } mp_dvdnav_bindings
[] = {
2355 { "up", MP_CMD_DVDNAV_UP
},
2356 { "down", MP_CMD_DVDNAV_DOWN
},
2357 { "left", MP_CMD_DVDNAV_LEFT
},
2358 { "right", MP_CMD_DVDNAV_RIGHT
},
2359 { "menu", MP_CMD_DVDNAV_MENU
},
2360 { "select", MP_CMD_DVDNAV_SELECT
},
2361 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2362 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2365 * keep old dvdnav sub-command options for a while in order not to
2366 * break slave-mode API too suddenly.
2368 { "1", MP_CMD_DVDNAV_UP
},
2369 { "2", MP_CMD_DVDNAV_DOWN
},
2370 { "3", MP_CMD_DVDNAV_LEFT
},
2371 { "4", MP_CMD_DVDNAV_RIGHT
},
2372 { "5", MP_CMD_DVDNAV_MENU
},
2373 { "6", MP_CMD_DVDNAV_SELECT
},
2374 { "7", MP_CMD_DVDNAV_PREVMENU
},
2375 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2380 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2382 struct MPOpts
*opts
= &mpctx
->opts
;
2383 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2384 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2385 int osd_duration
= opts
->osd_duration
;
2386 if (!set_property_command(mpctx
, cmd
))
2391 mpctx
->add_osd_seek_info
= true;
2392 v
= cmd
->args
[0].v
.f
;
2393 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2394 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2395 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2397 mpctx
->osd_function
=
2398 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2399 mpctx
->rel_seek_secs
= v
;
2400 } else if (abs
) { /* Absolute seek by percentage */
2401 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2403 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2404 mpctx
->rel_seek_secs
= v
/ 100.0;
2406 mpctx
->rel_seek_secs
+= v
;
2407 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2412 case MP_CMD_SET_PROPERTY
:{
2413 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2414 cmd
->args
[1].v
.s
, mpctx
);
2415 if (r
== M_PROPERTY_UNKNOWN
)
2416 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2417 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2419 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2420 "Failed to set property '%s' to '%s'.\n",
2421 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2425 case MP_CMD_STEP_PROPERTY
:{
2430 if (cmd
->args
[1].v
.f
) {
2432 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2433 M_PROPERTY_GET_TYPE
,
2434 &prop
, mpctx
)) <= 0)
2436 if(prop
->type
== CONF_TYPE_INT
||
2437 prop
->type
== CONF_TYPE_FLAG
)
2438 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2439 else if(prop
->type
== CONF_TYPE_FLOAT
)
2440 arg
= &cmd
->args
[1].v
.f
;
2441 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2442 prop
->type
== CONF_TYPE_TIME
)
2443 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2444 else if(prop
->type
== CONF_TYPE_POSITION
)
2445 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2447 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2448 "Ignoring step size stepping property '%s'.\n",
2451 r
= mp_property_do(cmd
->args
[0].v
.s
,
2452 cmd
->args
[2].v
.i
< 0 ?
2453 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2456 if (r
== M_PROPERTY_UNKNOWN
)
2457 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2458 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2460 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2461 "Failed to increment property '%s' by %f.\n",
2462 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2466 case MP_CMD_GET_PROPERTY
:{
2468 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2469 &tmp
, mpctx
) <= 0) {
2470 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2471 "Failed to get value of property '%s'.\n",
2475 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2476 cmd
->args
[0].v
.s
, tmp
);
2481 case MP_CMD_EDL_MARK
:
2483 float v
= sh_video
? sh_video
->pts
:
2484 playing_audio_pts(mpctx
);
2485 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2486 mpctx
->begin_skip
= v
;
2487 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2489 if (mpctx
->begin_skip
> v
)
2490 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2492 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2493 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2495 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2500 case MP_CMD_SWITCH_RATIO
:
2503 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2504 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2506 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2507 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2510 case MP_CMD_SPEED_INCR
:{
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
, MSGTR_OSDSpeed
,
2515 opts
->playback_speed
);
2518 case MP_CMD_SPEED_MULT
:{
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
, MSGTR_OSDSpeed
,
2523 opts
->playback_speed
);
2526 case MP_CMD_SPEED_SET
:{
2527 float v
= cmd
->args
[0].v
.f
;
2528 opts
->playback_speed
= v
;
2529 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2530 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2531 opts
->playback_speed
);
2534 case MP_CMD_FRAME_STEP
:
2535 add_step_frame(mpctx
);
2538 case MP_CMD_FILE_FILTER
:
2539 file_filter
= cmd
->args
[0].v
.i
;
2543 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2544 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2546 case MP_CMD_PLAY_TREE_STEP
:{
2547 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2548 int force
= cmd
->args
[1].v
.i
;
2554 for (i
= 0; i
< n
; i
++)
2557 for (i
= 0; i
< -1 * n
; i
++)
2562 if (!force
&& mpctx
->playtree_iter
) {
2563 play_tree_iter_t
*i
=
2564 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2565 if (play_tree_iter_step(i
, n
, 0) ==
2566 PLAY_TREE_ITER_ENTRY
)
2568 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2569 play_tree_iter_free(i
);
2571 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2572 if (mpctx
->stop_play
)
2573 mpctx
->play_tree_step
= n
;
2578 case MP_CMD_PLAY_TREE_UP_STEP
:{
2579 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2580 int force
= cmd
->args
[1].v
.i
;
2582 if (!force
&& mpctx
->playtree_iter
) {
2583 play_tree_iter_t
*i
=
2584 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2585 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2586 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2587 play_tree_iter_free(i
);
2589 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2593 case MP_CMD_PLAY_ALT_SRC_STEP
:
2594 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2595 int v
= cmd
->args
[0].v
.i
;
2597 && mpctx
->playtree_iter
->file
<
2598 mpctx
->playtree_iter
->num_files
)
2599 mpctx
->stop_play
= PT_NEXT_SRC
;
2600 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2601 mpctx
->stop_play
= PT_PREV_SRC
;
2605 case MP_CMD_SUB_STEP
:
2607 int movement
= cmd
->args
[0].v
.i
;
2608 step_sub(subdata
, sh_video
->pts
, movement
);
2612 ass_step_sub(ass_track
,
2614 sub_delay
) * 1000 + .5, movement
) / 1000.;
2616 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2617 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2621 case MP_CMD_SUB_LOG
:
2626 int v
= cmd
->args
[0].v
.i
;
2628 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2629 if (opts
->osd_level
> max
)
2630 opts
->osd_level
= max
;
2632 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2634 opts
->osd_level
= v
> max
? max
: v
;
2635 /* Show OSD state when disabled, but not when an explicit
2636 argument is given to the OSD command, i.e. in slave mode. */
2637 if (v
== -1 && opts
->osd_level
<= 1)
2638 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2640 opts
->osd_level
? MSGTR_OSDenabled
:
2643 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2647 case MP_CMD_OSD_SHOW_TEXT
:
2648 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2650 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2651 "%-.63s", cmd
->args
[0].v
.s
);
2654 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2655 char *txt
= m_properties_expand_string(mp_properties
,
2658 /* if no argument supplied take default osd_duration, else <arg> ms. */
2660 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2662 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2669 case MP_CMD_LOADFILE
:{
2670 play_tree_t
*e
= play_tree_new();
2671 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2673 if (cmd
->args
[1].v
.i
) // append
2674 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2676 // Go back to the starting point.
2677 while (play_tree_iter_up_step
2678 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2680 play_tree_free_list(mpctx
->playtree
->child
, 1);
2681 play_tree_set_child(mpctx
->playtree
, e
);
2682 pt_iter_goto_head(mpctx
->playtree_iter
);
2683 mpctx
->stop_play
= PT_NEXT_SRC
;
2688 case MP_CMD_LOADLIST
:{
2689 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2691 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2692 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2694 if (cmd
->args
[1].v
.i
) // append
2695 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2697 // Go back to the starting point.
2698 while (play_tree_iter_up_step
2699 (mpctx
->playtree_iter
, 0, 1)
2700 != PLAY_TREE_ITER_END
)
2702 play_tree_free_list(mpctx
->playtree
->child
, 1);
2703 play_tree_set_child(mpctx
->playtree
, e
);
2704 pt_iter_goto_head(mpctx
->playtree_iter
);
2705 mpctx
->stop_play
= PT_NEXT_SRC
;
2712 // Go back to the starting point.
2713 while (play_tree_iter_up_step
2714 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2716 mpctx
->stop_play
= PT_STOP
;
2720 case MP_CMD_RADIO_STEP_CHANNEL
:
2721 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2722 int v
= cmd
->args
[0].v
.i
;
2724 radio_step_channel(mpctx
->demuxer
->stream
,
2725 RADIO_CHANNEL_HIGHER
);
2727 radio_step_channel(mpctx
->demuxer
->stream
,
2728 RADIO_CHANNEL_LOWER
);
2729 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2730 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2732 radio_get_channel_name(mpctx
->demuxer
->stream
));
2737 case MP_CMD_RADIO_SET_CHANNEL
:
2738 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2739 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2740 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2741 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2743 radio_get_channel_name(mpctx
->demuxer
->stream
));
2748 case MP_CMD_RADIO_SET_FREQ
:
2749 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2750 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2753 case MP_CMD_RADIO_STEP_FREQ
:
2754 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2755 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2760 case MP_CMD_TV_START_SCAN
:
2761 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2762 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2764 case MP_CMD_TV_SET_FREQ
:
2765 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2766 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2767 cmd
->args
[0].v
.f
* 16.0);
2769 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2770 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2771 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2772 pvr_get_current_channelname (mpctx
->stream
),
2773 pvr_get_current_stationname (mpctx
->stream
));
2775 #endif /* CONFIG_PVR */
2778 case MP_CMD_TV_STEP_FREQ
:
2779 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2780 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2781 cmd
->args
[0].v
.f
* 16.0);
2783 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2784 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2785 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2786 pvr_get_current_channelname (mpctx
->stream
),
2787 pvr_get_current_frequency (mpctx
->stream
));
2789 #endif /* CONFIG_PVR */
2792 case MP_CMD_TV_SET_NORM
:
2793 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2794 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2798 case MP_CMD_TV_STEP_CHANNEL
:{
2799 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2800 int v
= cmd
->args
[0].v
.i
;
2802 tv_step_channel((tvi_handle_t
*) (mpctx
->
2806 tv_step_channel((tvi_handle_t
*) (mpctx
->
2810 if (tv_channel_list
) {
2811 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2812 MSGTR_OSDChannel
, tv_channel_current
->name
);
2813 //vo_osd_changed(OSDTYPE_SUBTITLE);
2817 else if (mpctx
->stream
&&
2818 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2819 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2820 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2821 pvr_get_current_channelname (mpctx
->stream
),
2822 pvr_get_current_stationname (mpctx
->stream
));
2824 #endif /* CONFIG_PVR */
2827 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2829 int v
= cmd
->args
[0].v
.i
;
2831 mpctx
->last_dvb_step
= v
;
2833 dir
= DVB_CHANNEL_HIGHER
;
2835 dir
= DVB_CHANNEL_LOWER
;
2838 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2839 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2840 mpctx
->dvbin_reopen
= 1;
2843 #endif /* CONFIG_DVBIN */
2846 case MP_CMD_TV_SET_CHANNEL
:
2847 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2848 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2850 if (tv_channel_list
) {
2851 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2852 MSGTR_OSDChannel
, tv_channel_current
->name
);
2853 //vo_osd_changed(OSDTYPE_SUBTITLE);
2857 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2858 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2859 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2860 pvr_get_current_channelname (mpctx
->stream
),
2861 pvr_get_current_stationname (mpctx
->stream
));
2863 #endif /* CONFIG_PVR */
2867 case MP_CMD_DVB_SET_CHANNEL
:
2868 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2869 mpctx
->last_dvb_step
= 1;
2871 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2872 cmd
->args
[0].v
.i
)) {
2873 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2874 mpctx
->dvbin_reopen
= 1;
2878 #endif /* CONFIG_DVBIN */
2880 case MP_CMD_TV_LAST_CHANNEL
:
2881 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2882 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2883 if (tv_channel_list
) {
2884 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2885 MSGTR_OSDChannel
, tv_channel_current
->name
);
2886 //vo_osd_changed(OSDTYPE_SUBTITLE);
2890 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2891 pvr_set_lastchannel (mpctx
->stream
);
2892 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2893 pvr_get_current_channelname (mpctx
->stream
),
2894 pvr_get_current_stationname (mpctx
->stream
));
2896 #endif /* CONFIG_PVR */
2899 case MP_CMD_TV_STEP_NORM
:
2900 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2901 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2904 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2905 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2906 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2908 #ifdef CONFIG_TV_TELETEXT
2909 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2911 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2912 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2913 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2916 case MP_CMD_TV_TELETEXT_GO_LINK
:
2918 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2919 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2920 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2923 #endif /* CONFIG_TV_TELETEXT */
2924 #endif /* CONFIG_TV */
2926 case MP_CMD_SUB_LOAD
:
2928 int n
= mpctx
->set_of_sub_size
;
2929 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2930 if (n
!= mpctx
->set_of_sub_size
) {
2931 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2932 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2933 mpctx
->global_sub_size
;
2934 ++mpctx
->global_sub_size
;
2939 case MP_CMD_SUB_REMOVE
:
2941 int v
= cmd
->args
[0].v
.i
;
2944 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2945 subd
= mpctx
->set_of_subtitles
[v
];
2946 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2947 MSGTR_RemovedSubtitleFile
, v
+ 1,
2948 filename_recode(subd
->filename
));
2950 mpctx
->set_of_subtitles
[v
] = NULL
;
2952 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2953 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2954 mpctx
->set_of_sub_size
= 0;
2955 if (mpctx
->set_of_sub_pos
>= 0) {
2956 mpctx
->global_sub_pos
= -2;
2958 mp_input_queue_cmd(mpctx
->input
,
2959 mp_input_parse_cmd("sub_select"));
2961 } else if (v
< mpctx
->set_of_sub_size
) {
2962 subd
= mpctx
->set_of_subtitles
[v
];
2963 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2964 MSGTR_RemovedSubtitleFile
, v
+ 1,
2965 filename_recode(subd
->filename
));
2967 if (mpctx
->set_of_sub_pos
== v
) {
2968 mpctx
->global_sub_pos
= -2;
2970 mp_input_queue_cmd(mpctx
->input
,
2971 mp_input_parse_cmd("sub_select"));
2972 } else if (mpctx
->set_of_sub_pos
> v
) {
2973 --mpctx
->set_of_sub_pos
;
2974 --mpctx
->global_sub_pos
;
2976 while (++v
< mpctx
->set_of_sub_size
)
2977 mpctx
->set_of_subtitles
[v
- 1] =
2978 mpctx
->set_of_subtitles
[v
];
2979 --mpctx
->set_of_sub_size
;
2980 --mpctx
->global_sub_size
;
2981 if (mpctx
->set_of_sub_size
<= 0)
2982 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2983 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2988 case MP_CMD_GET_SUB_VISIBILITY
:
2990 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2991 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2995 case MP_CMD_SCREENSHOT
:
2996 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2997 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2999 ((vf_instance_t
*) sh_video
->vfilter
)->
3000 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3002 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3006 case MP_CMD_VF_CHANGE_RECTANGLE
:
3009 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3012 case MP_CMD_GET_TIME_LENGTH
:{
3013 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
3014 demuxer_get_time_length(mpctx
->demuxer
));
3018 case MP_CMD_GET_FILENAME
:{
3019 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3020 get_metadata(mpctx
, META_NAME
));
3024 case MP_CMD_GET_VIDEO_CODEC
:{
3025 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3028 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3033 case MP_CMD_GET_VIDEO_BITRATE
:{
3034 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3037 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3042 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3043 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3046 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3047 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3052 case MP_CMD_GET_AUDIO_CODEC
:{
3053 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3056 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3061 case MP_CMD_GET_AUDIO_BITRATE
:{
3062 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3065 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3070 case MP_CMD_GET_AUDIO_SAMPLES
:{
3071 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3074 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3079 case MP_CMD_GET_META_TITLE
:{
3080 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3083 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3088 case MP_CMD_GET_META_ARTIST
:{
3089 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3092 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3097 case MP_CMD_GET_META_ALBUM
:{
3098 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3101 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3106 case MP_CMD_GET_META_YEAR
:{
3107 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3110 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3115 case MP_CMD_GET_META_COMMENT
:{
3116 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3119 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3124 case MP_CMD_GET_META_TRACK
:{
3125 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3128 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3133 case MP_CMD_GET_META_GENRE
:{
3134 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3137 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3142 case MP_CMD_GET_VO_FULLSCREEN
:
3143 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3144 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3147 case MP_CMD_GET_PERCENT_POS
:
3148 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3149 demuxer_get_percent_pos(mpctx
->demuxer
));
3152 case MP_CMD_GET_TIME_POS
:{
3155 pos
= sh_video
->pts
;
3156 else if (sh_audio
&& mpctx
->audio_out
)
3157 pos
= playing_audio_pts(mpctx
);
3158 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3165 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3171 case MP_CMD_KEYDOWN_EVENTS
:
3172 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3175 case MP_CMD_SET_MOUSE_POS
:{
3176 int pointer_x
, pointer_y
;
3178 pointer_x
= cmd
->args
[0].v
.i
;
3179 pointer_y
= cmd
->args
[1].v
.i
;
3180 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3181 #ifdef CONFIG_DVDNAV
3182 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3183 && dx
> 0.0 && dy
> 0.0) {
3185 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3186 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3187 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3188 pointer_x
, pointer_y
, &button
);
3189 if (opts
->osd_level
> 1 && button
> 0)
3190 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3191 "Selected button number %d", button
);
3195 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3196 menu_update_mouse_pos(dx
, dy
);
3201 #ifdef CONFIG_DVDNAV
3202 case MP_CMD_DVDNAV
:{
3205 mp_command_type command
= 0;
3206 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3209 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3210 if (cmd
->args
[0].v
.s
&&
3211 !strcasecmp (cmd
->args
[0].v
.s
,
3212 mp_dvdnav_bindings
[i
].name
))
3213 command
= mp_dvdnav_bindings
[i
].cmd
;
3215 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3216 if (opts
->osd_level
> 1 && button
> 0)
3217 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3218 "Selected button number %d", button
);
3222 case MP_CMD_SWITCH_TITLE
:
3223 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3224 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3231 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3232 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3235 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3236 "Received unknown cmd %s\n", cmd
->name
);
3239 switch (cmd
->pausing
) {
3240 case 1: // "pausing"
3241 pause_player(mpctx
);
3243 case 3: // "pausing_toggle"
3245 unpause_player(mpctx
);
3247 pause_player(mpctx
);