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"
38 #include "libmpcodecs/vf.h"
39 #include "libmpcodecs/vd.h"
41 #include "libvo/video_out.h"
42 #include "libvo/font_load.h"
44 #include "libao2/audio_out.h"
47 #include "libmpcodecs/dec_video.h"
48 #include "libmpcodecs/dec_teletext.h"
53 #include "stream/tv.h"
54 #include "stream/stream_radio.h"
55 #include "stream/pvr.h"
57 #include "stream/dvbin.h"
60 #include "stream/stream_dvd.h"
62 #include "stream/stream_dvdnav.h"
64 #include "libmenu/menu.h"
68 #include "libavutil/avstring.h"
70 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
74 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
75 double *dx
, double *dy
)
77 struct MPOpts
*opts
= &mpctx
->opts
;
78 struct vo
*vo
= mpctx
->video_out
;
79 //remove the borders, if any, and rescale to the range [0,1],[0,1]
80 if (vo_fs
) { //we are in full-screen mode
81 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
82 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
83 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
84 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
86 if (ix
< 0 || ix
> vo
->dwidth
) {
89 } //we are on one of the borders
90 if (iy
< 0 || iy
> vo
->dheight
) {
93 } //we are on one of the borders
96 *dx
= (double) ix
/ (double) vo
->dwidth
;
97 *dy
= (double) iy
/ (double) vo
->dheight
;
99 mp_msg(MSGT_CPLAYER
, MSGL_V
,
100 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
101 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
105 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
110 for (i
= 0; i
< SUB_SOURCES
; i
++) {
111 int j
= mpctx
->global_sub_indices
[i
];
112 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
120 static int sub_source(MPContext
*mpctx
)
122 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
126 * \brief Log the currently displayed subtitle to a file
128 * Logs the current or last displayed subtitle together with filename
129 * and time information to ~/.mplayer/subtitle_log
131 * Intended purpose is to allow convenient marking of bogus subtitles
132 * which need to be fixed while watching the movie.
135 static void log_sub(struct MPContext
*mpctx
)
141 if (subdata
== NULL
|| vo_sub_last
== NULL
)
143 fname
= get_path("subtitle_log");
144 f
= fopen(fname
, "a");
147 fprintf(f
, "----------------------------------------------------------\n");
148 if (subdata
->sub_uses_time
) {
150 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
151 mpctx
->filename
, vo_sub_last
->start
/ 360000,
152 (vo_sub_last
->start
/ 6000) % 60,
153 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
154 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
155 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
157 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
158 vo_sub_last
->start
, vo_sub_last
->end
);
160 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
161 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
167 /// \defgroup Properties
170 /// \defgroup GeneralProperties General properties
171 /// \ingroup Properties
175 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
178 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
182 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
185 struct MPOpts
*opts
= &mpctx
->opts
;
187 case M_PROPERTY_PRINT
:
188 if (!arg
) return M_PROPERTY_ERROR
;
189 if (opts
->loop_times
< 0)
190 *(char**)arg
= strdup("off");
191 else if (opts
->loop_times
== 0)
192 *(char**)arg
= strdup("inf");
195 return M_PROPERTY_OK
;
197 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
200 /// Playback speed (RW)
201 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
202 void *arg
, MPContext
*mpctx
)
204 struct MPOpts
*opts
= &mpctx
->opts
;
208 return M_PROPERTY_ERROR
;
209 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
210 opts
->playback_speed
= *(float *) arg
;
211 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
212 return M_PROPERTY_OK
;
213 case M_PROPERTY_STEP_UP
:
214 case M_PROPERTY_STEP_DOWN
:
215 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
216 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
217 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
218 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
219 return M_PROPERTY_OK
;
221 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
224 /// filename with path (RO)
225 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
228 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
231 /// filename without path (RO)
232 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
236 if (!mpctx
->filename
)
237 return M_PROPERTY_UNAVAILABLE
;
238 if (((f
= strrchr(mpctx
->filename
, '/'))
239 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
243 return m_property_string_ro(prop
, action
, arg
, f
);
246 /// Demuxer name (RO)
247 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
251 return M_PROPERTY_UNAVAILABLE
;
252 return m_property_string_ro(prop
, action
, arg
,
253 (char *) mpctx
->demuxer
->desc
->name
);
256 /// Position in the stream (RW)
257 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
260 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
261 return M_PROPERTY_UNAVAILABLE
;
263 return M_PROPERTY_ERROR
;
266 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
267 return M_PROPERTY_OK
;
269 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
270 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
271 return M_PROPERTY_OK
;
273 return M_PROPERTY_NOT_IMPLEMENTED
;
276 /// Stream start offset (RO)
277 static int mp_property_stream_start(m_option_t
*prop
, int action
,
278 void *arg
, MPContext
*mpctx
)
280 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
281 return M_PROPERTY_UNAVAILABLE
;
284 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
285 return M_PROPERTY_OK
;
287 return M_PROPERTY_NOT_IMPLEMENTED
;
290 /// Stream end offset (RO)
291 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
294 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
295 return M_PROPERTY_UNAVAILABLE
;
298 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
299 return M_PROPERTY_OK
;
301 return M_PROPERTY_NOT_IMPLEMENTED
;
304 /// Stream length (RO)
305 static int mp_property_stream_length(m_option_t
*prop
, int action
,
306 void *arg
, MPContext
*mpctx
)
308 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
309 return M_PROPERTY_UNAVAILABLE
;
313 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
314 return M_PROPERTY_OK
;
316 return M_PROPERTY_NOT_IMPLEMENTED
;
319 /// Media length in seconds (RO)
320 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
325 if (!mpctx
->demuxer
||
326 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
327 return M_PROPERTY_UNAVAILABLE
;
329 return m_property_time_ro(prop
, action
, arg
, len
);
332 /// Current position in percent (RW)
333 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
334 void *arg
, MPContext
*mpctx
) {
338 return M_PROPERTY_UNAVAILABLE
;
342 if(!arg
) return M_PROPERTY_ERROR
;
343 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
346 case M_PROPERTY_STEP_UP
:
347 case M_PROPERTY_STEP_DOWN
:
348 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
349 pos
+= (arg
? *(int*)arg
: 10) *
350 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
351 M_PROPERTY_CLAMP(prop
, pos
);
354 return m_property_int_ro(prop
, action
, arg
,
355 demuxer_get_percent_pos(mpctx
->demuxer
));
358 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
359 mpctx
->rel_seek_secs
= pos
/ 100.0;
360 return M_PROPERTY_OK
;
363 /// Current position in seconds (RW)
364 static int mp_property_time_pos(m_option_t
*prop
, int action
,
365 void *arg
, MPContext
*mpctx
) {
366 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
367 return M_PROPERTY_UNAVAILABLE
;
371 if(!arg
) return M_PROPERTY_ERROR
;
372 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
373 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
374 mpctx
->rel_seek_secs
= *(double*)arg
;
375 return M_PROPERTY_OK
;
376 case M_PROPERTY_STEP_UP
:
377 case M_PROPERTY_STEP_DOWN
:
378 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
379 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
380 return M_PROPERTY_OK
;
382 return m_property_time_ro(prop
, action
, arg
,
383 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
384 playing_audio_pts(mpctx
));
387 /// Current chapter (RW)
388 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
391 struct MPOpts
*opts
= &mpctx
->opts
;
394 char *chapter_name
= NULL
;
397 chapter
= get_current_chapter(mpctx
);
399 return M_PROPERTY_UNAVAILABLE
;
404 return M_PROPERTY_ERROR
;
405 *(int *) arg
= chapter
;
406 return M_PROPERTY_OK
;
407 case M_PROPERTY_PRINT
: {
409 return M_PROPERTY_ERROR
;
410 chapter_name
= chapter_display_name(mpctx
, chapter
);
412 return M_PROPERTY_UNAVAILABLE
;
413 *(char **) arg
= chapter_name
;
414 return M_PROPERTY_OK
;
418 return M_PROPERTY_ERROR
;
419 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
420 step_all
= *(int *)arg
- chapter
;
423 case M_PROPERTY_STEP_UP
:
424 case M_PROPERTY_STEP_DOWN
: {
425 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
426 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
433 return M_PROPERTY_NOT_IMPLEMENTED
;
437 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
438 mpctx
->rel_seek_secs
= 0;
439 mpctx
->abs_seek_pos
= 0;
441 if (next_pts
> -1.0) {
442 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
443 mpctx
->rel_seek_secs
= next_pts
;
446 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
447 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
449 else if (step_all
> 0)
450 mpctx
->rel_seek_secs
= 1000000000.;
452 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
453 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
455 talloc_free(chapter_name
);
456 return M_PROPERTY_OK
;
459 /// Number of chapters in file
460 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
464 return M_PROPERTY_UNAVAILABLE
;
465 if (mpctx
->demuxer
->num_chapters
== 0)
466 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
467 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
470 /// Current dvd angle (RW)
471 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
474 struct MPOpts
*opts
= &mpctx
->opts
;
477 char *angle_name
= NULL
;
480 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
482 return M_PROPERTY_UNAVAILABLE
;
483 angles
= demuxer_angles_count(mpctx
->demuxer
);
485 return M_PROPERTY_UNAVAILABLE
;
490 return M_PROPERTY_ERROR
;
491 *(int *) arg
= angle
;
492 return M_PROPERTY_OK
;
493 case M_PROPERTY_PRINT
: {
495 return M_PROPERTY_ERROR
;
496 angle_name
= calloc(1, 64);
498 return M_PROPERTY_UNAVAILABLE
;
499 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
500 *(char **) arg
= angle_name
;
501 return M_PROPERTY_OK
;
505 return M_PROPERTY_ERROR
;
507 M_PROPERTY_CLAMP(prop
, angle
);
509 case M_PROPERTY_STEP_UP
:
510 case M_PROPERTY_STEP_DOWN
: {
516 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
518 if (angle
< 1) //cycle
523 return M_PROPERTY_NOT_IMPLEMENTED
;
525 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
526 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
527 "Angle: %d/%d", angle
, angles
);
530 return M_PROPERTY_OK
;
533 /// Demuxer meta data
534 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
536 m_property_action_t
* ka
;
538 static const m_option_t key_type
=
539 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
541 return M_PROPERTY_UNAVAILABLE
;
545 if(!arg
) return M_PROPERTY_ERROR
;
546 *(char***)arg
= mpctx
->demuxer
->info
;
547 return M_PROPERTY_OK
;
548 case M_PROPERTY_KEY_ACTION
:
549 if(!arg
) return M_PROPERTY_ERROR
;
551 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
552 return M_PROPERTY_UNKNOWN
;
555 if(!ka
->arg
) return M_PROPERTY_ERROR
;
556 *(char**)ka
->arg
= meta
;
557 return M_PROPERTY_OK
;
558 case M_PROPERTY_GET_TYPE
:
559 if(!ka
->arg
) return M_PROPERTY_ERROR
;
560 *(m_option_t
**)ka
->arg
= &key_type
;
561 return M_PROPERTY_OK
;
564 return M_PROPERTY_NOT_IMPLEMENTED
;
567 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
570 MPContext
*mpctx
= ctx
;
575 return M_PROPERTY_ERROR
;
576 if (mpctx
->paused
== (bool)*(int *) arg
)
577 return M_PROPERTY_OK
;
578 case M_PROPERTY_STEP_UP
:
579 case M_PROPERTY_STEP_DOWN
:
581 unpause_player(mpctx
);
582 mpctx
->osd_function
= OSD_PLAY
;
586 mpctx
->osd_function
= OSD_PAUSE
;
588 return M_PROPERTY_OK
;
590 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
597 /// \defgroup AudioProperties Audio properties
598 /// \ingroup Properties
602 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
606 if (!mpctx
->sh_audio
)
607 return M_PROPERTY_UNAVAILABLE
;
612 return M_PROPERTY_ERROR
;
613 mixer_getbothvolume(&mpctx
->mixer
, arg
);
614 return M_PROPERTY_OK
;
615 case M_PROPERTY_PRINT
:{
618 return M_PROPERTY_ERROR
;
619 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
620 return m_property_float_range(prop
, action
, arg
, &vol
);
622 case M_PROPERTY_STEP_UP
:
623 case M_PROPERTY_STEP_DOWN
:
627 return M_PROPERTY_NOT_IMPLEMENTED
;
630 if (mpctx
->edl_muted
)
631 return M_PROPERTY_DISABLED
;
632 mpctx
->user_muted
= 0;
637 return M_PROPERTY_ERROR
;
638 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
639 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
640 return M_PROPERTY_OK
;
641 case M_PROPERTY_STEP_UP
:
642 if (arg
&& *(float *) arg
<= 0)
643 mixer_decvolume(&mpctx
->mixer
);
645 mixer_incvolume(&mpctx
->mixer
);
646 return M_PROPERTY_OK
;
647 case M_PROPERTY_STEP_DOWN
:
648 if (arg
&& *(float *) arg
<= 0)
649 mixer_incvolume(&mpctx
->mixer
);
651 mixer_decvolume(&mpctx
->mixer
);
652 return M_PROPERTY_OK
;
654 return M_PROPERTY_NOT_IMPLEMENTED
;
658 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
662 if (!mpctx
->sh_audio
)
663 return M_PROPERTY_UNAVAILABLE
;
667 if (mpctx
->edl_muted
)
668 return M_PROPERTY_DISABLED
;
670 return M_PROPERTY_ERROR
;
671 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
672 mixer_mute(&mpctx
->mixer
);
673 mpctx
->user_muted
= mpctx
->mixer
.muted
;
674 return M_PROPERTY_OK
;
675 case M_PROPERTY_STEP_UP
:
676 case M_PROPERTY_STEP_DOWN
:
677 if (mpctx
->edl_muted
)
678 return M_PROPERTY_DISABLED
;
679 mixer_mute(&mpctx
->mixer
);
680 mpctx
->user_muted
= mpctx
->mixer
.muted
;
681 return M_PROPERTY_OK
;
682 case M_PROPERTY_PRINT
:
684 return M_PROPERTY_ERROR
;
685 if (mpctx
->edl_muted
) {
686 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
687 return M_PROPERTY_OK
;
690 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
696 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
697 void *arg
, MPContext
*mpctx
)
699 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
700 return M_PROPERTY_UNAVAILABLE
;
703 case M_PROPERTY_STEP_UP
:
704 case M_PROPERTY_STEP_DOWN
: {
706 float delay
= audio_delay
;
707 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
708 if (ret
!= M_PROPERTY_OK
)
711 mpctx
->delay
-= audio_delay
- delay
;
713 return M_PROPERTY_OK
;
715 return m_property_delay(prop
, action
, arg
, &audio_delay
);
719 /// Audio codec tag (RO)
720 static int mp_property_audio_format(m_option_t
*prop
, int action
,
721 void *arg
, MPContext
*mpctx
)
723 if (!mpctx
->sh_audio
)
724 return M_PROPERTY_UNAVAILABLE
;
725 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
728 /// Audio codec name (RO)
729 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
730 void *arg
, MPContext
*mpctx
)
732 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
733 return M_PROPERTY_UNAVAILABLE
;
734 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
737 /// Audio bitrate (RO)
738 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
739 void *arg
, MPContext
*mpctx
)
741 if (!mpctx
->sh_audio
)
742 return M_PROPERTY_UNAVAILABLE
;
743 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
747 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
750 if (!mpctx
->sh_audio
)
751 return M_PROPERTY_UNAVAILABLE
;
753 case M_PROPERTY_PRINT
:
754 if(!arg
) return M_PROPERTY_ERROR
;
755 *(char**)arg
= malloc(16);
756 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
757 return M_PROPERTY_OK
;
759 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
762 /// Number of channels (RO)
763 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
766 if (!mpctx
->sh_audio
)
767 return M_PROPERTY_UNAVAILABLE
;
769 case M_PROPERTY_PRINT
:
771 return M_PROPERTY_ERROR
;
772 switch (mpctx
->sh_audio
->channels
) {
774 *(char **) arg
= strdup("mono");
777 *(char **) arg
= strdup("stereo");
780 *(char **) arg
= malloc(32);
781 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
783 return M_PROPERTY_OK
;
785 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
789 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
794 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
795 return M_PROPERTY_UNAVAILABLE
;
800 return M_PROPERTY_ERROR
;
801 mixer_getbalance(&mpctx
->mixer
, arg
);
802 return M_PROPERTY_OK
;
803 case M_PROPERTY_PRINT
: {
806 return M_PROPERTY_ERROR
;
807 mixer_getbalance(&mpctx
->mixer
, &bal
);
809 *str
= strdup("center");
810 else if (bal
== -1.f
)
811 *str
= strdup("left only");
813 *str
= strdup("right only");
815 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
816 *str
= malloc(sizeof("left xxx%, right xxx%"));
817 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
819 return M_PROPERTY_OK
;
821 case M_PROPERTY_STEP_UP
:
822 case M_PROPERTY_STEP_DOWN
:
823 mixer_getbalance(&mpctx
->mixer
, &bal
);
824 bal
+= (arg
? *(float*)arg
: .1f
) *
825 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
826 M_PROPERTY_CLAMP(prop
, bal
);
827 mixer_setbalance(&mpctx
->mixer
, bal
);
828 return M_PROPERTY_OK
;
831 return M_PROPERTY_ERROR
;
832 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
833 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
834 return M_PROPERTY_OK
;
836 return M_PROPERTY_NOT_IMPLEMENTED
;
839 /// Selected audio id (RW)
840 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
843 struct MPOpts
*opts
= &mpctx
->opts
;
845 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
846 return M_PROPERTY_UNAVAILABLE
;
847 current_id
= mpctx
->demuxer
->audio
->id
;
852 return M_PROPERTY_ERROR
;
853 *(int *) arg
= current_id
;
854 return M_PROPERTY_OK
;
855 case M_PROPERTY_PRINT
:
857 return M_PROPERTY_ERROR
;
860 *(char **) arg
= strdup(mp_gtext("disabled"));
863 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
864 sh_audio_t
* sh
= mpctx
->sh_audio
;
866 av_strlcpy(lang
, sh
->lang
, 40);
867 #ifdef CONFIG_DVDREAD
868 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
869 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
879 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
880 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
882 *(char **) arg
= malloc(64);
883 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
885 return M_PROPERTY_OK
;
887 case M_PROPERTY_STEP_UP
:
889 if (action
== M_PROPERTY_SET
&& arg
)
890 tmp
= *((int *) arg
);
893 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
894 if (opts
->audio_id
== -2
895 || (opts
->audio_id
> -1
896 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
897 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
898 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
900 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
902 sh2
->ds
= mpctx
->demuxer
->audio
;
903 mpctx
->sh_audio
= sh2
;
904 reinit_audio_chain(mpctx
);
907 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
908 return M_PROPERTY_OK
;
910 return M_PROPERTY_NOT_IMPLEMENTED
;
915 /// Selected video id (RW)
916 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
919 struct MPOpts
*opts
= &mpctx
->opts
;
921 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
922 return M_PROPERTY_UNAVAILABLE
;
923 current_id
= mpctx
->demuxer
->video
->id
;
928 return M_PROPERTY_ERROR
;
929 *(int *) arg
= current_id
;
930 return M_PROPERTY_OK
;
931 case M_PROPERTY_PRINT
:
933 return M_PROPERTY_ERROR
;
936 *(char **) arg
= strdup(mp_gtext("disabled"));
939 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
940 *(char **) arg
= malloc(64);
941 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
943 return M_PROPERTY_OK
;
945 case M_PROPERTY_STEP_UP
:
947 if (action
== M_PROPERTY_SET
&& arg
)
948 tmp
= *((int *) arg
);
951 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
952 if (opts
->video_id
== -2
953 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
954 && current_id
!= -2))
955 uninit_player(mpctx
, INITIALIZED_VCODEC
|
956 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
957 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
959 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
961 sh2
->ds
= mpctx
->demuxer
->video
;
962 mpctx
->sh_video
= sh2
;
963 reinit_video_chain(mpctx
);
966 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
967 return M_PROPERTY_OK
;
970 return M_PROPERTY_NOT_IMPLEMENTED
;
974 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
977 demux_program_t prog
;
980 case M_PROPERTY_STEP_UP
:
982 if (action
== M_PROPERTY_SET
&& arg
)
983 prog
.progid
= *((int *) arg
);
987 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
988 &prog
) == DEMUXER_CTRL_NOTIMPL
)
989 return M_PROPERTY_ERROR
;
991 if (prog
.aid
< 0 && prog
.vid
< 0) {
992 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
993 return M_PROPERTY_ERROR
;
995 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
996 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
997 return M_PROPERTY_OK
;
1000 return M_PROPERTY_NOT_IMPLEMENTED
;
1006 /// \defgroup VideoProperties Video properties
1007 /// \ingroup Properties
1010 /// Fullscreen state (RW)
1011 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1015 if (!mpctx
->video_out
)
1016 return M_PROPERTY_UNAVAILABLE
;
1019 case M_PROPERTY_SET
:
1021 return M_PROPERTY_ERROR
;
1022 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1023 if (vo_fs
== !!*(int *) arg
)
1024 return M_PROPERTY_OK
;
1025 case M_PROPERTY_STEP_UP
:
1026 case M_PROPERTY_STEP_DOWN
:
1027 if (mpctx
->video_out
->config_ok
)
1028 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1029 mpctx
->opts
.fullscreen
= vo_fs
;
1030 return M_PROPERTY_OK
;
1032 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1036 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1037 void *arg
, MPContext
*mpctx
)
1041 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1042 return M_PROPERTY_UNAVAILABLE
;
1043 vf
= mpctx
->sh_video
->vfilter
;
1045 case M_PROPERTY_GET
:
1047 return M_PROPERTY_ERROR
;
1048 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1049 return M_PROPERTY_OK
;
1050 case M_PROPERTY_SET
:
1052 return M_PROPERTY_ERROR
;
1053 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1054 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1055 return M_PROPERTY_OK
;
1056 case M_PROPERTY_STEP_UP
:
1057 case M_PROPERTY_STEP_DOWN
:
1058 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1059 deinterlace
= !deinterlace
;
1060 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1061 return M_PROPERTY_OK
;
1064 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1065 return m_property_flag_ro(prop
, action
, arg
, value
);
1068 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1069 void *arg
, MPContext
*mpctx
)
1071 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1072 return M_PROPERTY_UNAVAILABLE
;
1074 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1077 case M_PROPERTY_GET
:
1079 return M_PROPERTY_ERROR
;
1080 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1081 return M_PROPERTY_UNAVAILABLE
;
1082 return M_PROPERTY_OK
;
1083 case M_PROPERTY_PRINT
:
1085 return M_PROPERTY_ERROR
;
1086 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1087 return M_PROPERTY_UNAVAILABLE
;
1088 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1089 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1090 *(char **)arg
= strdup("Unknown");
1092 *(char**)arg
= strdup(names
[colorspace
]);
1093 return M_PROPERTY_OK
;
1094 case M_PROPERTY_SET
:
1096 return M_PROPERTY_ERROR
;
1097 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1098 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1099 return M_PROPERTY_OK
;
1100 case M_PROPERTY_STEP_UP
:;
1101 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1102 return M_PROPERTY_UNAVAILABLE
;
1104 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1105 return M_PROPERTY_OK
;
1107 return M_PROPERTY_NOT_IMPLEMENTED
;
1111 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1115 if (!mpctx
->video_out
1116 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1117 return M_PROPERTY_UNAVAILABLE
;
1120 case M_PROPERTY_SET
:
1122 return M_PROPERTY_ERROR
;
1123 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1124 vo_panscan
= *(float *) arg
;
1125 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1126 return M_PROPERTY_OK
;
1127 case M_PROPERTY_STEP_UP
:
1128 case M_PROPERTY_STEP_DOWN
:
1129 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1130 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1133 else if (vo_panscan
< 0)
1135 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1136 return M_PROPERTY_OK
;
1138 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1142 /// Helper to set vo flags.
1143 /** \ingroup PropertyImplHelper
1145 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1146 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1149 if (!mpctx
->video_out
)
1150 return M_PROPERTY_UNAVAILABLE
;
1153 case M_PROPERTY_SET
:
1155 return M_PROPERTY_ERROR
;
1156 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1157 if (*vo_var
== !!*(int *) arg
)
1158 return M_PROPERTY_OK
;
1159 case M_PROPERTY_STEP_UP
:
1160 case M_PROPERTY_STEP_DOWN
:
1161 if (mpctx
->video_out
->config_ok
)
1162 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1163 return M_PROPERTY_OK
;
1165 return m_property_flag(prop
, action
, arg
, vo_var
);
1169 /// Window always on top (RW)
1170 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1173 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1174 &mpctx
->opts
.vo_ontop
, mpctx
);
1177 /// Display in the root window (RW)
1178 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1181 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1182 &vo_rootwin
, mpctx
);
1185 /// Show window borders (RW)
1186 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1189 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1193 /// Framedropping state (RW)
1194 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1195 void *arg
, MPContext
*mpctx
)
1198 if (!mpctx
->sh_video
)
1199 return M_PROPERTY_UNAVAILABLE
;
1202 case M_PROPERTY_PRINT
:
1204 return M_PROPERTY_ERROR
;
1205 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1206 (frame_dropping
== 2 ? mp_gtext("hard") :
1207 mp_gtext("disabled")));
1208 return M_PROPERTY_OK
;
1210 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1214 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1215 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1218 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1221 if (!mpctx
->sh_video
)
1222 return M_PROPERTY_UNAVAILABLE
;
1224 if (gamma
[0] == 1000) {
1226 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1230 case M_PROPERTY_SET
:
1232 return M_PROPERTY_ERROR
;
1233 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1234 *gamma
= *(int *) arg
;
1235 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1239 case M_PROPERTY_GET
:
1240 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1242 return M_PROPERTY_ERROR
;
1244 return M_PROPERTY_OK
;
1247 case M_PROPERTY_STEP_UP
:
1248 case M_PROPERTY_STEP_DOWN
:
1249 *gamma
+= (arg
? *(int *) arg
: 1) *
1250 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1251 M_PROPERTY_CLAMP(prop
, *gamma
);
1252 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1257 return M_PROPERTY_NOT_IMPLEMENTED
;
1261 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1262 int l
= strlen(prop
->name
);
1263 char tv_prop
[3 + l
+ 1];
1264 sprintf(tv_prop
, "tv_%s", prop
->name
);
1265 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1269 return M_PROPERTY_UNAVAILABLE
;
1273 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1276 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1279 /// Video codec tag (RO)
1280 static int mp_property_video_format(m_option_t
*prop
, int action
,
1281 void *arg
, MPContext
*mpctx
)
1284 if (!mpctx
->sh_video
)
1285 return M_PROPERTY_UNAVAILABLE
;
1287 case M_PROPERTY_PRINT
:
1289 return M_PROPERTY_ERROR
;
1290 switch(mpctx
->sh_video
->format
) {
1292 meta
= strdup ("mpeg1"); break;
1294 meta
= strdup ("mpeg2"); break;
1296 meta
= strdup ("mpeg4"); break;
1298 meta
= strdup ("h264"); break;
1300 if(mpctx
->sh_video
->format
>= 0x20202020) {
1302 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1305 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1308 *(char**)arg
= meta
;
1309 return M_PROPERTY_OK
;
1311 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1314 /// Video codec name (RO)
1315 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1316 void *arg
, MPContext
*mpctx
)
1318 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1319 return M_PROPERTY_UNAVAILABLE
;
1320 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1324 /// Video bitrate (RO)
1325 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1326 void *arg
, MPContext
*mpctx
)
1328 if (!mpctx
->sh_video
)
1329 return M_PROPERTY_UNAVAILABLE
;
1330 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1333 /// Video display width (RO)
1334 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1337 if (!mpctx
->sh_video
)
1338 return M_PROPERTY_UNAVAILABLE
;
1339 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1342 /// Video display height (RO)
1343 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1346 if (!mpctx
->sh_video
)
1347 return M_PROPERTY_UNAVAILABLE
;
1348 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1352 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1355 if (!mpctx
->sh_video
)
1356 return M_PROPERTY_UNAVAILABLE
;
1357 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1360 /// Video aspect (RO)
1361 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1364 if (!mpctx
->sh_video
)
1365 return M_PROPERTY_UNAVAILABLE
;
1366 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1371 /// \defgroup SubProprties Subtitles properties
1372 /// \ingroup Properties
1375 /// Text subtitle position (RW)
1376 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1380 case M_PROPERTY_SET
:
1382 return M_PROPERTY_ERROR
;
1383 case M_PROPERTY_STEP_UP
:
1384 case M_PROPERTY_STEP_DOWN
:
1385 vo_osd_changed(OSDTYPE_SUBTITLE
);
1387 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1391 /// Selected subtitles (RW)
1392 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1395 struct MPOpts
*opts
= &mpctx
->opts
;
1396 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1397 const int global_sub_size
= mpctx
->global_sub_size
;
1398 int source
= -1, reset_spu
= 0;
1401 if (global_sub_size
<= 0)
1402 return M_PROPERTY_UNAVAILABLE
;
1405 case M_PROPERTY_GET
:
1407 return M_PROPERTY_ERROR
;
1408 *(int *) arg
= mpctx
->global_sub_pos
;
1409 return M_PROPERTY_OK
;
1410 case M_PROPERTY_PRINT
:
1412 return M_PROPERTY_ERROR
;
1413 *(char **) arg
= malloc(64);
1414 (*(char **) arg
)[63] = 0;
1417 sub_name
= subdata
->filename
;
1419 if (ass_track
&& ass_track
->name
)
1420 sub_name
= ass_track
->name
;
1425 if ((tmp2
= strrchr(tmp
, '/')))
1428 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1429 mpctx
->set_of_sub_pos
+ 1,
1430 strlen(tmp
) < 20 ? "" : "...",
1431 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1432 return M_PROPERTY_OK
;
1434 #ifdef CONFIG_DVDNAV
1435 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1436 if (vo_spudec
&& opts
->sub_id
>= 0) {
1437 unsigned char lang
[3];
1438 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1439 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1440 return M_PROPERTY_OK
;
1446 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1447 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1448 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1449 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1450 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1451 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1452 if (!lang
) lang
= mp_gtext("unknown");
1453 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1454 return M_PROPERTY_OK
;
1457 if (vo_vobsub
&& vobsub_id
>= 0) {
1458 const char *language
= mp_gtext("unknown");
1459 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1460 snprintf(*(char **) arg
, 63, "(%d) %s",
1461 vobsub_id
, language
? language
: mp_gtext("unknown"));
1462 return M_PROPERTY_OK
;
1464 #ifdef CONFIG_DVDREAD
1465 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1466 && opts
->sub_id
>= 0) {
1468 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1469 lang
[0] = code
>> 8;
1472 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1473 return M_PROPERTY_OK
;
1476 if (opts
->sub_id
>= 0) {
1477 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1478 mp_gtext("unknown"));
1479 return M_PROPERTY_OK
;
1481 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1482 return M_PROPERTY_OK
;
1484 case M_PROPERTY_SET
:
1486 return M_PROPERTY_ERROR
;
1487 if (*(int *) arg
< -1)
1489 else if (*(int *) arg
>= global_sub_size
)
1490 *(int *) arg
= global_sub_size
- 1;
1491 mpctx
->global_sub_pos
= *(int *) arg
;
1493 case M_PROPERTY_STEP_UP
:
1494 mpctx
->global_sub_pos
+= 2;
1495 mpctx
->global_sub_pos
=
1496 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1498 case M_PROPERTY_STEP_DOWN
:
1499 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1500 mpctx
->global_sub_pos
=
1501 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1504 return M_PROPERTY_NOT_IMPLEMENTED
;
1507 if (mpctx
->global_sub_pos
>= 0)
1508 source
= sub_source(mpctx
);
1510 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1511 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1513 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1514 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1515 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1516 mpctx
->global_sub_pos
, source
);
1518 mpctx
->set_of_sub_pos
= -1;
1532 if (source
== SUB_SOURCE_VOBSUB
) {
1533 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1534 } else if (source
== SUB_SOURCE_SUBS
) {
1535 mpctx
->set_of_sub_pos
=
1536 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1538 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1539 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1543 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1544 vo_osd_changed(OSDTYPE_SUBTITLE
);
1546 } else if (source
== SUB_SOURCE_DEMUX
) {
1548 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1549 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1551 // default: assume 1:1 mapping of sid and stream id
1552 d_sub
->id
= opts
->sub_id
;
1553 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1554 ds_free_packs(d_sub
);
1555 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1556 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1557 if (sh
&& sh
->sid
== opts
->sub_id
) {
1563 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1564 sh_sub_t
*sh
= d_sub
->sh
;
1565 if (sh
->type
== 'v')
1566 init_vo_spudec(mpctx
);
1568 else if (opts
->ass_enabled
)
1569 ass_track
= sh
->ass_track
;
1577 #ifdef CONFIG_DVDREAD
1579 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1580 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1581 && opts
->sub_id
< 0 && reset_spu
) {
1587 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1589 return M_PROPERTY_OK
;
1592 /// Selected sub source (RW)
1593 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1597 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1598 return M_PROPERTY_UNAVAILABLE
;
1601 case M_PROPERTY_GET
:
1603 return M_PROPERTY_ERROR
;
1604 *(int *) arg
= sub_source(mpctx
);
1605 return M_PROPERTY_OK
;
1606 case M_PROPERTY_PRINT
:
1608 return M_PROPERTY_ERROR
;
1609 *(char **) arg
= malloc(64);
1610 (*(char **) arg
)[63] = 0;
1611 switch (sub_source(mpctx
))
1613 case SUB_SOURCE_SUBS
:
1614 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1616 case SUB_SOURCE_VOBSUB
:
1617 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1619 case SUB_SOURCE_DEMUX
:
1620 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1623 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1625 return M_PROPERTY_OK
;
1626 case M_PROPERTY_SET
:
1628 return M_PROPERTY_ERROR
;
1629 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1630 if (*(int *) arg
< 0)
1631 mpctx
->global_sub_pos
= -1;
1632 else if (*(int *) arg
!= sub_source(mpctx
)) {
1633 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1634 return M_PROPERTY_UNAVAILABLE
;
1635 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1638 case M_PROPERTY_STEP_UP
:
1639 case M_PROPERTY_STEP_DOWN
: {
1640 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1641 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1642 int step
= (step_all
> 0) ? 1 : -1;
1643 int cur_source
= sub_source(mpctx
);
1644 source
= cur_source
;
1647 if (source
>= SUB_SOURCES
)
1649 else if (source
< -1)
1650 source
= SUB_SOURCES
- 1;
1651 if (source
== cur_source
|| source
== -1 ||
1652 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1655 if (source
== cur_source
)
1656 return M_PROPERTY_OK
;
1658 mpctx
->global_sub_pos
= -1;
1660 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1664 return M_PROPERTY_NOT_IMPLEMENTED
;
1666 --mpctx
->global_sub_pos
;
1667 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1670 /// Selected subtitles from specific source (RW)
1671 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1674 int source
, is_cur_source
, offset
;
1675 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1676 return M_PROPERTY_UNAVAILABLE
;
1678 if (!strcmp(prop
->name
, "sub_file"))
1679 source
= SUB_SOURCE_SUBS
;
1680 else if (!strcmp(prop
->name
, "sub_vob"))
1681 source
= SUB_SOURCE_VOBSUB
;
1682 else if (!strcmp(prop
->name
, "sub_demux"))
1683 source
= SUB_SOURCE_DEMUX
;
1685 return M_PROPERTY_ERROR
;
1687 offset
= mpctx
->global_sub_indices
[source
];
1688 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1689 return M_PROPERTY_UNAVAILABLE
;
1691 is_cur_source
= sub_source(mpctx
) == source
;
1693 case M_PROPERTY_GET
:
1695 return M_PROPERTY_ERROR
;
1696 if (is_cur_source
) {
1697 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1698 if (source
== SUB_SOURCE_VOBSUB
)
1699 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1703 return M_PROPERTY_OK
;
1704 case M_PROPERTY_PRINT
:
1706 return M_PROPERTY_ERROR
;
1708 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1709 *(char **) arg
= malloc(64);
1710 (*(char **) arg
)[63] = 0;
1711 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1712 return M_PROPERTY_OK
;
1713 case M_PROPERTY_SET
:
1715 return M_PROPERTY_ERROR
;
1716 if (*(int *) arg
>= 0) {
1717 int index
= *(int *)arg
;
1718 if (source
== SUB_SOURCE_VOBSUB
)
1719 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1720 mpctx
->global_sub_pos
= offset
+ index
;
1721 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1722 || sub_source(mpctx
) != source
) {
1723 mpctx
->global_sub_pos
= -1;
1728 mpctx
->global_sub_pos
= -1;
1730 case M_PROPERTY_STEP_UP
:
1731 case M_PROPERTY_STEP_DOWN
: {
1732 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1733 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1734 int step
= (step_all
> 0) ? 1 : -1;
1735 int max_sub_pos_for_source
= -1;
1737 mpctx
->global_sub_pos
= -1;
1739 if (mpctx
->global_sub_pos
== -1) {
1741 mpctx
->global_sub_pos
= offset
;
1742 else if (max_sub_pos_for_source
== -1) {
1743 // Find max pos for specific source
1744 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1745 while (mpctx
->global_sub_pos
>= 0
1746 && sub_source(mpctx
) != source
)
1747 --mpctx
->global_sub_pos
;
1750 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1753 mpctx
->global_sub_pos
+= step
;
1754 if (mpctx
->global_sub_pos
< offset
||
1755 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1756 sub_source(mpctx
) != source
)
1757 mpctx
->global_sub_pos
= -1;
1764 return M_PROPERTY_NOT_IMPLEMENTED
;
1766 --mpctx
->global_sub_pos
;
1767 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1770 /// Subtitle delay (RW)
1771 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1774 if (!mpctx
->sh_video
)
1775 return M_PROPERTY_UNAVAILABLE
;
1776 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1779 /// Alignment of text subtitles (RW)
1780 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1781 void *arg
, MPContext
*mpctx
)
1783 char *name
[] = { _("top"), _("center"), _("bottom") };
1785 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1786 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1787 return M_PROPERTY_UNAVAILABLE
;
1790 case M_PROPERTY_PRINT
:
1792 return M_PROPERTY_ERROR
;
1793 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1794 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1795 return M_PROPERTY_OK
;
1796 case M_PROPERTY_SET
:
1798 return M_PROPERTY_ERROR
;
1799 case M_PROPERTY_STEP_UP
:
1800 case M_PROPERTY_STEP_DOWN
:
1801 vo_osd_changed(OSDTYPE_SUBTITLE
);
1803 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1807 /// Subtitle visibility (RW)
1808 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1809 void *arg
, MPContext
*mpctx
)
1811 if (!mpctx
->sh_video
)
1812 return M_PROPERTY_UNAVAILABLE
;
1815 case M_PROPERTY_SET
:
1817 return M_PROPERTY_ERROR
;
1818 case M_PROPERTY_STEP_UP
:
1819 case M_PROPERTY_STEP_DOWN
:
1820 vo_osd_changed(OSDTYPE_SUBTITLE
);
1822 vo_osd_changed(OSDTYPE_SPU
);
1824 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1829 /// Use margins for libass subtitles (RW)
1830 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1831 void *arg
, MPContext
*mpctx
)
1833 if (!mpctx
->sh_video
)
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 ass_force_reload
= 1;
1844 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1849 /// Show only forced subtitles (RW)
1850 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1851 void *arg
, MPContext
*mpctx
)
1854 return M_PROPERTY_UNAVAILABLE
;
1857 case M_PROPERTY_SET
:
1859 return M_PROPERTY_ERROR
;
1860 case M_PROPERTY_STEP_UP
:
1861 case M_PROPERTY_STEP_DOWN
:
1862 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1863 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1864 return M_PROPERTY_OK
;
1866 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1871 #ifdef CONFIG_FREETYPE
1872 /// Subtitle scale (RW)
1873 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1876 struct MPOpts
*opts
= &mpctx
->opts
;
1879 case M_PROPERTY_SET
:
1881 return M_PROPERTY_ERROR
;
1882 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1884 if (opts
->ass_enabled
) {
1885 ass_font_scale
= *(float *) arg
;
1886 ass_force_reload
= 1;
1889 text_font_scale_factor
= *(float *) arg
;
1890 force_load_font
= 1;
1891 return M_PROPERTY_OK
;
1892 case M_PROPERTY_STEP_UP
:
1893 case M_PROPERTY_STEP_DOWN
:
1895 if (opts
->ass_enabled
) {
1896 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1897 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1898 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1899 ass_force_reload
= 1;
1902 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1903 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1904 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1905 force_load_font
= 1;
1906 return M_PROPERTY_OK
;
1909 if (opts
->ass_enabled
)
1910 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1913 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1920 /// \defgroup TVProperties TV properties
1921 /// \ingroup Properties
1926 /// TV color settings (RW)
1927 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1931 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1932 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1933 return M_PROPERTY_UNAVAILABLE
;
1936 case M_PROPERTY_SET
:
1938 return M_PROPERTY_ERROR
;
1939 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1940 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1941 case M_PROPERTY_GET
:
1942 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1943 case M_PROPERTY_STEP_UP
:
1944 case M_PROPERTY_STEP_DOWN
:
1945 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1947 return M_PROPERTY_ERROR
;
1948 val
+= (arg
? *(int *) arg
: 1) *
1949 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1950 M_PROPERTY_CLAMP(prop
, val
);
1951 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1953 return M_PROPERTY_ERROR
;
1955 return M_PROPERTY_NOT_IMPLEMENTED
;
1960 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1964 int base_ioctl
=(int)prop
->priv
;
1966 for teletext's GET,SET,STEP ioctls this is not 0
1970 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1971 return M_PROPERTY_UNAVAILABLE
;
1973 return M_PROPERTY_ERROR
;
1976 case M_PROPERTY_GET
:
1978 return M_PROPERTY_ERROR
;
1979 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1981 case M_PROPERTY_SET
:
1983 return M_PROPERTY_ERROR
;
1984 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1985 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1987 case M_PROPERTY_STEP_UP
:
1988 case M_PROPERTY_STEP_DOWN
:
1989 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1990 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1991 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
1994 return M_PROPERTY_NOT_IMPLEMENTED
;
1997 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2000 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2006 //with tvh==NULL will fail too
2007 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2008 if(result
!=M_PROPERTY_OK
)
2011 if(teletext_control(mpctx
->demuxer
->teletext
,
2012 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
2013 mp_input_set_section(mpctx
->input
, "teletext");
2015 mp_input_set_section(mpctx
->input
, "tv");
2016 return M_PROPERTY_OK
;
2019 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2024 if (!mpctx
->demuxer
->teletext
)
2025 return M_PROPERTY_UNAVAILABLE
;
2027 case M_PROPERTY_STEP_UP
:
2028 case M_PROPERTY_STEP_DOWN
:
2029 //This should be handled separately
2030 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2031 result
=teletext_control(mpctx
->demuxer
->teletext
,
2032 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2035 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2042 /// All properties available in MPlayer.
2043 /** \ingroup Properties
2045 static const m_option_t mp_properties
[] = {
2047 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2048 M_OPT_RANGE
, 0, 3, NULL
},
2049 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2050 M_OPT_MIN
, -1, 0, NULL
},
2051 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2052 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2053 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2055 { "path", mp_property_path
, CONF_TYPE_STRING
,
2057 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2059 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2060 M_OPT_MIN
, 0, 0, NULL
},
2061 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2062 M_OPT_MIN
, 0, 0, NULL
},
2063 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2064 M_OPT_MIN
, 0, 0, NULL
},
2065 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2066 M_OPT_MIN
, 0, 0, NULL
},
2067 { "length", mp_property_length
, CONF_TYPE_TIME
,
2068 M_OPT_MIN
, 0, 0, NULL
},
2069 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2070 M_OPT_RANGE
, 0, 100, NULL
},
2071 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2072 M_OPT_MIN
, 0, 0, NULL
},
2073 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2074 M_OPT_MIN
, 0, 0, NULL
},
2075 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2077 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2078 CONF_RANGE
, -2, 10, NULL
},
2079 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2081 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2082 M_OPT_RANGE
, 0, 1, NULL
},
2085 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2086 M_OPT_RANGE
, 0, 100, NULL
},
2087 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2088 M_OPT_RANGE
, 0, 1, NULL
},
2089 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2090 M_OPT_RANGE
, -100, 100, NULL
},
2091 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2093 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2095 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2097 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2099 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2101 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2102 CONF_RANGE
, -2, 65535, NULL
},
2103 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2104 M_OPT_RANGE
, -1, 1, NULL
},
2107 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2108 M_OPT_RANGE
, 0, 1, NULL
},
2109 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2110 M_OPT_RANGE
, 0, 1, NULL
},
2111 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2112 M_OPT_RANGE
, 0, 2, NULL
},
2113 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2114 M_OPT_RANGE
, 0, 1, NULL
},
2115 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2116 M_OPT_RANGE
, 0, 1, NULL
},
2117 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2118 M_OPT_RANGE
, 0, 1, NULL
},
2119 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2120 M_OPT_RANGE
, 0, 2, NULL
},
2121 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2122 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2123 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2124 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2125 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2126 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2127 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2128 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2129 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2130 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2131 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2132 M_OPT_RANGE
, 0, 1, NULL
},
2133 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2134 M_OPT_RANGE
, 0, 1, NULL
},
2135 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2137 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2139 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2141 { "width", mp_property_width
, CONF_TYPE_INT
,
2143 { "height", mp_property_height
, CONF_TYPE_INT
,
2145 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2147 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2149 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2150 CONF_RANGE
, -2, 65535, NULL
},
2151 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2152 CONF_RANGE
, -1, 65535, NULL
},
2155 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2156 M_OPT_MIN
, -1, 0, NULL
},
2157 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2158 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2159 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2160 M_OPT_MIN
, -1, 0, NULL
},
2161 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2162 M_OPT_MIN
, -1, 0, NULL
},
2163 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2164 M_OPT_MIN
, -1, 0, NULL
},
2165 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2167 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2168 M_OPT_RANGE
, 0, 100, NULL
},
2169 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2170 M_OPT_RANGE
, 0, 2, NULL
},
2171 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2172 M_OPT_RANGE
, 0, 1, NULL
},
2173 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2174 M_OPT_RANGE
, 0, 1, NULL
},
2175 #ifdef CONFIG_FREETYPE
2176 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2177 M_OPT_RANGE
, 0, 100, NULL
},
2180 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2181 M_OPT_RANGE
, 0, 1, NULL
},
2185 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2186 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2187 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2188 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2189 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2190 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2191 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2192 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2194 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2195 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2196 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2197 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2198 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2199 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2200 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2201 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2202 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2203 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2204 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2208 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2210 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2213 char* mp_property_print(const char *name
, void* ctx
)
2216 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2221 char *property_expand_string(MPContext
*mpctx
, char *str
)
2223 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2226 void property_print_help(void)
2228 m_properties_print_help_list(mp_properties
);
2232 /* List of default ways to show a property on OSD.
2234 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2235 * a bar showing the current position between min/max values of the
2236 * property. In this case osd_msg is only used for terminal output
2237 * if there is no video; it'll be a label shown together with percentage.
2239 * Otherwise setting osd_msg will show the string on OSD, formatted with
2240 * the text value of the property as argument.
2242 static struct property_osd_display
{
2245 /// progressbar type
2246 int osd_progbar
; // -1 is special value for seek indicators
2247 /// osd msg id if it must be shared
2249 /// osd msg template
2250 const char *osd_msg
;
2251 } property_osd_display
[] = {
2253 { "loop", 0, -1, _("Loop: %s") },
2254 { "chapter", -1, -1, NULL
},
2256 { "volume", OSD_VOLUME
, -1, _("Volume") },
2257 { "mute", 0, -1, _("Mute: %s") },
2258 { "audio_delay", 0, -1, _("A-V delay: %s") },
2259 { "switch_audio", 0, -1, _("Audio: %s") },
2260 { "balance", OSD_BALANCE
, -1, _("Balance") },
2262 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2263 { "ontop", 0, -1, _("Stay on top: %s") },
2264 { "rootwin", 0, -1, _("Rootwin: %s") },
2265 { "border", 0, -1, _("Border: %s") },
2266 { "framedropping", 0, -1, _("Framedropping: %s") },
2267 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2268 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2269 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2270 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2271 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2272 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2273 { "hue", OSD_HUE
, -1, _("Hue") },
2274 { "vsync", 0, -1, _("VSync: %s") },
2276 { "sub", 0, -1, _("Subtitles: %s") },
2277 { "sub_source", 0, -1, _("Sub source: %s") },
2278 { "sub_vob", 0, -1, _("Subtitles: %s") },
2279 { "sub_demux", 0, -1, _("Subtitles: %s") },
2280 { "sub_file", 0, -1, _("Subtitles: %s") },
2281 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2282 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2283 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2284 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2285 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2286 #ifdef CONFIG_FREETYPE
2287 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2290 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2291 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2292 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2293 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2298 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2300 struct MPOpts
*opts
= &mpctx
->opts
;
2303 struct property_osd_display
*p
;
2305 // look for the command
2306 for (p
= property_osd_display
; p
->name
; p
++)
2307 if (!strcmp(p
->name
, pname
))
2312 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2315 if (p
->osd_progbar
== -1)
2316 mpctx
->add_osd_seek_info
= true;
2317 else if (p
->osd_progbar
) {
2318 if (prop
->type
== CONF_TYPE_INT
) {
2319 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2320 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2321 prop
->min
, prop
->max
, r
);
2322 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2324 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2325 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2326 prop
->min
, prop
->max
, f
);
2328 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2329 "Property use an unsupported type.\n");
2336 char *val
= mp_property_print(pname
, mpctx
);
2338 int index
= p
- property_osd_display
;
2339 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2340 1, opts
->osd_duration
, p
->osd_msg
, val
);
2349 * \defgroup Command2Property Command to property bridge
2351 * It is used to handle most commands that just set a property
2352 * and optionally display something on the OSD.
2353 * Two kinds of commands are handled: adjust or toggle.
2355 * Adjust commands take 1 or 2 parameters: <value> <abs>
2356 * If <abs> is non-zero the property is set to the given value
2357 * otherwise it is adjusted.
2359 * Toggle commands take 0 or 1 parameters. With no parameter
2360 * or a value less than the property minimum it just steps the
2361 * property to its next value. Otherwise it sets it to the given
2367 /// List of the commands that can be handled by setting a property.
2373 /// set/adjust or toggle command
2375 } set_prop_cmd
[] = {
2377 { "loop", MP_CMD_LOOP
, 0},
2378 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2379 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2380 { "pause", MP_CMD_PAUSE
, 0},
2382 { "volume", MP_CMD_VOLUME
, 0},
2383 { "mute", MP_CMD_MUTE
, 1},
2384 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2385 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2386 { "balance", MP_CMD_BALANCE
, 0},
2388 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2389 { "panscan", MP_CMD_PANSCAN
, 0},
2390 { "ontop", MP_CMD_VO_ONTOP
, 1},
2391 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2392 { "border", MP_CMD_VO_BORDER
, 1},
2393 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2394 { "gamma", MP_CMD_GAMMA
, 0},
2395 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2396 { "contrast", MP_CMD_CONTRAST
, 0},
2397 { "saturation", MP_CMD_SATURATION
, 0},
2398 { "hue", MP_CMD_HUE
, 0},
2399 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2401 { "sub", MP_CMD_SUB_SELECT
, 1},
2402 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2403 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2404 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2405 { "sub_file", MP_CMD_SUB_FILE
, 1},
2406 { "sub_pos", MP_CMD_SUB_POS
, 0},
2407 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2408 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2409 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2410 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2411 #ifdef CONFIG_FREETYPE
2412 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2415 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2418 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2419 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2420 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2421 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2426 /// Handle commands that set a property.
2427 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2433 // look for the command
2434 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2435 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2437 if (!(pname
= set_prop_cmd
[i
].name
))
2440 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2444 if (set_prop_cmd
[i
].toggle
) {
2446 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2447 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2449 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2450 } else if (cmd
->args
[1].v
.i
) //set
2451 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2453 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2458 show_property_osd(mpctx
, pname
);
2463 #ifdef CONFIG_DVDNAV
2464 static const struct {
2466 const mp_command_type cmd
;
2467 } mp_dvdnav_bindings
[] = {
2468 { "up", MP_CMD_DVDNAV_UP
},
2469 { "down", MP_CMD_DVDNAV_DOWN
},
2470 { "left", MP_CMD_DVDNAV_LEFT
},
2471 { "right", MP_CMD_DVDNAV_RIGHT
},
2472 { "menu", MP_CMD_DVDNAV_MENU
},
2473 { "select", MP_CMD_DVDNAV_SELECT
},
2474 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2475 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2478 * keep old dvdnav sub-command options for a while in order not to
2479 * break slave-mode API too suddenly.
2481 { "1", MP_CMD_DVDNAV_UP
},
2482 { "2", MP_CMD_DVDNAV_DOWN
},
2483 { "3", MP_CMD_DVDNAV_LEFT
},
2484 { "4", MP_CMD_DVDNAV_RIGHT
},
2485 { "5", MP_CMD_DVDNAV_MENU
},
2486 { "6", MP_CMD_DVDNAV_SELECT
},
2487 { "7", MP_CMD_DVDNAV_PREVMENU
},
2488 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2493 static const char *property_error_string(int error_value
)
2495 switch (error_value
) {
2496 case M_PROPERTY_ERROR
:
2498 case M_PROPERTY_UNAVAILABLE
:
2499 return "PROPERTY_UNAVAILABLE";
2500 case M_PROPERTY_NOT_IMPLEMENTED
:
2501 return "NOT_IMPLEMENTED";
2502 case M_PROPERTY_UNKNOWN
:
2503 return "PROPERTY_UNKNOWN";
2504 case M_PROPERTY_DISABLED
:
2510 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2513 int end
= start
+ count
;
2514 int after
= mpctx
->set_of_sub_size
- end
;
2515 sub_data
**subs
= mpctx
->set_of_subtitles
;
2517 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2519 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2520 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2521 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2522 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2525 for (idx
= start
; idx
< end
; idx
++) {
2526 sub_data
*subd
= subs
[idx
];
2527 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2528 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2529 filename_recode(subd
->filename
));
2533 if (ass_tracks
[idx
])
2534 ass_free_track(ass_tracks
[idx
]);
2535 ass_tracks
[idx
] = NULL
;
2539 mpctx
->global_sub_size
-= count
;
2540 mpctx
->set_of_sub_size
-= count
;
2541 if (mpctx
->set_of_sub_size
<= 0)
2542 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2544 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2545 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2547 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2548 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2551 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2552 mpctx
->global_sub_pos
= -2;
2557 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2558 } else if (mpctx
->set_of_sub_pos
>= end
) {
2559 mpctx
->set_of_sub_pos
-= count
;
2560 mpctx
->global_sub_pos
-= count
;
2564 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2566 struct MPOpts
*opts
= &mpctx
->opts
;
2567 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2568 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2569 int osd_duration
= opts
->osd_duration
;
2570 int case_fallthrough_hack
= 0;
2571 if (!set_property_command(mpctx
, cmd
))
2576 mpctx
->add_osd_seek_info
= true;
2577 v
= cmd
->args
[0].v
.f
;
2578 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2579 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2580 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2582 mpctx
->osd_function
=
2583 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2584 mpctx
->rel_seek_secs
= v
;
2585 } else if (abs
) { /* Absolute seek by percentage */
2586 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2588 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2589 mpctx
->rel_seek_secs
= v
/ 100.0;
2591 mpctx
->rel_seek_secs
+= v
;
2592 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2597 case MP_CMD_SET_PROPERTY_OSD
:
2598 case_fallthrough_hack
= 1;
2600 case MP_CMD_SET_PROPERTY
:{
2601 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2602 cmd
->args
[1].v
.s
, mpctx
);
2603 if (r
== M_PROPERTY_UNKNOWN
)
2604 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2605 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2607 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2608 "Failed to set property '%s' to '%s'.\n",
2609 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2610 else if (case_fallthrough_hack
)
2611 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2613 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2617 case MP_CMD_STEP_PROPERTY_OSD
:
2618 case_fallthrough_hack
= 1;
2620 case MP_CMD_STEP_PROPERTY
:{
2625 if (cmd
->args
[1].v
.f
) {
2627 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2628 M_PROPERTY_GET_TYPE
,
2629 &prop
, mpctx
)) <= 0)
2631 if(prop
->type
== CONF_TYPE_INT
||
2632 prop
->type
== CONF_TYPE_FLAG
)
2633 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2634 else if(prop
->type
== CONF_TYPE_FLOAT
)
2635 arg
= &cmd
->args
[1].v
.f
;
2636 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2637 prop
->type
== CONF_TYPE_TIME
)
2638 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2639 else if(prop
->type
== CONF_TYPE_POSITION
)
2640 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2642 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2643 "Ignoring step size stepping property '%s'.\n",
2646 r
= mp_property_do(cmd
->args
[0].v
.s
,
2647 cmd
->args
[2].v
.i
< 0 ?
2648 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2651 if (r
== M_PROPERTY_UNKNOWN
)
2652 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2653 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2655 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2656 "Failed to increment property '%s' by %f.\n",
2657 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2658 else if (case_fallthrough_hack
)
2659 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2661 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2665 case MP_CMD_GET_PROPERTY
:{
2667 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2670 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2671 "Failed to get value of property '%s'.\n",
2673 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2676 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2677 cmd
->args
[0].v
.s
, tmp
);
2682 case MP_CMD_EDL_MARK
:
2684 float v
= sh_video
? sh_video
->pts
:
2685 playing_audio_pts(mpctx
);
2686 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2687 mpctx
->begin_skip
= v
;
2688 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2690 if (mpctx
->begin_skip
> v
)
2691 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2693 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2694 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2696 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2701 case MP_CMD_SWITCH_RATIO
:
2704 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2705 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2707 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2708 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2711 case MP_CMD_SPEED_INCR
:{
2712 float v
= cmd
->args
[0].v
.f
;
2713 opts
->playback_speed
+= v
;
2714 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2715 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2716 opts
->playback_speed
);
2719 case MP_CMD_SPEED_MULT
:{
2720 float v
= cmd
->args
[0].v
.f
;
2721 opts
->playback_speed
*= v
;
2722 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2723 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2724 opts
->playback_speed
);
2727 case MP_CMD_SPEED_SET
:{
2728 float v
= cmd
->args
[0].v
.f
;
2729 opts
->playback_speed
= v
;
2730 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2731 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2732 opts
->playback_speed
);
2735 case MP_CMD_FRAME_STEP
:
2736 add_step_frame(mpctx
);
2739 case MP_CMD_FILE_FILTER
:
2740 file_filter
= cmd
->args
[0].v
.i
;
2744 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2745 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2747 case MP_CMD_PLAY_TREE_STEP
:{
2748 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2749 int force
= cmd
->args
[1].v
.i
;
2752 if (!force
&& mpctx
->playtree_iter
) {
2753 play_tree_iter_t
*i
=
2754 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2755 if (play_tree_iter_step(i
, n
, 0) ==
2756 PLAY_TREE_ITER_ENTRY
)
2758 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2759 play_tree_iter_free(i
);
2761 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2762 if (mpctx
->stop_play
)
2763 mpctx
->play_tree_step
= n
;
2768 case MP_CMD_PLAY_TREE_UP_STEP
:{
2769 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2770 int force
= cmd
->args
[1].v
.i
;
2772 if (!force
&& mpctx
->playtree_iter
) {
2773 play_tree_iter_t
*i
=
2774 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2775 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2776 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2777 play_tree_iter_free(i
);
2779 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2783 case MP_CMD_PLAY_ALT_SRC_STEP
:
2784 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2785 int v
= cmd
->args
[0].v
.i
;
2787 && mpctx
->playtree_iter
->file
<
2788 mpctx
->playtree_iter
->num_files
)
2789 mpctx
->stop_play
= PT_NEXT_SRC
;
2790 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2791 mpctx
->stop_play
= PT_PREV_SRC
;
2795 case MP_CMD_SUB_STEP
:
2797 int movement
= cmd
->args
[0].v
.i
;
2798 step_sub(subdata
, sh_video
->pts
, movement
);
2802 ass_step_sub(ass_track
,
2804 sub_delay
) * 1000 + .5, movement
) / 1000.;
2806 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2807 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2811 case MP_CMD_SUB_LOG
:
2816 int v
= cmd
->args
[0].v
.i
;
2818 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2819 if (opts
->osd_level
> max
)
2820 opts
->osd_level
= max
;
2822 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2824 opts
->osd_level
= v
> max
? max
: v
;
2825 /* Show OSD state when disabled, but not when an explicit
2826 argument is given to the OSD command, i.e. in slave mode. */
2827 if (v
== -1 && opts
->osd_level
<= 1)
2828 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2830 opts
->osd_level
? mp_gtext("enabled") :
2831 mp_gtext("disabled"));
2833 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2837 case MP_CMD_OSD_SHOW_TEXT
:
2838 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2840 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2841 "%-.63s", cmd
->args
[0].v
.s
);
2844 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2845 char *txt
= m_properties_expand_string(mp_properties
,
2848 /* if no argument supplied take default osd_duration, else <arg> ms. */
2850 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2852 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2859 case MP_CMD_LOADFILE
:{
2860 play_tree_t
*e
= play_tree_new();
2861 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2863 if (cmd
->args
[1].v
.i
) // append
2864 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2866 // Go back to the starting point.
2867 while (play_tree_iter_up_step
2868 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2870 play_tree_free_list(mpctx
->playtree
->child
, 1);
2871 play_tree_set_child(mpctx
->playtree
, e
);
2872 pt_iter_goto_head(mpctx
->playtree_iter
);
2873 mpctx
->stop_play
= PT_NEXT_SRC
;
2878 case MP_CMD_LOADLIST
:{
2879 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2881 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2882 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2884 if (cmd
->args
[1].v
.i
) // append
2885 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2887 // Go back to the starting point.
2888 while (play_tree_iter_up_step
2889 (mpctx
->playtree_iter
, 0, 1)
2890 != PLAY_TREE_ITER_END
)
2892 play_tree_free_list(mpctx
->playtree
->child
, 1);
2893 play_tree_set_child(mpctx
->playtree
, e
);
2894 pt_iter_goto_head(mpctx
->playtree_iter
);
2895 mpctx
->stop_play
= PT_NEXT_SRC
;
2902 // Go back to the starting point.
2903 while (play_tree_iter_up_step
2904 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2906 mpctx
->stop_play
= PT_STOP
;
2910 case MP_CMD_RADIO_STEP_CHANNEL
:
2911 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2912 int v
= cmd
->args
[0].v
.i
;
2914 radio_step_channel(mpctx
->demuxer
->stream
,
2915 RADIO_CHANNEL_HIGHER
);
2917 radio_step_channel(mpctx
->demuxer
->stream
,
2918 RADIO_CHANNEL_LOWER
);
2919 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2920 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2922 radio_get_channel_name(mpctx
->demuxer
->stream
));
2927 case MP_CMD_RADIO_SET_CHANNEL
:
2928 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2929 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2930 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2931 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2933 radio_get_channel_name(mpctx
->demuxer
->stream
));
2938 case MP_CMD_RADIO_SET_FREQ
:
2939 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2940 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2943 case MP_CMD_RADIO_STEP_FREQ
:
2944 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2945 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2950 case MP_CMD_TV_START_SCAN
:
2951 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2952 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2954 case MP_CMD_TV_SET_FREQ
:
2955 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2956 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2957 cmd
->args
[0].v
.f
* 16.0);
2959 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2960 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2961 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2962 pvr_get_current_channelname (mpctx
->stream
),
2963 pvr_get_current_stationname (mpctx
->stream
));
2965 #endif /* CONFIG_PVR */
2968 case MP_CMD_TV_STEP_FREQ
:
2969 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2970 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2971 cmd
->args
[0].v
.f
* 16.0);
2973 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2974 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2975 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2976 pvr_get_current_channelname (mpctx
->stream
),
2977 pvr_get_current_frequency (mpctx
->stream
));
2979 #endif /* CONFIG_PVR */
2982 case MP_CMD_TV_SET_NORM
:
2983 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2984 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2988 case MP_CMD_TV_STEP_CHANNEL
:{
2989 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2990 int v
= cmd
->args
[0].v
.i
;
2992 tv_step_channel((tvi_handle_t
*) (mpctx
->
2996 tv_step_channel((tvi_handle_t
*) (mpctx
->
3000 if (tv_channel_list
) {
3001 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3002 "Channel: %s", tv_channel_current
->name
);
3003 //vo_osd_changed(OSDTYPE_SUBTITLE);
3007 else if (mpctx
->stream
&&
3008 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3009 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3010 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3011 pvr_get_current_channelname (mpctx
->stream
),
3012 pvr_get_current_stationname (mpctx
->stream
));
3014 #endif /* CONFIG_PVR */
3017 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3019 int v
= cmd
->args
[0].v
.i
;
3021 mpctx
->last_dvb_step
= v
;
3023 dir
= DVB_CHANNEL_HIGHER
;
3025 dir
= DVB_CHANNEL_LOWER
;
3028 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3029 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3030 mpctx
->dvbin_reopen
= 1;
3033 #endif /* CONFIG_DVBIN */
3036 case MP_CMD_TV_SET_CHANNEL
:
3037 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3038 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3040 if (tv_channel_list
) {
3041 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3042 "Channel: %s", tv_channel_current
->name
);
3043 //vo_osd_changed(OSDTYPE_SUBTITLE);
3047 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3048 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3049 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3050 pvr_get_current_channelname (mpctx
->stream
),
3051 pvr_get_current_stationname (mpctx
->stream
));
3053 #endif /* CONFIG_PVR */
3057 case MP_CMD_DVB_SET_CHANNEL
:
3058 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3059 mpctx
->last_dvb_step
= 1;
3061 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3062 cmd
->args
[0].v
.i
)) {
3063 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3064 mpctx
->dvbin_reopen
= 1;
3068 #endif /* CONFIG_DVBIN */
3070 case MP_CMD_TV_LAST_CHANNEL
:
3071 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3072 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3073 if (tv_channel_list
) {
3074 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3075 "Channel: %s", tv_channel_current
->name
);
3076 //vo_osd_changed(OSDTYPE_SUBTITLE);
3080 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3081 pvr_set_lastchannel (mpctx
->stream
);
3082 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3083 pvr_get_current_channelname (mpctx
->stream
),
3084 pvr_get_current_stationname (mpctx
->stream
));
3086 #endif /* CONFIG_PVR */
3089 case MP_CMD_TV_STEP_NORM
:
3090 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3091 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3094 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3095 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3096 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3098 #endif /* CONFIG_TV */
3099 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3101 if (mpctx
->demuxer
->teletext
)
3102 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3103 &(cmd
->args
[0].v
.s
));
3106 case MP_CMD_TV_TELETEXT_GO_LINK
:
3108 if (mpctx
->demuxer
->teletext
)
3109 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3110 &(cmd
->args
[0].v
.i
));
3114 case MP_CMD_SUB_LOAD
:
3116 int n
= mpctx
->set_of_sub_size
;
3117 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3118 if (n
!= mpctx
->set_of_sub_size
) {
3119 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
3120 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
3121 mpctx
->global_sub_size
;
3122 ++mpctx
->global_sub_size
;
3127 case MP_CMD_SUB_REMOVE
:
3129 int v
= cmd
->args
[0].v
.i
;
3131 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3132 } else if (v
< mpctx
->set_of_sub_size
) {
3133 remove_subtitle_range(mpctx
, v
, 1);
3138 case MP_CMD_GET_SUB_VISIBILITY
:
3140 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3141 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3145 case MP_CMD_SCREENSHOT
:
3146 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3147 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3149 ((vf_instance_t
*) sh_video
->vfilter
)->
3150 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3152 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3156 case MP_CMD_AF_EQ_SET
:{
3157 af_instance_t
* m1
=af_get(sh_audio
->afilter
, "equalizer");
3158 if (m1
) m1
->control( m1
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[0].v
.s
);
3159 else mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -af equalizer=0:0 ?)\n");
3163 case MP_CMD_VF_CHANGE_RECTANGLE
:
3166 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3169 case MP_CMD_GET_TIME_LENGTH
:{
3170 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3171 demuxer_get_time_length(mpctx
->demuxer
));
3175 case MP_CMD_GET_FILENAME
:{
3176 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3177 get_metadata(mpctx
, META_NAME
));
3181 case MP_CMD_GET_VIDEO_CODEC
:{
3182 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3185 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3190 case MP_CMD_GET_VIDEO_BITRATE
:{
3191 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3194 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3199 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3200 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3203 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3204 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3209 case MP_CMD_GET_AUDIO_CODEC
:{
3210 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3213 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3218 case MP_CMD_GET_AUDIO_BITRATE
:{
3219 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3222 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3227 case MP_CMD_GET_AUDIO_SAMPLES
:{
3228 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3231 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3236 case MP_CMD_GET_META_TITLE
:{
3237 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3240 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3245 case MP_CMD_GET_META_ARTIST
:{
3246 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3249 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3254 case MP_CMD_GET_META_ALBUM
:{
3255 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3258 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3263 case MP_CMD_GET_META_YEAR
:{
3264 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3267 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3272 case MP_CMD_GET_META_COMMENT
:{
3273 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3276 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3281 case MP_CMD_GET_META_TRACK
:{
3282 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3285 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3290 case MP_CMD_GET_META_GENRE
:{
3291 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3294 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3299 case MP_CMD_GET_VO_FULLSCREEN
:
3300 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3301 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3304 case MP_CMD_GET_PERCENT_POS
:
3305 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3306 demuxer_get_percent_pos(mpctx
->demuxer
));
3309 case MP_CMD_GET_TIME_POS
:{
3312 pos
= sh_video
->pts
;
3313 else if (sh_audio
&& mpctx
->audio_out
)
3314 pos
= playing_audio_pts(mpctx
);
3315 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3322 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3328 case MP_CMD_KEYDOWN_EVENTS
:
3329 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3332 case MP_CMD_SET_MOUSE_POS
:{
3333 int pointer_x
, pointer_y
;
3335 pointer_x
= cmd
->args
[0].v
.i
;
3336 pointer_y
= cmd
->args
[1].v
.i
;
3337 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3338 #ifdef CONFIG_DVDNAV
3339 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3340 && dx
> 0.0 && dy
> 0.0) {
3342 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3343 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3344 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3345 pointer_x
, pointer_y
, &button
);
3346 if (opts
->osd_level
> 1 && button
> 0)
3347 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3348 "Selected button number %d", button
);
3352 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3353 menu_update_mouse_pos(dx
, dy
);
3358 #ifdef CONFIG_DVDNAV
3359 case MP_CMD_DVDNAV
:{
3362 mp_command_type command
= 0;
3363 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3366 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3367 if (cmd
->args
[0].v
.s
&&
3368 !strcasecmp (cmd
->args
[0].v
.s
,
3369 mp_dvdnav_bindings
[i
].name
))
3370 command
= mp_dvdnav_bindings
[i
].cmd
;
3372 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3373 if (opts
->osd_level
> 1 && button
> 0)
3374 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3375 "Selected button number %d", button
);
3379 case MP_CMD_SWITCH_TITLE
:
3380 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3381 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3387 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3388 "Received unknown cmd %s\n", cmd
->name
);
3391 switch (cmd
->pausing
) {
3392 case 1: // "pausing"
3393 pause_player(mpctx
);
3395 case 3: // "pausing_toggle"
3397 unpause_player(mpctx
);
3399 pause_player(mpctx
);