2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "input/input.h"
29 #include "stream/stream.h"
30 #include "libmpdemux/demuxer.h"
31 #include "libmpdemux/stheader.h"
32 #include "codec-cfg.h"
34 #include "libvo/sub.h"
36 #include "m_property.h"
39 #include "libmpcodecs/vf.h"
40 #include "libmpcodecs/vd.h"
42 #include "libvo/video_out.h"
43 #include "libvo/font_load.h"
45 #include "libao2/audio_out.h"
48 #include "libmpcodecs/dec_video.h"
49 #include "libmpcodecs/dec_teletext.h"
54 #include "stream/tv.h"
55 #include "stream/stream_radio.h"
56 #include "stream/pvr.h"
58 #include "stream/dvbin.h"
61 #include "stream/stream_dvd.h"
63 #include "stream/stream_dvdnav.h"
65 #include "libmenu/menu.h"
69 #include "libavutil/avstring.h"
71 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
75 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
76 double *dx
, double *dy
)
78 struct MPOpts
*opts
= &mpctx
->opts
;
79 struct vo
*vo
= mpctx
->video_out
;
80 //remove the borders, if any, and rescale to the range [0,1],[0,1]
81 if (vo_fs
) { //we are in full-screen mode
82 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
83 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
84 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
85 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
87 if (ix
< 0 || ix
> vo
->dwidth
) {
90 } //we are on one of the borders
91 if (iy
< 0 || iy
> vo
->dheight
) {
94 } //we are on one of the borders
97 *dx
= (double) ix
/ (double) vo
->dwidth
;
98 *dy
= (double) iy
/ (double) vo
->dheight
;
100 mp_msg(MSGT_CPLAYER
, MSGL_V
,
101 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
102 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
106 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
111 for (i
= 0; i
< SUB_SOURCES
; i
++) {
112 int j
= mpctx
->global_sub_indices
[i
];
113 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
121 static int sub_source(MPContext
*mpctx
)
123 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
127 * \brief Log the currently displayed subtitle to a file
129 * Logs the current or last displayed subtitle together with filename
130 * and time information to ~/.mplayer/subtitle_log
132 * Intended purpose is to allow convenient marking of bogus subtitles
133 * which need to be fixed while watching the movie.
136 static void log_sub(struct MPContext
*mpctx
)
142 if (subdata
== NULL
|| vo_sub_last
== NULL
)
144 fname
= get_path("subtitle_log");
145 f
= fopen(fname
, "a");
148 fprintf(f
, "----------------------------------------------------------\n");
149 if (subdata
->sub_uses_time
) {
151 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
152 mpctx
->filename
, vo_sub_last
->start
/ 360000,
153 (vo_sub_last
->start
/ 6000) % 60,
154 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
155 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
156 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
158 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
159 vo_sub_last
->start
, vo_sub_last
->end
);
161 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
162 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
168 /// \defgroup Properties
171 /// \defgroup GeneralProperties General properties
172 /// \ingroup Properties
176 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
179 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
183 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
186 struct MPOpts
*opts
= &mpctx
->opts
;
188 case M_PROPERTY_PRINT
:
189 if (!arg
) return M_PROPERTY_ERROR
;
190 if (opts
->loop_times
< 0)
191 *(char**)arg
= strdup("off");
192 else if (opts
->loop_times
== 0)
193 *(char**)arg
= strdup("inf");
196 return M_PROPERTY_OK
;
198 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
201 /// Playback speed (RW)
202 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
203 void *arg
, MPContext
*mpctx
)
205 struct MPOpts
*opts
= &mpctx
->opts
;
209 return M_PROPERTY_ERROR
;
210 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
211 opts
->playback_speed
= *(float *) arg
;
212 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
213 return M_PROPERTY_OK
;
214 case M_PROPERTY_STEP_UP
:
215 case M_PROPERTY_STEP_DOWN
:
216 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
217 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
218 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
219 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
220 return M_PROPERTY_OK
;
222 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
225 /// filename with path (RO)
226 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
229 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
232 /// filename without path (RO)
233 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
237 if (!mpctx
->filename
)
238 return M_PROPERTY_UNAVAILABLE
;
239 if (((f
= strrchr(mpctx
->filename
, '/'))
240 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
244 return m_property_string_ro(prop
, action
, arg
, f
);
247 /// Demuxer name (RO)
248 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
252 return M_PROPERTY_UNAVAILABLE
;
253 return m_property_string_ro(prop
, action
, arg
,
254 (char *) mpctx
->demuxer
->desc
->name
);
257 /// Position in the stream (RW)
258 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
261 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
262 return M_PROPERTY_UNAVAILABLE
;
264 return M_PROPERTY_ERROR
;
267 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
268 return M_PROPERTY_OK
;
270 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
271 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
272 return M_PROPERTY_OK
;
274 return M_PROPERTY_NOT_IMPLEMENTED
;
277 /// Stream start offset (RO)
278 static int mp_property_stream_start(m_option_t
*prop
, int action
,
279 void *arg
, MPContext
*mpctx
)
281 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
282 return M_PROPERTY_UNAVAILABLE
;
285 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
286 return M_PROPERTY_OK
;
288 return M_PROPERTY_NOT_IMPLEMENTED
;
291 /// Stream end offset (RO)
292 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
295 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
296 return M_PROPERTY_UNAVAILABLE
;
299 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
300 return M_PROPERTY_OK
;
302 return M_PROPERTY_NOT_IMPLEMENTED
;
305 /// Stream length (RO)
306 static int mp_property_stream_length(m_option_t
*prop
, int action
,
307 void *arg
, MPContext
*mpctx
)
309 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
310 return M_PROPERTY_UNAVAILABLE
;
314 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
315 return M_PROPERTY_OK
;
317 return M_PROPERTY_NOT_IMPLEMENTED
;
320 /// Media length in seconds (RO)
321 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
326 if (!mpctx
->demuxer
||
327 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
328 return M_PROPERTY_UNAVAILABLE
;
330 return m_property_time_ro(prop
, action
, arg
, len
);
333 /// Current position in percent (RW)
334 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
335 void *arg
, MPContext
*mpctx
) {
339 return M_PROPERTY_UNAVAILABLE
;
343 if(!arg
) return M_PROPERTY_ERROR
;
344 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
347 case M_PROPERTY_STEP_UP
:
348 case M_PROPERTY_STEP_DOWN
:
349 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
350 pos
+= (arg
? *(int*)arg
: 10) *
351 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
352 M_PROPERTY_CLAMP(prop
, pos
);
355 return m_property_int_ro(prop
, action
, arg
,
356 demuxer_get_percent_pos(mpctx
->demuxer
));
359 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
360 mpctx
->rel_seek_secs
= pos
/ 100.0;
361 return M_PROPERTY_OK
;
364 /// Current position in seconds (RW)
365 static int mp_property_time_pos(m_option_t
*prop
, int action
,
366 void *arg
, MPContext
*mpctx
) {
367 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
368 return M_PROPERTY_UNAVAILABLE
;
372 if(!arg
) return M_PROPERTY_ERROR
;
373 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
374 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
375 mpctx
->rel_seek_secs
= *(double*)arg
;
376 return M_PROPERTY_OK
;
377 case M_PROPERTY_STEP_UP
:
378 case M_PROPERTY_STEP_DOWN
:
379 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
380 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
381 return M_PROPERTY_OK
;
383 return m_property_time_ro(prop
, action
, arg
,
384 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
385 playing_audio_pts(mpctx
));
388 /// Current chapter (RW)
389 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
392 struct MPOpts
*opts
= &mpctx
->opts
;
395 char *chapter_name
= NULL
;
398 chapter
= get_current_chapter(mpctx
);
400 return M_PROPERTY_UNAVAILABLE
;
405 return M_PROPERTY_ERROR
;
406 *(int *) arg
= chapter
;
407 return M_PROPERTY_OK
;
408 case M_PROPERTY_PRINT
: {
410 return M_PROPERTY_ERROR
;
411 chapter_name
= chapter_display_name(mpctx
, chapter
);
413 return M_PROPERTY_UNAVAILABLE
;
414 *(char **) arg
= chapter_name
;
415 return M_PROPERTY_OK
;
419 return M_PROPERTY_ERROR
;
420 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
421 step_all
= *(int *)arg
- chapter
;
424 case M_PROPERTY_STEP_UP
:
425 case M_PROPERTY_STEP_DOWN
: {
426 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
427 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
434 return M_PROPERTY_NOT_IMPLEMENTED
;
438 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
439 mpctx
->rel_seek_secs
= 0;
440 mpctx
->abs_seek_pos
= 0;
442 if (next_pts
> -1.0) {
443 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
444 mpctx
->rel_seek_secs
= next_pts
;
447 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
448 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
450 else if (step_all
> 0)
451 mpctx
->rel_seek_secs
= 1000000000.;
453 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
454 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
456 talloc_free(chapter_name
);
457 return M_PROPERTY_OK
;
460 /// Number of chapters in file
461 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
465 return M_PROPERTY_UNAVAILABLE
;
466 if (mpctx
->demuxer
->num_chapters
== 0)
467 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
468 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
471 /// Current dvd angle (RW)
472 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
475 struct MPOpts
*opts
= &mpctx
->opts
;
478 char *angle_name
= NULL
;
481 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
483 return M_PROPERTY_UNAVAILABLE
;
484 angles
= demuxer_angles_count(mpctx
->demuxer
);
486 return M_PROPERTY_UNAVAILABLE
;
491 return M_PROPERTY_ERROR
;
492 *(int *) arg
= angle
;
493 return M_PROPERTY_OK
;
494 case M_PROPERTY_PRINT
: {
496 return M_PROPERTY_ERROR
;
497 angle_name
= calloc(1, 64);
499 return M_PROPERTY_UNAVAILABLE
;
500 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
501 *(char **) arg
= angle_name
;
502 return M_PROPERTY_OK
;
506 return M_PROPERTY_ERROR
;
508 M_PROPERTY_CLAMP(prop
, angle
);
510 case M_PROPERTY_STEP_UP
:
511 case M_PROPERTY_STEP_DOWN
: {
517 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
519 if (angle
< 1) //cycle
524 return M_PROPERTY_NOT_IMPLEMENTED
;
526 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
527 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
528 "Angle: %d/%d", angle
, angles
);
531 return M_PROPERTY_OK
;
534 /// Demuxer meta data
535 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
537 m_property_action_t
* ka
;
539 static const m_option_t key_type
=
540 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
542 return M_PROPERTY_UNAVAILABLE
;
546 if(!arg
) return M_PROPERTY_ERROR
;
547 *(char***)arg
= mpctx
->demuxer
->info
;
548 return M_PROPERTY_OK
;
549 case M_PROPERTY_KEY_ACTION
:
550 if(!arg
) return M_PROPERTY_ERROR
;
552 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
553 return M_PROPERTY_UNKNOWN
;
556 if(!ka
->arg
) return M_PROPERTY_ERROR
;
557 *(char**)ka
->arg
= meta
;
558 return M_PROPERTY_OK
;
559 case M_PROPERTY_GET_TYPE
:
560 if(!ka
->arg
) return M_PROPERTY_ERROR
;
561 *(m_option_t
**)ka
->arg
= &key_type
;
562 return M_PROPERTY_OK
;
565 return M_PROPERTY_NOT_IMPLEMENTED
;
568 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
571 MPContext
*mpctx
= ctx
;
576 return M_PROPERTY_ERROR
;
577 if (mpctx
->paused
== (bool)*(int *) arg
)
578 return M_PROPERTY_OK
;
579 case M_PROPERTY_STEP_UP
:
580 case M_PROPERTY_STEP_DOWN
:
582 unpause_player(mpctx
);
583 mpctx
->osd_function
= OSD_PLAY
;
587 mpctx
->osd_function
= OSD_PAUSE
;
589 return M_PROPERTY_OK
;
591 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
598 /// \defgroup AudioProperties Audio properties
599 /// \ingroup Properties
603 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
607 if (!mpctx
->sh_audio
)
608 return M_PROPERTY_UNAVAILABLE
;
613 return M_PROPERTY_ERROR
;
614 mixer_getbothvolume(&mpctx
->mixer
, arg
);
615 return M_PROPERTY_OK
;
616 case M_PROPERTY_PRINT
:{
619 return M_PROPERTY_ERROR
;
620 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
621 return m_property_float_range(prop
, action
, arg
, &vol
);
623 case M_PROPERTY_STEP_UP
:
624 case M_PROPERTY_STEP_DOWN
:
628 return M_PROPERTY_NOT_IMPLEMENTED
;
631 if (mpctx
->edl_muted
)
632 return M_PROPERTY_DISABLED
;
633 mpctx
->user_muted
= 0;
638 return M_PROPERTY_ERROR
;
639 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
640 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
641 return M_PROPERTY_OK
;
642 case M_PROPERTY_STEP_UP
:
643 if (arg
&& *(float *) arg
<= 0)
644 mixer_decvolume(&mpctx
->mixer
);
646 mixer_incvolume(&mpctx
->mixer
);
647 return M_PROPERTY_OK
;
648 case M_PROPERTY_STEP_DOWN
:
649 if (arg
&& *(float *) arg
<= 0)
650 mixer_incvolume(&mpctx
->mixer
);
652 mixer_decvolume(&mpctx
->mixer
);
653 return M_PROPERTY_OK
;
655 return M_PROPERTY_NOT_IMPLEMENTED
;
659 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
663 if (!mpctx
->sh_audio
)
664 return M_PROPERTY_UNAVAILABLE
;
668 if (mpctx
->edl_muted
)
669 return M_PROPERTY_DISABLED
;
671 return M_PROPERTY_ERROR
;
672 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
673 mixer_mute(&mpctx
->mixer
);
674 mpctx
->user_muted
= mpctx
->mixer
.muted
;
675 return M_PROPERTY_OK
;
676 case M_PROPERTY_STEP_UP
:
677 case M_PROPERTY_STEP_DOWN
:
678 if (mpctx
->edl_muted
)
679 return M_PROPERTY_DISABLED
;
680 mixer_mute(&mpctx
->mixer
);
681 mpctx
->user_muted
= mpctx
->mixer
.muted
;
682 return M_PROPERTY_OK
;
683 case M_PROPERTY_PRINT
:
685 return M_PROPERTY_ERROR
;
686 if (mpctx
->edl_muted
) {
687 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
688 return M_PROPERTY_OK
;
691 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
697 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
698 void *arg
, MPContext
*mpctx
)
700 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
701 return M_PROPERTY_UNAVAILABLE
;
704 case M_PROPERTY_STEP_UP
:
705 case M_PROPERTY_STEP_DOWN
: {
707 float delay
= audio_delay
;
708 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
709 if (ret
!= M_PROPERTY_OK
)
712 mpctx
->delay
-= audio_delay
- delay
;
714 return M_PROPERTY_OK
;
716 return m_property_delay(prop
, action
, arg
, &audio_delay
);
720 /// Audio codec tag (RO)
721 static int mp_property_audio_format(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_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
729 /// Audio codec name (RO)
730 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
731 void *arg
, MPContext
*mpctx
)
733 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
734 return M_PROPERTY_UNAVAILABLE
;
735 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
738 /// Audio bitrate (RO)
739 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
740 void *arg
, MPContext
*mpctx
)
742 if (!mpctx
->sh_audio
)
743 return M_PROPERTY_UNAVAILABLE
;
744 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
748 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
751 if (!mpctx
->sh_audio
)
752 return M_PROPERTY_UNAVAILABLE
;
754 case M_PROPERTY_PRINT
:
755 if(!arg
) return M_PROPERTY_ERROR
;
756 *(char**)arg
= malloc(16);
757 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
758 return M_PROPERTY_OK
;
760 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
763 /// Number of channels (RO)
764 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
767 if (!mpctx
->sh_audio
)
768 return M_PROPERTY_UNAVAILABLE
;
770 case M_PROPERTY_PRINT
:
772 return M_PROPERTY_ERROR
;
773 switch (mpctx
->sh_audio
->channels
) {
775 *(char **) arg
= strdup("mono");
778 *(char **) arg
= strdup("stereo");
781 *(char **) arg
= malloc(32);
782 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
784 return M_PROPERTY_OK
;
786 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
790 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
795 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
796 return M_PROPERTY_UNAVAILABLE
;
801 return M_PROPERTY_ERROR
;
802 mixer_getbalance(&mpctx
->mixer
, arg
);
803 return M_PROPERTY_OK
;
804 case M_PROPERTY_PRINT
: {
807 return M_PROPERTY_ERROR
;
808 mixer_getbalance(&mpctx
->mixer
, &bal
);
810 *str
= strdup("center");
811 else if (bal
== -1.f
)
812 *str
= strdup("left only");
814 *str
= strdup("right only");
816 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
817 *str
= malloc(sizeof("left xxx%, right xxx%"));
818 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
820 return M_PROPERTY_OK
;
822 case M_PROPERTY_STEP_UP
:
823 case M_PROPERTY_STEP_DOWN
:
824 mixer_getbalance(&mpctx
->mixer
, &bal
);
825 bal
+= (arg
? *(float*)arg
: .1f
) *
826 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
827 M_PROPERTY_CLAMP(prop
, bal
);
828 mixer_setbalance(&mpctx
->mixer
, bal
);
829 return M_PROPERTY_OK
;
832 return M_PROPERTY_ERROR
;
833 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
834 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
835 return M_PROPERTY_OK
;
837 return M_PROPERTY_NOT_IMPLEMENTED
;
840 /// Selected audio id (RW)
841 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
844 struct MPOpts
*opts
= &mpctx
->opts
;
846 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
847 return M_PROPERTY_UNAVAILABLE
;
848 current_id
= mpctx
->demuxer
->audio
->id
;
853 return M_PROPERTY_ERROR
;
854 *(int *) arg
= current_id
;
855 return M_PROPERTY_OK
;
856 case M_PROPERTY_PRINT
:
858 return M_PROPERTY_ERROR
;
861 *(char **) arg
= strdup(mp_gtext("disabled"));
864 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
865 sh_audio_t
* sh
= mpctx
->sh_audio
;
867 av_strlcpy(lang
, sh
->lang
, 40);
868 #ifdef CONFIG_DVDREAD
869 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
870 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
880 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
881 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
883 *(char **) arg
= malloc(64);
884 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
886 return M_PROPERTY_OK
;
888 case M_PROPERTY_STEP_UP
:
890 if (action
== M_PROPERTY_SET
&& arg
)
891 tmp
= *((int *) arg
);
894 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
895 if (opts
->audio_id
== -2
896 || (opts
->audio_id
> -1
897 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
898 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
899 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
901 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
903 sh2
->ds
= mpctx
->demuxer
->audio
;
904 mpctx
->sh_audio
= sh2
;
905 reinit_audio_chain(mpctx
);
908 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
909 return M_PROPERTY_OK
;
911 return M_PROPERTY_NOT_IMPLEMENTED
;
916 /// Selected video id (RW)
917 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
920 struct MPOpts
*opts
= &mpctx
->opts
;
922 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
923 return M_PROPERTY_UNAVAILABLE
;
924 current_id
= mpctx
->demuxer
->video
->id
;
929 return M_PROPERTY_ERROR
;
930 *(int *) arg
= current_id
;
931 return M_PROPERTY_OK
;
932 case M_PROPERTY_PRINT
:
934 return M_PROPERTY_ERROR
;
937 *(char **) arg
= strdup(mp_gtext("disabled"));
940 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
941 *(char **) arg
= malloc(64);
942 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
944 return M_PROPERTY_OK
;
946 case M_PROPERTY_STEP_UP
:
948 if (action
== M_PROPERTY_SET
&& arg
)
949 tmp
= *((int *) arg
);
952 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
953 if (opts
->video_id
== -2
954 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
955 && current_id
!= -2))
956 uninit_player(mpctx
, INITIALIZED_VCODEC
|
957 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
958 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
960 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
962 sh2
->ds
= mpctx
->demuxer
->video
;
963 mpctx
->sh_video
= sh2
;
964 reinit_video_chain(mpctx
);
967 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
968 return M_PROPERTY_OK
;
971 return M_PROPERTY_NOT_IMPLEMENTED
;
975 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
978 demux_program_t prog
;
981 case M_PROPERTY_STEP_UP
:
983 if (action
== M_PROPERTY_SET
&& arg
)
984 prog
.progid
= *((int *) arg
);
988 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
989 &prog
) == DEMUXER_CTRL_NOTIMPL
)
990 return M_PROPERTY_ERROR
;
992 if (prog
.aid
< 0 && prog
.vid
< 0) {
993 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
994 return M_PROPERTY_ERROR
;
996 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
997 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
998 return M_PROPERTY_OK
;
1001 return M_PROPERTY_NOT_IMPLEMENTED
;
1007 /// \defgroup VideoProperties Video properties
1008 /// \ingroup Properties
1011 /// Fullscreen state (RW)
1012 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1016 if (!mpctx
->video_out
)
1017 return M_PROPERTY_UNAVAILABLE
;
1020 case M_PROPERTY_SET
:
1022 return M_PROPERTY_ERROR
;
1023 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1024 if (vo_fs
== !!*(int *) arg
)
1025 return M_PROPERTY_OK
;
1026 case M_PROPERTY_STEP_UP
:
1027 case M_PROPERTY_STEP_DOWN
:
1028 if (mpctx
->video_out
->config_ok
)
1029 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1030 mpctx
->opts
.fullscreen
= vo_fs
;
1031 return M_PROPERTY_OK
;
1033 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1037 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1038 void *arg
, MPContext
*mpctx
)
1042 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1043 return M_PROPERTY_UNAVAILABLE
;
1044 vf
= mpctx
->sh_video
->vfilter
;
1046 case M_PROPERTY_GET
:
1048 return M_PROPERTY_ERROR
;
1049 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1050 return M_PROPERTY_OK
;
1051 case M_PROPERTY_SET
:
1053 return M_PROPERTY_ERROR
;
1054 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1055 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1056 return M_PROPERTY_OK
;
1057 case M_PROPERTY_STEP_UP
:
1058 case M_PROPERTY_STEP_DOWN
:
1059 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1060 deinterlace
= !deinterlace
;
1061 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1062 return M_PROPERTY_OK
;
1065 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1066 return m_property_flag_ro(prop
, action
, arg
, value
);
1069 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1070 void *arg
, MPContext
*mpctx
)
1072 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1073 return M_PROPERTY_UNAVAILABLE
;
1075 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1078 case M_PROPERTY_GET
:
1080 return M_PROPERTY_ERROR
;
1081 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1082 return M_PROPERTY_UNAVAILABLE
;
1083 return M_PROPERTY_OK
;
1084 case M_PROPERTY_PRINT
:
1086 return M_PROPERTY_ERROR
;
1087 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1088 return M_PROPERTY_UNAVAILABLE
;
1089 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1090 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1091 *(char **)arg
= strdup("Unknown");
1093 *(char**)arg
= strdup(names
[colorspace
]);
1094 return M_PROPERTY_OK
;
1095 case M_PROPERTY_SET
:
1097 return M_PROPERTY_ERROR
;
1098 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1099 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1100 return M_PROPERTY_OK
;
1101 case M_PROPERTY_STEP_UP
:;
1102 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1103 return M_PROPERTY_UNAVAILABLE
;
1105 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1106 return M_PROPERTY_OK
;
1108 return M_PROPERTY_NOT_IMPLEMENTED
;
1112 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1116 if (!mpctx
->video_out
1117 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1118 return M_PROPERTY_UNAVAILABLE
;
1121 case M_PROPERTY_SET
:
1123 return M_PROPERTY_ERROR
;
1124 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1125 vo_panscan
= *(float *) arg
;
1126 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1127 return M_PROPERTY_OK
;
1128 case M_PROPERTY_STEP_UP
:
1129 case M_PROPERTY_STEP_DOWN
:
1130 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1131 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1134 else if (vo_panscan
< 0)
1136 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1137 return M_PROPERTY_OK
;
1139 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1143 /// Helper to set vo flags.
1144 /** \ingroup PropertyImplHelper
1146 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1147 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1150 if (!mpctx
->video_out
)
1151 return M_PROPERTY_UNAVAILABLE
;
1154 case M_PROPERTY_SET
:
1156 return M_PROPERTY_ERROR
;
1157 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1158 if (*vo_var
== !!*(int *) arg
)
1159 return M_PROPERTY_OK
;
1160 case M_PROPERTY_STEP_UP
:
1161 case M_PROPERTY_STEP_DOWN
:
1162 if (mpctx
->video_out
->config_ok
)
1163 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1164 return M_PROPERTY_OK
;
1166 return m_property_flag(prop
, action
, arg
, vo_var
);
1170 /// Window always on top (RW)
1171 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1174 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1175 &mpctx
->opts
.vo_ontop
, mpctx
);
1178 /// Display in the root window (RW)
1179 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1182 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1183 &vo_rootwin
, mpctx
);
1186 /// Show window borders (RW)
1187 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1190 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1194 /// Framedropping state (RW)
1195 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1196 void *arg
, MPContext
*mpctx
)
1199 if (!mpctx
->sh_video
)
1200 return M_PROPERTY_UNAVAILABLE
;
1203 case M_PROPERTY_PRINT
:
1205 return M_PROPERTY_ERROR
;
1206 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1207 (frame_dropping
== 2 ? mp_gtext("hard") :
1208 mp_gtext("disabled")));
1209 return M_PROPERTY_OK
;
1211 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1215 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1216 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1219 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1222 if (!mpctx
->sh_video
)
1223 return M_PROPERTY_UNAVAILABLE
;
1225 if (gamma
[0] == 1000) {
1227 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1231 case M_PROPERTY_SET
:
1233 return M_PROPERTY_ERROR
;
1234 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1235 *gamma
= *(int *) arg
;
1236 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1240 case M_PROPERTY_GET
:
1241 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1243 return M_PROPERTY_ERROR
;
1245 return M_PROPERTY_OK
;
1248 case M_PROPERTY_STEP_UP
:
1249 case M_PROPERTY_STEP_DOWN
:
1250 *gamma
+= (arg
? *(int *) arg
: 1) *
1251 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1252 M_PROPERTY_CLAMP(prop
, *gamma
);
1253 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1258 return M_PROPERTY_NOT_IMPLEMENTED
;
1262 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1263 int l
= strlen(prop
->name
);
1264 char tv_prop
[3 + l
+ 1];
1265 sprintf(tv_prop
, "tv_%s", prop
->name
);
1266 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1270 return M_PROPERTY_UNAVAILABLE
;
1274 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1277 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1280 /// Video codec tag (RO)
1281 static int mp_property_video_format(m_option_t
*prop
, int action
,
1282 void *arg
, MPContext
*mpctx
)
1285 if (!mpctx
->sh_video
)
1286 return M_PROPERTY_UNAVAILABLE
;
1288 case M_PROPERTY_PRINT
:
1290 return M_PROPERTY_ERROR
;
1291 switch(mpctx
->sh_video
->format
) {
1293 meta
= strdup ("mpeg1"); break;
1295 meta
= strdup ("mpeg2"); break;
1297 meta
= strdup ("mpeg4"); break;
1299 meta
= strdup ("h264"); break;
1301 if(mpctx
->sh_video
->format
>= 0x20202020) {
1303 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1306 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1309 *(char**)arg
= meta
;
1310 return M_PROPERTY_OK
;
1312 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1315 /// Video codec name (RO)
1316 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1317 void *arg
, MPContext
*mpctx
)
1319 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1320 return M_PROPERTY_UNAVAILABLE
;
1321 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1325 /// Video bitrate (RO)
1326 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1327 void *arg
, MPContext
*mpctx
)
1329 if (!mpctx
->sh_video
)
1330 return M_PROPERTY_UNAVAILABLE
;
1331 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1334 /// Video display width (RO)
1335 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1338 if (!mpctx
->sh_video
)
1339 return M_PROPERTY_UNAVAILABLE
;
1340 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1343 /// Video display height (RO)
1344 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1347 if (!mpctx
->sh_video
)
1348 return M_PROPERTY_UNAVAILABLE
;
1349 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1353 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1356 if (!mpctx
->sh_video
)
1357 return M_PROPERTY_UNAVAILABLE
;
1358 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1361 /// Video aspect (RO)
1362 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1365 if (!mpctx
->sh_video
)
1366 return M_PROPERTY_UNAVAILABLE
;
1367 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1372 /// \defgroup SubProprties Subtitles properties
1373 /// \ingroup Properties
1376 /// Text subtitle position (RW)
1377 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1381 case M_PROPERTY_SET
:
1383 return M_PROPERTY_ERROR
;
1384 case M_PROPERTY_STEP_UP
:
1385 case M_PROPERTY_STEP_DOWN
:
1386 vo_osd_changed(OSDTYPE_SUBTITLE
);
1388 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1392 /// Selected subtitles (RW)
1393 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1396 struct MPOpts
*opts
= &mpctx
->opts
;
1397 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1398 const int global_sub_size
= mpctx
->global_sub_size
;
1399 int source
= -1, reset_spu
= 0;
1402 if (global_sub_size
<= 0)
1403 return M_PROPERTY_UNAVAILABLE
;
1406 case M_PROPERTY_GET
:
1408 return M_PROPERTY_ERROR
;
1409 *(int *) arg
= mpctx
->global_sub_pos
;
1410 return M_PROPERTY_OK
;
1411 case M_PROPERTY_PRINT
:
1413 return M_PROPERTY_ERROR
;
1414 *(char **) arg
= malloc(64);
1415 (*(char **) arg
)[63] = 0;
1418 sub_name
= subdata
->filename
;
1420 if (ass_track
&& ass_track
->name
)
1421 sub_name
= ass_track
->name
;
1426 if ((tmp2
= strrchr(tmp
, '/')))
1429 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1430 mpctx
->set_of_sub_pos
+ 1,
1431 strlen(tmp
) < 20 ? "" : "...",
1432 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1433 return M_PROPERTY_OK
;
1435 #ifdef CONFIG_DVDNAV
1436 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1437 if (vo_spudec
&& opts
->sub_id
>= 0) {
1438 unsigned char lang
[3];
1439 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1440 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1441 return M_PROPERTY_OK
;
1447 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1448 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1449 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1450 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1451 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1452 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1453 if (!lang
) lang
= mp_gtext("unknown");
1454 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1455 return M_PROPERTY_OK
;
1458 if (vo_vobsub
&& vobsub_id
>= 0) {
1459 const char *language
= mp_gtext("unknown");
1460 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1461 snprintf(*(char **) arg
, 63, "(%d) %s",
1462 vobsub_id
, language
? language
: mp_gtext("unknown"));
1463 return M_PROPERTY_OK
;
1465 #ifdef CONFIG_DVDREAD
1466 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1467 && opts
->sub_id
>= 0) {
1469 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1470 lang
[0] = code
>> 8;
1473 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1474 return M_PROPERTY_OK
;
1477 if (opts
->sub_id
>= 0) {
1478 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1479 mp_gtext("unknown"));
1480 return M_PROPERTY_OK
;
1482 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1483 return M_PROPERTY_OK
;
1485 case M_PROPERTY_SET
:
1487 return M_PROPERTY_ERROR
;
1488 if (*(int *) arg
< -1)
1490 else if (*(int *) arg
>= global_sub_size
)
1491 *(int *) arg
= global_sub_size
- 1;
1492 mpctx
->global_sub_pos
= *(int *) arg
;
1494 case M_PROPERTY_STEP_UP
:
1495 mpctx
->global_sub_pos
+= 2;
1496 mpctx
->global_sub_pos
=
1497 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1499 case M_PROPERTY_STEP_DOWN
:
1500 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1501 mpctx
->global_sub_pos
=
1502 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1505 return M_PROPERTY_NOT_IMPLEMENTED
;
1508 if (mpctx
->global_sub_pos
>= 0)
1509 source
= sub_source(mpctx
);
1511 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1512 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1514 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1515 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1516 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1517 mpctx
->global_sub_pos
, source
);
1519 mpctx
->set_of_sub_pos
= -1;
1533 if (source
== SUB_SOURCE_VOBSUB
) {
1534 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1535 } else if (source
== SUB_SOURCE_SUBS
) {
1536 mpctx
->set_of_sub_pos
=
1537 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1539 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1540 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1544 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1545 vo_osd_changed(OSDTYPE_SUBTITLE
);
1547 } else if (source
== SUB_SOURCE_DEMUX
) {
1549 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1550 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1552 // default: assume 1:1 mapping of sid and stream id
1553 d_sub
->id
= opts
->sub_id
;
1554 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1555 ds_free_packs(d_sub
);
1556 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1557 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1558 if (sh
&& sh
->sid
== opts
->sub_id
) {
1564 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1565 sh_sub_t
*sh
= d_sub
->sh
;
1566 if (sh
->type
== 'v')
1567 init_vo_spudec(mpctx
);
1569 else if (opts
->ass_enabled
)
1570 ass_track
= sh
->ass_track
;
1578 #ifdef CONFIG_DVDREAD
1580 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1581 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1582 && opts
->sub_id
< 0 && reset_spu
) {
1588 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1590 return M_PROPERTY_OK
;
1593 /// Selected sub source (RW)
1594 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1598 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1599 return M_PROPERTY_UNAVAILABLE
;
1602 case M_PROPERTY_GET
:
1604 return M_PROPERTY_ERROR
;
1605 *(int *) arg
= sub_source(mpctx
);
1606 return M_PROPERTY_OK
;
1607 case M_PROPERTY_PRINT
:
1609 return M_PROPERTY_ERROR
;
1610 *(char **) arg
= malloc(64);
1611 (*(char **) arg
)[63] = 0;
1612 switch (sub_source(mpctx
))
1614 case SUB_SOURCE_SUBS
:
1615 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1617 case SUB_SOURCE_VOBSUB
:
1618 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1620 case SUB_SOURCE_DEMUX
:
1621 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1624 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1626 return M_PROPERTY_OK
;
1627 case M_PROPERTY_SET
:
1629 return M_PROPERTY_ERROR
;
1630 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1631 if (*(int *) arg
< 0)
1632 mpctx
->global_sub_pos
= -1;
1633 else if (*(int *) arg
!= sub_source(mpctx
)) {
1634 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1635 return M_PROPERTY_UNAVAILABLE
;
1636 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1639 case M_PROPERTY_STEP_UP
:
1640 case M_PROPERTY_STEP_DOWN
: {
1641 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1642 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1643 int step
= (step_all
> 0) ? 1 : -1;
1644 int cur_source
= sub_source(mpctx
);
1645 source
= cur_source
;
1648 if (source
>= SUB_SOURCES
)
1650 else if (source
< -1)
1651 source
= SUB_SOURCES
- 1;
1652 if (source
== cur_source
|| source
== -1 ||
1653 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1656 if (source
== cur_source
)
1657 return M_PROPERTY_OK
;
1659 mpctx
->global_sub_pos
= -1;
1661 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1665 return M_PROPERTY_NOT_IMPLEMENTED
;
1667 --mpctx
->global_sub_pos
;
1668 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1671 /// Selected subtitles from specific source (RW)
1672 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1675 int source
, is_cur_source
, offset
;
1676 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1677 return M_PROPERTY_UNAVAILABLE
;
1679 if (!strcmp(prop
->name
, "sub_file"))
1680 source
= SUB_SOURCE_SUBS
;
1681 else if (!strcmp(prop
->name
, "sub_vob"))
1682 source
= SUB_SOURCE_VOBSUB
;
1683 else if (!strcmp(prop
->name
, "sub_demux"))
1684 source
= SUB_SOURCE_DEMUX
;
1686 return M_PROPERTY_ERROR
;
1688 offset
= mpctx
->global_sub_indices
[source
];
1689 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1690 return M_PROPERTY_UNAVAILABLE
;
1692 is_cur_source
= sub_source(mpctx
) == source
;
1694 case M_PROPERTY_GET
:
1696 return M_PROPERTY_ERROR
;
1697 if (is_cur_source
) {
1698 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1699 if (source
== SUB_SOURCE_VOBSUB
)
1700 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1704 return M_PROPERTY_OK
;
1705 case M_PROPERTY_PRINT
:
1707 return M_PROPERTY_ERROR
;
1709 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1710 *(char **) arg
= malloc(64);
1711 (*(char **) arg
)[63] = 0;
1712 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1713 return M_PROPERTY_OK
;
1714 case M_PROPERTY_SET
:
1716 return M_PROPERTY_ERROR
;
1717 if (*(int *) arg
>= 0) {
1718 int index
= *(int *)arg
;
1719 if (source
== SUB_SOURCE_VOBSUB
)
1720 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1721 mpctx
->global_sub_pos
= offset
+ index
;
1722 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1723 || sub_source(mpctx
) != source
) {
1724 mpctx
->global_sub_pos
= -1;
1729 mpctx
->global_sub_pos
= -1;
1731 case M_PROPERTY_STEP_UP
:
1732 case M_PROPERTY_STEP_DOWN
: {
1733 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1734 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1735 int step
= (step_all
> 0) ? 1 : -1;
1736 int max_sub_pos_for_source
= -1;
1738 mpctx
->global_sub_pos
= -1;
1740 if (mpctx
->global_sub_pos
== -1) {
1742 mpctx
->global_sub_pos
= offset
;
1743 else if (max_sub_pos_for_source
== -1) {
1744 // Find max pos for specific source
1745 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1746 while (mpctx
->global_sub_pos
>= 0
1747 && sub_source(mpctx
) != source
)
1748 --mpctx
->global_sub_pos
;
1751 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1754 mpctx
->global_sub_pos
+= step
;
1755 if (mpctx
->global_sub_pos
< offset
||
1756 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1757 sub_source(mpctx
) != source
)
1758 mpctx
->global_sub_pos
= -1;
1765 return M_PROPERTY_NOT_IMPLEMENTED
;
1767 --mpctx
->global_sub_pos
;
1768 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1771 /// Subtitle delay (RW)
1772 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1775 if (!mpctx
->sh_video
)
1776 return M_PROPERTY_UNAVAILABLE
;
1777 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1780 /// Alignment of text subtitles (RW)
1781 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1782 void *arg
, MPContext
*mpctx
)
1784 char *name
[] = { _("top"), _("center"), _("bottom") };
1786 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1787 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1788 return M_PROPERTY_UNAVAILABLE
;
1791 case M_PROPERTY_PRINT
:
1793 return M_PROPERTY_ERROR
;
1794 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1795 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1796 return M_PROPERTY_OK
;
1797 case M_PROPERTY_SET
:
1799 return M_PROPERTY_ERROR
;
1800 case M_PROPERTY_STEP_UP
:
1801 case M_PROPERTY_STEP_DOWN
:
1802 vo_osd_changed(OSDTYPE_SUBTITLE
);
1804 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1808 /// Subtitle visibility (RW)
1809 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1810 void *arg
, MPContext
*mpctx
)
1812 if (!mpctx
->sh_video
)
1813 return M_PROPERTY_UNAVAILABLE
;
1816 case M_PROPERTY_SET
:
1818 return M_PROPERTY_ERROR
;
1819 case M_PROPERTY_STEP_UP
:
1820 case M_PROPERTY_STEP_DOWN
:
1821 vo_osd_changed(OSDTYPE_SUBTITLE
);
1823 vo_osd_changed(OSDTYPE_SPU
);
1825 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1830 /// Use margins for libass subtitles (RW)
1831 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1832 void *arg
, MPContext
*mpctx
)
1834 if (!mpctx
->sh_video
)
1835 return M_PROPERTY_UNAVAILABLE
;
1838 case M_PROPERTY_SET
:
1840 return M_PROPERTY_ERROR
;
1841 case M_PROPERTY_STEP_UP
:
1842 case M_PROPERTY_STEP_DOWN
:
1843 ass_force_reload
= 1;
1845 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1850 /// Show only forced subtitles (RW)
1851 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1852 void *arg
, MPContext
*mpctx
)
1855 return M_PROPERTY_UNAVAILABLE
;
1858 case M_PROPERTY_SET
:
1860 return M_PROPERTY_ERROR
;
1861 case M_PROPERTY_STEP_UP
:
1862 case M_PROPERTY_STEP_DOWN
:
1863 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1864 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1865 return M_PROPERTY_OK
;
1867 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1872 #ifdef CONFIG_FREETYPE
1873 /// Subtitle scale (RW)
1874 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1877 struct MPOpts
*opts
= &mpctx
->opts
;
1880 case M_PROPERTY_SET
:
1882 return M_PROPERTY_ERROR
;
1883 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1885 if (opts
->ass_enabled
) {
1886 ass_font_scale
= *(float *) arg
;
1887 ass_force_reload
= 1;
1890 text_font_scale_factor
= *(float *) arg
;
1891 force_load_font
= 1;
1892 return M_PROPERTY_OK
;
1893 case M_PROPERTY_STEP_UP
:
1894 case M_PROPERTY_STEP_DOWN
:
1896 if (opts
->ass_enabled
) {
1897 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1898 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1899 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1900 ass_force_reload
= 1;
1903 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1904 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1905 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1906 force_load_font
= 1;
1907 return M_PROPERTY_OK
;
1910 if (opts
->ass_enabled
)
1911 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1914 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1921 /// \defgroup TVProperties TV properties
1922 /// \ingroup Properties
1927 /// TV color settings (RW)
1928 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1932 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1933 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1934 return M_PROPERTY_UNAVAILABLE
;
1937 case M_PROPERTY_SET
:
1939 return M_PROPERTY_ERROR
;
1940 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1941 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1942 case M_PROPERTY_GET
:
1943 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1944 case M_PROPERTY_STEP_UP
:
1945 case M_PROPERTY_STEP_DOWN
:
1946 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1948 return M_PROPERTY_ERROR
;
1949 val
+= (arg
? *(int *) arg
: 1) *
1950 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1951 M_PROPERTY_CLAMP(prop
, val
);
1952 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1954 return M_PROPERTY_ERROR
;
1956 return M_PROPERTY_NOT_IMPLEMENTED
;
1961 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1965 int base_ioctl
=(int)prop
->priv
;
1967 for teletext's GET,SET,STEP ioctls this is not 0
1971 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1972 return M_PROPERTY_UNAVAILABLE
;
1974 return M_PROPERTY_ERROR
;
1977 case M_PROPERTY_GET
:
1979 return M_PROPERTY_ERROR
;
1980 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1982 case M_PROPERTY_SET
:
1984 return M_PROPERTY_ERROR
;
1985 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1986 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1988 case M_PROPERTY_STEP_UP
:
1989 case M_PROPERTY_STEP_DOWN
:
1990 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1991 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1992 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
1995 return M_PROPERTY_NOT_IMPLEMENTED
;
1998 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2001 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2007 //with tvh==NULL will fail too
2008 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2009 if(result
!=M_PROPERTY_OK
)
2012 if(teletext_control(mpctx
->demuxer
->teletext
,
2013 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
2014 mp_input_set_section(mpctx
->input
, "teletext");
2016 mp_input_set_section(mpctx
->input
, "tv");
2017 return M_PROPERTY_OK
;
2020 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2025 if (!mpctx
->demuxer
->teletext
)
2026 return M_PROPERTY_UNAVAILABLE
;
2028 case M_PROPERTY_STEP_UP
:
2029 case M_PROPERTY_STEP_DOWN
:
2030 //This should be handled separately
2031 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2032 result
=teletext_control(mpctx
->demuxer
->teletext
,
2033 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2036 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2043 /// All properties available in MPlayer.
2044 /** \ingroup Properties
2046 static const m_option_t mp_properties
[] = {
2048 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2049 M_OPT_RANGE
, 0, 3, NULL
},
2050 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2051 M_OPT_MIN
, -1, 0, NULL
},
2052 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2053 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2054 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2056 { "path", mp_property_path
, CONF_TYPE_STRING
,
2058 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2060 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2061 M_OPT_MIN
, 0, 0, NULL
},
2062 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2063 M_OPT_MIN
, 0, 0, NULL
},
2064 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2065 M_OPT_MIN
, 0, 0, NULL
},
2066 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2067 M_OPT_MIN
, 0, 0, NULL
},
2068 { "length", mp_property_length
, CONF_TYPE_TIME
,
2069 M_OPT_MIN
, 0, 0, NULL
},
2070 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2071 M_OPT_RANGE
, 0, 100, NULL
},
2072 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2073 M_OPT_MIN
, 0, 0, NULL
},
2074 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2075 M_OPT_MIN
, 0, 0, NULL
},
2076 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2078 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2079 CONF_RANGE
, -2, 10, NULL
},
2080 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2082 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2083 M_OPT_RANGE
, 0, 1, NULL
},
2086 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2087 M_OPT_RANGE
, 0, 100, NULL
},
2088 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2089 M_OPT_RANGE
, 0, 1, NULL
},
2090 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2091 M_OPT_RANGE
, -100, 100, NULL
},
2092 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2094 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2096 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2098 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2100 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2102 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2103 CONF_RANGE
, -2, 65535, NULL
},
2104 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2105 M_OPT_RANGE
, -1, 1, NULL
},
2108 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2109 M_OPT_RANGE
, 0, 1, NULL
},
2110 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2111 M_OPT_RANGE
, 0, 1, NULL
},
2112 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, 0, 2, NULL
},
2114 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2115 M_OPT_RANGE
, 0, 1, NULL
},
2116 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2117 M_OPT_RANGE
, 0, 1, NULL
},
2118 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2119 M_OPT_RANGE
, 0, 1, NULL
},
2120 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2121 M_OPT_RANGE
, 0, 2, NULL
},
2122 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2123 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2124 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2125 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2126 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2127 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2128 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2129 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2130 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2131 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2132 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2133 M_OPT_RANGE
, 0, 1, NULL
},
2134 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2135 M_OPT_RANGE
, 0, 1, NULL
},
2136 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2138 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2140 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2142 { "width", mp_property_width
, CONF_TYPE_INT
,
2144 { "height", mp_property_height
, CONF_TYPE_INT
,
2146 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2148 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2150 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2151 CONF_RANGE
, -2, 65535, NULL
},
2152 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2153 CONF_RANGE
, -1, 65535, NULL
},
2156 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2157 M_OPT_MIN
, -1, 0, NULL
},
2158 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2159 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2160 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2161 M_OPT_MIN
, -1, 0, NULL
},
2162 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2163 M_OPT_MIN
, -1, 0, NULL
},
2164 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2165 M_OPT_MIN
, -1, 0, NULL
},
2166 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2168 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2169 M_OPT_RANGE
, 0, 100, NULL
},
2170 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2171 M_OPT_RANGE
, 0, 2, NULL
},
2172 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2173 M_OPT_RANGE
, 0, 1, NULL
},
2174 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2175 M_OPT_RANGE
, 0, 1, NULL
},
2176 #ifdef CONFIG_FREETYPE
2177 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2178 M_OPT_RANGE
, 0, 100, NULL
},
2181 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2182 M_OPT_RANGE
, 0, 1, NULL
},
2186 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2187 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2188 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2189 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2190 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2191 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2192 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2193 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2195 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2196 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2197 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2198 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2199 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2200 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2201 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2202 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2203 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2204 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2205 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2209 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2211 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2214 char* mp_property_print(const char *name
, void* ctx
)
2217 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2222 char *property_expand_string(MPContext
*mpctx
, char *str
)
2224 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2227 void property_print_help(void)
2229 m_properties_print_help_list(mp_properties
);
2233 /* List of default ways to show a property on OSD.
2235 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2236 * a bar showing the current position between min/max values of the
2237 * property. In this case osd_msg is only used for terminal output
2238 * if there is no video; it'll be a label shown together with percentage.
2240 * Otherwise setting osd_msg will show the string on OSD, formatted with
2241 * the text value of the property as argument.
2243 static struct property_osd_display
{
2246 /// progressbar type
2247 int osd_progbar
; // -1 is special value for seek indicators
2248 /// osd msg id if it must be shared
2250 /// osd msg template
2251 const char *osd_msg
;
2252 } property_osd_display
[] = {
2254 { "loop", 0, -1, _("Loop: %s") },
2255 { "chapter", -1, -1, NULL
},
2257 { "volume", OSD_VOLUME
, -1, _("Volume") },
2258 { "mute", 0, -1, _("Mute: %s") },
2259 { "audio_delay", 0, -1, _("A-V delay: %s") },
2260 { "switch_audio", 0, -1, _("Audio: %s") },
2261 { "balance", OSD_BALANCE
, -1, _("Balance") },
2263 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2264 { "ontop", 0, -1, _("Stay on top: %s") },
2265 { "rootwin", 0, -1, _("Rootwin: %s") },
2266 { "border", 0, -1, _("Border: %s") },
2267 { "framedropping", 0, -1, _("Framedropping: %s") },
2268 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2269 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2270 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2271 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2272 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2273 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2274 { "hue", OSD_HUE
, -1, _("Hue") },
2275 { "vsync", 0, -1, _("VSync: %s") },
2277 { "sub", 0, -1, _("Subtitles: %s") },
2278 { "sub_source", 0, -1, _("Sub source: %s") },
2279 { "sub_vob", 0, -1, _("Subtitles: %s") },
2280 { "sub_demux", 0, -1, _("Subtitles: %s") },
2281 { "sub_file", 0, -1, _("Subtitles: %s") },
2282 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2283 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2284 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2285 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2286 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2287 #ifdef CONFIG_FREETYPE
2288 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2291 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2292 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2293 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2294 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2299 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2301 struct MPOpts
*opts
= &mpctx
->opts
;
2304 struct property_osd_display
*p
;
2306 // look for the command
2307 for (p
= property_osd_display
; p
->name
; p
++)
2308 if (!strcmp(p
->name
, pname
))
2313 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2316 if (p
->osd_progbar
== -1)
2317 mpctx
->add_osd_seek_info
= true;
2318 else if (p
->osd_progbar
) {
2319 if (prop
->type
== CONF_TYPE_INT
) {
2320 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2321 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2322 prop
->min
, prop
->max
, r
);
2323 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2325 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2326 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2327 prop
->min
, prop
->max
, f
);
2329 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2330 "Property use an unsupported type.\n");
2337 char *val
= mp_property_print(pname
, mpctx
);
2339 int index
= p
- property_osd_display
;
2340 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2341 1, opts
->osd_duration
, p
->osd_msg
, val
);
2350 * \defgroup Command2Property Command to property bridge
2352 * It is used to handle most commands that just set a property
2353 * and optionally display something on the OSD.
2354 * Two kinds of commands are handled: adjust or toggle.
2356 * Adjust commands take 1 or 2 parameters: <value> <abs>
2357 * If <abs> is non-zero the property is set to the given value
2358 * otherwise it is adjusted.
2360 * Toggle commands take 0 or 1 parameters. With no parameter
2361 * or a value less than the property minimum it just steps the
2362 * property to its next value. Otherwise it sets it to the given
2368 /// List of the commands that can be handled by setting a property.
2374 /// set/adjust or toggle command
2376 } set_prop_cmd
[] = {
2378 { "loop", MP_CMD_LOOP
, 0},
2379 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2380 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2381 { "pause", MP_CMD_PAUSE
, 0},
2383 { "volume", MP_CMD_VOLUME
, 0},
2384 { "mute", MP_CMD_MUTE
, 1},
2385 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2386 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2387 { "balance", MP_CMD_BALANCE
, 0},
2389 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2390 { "panscan", MP_CMD_PANSCAN
, 0},
2391 { "ontop", MP_CMD_VO_ONTOP
, 1},
2392 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2393 { "border", MP_CMD_VO_BORDER
, 1},
2394 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2395 { "gamma", MP_CMD_GAMMA
, 0},
2396 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2397 { "contrast", MP_CMD_CONTRAST
, 0},
2398 { "saturation", MP_CMD_SATURATION
, 0},
2399 { "hue", MP_CMD_HUE
, 0},
2400 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2402 { "sub", MP_CMD_SUB_SELECT
, 1},
2403 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2404 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2405 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2406 { "sub_file", MP_CMD_SUB_FILE
, 1},
2407 { "sub_pos", MP_CMD_SUB_POS
, 0},
2408 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2409 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2410 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2411 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2412 #ifdef CONFIG_FREETYPE
2413 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2416 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2419 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2420 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2421 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2422 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2427 /// Handle commands that set a property.
2428 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2434 // look for the command
2435 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2436 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2438 if (!(pname
= set_prop_cmd
[i
].name
))
2441 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2445 if (set_prop_cmd
[i
].toggle
) {
2447 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2448 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2450 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2451 } else if (cmd
->args
[1].v
.i
) //set
2452 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2454 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2459 show_property_osd(mpctx
, pname
);
2464 #ifdef CONFIG_DVDNAV
2465 static const struct {
2467 const mp_command_type cmd
;
2468 } mp_dvdnav_bindings
[] = {
2469 { "up", MP_CMD_DVDNAV_UP
},
2470 { "down", MP_CMD_DVDNAV_DOWN
},
2471 { "left", MP_CMD_DVDNAV_LEFT
},
2472 { "right", MP_CMD_DVDNAV_RIGHT
},
2473 { "menu", MP_CMD_DVDNAV_MENU
},
2474 { "select", MP_CMD_DVDNAV_SELECT
},
2475 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2476 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2479 * keep old dvdnav sub-command options for a while in order not to
2480 * break slave-mode API too suddenly.
2482 { "1", MP_CMD_DVDNAV_UP
},
2483 { "2", MP_CMD_DVDNAV_DOWN
},
2484 { "3", MP_CMD_DVDNAV_LEFT
},
2485 { "4", MP_CMD_DVDNAV_RIGHT
},
2486 { "5", MP_CMD_DVDNAV_MENU
},
2487 { "6", MP_CMD_DVDNAV_SELECT
},
2488 { "7", MP_CMD_DVDNAV_PREVMENU
},
2489 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2494 static const char *property_error_string(int error_value
)
2496 switch (error_value
) {
2497 case M_PROPERTY_ERROR
:
2499 case M_PROPERTY_UNAVAILABLE
:
2500 return "PROPERTY_UNAVAILABLE";
2501 case M_PROPERTY_NOT_IMPLEMENTED
:
2502 return "NOT_IMPLEMENTED";
2503 case M_PROPERTY_UNKNOWN
:
2504 return "PROPERTY_UNKNOWN";
2505 case M_PROPERTY_DISABLED
:
2511 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2514 int end
= start
+ count
;
2515 int after
= mpctx
->set_of_sub_size
- end
;
2516 sub_data
**subs
= mpctx
->set_of_subtitles
;
2518 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2520 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2521 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2522 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2523 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2526 for (idx
= start
; idx
< end
; idx
++) {
2527 sub_data
*subd
= subs
[idx
];
2528 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2529 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2530 filename_recode(subd
->filename
));
2534 if (ass_tracks
[idx
])
2535 ass_free_track(ass_tracks
[idx
]);
2536 ass_tracks
[idx
] = NULL
;
2540 mpctx
->global_sub_size
-= count
;
2541 mpctx
->set_of_sub_size
-= count
;
2542 if (mpctx
->set_of_sub_size
<= 0)
2543 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2545 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2546 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2548 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2549 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2552 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2553 mpctx
->global_sub_pos
= -2;
2558 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2559 } else if (mpctx
->set_of_sub_pos
>= end
) {
2560 mpctx
->set_of_sub_pos
-= count
;
2561 mpctx
->global_sub_pos
-= count
;
2565 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2567 struct MPOpts
*opts
= &mpctx
->opts
;
2568 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2569 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2570 int osd_duration
= opts
->osd_duration
;
2571 int case_fallthrough_hack
= 0;
2572 if (!set_property_command(mpctx
, cmd
))
2577 mpctx
->add_osd_seek_info
= true;
2578 v
= cmd
->args
[0].v
.f
;
2579 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2580 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2581 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2583 mpctx
->osd_function
=
2584 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2585 mpctx
->rel_seek_secs
= v
;
2586 } else if (abs
) { /* Absolute seek by percentage */
2587 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2589 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2590 mpctx
->rel_seek_secs
= v
/ 100.0;
2592 mpctx
->rel_seek_secs
+= v
;
2593 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2598 case MP_CMD_SET_PROPERTY_OSD
:
2599 case_fallthrough_hack
= 1;
2601 case MP_CMD_SET_PROPERTY
:{
2602 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2603 cmd
->args
[1].v
.s
, mpctx
);
2604 if (r
== M_PROPERTY_UNKNOWN
)
2605 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2606 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2608 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2609 "Failed to set property '%s' to '%s'.\n",
2610 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2611 else if (case_fallthrough_hack
)
2612 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2614 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2618 case MP_CMD_STEP_PROPERTY_OSD
:
2619 case_fallthrough_hack
= 1;
2621 case MP_CMD_STEP_PROPERTY
:{
2626 if (cmd
->args
[1].v
.f
) {
2628 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2629 M_PROPERTY_GET_TYPE
,
2630 &prop
, mpctx
)) <= 0)
2632 if(prop
->type
== CONF_TYPE_INT
||
2633 prop
->type
== CONF_TYPE_FLAG
)
2634 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2635 else if(prop
->type
== CONF_TYPE_FLOAT
)
2636 arg
= &cmd
->args
[1].v
.f
;
2637 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2638 prop
->type
== CONF_TYPE_TIME
)
2639 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2640 else if(prop
->type
== CONF_TYPE_POSITION
)
2641 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2643 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2644 "Ignoring step size stepping property '%s'.\n",
2647 r
= mp_property_do(cmd
->args
[0].v
.s
,
2648 cmd
->args
[2].v
.i
< 0 ?
2649 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2652 if (r
== M_PROPERTY_UNKNOWN
)
2653 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2654 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2656 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2657 "Failed to increment property '%s' by %f.\n",
2658 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2659 else if (case_fallthrough_hack
)
2660 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2662 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2666 case MP_CMD_GET_PROPERTY
:{
2668 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2671 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2672 "Failed to get value of property '%s'.\n",
2674 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2677 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2678 cmd
->args
[0].v
.s
, tmp
);
2683 case MP_CMD_EDL_MARK
:
2685 float v
= sh_video
? sh_video
->pts
:
2686 playing_audio_pts(mpctx
);
2687 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2688 mpctx
->begin_skip
= v
;
2689 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2691 if (mpctx
->begin_skip
> v
)
2692 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2694 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2695 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2697 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2702 case MP_CMD_SWITCH_RATIO
:
2705 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2706 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2708 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2709 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2712 case MP_CMD_SPEED_INCR
:{
2713 float v
= cmd
->args
[0].v
.f
;
2714 opts
->playback_speed
+= v
;
2715 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2716 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2717 opts
->playback_speed
);
2720 case MP_CMD_SPEED_MULT
:{
2721 float v
= cmd
->args
[0].v
.f
;
2722 opts
->playback_speed
*= v
;
2723 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2724 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2725 opts
->playback_speed
);
2728 case MP_CMD_SPEED_SET
:{
2729 float v
= cmd
->args
[0].v
.f
;
2730 opts
->playback_speed
= v
;
2731 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2732 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2733 opts
->playback_speed
);
2736 case MP_CMD_FRAME_STEP
:
2737 add_step_frame(mpctx
);
2740 case MP_CMD_FILE_FILTER
:
2741 file_filter
= cmd
->args
[0].v
.i
;
2745 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2746 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2748 case MP_CMD_PLAY_TREE_STEP
:{
2749 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2750 int force
= cmd
->args
[1].v
.i
;
2753 if (!force
&& mpctx
->playtree_iter
) {
2754 play_tree_iter_t
*i
=
2755 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2756 if (play_tree_iter_step(i
, n
, 0) ==
2757 PLAY_TREE_ITER_ENTRY
)
2759 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2760 play_tree_iter_free(i
);
2762 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2763 if (mpctx
->stop_play
)
2764 mpctx
->play_tree_step
= n
;
2769 case MP_CMD_PLAY_TREE_UP_STEP
:{
2770 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2771 int force
= cmd
->args
[1].v
.i
;
2773 if (!force
&& mpctx
->playtree_iter
) {
2774 play_tree_iter_t
*i
=
2775 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2776 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2777 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2778 play_tree_iter_free(i
);
2780 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2784 case MP_CMD_PLAY_ALT_SRC_STEP
:
2785 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2786 int v
= cmd
->args
[0].v
.i
;
2788 && mpctx
->playtree_iter
->file
<
2789 mpctx
->playtree_iter
->num_files
)
2790 mpctx
->stop_play
= PT_NEXT_SRC
;
2791 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2792 mpctx
->stop_play
= PT_PREV_SRC
;
2796 case MP_CMD_SUB_STEP
:
2798 int movement
= cmd
->args
[0].v
.i
;
2799 step_sub(subdata
, sh_video
->pts
, movement
);
2803 ass_step_sub(ass_track
,
2805 sub_delay
) * 1000 + .5, movement
) / 1000.;
2807 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2808 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2812 case MP_CMD_SUB_LOG
:
2817 int v
= cmd
->args
[0].v
.i
;
2819 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2820 if (opts
->osd_level
> max
)
2821 opts
->osd_level
= max
;
2823 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2825 opts
->osd_level
= v
> max
? max
: v
;
2826 /* Show OSD state when disabled, but not when an explicit
2827 argument is given to the OSD command, i.e. in slave mode. */
2828 if (v
== -1 && opts
->osd_level
<= 1)
2829 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2831 opts
->osd_level
? mp_gtext("enabled") :
2832 mp_gtext("disabled"));
2834 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2838 case MP_CMD_OSD_SHOW_TEXT
:
2839 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2841 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2842 "%-.63s", cmd
->args
[0].v
.s
);
2845 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2846 char *txt
= m_properties_expand_string(mp_properties
,
2849 /* if no argument supplied take default osd_duration, else <arg> ms. */
2851 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2853 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2860 case MP_CMD_LOADFILE
:{
2861 play_tree_t
*e
= play_tree_new();
2862 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2864 if (cmd
->args
[1].v
.i
) // append
2865 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2867 // Go back to the starting point.
2868 while (play_tree_iter_up_step
2869 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2871 play_tree_free_list(mpctx
->playtree
->child
, 1);
2872 play_tree_set_child(mpctx
->playtree
, e
);
2873 pt_iter_goto_head(mpctx
->playtree_iter
);
2874 mpctx
->stop_play
= PT_NEXT_SRC
;
2879 case MP_CMD_LOADLIST
:{
2880 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2882 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2883 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2885 if (cmd
->args
[1].v
.i
) // append
2886 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2888 // Go back to the starting point.
2889 while (play_tree_iter_up_step
2890 (mpctx
->playtree_iter
, 0, 1)
2891 != PLAY_TREE_ITER_END
)
2893 play_tree_free_list(mpctx
->playtree
->child
, 1);
2894 play_tree_set_child(mpctx
->playtree
, e
);
2895 pt_iter_goto_head(mpctx
->playtree_iter
);
2896 mpctx
->stop_play
= PT_NEXT_SRC
;
2903 // Go back to the starting point.
2904 while (play_tree_iter_up_step
2905 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2907 mpctx
->stop_play
= PT_STOP
;
2911 case MP_CMD_RADIO_STEP_CHANNEL
:
2912 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2913 int v
= cmd
->args
[0].v
.i
;
2915 radio_step_channel(mpctx
->demuxer
->stream
,
2916 RADIO_CHANNEL_HIGHER
);
2918 radio_step_channel(mpctx
->demuxer
->stream
,
2919 RADIO_CHANNEL_LOWER
);
2920 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2921 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2923 radio_get_channel_name(mpctx
->demuxer
->stream
));
2928 case MP_CMD_RADIO_SET_CHANNEL
:
2929 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2930 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2931 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2932 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2934 radio_get_channel_name(mpctx
->demuxer
->stream
));
2939 case MP_CMD_RADIO_SET_FREQ
:
2940 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2941 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2944 case MP_CMD_RADIO_STEP_FREQ
:
2945 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2946 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2951 case MP_CMD_TV_START_SCAN
:
2952 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2953 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2955 case MP_CMD_TV_SET_FREQ
:
2956 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2957 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2958 cmd
->args
[0].v
.f
* 16.0);
2960 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2961 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2962 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2963 pvr_get_current_channelname (mpctx
->stream
),
2964 pvr_get_current_stationname (mpctx
->stream
));
2966 #endif /* CONFIG_PVR */
2969 case MP_CMD_TV_STEP_FREQ
:
2970 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2971 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2972 cmd
->args
[0].v
.f
* 16.0);
2974 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2975 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2976 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2977 pvr_get_current_channelname (mpctx
->stream
),
2978 pvr_get_current_frequency (mpctx
->stream
));
2980 #endif /* CONFIG_PVR */
2983 case MP_CMD_TV_SET_NORM
:
2984 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2985 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2989 case MP_CMD_TV_STEP_CHANNEL
:{
2990 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2991 int v
= cmd
->args
[0].v
.i
;
2993 tv_step_channel((tvi_handle_t
*) (mpctx
->
2997 tv_step_channel((tvi_handle_t
*) (mpctx
->
3001 if (tv_channel_list
) {
3002 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3003 "Channel: %s", tv_channel_current
->name
);
3004 //vo_osd_changed(OSDTYPE_SUBTITLE);
3008 else if (mpctx
->stream
&&
3009 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3010 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3011 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3012 pvr_get_current_channelname (mpctx
->stream
),
3013 pvr_get_current_stationname (mpctx
->stream
));
3015 #endif /* CONFIG_PVR */
3018 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3020 int v
= cmd
->args
[0].v
.i
;
3022 mpctx
->last_dvb_step
= v
;
3024 dir
= DVB_CHANNEL_HIGHER
;
3026 dir
= DVB_CHANNEL_LOWER
;
3029 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3030 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3031 mpctx
->dvbin_reopen
= 1;
3034 #endif /* CONFIG_DVBIN */
3037 case MP_CMD_TV_SET_CHANNEL
:
3038 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3039 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3041 if (tv_channel_list
) {
3042 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3043 "Channel: %s", tv_channel_current
->name
);
3044 //vo_osd_changed(OSDTYPE_SUBTITLE);
3048 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3049 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3050 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3051 pvr_get_current_channelname (mpctx
->stream
),
3052 pvr_get_current_stationname (mpctx
->stream
));
3054 #endif /* CONFIG_PVR */
3058 case MP_CMD_DVB_SET_CHANNEL
:
3059 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3060 mpctx
->last_dvb_step
= 1;
3062 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3063 cmd
->args
[0].v
.i
)) {
3064 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3065 mpctx
->dvbin_reopen
= 1;
3069 #endif /* CONFIG_DVBIN */
3071 case MP_CMD_TV_LAST_CHANNEL
:
3072 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3073 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3074 if (tv_channel_list
) {
3075 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3076 "Channel: %s", tv_channel_current
->name
);
3077 //vo_osd_changed(OSDTYPE_SUBTITLE);
3081 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3082 pvr_set_lastchannel (mpctx
->stream
);
3083 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3084 pvr_get_current_channelname (mpctx
->stream
),
3085 pvr_get_current_stationname (mpctx
->stream
));
3087 #endif /* CONFIG_PVR */
3090 case MP_CMD_TV_STEP_NORM
:
3091 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3092 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3095 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3096 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3097 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3099 #endif /* CONFIG_TV */
3100 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3102 if (mpctx
->demuxer
->teletext
)
3103 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3104 &(cmd
->args
[0].v
.s
));
3107 case MP_CMD_TV_TELETEXT_GO_LINK
:
3109 if (mpctx
->demuxer
->teletext
)
3110 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3111 &(cmd
->args
[0].v
.i
));
3115 case MP_CMD_SUB_LOAD
:
3117 int n
= mpctx
->set_of_sub_size
;
3118 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3119 if (n
!= mpctx
->set_of_sub_size
) {
3120 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
3121 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
3122 mpctx
->global_sub_size
;
3123 ++mpctx
->global_sub_size
;
3128 case MP_CMD_SUB_REMOVE
:
3130 int v
= cmd
->args
[0].v
.i
;
3132 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3133 } else if (v
< mpctx
->set_of_sub_size
) {
3134 remove_subtitle_range(mpctx
, v
, 1);
3139 case MP_CMD_GET_SUB_VISIBILITY
:
3141 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3142 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3146 case MP_CMD_SCREENSHOT
:
3147 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3148 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3150 ((vf_instance_t
*) sh_video
->vfilter
)->
3151 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3153 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3157 case MP_CMD_VF_CHANGE_RECTANGLE
:
3160 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3163 case MP_CMD_GET_TIME_LENGTH
:{
3164 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3165 demuxer_get_time_length(mpctx
->demuxer
));
3169 case MP_CMD_GET_FILENAME
:{
3170 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3171 get_metadata(mpctx
, META_NAME
));
3175 case MP_CMD_GET_VIDEO_CODEC
:{
3176 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3179 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3184 case MP_CMD_GET_VIDEO_BITRATE
:{
3185 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3188 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3193 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3194 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3197 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3198 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3203 case MP_CMD_GET_AUDIO_CODEC
:{
3204 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3207 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3212 case MP_CMD_GET_AUDIO_BITRATE
:{
3213 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3216 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3221 case MP_CMD_GET_AUDIO_SAMPLES
:{
3222 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3225 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3230 case MP_CMD_GET_META_TITLE
:{
3231 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3234 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3239 case MP_CMD_GET_META_ARTIST
:{
3240 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3243 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3248 case MP_CMD_GET_META_ALBUM
:{
3249 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3252 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3257 case MP_CMD_GET_META_YEAR
:{
3258 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3261 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3266 case MP_CMD_GET_META_COMMENT
:{
3267 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3270 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3275 case MP_CMD_GET_META_TRACK
:{
3276 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3279 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3284 case MP_CMD_GET_META_GENRE
:{
3285 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3288 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3293 case MP_CMD_GET_VO_FULLSCREEN
:
3294 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3295 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3298 case MP_CMD_GET_PERCENT_POS
:
3299 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3300 demuxer_get_percent_pos(mpctx
->demuxer
));
3303 case MP_CMD_GET_TIME_POS
:{
3306 pos
= sh_video
->pts
;
3307 else if (sh_audio
&& mpctx
->audio_out
)
3308 pos
= playing_audio_pts(mpctx
);
3309 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3316 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3322 case MP_CMD_KEYDOWN_EVENTS
:
3323 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3326 case MP_CMD_SET_MOUSE_POS
:{
3327 int pointer_x
, pointer_y
;
3329 pointer_x
= cmd
->args
[0].v
.i
;
3330 pointer_y
= cmd
->args
[1].v
.i
;
3331 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3332 #ifdef CONFIG_DVDNAV
3333 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3334 && dx
> 0.0 && dy
> 0.0) {
3336 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3337 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3338 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3339 pointer_x
, pointer_y
, &button
);
3340 if (opts
->osd_level
> 1 && button
> 0)
3341 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3342 "Selected button number %d", button
);
3346 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3347 menu_update_mouse_pos(dx
, dy
);
3352 #ifdef CONFIG_DVDNAV
3353 case MP_CMD_DVDNAV
:{
3356 mp_command_type command
= 0;
3357 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3360 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3361 if (cmd
->args
[0].v
.s
&&
3362 !strcasecmp (cmd
->args
[0].v
.s
,
3363 mp_dvdnav_bindings
[i
].name
))
3364 command
= mp_dvdnav_bindings
[i
].cmd
;
3366 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3367 if (opts
->osd_level
> 1 && button
> 0)
3368 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3369 "Selected button number %d", button
);
3373 case MP_CMD_SWITCH_TITLE
:
3374 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3375 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3381 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3382 "Received unknown cmd %s\n", cmd
->name
);
3385 switch (cmd
->pausing
) {
3386 case 1: // "pausing"
3387 pause_player(mpctx
);
3389 case 3: // "pausing_toggle"
3391 unpause_player(mpctx
);
3393 pause_player(mpctx
);