10 #include "input/input.h"
11 #include "stream/stream.h"
12 #include "libmpdemux/demuxer.h"
13 #include "libmpdemux/stheader.h"
14 #include "codec-cfg.h"
16 #include "libvo/sub.h"
18 #include "m_property.h"
21 #include "libmpcodecs/vf.h"
22 #include "libmpcodecs/vd.h"
24 #include "libvo/video_out.h"
25 #include "libvo/font_load.h"
27 #include "libao2/audio_out.h"
30 #include "libmpcodecs/dec_video.h"
36 #include "stream/tv.h"
39 #include "stream/stream_radio.h"
42 #include "stream/pvr.h"
45 #include "stream/dvbin.h"
48 #include "stream/stream_dvd.h"
51 #include "stream/stream_dvdnav.h"
55 #include "libmenu/menu.h"
60 #include "libavutil/avstring.h"
62 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
66 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
67 double *dx
, double *dy
)
69 struct MPOpts
*opts
= &mpctx
->opts
;
70 struct vo
*vo
= mpctx
->video_out
;
71 //remove the borders, if any, and rescale to the range [0,1],[0,1]
72 if (vo_fs
) { //we are in full-screen mode
73 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
74 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
75 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
76 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
78 if (ix
< 0 || ix
> vo
->dwidth
) {
81 } //we are on one of the borders
82 if (iy
< 0 || iy
> vo
->dheight
) {
85 } //we are on one of the borders
88 *dx
= (double) ix
/ (double) vo
->dwidth
;
89 *dy
= (double) iy
/ (double) vo
->dheight
;
91 mp_msg(MSGT_CPLAYER
, MSGL_V
,
92 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
93 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
97 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
102 for (i
= 0; i
< SUB_SOURCES
; i
++) {
103 int j
= mpctx
->global_sub_indices
[i
];
104 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
112 static int sub_source(MPContext
*mpctx
)
114 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
118 * \brief Log the currently displayed subtitle to a file
120 * Logs the current or last displayed subtitle together with filename
121 * and time information to ~/.mplayer/subtitle_log
123 * Intended purpose is to allow convenient marking of bogus subtitles
124 * which need to be fixed while watching the movie.
127 static void log_sub(struct MPContext
*mpctx
)
133 if (subdata
== NULL
|| vo_sub_last
== NULL
)
135 fname
= get_path("subtitle_log");
136 f
= fopen(fname
, "a");
139 fprintf(f
, "----------------------------------------------------------\n");
140 if (subdata
->sub_uses_time
) {
142 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
143 mpctx
->filename
, vo_sub_last
->start
/ 360000,
144 (vo_sub_last
->start
/ 6000) % 60,
145 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
146 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
147 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
149 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
150 vo_sub_last
->start
, vo_sub_last
->end
);
152 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
153 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
159 /// \defgroup Properties
162 /// \defgroup GeneralProperties General properties
163 /// \ingroup Properties
167 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
170 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
174 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
177 struct MPOpts
*opts
= &mpctx
->opts
;
179 case M_PROPERTY_PRINT
:
180 if (!arg
) return M_PROPERTY_ERROR
;
181 if (opts
->loop_times
< 0)
182 *(char**)arg
= strdup("off");
183 else if (opts
->loop_times
== 0)
184 *(char**)arg
= strdup("inf");
187 return M_PROPERTY_OK
;
189 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
192 /// Playback speed (RW)
193 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
194 void *arg
, MPContext
*mpctx
)
196 struct MPOpts
*opts
= &mpctx
->opts
;
200 return M_PROPERTY_ERROR
;
201 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
202 opts
->playback_speed
= *(float *) arg
;
203 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
204 return M_PROPERTY_OK
;
205 case M_PROPERTY_STEP_UP
:
206 case M_PROPERTY_STEP_DOWN
:
207 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
208 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
209 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
210 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
211 return M_PROPERTY_OK
;
213 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
216 /// filename with path (RO)
217 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
220 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
223 /// filename without path (RO)
224 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
228 if (!mpctx
->filename
)
229 return M_PROPERTY_UNAVAILABLE
;
230 if (((f
= strrchr(mpctx
->filename
, '/'))
231 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
235 return m_property_string_ro(prop
, action
, arg
, f
);
238 /// Demuxer name (RO)
239 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
243 return M_PROPERTY_UNAVAILABLE
;
244 return m_property_string_ro(prop
, action
, arg
,
245 (char *) mpctx
->demuxer
->desc
->name
);
248 /// Position in the stream (RW)
249 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
252 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
253 return M_PROPERTY_UNAVAILABLE
;
255 return M_PROPERTY_ERROR
;
258 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
259 return M_PROPERTY_OK
;
261 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
262 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
263 return M_PROPERTY_OK
;
265 return M_PROPERTY_NOT_IMPLEMENTED
;
268 /// Stream start offset (RO)
269 static int mp_property_stream_start(m_option_t
*prop
, int action
,
270 void *arg
, MPContext
*mpctx
)
272 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
273 return M_PROPERTY_UNAVAILABLE
;
276 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
277 return M_PROPERTY_OK
;
279 return M_PROPERTY_NOT_IMPLEMENTED
;
282 /// Stream end offset (RO)
283 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
286 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
287 return M_PROPERTY_UNAVAILABLE
;
290 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
291 return M_PROPERTY_OK
;
293 return M_PROPERTY_NOT_IMPLEMENTED
;
296 /// Stream length (RO)
297 static int mp_property_stream_length(m_option_t
*prop
, int action
,
298 void *arg
, MPContext
*mpctx
)
300 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
301 return M_PROPERTY_UNAVAILABLE
;
305 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
306 return M_PROPERTY_OK
;
308 return M_PROPERTY_NOT_IMPLEMENTED
;
311 /// Media length in seconds (RO)
312 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
317 if (!mpctx
->demuxer
||
318 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
319 return M_PROPERTY_UNAVAILABLE
;
321 return m_property_time_ro(prop
, action
, arg
, len
);
324 /// Current position in percent (RW)
325 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
326 void *arg
, MPContext
*mpctx
) {
330 return M_PROPERTY_UNAVAILABLE
;
334 if(!arg
) return M_PROPERTY_ERROR
;
335 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
338 case M_PROPERTY_STEP_UP
:
339 case M_PROPERTY_STEP_DOWN
:
340 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
341 pos
+= (arg
? *(int*)arg
: 10) *
342 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
343 M_PROPERTY_CLAMP(prop
, pos
);
346 return m_property_int_ro(prop
, action
, arg
,
347 demuxer_get_percent_pos(mpctx
->demuxer
));
350 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
351 mpctx
->rel_seek_secs
= pos
/ 100.0;
352 return M_PROPERTY_OK
;
355 /// Current position in seconds (RW)
356 static int mp_property_time_pos(m_option_t
*prop
, int action
,
357 void *arg
, MPContext
*mpctx
) {
358 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
359 return M_PROPERTY_UNAVAILABLE
;
363 if(!arg
) return M_PROPERTY_ERROR
;
364 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
365 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
366 mpctx
->rel_seek_secs
= *(double*)arg
;
367 return M_PROPERTY_OK
;
368 case M_PROPERTY_STEP_UP
:
369 case M_PROPERTY_STEP_DOWN
:
370 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
371 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
372 return M_PROPERTY_OK
;
374 return m_property_time_ro(prop
, action
, arg
,
375 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
376 playing_audio_pts(mpctx
));
379 /// Current chapter (RW)
380 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
383 struct MPOpts
*opts
= &mpctx
->opts
;
386 char *chapter_name
= NULL
;
389 chapter
= get_current_chapter(mpctx
);
391 return M_PROPERTY_UNAVAILABLE
;
396 return M_PROPERTY_ERROR
;
397 *(int *) arg
= chapter
;
398 return M_PROPERTY_OK
;
399 case M_PROPERTY_PRINT
: {
401 return M_PROPERTY_ERROR
;
402 chapter_name
= chapter_display_name(mpctx
, chapter
);
404 return M_PROPERTY_UNAVAILABLE
;
405 *(char **) arg
= chapter_name
;
406 return M_PROPERTY_OK
;
410 return M_PROPERTY_ERROR
;
411 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
412 step_all
= *(int *)arg
- chapter
;
415 case M_PROPERTY_STEP_UP
:
416 case M_PROPERTY_STEP_DOWN
: {
417 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
418 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
425 return M_PROPERTY_NOT_IMPLEMENTED
;
429 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
430 mpctx
->rel_seek_secs
= 0;
431 mpctx
->abs_seek_pos
= 0;
433 if (next_pts
> -1.0) {
434 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
435 mpctx
->rel_seek_secs
= next_pts
;
438 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
439 _("Chapter: (%d) %s"), chapter
+ 1, chapter_name
);
441 else if (step_all
> 0)
442 mpctx
->rel_seek_secs
= 1000000000.;
444 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
445 _("Chapter: (%d) %s"), 0, _("unknown"));
447 talloc_free(chapter_name
);
448 return M_PROPERTY_OK
;
451 /// Number of chapters in file
452 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
456 return M_PROPERTY_UNAVAILABLE
;
457 if (mpctx
->demuxer
->num_chapters
== 0)
458 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
459 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
462 /// Current dvd angle (RW)
463 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
466 struct MPOpts
*opts
= &mpctx
->opts
;
469 char *angle_name
= NULL
;
472 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
474 return M_PROPERTY_UNAVAILABLE
;
475 angles
= demuxer_angles_count(mpctx
->demuxer
);
477 return M_PROPERTY_UNAVAILABLE
;
482 return M_PROPERTY_ERROR
;
483 *(int *) arg
= angle
;
484 return M_PROPERTY_OK
;
485 case M_PROPERTY_PRINT
: {
487 return M_PROPERTY_ERROR
;
488 angle_name
= calloc(1, 64);
490 return M_PROPERTY_UNAVAILABLE
;
491 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
492 *(char **) arg
= angle_name
;
493 return M_PROPERTY_OK
;
497 return M_PROPERTY_ERROR
;
499 M_PROPERTY_CLAMP(prop
, angle
);
501 case M_PROPERTY_STEP_UP
:
502 case M_PROPERTY_STEP_DOWN
: {
508 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
510 if (angle
< 1) //cycle
515 return M_PROPERTY_NOT_IMPLEMENTED
;
517 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
518 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
519 _("Angle: %d/%d"), angle
, angles
);
522 return M_PROPERTY_OK
;
525 /// Demuxer meta data
526 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
528 m_property_action_t
* ka
;
530 static const m_option_t key_type
=
531 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
533 return M_PROPERTY_UNAVAILABLE
;
537 if(!arg
) return M_PROPERTY_ERROR
;
538 *(char***)arg
= mpctx
->demuxer
->info
;
539 return M_PROPERTY_OK
;
540 case M_PROPERTY_KEY_ACTION
:
541 if(!arg
) return M_PROPERTY_ERROR
;
543 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
544 return M_PROPERTY_UNKNOWN
;
547 if(!ka
->arg
) return M_PROPERTY_ERROR
;
548 *(char**)ka
->arg
= meta
;
549 return M_PROPERTY_OK
;
550 case M_PROPERTY_GET_TYPE
:
551 if(!ka
->arg
) return M_PROPERTY_ERROR
;
552 *(m_option_t
**)ka
->arg
= &key_type
;
553 return M_PROPERTY_OK
;
556 return M_PROPERTY_NOT_IMPLEMENTED
;
559 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
562 MPContext
*mpctx
= ctx
;
567 return M_PROPERTY_ERROR
;
568 if (mpctx
->paused
== (bool)*(int *) arg
)
569 return M_PROPERTY_OK
;
570 case M_PROPERTY_STEP_UP
:
571 case M_PROPERTY_STEP_DOWN
:
573 unpause_player(mpctx
);
574 mpctx
->osd_function
= OSD_PLAY
;
578 mpctx
->osd_function
= OSD_PAUSE
;
580 return M_PROPERTY_OK
;
582 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
589 /// \defgroup AudioProperties Audio properties
590 /// \ingroup Properties
594 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
598 if (!mpctx
->sh_audio
)
599 return M_PROPERTY_UNAVAILABLE
;
604 return M_PROPERTY_ERROR
;
605 mixer_getbothvolume(&mpctx
->mixer
, arg
);
606 return M_PROPERTY_OK
;
607 case M_PROPERTY_PRINT
:{
610 return M_PROPERTY_ERROR
;
611 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
612 return m_property_float_range(prop
, action
, arg
, &vol
);
614 case M_PROPERTY_STEP_UP
:
615 case M_PROPERTY_STEP_DOWN
:
619 return M_PROPERTY_NOT_IMPLEMENTED
;
622 if (mpctx
->edl_muted
)
623 return M_PROPERTY_DISABLED
;
624 mpctx
->user_muted
= 0;
629 return M_PROPERTY_ERROR
;
630 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
631 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
632 return M_PROPERTY_OK
;
633 case M_PROPERTY_STEP_UP
:
634 if (arg
&& *(float *) arg
<= 0)
635 mixer_decvolume(&mpctx
->mixer
);
637 mixer_incvolume(&mpctx
->mixer
);
638 return M_PROPERTY_OK
;
639 case M_PROPERTY_STEP_DOWN
:
640 if (arg
&& *(float *) arg
<= 0)
641 mixer_incvolume(&mpctx
->mixer
);
643 mixer_decvolume(&mpctx
->mixer
);
644 return M_PROPERTY_OK
;
646 return M_PROPERTY_NOT_IMPLEMENTED
;
650 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
654 if (!mpctx
->sh_audio
)
655 return M_PROPERTY_UNAVAILABLE
;
659 if (mpctx
->edl_muted
)
660 return M_PROPERTY_DISABLED
;
662 return M_PROPERTY_ERROR
;
663 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
664 mixer_mute(&mpctx
->mixer
);
665 mpctx
->user_muted
= mpctx
->mixer
.muted
;
666 return M_PROPERTY_OK
;
667 case M_PROPERTY_STEP_UP
:
668 case M_PROPERTY_STEP_DOWN
:
669 if (mpctx
->edl_muted
)
670 return M_PROPERTY_DISABLED
;
671 mixer_mute(&mpctx
->mixer
);
672 mpctx
->user_muted
= mpctx
->mixer
.muted
;
673 return M_PROPERTY_OK
;
674 case M_PROPERTY_PRINT
:
676 return M_PROPERTY_ERROR
;
677 if (mpctx
->edl_muted
) {
678 *(char **) arg
= strdup(_("enabled (EDL)"));
679 return M_PROPERTY_OK
;
682 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
688 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
689 void *arg
, MPContext
*mpctx
)
691 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
692 return M_PROPERTY_UNAVAILABLE
;
695 case M_PROPERTY_STEP_UP
:
696 case M_PROPERTY_STEP_DOWN
: {
698 float delay
= audio_delay
;
699 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
700 if (ret
!= M_PROPERTY_OK
)
703 mpctx
->delay
-= audio_delay
- delay
;
705 return M_PROPERTY_OK
;
707 return m_property_delay(prop
, action
, arg
, &audio_delay
);
711 /// Audio codec tag (RO)
712 static int mp_property_audio_format(m_option_t
*prop
, int action
,
713 void *arg
, MPContext
*mpctx
)
715 if (!mpctx
->sh_audio
)
716 return M_PROPERTY_UNAVAILABLE
;
717 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
720 /// Audio codec name (RO)
721 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
722 void *arg
, MPContext
*mpctx
)
724 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
725 return M_PROPERTY_UNAVAILABLE
;
726 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
729 /// Audio bitrate (RO)
730 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
731 void *arg
, MPContext
*mpctx
)
733 if (!mpctx
->sh_audio
)
734 return M_PROPERTY_UNAVAILABLE
;
735 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
739 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
742 if (!mpctx
->sh_audio
)
743 return M_PROPERTY_UNAVAILABLE
;
745 case M_PROPERTY_PRINT
:
746 if(!arg
) return M_PROPERTY_ERROR
;
747 *(char**)arg
= malloc(16);
748 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
749 return M_PROPERTY_OK
;
751 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
754 /// Number of channels (RO)
755 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
758 if (!mpctx
->sh_audio
)
759 return M_PROPERTY_UNAVAILABLE
;
761 case M_PROPERTY_PRINT
:
763 return M_PROPERTY_ERROR
;
764 switch (mpctx
->sh_audio
->channels
) {
766 *(char **) arg
= strdup("mono");
769 *(char **) arg
= strdup("stereo");
772 *(char **) arg
= malloc(32);
773 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
775 return M_PROPERTY_OK
;
777 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
781 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
786 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
787 return M_PROPERTY_UNAVAILABLE
;
792 return M_PROPERTY_ERROR
;
793 mixer_getbalance(&mpctx
->mixer
, arg
);
794 return M_PROPERTY_OK
;
795 case M_PROPERTY_PRINT
: {
798 return M_PROPERTY_ERROR
;
799 mixer_getbalance(&mpctx
->mixer
, &bal
);
801 *str
= strdup("center");
802 else if (bal
== -1.f
)
803 *str
= strdup("left only");
805 *str
= strdup("right only");
807 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
808 *str
= malloc(sizeof("left xxx%, right xxx%"));
809 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
811 return M_PROPERTY_OK
;
813 case M_PROPERTY_STEP_UP
:
814 case M_PROPERTY_STEP_DOWN
:
815 mixer_getbalance(&mpctx
->mixer
, &bal
);
816 bal
+= (arg
? *(float*)arg
: .1f
) *
817 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
818 M_PROPERTY_CLAMP(prop
, bal
);
819 mixer_setbalance(&mpctx
->mixer
, bal
);
820 return M_PROPERTY_OK
;
823 return M_PROPERTY_ERROR
;
824 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
825 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
826 return M_PROPERTY_OK
;
828 return M_PROPERTY_NOT_IMPLEMENTED
;
831 /// Selected audio id (RW)
832 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
835 struct MPOpts
*opts
= &mpctx
->opts
;
836 int current_id
= -1, tmp
;
840 if (!mpctx
->sh_audio
)
841 return M_PROPERTY_UNAVAILABLE
;
843 return M_PROPERTY_ERROR
;
844 *(int *) arg
= opts
->audio_id
;
845 return M_PROPERTY_OK
;
846 case M_PROPERTY_PRINT
:
847 if (!mpctx
->sh_audio
)
848 return M_PROPERTY_UNAVAILABLE
;
850 return M_PROPERTY_ERROR
;
852 if (opts
->audio_id
< 0)
853 *(char **) arg
= strdup(_("disabled"));
855 char lang
[40] = _("unknown");
856 sh_audio_t
* sh
= mpctx
->sh_audio
;
858 av_strlcpy(lang
, sh
->lang
, 40);
859 #ifdef CONFIG_DVDREAD
860 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
861 int code
= dvd_lang_from_aid(mpctx
->stream
, opts
->audio_id
);
871 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
872 mp_dvdnav_lang_from_aid(mpctx
->stream
, opts
->audio_id
, lang
);
874 *(char **) arg
= malloc(64);
875 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->audio_id
, lang
);
877 return M_PROPERTY_OK
;
879 case M_PROPERTY_STEP_UP
:
882 return M_PROPERTY_UNAVAILABLE
;
883 if (action
== M_PROPERTY_SET
&& arg
)
884 tmp
= *((int *) arg
);
887 current_id
= mpctx
->demuxer
->audio
->id
;
888 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
889 if (opts
->audio_id
== -2
890 || (opts
->audio_id
> -1
891 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
892 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
893 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
895 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
897 sh2
->ds
= mpctx
->demuxer
->audio
;
898 mpctx
->sh_audio
= sh2
;
899 reinit_audio_chain(mpctx
);
902 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
903 return M_PROPERTY_OK
;
905 return M_PROPERTY_NOT_IMPLEMENTED
;
910 /// Selected video id (RW)
911 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
914 struct MPOpts
*opts
= &mpctx
->opts
;
915 int current_id
= -1, tmp
;
919 if (!mpctx
->sh_video
)
920 return M_PROPERTY_UNAVAILABLE
;
922 return M_PROPERTY_ERROR
;
923 *(int *) arg
= opts
->video_id
;
924 return M_PROPERTY_OK
;
925 case M_PROPERTY_PRINT
:
926 if (!mpctx
->sh_video
)
927 return M_PROPERTY_UNAVAILABLE
;
929 return M_PROPERTY_ERROR
;
931 if (opts
->video_id
< 0)
932 *(char **) arg
= strdup(_("disabled"));
934 char lang
[40] = _("unknown");
935 *(char **) arg
= malloc(64);
936 snprintf(*(char **) arg
, 64, "(%d) %s", opts
->video_id
, lang
);
938 return M_PROPERTY_OK
;
940 case M_PROPERTY_STEP_UP
:
942 current_id
= mpctx
->demuxer
->video
->id
;
943 if (action
== M_PROPERTY_SET
&& arg
)
944 tmp
= *((int *) arg
);
947 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
948 if (opts
->video_id
== -2
949 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
950 && current_id
!= -2))
951 uninit_player(mpctx
, INITIALIZED_VCODEC
|
952 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
953 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
955 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
957 sh2
->ds
= mpctx
->demuxer
->video
;
958 mpctx
->sh_video
= sh2
;
959 reinit_video_chain(mpctx
);
962 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
963 return M_PROPERTY_OK
;
966 return M_PROPERTY_NOT_IMPLEMENTED
;
970 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
973 demux_program_t prog
;
976 case M_PROPERTY_STEP_UP
:
978 if (action
== M_PROPERTY_SET
&& arg
)
979 prog
.progid
= *((int *) arg
);
983 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
984 &prog
) == DEMUXER_CTRL_NOTIMPL
)
985 return M_PROPERTY_ERROR
;
987 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
988 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
989 return M_PROPERTY_OK
;
992 return M_PROPERTY_NOT_IMPLEMENTED
;
998 /// \defgroup VideoProperties Video properties
999 /// \ingroup Properties
1002 /// Fullscreen state (RW)
1003 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1007 if (!mpctx
->video_out
)
1008 return M_PROPERTY_UNAVAILABLE
;
1011 case M_PROPERTY_SET
:
1013 return M_PROPERTY_ERROR
;
1014 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1015 if (vo_fs
== !!*(int *) arg
)
1016 return M_PROPERTY_OK
;
1017 case M_PROPERTY_STEP_UP
:
1018 case M_PROPERTY_STEP_DOWN
:
1019 if (mpctx
->video_out
->config_ok
)
1020 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1021 mpctx
->opts
.fullscreen
= vo_fs
;
1022 return M_PROPERTY_OK
;
1024 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1028 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1029 void *arg
, MPContext
*mpctx
)
1033 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1034 return M_PROPERTY_UNAVAILABLE
;
1035 vf
= mpctx
->sh_video
->vfilter
;
1037 case M_PROPERTY_GET
:
1039 return M_PROPERTY_ERROR
;
1040 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1041 return M_PROPERTY_OK
;
1042 case M_PROPERTY_SET
:
1044 return M_PROPERTY_ERROR
;
1045 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1046 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1047 return M_PROPERTY_OK
;
1048 case M_PROPERTY_STEP_UP
:
1049 case M_PROPERTY_STEP_DOWN
:
1050 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1051 deinterlace
= !deinterlace
;
1052 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1053 return M_PROPERTY_OK
;
1055 return M_PROPERTY_NOT_IMPLEMENTED
;
1059 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1063 if (!mpctx
->video_out
1064 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1065 return M_PROPERTY_UNAVAILABLE
;
1068 case M_PROPERTY_SET
:
1070 return M_PROPERTY_ERROR
;
1071 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1072 vo_panscan
= *(float *) arg
;
1073 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1074 return M_PROPERTY_OK
;
1075 case M_PROPERTY_STEP_UP
:
1076 case M_PROPERTY_STEP_DOWN
:
1077 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1078 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1081 else if (vo_panscan
< 0)
1083 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1084 return M_PROPERTY_OK
;
1086 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1090 /// Helper to set vo flags.
1091 /** \ingroup PropertyImplHelper
1093 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1094 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1097 if (!mpctx
->video_out
)
1098 return M_PROPERTY_UNAVAILABLE
;
1101 case M_PROPERTY_SET
:
1103 return M_PROPERTY_ERROR
;
1104 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1105 if (*vo_var
== !!*(int *) arg
)
1106 return M_PROPERTY_OK
;
1107 case M_PROPERTY_STEP_UP
:
1108 case M_PROPERTY_STEP_DOWN
:
1109 if (mpctx
->video_out
->config_ok
)
1110 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1111 return M_PROPERTY_OK
;
1113 return m_property_flag(prop
, action
, arg
, vo_var
);
1117 /// Window always on top (RW)
1118 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1121 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1122 &mpctx
->opts
.vo_ontop
, mpctx
);
1125 /// Display in the root window (RW)
1126 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1129 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1130 &vo_rootwin
, mpctx
);
1133 /// Show window borders (RW)
1134 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1137 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1141 /// Framedropping state (RW)
1142 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1143 void *arg
, MPContext
*mpctx
)
1146 if (!mpctx
->sh_video
)
1147 return M_PROPERTY_UNAVAILABLE
;
1150 case M_PROPERTY_PRINT
:
1152 return M_PROPERTY_ERROR
;
1153 *(char **) arg
= strdup(frame_dropping
== 1 ? _("enabled") :
1154 (frame_dropping
== 2 ? _("hard") :
1156 return M_PROPERTY_OK
;
1158 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1162 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1163 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1166 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1169 if (!mpctx
->sh_video
)
1170 return M_PROPERTY_UNAVAILABLE
;
1172 if (gamma
[0] == 1000) {
1174 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1178 case M_PROPERTY_SET
:
1180 return M_PROPERTY_ERROR
;
1181 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1182 *gamma
= *(int *) arg
;
1183 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1187 case M_PROPERTY_GET
:
1188 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1190 return M_PROPERTY_ERROR
;
1192 return M_PROPERTY_OK
;
1195 case M_PROPERTY_STEP_UP
:
1196 case M_PROPERTY_STEP_DOWN
:
1197 *gamma
+= (arg
? *(int *) arg
: 1) *
1198 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1199 M_PROPERTY_CLAMP(prop
, *gamma
);
1200 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1205 return M_PROPERTY_NOT_IMPLEMENTED
;
1209 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1210 int l
= strlen(prop
->name
);
1211 char tv_prop
[3 + l
+ 1];
1212 sprintf(tv_prop
, "tv_%s", prop
->name
);
1213 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1217 return M_PROPERTY_UNAVAILABLE
;
1221 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1224 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1227 /// Video codec tag (RO)
1228 static int mp_property_video_format(m_option_t
*prop
, int action
,
1229 void *arg
, MPContext
*mpctx
)
1232 if (!mpctx
->sh_video
)
1233 return M_PROPERTY_UNAVAILABLE
;
1235 case M_PROPERTY_PRINT
:
1237 return M_PROPERTY_ERROR
;
1238 switch(mpctx
->sh_video
->format
) {
1240 meta
= strdup ("mpeg1"); break;
1242 meta
= strdup ("mpeg2"); break;
1244 meta
= strdup ("mpeg4"); break;
1246 meta
= strdup ("h264"); break;
1248 if(mpctx
->sh_video
->format
>= 0x20202020) {
1250 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1253 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1256 *(char**)arg
= meta
;
1257 return M_PROPERTY_OK
;
1259 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1262 /// Video codec name (RO)
1263 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1264 void *arg
, MPContext
*mpctx
)
1266 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1267 return M_PROPERTY_UNAVAILABLE
;
1268 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1272 /// Video bitrate (RO)
1273 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1274 void *arg
, MPContext
*mpctx
)
1276 if (!mpctx
->sh_video
)
1277 return M_PROPERTY_UNAVAILABLE
;
1278 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1281 /// Video display width (RO)
1282 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1285 if (!mpctx
->sh_video
)
1286 return M_PROPERTY_UNAVAILABLE
;
1287 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1290 /// Video display height (RO)
1291 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1294 if (!mpctx
->sh_video
)
1295 return M_PROPERTY_UNAVAILABLE
;
1296 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1300 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1303 if (!mpctx
->sh_video
)
1304 return M_PROPERTY_UNAVAILABLE
;
1305 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1308 /// Video aspect (RO)
1309 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1312 if (!mpctx
->sh_video
)
1313 return M_PROPERTY_UNAVAILABLE
;
1314 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1319 /// \defgroup SubProprties Subtitles properties
1320 /// \ingroup Properties
1323 /// Text subtitle position (RW)
1324 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1327 if (!mpctx
->sh_video
)
1328 return M_PROPERTY_UNAVAILABLE
;
1331 case M_PROPERTY_SET
:
1333 return M_PROPERTY_ERROR
;
1334 case M_PROPERTY_STEP_UP
:
1335 case M_PROPERTY_STEP_DOWN
:
1336 vo_osd_changed(OSDTYPE_SUBTITLE
);
1338 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1342 /// Selected subtitles (RW)
1343 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1346 struct MPOpts
*opts
= &mpctx
->opts
;
1347 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1348 const int global_sub_size
= mpctx
->global_sub_size
;
1349 int source
= -1, reset_spu
= 0;
1352 if (!mpctx
->sh_video
|| global_sub_size
<= 0)
1353 return M_PROPERTY_UNAVAILABLE
;
1356 case M_PROPERTY_GET
:
1358 return M_PROPERTY_ERROR
;
1359 *(int *) arg
= mpctx
->global_sub_pos
;
1360 return M_PROPERTY_OK
;
1361 case M_PROPERTY_PRINT
:
1363 return M_PROPERTY_ERROR
;
1364 *(char **) arg
= malloc(64);
1365 (*(char **) arg
)[63] = 0;
1368 sub_name
= subdata
->filename
;
1370 if (ass_track
&& ass_track
->name
)
1371 sub_name
= ass_track
->name
;
1376 if ((tmp2
= strrchr(tmp
, '/')))
1379 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1380 mpctx
->set_of_sub_pos
+ 1,
1381 strlen(tmp
) < 20 ? "" : "...",
1382 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1383 return M_PROPERTY_OK
;
1385 #ifdef CONFIG_DVDNAV
1386 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1387 if (vo_spudec
&& opts
->sub_id
>= 0) {
1388 unsigned char lang
[3];
1389 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1390 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1391 return M_PROPERTY_OK
;
1397 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1398 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1399 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1400 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1401 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1402 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1403 if (!lang
) lang
= _("unknown");
1404 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1405 return M_PROPERTY_OK
;
1408 if (vo_vobsub
&& vobsub_id
>= 0) {
1409 const char *language
= _("unknown");
1410 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1411 snprintf(*(char **) arg
, 63, "(%d) %s",
1412 vobsub_id
, language
? language
: _("unknown"));
1413 return M_PROPERTY_OK
;
1415 #ifdef CONFIG_DVDREAD
1416 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1417 && opts
->sub_id
>= 0) {
1419 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1420 lang
[0] = code
>> 8;
1423 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1424 return M_PROPERTY_OK
;
1427 if (opts
->sub_id
>= 0) {
1428 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, _("unknown"));
1429 return M_PROPERTY_OK
;
1431 snprintf(*(char **) arg
, 63, _("disabled"));
1432 return M_PROPERTY_OK
;
1434 case M_PROPERTY_SET
:
1436 return M_PROPERTY_ERROR
;
1437 if (*(int *) arg
< -1)
1439 else if (*(int *) arg
>= global_sub_size
)
1440 *(int *) arg
= global_sub_size
- 1;
1441 mpctx
->global_sub_pos
= *(int *) arg
;
1443 case M_PROPERTY_STEP_UP
:
1444 mpctx
->global_sub_pos
+= 2;
1445 mpctx
->global_sub_pos
=
1446 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1448 case M_PROPERTY_STEP_DOWN
:
1449 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1450 mpctx
->global_sub_pos
=
1451 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1454 return M_PROPERTY_NOT_IMPLEMENTED
;
1457 if (mpctx
->global_sub_pos
>= 0)
1458 source
= sub_source(mpctx
);
1460 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1461 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1463 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1464 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1465 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1466 mpctx
->global_sub_pos
, source
);
1468 mpctx
->set_of_sub_pos
= -1;
1482 if (source
== SUB_SOURCE_VOBSUB
) {
1483 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1484 } else if (source
== SUB_SOURCE_SUBS
) {
1485 mpctx
->set_of_sub_pos
=
1486 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1488 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1489 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1493 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1494 vo_osd_changed(OSDTYPE_SUBTITLE
);
1496 } else if (source
== SUB_SOURCE_DEMUX
) {
1498 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1499 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1501 // default: assume 1:1 mapping of sid and stream id
1502 d_sub
->id
= opts
->sub_id
;
1503 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1504 ds_free_packs(d_sub
);
1505 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1506 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1507 if (sh
&& sh
->sid
== opts
->sub_id
) {
1513 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1514 sh_sub_t
*sh
= d_sub
->sh
;
1515 if (sh
->type
== 'v')
1516 init_vo_spudec(mpctx
);
1518 else if (ass_enabled
)
1519 ass_track
= sh
->ass_track
;
1527 #ifdef CONFIG_DVDREAD
1529 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1530 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1531 && opts
->sub_id
< 0 && reset_spu
) {
1533 d_sub
->id
= opts
->sub_id
;
1536 update_subtitles(mpctx
->sh_video
, d_sub
, 0, 1);
1538 return M_PROPERTY_OK
;
1541 /// Selected sub source (RW)
1542 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1546 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1547 return M_PROPERTY_UNAVAILABLE
;
1550 case M_PROPERTY_GET
:
1552 return M_PROPERTY_ERROR
;
1553 *(int *) arg
= sub_source(mpctx
);
1554 return M_PROPERTY_OK
;
1555 case M_PROPERTY_PRINT
:
1557 return M_PROPERTY_ERROR
;
1558 *(char **) arg
= malloc(64);
1559 (*(char **) arg
)[63] = 0;
1560 switch (sub_source(mpctx
))
1562 case SUB_SOURCE_SUBS
:
1563 snprintf(*(char **) arg
, 63, _("file"));
1565 case SUB_SOURCE_VOBSUB
:
1566 snprintf(*(char **) arg
, 63, _("vobsub"));
1568 case SUB_SOURCE_DEMUX
:
1569 snprintf(*(char **) arg
, 63, _("embedded"));
1572 snprintf(*(char **) arg
, 63, _("disabled"));
1574 return M_PROPERTY_OK
;
1575 case M_PROPERTY_SET
:
1577 return M_PROPERTY_ERROR
;
1578 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1579 if (*(int *) arg
< 0)
1580 mpctx
->global_sub_pos
= -1;
1581 else if (*(int *) arg
!= sub_source(mpctx
)) {
1582 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1583 return M_PROPERTY_UNAVAILABLE
;
1584 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1587 case M_PROPERTY_STEP_UP
:
1588 case M_PROPERTY_STEP_DOWN
: {
1589 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1590 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1591 int step
= (step_all
> 0) ? 1 : -1;
1592 int cur_source
= sub_source(mpctx
);
1593 source
= cur_source
;
1596 if (source
>= SUB_SOURCES
)
1598 else if (source
< -1)
1599 source
= SUB_SOURCES
- 1;
1600 if (source
== cur_source
|| source
== -1 ||
1601 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1604 if (source
== cur_source
)
1605 return M_PROPERTY_OK
;
1607 mpctx
->global_sub_pos
= -1;
1609 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1613 return M_PROPERTY_NOT_IMPLEMENTED
;
1615 --mpctx
->global_sub_pos
;
1616 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1619 /// Selected subtitles from specific source (RW)
1620 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1623 int source
, is_cur_source
, offset
;
1624 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1625 return M_PROPERTY_UNAVAILABLE
;
1627 if (!strcmp(prop
->name
, "sub_file"))
1628 source
= SUB_SOURCE_SUBS
;
1629 else if (!strcmp(prop
->name
, "sub_vob"))
1630 source
= SUB_SOURCE_VOBSUB
;
1631 else if (!strcmp(prop
->name
, "sub_demux"))
1632 source
= SUB_SOURCE_DEMUX
;
1634 return M_PROPERTY_ERROR
;
1636 offset
= mpctx
->global_sub_indices
[source
];
1637 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1638 return M_PROPERTY_UNAVAILABLE
;
1640 is_cur_source
= sub_source(mpctx
) == source
;
1642 case M_PROPERTY_GET
:
1644 return M_PROPERTY_ERROR
;
1645 if (is_cur_source
) {
1646 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1647 if (source
== SUB_SOURCE_VOBSUB
)
1648 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1652 return M_PROPERTY_OK
;
1653 case M_PROPERTY_PRINT
:
1655 return M_PROPERTY_ERROR
;
1657 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1658 *(char **) arg
= malloc(64);
1659 (*(char **) arg
)[63] = 0;
1660 snprintf(*(char **) arg
, 63, _("disabled"));
1661 return M_PROPERTY_OK
;
1662 case M_PROPERTY_SET
:
1664 return M_PROPERTY_ERROR
;
1665 if (*(int *) arg
>= 0) {
1666 int index
= *(int *)arg
;
1667 if (source
== SUB_SOURCE_VOBSUB
)
1668 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1669 mpctx
->global_sub_pos
= offset
+ index
;
1670 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1671 || sub_source(mpctx
) != source
) {
1672 mpctx
->global_sub_pos
= -1;
1677 mpctx
->global_sub_pos
= -1;
1679 case M_PROPERTY_STEP_UP
:
1680 case M_PROPERTY_STEP_DOWN
: {
1681 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1682 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1683 int step
= (step_all
> 0) ? 1 : -1;
1684 int max_sub_pos_for_source
= -1;
1686 mpctx
->global_sub_pos
= -1;
1688 if (mpctx
->global_sub_pos
== -1) {
1690 mpctx
->global_sub_pos
= offset
;
1691 else if (max_sub_pos_for_source
== -1) {
1692 // Find max pos for specific source
1693 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1694 while (mpctx
->global_sub_pos
>= 0
1695 && sub_source(mpctx
) != source
)
1696 --mpctx
->global_sub_pos
;
1699 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1702 mpctx
->global_sub_pos
+= step
;
1703 if (mpctx
->global_sub_pos
< offset
||
1704 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1705 sub_source(mpctx
) != source
)
1706 mpctx
->global_sub_pos
= -1;
1713 return M_PROPERTY_NOT_IMPLEMENTED
;
1715 --mpctx
->global_sub_pos
;
1716 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1719 /// Subtitle delay (RW)
1720 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1723 if (!mpctx
->sh_video
)
1724 return M_PROPERTY_UNAVAILABLE
;
1725 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1728 /// Alignment of text subtitles (RW)
1729 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1730 void *arg
, MPContext
*mpctx
)
1732 char *name
[] = { _("top"), _("center"), _("bottom") };
1734 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1735 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1736 return M_PROPERTY_UNAVAILABLE
;
1739 case M_PROPERTY_PRINT
:
1741 return M_PROPERTY_ERROR
;
1742 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1743 *(char **) arg
= strdup(name
[sub_alignment
]);
1744 return M_PROPERTY_OK
;
1745 case M_PROPERTY_SET
:
1747 return M_PROPERTY_ERROR
;
1748 case M_PROPERTY_STEP_UP
:
1749 case M_PROPERTY_STEP_DOWN
:
1750 vo_osd_changed(OSDTYPE_SUBTITLE
);
1752 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1756 /// Subtitle visibility (RW)
1757 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1758 void *arg
, MPContext
*mpctx
)
1760 if (!mpctx
->sh_video
)
1761 return M_PROPERTY_UNAVAILABLE
;
1764 case M_PROPERTY_SET
:
1766 return M_PROPERTY_ERROR
;
1767 case M_PROPERTY_STEP_UP
:
1768 case M_PROPERTY_STEP_DOWN
:
1769 vo_osd_changed(OSDTYPE_SUBTITLE
);
1771 vo_osd_changed(OSDTYPE_SPU
);
1773 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1778 /// Use margins for libass subtitles (RW)
1779 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1780 void *arg
, MPContext
*mpctx
)
1782 if (!mpctx
->sh_video
)
1783 return M_PROPERTY_UNAVAILABLE
;
1786 case M_PROPERTY_SET
:
1788 return M_PROPERTY_ERROR
;
1789 case M_PROPERTY_STEP_UP
:
1790 case M_PROPERTY_STEP_DOWN
:
1791 ass_force_reload
= 1;
1793 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1798 /// Show only forced subtitles (RW)
1799 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1800 void *arg
, MPContext
*mpctx
)
1803 return M_PROPERTY_UNAVAILABLE
;
1806 case M_PROPERTY_SET
:
1808 return M_PROPERTY_ERROR
;
1809 case M_PROPERTY_STEP_UP
:
1810 case M_PROPERTY_STEP_DOWN
:
1811 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1812 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1813 return M_PROPERTY_OK
;
1815 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1820 #ifdef CONFIG_FREETYPE
1821 /// Subtitle scale (RW)
1822 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1827 case M_PROPERTY_SET
:
1829 return M_PROPERTY_ERROR
;
1830 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1833 ass_font_scale
= *(float *) arg
;
1834 ass_force_reload
= 1;
1837 text_font_scale_factor
= *(float *) arg
;
1838 force_load_font
= 1;
1839 return M_PROPERTY_OK
;
1840 case M_PROPERTY_STEP_UP
:
1841 case M_PROPERTY_STEP_DOWN
:
1844 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1845 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1846 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1847 ass_force_reload
= 1;
1850 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1851 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1852 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1853 force_load_font
= 1;
1854 return M_PROPERTY_OK
;
1858 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1861 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1868 /// \defgroup TVProperties TV properties
1869 /// \ingroup Properties
1874 /// TV color settings (RW)
1875 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1879 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1880 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1881 return M_PROPERTY_UNAVAILABLE
;
1884 case M_PROPERTY_SET
:
1886 return M_PROPERTY_ERROR
;
1887 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1888 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1889 case M_PROPERTY_GET
:
1890 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1891 case M_PROPERTY_STEP_UP
:
1892 case M_PROPERTY_STEP_DOWN
:
1893 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1895 return M_PROPERTY_ERROR
;
1896 val
+= (arg
? *(int *) arg
: 1) *
1897 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1898 M_PROPERTY_CLAMP(prop
, val
);
1899 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1901 return M_PROPERTY_ERROR
;
1903 return M_PROPERTY_NOT_IMPLEMENTED
;
1908 #ifdef CONFIG_TV_TELETEXT
1909 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1913 int base_ioctl
=(int)prop
->priv
;
1915 for teletext's GET,SET,STEP ioctls this is not 0
1919 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1920 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1921 return M_PROPERTY_UNAVAILABLE
;
1923 return M_PROPERTY_ERROR
;
1926 case M_PROPERTY_GET
:
1928 return M_PROPERTY_ERROR
;
1929 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1931 case M_PROPERTY_SET
:
1933 return M_PROPERTY_ERROR
;
1934 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1935 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1937 case M_PROPERTY_STEP_UP
:
1938 case M_PROPERTY_STEP_DOWN
:
1939 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1940 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1941 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1944 return M_PROPERTY_NOT_IMPLEMENTED
;
1947 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1950 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1953 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1957 //with tvh==NULL will fail too
1958 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1959 if(result
!=M_PROPERTY_OK
)
1962 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1963 mp_input_set_section(mpctx
->input
, "teletext");
1965 mp_input_set_section(mpctx
->input
, "tv");
1966 return M_PROPERTY_OK
;
1969 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
1972 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1975 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1976 return M_PROPERTY_UNAVAILABLE
;
1978 case M_PROPERTY_STEP_UP
:
1979 case M_PROPERTY_STEP_DOWN
:
1980 //This should be handled separately
1981 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1982 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1985 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1991 #endif /* CONFIG_TV_TELETEXT */
1995 /// All properties available in MPlayer.
1996 /** \ingroup Properties
1998 static const m_option_t mp_properties
[] = {
2000 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2001 M_OPT_RANGE
, 0, 3, NULL
},
2002 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2003 M_OPT_MIN
, -1, 0, NULL
},
2004 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2005 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2006 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2008 { "path", mp_property_path
, CONF_TYPE_STRING
,
2010 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2012 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2013 M_OPT_MIN
, 0, 0, NULL
},
2014 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2015 M_OPT_MIN
, 0, 0, NULL
},
2016 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2017 M_OPT_MIN
, 0, 0, NULL
},
2018 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2019 M_OPT_MIN
, 0, 0, NULL
},
2020 { "length", mp_property_length
, CONF_TYPE_TIME
,
2021 M_OPT_MIN
, 0, 0, NULL
},
2022 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2023 M_OPT_RANGE
, 0, 100, NULL
},
2024 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2025 M_OPT_MIN
, 0, 0, NULL
},
2026 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2027 M_OPT_MIN
, 0, 0, NULL
},
2028 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2030 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2031 CONF_RANGE
, -2, 10, NULL
},
2032 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2034 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2035 M_OPT_RANGE
, 0, 1, NULL
},
2038 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2039 M_OPT_RANGE
, 0, 100, NULL
},
2040 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2041 M_OPT_RANGE
, 0, 1, NULL
},
2042 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2043 M_OPT_RANGE
, -100, 100, NULL
},
2044 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2046 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2048 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2050 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2052 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2054 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2055 CONF_RANGE
, -2, 65535, NULL
},
2056 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2057 M_OPT_RANGE
, -1, 1, NULL
},
2060 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2061 M_OPT_RANGE
, 0, 1, NULL
},
2062 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2063 M_OPT_RANGE
, 0, 1, NULL
},
2064 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2065 M_OPT_RANGE
, 0, 1, NULL
},
2066 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2067 M_OPT_RANGE
, 0, 1, NULL
},
2068 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2069 M_OPT_RANGE
, 0, 1, NULL
},
2070 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2071 M_OPT_RANGE
, 0, 2, NULL
},
2072 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2073 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2074 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2075 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2076 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2077 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2078 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2080 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2081 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2082 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2083 M_OPT_RANGE
, 0, 1, NULL
},
2084 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2085 M_OPT_RANGE
, 0, 1, NULL
},
2086 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2088 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2090 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2092 { "width", mp_property_width
, CONF_TYPE_INT
,
2094 { "height", mp_property_height
, CONF_TYPE_INT
,
2096 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2098 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2100 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2101 CONF_RANGE
, -2, 65535, NULL
},
2102 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2103 CONF_RANGE
, -1, 65535, NULL
},
2106 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2107 M_OPT_MIN
, -1, 0, NULL
},
2108 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2109 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2110 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2111 M_OPT_MIN
, -1, 0, NULL
},
2112 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2113 M_OPT_MIN
, -1, 0, NULL
},
2114 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2115 M_OPT_MIN
, -1, 0, NULL
},
2116 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2118 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2119 M_OPT_RANGE
, 0, 100, NULL
},
2120 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2121 M_OPT_RANGE
, 0, 2, NULL
},
2122 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2123 M_OPT_RANGE
, 0, 1, NULL
},
2124 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2125 M_OPT_RANGE
, 0, 1, NULL
},
2126 #ifdef CONFIG_FREETYPE
2127 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2128 M_OPT_RANGE
, 0, 100, NULL
},
2131 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2132 M_OPT_RANGE
, 0, 1, NULL
},
2136 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2137 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2138 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2139 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2140 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2141 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2142 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2143 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2146 #ifdef CONFIG_TV_TELETEXT
2147 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2148 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2149 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2150 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2151 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2152 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2153 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2154 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2155 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2156 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2159 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2163 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2165 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2168 char* mp_property_print(const char *name
, void* ctx
)
2171 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2176 char *property_expand_string(MPContext
*mpctx
, char *str
)
2178 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2181 void property_print_help(void)
2183 m_properties_print_help_list(mp_properties
);
2192 * \defgroup Command2Property Command to property bridge
2194 * It is used to handle most commands that just set a property
2195 * and optionally display something on the OSD.
2196 * Two kinds of commands are handled: adjust or toggle.
2198 * Adjust commands take 1 or 2 parameters: <value> <abs>
2199 * If <abs> is non-zero the property is set to the given value
2200 * otherwise it is adjusted.
2202 * Toggle commands take 0 or 1 parameters. With no parameter
2203 * or a value less than the property minimum it just steps the
2204 * property to its next value. Otherwise it sets it to the given
2210 /// List of the commands that can be handled by setting a property.
2216 /// set/adjust or toggle command
2218 /// progressbar type
2219 int osd_progbar
; // -1 is special value for seek indicators
2220 /// osd msg id if it must be shared
2222 /// osd msg template
2223 const char *osd_msg
;
2224 } set_prop_cmd
[] = {
2226 { "loop", MP_CMD_LOOP
, 0, 0, -1, _("Loop: %s") },
2227 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, -1, -1, NULL
},
2228 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2229 { "pause", MP_CMD_PAUSE
, 0, 0, -1, NULL
},
2231 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, _("Volume") },
2232 { "mute", MP_CMD_MUTE
, 1, 0, -1, _("Mute: %s") },
2233 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, _("A-V delay: %s") },
2234 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, _("Audio: %s") },
2235 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, _("Balance") },
2237 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2238 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, _("Panscan") },
2239 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, _("Stay on top: %s") },
2240 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, _("Rootwin: %s") },
2241 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, _("Border: %s") },
2242 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, _("Framedropping: %s") },
2243 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, _("Gamma") },
2244 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, _("Brightness") },
2245 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, _("Contrast") },
2246 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, _("Saturation") },
2247 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, _("Hue") },
2248 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, _("VSync: %s") },
2250 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, _("Subtitles: %s") },
2251 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, _("Sub source: %s") },
2252 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, _("Subtitles: %s") },
2253 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, _("Subtitles: %s") },
2254 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, _("Subtitles: %s") },
2255 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, _("Sub position: %s/100") },
2256 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, _("Sub alignment: %s") },
2257 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2258 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, _("Subtitles: %s") },
2259 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, _("Forced sub only: %s") },
2260 #ifdef CONFIG_FREETYPE
2261 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, _("Sub Scale: %s")},
2264 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2267 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, _("Brightness") },
2268 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, _("Hue") },
2269 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, _("Saturation") },
2270 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, _("Contrast") },
2272 { NULL
, 0, 0, 0, -1, NULL
}
2276 /// Handle commands that set a property.
2277 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2279 struct MPOpts
*opts
= &mpctx
->opts
;
2284 // look for the command
2285 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2286 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2288 if (!(pname
= set_prop_cmd
[i
].name
))
2291 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2295 if (set_prop_cmd
[i
].toggle
) {
2297 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2298 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2300 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2301 } else if (cmd
->args
[1].v
.i
) //set
2302 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2304 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2309 if (set_prop_cmd
[i
].osd_progbar
== -1)
2310 mpctx
->add_osd_seek_info
= true;
2311 else if (set_prop_cmd
[i
].osd_progbar
) {
2312 if (prop
->type
== CONF_TYPE_INT
) {
2313 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2314 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2315 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2316 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2318 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2319 set_osd_bar(mpctx
, set_prop_cmd
[i
].osd_progbar
,
2320 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2322 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2323 "Property use an unsupported type.\n");
2327 if (set_prop_cmd
[i
].osd_msg
) {
2328 char *val
= mp_property_print(pname
, mpctx
);
2330 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2331 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2332 1, opts
->osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2339 #ifdef CONFIG_DVDNAV
2340 static const struct {
2342 const mp_command_type cmd
;
2343 } mp_dvdnav_bindings
[] = {
2344 { "up", MP_CMD_DVDNAV_UP
},
2345 { "down", MP_CMD_DVDNAV_DOWN
},
2346 { "left", MP_CMD_DVDNAV_LEFT
},
2347 { "right", MP_CMD_DVDNAV_RIGHT
},
2348 { "menu", MP_CMD_DVDNAV_MENU
},
2349 { "select", MP_CMD_DVDNAV_SELECT
},
2350 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2351 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2354 * keep old dvdnav sub-command options for a while in order not to
2355 * break slave-mode API too suddenly.
2357 { "1", MP_CMD_DVDNAV_UP
},
2358 { "2", MP_CMD_DVDNAV_DOWN
},
2359 { "3", MP_CMD_DVDNAV_LEFT
},
2360 { "4", MP_CMD_DVDNAV_RIGHT
},
2361 { "5", MP_CMD_DVDNAV_MENU
},
2362 { "6", MP_CMD_DVDNAV_SELECT
},
2363 { "7", MP_CMD_DVDNAV_PREVMENU
},
2364 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2369 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2371 struct MPOpts
*opts
= &mpctx
->opts
;
2372 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2373 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2374 int osd_duration
= opts
->osd_duration
;
2375 if (!set_property_command(mpctx
, cmd
))
2380 mpctx
->add_osd_seek_info
= true;
2381 v
= cmd
->args
[0].v
.f
;
2382 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2383 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2384 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2386 mpctx
->osd_function
=
2387 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2388 mpctx
->rel_seek_secs
= v
;
2389 } else if (abs
) { /* Absolute seek by percentage */
2390 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2392 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2393 mpctx
->rel_seek_secs
= v
/ 100.0;
2395 mpctx
->rel_seek_secs
+= v
;
2396 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2401 case MP_CMD_SET_PROPERTY
:{
2402 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2403 cmd
->args
[1].v
.s
, mpctx
);
2404 if (r
== M_PROPERTY_UNKNOWN
)
2405 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2406 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2408 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2409 "Failed to set property '%s' to '%s'.\n",
2410 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2414 case MP_CMD_STEP_PROPERTY
:{
2419 if (cmd
->args
[1].v
.f
) {
2421 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2422 M_PROPERTY_GET_TYPE
,
2423 &prop
, mpctx
)) <= 0)
2425 if(prop
->type
== CONF_TYPE_INT
||
2426 prop
->type
== CONF_TYPE_FLAG
)
2427 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2428 else if(prop
->type
== CONF_TYPE_FLOAT
)
2429 arg
= &cmd
->args
[1].v
.f
;
2430 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2431 prop
->type
== CONF_TYPE_TIME
)
2432 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2433 else if(prop
->type
== CONF_TYPE_POSITION
)
2434 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2436 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2437 "Ignoring step size stepping property '%s'.\n",
2440 r
= mp_property_do(cmd
->args
[0].v
.s
,
2441 cmd
->args
[2].v
.i
< 0 ?
2442 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2445 if (r
== M_PROPERTY_UNKNOWN
)
2446 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2447 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2449 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2450 "Failed to increment property '%s' by %f.\n",
2451 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2455 case MP_CMD_GET_PROPERTY
:{
2457 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2458 &tmp
, mpctx
) <= 0) {
2459 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2460 "Failed to get value of property '%s'.\n",
2464 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2465 cmd
->args
[0].v
.s
, tmp
);
2470 case MP_CMD_EDL_MARK
:
2472 float v
= sh_video
? sh_video
->pts
:
2473 playing_audio_pts(mpctx
);
2474 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2475 mpctx
->begin_skip
= v
;
2476 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2478 if (mpctx
->begin_skip
> v
)
2479 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2481 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2482 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2484 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2489 case MP_CMD_SWITCH_RATIO
:
2492 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2493 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2495 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2496 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2499 case MP_CMD_SPEED_INCR
:{
2500 float v
= cmd
->args
[0].v
.f
;
2501 opts
->playback_speed
+= v
;
2502 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2503 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2504 opts
->playback_speed
);
2507 case MP_CMD_SPEED_MULT
:{
2508 float v
= cmd
->args
[0].v
.f
;
2509 opts
->playback_speed
*= v
;
2510 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2511 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2512 opts
->playback_speed
);
2515 case MP_CMD_SPEED_SET
:{
2516 float v
= cmd
->args
[0].v
.f
;
2517 opts
->playback_speed
= v
;
2518 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2519 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2520 opts
->playback_speed
);
2523 case MP_CMD_FRAME_STEP
:
2524 add_step_frame(mpctx
);
2527 case MP_CMD_FILE_FILTER
:
2528 file_filter
= cmd
->args
[0].v
.i
;
2532 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2533 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2535 case MP_CMD_PLAY_TREE_STEP
:{
2536 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2537 int force
= cmd
->args
[1].v
.i
;
2540 if (!force
&& mpctx
->playtree_iter
) {
2541 play_tree_iter_t
*i
=
2542 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2543 if (play_tree_iter_step(i
, n
, 0) ==
2544 PLAY_TREE_ITER_ENTRY
)
2546 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2547 play_tree_iter_free(i
);
2549 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2550 if (mpctx
->stop_play
)
2551 mpctx
->play_tree_step
= n
;
2556 case MP_CMD_PLAY_TREE_UP_STEP
:{
2557 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2558 int force
= cmd
->args
[1].v
.i
;
2560 if (!force
&& mpctx
->playtree_iter
) {
2561 play_tree_iter_t
*i
=
2562 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2563 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2564 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2565 play_tree_iter_free(i
);
2567 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2571 case MP_CMD_PLAY_ALT_SRC_STEP
:
2572 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2573 int v
= cmd
->args
[0].v
.i
;
2575 && mpctx
->playtree_iter
->file
<
2576 mpctx
->playtree_iter
->num_files
)
2577 mpctx
->stop_play
= PT_NEXT_SRC
;
2578 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2579 mpctx
->stop_play
= PT_PREV_SRC
;
2583 case MP_CMD_SUB_STEP
:
2585 int movement
= cmd
->args
[0].v
.i
;
2586 step_sub(subdata
, sh_video
->pts
, movement
);
2590 ass_step_sub(ass_track
,
2592 sub_delay
) * 1000 + .5, movement
) / 1000.;
2594 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2595 _("Sub delay: %d ms"), ROUND(sub_delay
* 1000));
2599 case MP_CMD_SUB_LOG
:
2604 int v
= cmd
->args
[0].v
.i
;
2606 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2607 if (opts
->osd_level
> max
)
2608 opts
->osd_level
= max
;
2610 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2612 opts
->osd_level
= v
> max
? max
: v
;
2613 /* Show OSD state when disabled, but not when an explicit
2614 argument is given to the OSD command, i.e. in slave mode. */
2615 if (v
== -1 && opts
->osd_level
<= 1)
2616 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2618 opts
->osd_level
? _("enabled") :
2621 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2625 case MP_CMD_OSD_SHOW_TEXT
:
2626 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2628 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2629 "%-.63s", cmd
->args
[0].v
.s
);
2632 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2633 char *txt
= m_properties_expand_string(mp_properties
,
2636 /* if no argument supplied take default osd_duration, else <arg> ms. */
2638 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2640 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2647 case MP_CMD_LOADFILE
:{
2648 play_tree_t
*e
= play_tree_new();
2649 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2651 if (cmd
->args
[1].v
.i
) // append
2652 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2654 // Go back to the starting point.
2655 while (play_tree_iter_up_step
2656 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2658 play_tree_free_list(mpctx
->playtree
->child
, 1);
2659 play_tree_set_child(mpctx
->playtree
, e
);
2660 pt_iter_goto_head(mpctx
->playtree_iter
);
2661 mpctx
->stop_play
= PT_NEXT_SRC
;
2666 case MP_CMD_LOADLIST
:{
2667 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2669 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2670 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2672 if (cmd
->args
[1].v
.i
) // append
2673 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2675 // Go back to the starting point.
2676 while (play_tree_iter_up_step
2677 (mpctx
->playtree_iter
, 0, 1)
2678 != 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
;
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
;
2698 case MP_CMD_RADIO_STEP_CHANNEL
:
2699 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2700 int v
= cmd
->args
[0].v
.i
;
2702 radio_step_channel(mpctx
->demuxer
->stream
,
2703 RADIO_CHANNEL_HIGHER
);
2705 radio_step_channel(mpctx
->demuxer
->stream
,
2706 RADIO_CHANNEL_LOWER
);
2707 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2708 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2710 radio_get_channel_name(mpctx
->demuxer
->stream
));
2715 case MP_CMD_RADIO_SET_CHANNEL
:
2716 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2717 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2718 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2719 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2721 radio_get_channel_name(mpctx
->demuxer
->stream
));
2726 case MP_CMD_RADIO_SET_FREQ
:
2727 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2728 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2731 case MP_CMD_RADIO_STEP_FREQ
:
2732 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2733 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2738 case MP_CMD_TV_START_SCAN
:
2739 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2740 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2742 case MP_CMD_TV_SET_FREQ
:
2743 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2744 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2745 cmd
->args
[0].v
.f
* 16.0);
2747 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2748 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2749 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2750 pvr_get_current_channelname (mpctx
->stream
),
2751 pvr_get_current_stationname (mpctx
->stream
));
2753 #endif /* CONFIG_PVR */
2756 case MP_CMD_TV_STEP_FREQ
:
2757 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2758 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2759 cmd
->args
[0].v
.f
* 16.0);
2761 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2762 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2763 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2764 pvr_get_current_channelname (mpctx
->stream
),
2765 pvr_get_current_frequency (mpctx
->stream
));
2767 #endif /* CONFIG_PVR */
2770 case MP_CMD_TV_SET_NORM
:
2771 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2772 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2776 case MP_CMD_TV_STEP_CHANNEL
:{
2777 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2778 int v
= cmd
->args
[0].v
.i
;
2780 tv_step_channel((tvi_handle_t
*) (mpctx
->
2784 tv_step_channel((tvi_handle_t
*) (mpctx
->
2788 if (tv_channel_list
) {
2789 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2790 _("Channel: %s"), tv_channel_current
->name
);
2791 //vo_osd_changed(OSDTYPE_SUBTITLE);
2795 else if (mpctx
->stream
&&
2796 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2797 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2798 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2799 pvr_get_current_channelname (mpctx
->stream
),
2800 pvr_get_current_stationname (mpctx
->stream
));
2802 #endif /* CONFIG_PVR */
2805 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2807 int v
= cmd
->args
[0].v
.i
;
2809 mpctx
->last_dvb_step
= v
;
2811 dir
= DVB_CHANNEL_HIGHER
;
2813 dir
= DVB_CHANNEL_LOWER
;
2816 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2817 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2818 mpctx
->dvbin_reopen
= 1;
2821 #endif /* CONFIG_DVBIN */
2824 case MP_CMD_TV_SET_CHANNEL
:
2825 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2826 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2828 if (tv_channel_list
) {
2829 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2830 _("Channel: %s"), tv_channel_current
->name
);
2831 //vo_osd_changed(OSDTYPE_SUBTITLE);
2835 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2836 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2837 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2838 pvr_get_current_channelname (mpctx
->stream
),
2839 pvr_get_current_stationname (mpctx
->stream
));
2841 #endif /* CONFIG_PVR */
2845 case MP_CMD_DVB_SET_CHANNEL
:
2846 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2847 mpctx
->last_dvb_step
= 1;
2849 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2850 cmd
->args
[0].v
.i
)) {
2851 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2852 mpctx
->dvbin_reopen
= 1;
2856 #endif /* CONFIG_DVBIN */
2858 case MP_CMD_TV_LAST_CHANNEL
:
2859 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2860 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2861 if (tv_channel_list
) {
2862 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2863 _("Channel: %s"), tv_channel_current
->name
);
2864 //vo_osd_changed(OSDTYPE_SUBTITLE);
2868 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2869 pvr_set_lastchannel (mpctx
->stream
);
2870 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2871 pvr_get_current_channelname (mpctx
->stream
),
2872 pvr_get_current_stationname (mpctx
->stream
));
2874 #endif /* CONFIG_PVR */
2877 case MP_CMD_TV_STEP_NORM
:
2878 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2879 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2882 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2883 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2884 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2886 #ifdef CONFIG_TV_TELETEXT
2887 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2889 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2890 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2891 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2894 case MP_CMD_TV_TELETEXT_GO_LINK
:
2896 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2897 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2898 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2901 #endif /* CONFIG_TV_TELETEXT */
2902 #endif /* CONFIG_TV */
2904 case MP_CMD_SUB_LOAD
:
2906 int n
= mpctx
->set_of_sub_size
;
2907 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2908 if (n
!= mpctx
->set_of_sub_size
) {
2909 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2910 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2911 mpctx
->global_sub_size
;
2912 ++mpctx
->global_sub_size
;
2917 case MP_CMD_SUB_REMOVE
:
2919 int v
= cmd
->args
[0].v
.i
;
2922 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2923 subd
= mpctx
->set_of_subtitles
[v
];
2924 mp_tmsg(MSGT_CPLAYER
, MSGL_STATUS
,
2925 "SUB: Removed subtitle file (%d): %s\n", v
+ 1,
2926 filename_recode(subd
->filename
));
2928 mpctx
->set_of_subtitles
[v
] = NULL
;
2930 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2931 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2932 mpctx
->set_of_sub_size
= 0;
2933 if (mpctx
->set_of_sub_pos
>= 0) {
2934 mpctx
->global_sub_pos
= -2;
2936 mp_input_queue_cmd(mpctx
->input
,
2937 mp_input_parse_cmd("sub_select"));
2939 } else if (v
< mpctx
->set_of_sub_size
) {
2940 subd
= mpctx
->set_of_subtitles
[v
];
2941 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2942 "SUB: Removed subtitle file (%d): %s\n", v
+ 1,
2943 filename_recode(subd
->filename
));
2945 if (mpctx
->set_of_sub_pos
== v
) {
2946 mpctx
->global_sub_pos
= -2;
2948 mp_input_queue_cmd(mpctx
->input
,
2949 mp_input_parse_cmd("sub_select"));
2950 } else if (mpctx
->set_of_sub_pos
> v
) {
2951 --mpctx
->set_of_sub_pos
;
2952 --mpctx
->global_sub_pos
;
2954 while (++v
< mpctx
->set_of_sub_size
)
2955 mpctx
->set_of_subtitles
[v
- 1] =
2956 mpctx
->set_of_subtitles
[v
];
2957 --mpctx
->set_of_sub_size
;
2958 --mpctx
->global_sub_size
;
2959 if (mpctx
->set_of_sub_size
<= 0)
2960 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2961 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2966 case MP_CMD_GET_SUB_VISIBILITY
:
2968 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2969 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2973 case MP_CMD_SCREENSHOT
:
2974 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
2975 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2977 ((vf_instance_t
*) sh_video
->vfilter
)->
2978 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2980 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2984 case MP_CMD_AF_EQ_SET
:{
2985 af_instance_t
* m1
=af_get(sh_audio
->afilter
, "equalizer");
2986 if (m1
) m1
->control( m1
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[0].v
.s
);
2987 else mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -af equalizer=0:0 ?)\n");
2991 case MP_CMD_VF_CHANGE_RECTANGLE
:
2994 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2997 case MP_CMD_GET_TIME_LENGTH
:{
2998 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2999 demuxer_get_time_length(mpctx
->demuxer
));
3003 case MP_CMD_GET_FILENAME
:{
3004 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3005 get_metadata(mpctx
, META_NAME
));
3009 case MP_CMD_GET_VIDEO_CODEC
:{
3010 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3013 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3018 case MP_CMD_GET_VIDEO_BITRATE
:{
3019 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3022 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3027 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3028 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3031 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3032 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3037 case MP_CMD_GET_AUDIO_CODEC
:{
3038 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3041 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3046 case MP_CMD_GET_AUDIO_BITRATE
:{
3047 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3050 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3055 case MP_CMD_GET_AUDIO_SAMPLES
:{
3056 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3059 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3064 case MP_CMD_GET_META_TITLE
:{
3065 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3068 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3073 case MP_CMD_GET_META_ARTIST
:{
3074 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3077 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3082 case MP_CMD_GET_META_ALBUM
:{
3083 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3086 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3091 case MP_CMD_GET_META_YEAR
:{
3092 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3095 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3100 case MP_CMD_GET_META_COMMENT
:{
3101 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3104 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3109 case MP_CMD_GET_META_TRACK
:{
3110 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3113 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3118 case MP_CMD_GET_META_GENRE
:{
3119 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3122 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3127 case MP_CMD_GET_VO_FULLSCREEN
:
3128 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3129 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3132 case MP_CMD_GET_PERCENT_POS
:
3133 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3134 demuxer_get_percent_pos(mpctx
->demuxer
));
3137 case MP_CMD_GET_TIME_POS
:{
3140 pos
= sh_video
->pts
;
3141 else if (sh_audio
&& mpctx
->audio_out
)
3142 pos
= playing_audio_pts(mpctx
);
3143 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3150 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3156 case MP_CMD_KEYDOWN_EVENTS
:
3157 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3160 case MP_CMD_SET_MOUSE_POS
:{
3161 int pointer_x
, pointer_y
;
3163 pointer_x
= cmd
->args
[0].v
.i
;
3164 pointer_y
= cmd
->args
[1].v
.i
;
3165 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3166 #ifdef CONFIG_DVDNAV
3167 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3168 && dx
> 0.0 && dy
> 0.0) {
3170 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3171 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3172 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3173 pointer_x
, pointer_y
, &button
);
3174 if (opts
->osd_level
> 1 && button
> 0)
3175 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3176 "Selected button number %d", button
);
3180 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3181 menu_update_mouse_pos(dx
, dy
);
3186 #ifdef CONFIG_DVDNAV
3187 case MP_CMD_DVDNAV
:{
3190 mp_command_type command
= 0;
3191 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3194 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3195 if (cmd
->args
[0].v
.s
&&
3196 !strcasecmp (cmd
->args
[0].v
.s
,
3197 mp_dvdnav_bindings
[i
].name
))
3198 command
= mp_dvdnav_bindings
[i
].cmd
;
3200 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3201 if (opts
->osd_level
> 1 && button
> 0)
3202 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3203 "Selected button number %d", button
);
3207 case MP_CMD_SWITCH_TITLE
:
3208 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3209 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3215 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3216 "Received unknown cmd %s\n", cmd
->name
);
3219 switch (cmd
->pausing
) {
3220 case 1: // "pausing"
3221 pause_player(mpctx
);
3223 case 3: // "pausing_toggle"
3225 unpause_player(mpctx
);
3227 pause_player(mpctx
);