8 #include "input/input.h"
9 #include "stream/stream.h"
10 #include "libmpdemux/demuxer.h"
11 #include "libmpdemux/stheader.h"
12 #include "codec-cfg.h"
14 #include "libvo/sub.h"
16 #include "m_property.h"
19 #include "libmpcodecs/vf.h"
20 #include "libmpcodecs/vd.h"
22 #include "libvo/video_out.h"
23 #include "libvo/font_load.h"
25 #include "libao2/audio_out.h"
28 #include "libmpcodecs/dec_video.h"
33 #include "stream/tv.h"
36 #include "stream/stream_radio.h"
39 #include "stream/pvr.h"
42 #include "stream/dvbin.h"
45 #include "stream/stream_dvd.h"
48 #include "stream/stream_dvdnav.h"
51 #include "libass/ass.h"
52 #include "libass/ass_mp.h"
56 #include "libmenu/menu.h"
59 #include "gui/interface.h"
64 #include "libavutil/avstring.h"
66 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
70 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
71 double *dx
, double *dy
)
73 struct MPOpts
*opts
= &mpctx
->opts
;
74 struct vo
*vo
= mpctx
->video_out
;
75 //remove the borders, if any, and rescale to the range [0,1],[0,1]
76 if (vo_fs
) { //we are in full-screen mode
77 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
78 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
79 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
80 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
82 if (ix
< 0 || ix
> vo
->dwidth
) {
85 } //we are on one of the borders
86 if (iy
< 0 || iy
> vo
->dheight
) {
89 } //we are on one of the borders
92 *dx
= (double) ix
/ (double) vo
->dwidth
;
93 *dy
= (double) iy
/ (double) vo
->dheight
;
95 mp_msg(MSGT_CPLAYER
, MSGL_V
,
96 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
97 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
101 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
106 for (i
= 0; i
< SUB_SOURCES
; i
++) {
107 int j
= mpctx
->global_sub_indices
[i
];
108 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
116 static int sub_source(MPContext
*mpctx
)
118 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
122 * \brief Log the currently displayed subtitle to a file
124 * Logs the current or last displayed subtitle together with filename
125 * and time information to ~/.mplayer/subtitle_log
127 * Intended purpose is to allow convenient marking of bogus subtitles
128 * which need to be fixed while watching the movie.
131 static void log_sub(struct MPContext
*mpctx
)
137 if (subdata
== NULL
|| vo_sub_last
== NULL
)
139 fname
= get_path("subtitle_log");
140 f
= fopen(fname
, "a");
143 fprintf(f
, "----------------------------------------------------------\n");
144 if (subdata
->sub_uses_time
) {
146 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
147 mpctx
->filename
, vo_sub_last
->start
/ 360000,
148 (vo_sub_last
->start
/ 6000) % 60,
149 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
150 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
151 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
153 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
154 vo_sub_last
->start
, vo_sub_last
->end
);
156 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
157 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
163 /// \defgroup Properties
166 /// \defgroup GeneralProperties General properties
167 /// \ingroup Properties
171 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
174 return m_property_choice(prop
, action
, arg
, &osd_level
);
178 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
181 struct MPOpts
*opts
= &mpctx
->opts
;
183 case M_PROPERTY_PRINT
:
184 if (!arg
) return M_PROPERTY_ERROR
;
185 if (opts
->loop_times
< 0)
186 *(char**)arg
= strdup("off");
187 else if (opts
->loop_times
== 0)
188 *(char**)arg
= strdup("inf");
191 return M_PROPERTY_OK
;
193 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
196 /// Playback speed (RW)
197 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
198 void *arg
, MPContext
*mpctx
)
200 struct MPOpts
*opts
= &mpctx
->opts
;
204 return M_PROPERTY_ERROR
;
205 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
206 opts
->playback_speed
= *(float *) arg
;
207 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
208 return M_PROPERTY_OK
;
209 case M_PROPERTY_STEP_UP
:
210 case M_PROPERTY_STEP_DOWN
:
211 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
212 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
213 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
214 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
215 return M_PROPERTY_OK
;
217 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
220 /// filename with path (RO)
221 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
224 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
227 /// filename without path (RO)
228 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
232 if (!mpctx
->filename
)
233 return M_PROPERTY_UNAVAILABLE
;
234 if (((f
= strrchr(mpctx
->filename
, '/'))
235 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
239 return m_property_string_ro(prop
, action
, arg
, f
);
242 /// Demuxer name (RO)
243 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
247 return M_PROPERTY_UNAVAILABLE
;
248 return m_property_string_ro(prop
, action
, arg
,
249 (char *) mpctx
->demuxer
->desc
->name
);
252 /// Position in the stream (RW)
253 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
256 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
257 return M_PROPERTY_UNAVAILABLE
;
259 return M_PROPERTY_ERROR
;
262 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
263 return M_PROPERTY_OK
;
265 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
266 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
267 return M_PROPERTY_OK
;
269 return M_PROPERTY_NOT_IMPLEMENTED
;
272 /// Stream start offset (RO)
273 static int mp_property_stream_start(m_option_t
*prop
, int action
,
274 void *arg
, MPContext
*mpctx
)
276 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
277 return M_PROPERTY_UNAVAILABLE
;
280 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
281 return M_PROPERTY_OK
;
283 return M_PROPERTY_NOT_IMPLEMENTED
;
286 /// Stream end offset (RO)
287 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
290 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
291 return M_PROPERTY_UNAVAILABLE
;
294 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
295 return M_PROPERTY_OK
;
297 return M_PROPERTY_NOT_IMPLEMENTED
;
300 /// Stream length (RO)
301 static int mp_property_stream_length(m_option_t
*prop
, int action
,
302 void *arg
, MPContext
*mpctx
)
304 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
305 return M_PROPERTY_UNAVAILABLE
;
309 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
310 return M_PROPERTY_OK
;
312 return M_PROPERTY_NOT_IMPLEMENTED
;
315 /// Media length in seconds (RO)
316 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
321 if (!mpctx
->demuxer
||
322 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
323 return M_PROPERTY_UNAVAILABLE
;
325 return m_property_time_ro(prop
, action
, arg
, len
);
328 /// Current position in percent (RW)
329 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
330 void *arg
, MPContext
*mpctx
) {
334 return M_PROPERTY_UNAVAILABLE
;
338 if(!arg
) return M_PROPERTY_ERROR
;
339 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
342 case M_PROPERTY_STEP_UP
:
343 case M_PROPERTY_STEP_DOWN
:
344 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
345 pos
+= (arg
? *(int*)arg
: 10) *
346 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
347 M_PROPERTY_CLAMP(prop
, pos
);
350 return m_property_int_ro(prop
, action
, arg
,
351 demuxer_get_percent_pos(mpctx
->demuxer
));
354 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
355 mpctx
->rel_seek_secs
= pos
/ 100.0;
356 return M_PROPERTY_OK
;
359 /// Current position in seconds (RW)
360 static int mp_property_time_pos(m_option_t
*prop
, int action
,
361 void *arg
, MPContext
*mpctx
) {
362 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
363 return M_PROPERTY_UNAVAILABLE
;
367 if(!arg
) return M_PROPERTY_ERROR
;
368 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
369 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
370 mpctx
->rel_seek_secs
= *(double*)arg
;
371 return M_PROPERTY_OK
;
372 case M_PROPERTY_STEP_UP
:
373 case M_PROPERTY_STEP_DOWN
:
374 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
375 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
376 return M_PROPERTY_OK
;
378 return m_property_time_ro(prop
, action
, arg
,
379 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
380 playing_audio_pts(mpctx
));
383 /// Current chapter (RW)
384 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
391 char *chapter_name
= NULL
;
394 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
396 return M_PROPERTY_UNAVAILABLE
;
401 return M_PROPERTY_ERROR
;
402 *(int *) arg
= chapter
;
403 return M_PROPERTY_OK
;
404 case M_PROPERTY_PRINT
: {
406 return M_PROPERTY_ERROR
;
407 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
409 return M_PROPERTY_UNAVAILABLE
;
410 *(char **) arg
= chapter_name
;
411 return M_PROPERTY_OK
;
415 return M_PROPERTY_ERROR
;
416 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
417 step_all
= *(int *)arg
- (chapter
+ 1);
420 case M_PROPERTY_STEP_UP
:
421 case M_PROPERTY_STEP_DOWN
: {
422 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
423 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
430 return M_PROPERTY_NOT_IMPLEMENTED
;
432 mpctx
->rel_seek_secs
= 0;
433 mpctx
->abs_seek_pos
= 0;
434 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
435 &next_pts
, &chapter_num
, &chapter_name
);
437 if (next_pts
> -1.0) {
438 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
439 mpctx
->rel_seek_secs
= next_pts
;
442 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
443 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
445 else if (step_all
> 0)
446 mpctx
->rel_seek_secs
= 1000000000.;
448 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
449 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
452 return M_PROPERTY_OK
;
455 /// Number of chapters in file
456 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
460 return M_PROPERTY_UNAVAILABLE
;
461 if (mpctx
->demuxer
->num_chapters
== 0)
462 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
463 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
466 /// Current dvd angle (RW)
467 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
472 char *angle_name
= NULL
;
475 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
477 return M_PROPERTY_UNAVAILABLE
;
478 angles
= demuxer_angles_count(mpctx
->demuxer
);
480 return M_PROPERTY_UNAVAILABLE
;
485 return M_PROPERTY_ERROR
;
486 *(int *) arg
= angle
;
487 return M_PROPERTY_OK
;
488 case M_PROPERTY_PRINT
: {
490 return M_PROPERTY_ERROR
;
491 angle_name
= calloc(1, 64);
493 return M_PROPERTY_UNAVAILABLE
;
494 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
495 *(char **) arg
= angle_name
;
496 return M_PROPERTY_OK
;
500 return M_PROPERTY_ERROR
;
502 M_PROPERTY_CLAMP(prop
, angle
);
504 case M_PROPERTY_STEP_UP
:
505 case M_PROPERTY_STEP_DOWN
: {
511 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
513 if (angle
< 1) //cycle
518 return M_PROPERTY_NOT_IMPLEMENTED
;
520 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
521 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
522 MSGTR_OSDAngle
, angle
, angles
);
525 return M_PROPERTY_OK
;
528 /// Demuxer meta data
529 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
531 m_property_action_t
* ka
;
533 static const m_option_t key_type
=
534 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
536 return M_PROPERTY_UNAVAILABLE
;
540 if(!arg
) return M_PROPERTY_ERROR
;
541 *(char***)arg
= mpctx
->demuxer
->info
;
542 return M_PROPERTY_OK
;
543 case M_PROPERTY_KEY_ACTION
:
544 if(!arg
) return M_PROPERTY_ERROR
;
546 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
547 return M_PROPERTY_UNKNOWN
;
550 if(!ka
->arg
) return M_PROPERTY_ERROR
;
551 *(char**)ka
->arg
= meta
;
552 return M_PROPERTY_OK
;
553 case M_PROPERTY_GET_TYPE
:
554 if(!ka
->arg
) return M_PROPERTY_ERROR
;
555 *(m_option_t
**)ka
->arg
= &key_type
;
556 return M_PROPERTY_OK
;
559 return M_PROPERTY_NOT_IMPLEMENTED
;
562 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
565 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
571 /// \defgroup AudioProperties Audio properties
572 /// \ingroup Properties
576 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
580 if (!mpctx
->sh_audio
)
581 return M_PROPERTY_UNAVAILABLE
;
586 return M_PROPERTY_ERROR
;
587 mixer_getbothvolume(&mpctx
->mixer
, arg
);
588 return M_PROPERTY_OK
;
589 case M_PROPERTY_PRINT
:{
592 return M_PROPERTY_ERROR
;
593 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
594 return m_property_float_range(prop
, action
, arg
, &vol
);
596 case M_PROPERTY_STEP_UP
:
597 case M_PROPERTY_STEP_DOWN
:
601 return M_PROPERTY_NOT_IMPLEMENTED
;
604 if (mpctx
->edl_muted
)
605 return M_PROPERTY_DISABLED
;
606 mpctx
->user_muted
= 0;
611 return M_PROPERTY_ERROR
;
612 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
613 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
614 return M_PROPERTY_OK
;
615 case M_PROPERTY_STEP_UP
:
616 if (arg
&& *(float *) arg
<= 0)
617 mixer_decvolume(&mpctx
->mixer
);
619 mixer_incvolume(&mpctx
->mixer
);
620 return M_PROPERTY_OK
;
621 case M_PROPERTY_STEP_DOWN
:
622 if (arg
&& *(float *) arg
<= 0)
623 mixer_incvolume(&mpctx
->mixer
);
625 mixer_decvolume(&mpctx
->mixer
);
626 return M_PROPERTY_OK
;
628 return M_PROPERTY_NOT_IMPLEMENTED
;
632 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
636 if (!mpctx
->sh_audio
)
637 return M_PROPERTY_UNAVAILABLE
;
641 if (mpctx
->edl_muted
)
642 return M_PROPERTY_DISABLED
;
644 return M_PROPERTY_ERROR
;
645 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
646 mixer_mute(&mpctx
->mixer
);
647 mpctx
->user_muted
= mpctx
->mixer
.muted
;
648 return M_PROPERTY_OK
;
649 case M_PROPERTY_STEP_UP
:
650 case M_PROPERTY_STEP_DOWN
:
651 if (mpctx
->edl_muted
)
652 return M_PROPERTY_DISABLED
;
653 mixer_mute(&mpctx
->mixer
);
654 mpctx
->user_muted
= mpctx
->mixer
.muted
;
655 return M_PROPERTY_OK
;
656 case M_PROPERTY_PRINT
:
658 return M_PROPERTY_ERROR
;
659 if (mpctx
->edl_muted
) {
660 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
661 return M_PROPERTY_OK
;
664 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
670 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
671 void *arg
, MPContext
*mpctx
)
673 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
674 return M_PROPERTY_UNAVAILABLE
;
677 case M_PROPERTY_STEP_UP
:
678 case M_PROPERTY_STEP_DOWN
: {
680 float delay
= audio_delay
;
681 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
682 if (ret
!= M_PROPERTY_OK
)
685 mpctx
->delay
-= audio_delay
- delay
;
687 return M_PROPERTY_OK
;
689 return m_property_delay(prop
, action
, arg
, &audio_delay
);
693 /// Audio codec tag (RO)
694 static int mp_property_audio_format(m_option_t
*prop
, int action
,
695 void *arg
, MPContext
*mpctx
)
697 if (!mpctx
->sh_audio
)
698 return M_PROPERTY_UNAVAILABLE
;
699 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
702 /// Audio codec name (RO)
703 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
704 void *arg
, MPContext
*mpctx
)
706 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
707 return M_PROPERTY_UNAVAILABLE
;
708 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
711 /// Audio bitrate (RO)
712 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
713 void *arg
, MPContext
*mpctx
)
715 if (!mpctx
->sh_audio
)
716 return M_PROPERTY_UNAVAILABLE
;
717 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
721 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
724 if (!mpctx
->sh_audio
)
725 return M_PROPERTY_UNAVAILABLE
;
727 case M_PROPERTY_PRINT
:
728 if(!arg
) return M_PROPERTY_ERROR
;
729 *(char**)arg
= malloc(16);
730 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
731 return M_PROPERTY_OK
;
733 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
736 /// Number of channels (RO)
737 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
740 if (!mpctx
->sh_audio
)
741 return M_PROPERTY_UNAVAILABLE
;
743 case M_PROPERTY_PRINT
:
745 return M_PROPERTY_ERROR
;
746 switch (mpctx
->sh_audio
->channels
) {
748 *(char **) arg
= strdup("mono");
751 *(char **) arg
= strdup("stereo");
754 *(char **) arg
= malloc(32);
755 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
757 return M_PROPERTY_OK
;
759 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
763 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
768 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
769 return M_PROPERTY_UNAVAILABLE
;
774 return M_PROPERTY_ERROR
;
775 mixer_getbalance(&mpctx
->mixer
, arg
);
776 return M_PROPERTY_OK
;
777 case M_PROPERTY_PRINT
: {
780 return M_PROPERTY_ERROR
;
781 mixer_getbalance(&mpctx
->mixer
, &bal
);
783 *str
= strdup("center");
784 else if (bal
== -1.f
)
785 *str
= strdup("left only");
787 *str
= strdup("right only");
789 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
790 *str
= malloc(sizeof("left xxx%, right xxx%"));
791 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
793 return M_PROPERTY_OK
;
795 case M_PROPERTY_STEP_UP
:
796 case M_PROPERTY_STEP_DOWN
:
797 mixer_getbalance(&mpctx
->mixer
, &bal
);
798 bal
+= (arg
? *(float*)arg
: .1f
) *
799 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
800 M_PROPERTY_CLAMP(prop
, bal
);
801 mixer_setbalance(&mpctx
->mixer
, bal
);
802 return M_PROPERTY_OK
;
805 return M_PROPERTY_ERROR
;
806 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
807 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
808 return M_PROPERTY_OK
;
810 return M_PROPERTY_NOT_IMPLEMENTED
;
813 /// Selected audio id (RW)
814 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
817 struct MPOpts
*opts
= &mpctx
->opts
;
818 int current_id
= -1, tmp
;
822 if (!mpctx
->sh_audio
)
823 return M_PROPERTY_UNAVAILABLE
;
825 return M_PROPERTY_ERROR
;
826 *(int *) arg
= opts
->audio_id
;
827 return M_PROPERTY_OK
;
828 case M_PROPERTY_PRINT
:
829 if (!mpctx
->sh_audio
)
830 return M_PROPERTY_UNAVAILABLE
;
832 return M_PROPERTY_ERROR
;
834 if (opts
->audio_id
< 0)
835 *(char **) arg
= strdup(MSGTR_Disabled
);
837 char lang
[40] = MSGTR_Unknown
;
838 sh_audio_t
* sh
= mpctx
->sh_audio
;
840 av_strlcpy(lang
, sh
->lang
, 40);
841 #ifdef CONFIG_DVDREAD
842 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
843 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
853 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
854 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
856 *(char **) arg
= malloc(64);
857 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
859 return M_PROPERTY_OK
;
861 case M_PROPERTY_STEP_UP
:
864 return M_PROPERTY_UNAVAILABLE
;
865 if (action
== M_PROPERTY_SET
&& arg
)
866 tmp
= *((int *) arg
);
869 current_id
= mpctx
->demuxer
->audio
->id
;
870 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
871 if (opts
->audio_id
== -2
872 || (opts
->audio_id
> -1
873 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
874 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
875 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
877 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
879 sh2
->ds
= mpctx
->demuxer
->audio
;
880 mpctx
->sh_audio
= sh2
;
881 reinit_audio_chain(mpctx
);
884 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
885 return M_PROPERTY_OK
;
887 return M_PROPERTY_NOT_IMPLEMENTED
;
892 /// Selected video id (RW)
893 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
896 struct MPOpts
*opts
= &mpctx
->opts
;
897 int current_id
= -1, tmp
;
901 if (!mpctx
->sh_video
)
902 return M_PROPERTY_UNAVAILABLE
;
904 return M_PROPERTY_ERROR
;
905 *(int *) arg
= opts
->video_id
;
906 return M_PROPERTY_OK
;
907 case M_PROPERTY_PRINT
:
908 if (!mpctx
->sh_video
)
909 return M_PROPERTY_UNAVAILABLE
;
911 return M_PROPERTY_ERROR
;
913 if (opts
->video_id
< 0)
914 *(char **) arg
= strdup(MSGTR_Disabled
);
916 char lang
[40] = MSGTR_Unknown
;
917 *(char **) arg
= malloc(64);
918 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
920 return M_PROPERTY_OK
;
922 case M_PROPERTY_STEP_UP
:
924 current_id
= mpctx
->demuxer
->video
->id
;
925 if (action
== M_PROPERTY_SET
&& arg
)
926 tmp
= *((int *) arg
);
929 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
930 if (opts
->video_id
== -2
931 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
932 && current_id
!= -2))
933 uninit_player(mpctx
, INITIALIZED_VCODEC
|
934 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
935 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
937 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
939 sh2
->ds
= mpctx
->demuxer
->video
;
940 mpctx
->sh_video
= sh2
;
941 reinit_video_chain(mpctx
);
944 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
945 return M_PROPERTY_OK
;
948 return M_PROPERTY_NOT_IMPLEMENTED
;
952 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
955 demux_program_t prog
;
958 case M_PROPERTY_STEP_UP
:
960 if (action
== M_PROPERTY_SET
&& arg
)
961 prog
.progid
= *((int *) arg
);
965 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
966 &prog
) == DEMUXER_CTRL_NOTIMPL
)
967 return M_PROPERTY_ERROR
;
969 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
970 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
971 return M_PROPERTY_OK
;
974 return M_PROPERTY_NOT_IMPLEMENTED
;
980 /// \defgroup VideoProperties Video properties
981 /// \ingroup Properties
984 /// Fullscreen state (RW)
985 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
989 if (!mpctx
->video_out
)
990 return M_PROPERTY_UNAVAILABLE
;
995 return M_PROPERTY_ERROR
;
996 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
997 if (vo_fs
== !!*(int *) arg
)
998 return M_PROPERTY_OK
;
999 case M_PROPERTY_STEP_UP
:
1000 case M_PROPERTY_STEP_DOWN
:
1003 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
1006 if (mpctx
->video_out
->config_ok
)
1007 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1008 return M_PROPERTY_OK
;
1010 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1014 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1015 void *arg
, MPContext
*mpctx
)
1019 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1020 return M_PROPERTY_UNAVAILABLE
;
1021 vf
= mpctx
->sh_video
->vfilter
;
1023 case M_PROPERTY_GET
:
1025 return M_PROPERTY_ERROR
;
1026 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1027 return M_PROPERTY_OK
;
1028 case M_PROPERTY_SET
:
1030 return M_PROPERTY_ERROR
;
1031 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1032 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1033 return M_PROPERTY_OK
;
1034 case M_PROPERTY_STEP_UP
:
1035 case M_PROPERTY_STEP_DOWN
:
1036 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1037 deinterlace
= !deinterlace
;
1038 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1039 return M_PROPERTY_OK
;
1041 return M_PROPERTY_NOT_IMPLEMENTED
;
1045 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1049 if (!mpctx
->video_out
1050 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1051 return M_PROPERTY_UNAVAILABLE
;
1054 case M_PROPERTY_SET
:
1056 return M_PROPERTY_ERROR
;
1057 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1058 vo_panscan
= *(float *) arg
;
1059 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1060 return M_PROPERTY_OK
;
1061 case M_PROPERTY_STEP_UP
:
1062 case M_PROPERTY_STEP_DOWN
:
1063 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1064 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1067 else if (vo_panscan
< 0)
1069 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1070 return M_PROPERTY_OK
;
1072 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1076 /// Helper to set vo flags.
1077 /** \ingroup PropertyImplHelper
1079 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1080 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1083 if (!mpctx
->video_out
)
1084 return M_PROPERTY_UNAVAILABLE
;
1087 case M_PROPERTY_SET
:
1089 return M_PROPERTY_ERROR
;
1090 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1091 if (*vo_var
== !!*(int *) arg
)
1092 return M_PROPERTY_OK
;
1093 case M_PROPERTY_STEP_UP
:
1094 case M_PROPERTY_STEP_DOWN
:
1095 if (mpctx
->video_out
->config_ok
)
1096 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1097 return M_PROPERTY_OK
;
1099 return m_property_flag(prop
, action
, arg
, vo_var
);
1103 /// Window always on top (RW)
1104 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1107 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1108 &mpctx
->opts
.vo_ontop
, mpctx
);
1111 /// Display in the root window (RW)
1112 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1115 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1116 &vo_rootwin
, mpctx
);
1119 /// Show window borders (RW)
1120 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1123 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1127 /// Framedropping state (RW)
1128 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1129 void *arg
, MPContext
*mpctx
)
1132 if (!mpctx
->sh_video
)
1133 return M_PROPERTY_UNAVAILABLE
;
1136 case M_PROPERTY_PRINT
:
1138 return M_PROPERTY_ERROR
;
1139 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1140 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1142 return M_PROPERTY_OK
;
1144 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1148 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1149 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1152 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1155 if (!mpctx
->sh_video
)
1156 return M_PROPERTY_UNAVAILABLE
;
1158 if (gamma
[0] == 1000) {
1160 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1164 case M_PROPERTY_SET
:
1166 return M_PROPERTY_ERROR
;
1167 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1168 *gamma
= *(int *) arg
;
1169 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1173 case M_PROPERTY_GET
:
1174 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1176 return M_PROPERTY_ERROR
;
1178 return M_PROPERTY_OK
;
1181 case M_PROPERTY_STEP_UP
:
1182 case M_PROPERTY_STEP_DOWN
:
1183 *gamma
+= (arg
? *(int *) arg
: 1) *
1184 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1185 M_PROPERTY_CLAMP(prop
, *gamma
);
1186 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1191 return M_PROPERTY_NOT_IMPLEMENTED
;
1195 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1196 int l
= strlen(prop
->name
);
1197 char tv_prop
[3 + l
+ 1];
1198 sprintf(tv_prop
, "tv_%s", prop
->name
);
1199 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1203 return M_PROPERTY_UNAVAILABLE
;
1207 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1210 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1213 /// Video codec tag (RO)
1214 static int mp_property_video_format(m_option_t
*prop
, int action
,
1215 void *arg
, MPContext
*mpctx
)
1218 if (!mpctx
->sh_video
)
1219 return M_PROPERTY_UNAVAILABLE
;
1221 case M_PROPERTY_PRINT
:
1223 return M_PROPERTY_ERROR
;
1224 switch(mpctx
->sh_video
->format
) {
1226 meta
= strdup ("mpeg1"); break;
1228 meta
= strdup ("mpeg2"); break;
1230 meta
= strdup ("mpeg4"); break;
1232 meta
= strdup ("h264"); break;
1234 if(mpctx
->sh_video
->format
>= 0x20202020) {
1236 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1239 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1242 *(char**)arg
= meta
;
1243 return M_PROPERTY_OK
;
1245 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1248 /// Video codec name (RO)
1249 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1250 void *arg
, MPContext
*mpctx
)
1252 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1253 return M_PROPERTY_UNAVAILABLE
;
1254 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1258 /// Video bitrate (RO)
1259 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1260 void *arg
, MPContext
*mpctx
)
1262 if (!mpctx
->sh_video
)
1263 return M_PROPERTY_UNAVAILABLE
;
1264 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1267 /// Video display width (RO)
1268 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1271 if (!mpctx
->sh_video
)
1272 return M_PROPERTY_UNAVAILABLE
;
1273 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1276 /// Video display height (RO)
1277 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1280 if (!mpctx
->sh_video
)
1281 return M_PROPERTY_UNAVAILABLE
;
1282 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1286 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1289 if (!mpctx
->sh_video
)
1290 return M_PROPERTY_UNAVAILABLE
;
1291 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1294 /// Video aspect (RO)
1295 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1298 if (!mpctx
->sh_video
)
1299 return M_PROPERTY_UNAVAILABLE
;
1300 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1305 /// \defgroup SubProprties Subtitles properties
1306 /// \ingroup Properties
1309 /// Text subtitle position (RW)
1310 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1313 if (!mpctx
->sh_video
)
1314 return M_PROPERTY_UNAVAILABLE
;
1317 case M_PROPERTY_SET
:
1319 return M_PROPERTY_ERROR
;
1320 case M_PROPERTY_STEP_UP
:
1321 case M_PROPERTY_STEP_DOWN
:
1322 vo_osd_changed(OSDTYPE_SUBTITLE
);
1324 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1328 /// Selected subtitles (RW)
1329 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1332 struct MPOpts
*opts
= &mpctx
->opts
;
1333 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1334 const int global_sub_size
= mpctx
->global_sub_size
;
1335 int source
= -1, reset_spu
= 0;
1338 if (global_sub_size
<= 0)
1339 return M_PROPERTY_UNAVAILABLE
;
1342 case M_PROPERTY_GET
:
1344 return M_PROPERTY_ERROR
;
1345 *(int *) arg
= mpctx
->global_sub_pos
;
1346 return M_PROPERTY_OK
;
1347 case M_PROPERTY_PRINT
:
1349 return M_PROPERTY_ERROR
;
1350 *(char **) arg
= malloc(64);
1351 (*(char **) arg
)[63] = 0;
1354 sub_name
= subdata
->filename
;
1356 if (ass_track
&& ass_track
->name
)
1357 sub_name
= ass_track
->name
;
1362 if ((tmp2
= strrchr(tmp
, '/')))
1365 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1366 mpctx
->set_of_sub_pos
+ 1,
1367 strlen(tmp
) < 20 ? "" : "...",
1368 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1369 return M_PROPERTY_OK
;
1371 #ifdef CONFIG_DVDNAV
1372 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1373 if (vo_spudec
&& opts
->sub_id
>= 0) {
1374 unsigned char lang
[3];
1375 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1376 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1377 return M_PROPERTY_OK
;
1383 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1384 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1385 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1386 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1387 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1388 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1389 if (!lang
) lang
= MSGTR_Unknown
;
1390 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1391 return M_PROPERTY_OK
;
1394 if (vo_vobsub
&& vobsub_id
>= 0) {
1395 const char *language
= MSGTR_Unknown
;
1396 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1397 snprintf(*(char **) arg
, 63, "(%d) %s",
1398 vobsub_id
, language
? language
: MSGTR_Unknown
);
1399 return M_PROPERTY_OK
;
1401 #ifdef CONFIG_DVDREAD
1402 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1403 && opts
->sub_id
>= 0) {
1405 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1406 lang
[0] = code
>> 8;
1409 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1410 return M_PROPERTY_OK
;
1413 if (opts
->sub_id
>= 0) {
1414 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, MSGTR_Unknown
);
1415 return M_PROPERTY_OK
;
1417 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1418 return M_PROPERTY_OK
;
1420 case M_PROPERTY_SET
:
1422 return M_PROPERTY_ERROR
;
1423 if (*(int *) arg
< -1)
1425 else if (*(int *) arg
>= global_sub_size
)
1426 *(int *) arg
= global_sub_size
- 1;
1427 mpctx
->global_sub_pos
= *(int *) arg
;
1429 case M_PROPERTY_STEP_UP
:
1430 mpctx
->global_sub_pos
+= 2;
1431 mpctx
->global_sub_pos
=
1432 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1434 case M_PROPERTY_STEP_DOWN
:
1435 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1436 mpctx
->global_sub_pos
=
1437 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1440 return M_PROPERTY_NOT_IMPLEMENTED
;
1443 if (mpctx
->global_sub_pos
>= 0)
1444 source
= sub_source(mpctx
);
1446 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1447 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1449 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1450 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1451 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1452 mpctx
->global_sub_pos
, source
);
1454 mpctx
->set_of_sub_pos
= -1;
1468 if (source
== SUB_SOURCE_VOBSUB
) {
1469 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1470 } else if (source
== SUB_SOURCE_SUBS
) {
1471 mpctx
->set_of_sub_pos
=
1472 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1474 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1475 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1479 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1480 vo_osd_changed(OSDTYPE_SUBTITLE
);
1482 } else if (source
== SUB_SOURCE_DEMUX
) {
1484 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1485 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1487 // default: assume 1:1 mapping of sid and stream id
1488 d_sub
->id
= opts
->sub_id
;
1489 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1490 ds_free_packs(d_sub
);
1491 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1492 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1493 if (sh
&& sh
->sid
== opts
->sub_id
) {
1499 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1500 sh_sub_t
*sh
= d_sub
->sh
;
1501 if (sh
->type
== 'v')
1502 init_vo_spudec(mpctx
);
1504 else if (ass_enabled
)
1505 ass_track
= sh
->ass_track
;
1513 #ifdef CONFIG_DVDREAD
1515 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1516 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1517 && opts
->sub_id
< 0 && reset_spu
) {
1519 d_sub
->id
= opts
->sub_id
;
1522 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1524 return M_PROPERTY_OK
;
1527 /// Selected sub source (RW)
1528 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1532 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1533 return M_PROPERTY_UNAVAILABLE
;
1536 case M_PROPERTY_GET
:
1538 return M_PROPERTY_ERROR
;
1539 *(int *) arg
= sub_source(mpctx
);
1540 return M_PROPERTY_OK
;
1541 case M_PROPERTY_PRINT
:
1543 return M_PROPERTY_ERROR
;
1544 *(char **) arg
= malloc(64);
1545 (*(char **) arg
)[63] = 0;
1546 switch (sub_source(mpctx
))
1548 case SUB_SOURCE_SUBS
:
1549 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1551 case SUB_SOURCE_VOBSUB
:
1552 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1554 case SUB_SOURCE_DEMUX
:
1555 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1558 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1560 return M_PROPERTY_OK
;
1561 case M_PROPERTY_SET
:
1563 return M_PROPERTY_ERROR
;
1564 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1565 if (*(int *) arg
< 0)
1566 mpctx
->global_sub_pos
= -1;
1567 else if (*(int *) arg
!= sub_source(mpctx
)) {
1568 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1569 return M_PROPERTY_UNAVAILABLE
;
1570 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1573 case M_PROPERTY_STEP_UP
:
1574 case M_PROPERTY_STEP_DOWN
: {
1575 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1576 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1577 int step
= (step_all
> 0) ? 1 : -1;
1578 int cur_source
= sub_source(mpctx
);
1579 source
= cur_source
;
1582 if (source
>= SUB_SOURCES
)
1584 else if (source
< -1)
1585 source
= SUB_SOURCES
- 1;
1586 if (source
== cur_source
|| source
== -1 ||
1587 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1590 if (source
== cur_source
)
1591 return M_PROPERTY_OK
;
1593 mpctx
->global_sub_pos
= -1;
1595 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1599 return M_PROPERTY_NOT_IMPLEMENTED
;
1601 --mpctx
->global_sub_pos
;
1602 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1605 /// Selected subtitles from specific source (RW)
1606 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1609 int source
, is_cur_source
, offset
;
1610 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1611 return M_PROPERTY_UNAVAILABLE
;
1613 if (!strcmp(prop
->name
, "sub_file"))
1614 source
= SUB_SOURCE_SUBS
;
1615 else if (!strcmp(prop
->name
, "sub_vob"))
1616 source
= SUB_SOURCE_VOBSUB
;
1617 else if (!strcmp(prop
->name
, "sub_demux"))
1618 source
= SUB_SOURCE_DEMUX
;
1620 return M_PROPERTY_ERROR
;
1622 offset
= mpctx
->global_sub_indices
[source
];
1623 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1624 return M_PROPERTY_UNAVAILABLE
;
1626 is_cur_source
= sub_source(mpctx
) == source
;
1628 case M_PROPERTY_GET
:
1630 return M_PROPERTY_ERROR
;
1631 if (is_cur_source
) {
1632 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1633 if (source
== SUB_SOURCE_VOBSUB
)
1634 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1638 return M_PROPERTY_OK
;
1639 case M_PROPERTY_PRINT
:
1641 return M_PROPERTY_ERROR
;
1643 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1644 *(char **) arg
= malloc(64);
1645 (*(char **) arg
)[63] = 0;
1646 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1647 return M_PROPERTY_OK
;
1648 case M_PROPERTY_SET
:
1650 return M_PROPERTY_ERROR
;
1651 if (*(int *) arg
>= 0) {
1652 int index
= *(int *)arg
;
1653 if (source
== SUB_SOURCE_VOBSUB
)
1654 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1655 mpctx
->global_sub_pos
= offset
+ index
;
1656 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1657 || sub_source(mpctx
) != source
) {
1658 mpctx
->global_sub_pos
= -1;
1663 mpctx
->global_sub_pos
= -1;
1665 case M_PROPERTY_STEP_UP
:
1666 case M_PROPERTY_STEP_DOWN
: {
1667 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1668 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1669 int step
= (step_all
> 0) ? 1 : -1;
1670 int max_sub_pos_for_source
= -1;
1672 mpctx
->global_sub_pos
= -1;
1674 if (mpctx
->global_sub_pos
== -1) {
1676 mpctx
->global_sub_pos
= offset
;
1677 else if (max_sub_pos_for_source
== -1) {
1678 // Find max pos for specific source
1679 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1680 while (mpctx
->global_sub_pos
>= 0
1681 && sub_source(mpctx
) != source
)
1682 --mpctx
->global_sub_pos
;
1685 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1688 mpctx
->global_sub_pos
+= step
;
1689 if (mpctx
->global_sub_pos
< offset
||
1690 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1691 sub_source(mpctx
) != source
)
1692 mpctx
->global_sub_pos
= -1;
1699 return M_PROPERTY_NOT_IMPLEMENTED
;
1701 --mpctx
->global_sub_pos
;
1702 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1705 /// Subtitle delay (RW)
1706 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1709 if (!mpctx
->sh_video
)
1710 return M_PROPERTY_UNAVAILABLE
;
1711 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1714 /// Alignment of text subtitles (RW)
1715 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1716 void *arg
, MPContext
*mpctx
)
1718 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1720 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1721 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1722 return M_PROPERTY_UNAVAILABLE
;
1725 case M_PROPERTY_PRINT
:
1727 return M_PROPERTY_ERROR
;
1728 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1729 *(char **) arg
= strdup(name
[sub_alignment
]);
1730 return M_PROPERTY_OK
;
1731 case M_PROPERTY_SET
:
1733 return M_PROPERTY_ERROR
;
1734 case M_PROPERTY_STEP_UP
:
1735 case M_PROPERTY_STEP_DOWN
:
1736 vo_osd_changed(OSDTYPE_SUBTITLE
);
1738 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1742 /// Subtitle visibility (RW)
1743 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1744 void *arg
, MPContext
*mpctx
)
1746 if (!mpctx
->sh_video
)
1747 return M_PROPERTY_UNAVAILABLE
;
1750 case M_PROPERTY_SET
:
1752 return M_PROPERTY_ERROR
;
1753 case M_PROPERTY_STEP_UP
:
1754 case M_PROPERTY_STEP_DOWN
:
1755 vo_osd_changed(OSDTYPE_SUBTITLE
);
1757 vo_osd_changed(OSDTYPE_SPU
);
1759 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1764 /// Use margins for libass subtitles (RW)
1765 static int mp_property_ass_use_margins(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 ass_force_reload
= 1;
1779 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1784 /// Show only forced subtitles (RW)
1785 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1786 void *arg
, MPContext
*mpctx
)
1789 return M_PROPERTY_UNAVAILABLE
;
1792 case M_PROPERTY_SET
:
1794 return M_PROPERTY_ERROR
;
1795 case M_PROPERTY_STEP_UP
:
1796 case M_PROPERTY_STEP_DOWN
:
1797 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1798 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1799 return M_PROPERTY_OK
;
1801 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1806 #ifdef CONFIG_FREETYPE
1807 /// Subtitle scale (RW)
1808 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1813 case M_PROPERTY_SET
:
1815 return M_PROPERTY_ERROR
;
1816 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1819 ass_font_scale
= *(float *) arg
;
1820 ass_force_reload
= 1;
1823 text_font_scale_factor
= *(float *) arg
;
1824 force_load_font
= 1;
1825 return M_PROPERTY_OK
;
1826 case M_PROPERTY_STEP_UP
:
1827 case M_PROPERTY_STEP_DOWN
:
1830 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1831 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1832 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1833 ass_force_reload
= 1;
1836 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1837 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1838 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1839 force_load_font
= 1;
1840 return M_PROPERTY_OK
;
1844 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1847 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1854 /// \defgroup TVProperties TV properties
1855 /// \ingroup Properties
1860 /// TV color settings (RW)
1861 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1865 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1866 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1867 return M_PROPERTY_UNAVAILABLE
;
1870 case M_PROPERTY_SET
:
1872 return M_PROPERTY_ERROR
;
1873 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1874 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1875 case M_PROPERTY_GET
:
1876 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1877 case M_PROPERTY_STEP_UP
:
1878 case M_PROPERTY_STEP_DOWN
:
1879 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1881 return M_PROPERTY_ERROR
;
1882 val
+= (arg
? *(int *) arg
: 1) *
1883 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1884 M_PROPERTY_CLAMP(prop
, val
);
1885 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1887 return M_PROPERTY_ERROR
;
1889 return M_PROPERTY_NOT_IMPLEMENTED
;
1894 #ifdef CONFIG_TV_TELETEXT
1895 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1899 int base_ioctl
=(int)prop
->priv
;
1901 for teletext's GET,SET,STEP ioctls this is not 0
1905 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1906 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1907 return M_PROPERTY_UNAVAILABLE
;
1909 return M_PROPERTY_ERROR
;
1912 case M_PROPERTY_GET
:
1914 return M_PROPERTY_ERROR
;
1915 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1917 case M_PROPERTY_SET
:
1919 return M_PROPERTY_ERROR
;
1920 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1921 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1923 case M_PROPERTY_STEP_UP
:
1924 case M_PROPERTY_STEP_DOWN
:
1925 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1926 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1927 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1930 return M_PROPERTY_NOT_IMPLEMENTED
;
1933 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1936 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1939 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1943 //with tvh==NULL will fail too
1944 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1945 if(result
!=M_PROPERTY_OK
)
1948 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1949 mp_input_set_section(mpctx
->input
, "teletext");
1951 mp_input_set_section(mpctx
->input
, "tv");
1952 return M_PROPERTY_OK
;
1955 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1958 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1961 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1962 return M_PROPERTY_UNAVAILABLE
;
1964 case M_PROPERTY_STEP_UP
:
1965 case M_PROPERTY_STEP_DOWN
:
1966 //This should be handled separately
1967 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1968 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1971 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1977 #endif /* CONFIG_TV_TELETEXT */
1981 /// All properties available in MPlayer.
1982 /** \ingroup Properties
1984 static const m_option_t mp_properties
[] = {
1986 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1987 M_OPT_RANGE
, 0, 3, NULL
},
1988 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1989 M_OPT_MIN
, -1, 0, NULL
},
1990 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1991 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1992 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1994 { "path", mp_property_path
, CONF_TYPE_STRING
,
1996 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1998 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1999 M_OPT_MIN
, 0, 0, NULL
},
2000 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2001 M_OPT_MIN
, 0, 0, NULL
},
2002 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2003 M_OPT_MIN
, 0, 0, NULL
},
2004 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2005 M_OPT_MIN
, 0, 0, NULL
},
2006 { "length", mp_property_length
, CONF_TYPE_TIME
,
2007 M_OPT_MIN
, 0, 0, NULL
},
2008 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2009 M_OPT_RANGE
, 0, 100, NULL
},
2010 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2011 M_OPT_MIN
, 0, 0, NULL
},
2012 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2013 M_OPT_MIN
, 1, 0, NULL
},
2014 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2016 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2017 CONF_RANGE
, -2, 10, NULL
},
2018 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2020 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2021 M_OPT_RANGE
, 0, 1, NULL
},
2024 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2025 M_OPT_RANGE
, 0, 100, NULL
},
2026 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2027 M_OPT_RANGE
, 0, 1, NULL
},
2028 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2029 M_OPT_RANGE
, -100, 100, NULL
},
2030 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2032 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2034 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2036 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2038 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2040 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2041 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2042 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2043 M_OPT_RANGE
, -1, 1, NULL
},
2046 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2047 M_OPT_RANGE
, 0, 1, NULL
},
2048 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2049 M_OPT_RANGE
, 0, 1, NULL
},
2050 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2051 M_OPT_RANGE
, 0, 1, NULL
},
2052 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2053 M_OPT_RANGE
, 0, 1, NULL
},
2054 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2055 M_OPT_RANGE
, 0, 1, NULL
},
2056 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2057 M_OPT_RANGE
, 0, 2, NULL
},
2058 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2059 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2060 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2061 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2062 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2063 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2064 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2065 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2066 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2067 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2068 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2069 M_OPT_RANGE
, 0, 1, NULL
},
2070 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2071 M_OPT_RANGE
, 0, 1, NULL
},
2072 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2074 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2076 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2078 { "width", mp_property_width
, CONF_TYPE_INT
,
2080 { "height", mp_property_height
, CONF_TYPE_INT
,
2082 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2084 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2086 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2087 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2088 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2089 CONF_RANGE
, -1, 65535, NULL
},
2092 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2093 M_OPT_MIN
, -1, 0, NULL
},
2094 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2095 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2096 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2097 M_OPT_MIN
, -1, 0, NULL
},
2098 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2099 M_OPT_MIN
, -1, 0, NULL
},
2100 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2101 M_OPT_MIN
, -1, 0, NULL
},
2102 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2104 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2105 M_OPT_RANGE
, 0, 100, NULL
},
2106 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2107 M_OPT_RANGE
, 0, 2, NULL
},
2108 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2109 M_OPT_RANGE
, 0, 1, NULL
},
2110 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2111 M_OPT_RANGE
, 0, 1, NULL
},
2112 #ifdef CONFIG_FREETYPE
2113 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2114 M_OPT_RANGE
, 0, 100, NULL
},
2117 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2118 M_OPT_RANGE
, 0, 1, NULL
},
2122 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2123 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2124 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2125 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2126 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2127 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2128 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2129 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2132 #ifdef CONFIG_TV_TELETEXT
2133 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2134 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2135 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2136 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2137 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2138 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2139 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2140 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2141 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2142 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2145 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2149 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2151 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2154 char* mp_property_print(const char *name
, void* ctx
)
2157 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2162 char *property_expand_string(MPContext
*mpctx
, char *str
)
2164 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2167 void property_print_help(void)
2169 m_properties_print_help_list(mp_properties
);
2178 * \defgroup Command2Property Command to property bridge
2180 * It is used to handle most commands that just set a property
2181 * and optionally display something on the OSD.
2182 * Two kinds of commands are handled: adjust or toggle.
2184 * Adjust commands take 1 or 2 parameters: <value> <abs>
2185 * If <abs> is non-zero the property is set to the given value
2186 * otherwise it is adjusted.
2188 * Toggle commands take 0 or 1 parameters. With no parameter
2189 * or a value less than the property minimum it just steps the
2190 * property to its next value. Otherwise it sets it to the given
2196 /// List of the commands that can be handled by setting a property.
2202 /// set/adjust or toggle command
2204 /// progressbar type
2206 /// osd msg id if it must be shared
2208 /// osd msg template
2209 const char *osd_msg
;
2210 } set_prop_cmd
[] = {
2212 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2213 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2214 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2216 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2217 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2218 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2219 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2220 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2222 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2223 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2224 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2225 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2226 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2227 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2228 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2229 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2230 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2231 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2232 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2233 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2235 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2236 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2237 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2238 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2239 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2240 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2241 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2242 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2243 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2244 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2245 #ifdef CONFIG_FREETYPE
2246 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2249 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2252 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2253 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2254 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2255 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2257 { NULL
, 0, 0, 0, -1, NULL
}
2261 /// Handle commands that set a property.
2262 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2268 // look for the command
2269 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2270 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2272 if (!(pname
= set_prop_cmd
[i
].name
))
2275 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2279 if (set_prop_cmd
[i
].toggle
) {
2281 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2282 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2284 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2285 } else if (cmd
->args
[1].v
.i
) //set
2286 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2288 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2293 if (set_prop_cmd
[i
].osd_progbar
) {
2294 if (prop
->type
== CONF_TYPE_INT
) {
2295 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2296 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2297 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2298 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2300 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2301 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2302 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2304 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2305 "Property use an unsupported type.\n");
2309 if (set_prop_cmd
[i
].osd_msg
) {
2310 char *val
= mp_property_print(pname
, mpctx
);
2312 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2313 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2314 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2321 #ifdef CONFIG_DVDNAV
2322 static const struct {
2324 const mp_command_type cmd
;
2325 } mp_dvdnav_bindings
[] = {
2326 { "up", MP_CMD_DVDNAV_UP
},
2327 { "down", MP_CMD_DVDNAV_DOWN
},
2328 { "left", MP_CMD_DVDNAV_LEFT
},
2329 { "right", MP_CMD_DVDNAV_RIGHT
},
2330 { "menu", MP_CMD_DVDNAV_MENU
},
2331 { "select", MP_CMD_DVDNAV_SELECT
},
2332 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2333 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2336 * keep old dvdnav sub-command options for a while in order not to
2337 * break slave-mode API too suddenly.
2339 { "1", MP_CMD_DVDNAV_UP
},
2340 { "2", MP_CMD_DVDNAV_DOWN
},
2341 { "3", MP_CMD_DVDNAV_LEFT
},
2342 { "4", MP_CMD_DVDNAV_RIGHT
},
2343 { "5", MP_CMD_DVDNAV_MENU
},
2344 { "6", MP_CMD_DVDNAV_SELECT
},
2345 { "7", MP_CMD_DVDNAV_PREVMENU
},
2346 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2351 int run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2353 struct MPOpts
*opts
= &mpctx
->opts
;
2354 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2355 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2357 if (!set_property_command(mpctx
, cmd
))
2363 mpctx
->osd_show_percentage
= sh_video
->fps
;
2364 v
= cmd
->args
[0].v
.f
;
2365 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2366 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2367 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2369 mpctx
->osd_function
=
2370 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2371 mpctx
->rel_seek_secs
= v
;
2372 } else if (abs
) { /* Absolute seek by percentage */
2373 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2375 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2376 mpctx
->rel_seek_secs
= v
/ 100.0;
2378 mpctx
->rel_seek_secs
+= v
;
2379 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2385 case MP_CMD_SET_PROPERTY
:{
2386 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2387 cmd
->args
[1].v
.s
, mpctx
);
2388 if (r
== M_PROPERTY_UNKNOWN
)
2389 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2390 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2392 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2393 "Failed to set property '%s' to '%s'.\n",
2394 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2398 case MP_CMD_STEP_PROPERTY
:{
2403 if (cmd
->args
[1].v
.f
) {
2405 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2406 M_PROPERTY_GET_TYPE
,
2407 &prop
, mpctx
)) <= 0)
2409 if(prop
->type
== CONF_TYPE_INT
||
2410 prop
->type
== CONF_TYPE_FLAG
)
2411 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2412 else if(prop
->type
== CONF_TYPE_FLOAT
)
2413 arg
= &cmd
->args
[1].v
.f
;
2414 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2415 prop
->type
== CONF_TYPE_TIME
)
2416 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2417 else if(prop
->type
== CONF_TYPE_POSITION
)
2418 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2420 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2421 "Ignoring step size stepping property '%s'.\n",
2424 r
= mp_property_do(cmd
->args
[0].v
.s
,
2425 cmd
->args
[2].v
.i
< 0 ?
2426 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2429 if (r
== M_PROPERTY_UNKNOWN
)
2430 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2431 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2433 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2434 "Failed to increment property '%s' by %f.\n",
2435 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2439 case MP_CMD_GET_PROPERTY
:{
2441 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2442 &tmp
, mpctx
) <= 0) {
2443 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2444 "Failed to get value of property '%s'.\n",
2448 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2449 cmd
->args
[0].v
.s
, tmp
);
2454 case MP_CMD_EDL_MARK
:
2456 float v
= sh_video
? sh_video
->pts
:
2457 playing_audio_pts(mpctx
);
2458 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2459 mpctx
->begin_skip
= v
;
2460 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2462 if (mpctx
->begin_skip
> v
)
2463 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2465 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2466 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2468 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2473 case MP_CMD_SWITCH_RATIO
:
2474 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2475 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2477 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2478 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2481 case MP_CMD_SPEED_INCR
:{
2482 float v
= cmd
->args
[0].v
.f
;
2483 opts
->playback_speed
+= v
;
2484 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2485 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2486 opts
->playback_speed
);
2489 case MP_CMD_SPEED_MULT
:{
2490 float v
= cmd
->args
[0].v
.f
;
2491 opts
->playback_speed
*= v
;
2492 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2493 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2494 opts
->playback_speed
);
2497 case MP_CMD_SPEED_SET
:{
2498 float v
= cmd
->args
[0].v
.f
;
2499 opts
->playback_speed
= v
;
2500 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2501 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2502 opts
->playback_speed
);
2505 case MP_CMD_FRAME_STEP
:
2511 case MP_CMD_FILE_FILTER
:
2512 file_filter
= cmd
->args
[0].v
.i
;
2516 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2517 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2519 case MP_CMD_PLAY_TREE_STEP
:{
2520 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2521 int force
= cmd
->args
[1].v
.i
;
2527 for (i
= 0; i
< n
; i
++)
2530 for (i
= 0; i
< -1 * n
; i
++)
2535 if (!force
&& mpctx
->playtree_iter
) {
2536 play_tree_iter_t
*i
=
2537 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2538 if (play_tree_iter_step(i
, n
, 0) ==
2539 PLAY_TREE_ITER_ENTRY
)
2541 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2542 play_tree_iter_free(i
);
2544 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2545 if (mpctx
->stop_play
)
2546 mpctx
->play_tree_step
= n
;
2552 case MP_CMD_PLAY_TREE_UP_STEP
:{
2553 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2554 int force
= cmd
->args
[1].v
.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_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2560 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2561 play_tree_iter_free(i
);
2563 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2568 case MP_CMD_PLAY_ALT_SRC_STEP
:
2569 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2570 int v
= cmd
->args
[0].v
.i
;
2572 && mpctx
->playtree_iter
->file
<
2573 mpctx
->playtree_iter
->num_files
)
2574 mpctx
->stop_play
= PT_NEXT_SRC
;
2575 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2576 mpctx
->stop_play
= PT_PREV_SRC
;
2581 case MP_CMD_SUB_STEP
:
2583 int movement
= cmd
->args
[0].v
.i
;
2584 step_sub(subdata
, sh_video
->pts
, movement
);
2588 ass_step_sub(ass_track
,
2590 sub_delay
) * 1000 + .5, movement
) / 1000.;
2592 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2593 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2597 case MP_CMD_SUB_LOG
:
2602 int v
= cmd
->args
[0].v
.i
;
2604 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2605 if (osd_level
> max
)
2608 osd_level
= (osd_level
+ 1) % (max
+ 1);
2610 osd_level
= v
> max
? max
: v
;
2611 /* Show OSD state when disabled, but not when an explicit
2612 argument is given to the OSD command, i.e. in slave mode. */
2613 if (v
== -1 && osd_level
<= 1)
2614 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2616 osd_level
? MSGTR_OSDenabled
:
2619 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2623 case MP_CMD_OSD_SHOW_TEXT
:
2624 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2626 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2627 "%-.63s", cmd
->args
[0].v
.s
);
2630 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2631 char *txt
= m_properties_expand_string(mp_properties
,
2634 /* if no argument supplied take default osd_duration, else <arg> ms. */
2636 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2638 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2645 case MP_CMD_LOADFILE
:{
2646 play_tree_t
*e
= play_tree_new();
2647 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2649 if (cmd
->args
[1].v
.i
) // append
2650 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2652 // Go back to the starting point.
2653 while (play_tree_iter_up_step
2654 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2656 play_tree_free_list(mpctx
->playtree
->child
, 1);
2657 play_tree_set_child(mpctx
->playtree
, e
);
2658 pt_iter_goto_head(mpctx
->playtree_iter
);
2659 mpctx
->stop_play
= PT_NEXT_SRC
;
2665 case MP_CMD_LOADLIST
:{
2666 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2668 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2669 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2671 if (cmd
->args
[1].v
.i
) // append
2672 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2674 // Go back to the starting point.
2675 while (play_tree_iter_up_step
2676 (mpctx
->playtree_iter
, 0, 1)
2677 != PLAY_TREE_ITER_END
)
2679 play_tree_free_list(mpctx
->playtree
->child
, 1);
2680 play_tree_set_child(mpctx
->playtree
, e
);
2681 pt_iter_goto_head(mpctx
->playtree_iter
);
2682 mpctx
->stop_play
= PT_NEXT_SRC
;
2690 // Go back to the starting point.
2691 while (play_tree_iter_up_step
2692 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2694 mpctx
->stop_play
= PT_STOP
;
2699 case MP_CMD_RADIO_STEP_CHANNEL
:
2700 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2701 int v
= cmd
->args
[0].v
.i
;
2703 radio_step_channel(mpctx
->demuxer
->stream
,
2704 RADIO_CHANNEL_HIGHER
);
2706 radio_step_channel(mpctx
->demuxer
->stream
,
2707 RADIO_CHANNEL_LOWER
);
2708 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2709 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2711 radio_get_channel_name(mpctx
->demuxer
->stream
));
2716 case MP_CMD_RADIO_SET_CHANNEL
:
2717 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2718 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2719 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2720 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2722 radio_get_channel_name(mpctx
->demuxer
->stream
));
2727 case MP_CMD_RADIO_SET_FREQ
:
2728 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2729 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2732 case MP_CMD_RADIO_STEP_FREQ
:
2733 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2734 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2739 case MP_CMD_TV_START_SCAN
:
2740 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2741 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2743 case MP_CMD_TV_SET_FREQ
:
2744 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2745 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2746 cmd
->args
[0].v
.f
* 16.0);
2748 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2749 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2750 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2751 pvr_get_current_channelname (mpctx
->stream
),
2752 pvr_get_current_stationname (mpctx
->stream
));
2754 #endif /* CONFIG_PVR */
2757 case MP_CMD_TV_STEP_FREQ
:
2758 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2759 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2760 cmd
->args
[0].v
.f
* 16.0);
2762 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2763 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2764 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2765 pvr_get_current_channelname (mpctx
->stream
),
2766 pvr_get_current_frequency (mpctx
->stream
));
2768 #endif /* CONFIG_PVR */
2771 case MP_CMD_TV_SET_NORM
:
2772 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2773 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2777 case MP_CMD_TV_STEP_CHANNEL
:{
2778 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2779 int v
= cmd
->args
[0].v
.i
;
2781 tv_step_channel((tvi_handle_t
*) (mpctx
->
2785 tv_step_channel((tvi_handle_t
*) (mpctx
->
2789 if (tv_channel_list
) {
2790 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2791 MSGTR_OSDChannel
, tv_channel_current
->name
);
2792 //vo_osd_changed(OSDTYPE_SUBTITLE);
2796 else if (mpctx
->stream
&&
2797 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2798 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2799 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2800 pvr_get_current_channelname (mpctx
->stream
),
2801 pvr_get_current_stationname (mpctx
->stream
));
2803 #endif /* CONFIG_PVR */
2806 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2808 int v
= cmd
->args
[0].v
.i
;
2810 mpctx
->last_dvb_step
= v
;
2812 dir
= DVB_CHANNEL_HIGHER
;
2814 dir
= DVB_CHANNEL_LOWER
;
2817 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2818 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2819 mpctx
->dvbin_reopen
= 1;
2822 #endif /* CONFIG_DVBIN */
2825 case MP_CMD_TV_SET_CHANNEL
:
2826 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2827 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2829 if (tv_channel_list
) {
2830 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2831 MSGTR_OSDChannel
, tv_channel_current
->name
);
2832 //vo_osd_changed(OSDTYPE_SUBTITLE);
2836 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2837 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2838 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2839 pvr_get_current_channelname (mpctx
->stream
),
2840 pvr_get_current_stationname (mpctx
->stream
));
2842 #endif /* CONFIG_PVR */
2846 case MP_CMD_DVB_SET_CHANNEL
:
2847 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2848 mpctx
->last_dvb_step
= 1;
2850 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2851 cmd
->args
[0].v
.i
)) {
2852 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2853 mpctx
->dvbin_reopen
= 1;
2857 #endif /* CONFIG_DVBIN */
2859 case MP_CMD_TV_LAST_CHANNEL
:
2860 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2861 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2862 if (tv_channel_list
) {
2863 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2864 MSGTR_OSDChannel
, tv_channel_current
->name
);
2865 //vo_osd_changed(OSDTYPE_SUBTITLE);
2869 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2870 pvr_set_lastchannel (mpctx
->stream
);
2871 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2872 pvr_get_current_channelname (mpctx
->stream
),
2873 pvr_get_current_stationname (mpctx
->stream
));
2875 #endif /* CONFIG_PVR */
2878 case MP_CMD_TV_STEP_NORM
:
2879 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2880 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2883 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2884 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2885 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2887 #ifdef CONFIG_TV_TELETEXT
2888 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2890 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2891 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2892 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2895 case MP_CMD_TV_TELETEXT_GO_LINK
:
2897 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2898 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2899 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2902 #endif /* CONFIG_TV_TELETEXT */
2903 #endif /* CONFIG_TV */
2905 case MP_CMD_SUB_LOAD
:
2907 int n
= mpctx
->set_of_sub_size
;
2908 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2909 if (n
!= mpctx
->set_of_sub_size
) {
2910 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2911 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2912 mpctx
->global_sub_size
;
2913 ++mpctx
->global_sub_size
;
2918 case MP_CMD_SUB_REMOVE
:
2920 int v
= cmd
->args
[0].v
.i
;
2923 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2924 subd
= mpctx
->set_of_subtitles
[v
];
2925 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2926 MSGTR_RemovedSubtitleFile
, v
+ 1,
2927 filename_recode(subd
->filename
));
2929 mpctx
->set_of_subtitles
[v
] = NULL
;
2931 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2932 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2933 mpctx
->set_of_sub_size
= 0;
2934 if (mpctx
->set_of_sub_pos
>= 0) {
2935 mpctx
->global_sub_pos
= -2;
2937 mp_input_queue_cmd(mpctx
->input
,
2938 mp_input_parse_cmd("sub_select"));
2940 } else if (v
< mpctx
->set_of_sub_size
) {
2941 subd
= mpctx
->set_of_subtitles
[v
];
2942 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2943 MSGTR_RemovedSubtitleFile
, v
+ 1,
2944 filename_recode(subd
->filename
));
2946 if (mpctx
->set_of_sub_pos
== v
) {
2947 mpctx
->global_sub_pos
= -2;
2949 mp_input_queue_cmd(mpctx
->input
,
2950 mp_input_parse_cmd("sub_select"));
2951 } else if (mpctx
->set_of_sub_pos
> v
) {
2952 --mpctx
->set_of_sub_pos
;
2953 --mpctx
->global_sub_pos
;
2955 while (++v
< mpctx
->set_of_sub_size
)
2956 mpctx
->set_of_subtitles
[v
- 1] =
2957 mpctx
->set_of_subtitles
[v
];
2958 --mpctx
->set_of_sub_size
;
2959 --mpctx
->global_sub_size
;
2960 if (mpctx
->set_of_sub_size
<= 0)
2961 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2962 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2967 case MP_CMD_GET_SUB_VISIBILITY
:
2969 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2970 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2974 case MP_CMD_SCREENSHOT
:
2975 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2976 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2978 ((vf_instance_t
*) sh_video
->vfilter
)->
2979 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2981 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2985 case MP_CMD_VF_CHANGE_RECTANGLE
:
2986 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2989 case MP_CMD_GET_TIME_LENGTH
:{
2990 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2991 demuxer_get_time_length(mpctx
->demuxer
));
2995 case MP_CMD_GET_FILENAME
:{
2996 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2997 get_metadata(mpctx
, META_NAME
));
3001 case MP_CMD_GET_VIDEO_CODEC
:{
3002 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3005 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3010 case MP_CMD_GET_VIDEO_BITRATE
:{
3011 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3014 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3019 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3020 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3023 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3024 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3029 case MP_CMD_GET_AUDIO_CODEC
:{
3030 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3033 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3038 case MP_CMD_GET_AUDIO_BITRATE
:{
3039 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3042 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3047 case MP_CMD_GET_AUDIO_SAMPLES
:{
3048 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3051 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3056 case MP_CMD_GET_META_TITLE
:{
3057 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3060 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3065 case MP_CMD_GET_META_ARTIST
:{
3066 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3069 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3074 case MP_CMD_GET_META_ALBUM
:{
3075 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3078 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3083 case MP_CMD_GET_META_YEAR
:{
3084 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3087 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3092 case MP_CMD_GET_META_COMMENT
:{
3093 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3096 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3101 case MP_CMD_GET_META_TRACK
:{
3102 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3105 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3110 case MP_CMD_GET_META_GENRE
:{
3111 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3114 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3119 case MP_CMD_GET_VO_FULLSCREEN
:
3120 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3121 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3124 case MP_CMD_GET_PERCENT_POS
:
3125 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3126 demuxer_get_percent_pos(mpctx
->demuxer
));
3129 case MP_CMD_GET_TIME_POS
:{
3132 pos
= sh_video
->pts
;
3133 else if (sh_audio
&& mpctx
->audio_out
)
3134 pos
= playing_audio_pts(mpctx
);
3135 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3142 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3148 case MP_CMD_KEYDOWN_EVENTS
:
3149 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3152 case MP_CMD_SET_MOUSE_POS
:{
3153 int pointer_x
, pointer_y
;
3155 pointer_x
= cmd
->args
[0].v
.i
;
3156 pointer_y
= cmd
->args
[1].v
.i
;
3157 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3158 #ifdef CONFIG_DVDNAV
3159 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3160 && dx
> 0.0 && dy
> 0.0) {
3162 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3163 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3164 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3165 pointer_x
, pointer_y
, &button
);
3166 if (osd_level
> 1 && button
> 0)
3167 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3168 "Selected button number %d", button
);
3172 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3173 menu_update_mouse_pos(dx
, dy
);
3178 #ifdef CONFIG_DVDNAV
3179 case MP_CMD_DVDNAV
:{
3182 mp_command_type command
= 0;
3183 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3186 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3187 if (cmd
->args
[0].v
.s
&&
3188 !strcasecmp (cmd
->args
[0].v
.s
,
3189 mp_dvdnav_bindings
[i
].name
))
3190 command
= mp_dvdnav_bindings
[i
].cmd
;
3192 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3193 if (osd_level
> 1 && button
> 0)
3194 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3195 "Selected button number %d", button
);
3199 case MP_CMD_SWITCH_TITLE
:
3200 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3201 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3208 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3209 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3212 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3213 "Received unknown cmd %s\n", cmd
->name
);
3216 switch (cmd
->pausing
) {
3217 case 1: // "pausing"
3218 mpctx
->osd_function
= OSD_PAUSE
;
3220 case 3: // "pausing_toggle"
3221 mpctx
->was_paused
= !mpctx
->was_paused
;
3222 if (mpctx
->was_paused
)
3223 mpctx
->osd_function
= OSD_PAUSE
;
3224 else if (mpctx
->osd_function
== OSD_PAUSE
)
3225 mpctx
->osd_function
= OSD_PLAY
;
3227 case 2: // "pausing_keep"
3228 if (mpctx
->was_paused
)
3229 mpctx
->osd_function
= OSD_PAUSE
;