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"
31 #include "libmpcodecs/dec_teletext.h"
36 #include "stream/tv.h"
37 #include "stream/stream_radio.h"
38 #include "stream/pvr.h"
40 #include "stream/dvbin.h"
43 #include "stream/stream_dvd.h"
45 #include "stream/stream_dvdnav.h"
47 #include "libmenu/menu.h"
51 #include "libavutil/avstring.h"
53 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
57 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
58 double *dx
, double *dy
)
60 struct MPOpts
*opts
= &mpctx
->opts
;
61 struct vo
*vo
= mpctx
->video_out
;
62 //remove the borders, if any, and rescale to the range [0,1],[0,1]
63 if (vo_fs
) { //we are in full-screen mode
64 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
65 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
66 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
67 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
69 if (ix
< 0 || ix
> vo
->dwidth
) {
72 } //we are on one of the borders
73 if (iy
< 0 || iy
> vo
->dheight
) {
76 } //we are on one of the borders
79 *dx
= (double) ix
/ (double) vo
->dwidth
;
80 *dy
= (double) iy
/ (double) vo
->dheight
;
82 mp_msg(MSGT_CPLAYER
, MSGL_V
,
83 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
84 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
88 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
93 for (i
= 0; i
< SUB_SOURCES
; i
++) {
94 int j
= mpctx
->global_sub_indices
[i
];
95 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
103 static int sub_source(MPContext
*mpctx
)
105 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
109 * \brief Log the currently displayed subtitle to a file
111 * Logs the current or last displayed subtitle together with filename
112 * and time information to ~/.mplayer/subtitle_log
114 * Intended purpose is to allow convenient marking of bogus subtitles
115 * which need to be fixed while watching the movie.
118 static void log_sub(struct MPContext
*mpctx
)
124 if (subdata
== NULL
|| vo_sub_last
== NULL
)
126 fname
= get_path("subtitle_log");
127 f
= fopen(fname
, "a");
130 fprintf(f
, "----------------------------------------------------------\n");
131 if (subdata
->sub_uses_time
) {
133 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
134 mpctx
->filename
, vo_sub_last
->start
/ 360000,
135 (vo_sub_last
->start
/ 6000) % 60,
136 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
137 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
138 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
140 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
141 vo_sub_last
->start
, vo_sub_last
->end
);
143 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
144 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
150 /// \defgroup Properties
153 /// \defgroup GeneralProperties General properties
154 /// \ingroup Properties
158 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
161 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
165 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
168 struct MPOpts
*opts
= &mpctx
->opts
;
170 case M_PROPERTY_PRINT
:
171 if (!arg
) return M_PROPERTY_ERROR
;
172 if (opts
->loop_times
< 0)
173 *(char**)arg
= strdup("off");
174 else if (opts
->loop_times
== 0)
175 *(char**)arg
= strdup("inf");
178 return M_PROPERTY_OK
;
180 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
183 /// Playback speed (RW)
184 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
185 void *arg
, MPContext
*mpctx
)
187 struct MPOpts
*opts
= &mpctx
->opts
;
191 return M_PROPERTY_ERROR
;
192 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
193 opts
->playback_speed
= *(float *) arg
;
194 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
195 return M_PROPERTY_OK
;
196 case M_PROPERTY_STEP_UP
:
197 case M_PROPERTY_STEP_DOWN
:
198 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
199 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
200 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
201 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
202 return M_PROPERTY_OK
;
204 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
207 /// filename with path (RO)
208 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
211 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
214 /// filename without path (RO)
215 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
219 if (!mpctx
->filename
)
220 return M_PROPERTY_UNAVAILABLE
;
221 if (((f
= strrchr(mpctx
->filename
, '/'))
222 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
226 return m_property_string_ro(prop
, action
, arg
, f
);
229 /// Demuxer name (RO)
230 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
234 return M_PROPERTY_UNAVAILABLE
;
235 return m_property_string_ro(prop
, action
, arg
,
236 (char *) mpctx
->demuxer
->desc
->name
);
239 /// Position in the stream (RW)
240 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
243 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
244 return M_PROPERTY_UNAVAILABLE
;
246 return M_PROPERTY_ERROR
;
249 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
250 return M_PROPERTY_OK
;
252 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
253 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
254 return M_PROPERTY_OK
;
256 return M_PROPERTY_NOT_IMPLEMENTED
;
259 /// Stream start offset (RO)
260 static int mp_property_stream_start(m_option_t
*prop
, int action
,
261 void *arg
, MPContext
*mpctx
)
263 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
264 return M_PROPERTY_UNAVAILABLE
;
267 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
268 return M_PROPERTY_OK
;
270 return M_PROPERTY_NOT_IMPLEMENTED
;
273 /// Stream end offset (RO)
274 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
277 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
278 return M_PROPERTY_UNAVAILABLE
;
281 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
282 return M_PROPERTY_OK
;
284 return M_PROPERTY_NOT_IMPLEMENTED
;
287 /// Stream length (RO)
288 static int mp_property_stream_length(m_option_t
*prop
, int action
,
289 void *arg
, MPContext
*mpctx
)
291 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
292 return M_PROPERTY_UNAVAILABLE
;
296 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
297 return M_PROPERTY_OK
;
299 return M_PROPERTY_NOT_IMPLEMENTED
;
302 /// Media length in seconds (RO)
303 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
308 if (!mpctx
->demuxer
||
309 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
310 return M_PROPERTY_UNAVAILABLE
;
312 return m_property_time_ro(prop
, action
, arg
, len
);
315 /// Current position in percent (RW)
316 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
317 void *arg
, MPContext
*mpctx
) {
321 return M_PROPERTY_UNAVAILABLE
;
325 if(!arg
) return M_PROPERTY_ERROR
;
326 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
329 case M_PROPERTY_STEP_UP
:
330 case M_PROPERTY_STEP_DOWN
:
331 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
332 pos
+= (arg
? *(int*)arg
: 10) *
333 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
334 M_PROPERTY_CLAMP(prop
, pos
);
337 return m_property_int_ro(prop
, action
, arg
,
338 demuxer_get_percent_pos(mpctx
->demuxer
));
341 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
342 mpctx
->rel_seek_secs
= pos
/ 100.0;
343 return M_PROPERTY_OK
;
346 /// Current position in seconds (RW)
347 static int mp_property_time_pos(m_option_t
*prop
, int action
,
348 void *arg
, MPContext
*mpctx
) {
349 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
350 return M_PROPERTY_UNAVAILABLE
;
354 if(!arg
) return M_PROPERTY_ERROR
;
355 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
356 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
357 mpctx
->rel_seek_secs
= *(double*)arg
;
358 return M_PROPERTY_OK
;
359 case M_PROPERTY_STEP_UP
:
360 case M_PROPERTY_STEP_DOWN
:
361 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
362 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
363 return M_PROPERTY_OK
;
365 return m_property_time_ro(prop
, action
, arg
,
366 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
367 playing_audio_pts(mpctx
));
370 /// Current chapter (RW)
371 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
374 struct MPOpts
*opts
= &mpctx
->opts
;
377 char *chapter_name
= NULL
;
380 chapter
= get_current_chapter(mpctx
);
382 return M_PROPERTY_UNAVAILABLE
;
387 return M_PROPERTY_ERROR
;
388 *(int *) arg
= chapter
;
389 return M_PROPERTY_OK
;
390 case M_PROPERTY_PRINT
: {
392 return M_PROPERTY_ERROR
;
393 chapter_name
= chapter_display_name(mpctx
, chapter
);
395 return M_PROPERTY_UNAVAILABLE
;
396 *(char **) arg
= chapter_name
;
397 return M_PROPERTY_OK
;
401 return M_PROPERTY_ERROR
;
402 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
403 step_all
= *(int *)arg
- chapter
;
406 case M_PROPERTY_STEP_UP
:
407 case M_PROPERTY_STEP_DOWN
: {
408 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
409 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
416 return M_PROPERTY_NOT_IMPLEMENTED
;
420 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
421 mpctx
->rel_seek_secs
= 0;
422 mpctx
->abs_seek_pos
= 0;
424 if (next_pts
> -1.0) {
425 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
426 mpctx
->rel_seek_secs
= next_pts
;
429 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
430 _("Chapter: (%d) %s"), chapter
+ 1, chapter_name
);
432 else if (step_all
> 0)
433 mpctx
->rel_seek_secs
= 1000000000.;
435 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
436 _("Chapter: (%d) %s"), 0, _("unknown"));
438 talloc_free(chapter_name
);
439 return M_PROPERTY_OK
;
442 /// Number of chapters in file
443 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
447 return M_PROPERTY_UNAVAILABLE
;
448 if (mpctx
->demuxer
->num_chapters
== 0)
449 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
450 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
453 /// Current dvd angle (RW)
454 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
457 struct MPOpts
*opts
= &mpctx
->opts
;
460 char *angle_name
= NULL
;
463 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
465 return M_PROPERTY_UNAVAILABLE
;
466 angles
= demuxer_angles_count(mpctx
->demuxer
);
468 return M_PROPERTY_UNAVAILABLE
;
473 return M_PROPERTY_ERROR
;
474 *(int *) arg
= angle
;
475 return M_PROPERTY_OK
;
476 case M_PROPERTY_PRINT
: {
478 return M_PROPERTY_ERROR
;
479 angle_name
= calloc(1, 64);
481 return M_PROPERTY_UNAVAILABLE
;
482 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
483 *(char **) arg
= angle_name
;
484 return M_PROPERTY_OK
;
488 return M_PROPERTY_ERROR
;
490 M_PROPERTY_CLAMP(prop
, angle
);
492 case M_PROPERTY_STEP_UP
:
493 case M_PROPERTY_STEP_DOWN
: {
499 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
501 if (angle
< 1) //cycle
506 return M_PROPERTY_NOT_IMPLEMENTED
;
508 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
509 set_osd_msg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
510 _("Angle: %d/%d"), angle
, angles
);
513 return M_PROPERTY_OK
;
516 /// Demuxer meta data
517 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
519 m_property_action_t
* ka
;
521 static const m_option_t key_type
=
522 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
524 return M_PROPERTY_UNAVAILABLE
;
528 if(!arg
) return M_PROPERTY_ERROR
;
529 *(char***)arg
= mpctx
->demuxer
->info
;
530 return M_PROPERTY_OK
;
531 case M_PROPERTY_KEY_ACTION
:
532 if(!arg
) return M_PROPERTY_ERROR
;
534 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
535 return M_PROPERTY_UNKNOWN
;
538 if(!ka
->arg
) return M_PROPERTY_ERROR
;
539 *(char**)ka
->arg
= meta
;
540 return M_PROPERTY_OK
;
541 case M_PROPERTY_GET_TYPE
:
542 if(!ka
->arg
) return M_PROPERTY_ERROR
;
543 *(m_option_t
**)ka
->arg
= &key_type
;
544 return M_PROPERTY_OK
;
547 return M_PROPERTY_NOT_IMPLEMENTED
;
550 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
553 MPContext
*mpctx
= ctx
;
558 return M_PROPERTY_ERROR
;
559 if (mpctx
->paused
== (bool)*(int *) arg
)
560 return M_PROPERTY_OK
;
561 case M_PROPERTY_STEP_UP
:
562 case M_PROPERTY_STEP_DOWN
:
564 unpause_player(mpctx
);
565 mpctx
->osd_function
= OSD_PLAY
;
569 mpctx
->osd_function
= OSD_PAUSE
;
571 return M_PROPERTY_OK
;
573 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
580 /// \defgroup AudioProperties Audio properties
581 /// \ingroup Properties
585 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
589 if (!mpctx
->sh_audio
)
590 return M_PROPERTY_UNAVAILABLE
;
595 return M_PROPERTY_ERROR
;
596 mixer_getbothvolume(&mpctx
->mixer
, arg
);
597 return M_PROPERTY_OK
;
598 case M_PROPERTY_PRINT
:{
601 return M_PROPERTY_ERROR
;
602 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
603 return m_property_float_range(prop
, action
, arg
, &vol
);
605 case M_PROPERTY_STEP_UP
:
606 case M_PROPERTY_STEP_DOWN
:
610 return M_PROPERTY_NOT_IMPLEMENTED
;
613 if (mpctx
->edl_muted
)
614 return M_PROPERTY_DISABLED
;
615 mpctx
->user_muted
= 0;
620 return M_PROPERTY_ERROR
;
621 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
622 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
623 return M_PROPERTY_OK
;
624 case M_PROPERTY_STEP_UP
:
625 if (arg
&& *(float *) arg
<= 0)
626 mixer_decvolume(&mpctx
->mixer
);
628 mixer_incvolume(&mpctx
->mixer
);
629 return M_PROPERTY_OK
;
630 case M_PROPERTY_STEP_DOWN
:
631 if (arg
&& *(float *) arg
<= 0)
632 mixer_incvolume(&mpctx
->mixer
);
634 mixer_decvolume(&mpctx
->mixer
);
635 return M_PROPERTY_OK
;
637 return M_PROPERTY_NOT_IMPLEMENTED
;
641 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
645 if (!mpctx
->sh_audio
)
646 return M_PROPERTY_UNAVAILABLE
;
650 if (mpctx
->edl_muted
)
651 return M_PROPERTY_DISABLED
;
653 return M_PROPERTY_ERROR
;
654 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
655 mixer_mute(&mpctx
->mixer
);
656 mpctx
->user_muted
= mpctx
->mixer
.muted
;
657 return M_PROPERTY_OK
;
658 case M_PROPERTY_STEP_UP
:
659 case M_PROPERTY_STEP_DOWN
:
660 if (mpctx
->edl_muted
)
661 return M_PROPERTY_DISABLED
;
662 mixer_mute(&mpctx
->mixer
);
663 mpctx
->user_muted
= mpctx
->mixer
.muted
;
664 return M_PROPERTY_OK
;
665 case M_PROPERTY_PRINT
:
667 return M_PROPERTY_ERROR
;
668 if (mpctx
->edl_muted
) {
669 *(char **) arg
= strdup(_("enabled (EDL)"));
670 return M_PROPERTY_OK
;
673 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
679 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
680 void *arg
, MPContext
*mpctx
)
682 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
683 return M_PROPERTY_UNAVAILABLE
;
686 case M_PROPERTY_STEP_UP
:
687 case M_PROPERTY_STEP_DOWN
: {
689 float delay
= audio_delay
;
690 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
691 if (ret
!= M_PROPERTY_OK
)
694 mpctx
->delay
-= audio_delay
- delay
;
696 return M_PROPERTY_OK
;
698 return m_property_delay(prop
, action
, arg
, &audio_delay
);
702 /// Audio codec tag (RO)
703 static int mp_property_audio_format(m_option_t
*prop
, int action
,
704 void *arg
, MPContext
*mpctx
)
706 if (!mpctx
->sh_audio
)
707 return M_PROPERTY_UNAVAILABLE
;
708 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
711 /// Audio codec name (RO)
712 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
713 void *arg
, MPContext
*mpctx
)
715 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
716 return M_PROPERTY_UNAVAILABLE
;
717 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
720 /// Audio bitrate (RO)
721 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
722 void *arg
, MPContext
*mpctx
)
724 if (!mpctx
->sh_audio
)
725 return M_PROPERTY_UNAVAILABLE
;
726 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
730 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
733 if (!mpctx
->sh_audio
)
734 return M_PROPERTY_UNAVAILABLE
;
736 case M_PROPERTY_PRINT
:
737 if(!arg
) return M_PROPERTY_ERROR
;
738 *(char**)arg
= malloc(16);
739 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
740 return M_PROPERTY_OK
;
742 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
745 /// Number of channels (RO)
746 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
749 if (!mpctx
->sh_audio
)
750 return M_PROPERTY_UNAVAILABLE
;
752 case M_PROPERTY_PRINT
:
754 return M_PROPERTY_ERROR
;
755 switch (mpctx
->sh_audio
->channels
) {
757 *(char **) arg
= strdup("mono");
760 *(char **) arg
= strdup("stereo");
763 *(char **) arg
= malloc(32);
764 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
766 return M_PROPERTY_OK
;
768 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
772 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
777 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
778 return M_PROPERTY_UNAVAILABLE
;
783 return M_PROPERTY_ERROR
;
784 mixer_getbalance(&mpctx
->mixer
, arg
);
785 return M_PROPERTY_OK
;
786 case M_PROPERTY_PRINT
: {
789 return M_PROPERTY_ERROR
;
790 mixer_getbalance(&mpctx
->mixer
, &bal
);
792 *str
= strdup("center");
793 else if (bal
== -1.f
)
794 *str
= strdup("left only");
796 *str
= strdup("right only");
798 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
799 *str
= malloc(sizeof("left xxx%, right xxx%"));
800 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
802 return M_PROPERTY_OK
;
804 case M_PROPERTY_STEP_UP
:
805 case M_PROPERTY_STEP_DOWN
:
806 mixer_getbalance(&mpctx
->mixer
, &bal
);
807 bal
+= (arg
? *(float*)arg
: .1f
) *
808 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
809 M_PROPERTY_CLAMP(prop
, bal
);
810 mixer_setbalance(&mpctx
->mixer
, bal
);
811 return M_PROPERTY_OK
;
814 return M_PROPERTY_ERROR
;
815 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
816 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
817 return M_PROPERTY_OK
;
819 return M_PROPERTY_NOT_IMPLEMENTED
;
822 /// Selected audio id (RW)
823 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
826 struct MPOpts
*opts
= &mpctx
->opts
;
828 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
829 return M_PROPERTY_UNAVAILABLE
;
830 current_id
= mpctx
->demuxer
->audio
->id
;
835 return M_PROPERTY_ERROR
;
836 *(int *) arg
= current_id
;
837 return M_PROPERTY_OK
;
838 case M_PROPERTY_PRINT
:
840 return M_PROPERTY_ERROR
;
843 *(char **) arg
= strdup(_("disabled"));
845 char lang
[40] = _("unknown");
846 sh_audio_t
* sh
= mpctx
->sh_audio
;
848 av_strlcpy(lang
, sh
->lang
, 40);
849 #ifdef CONFIG_DVDREAD
850 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
851 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
861 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
862 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
864 *(char **) arg
= malloc(64);
865 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
867 return M_PROPERTY_OK
;
869 case M_PROPERTY_STEP_UP
:
871 if (action
== M_PROPERTY_SET
&& arg
)
872 tmp
= *((int *) arg
);
875 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
876 if (opts
->audio_id
== -2
877 || (opts
->audio_id
> -1
878 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
879 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
880 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
882 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
884 sh2
->ds
= mpctx
->demuxer
->audio
;
885 mpctx
->sh_audio
= sh2
;
886 reinit_audio_chain(mpctx
);
889 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
890 return M_PROPERTY_OK
;
892 return M_PROPERTY_NOT_IMPLEMENTED
;
897 /// Selected video id (RW)
898 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
901 struct MPOpts
*opts
= &mpctx
->opts
;
903 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
904 return M_PROPERTY_UNAVAILABLE
;
905 current_id
= mpctx
->demuxer
->video
->id
;
910 return M_PROPERTY_ERROR
;
911 *(int *) arg
= current_id
;
912 return M_PROPERTY_OK
;
913 case M_PROPERTY_PRINT
:
915 return M_PROPERTY_ERROR
;
918 *(char **) arg
= strdup(_("disabled"));
920 char lang
[40] = _("unknown");
921 *(char **) arg
= malloc(64);
922 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
924 return M_PROPERTY_OK
;
926 case M_PROPERTY_STEP_UP
:
928 if (action
== M_PROPERTY_SET
&& arg
)
929 tmp
= *((int *) arg
);
932 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
933 if (opts
->video_id
== -2
934 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
935 && current_id
!= -2))
936 uninit_player(mpctx
, INITIALIZED_VCODEC
|
937 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
938 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
940 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
942 sh2
->ds
= mpctx
->demuxer
->video
;
943 mpctx
->sh_video
= sh2
;
944 reinit_video_chain(mpctx
);
947 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
948 return M_PROPERTY_OK
;
951 return M_PROPERTY_NOT_IMPLEMENTED
;
955 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
958 demux_program_t prog
;
961 case M_PROPERTY_STEP_UP
:
963 if (action
== M_PROPERTY_SET
&& arg
)
964 prog
.progid
= *((int *) arg
);
968 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
969 &prog
) == DEMUXER_CTRL_NOTIMPL
)
970 return M_PROPERTY_ERROR
;
972 if (prog
.aid
< 0 && prog
.vid
< 0) {
973 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
974 return M_PROPERTY_ERROR
;
976 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
977 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
978 return M_PROPERTY_OK
;
981 return M_PROPERTY_NOT_IMPLEMENTED
;
987 /// \defgroup VideoProperties Video properties
988 /// \ingroup Properties
991 /// Fullscreen state (RW)
992 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
996 if (!mpctx
->video_out
)
997 return M_PROPERTY_UNAVAILABLE
;
1000 case M_PROPERTY_SET
:
1002 return M_PROPERTY_ERROR
;
1003 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1004 if (vo_fs
== !!*(int *) arg
)
1005 return M_PROPERTY_OK
;
1006 case M_PROPERTY_STEP_UP
:
1007 case M_PROPERTY_STEP_DOWN
:
1008 if (mpctx
->video_out
->config_ok
)
1009 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1010 mpctx
->opts
.fullscreen
= vo_fs
;
1011 return M_PROPERTY_OK
;
1013 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1017 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1018 void *arg
, MPContext
*mpctx
)
1022 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1023 return M_PROPERTY_UNAVAILABLE
;
1024 vf
= mpctx
->sh_video
->vfilter
;
1026 case M_PROPERTY_GET
:
1028 return M_PROPERTY_ERROR
;
1029 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1030 return M_PROPERTY_OK
;
1031 case M_PROPERTY_SET
:
1033 return M_PROPERTY_ERROR
;
1034 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1035 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1036 return M_PROPERTY_OK
;
1037 case M_PROPERTY_STEP_UP
:
1038 case M_PROPERTY_STEP_DOWN
:
1039 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1040 deinterlace
= !deinterlace
;
1041 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1042 return M_PROPERTY_OK
;
1045 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1046 return m_property_flag_ro(prop
, action
, arg
, value
);
1049 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1050 void *arg
, MPContext
*mpctx
)
1052 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1053 return M_PROPERTY_UNAVAILABLE
;
1055 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1058 case M_PROPERTY_GET
:
1060 return M_PROPERTY_ERROR
;
1061 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1062 return M_PROPERTY_UNAVAILABLE
;
1063 return M_PROPERTY_OK
;
1064 case M_PROPERTY_PRINT
:
1066 return M_PROPERTY_ERROR
;
1067 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1068 return M_PROPERTY_UNAVAILABLE
;
1069 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1070 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1071 *(char **)arg
= strdup("Unknown");
1073 *(char**)arg
= strdup(names
[colorspace
]);
1074 return M_PROPERTY_OK
;
1075 case M_PROPERTY_SET
:
1077 return M_PROPERTY_ERROR
;
1078 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1079 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1080 return M_PROPERTY_OK
;
1081 case M_PROPERTY_STEP_UP
:;
1082 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1083 return M_PROPERTY_UNAVAILABLE
;
1085 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1086 return M_PROPERTY_OK
;
1088 return M_PROPERTY_NOT_IMPLEMENTED
;
1092 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1096 if (!mpctx
->video_out
1097 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1098 return M_PROPERTY_UNAVAILABLE
;
1101 case M_PROPERTY_SET
:
1103 return M_PROPERTY_ERROR
;
1104 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1105 vo_panscan
= *(float *) arg
;
1106 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1107 return M_PROPERTY_OK
;
1108 case M_PROPERTY_STEP_UP
:
1109 case M_PROPERTY_STEP_DOWN
:
1110 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1111 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1114 else if (vo_panscan
< 0)
1116 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1117 return M_PROPERTY_OK
;
1119 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1123 /// Helper to set vo flags.
1124 /** \ingroup PropertyImplHelper
1126 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1127 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1130 if (!mpctx
->video_out
)
1131 return M_PROPERTY_UNAVAILABLE
;
1134 case M_PROPERTY_SET
:
1136 return M_PROPERTY_ERROR
;
1137 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1138 if (*vo_var
== !!*(int *) arg
)
1139 return M_PROPERTY_OK
;
1140 case M_PROPERTY_STEP_UP
:
1141 case M_PROPERTY_STEP_DOWN
:
1142 if (mpctx
->video_out
->config_ok
)
1143 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1144 return M_PROPERTY_OK
;
1146 return m_property_flag(prop
, action
, arg
, vo_var
);
1150 /// Window always on top (RW)
1151 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1154 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1155 &mpctx
->opts
.vo_ontop
, mpctx
);
1158 /// Display in the root window (RW)
1159 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1162 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1163 &vo_rootwin
, mpctx
);
1166 /// Show window borders (RW)
1167 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1170 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1174 /// Framedropping state (RW)
1175 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1176 void *arg
, MPContext
*mpctx
)
1179 if (!mpctx
->sh_video
)
1180 return M_PROPERTY_UNAVAILABLE
;
1183 case M_PROPERTY_PRINT
:
1185 return M_PROPERTY_ERROR
;
1186 *(char **) arg
= strdup(frame_dropping
== 1 ? _("enabled") :
1187 (frame_dropping
== 2 ? _("hard") :
1189 return M_PROPERTY_OK
;
1191 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1195 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1196 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1199 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1202 if (!mpctx
->sh_video
)
1203 return M_PROPERTY_UNAVAILABLE
;
1205 if (gamma
[0] == 1000) {
1207 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1211 case M_PROPERTY_SET
:
1213 return M_PROPERTY_ERROR
;
1214 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1215 *gamma
= *(int *) arg
;
1216 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1220 case M_PROPERTY_GET
:
1221 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1223 return M_PROPERTY_ERROR
;
1225 return M_PROPERTY_OK
;
1228 case M_PROPERTY_STEP_UP
:
1229 case M_PROPERTY_STEP_DOWN
:
1230 *gamma
+= (arg
? *(int *) arg
: 1) *
1231 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1232 M_PROPERTY_CLAMP(prop
, *gamma
);
1233 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1238 return M_PROPERTY_NOT_IMPLEMENTED
;
1242 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1243 int l
= strlen(prop
->name
);
1244 char tv_prop
[3 + l
+ 1];
1245 sprintf(tv_prop
, "tv_%s", prop
->name
);
1246 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1250 return M_PROPERTY_UNAVAILABLE
;
1254 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1257 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1260 /// Video codec tag (RO)
1261 static int mp_property_video_format(m_option_t
*prop
, int action
,
1262 void *arg
, MPContext
*mpctx
)
1265 if (!mpctx
->sh_video
)
1266 return M_PROPERTY_UNAVAILABLE
;
1268 case M_PROPERTY_PRINT
:
1270 return M_PROPERTY_ERROR
;
1271 switch(mpctx
->sh_video
->format
) {
1273 meta
= strdup ("mpeg1"); break;
1275 meta
= strdup ("mpeg2"); break;
1277 meta
= strdup ("mpeg4"); break;
1279 meta
= strdup ("h264"); break;
1281 if(mpctx
->sh_video
->format
>= 0x20202020) {
1283 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1286 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1289 *(char**)arg
= meta
;
1290 return M_PROPERTY_OK
;
1292 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1295 /// Video codec name (RO)
1296 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1297 void *arg
, MPContext
*mpctx
)
1299 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1300 return M_PROPERTY_UNAVAILABLE
;
1301 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1305 /// Video bitrate (RO)
1306 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1307 void *arg
, MPContext
*mpctx
)
1309 if (!mpctx
->sh_video
)
1310 return M_PROPERTY_UNAVAILABLE
;
1311 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1314 /// Video display width (RO)
1315 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1318 if (!mpctx
->sh_video
)
1319 return M_PROPERTY_UNAVAILABLE
;
1320 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1323 /// Video display height (RO)
1324 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1327 if (!mpctx
->sh_video
)
1328 return M_PROPERTY_UNAVAILABLE
;
1329 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1333 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1336 if (!mpctx
->sh_video
)
1337 return M_PROPERTY_UNAVAILABLE
;
1338 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1341 /// Video aspect (RO)
1342 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1345 if (!mpctx
->sh_video
)
1346 return M_PROPERTY_UNAVAILABLE
;
1347 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1352 /// \defgroup SubProprties Subtitles properties
1353 /// \ingroup Properties
1356 /// Text subtitle position (RW)
1357 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1361 case M_PROPERTY_SET
:
1363 return M_PROPERTY_ERROR
;
1364 case M_PROPERTY_STEP_UP
:
1365 case M_PROPERTY_STEP_DOWN
:
1366 vo_osd_changed(OSDTYPE_SUBTITLE
);
1368 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1372 /// Selected subtitles (RW)
1373 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1376 struct MPOpts
*opts
= &mpctx
->opts
;
1377 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1378 const int global_sub_size
= mpctx
->global_sub_size
;
1379 int source
= -1, reset_spu
= 0;
1382 if (global_sub_size
<= 0)
1383 return M_PROPERTY_UNAVAILABLE
;
1386 case M_PROPERTY_GET
:
1388 return M_PROPERTY_ERROR
;
1389 *(int *) arg
= mpctx
->global_sub_pos
;
1390 return M_PROPERTY_OK
;
1391 case M_PROPERTY_PRINT
:
1393 return M_PROPERTY_ERROR
;
1394 *(char **) arg
= malloc(64);
1395 (*(char **) arg
)[63] = 0;
1398 sub_name
= subdata
->filename
;
1400 if (ass_track
&& ass_track
->name
)
1401 sub_name
= ass_track
->name
;
1406 if ((tmp2
= strrchr(tmp
, '/')))
1409 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1410 mpctx
->set_of_sub_pos
+ 1,
1411 strlen(tmp
) < 20 ? "" : "...",
1412 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1413 return M_PROPERTY_OK
;
1415 #ifdef CONFIG_DVDNAV
1416 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1417 if (vo_spudec
&& opts
->sub_id
>= 0) {
1418 unsigned char lang
[3];
1419 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1420 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1421 return M_PROPERTY_OK
;
1427 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1428 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1429 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1430 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1431 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1432 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1433 if (!lang
) lang
= _("unknown");
1434 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1435 return M_PROPERTY_OK
;
1438 if (vo_vobsub
&& vobsub_id
>= 0) {
1439 const char *language
= _("unknown");
1440 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1441 snprintf(*(char **) arg
, 63, "(%d) %s",
1442 vobsub_id
, language
? language
: _("unknown"));
1443 return M_PROPERTY_OK
;
1445 #ifdef CONFIG_DVDREAD
1446 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1447 && opts
->sub_id
>= 0) {
1449 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1450 lang
[0] = code
>> 8;
1453 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1454 return M_PROPERTY_OK
;
1457 if (opts
->sub_id
>= 0) {
1458 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, _("unknown"));
1459 return M_PROPERTY_OK
;
1461 snprintf(*(char **) arg
, 63, _("disabled"));
1462 return M_PROPERTY_OK
;
1464 case M_PROPERTY_SET
:
1466 return M_PROPERTY_ERROR
;
1467 if (*(int *) arg
< -1)
1469 else if (*(int *) arg
>= global_sub_size
)
1470 *(int *) arg
= global_sub_size
- 1;
1471 mpctx
->global_sub_pos
= *(int *) arg
;
1473 case M_PROPERTY_STEP_UP
:
1474 mpctx
->global_sub_pos
+= 2;
1475 mpctx
->global_sub_pos
=
1476 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1478 case M_PROPERTY_STEP_DOWN
:
1479 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1480 mpctx
->global_sub_pos
=
1481 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1484 return M_PROPERTY_NOT_IMPLEMENTED
;
1487 if (mpctx
->global_sub_pos
>= 0)
1488 source
= sub_source(mpctx
);
1490 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1491 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1493 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1494 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1495 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1496 mpctx
->global_sub_pos
, source
);
1498 mpctx
->set_of_sub_pos
= -1;
1512 if (source
== SUB_SOURCE_VOBSUB
) {
1513 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1514 } else if (source
== SUB_SOURCE_SUBS
) {
1515 mpctx
->set_of_sub_pos
=
1516 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1518 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1519 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1523 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1524 vo_osd_changed(OSDTYPE_SUBTITLE
);
1526 } else if (source
== SUB_SOURCE_DEMUX
) {
1528 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1529 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1531 // default: assume 1:1 mapping of sid and stream id
1532 d_sub
->id
= opts
->sub_id
;
1533 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1534 ds_free_packs(d_sub
);
1535 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1536 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1537 if (sh
&& sh
->sid
== opts
->sub_id
) {
1543 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1544 sh_sub_t
*sh
= d_sub
->sh
;
1545 if (sh
->type
== 'v')
1546 init_vo_spudec(mpctx
);
1548 else if (opts
->ass_enabled
)
1549 ass_track
= sh
->ass_track
;
1557 #ifdef CONFIG_DVDREAD
1559 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1560 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1561 && opts
->sub_id
< 0 && reset_spu
) {
1567 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1569 return M_PROPERTY_OK
;
1572 /// Selected sub source (RW)
1573 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1577 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1578 return M_PROPERTY_UNAVAILABLE
;
1581 case M_PROPERTY_GET
:
1583 return M_PROPERTY_ERROR
;
1584 *(int *) arg
= sub_source(mpctx
);
1585 return M_PROPERTY_OK
;
1586 case M_PROPERTY_PRINT
:
1588 return M_PROPERTY_ERROR
;
1589 *(char **) arg
= malloc(64);
1590 (*(char **) arg
)[63] = 0;
1591 switch (sub_source(mpctx
))
1593 case SUB_SOURCE_SUBS
:
1594 snprintf(*(char **) arg
, 63, _("file"));
1596 case SUB_SOURCE_VOBSUB
:
1597 snprintf(*(char **) arg
, 63, _("vobsub"));
1599 case SUB_SOURCE_DEMUX
:
1600 snprintf(*(char **) arg
, 63, _("embedded"));
1603 snprintf(*(char **) arg
, 63, _("disabled"));
1605 return M_PROPERTY_OK
;
1606 case M_PROPERTY_SET
:
1608 return M_PROPERTY_ERROR
;
1609 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1610 if (*(int *) arg
< 0)
1611 mpctx
->global_sub_pos
= -1;
1612 else if (*(int *) arg
!= sub_source(mpctx
)) {
1613 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1614 return M_PROPERTY_UNAVAILABLE
;
1615 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1618 case M_PROPERTY_STEP_UP
:
1619 case M_PROPERTY_STEP_DOWN
: {
1620 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1621 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1622 int step
= (step_all
> 0) ? 1 : -1;
1623 int cur_source
= sub_source(mpctx
);
1624 source
= cur_source
;
1627 if (source
>= SUB_SOURCES
)
1629 else if (source
< -1)
1630 source
= SUB_SOURCES
- 1;
1631 if (source
== cur_source
|| source
== -1 ||
1632 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1635 if (source
== cur_source
)
1636 return M_PROPERTY_OK
;
1638 mpctx
->global_sub_pos
= -1;
1640 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1644 return M_PROPERTY_NOT_IMPLEMENTED
;
1646 --mpctx
->global_sub_pos
;
1647 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1650 /// Selected subtitles from specific source (RW)
1651 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1654 int source
, is_cur_source
, offset
;
1655 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1656 return M_PROPERTY_UNAVAILABLE
;
1658 if (!strcmp(prop
->name
, "sub_file"))
1659 source
= SUB_SOURCE_SUBS
;
1660 else if (!strcmp(prop
->name
, "sub_vob"))
1661 source
= SUB_SOURCE_VOBSUB
;
1662 else if (!strcmp(prop
->name
, "sub_demux"))
1663 source
= SUB_SOURCE_DEMUX
;
1665 return M_PROPERTY_ERROR
;
1667 offset
= mpctx
->global_sub_indices
[source
];
1668 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1669 return M_PROPERTY_UNAVAILABLE
;
1671 is_cur_source
= sub_source(mpctx
) == source
;
1673 case M_PROPERTY_GET
:
1675 return M_PROPERTY_ERROR
;
1676 if (is_cur_source
) {
1677 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1678 if (source
== SUB_SOURCE_VOBSUB
)
1679 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1683 return M_PROPERTY_OK
;
1684 case M_PROPERTY_PRINT
:
1686 return M_PROPERTY_ERROR
;
1688 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1689 *(char **) arg
= malloc(64);
1690 (*(char **) arg
)[63] = 0;
1691 snprintf(*(char **) arg
, 63, _("disabled"));
1692 return M_PROPERTY_OK
;
1693 case M_PROPERTY_SET
:
1695 return M_PROPERTY_ERROR
;
1696 if (*(int *) arg
>= 0) {
1697 int index
= *(int *)arg
;
1698 if (source
== SUB_SOURCE_VOBSUB
)
1699 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1700 mpctx
->global_sub_pos
= offset
+ index
;
1701 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1702 || sub_source(mpctx
) != source
) {
1703 mpctx
->global_sub_pos
= -1;
1708 mpctx
->global_sub_pos
= -1;
1710 case M_PROPERTY_STEP_UP
:
1711 case M_PROPERTY_STEP_DOWN
: {
1712 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1713 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1714 int step
= (step_all
> 0) ? 1 : -1;
1715 int max_sub_pos_for_source
= -1;
1717 mpctx
->global_sub_pos
= -1;
1719 if (mpctx
->global_sub_pos
== -1) {
1721 mpctx
->global_sub_pos
= offset
;
1722 else if (max_sub_pos_for_source
== -1) {
1723 // Find max pos for specific source
1724 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1725 while (mpctx
->global_sub_pos
>= 0
1726 && sub_source(mpctx
) != source
)
1727 --mpctx
->global_sub_pos
;
1730 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1733 mpctx
->global_sub_pos
+= step
;
1734 if (mpctx
->global_sub_pos
< offset
||
1735 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1736 sub_source(mpctx
) != source
)
1737 mpctx
->global_sub_pos
= -1;
1744 return M_PROPERTY_NOT_IMPLEMENTED
;
1746 --mpctx
->global_sub_pos
;
1747 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1750 /// Subtitle delay (RW)
1751 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1754 if (!mpctx
->sh_video
)
1755 return M_PROPERTY_UNAVAILABLE
;
1756 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1759 /// Alignment of text subtitles (RW)
1760 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1761 void *arg
, MPContext
*mpctx
)
1763 char *name
[] = { _("top"), _("center"), _("bottom") };
1765 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1766 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1767 return M_PROPERTY_UNAVAILABLE
;
1770 case M_PROPERTY_PRINT
:
1772 return M_PROPERTY_ERROR
;
1773 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1774 *(char **) arg
= strdup(name
[sub_alignment
]);
1775 return M_PROPERTY_OK
;
1776 case M_PROPERTY_SET
:
1778 return M_PROPERTY_ERROR
;
1779 case M_PROPERTY_STEP_UP
:
1780 case M_PROPERTY_STEP_DOWN
:
1781 vo_osd_changed(OSDTYPE_SUBTITLE
);
1783 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1787 /// Subtitle visibility (RW)
1788 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1789 void *arg
, MPContext
*mpctx
)
1791 if (!mpctx
->sh_video
)
1792 return M_PROPERTY_UNAVAILABLE
;
1795 case M_PROPERTY_SET
:
1797 return M_PROPERTY_ERROR
;
1798 case M_PROPERTY_STEP_UP
:
1799 case M_PROPERTY_STEP_DOWN
:
1800 vo_osd_changed(OSDTYPE_SUBTITLE
);
1802 vo_osd_changed(OSDTYPE_SPU
);
1804 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1809 /// Use margins for libass subtitles (RW)
1810 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1811 void *arg
, MPContext
*mpctx
)
1813 if (!mpctx
->sh_video
)
1814 return M_PROPERTY_UNAVAILABLE
;
1817 case M_PROPERTY_SET
:
1819 return M_PROPERTY_ERROR
;
1820 case M_PROPERTY_STEP_UP
:
1821 case M_PROPERTY_STEP_DOWN
:
1822 ass_force_reload
= 1;
1824 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1829 /// Show only forced subtitles (RW)
1830 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1831 void *arg
, MPContext
*mpctx
)
1834 return M_PROPERTY_UNAVAILABLE
;
1837 case M_PROPERTY_SET
:
1839 return M_PROPERTY_ERROR
;
1840 case M_PROPERTY_STEP_UP
:
1841 case M_PROPERTY_STEP_DOWN
:
1842 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1843 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1844 return M_PROPERTY_OK
;
1846 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1851 #ifdef CONFIG_FREETYPE
1852 /// Subtitle scale (RW)
1853 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1856 struct MPOpts
*opts
= &mpctx
->opts
;
1859 case M_PROPERTY_SET
:
1861 return M_PROPERTY_ERROR
;
1862 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1864 if (opts
->ass_enabled
) {
1865 ass_font_scale
= *(float *) arg
;
1866 ass_force_reload
= 1;
1869 text_font_scale_factor
= *(float *) arg
;
1870 force_load_font
= 1;
1871 return M_PROPERTY_OK
;
1872 case M_PROPERTY_STEP_UP
:
1873 case M_PROPERTY_STEP_DOWN
:
1875 if (opts
->ass_enabled
) {
1876 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1877 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1878 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1879 ass_force_reload
= 1;
1882 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1883 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1884 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1885 force_load_font
= 1;
1886 return M_PROPERTY_OK
;
1889 if (opts
->ass_enabled
)
1890 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1893 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1900 /// \defgroup TVProperties TV properties
1901 /// \ingroup Properties
1906 /// TV color settings (RW)
1907 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1911 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1912 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1913 return M_PROPERTY_UNAVAILABLE
;
1916 case M_PROPERTY_SET
:
1918 return M_PROPERTY_ERROR
;
1919 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1920 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1921 case M_PROPERTY_GET
:
1922 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1923 case M_PROPERTY_STEP_UP
:
1924 case M_PROPERTY_STEP_DOWN
:
1925 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1927 return M_PROPERTY_ERROR
;
1928 val
+= (arg
? *(int *) arg
: 1) *
1929 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1930 M_PROPERTY_CLAMP(prop
, val
);
1931 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1933 return M_PROPERTY_ERROR
;
1935 return M_PROPERTY_NOT_IMPLEMENTED
;
1940 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1944 int base_ioctl
=(int)prop
->priv
;
1946 for teletext's GET,SET,STEP ioctls this is not 0
1950 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1951 return M_PROPERTY_UNAVAILABLE
;
1953 return M_PROPERTY_ERROR
;
1956 case M_PROPERTY_GET
:
1958 return M_PROPERTY_ERROR
;
1959 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1961 case M_PROPERTY_SET
:
1963 return M_PROPERTY_ERROR
;
1964 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1965 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1967 case M_PROPERTY_STEP_UP
:
1968 case M_PROPERTY_STEP_DOWN
:
1969 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1970 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1971 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
1974 return M_PROPERTY_NOT_IMPLEMENTED
;
1977 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1980 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
1986 //with tvh==NULL will fail too
1987 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1988 if(result
!=M_PROPERTY_OK
)
1991 if(teletext_control(mpctx
->demuxer
->teletext
,
1992 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
1993 mp_input_set_section(mpctx
->input
, "teletext");
1995 mp_input_set_section(mpctx
->input
, "tv");
1996 return M_PROPERTY_OK
;
1999 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2004 if (!mpctx
->demuxer
->teletext
)
2005 return M_PROPERTY_UNAVAILABLE
;
2007 case M_PROPERTY_STEP_UP
:
2008 case M_PROPERTY_STEP_DOWN
:
2009 //This should be handled separately
2010 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2011 result
=teletext_control(mpctx
->demuxer
->teletext
,
2012 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2015 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2022 /// All properties available in MPlayer.
2023 /** \ingroup Properties
2025 static const m_option_t mp_properties
[] = {
2027 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2028 M_OPT_RANGE
, 0, 3, NULL
},
2029 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2030 M_OPT_MIN
, -1, 0, NULL
},
2031 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2032 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2033 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2035 { "path", mp_property_path
, CONF_TYPE_STRING
,
2037 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2039 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2040 M_OPT_MIN
, 0, 0, NULL
},
2041 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2042 M_OPT_MIN
, 0, 0, NULL
},
2043 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2044 M_OPT_MIN
, 0, 0, NULL
},
2045 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2046 M_OPT_MIN
, 0, 0, NULL
},
2047 { "length", mp_property_length
, CONF_TYPE_TIME
,
2048 M_OPT_MIN
, 0, 0, NULL
},
2049 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2050 M_OPT_RANGE
, 0, 100, NULL
},
2051 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2052 M_OPT_MIN
, 0, 0, NULL
},
2053 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2054 M_OPT_MIN
, 0, 0, NULL
},
2055 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2057 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2058 CONF_RANGE
, -2, 10, NULL
},
2059 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2061 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2062 M_OPT_RANGE
, 0, 1, NULL
},
2065 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2066 M_OPT_RANGE
, 0, 100, NULL
},
2067 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2068 M_OPT_RANGE
, 0, 1, NULL
},
2069 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2070 M_OPT_RANGE
, -100, 100, NULL
},
2071 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2073 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2075 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2077 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2079 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2081 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2082 CONF_RANGE
, -2, 65535, NULL
},
2083 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2084 M_OPT_RANGE
, -1, 1, NULL
},
2087 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2088 M_OPT_RANGE
, 0, 1, NULL
},
2089 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2090 M_OPT_RANGE
, 0, 1, NULL
},
2091 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2092 M_OPT_RANGE
, 0, 2, NULL
},
2093 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2094 M_OPT_RANGE
, 0, 1, NULL
},
2095 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2096 M_OPT_RANGE
, 0, 1, NULL
},
2097 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2098 M_OPT_RANGE
, 0, 1, NULL
},
2099 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2100 M_OPT_RANGE
, 0, 2, NULL
},
2101 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2102 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2103 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2104 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2105 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2106 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2107 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2108 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2109 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2110 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2111 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2112 M_OPT_RANGE
, 0, 1, NULL
},
2113 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2114 M_OPT_RANGE
, 0, 1, NULL
},
2115 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2117 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2119 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2121 { "width", mp_property_width
, CONF_TYPE_INT
,
2123 { "height", mp_property_height
, CONF_TYPE_INT
,
2125 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2127 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2129 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2130 CONF_RANGE
, -2, 65535, NULL
},
2131 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2132 CONF_RANGE
, -1, 65535, NULL
},
2135 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2136 M_OPT_MIN
, -1, 0, NULL
},
2137 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2138 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2139 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2140 M_OPT_MIN
, -1, 0, NULL
},
2141 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2142 M_OPT_MIN
, -1, 0, NULL
},
2143 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2144 M_OPT_MIN
, -1, 0, NULL
},
2145 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2147 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2148 M_OPT_RANGE
, 0, 100, NULL
},
2149 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2150 M_OPT_RANGE
, 0, 2, NULL
},
2151 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2152 M_OPT_RANGE
, 0, 1, NULL
},
2153 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2154 M_OPT_RANGE
, 0, 1, NULL
},
2155 #ifdef CONFIG_FREETYPE
2156 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2157 M_OPT_RANGE
, 0, 100, NULL
},
2160 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2161 M_OPT_RANGE
, 0, 1, NULL
},
2165 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2166 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2167 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2168 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2169 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2170 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2171 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2172 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2174 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2175 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2176 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2177 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2178 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2179 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2180 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2181 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2182 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2183 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2184 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2188 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2190 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2193 char* mp_property_print(const char *name
, void* ctx
)
2196 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2201 char *property_expand_string(MPContext
*mpctx
, char *str
)
2203 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2206 void property_print_help(void)
2208 m_properties_print_help_list(mp_properties
);
2212 /* List of default ways to show a property on OSD.
2214 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2215 * a bar showing the current position between min/max values of the
2216 * property. In this case osd_msg is only used for terminal output
2217 * if there is no video; it'll be a label shown together with percentage.
2219 * Otherwise setting osd_msg will show the string on OSD, formatted with
2220 * the text value of the property as argument.
2222 static struct property_osd_display
{
2225 /// progressbar type
2226 int osd_progbar
; // -1 is special value for seek indicators
2227 /// osd msg id if it must be shared
2229 /// osd msg template
2230 const char *osd_msg
;
2231 } property_osd_display
[] = {
2233 { "loop", 0, -1, _("Loop: %s") },
2234 { "chapter", -1, -1, NULL
},
2236 { "volume", OSD_VOLUME
, -1, _("Volume") },
2237 { "mute", 0, -1, _("Mute: %s") },
2238 { "audio_delay", 0, -1, _("A-V delay: %s") },
2239 { "switch_audio", 0, -1, _("Audio: %s") },
2240 { "balance", OSD_BALANCE
, -1, _("Balance") },
2242 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2243 { "ontop", 0, -1, _("Stay on top: %s") },
2244 { "rootwin", 0, -1, _("Rootwin: %s") },
2245 { "border", 0, -1, _("Border: %s") },
2246 { "framedropping", 0, -1, _("Framedropping: %s") },
2247 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2248 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2249 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2250 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2251 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2252 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2253 { "hue", OSD_HUE
, -1, _("Hue") },
2254 { "vsync", 0, -1, _("VSync: %s") },
2256 { "sub", 0, -1, _("Subtitles: %s") },
2257 { "sub_source", 0, -1, _("Sub source: %s") },
2258 { "sub_vob", 0, -1, _("Subtitles: %s") },
2259 { "sub_demux", 0, -1, _("Subtitles: %s") },
2260 { "sub_file", 0, -1, _("Subtitles: %s") },
2261 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2262 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2263 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2264 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2265 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2266 #ifdef CONFIG_FREETYPE
2267 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2270 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2271 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2272 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2273 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2278 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2280 struct MPOpts
*opts
= &mpctx
->opts
;
2283 struct property_osd_display
*p
;
2285 // look for the command
2286 for (p
= property_osd_display
; p
->name
; p
++)
2287 if (!strcmp(p
->name
, pname
))
2292 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2295 if (p
->osd_progbar
== -1)
2296 mpctx
->add_osd_seek_info
= true;
2297 else if (p
->osd_progbar
) {
2298 if (prop
->type
== CONF_TYPE_INT
) {
2299 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2300 set_osd_bar(mpctx
, p
->osd_progbar
, p
->osd_msg
,
2301 prop
->min
, prop
->max
, r
);
2302 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2304 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2305 set_osd_bar(mpctx
, p
->osd_progbar
, p
->osd_msg
,
2306 prop
->min
, prop
->max
, f
);
2308 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2309 "Property use an unsupported type.\n");
2316 char *val
= mp_property_print(pname
, mpctx
);
2318 int index
= p
- property_osd_display
;
2319 set_osd_msg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2320 1, opts
->osd_duration
, p
->osd_msg
, val
);
2329 * \defgroup Command2Property Command to property bridge
2331 * It is used to handle most commands that just set a property
2332 * and optionally display something on the OSD.
2333 * Two kinds of commands are handled: adjust or toggle.
2335 * Adjust commands take 1 or 2 parameters: <value> <abs>
2336 * If <abs> is non-zero the property is set to the given value
2337 * otherwise it is adjusted.
2339 * Toggle commands take 0 or 1 parameters. With no parameter
2340 * or a value less than the property minimum it just steps the
2341 * property to its next value. Otherwise it sets it to the given
2347 /// List of the commands that can be handled by setting a property.
2353 /// set/adjust or toggle command
2355 } set_prop_cmd
[] = {
2357 { "loop", MP_CMD_LOOP
, 0},
2358 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2359 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2360 { "pause", MP_CMD_PAUSE
, 0},
2362 { "volume", MP_CMD_VOLUME
, 0},
2363 { "mute", MP_CMD_MUTE
, 1},
2364 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2365 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2366 { "balance", MP_CMD_BALANCE
, 0},
2368 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2369 { "panscan", MP_CMD_PANSCAN
, 0},
2370 { "ontop", MP_CMD_VO_ONTOP
, 1},
2371 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2372 { "border", MP_CMD_VO_BORDER
, 1},
2373 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2374 { "gamma", MP_CMD_GAMMA
, 0},
2375 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2376 { "contrast", MP_CMD_CONTRAST
, 0},
2377 { "saturation", MP_CMD_SATURATION
, 0},
2378 { "hue", MP_CMD_HUE
, 0},
2379 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2381 { "sub", MP_CMD_SUB_SELECT
, 1},
2382 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2383 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2384 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2385 { "sub_file", MP_CMD_SUB_FILE
, 1},
2386 { "sub_pos", MP_CMD_SUB_POS
, 0},
2387 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2388 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2389 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2390 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2391 #ifdef CONFIG_FREETYPE
2392 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2395 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2398 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2399 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2400 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2401 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2406 /// Handle commands that set a property.
2407 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2413 // look for the command
2414 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2415 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2417 if (!(pname
= set_prop_cmd
[i
].name
))
2420 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2424 if (set_prop_cmd
[i
].toggle
) {
2426 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2427 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2429 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2430 } else if (cmd
->args
[1].v
.i
) //set
2431 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2433 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2438 show_property_osd(mpctx
, pname
);
2443 #ifdef CONFIG_DVDNAV
2444 static const struct {
2446 const mp_command_type cmd
;
2447 } mp_dvdnav_bindings
[] = {
2448 { "up", MP_CMD_DVDNAV_UP
},
2449 { "down", MP_CMD_DVDNAV_DOWN
},
2450 { "left", MP_CMD_DVDNAV_LEFT
},
2451 { "right", MP_CMD_DVDNAV_RIGHT
},
2452 { "menu", MP_CMD_DVDNAV_MENU
},
2453 { "select", MP_CMD_DVDNAV_SELECT
},
2454 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2455 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2458 * keep old dvdnav sub-command options for a while in order not to
2459 * break slave-mode API too suddenly.
2461 { "1", MP_CMD_DVDNAV_UP
},
2462 { "2", MP_CMD_DVDNAV_DOWN
},
2463 { "3", MP_CMD_DVDNAV_LEFT
},
2464 { "4", MP_CMD_DVDNAV_RIGHT
},
2465 { "5", MP_CMD_DVDNAV_MENU
},
2466 { "6", MP_CMD_DVDNAV_SELECT
},
2467 { "7", MP_CMD_DVDNAV_PREVMENU
},
2468 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2473 static const char *property_error_string(int error_value
)
2475 switch (error_value
) {
2476 case M_PROPERTY_ERROR
:
2478 case M_PROPERTY_UNAVAILABLE
:
2479 return "PROPERTY_UNAVAILABLE";
2480 case M_PROPERTY_NOT_IMPLEMENTED
:
2481 return "NOT_IMPLEMENTED";
2482 case M_PROPERTY_UNKNOWN
:
2483 return "PROPERTY_UNKNOWN";
2484 case M_PROPERTY_DISABLED
:
2490 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2492 struct MPOpts
*opts
= &mpctx
->opts
;
2493 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2494 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2495 int osd_duration
= opts
->osd_duration
;
2496 int case_fallthrough_hack
= 0;
2497 if (!set_property_command(mpctx
, cmd
))
2502 mpctx
->add_osd_seek_info
= true;
2503 v
= cmd
->args
[0].v
.f
;
2504 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2505 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2506 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2508 mpctx
->osd_function
=
2509 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2510 mpctx
->rel_seek_secs
= v
;
2511 } else if (abs
) { /* Absolute seek by percentage */
2512 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2514 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2515 mpctx
->rel_seek_secs
= v
/ 100.0;
2517 mpctx
->rel_seek_secs
+= v
;
2518 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2523 case MP_CMD_SET_PROPERTY_OSD
:
2524 case_fallthrough_hack
= 1;
2526 case MP_CMD_SET_PROPERTY
:{
2527 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2528 cmd
->args
[1].v
.s
, mpctx
);
2529 if (r
== M_PROPERTY_UNKNOWN
)
2530 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2531 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2533 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2534 "Failed to set property '%s' to '%s'.\n",
2535 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2536 else if (case_fallthrough_hack
)
2537 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2539 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2543 case MP_CMD_STEP_PROPERTY_OSD
:
2544 case_fallthrough_hack
= 1;
2546 case MP_CMD_STEP_PROPERTY
:{
2551 if (cmd
->args
[1].v
.f
) {
2553 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2554 M_PROPERTY_GET_TYPE
,
2555 &prop
, mpctx
)) <= 0)
2557 if(prop
->type
== CONF_TYPE_INT
||
2558 prop
->type
== CONF_TYPE_FLAG
)
2559 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2560 else if(prop
->type
== CONF_TYPE_FLOAT
)
2561 arg
= &cmd
->args
[1].v
.f
;
2562 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2563 prop
->type
== CONF_TYPE_TIME
)
2564 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2565 else if(prop
->type
== CONF_TYPE_POSITION
)
2566 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2568 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2569 "Ignoring step size stepping property '%s'.\n",
2572 r
= mp_property_do(cmd
->args
[0].v
.s
,
2573 cmd
->args
[2].v
.i
< 0 ?
2574 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2577 if (r
== M_PROPERTY_UNKNOWN
)
2578 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2579 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2581 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2582 "Failed to increment property '%s' by %f.\n",
2583 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2584 else if (case_fallthrough_hack
)
2585 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2587 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2591 case MP_CMD_GET_PROPERTY
:{
2593 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2596 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2597 "Failed to get value of property '%s'.\n",
2599 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2602 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2603 cmd
->args
[0].v
.s
, tmp
);
2608 case MP_CMD_EDL_MARK
:
2610 float v
= sh_video
? sh_video
->pts
:
2611 playing_audio_pts(mpctx
);
2612 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2613 mpctx
->begin_skip
= v
;
2614 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2616 if (mpctx
->begin_skip
> v
)
2617 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2619 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2620 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2622 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2627 case MP_CMD_SWITCH_RATIO
:
2630 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2631 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2633 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2634 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2637 case MP_CMD_SPEED_INCR
:{
2638 float v
= cmd
->args
[0].v
.f
;
2639 opts
->playback_speed
+= v
;
2640 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2641 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2642 opts
->playback_speed
);
2645 case MP_CMD_SPEED_MULT
:{
2646 float v
= cmd
->args
[0].v
.f
;
2647 opts
->playback_speed
*= v
;
2648 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2649 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2650 opts
->playback_speed
);
2653 case MP_CMD_SPEED_SET
:{
2654 float v
= cmd
->args
[0].v
.f
;
2655 opts
->playback_speed
= v
;
2656 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2657 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, _("Speed: x %6.2f"),
2658 opts
->playback_speed
);
2661 case MP_CMD_FRAME_STEP
:
2662 add_step_frame(mpctx
);
2665 case MP_CMD_FILE_FILTER
:
2666 file_filter
= cmd
->args
[0].v
.i
;
2670 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2671 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2673 case MP_CMD_PLAY_TREE_STEP
:{
2674 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2675 int force
= cmd
->args
[1].v
.i
;
2678 if (!force
&& mpctx
->playtree_iter
) {
2679 play_tree_iter_t
*i
=
2680 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2681 if (play_tree_iter_step(i
, n
, 0) ==
2682 PLAY_TREE_ITER_ENTRY
)
2684 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2685 play_tree_iter_free(i
);
2687 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2688 if (mpctx
->stop_play
)
2689 mpctx
->play_tree_step
= n
;
2694 case MP_CMD_PLAY_TREE_UP_STEP
:{
2695 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2696 int force
= cmd
->args
[1].v
.i
;
2698 if (!force
&& mpctx
->playtree_iter
) {
2699 play_tree_iter_t
*i
=
2700 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2701 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2702 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2703 play_tree_iter_free(i
);
2705 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2709 case MP_CMD_PLAY_ALT_SRC_STEP
:
2710 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2711 int v
= cmd
->args
[0].v
.i
;
2713 && mpctx
->playtree_iter
->file
<
2714 mpctx
->playtree_iter
->num_files
)
2715 mpctx
->stop_play
= PT_NEXT_SRC
;
2716 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2717 mpctx
->stop_play
= PT_PREV_SRC
;
2721 case MP_CMD_SUB_STEP
:
2723 int movement
= cmd
->args
[0].v
.i
;
2724 step_sub(subdata
, sh_video
->pts
, movement
);
2728 ass_step_sub(ass_track
,
2730 sub_delay
) * 1000 + .5, movement
) / 1000.;
2732 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2733 _("Sub delay: %d ms"), ROUND(sub_delay
* 1000));
2737 case MP_CMD_SUB_LOG
:
2742 int v
= cmd
->args
[0].v
.i
;
2744 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2745 if (opts
->osd_level
> max
)
2746 opts
->osd_level
= max
;
2748 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2750 opts
->osd_level
= v
> max
? max
: v
;
2751 /* Show OSD state when disabled, but not when an explicit
2752 argument is given to the OSD command, i.e. in slave mode. */
2753 if (v
== -1 && opts
->osd_level
<= 1)
2754 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2756 opts
->osd_level
? _("enabled") :
2759 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2763 case MP_CMD_OSD_SHOW_TEXT
:
2764 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2766 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2767 "%-.63s", cmd
->args
[0].v
.s
);
2770 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2771 char *txt
= m_properties_expand_string(mp_properties
,
2774 /* if no argument supplied take default osd_duration, else <arg> ms. */
2776 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2778 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2785 case MP_CMD_LOADFILE
:{
2786 play_tree_t
*e
= play_tree_new();
2787 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2789 if (cmd
->args
[1].v
.i
) // append
2790 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2792 // Go back to the starting point.
2793 while (play_tree_iter_up_step
2794 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2796 play_tree_free_list(mpctx
->playtree
->child
, 1);
2797 play_tree_set_child(mpctx
->playtree
, e
);
2798 pt_iter_goto_head(mpctx
->playtree_iter
);
2799 mpctx
->stop_play
= PT_NEXT_SRC
;
2804 case MP_CMD_LOADLIST
:{
2805 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2807 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2808 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2810 if (cmd
->args
[1].v
.i
) // append
2811 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2813 // Go back to the starting point.
2814 while (play_tree_iter_up_step
2815 (mpctx
->playtree_iter
, 0, 1)
2816 != PLAY_TREE_ITER_END
)
2818 play_tree_free_list(mpctx
->playtree
->child
, 1);
2819 play_tree_set_child(mpctx
->playtree
, e
);
2820 pt_iter_goto_head(mpctx
->playtree_iter
);
2821 mpctx
->stop_play
= PT_NEXT_SRC
;
2828 // Go back to the starting point.
2829 while (play_tree_iter_up_step
2830 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2832 mpctx
->stop_play
= PT_STOP
;
2836 case MP_CMD_RADIO_STEP_CHANNEL
:
2837 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2838 int v
= cmd
->args
[0].v
.i
;
2840 radio_step_channel(mpctx
->demuxer
->stream
,
2841 RADIO_CHANNEL_HIGHER
);
2843 radio_step_channel(mpctx
->demuxer
->stream
,
2844 RADIO_CHANNEL_LOWER
);
2845 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2846 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2848 radio_get_channel_name(mpctx
->demuxer
->stream
));
2853 case MP_CMD_RADIO_SET_CHANNEL
:
2854 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2855 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2856 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2857 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2859 radio_get_channel_name(mpctx
->demuxer
->stream
));
2864 case MP_CMD_RADIO_SET_FREQ
:
2865 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2866 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2869 case MP_CMD_RADIO_STEP_FREQ
:
2870 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2871 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2876 case MP_CMD_TV_START_SCAN
:
2877 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2878 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2880 case MP_CMD_TV_SET_FREQ
:
2881 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2882 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2883 cmd
->args
[0].v
.f
* 16.0);
2885 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2886 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2887 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2888 pvr_get_current_channelname (mpctx
->stream
),
2889 pvr_get_current_stationname (mpctx
->stream
));
2891 #endif /* CONFIG_PVR */
2894 case MP_CMD_TV_STEP_FREQ
:
2895 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2896 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2897 cmd
->args
[0].v
.f
* 16.0);
2899 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2900 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2901 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2902 pvr_get_current_channelname (mpctx
->stream
),
2903 pvr_get_current_frequency (mpctx
->stream
));
2905 #endif /* CONFIG_PVR */
2908 case MP_CMD_TV_SET_NORM
:
2909 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2910 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2914 case MP_CMD_TV_STEP_CHANNEL
:{
2915 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2916 int v
= cmd
->args
[0].v
.i
;
2918 tv_step_channel((tvi_handle_t
*) (mpctx
->
2922 tv_step_channel((tvi_handle_t
*) (mpctx
->
2926 if (tv_channel_list
) {
2927 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2928 _("Channel: %s"), tv_channel_current
->name
);
2929 //vo_osd_changed(OSDTYPE_SUBTITLE);
2933 else if (mpctx
->stream
&&
2934 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2935 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2936 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2937 pvr_get_current_channelname (mpctx
->stream
),
2938 pvr_get_current_stationname (mpctx
->stream
));
2940 #endif /* CONFIG_PVR */
2943 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2945 int v
= cmd
->args
[0].v
.i
;
2947 mpctx
->last_dvb_step
= v
;
2949 dir
= DVB_CHANNEL_HIGHER
;
2951 dir
= DVB_CHANNEL_LOWER
;
2954 if (dvb_step_channel(mpctx
->stream
, dir
)) {
2955 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2956 mpctx
->dvbin_reopen
= 1;
2959 #endif /* CONFIG_DVBIN */
2962 case MP_CMD_TV_SET_CHANNEL
:
2963 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2964 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2966 if (tv_channel_list
) {
2967 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2968 _("Channel: %s"), tv_channel_current
->name
);
2969 //vo_osd_changed(OSDTYPE_SUBTITLE);
2973 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2974 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2975 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2976 pvr_get_current_channelname (mpctx
->stream
),
2977 pvr_get_current_stationname (mpctx
->stream
));
2979 #endif /* CONFIG_PVR */
2983 case MP_CMD_DVB_SET_CHANNEL
:
2984 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2985 mpctx
->last_dvb_step
= 1;
2987 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
2988 cmd
->args
[0].v
.i
)) {
2989 mpctx
->stop_play
= PT_NEXT_ENTRY
;
2990 mpctx
->dvbin_reopen
= 1;
2994 #endif /* CONFIG_DVBIN */
2996 case MP_CMD_TV_LAST_CHANNEL
:
2997 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2998 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2999 if (tv_channel_list
) {
3000 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3001 _("Channel: %s"), tv_channel_current
->name
);
3002 //vo_osd_changed(OSDTYPE_SUBTITLE);
3006 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3007 pvr_set_lastchannel (mpctx
->stream
);
3008 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3009 pvr_get_current_channelname (mpctx
->stream
),
3010 pvr_get_current_stationname (mpctx
->stream
));
3012 #endif /* CONFIG_PVR */
3015 case MP_CMD_TV_STEP_NORM
:
3016 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3017 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3020 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3021 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3022 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3024 #endif /* CONFIG_TV */
3025 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3027 if (mpctx
->demuxer
->teletext
)
3028 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3029 &(cmd
->args
[0].v
.s
));
3032 case MP_CMD_TV_TELETEXT_GO_LINK
:
3034 if (mpctx
->demuxer
->teletext
)
3035 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3036 &(cmd
->args
[0].v
.i
));
3040 case MP_CMD_SUB_LOAD
:
3042 int n
= mpctx
->set_of_sub_size
;
3043 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3044 if (n
!= mpctx
->set_of_sub_size
) {
3045 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
3046 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
3047 mpctx
->global_sub_size
;
3048 ++mpctx
->global_sub_size
;
3053 case MP_CMD_SUB_REMOVE
:
3055 int v
= cmd
->args
[0].v
.i
;
3058 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
3059 subd
= mpctx
->set_of_subtitles
[v
];
3060 mp_tmsg(MSGT_CPLAYER
, MSGL_STATUS
,
3061 "SUB: Removed subtitle file (%d): %s\n", v
+ 1,
3062 filename_recode(subd
->filename
));
3064 mpctx
->set_of_subtitles
[v
] = NULL
;
3066 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
3067 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
3068 mpctx
->set_of_sub_size
= 0;
3069 if (mpctx
->set_of_sub_pos
>= 0) {
3070 mpctx
->global_sub_pos
= -2;
3072 mp_input_queue_cmd(mpctx
->input
,
3073 mp_input_parse_cmd("sub_select"));
3075 } else if (v
< mpctx
->set_of_sub_size
) {
3076 subd
= mpctx
->set_of_subtitles
[v
];
3077 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
3078 "SUB: Removed subtitle file (%d): %s\n", v
+ 1,
3079 filename_recode(subd
->filename
));
3081 if (mpctx
->set_of_sub_pos
== v
) {
3082 mpctx
->global_sub_pos
= -2;
3084 mp_input_queue_cmd(mpctx
->input
,
3085 mp_input_parse_cmd("sub_select"));
3086 } else if (mpctx
->set_of_sub_pos
> v
) {
3087 --mpctx
->set_of_sub_pos
;
3088 --mpctx
->global_sub_pos
;
3090 while (++v
< mpctx
->set_of_sub_size
)
3091 mpctx
->set_of_subtitles
[v
- 1] =
3092 mpctx
->set_of_subtitles
[v
];
3093 --mpctx
->set_of_sub_size
;
3094 --mpctx
->global_sub_size
;
3095 if (mpctx
->set_of_sub_size
<= 0)
3096 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
3097 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
3102 case MP_CMD_GET_SUB_VISIBILITY
:
3104 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3105 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3109 case MP_CMD_SCREENSHOT
:
3110 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3111 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3113 ((vf_instance_t
*) sh_video
->vfilter
)->
3114 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3116 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3120 case MP_CMD_VF_CHANGE_RECTANGLE
:
3123 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3126 case MP_CMD_GET_TIME_LENGTH
:{
3127 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3128 demuxer_get_time_length(mpctx
->demuxer
));
3132 case MP_CMD_GET_FILENAME
:{
3133 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3134 get_metadata(mpctx
, META_NAME
));
3138 case MP_CMD_GET_VIDEO_CODEC
:{
3139 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3142 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3147 case MP_CMD_GET_VIDEO_BITRATE
:{
3148 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3151 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3156 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3157 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3160 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3161 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3166 case MP_CMD_GET_AUDIO_CODEC
:{
3167 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3170 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3175 case MP_CMD_GET_AUDIO_BITRATE
:{
3176 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3179 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3184 case MP_CMD_GET_AUDIO_SAMPLES
:{
3185 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3188 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3193 case MP_CMD_GET_META_TITLE
:{
3194 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3197 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3202 case MP_CMD_GET_META_ARTIST
:{
3203 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3206 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3211 case MP_CMD_GET_META_ALBUM
:{
3212 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3215 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3220 case MP_CMD_GET_META_YEAR
:{
3221 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3224 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3229 case MP_CMD_GET_META_COMMENT
:{
3230 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3233 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3238 case MP_CMD_GET_META_TRACK
:{
3239 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3242 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3247 case MP_CMD_GET_META_GENRE
:{
3248 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3251 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3256 case MP_CMD_GET_VO_FULLSCREEN
:
3257 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3258 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3261 case MP_CMD_GET_PERCENT_POS
:
3262 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3263 demuxer_get_percent_pos(mpctx
->demuxer
));
3266 case MP_CMD_GET_TIME_POS
:{
3269 pos
= sh_video
->pts
;
3270 else if (sh_audio
&& mpctx
->audio_out
)
3271 pos
= playing_audio_pts(mpctx
);
3272 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3279 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3285 case MP_CMD_KEYDOWN_EVENTS
:
3286 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3289 case MP_CMD_SET_MOUSE_POS
:{
3290 int pointer_x
, pointer_y
;
3292 pointer_x
= cmd
->args
[0].v
.i
;
3293 pointer_y
= cmd
->args
[1].v
.i
;
3294 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3295 #ifdef CONFIG_DVDNAV
3296 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3297 && dx
> 0.0 && dy
> 0.0) {
3299 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3300 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3301 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3302 pointer_x
, pointer_y
, &button
);
3303 if (opts
->osd_level
> 1 && button
> 0)
3304 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3305 "Selected button number %d", button
);
3309 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3310 menu_update_mouse_pos(dx
, dy
);
3315 #ifdef CONFIG_DVDNAV
3316 case MP_CMD_DVDNAV
:{
3319 mp_command_type command
= 0;
3320 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3323 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3324 if (cmd
->args
[0].v
.s
&&
3325 !strcasecmp (cmd
->args
[0].v
.s
,
3326 mp_dvdnav_bindings
[i
].name
))
3327 command
= mp_dvdnav_bindings
[i
].cmd
;
3329 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3330 if (opts
->osd_level
> 1 && button
> 0)
3331 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3332 "Selected button number %d", button
);
3336 case MP_CMD_SWITCH_TITLE
:
3337 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3338 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3344 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3345 "Received unknown cmd %s\n", cmd
->name
);
3348 switch (cmd
->pausing
) {
3349 case 1: // "pausing"
3350 pause_player(mpctx
);
3352 case 3: // "pausing_toggle"
3354 unpause_player(mpctx
);
3356 pause_player(mpctx
);