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_audio.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
);
528 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
530 resync_video_stream(sh_video
);
532 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
534 resync_audio_stream(sh_audio
);
537 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
538 "Angle: %d/%d", angle
, angles
);
541 return M_PROPERTY_OK
;
544 /// Demuxer meta data
545 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
547 m_property_action_t
* ka
;
549 static const m_option_t key_type
=
550 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
552 return M_PROPERTY_UNAVAILABLE
;
556 if(!arg
) return M_PROPERTY_ERROR
;
557 *(char***)arg
= mpctx
->demuxer
->info
;
558 return M_PROPERTY_OK
;
559 case M_PROPERTY_KEY_ACTION
:
560 if(!arg
) return M_PROPERTY_ERROR
;
562 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
563 return M_PROPERTY_UNKNOWN
;
566 if(!ka
->arg
) return M_PROPERTY_ERROR
;
567 *(char**)ka
->arg
= meta
;
568 return M_PROPERTY_OK
;
569 case M_PROPERTY_GET_TYPE
:
570 if(!ka
->arg
) return M_PROPERTY_ERROR
;
571 *(m_option_t
**)ka
->arg
= &key_type
;
572 return M_PROPERTY_OK
;
575 return M_PROPERTY_NOT_IMPLEMENTED
;
578 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
581 MPContext
*mpctx
= ctx
;
586 return M_PROPERTY_ERROR
;
587 if (mpctx
->paused
== (bool)*(int *) arg
)
588 return M_PROPERTY_OK
;
589 case M_PROPERTY_STEP_UP
:
590 case M_PROPERTY_STEP_DOWN
:
592 unpause_player(mpctx
);
593 mpctx
->osd_function
= OSD_PLAY
;
597 mpctx
->osd_function
= OSD_PAUSE
;
599 return M_PROPERTY_OK
;
601 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
608 /// \defgroup AudioProperties Audio properties
609 /// \ingroup Properties
613 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
617 if (!mpctx
->sh_audio
)
618 return M_PROPERTY_UNAVAILABLE
;
623 return M_PROPERTY_ERROR
;
624 mixer_getbothvolume(&mpctx
->mixer
, arg
);
625 return M_PROPERTY_OK
;
626 case M_PROPERTY_PRINT
:{
629 return M_PROPERTY_ERROR
;
630 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
631 return m_property_float_range(prop
, action
, arg
, &vol
);
633 case M_PROPERTY_STEP_UP
:
634 case M_PROPERTY_STEP_DOWN
:
638 return M_PROPERTY_NOT_IMPLEMENTED
;
641 if (mpctx
->edl_muted
)
642 return M_PROPERTY_DISABLED
;
643 mpctx
->user_muted
= 0;
648 return M_PROPERTY_ERROR
;
649 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
650 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
651 return M_PROPERTY_OK
;
652 case M_PROPERTY_STEP_UP
:
653 if (arg
&& *(float *) arg
<= 0)
654 mixer_decvolume(&mpctx
->mixer
);
656 mixer_incvolume(&mpctx
->mixer
);
657 return M_PROPERTY_OK
;
658 case M_PROPERTY_STEP_DOWN
:
659 if (arg
&& *(float *) arg
<= 0)
660 mixer_incvolume(&mpctx
->mixer
);
662 mixer_decvolume(&mpctx
->mixer
);
663 return M_PROPERTY_OK
;
665 return M_PROPERTY_NOT_IMPLEMENTED
;
669 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
673 if (!mpctx
->sh_audio
)
674 return M_PROPERTY_UNAVAILABLE
;
678 if (mpctx
->edl_muted
)
679 return M_PROPERTY_DISABLED
;
681 return M_PROPERTY_ERROR
;
682 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
683 mixer_mute(&mpctx
->mixer
);
684 mpctx
->user_muted
= mpctx
->mixer
.muted
;
685 return M_PROPERTY_OK
;
686 case M_PROPERTY_STEP_UP
:
687 case M_PROPERTY_STEP_DOWN
:
688 if (mpctx
->edl_muted
)
689 return M_PROPERTY_DISABLED
;
690 mixer_mute(&mpctx
->mixer
);
691 mpctx
->user_muted
= mpctx
->mixer
.muted
;
692 return M_PROPERTY_OK
;
693 case M_PROPERTY_PRINT
:
695 return M_PROPERTY_ERROR
;
696 if (mpctx
->edl_muted
) {
697 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
698 return M_PROPERTY_OK
;
701 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
707 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
708 void *arg
, MPContext
*mpctx
)
710 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
711 return M_PROPERTY_UNAVAILABLE
;
714 case M_PROPERTY_STEP_UP
:
715 case M_PROPERTY_STEP_DOWN
: {
717 float delay
= audio_delay
;
718 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
719 if (ret
!= M_PROPERTY_OK
)
722 mpctx
->delay
-= audio_delay
- delay
;
724 return M_PROPERTY_OK
;
726 return m_property_delay(prop
, action
, arg
, &audio_delay
);
730 /// Audio codec tag (RO)
731 static int mp_property_audio_format(m_option_t
*prop
, int action
,
732 void *arg
, MPContext
*mpctx
)
734 if (!mpctx
->sh_audio
)
735 return M_PROPERTY_UNAVAILABLE
;
736 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
739 /// Audio codec name (RO)
740 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
741 void *arg
, MPContext
*mpctx
)
743 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
744 return M_PROPERTY_UNAVAILABLE
;
745 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
748 /// Audio bitrate (RO)
749 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
750 void *arg
, MPContext
*mpctx
)
752 if (!mpctx
->sh_audio
)
753 return M_PROPERTY_UNAVAILABLE
;
754 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
758 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
761 if (!mpctx
->sh_audio
)
762 return M_PROPERTY_UNAVAILABLE
;
764 case M_PROPERTY_PRINT
:
765 if(!arg
) return M_PROPERTY_ERROR
;
766 *(char**)arg
= malloc(16);
767 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
768 return M_PROPERTY_OK
;
770 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
773 /// Number of channels (RO)
774 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
777 if (!mpctx
->sh_audio
)
778 return M_PROPERTY_UNAVAILABLE
;
780 case M_PROPERTY_PRINT
:
782 return M_PROPERTY_ERROR
;
783 switch (mpctx
->sh_audio
->channels
) {
785 *(char **) arg
= strdup("mono");
788 *(char **) arg
= strdup("stereo");
791 *(char **) arg
= malloc(32);
792 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
794 return M_PROPERTY_OK
;
796 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
800 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
805 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
806 return M_PROPERTY_UNAVAILABLE
;
811 return M_PROPERTY_ERROR
;
812 mixer_getbalance(&mpctx
->mixer
, arg
);
813 return M_PROPERTY_OK
;
814 case M_PROPERTY_PRINT
: {
817 return M_PROPERTY_ERROR
;
818 mixer_getbalance(&mpctx
->mixer
, &bal
);
820 *str
= strdup("center");
821 else if (bal
== -1.f
)
822 *str
= strdup("left only");
824 *str
= strdup("right only");
826 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
827 *str
= malloc(sizeof("left xxx%, right xxx%"));
828 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
830 return M_PROPERTY_OK
;
832 case M_PROPERTY_STEP_UP
:
833 case M_PROPERTY_STEP_DOWN
:
834 mixer_getbalance(&mpctx
->mixer
, &bal
);
835 bal
+= (arg
? *(float*)arg
: .1f
) *
836 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
837 M_PROPERTY_CLAMP(prop
, bal
);
838 mixer_setbalance(&mpctx
->mixer
, bal
);
839 return M_PROPERTY_OK
;
842 return M_PROPERTY_ERROR
;
843 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
844 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
845 return M_PROPERTY_OK
;
847 return M_PROPERTY_NOT_IMPLEMENTED
;
850 /// Selected audio id (RW)
851 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
855 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
856 return M_PROPERTY_UNAVAILABLE
;
857 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
862 return M_PROPERTY_ERROR
;
863 *(int *) arg
= current_id
;
864 return M_PROPERTY_OK
;
865 case M_PROPERTY_PRINT
:
867 return M_PROPERTY_ERROR
;
870 *(char **) arg
= strdup(mp_gtext("disabled"));
873 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
874 sh_audio_t
* sh
= mpctx
->sh_audio
;
876 av_strlcpy(lang
, sh
->lang
, 40);
877 #ifdef CONFIG_DVDREAD
878 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
879 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
889 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
890 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
892 *(char **) arg
= malloc(64);
893 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
895 return M_PROPERTY_OK
;
897 case M_PROPERTY_STEP_UP
:
899 if (action
== M_PROPERTY_SET
&& arg
)
900 tmp
= *((int *) arg
);
903 int new_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
904 if (new_id
!= current_id
)
905 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
906 if (new_id
!= current_id
&& new_id
>= 0) {
908 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
909 sh2
->ds
= mpctx
->demuxer
->audio
;
910 mpctx
->sh_audio
= sh2
;
911 reinit_audio_chain(mpctx
);
913 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
914 return M_PROPERTY_OK
;
916 return M_PROPERTY_NOT_IMPLEMENTED
;
921 /// Selected video id (RW)
922 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
925 struct MPOpts
*opts
= &mpctx
->opts
;
927 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
928 return M_PROPERTY_UNAVAILABLE
;
929 current_id
= mpctx
->demuxer
->video
->id
;
934 return M_PROPERTY_ERROR
;
935 *(int *) arg
= current_id
;
936 return M_PROPERTY_OK
;
937 case M_PROPERTY_PRINT
:
939 return M_PROPERTY_ERROR
;
942 *(char **) arg
= strdup(mp_gtext("disabled"));
945 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
946 *(char **) arg
= malloc(64);
947 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
949 return M_PROPERTY_OK
;
951 case M_PROPERTY_STEP_UP
:
953 if (action
== M_PROPERTY_SET
&& arg
)
954 tmp
= *((int *) arg
);
957 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
958 if (opts
->video_id
== -2
959 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
960 && current_id
!= -2))
961 uninit_player(mpctx
, INITIALIZED_VCODEC
|
962 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
963 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
965 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
967 sh2
->ds
= mpctx
->demuxer
->video
;
968 mpctx
->sh_video
= sh2
;
969 reinit_video_chain(mpctx
);
972 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
973 return M_PROPERTY_OK
;
976 return M_PROPERTY_NOT_IMPLEMENTED
;
980 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
983 demux_program_t prog
;
986 case M_PROPERTY_STEP_UP
:
988 if (action
== M_PROPERTY_SET
&& arg
)
989 prog
.progid
= *((int *) arg
);
993 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
994 &prog
) == DEMUXER_CTRL_NOTIMPL
)
995 return M_PROPERTY_ERROR
;
997 if (prog
.aid
< 0 && prog
.vid
< 0) {
998 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
999 return M_PROPERTY_ERROR
;
1001 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1002 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1003 return M_PROPERTY_OK
;
1006 return M_PROPERTY_NOT_IMPLEMENTED
;
1012 /// \defgroup VideoProperties Video properties
1013 /// \ingroup Properties
1016 /// Fullscreen state (RW)
1017 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1021 if (!mpctx
->video_out
)
1022 return M_PROPERTY_UNAVAILABLE
;
1025 case M_PROPERTY_SET
:
1027 return M_PROPERTY_ERROR
;
1028 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1029 if (vo_fs
== !!*(int *) arg
)
1030 return M_PROPERTY_OK
;
1031 case M_PROPERTY_STEP_UP
:
1032 case M_PROPERTY_STEP_DOWN
:
1033 if (mpctx
->video_out
->config_ok
)
1034 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1035 mpctx
->opts
.fullscreen
= vo_fs
;
1036 return M_PROPERTY_OK
;
1038 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1042 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1043 void *arg
, MPContext
*mpctx
)
1047 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1048 return M_PROPERTY_UNAVAILABLE
;
1049 vf
= mpctx
->sh_video
->vfilter
;
1051 case M_PROPERTY_GET
:
1053 return M_PROPERTY_ERROR
;
1054 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1055 return M_PROPERTY_OK
;
1056 case M_PROPERTY_SET
:
1058 return M_PROPERTY_ERROR
;
1059 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1060 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1061 return M_PROPERTY_OK
;
1062 case M_PROPERTY_STEP_UP
:
1063 case M_PROPERTY_STEP_DOWN
:
1064 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1065 deinterlace
= !deinterlace
;
1066 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1067 return M_PROPERTY_OK
;
1070 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1071 return m_property_flag_ro(prop
, action
, arg
, value
);
1074 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1075 void *arg
, MPContext
*mpctx
)
1077 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1078 return M_PROPERTY_UNAVAILABLE
;
1080 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1083 case M_PROPERTY_GET
:
1085 return M_PROPERTY_ERROR
;
1086 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1087 return M_PROPERTY_UNAVAILABLE
;
1088 return M_PROPERTY_OK
;
1089 case M_PROPERTY_PRINT
:
1091 return M_PROPERTY_ERROR
;
1092 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1093 return M_PROPERTY_UNAVAILABLE
;
1094 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1095 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1096 *(char **)arg
= strdup("Unknown");
1098 *(char**)arg
= strdup(names
[colorspace
]);
1099 return M_PROPERTY_OK
;
1100 case M_PROPERTY_SET
:
1102 return M_PROPERTY_ERROR
;
1103 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1104 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1105 return M_PROPERTY_OK
;
1106 case M_PROPERTY_STEP_UP
:;
1107 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1108 return M_PROPERTY_UNAVAILABLE
;
1110 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1111 return M_PROPERTY_OK
;
1113 return M_PROPERTY_NOT_IMPLEMENTED
;
1117 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1121 if (!mpctx
->video_out
1122 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1123 return M_PROPERTY_UNAVAILABLE
;
1126 case M_PROPERTY_SET
:
1128 return M_PROPERTY_ERROR
;
1129 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1130 vo_panscan
= *(float *) arg
;
1131 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1132 return M_PROPERTY_OK
;
1133 case M_PROPERTY_STEP_UP
:
1134 case M_PROPERTY_STEP_DOWN
:
1135 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1136 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1139 else if (vo_panscan
< 0)
1141 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1142 return M_PROPERTY_OK
;
1144 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1148 /// Helper to set vo flags.
1149 /** \ingroup PropertyImplHelper
1151 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1152 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1155 if (!mpctx
->video_out
)
1156 return M_PROPERTY_UNAVAILABLE
;
1159 case M_PROPERTY_SET
:
1161 return M_PROPERTY_ERROR
;
1162 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1163 if (*vo_var
== !!*(int *) arg
)
1164 return M_PROPERTY_OK
;
1165 case M_PROPERTY_STEP_UP
:
1166 case M_PROPERTY_STEP_DOWN
:
1167 if (mpctx
->video_out
->config_ok
)
1168 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1169 return M_PROPERTY_OK
;
1171 return m_property_flag(prop
, action
, arg
, vo_var
);
1175 /// Window always on top (RW)
1176 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1179 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1180 &mpctx
->opts
.vo_ontop
, mpctx
);
1183 /// Display in the root window (RW)
1184 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1187 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1188 &vo_rootwin
, mpctx
);
1191 /// Show window borders (RW)
1192 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1195 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1199 /// Framedropping state (RW)
1200 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1201 void *arg
, MPContext
*mpctx
)
1204 if (!mpctx
->sh_video
)
1205 return M_PROPERTY_UNAVAILABLE
;
1208 case M_PROPERTY_PRINT
:
1210 return M_PROPERTY_ERROR
;
1211 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1212 (frame_dropping
== 2 ? mp_gtext("hard") :
1213 mp_gtext("disabled")));
1214 return M_PROPERTY_OK
;
1216 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1220 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1221 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1224 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1227 if (!mpctx
->sh_video
)
1228 return M_PROPERTY_UNAVAILABLE
;
1230 if (gamma
[0] == 1000) {
1232 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1236 case M_PROPERTY_SET
:
1238 return M_PROPERTY_ERROR
;
1239 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1240 *gamma
= *(int *) arg
;
1241 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1245 case M_PROPERTY_GET
:
1246 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1248 return M_PROPERTY_ERROR
;
1250 return M_PROPERTY_OK
;
1253 case M_PROPERTY_STEP_UP
:
1254 case M_PROPERTY_STEP_DOWN
:
1255 *gamma
+= (arg
? *(int *) arg
: 1) *
1256 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1257 M_PROPERTY_CLAMP(prop
, *gamma
);
1258 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1263 return M_PROPERTY_NOT_IMPLEMENTED
;
1267 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1268 int l
= strlen(prop
->name
);
1269 char tv_prop
[3 + l
+ 1];
1270 sprintf(tv_prop
, "tv_%s", prop
->name
);
1271 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1275 return M_PROPERTY_UNAVAILABLE
;
1279 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1282 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1285 /// Video codec tag (RO)
1286 static int mp_property_video_format(m_option_t
*prop
, int action
,
1287 void *arg
, MPContext
*mpctx
)
1290 if (!mpctx
->sh_video
)
1291 return M_PROPERTY_UNAVAILABLE
;
1293 case M_PROPERTY_PRINT
:
1295 return M_PROPERTY_ERROR
;
1296 switch(mpctx
->sh_video
->format
) {
1298 meta
= strdup ("mpeg1"); break;
1300 meta
= strdup ("mpeg2"); break;
1302 meta
= strdup ("mpeg4"); break;
1304 meta
= strdup ("h264"); break;
1306 if(mpctx
->sh_video
->format
>= 0x20202020) {
1308 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1311 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1314 *(char**)arg
= meta
;
1315 return M_PROPERTY_OK
;
1317 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1320 /// Video codec name (RO)
1321 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1322 void *arg
, MPContext
*mpctx
)
1324 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1325 return M_PROPERTY_UNAVAILABLE
;
1326 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1330 /// Video bitrate (RO)
1331 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1332 void *arg
, MPContext
*mpctx
)
1334 if (!mpctx
->sh_video
)
1335 return M_PROPERTY_UNAVAILABLE
;
1336 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1339 /// Video display width (RO)
1340 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1343 if (!mpctx
->sh_video
)
1344 return M_PROPERTY_UNAVAILABLE
;
1345 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1348 /// Video display height (RO)
1349 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1352 if (!mpctx
->sh_video
)
1353 return M_PROPERTY_UNAVAILABLE
;
1354 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1358 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1361 if (!mpctx
->sh_video
)
1362 return M_PROPERTY_UNAVAILABLE
;
1363 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1366 /// Video aspect (RO)
1367 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1370 if (!mpctx
->sh_video
)
1371 return M_PROPERTY_UNAVAILABLE
;
1372 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1377 /// \defgroup SubProprties Subtitles properties
1378 /// \ingroup Properties
1381 /// Text subtitle position (RW)
1382 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1386 case M_PROPERTY_SET
:
1388 return M_PROPERTY_ERROR
;
1389 case M_PROPERTY_STEP_UP
:
1390 case M_PROPERTY_STEP_DOWN
:
1391 vo_osd_changed(OSDTYPE_SUBTITLE
);
1393 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1397 /// Selected subtitles (RW)
1398 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1401 struct MPOpts
*opts
= &mpctx
->opts
;
1402 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1403 const int global_sub_size
= mpctx
->global_sub_size
;
1404 int source
= -1, reset_spu
= 0;
1407 if (global_sub_size
<= 0)
1408 return M_PROPERTY_UNAVAILABLE
;
1411 case M_PROPERTY_GET
:
1413 return M_PROPERTY_ERROR
;
1414 *(int *) arg
= mpctx
->global_sub_pos
;
1415 return M_PROPERTY_OK
;
1416 case M_PROPERTY_PRINT
:
1418 return M_PROPERTY_ERROR
;
1419 *(char **) arg
= malloc(64);
1420 (*(char **) arg
)[63] = 0;
1423 sub_name
= subdata
->filename
;
1425 if (ass_track
&& ass_track
->name
)
1426 sub_name
= ass_track
->name
;
1431 if ((tmp2
= strrchr(tmp
, '/')))
1434 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1435 mpctx
->set_of_sub_pos
+ 1,
1436 strlen(tmp
) < 20 ? "" : "...",
1437 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1438 return M_PROPERTY_OK
;
1440 #ifdef CONFIG_DVDNAV
1441 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1442 if (vo_spudec
&& opts
->sub_id
>= 0) {
1443 unsigned char lang
[3];
1444 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1445 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1446 return M_PROPERTY_OK
;
1452 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1453 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1454 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1455 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1456 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1457 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1458 if (!lang
) lang
= mp_gtext("unknown");
1459 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1460 return M_PROPERTY_OK
;
1463 if (vo_vobsub
&& vobsub_id
>= 0) {
1464 const char *language
= mp_gtext("unknown");
1465 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1466 snprintf(*(char **) arg
, 63, "(%d) %s",
1467 vobsub_id
, language
? language
: mp_gtext("unknown"));
1468 return M_PROPERTY_OK
;
1470 #ifdef CONFIG_DVDREAD
1471 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1472 && opts
->sub_id
>= 0) {
1474 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1475 lang
[0] = code
>> 8;
1478 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1479 return M_PROPERTY_OK
;
1482 if (opts
->sub_id
>= 0) {
1483 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1484 mp_gtext("unknown"));
1485 return M_PROPERTY_OK
;
1487 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1488 return M_PROPERTY_OK
;
1490 case M_PROPERTY_SET
:
1492 return M_PROPERTY_ERROR
;
1493 if (*(int *) arg
< -1)
1495 else if (*(int *) arg
>= global_sub_size
)
1496 *(int *) arg
= global_sub_size
- 1;
1497 mpctx
->global_sub_pos
= *(int *) arg
;
1499 case M_PROPERTY_STEP_UP
:
1500 mpctx
->global_sub_pos
+= 2;
1501 mpctx
->global_sub_pos
=
1502 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1504 case M_PROPERTY_STEP_DOWN
:
1505 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1506 mpctx
->global_sub_pos
=
1507 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1510 return M_PROPERTY_NOT_IMPLEMENTED
;
1513 if (mpctx
->global_sub_pos
>= 0)
1514 source
= sub_source(mpctx
);
1516 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1517 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1519 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1520 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1521 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1522 mpctx
->global_sub_pos
, source
);
1524 mpctx
->set_of_sub_pos
= -1;
1538 if (source
== SUB_SOURCE_VOBSUB
) {
1539 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1540 } else if (source
== SUB_SOURCE_SUBS
) {
1541 mpctx
->set_of_sub_pos
=
1542 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1544 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1545 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1549 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1550 vo_osd_changed(OSDTYPE_SUBTITLE
);
1552 } else if (source
== SUB_SOURCE_DEMUX
) {
1554 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1555 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1557 // default: assume 1:1 mapping of sid and stream id
1558 d_sub
->id
= opts
->sub_id
;
1559 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1560 ds_free_packs(d_sub
);
1561 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1562 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1563 if (sh
&& sh
->sid
== opts
->sub_id
) {
1569 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1570 sh_sub_t
*sh
= d_sub
->sh
;
1571 if (sh
->type
== 'v')
1572 init_vo_spudec(mpctx
);
1574 else if (opts
->ass_enabled
)
1575 ass_track
= sh
->ass_track
;
1583 #ifdef CONFIG_DVDREAD
1585 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1586 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1587 && opts
->sub_id
< 0 && reset_spu
) {
1593 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1595 return M_PROPERTY_OK
;
1598 /// Selected sub source (RW)
1599 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1603 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1604 return M_PROPERTY_UNAVAILABLE
;
1607 case M_PROPERTY_GET
:
1609 return M_PROPERTY_ERROR
;
1610 *(int *) arg
= sub_source(mpctx
);
1611 return M_PROPERTY_OK
;
1612 case M_PROPERTY_PRINT
:
1614 return M_PROPERTY_ERROR
;
1615 *(char **) arg
= malloc(64);
1616 (*(char **) arg
)[63] = 0;
1617 switch (sub_source(mpctx
))
1619 case SUB_SOURCE_SUBS
:
1620 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1622 case SUB_SOURCE_VOBSUB
:
1623 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1625 case SUB_SOURCE_DEMUX
:
1626 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1629 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1631 return M_PROPERTY_OK
;
1632 case M_PROPERTY_SET
:
1634 return M_PROPERTY_ERROR
;
1635 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1636 if (*(int *) arg
< 0)
1637 mpctx
->global_sub_pos
= -1;
1638 else if (*(int *) arg
!= sub_source(mpctx
)) {
1639 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1640 return M_PROPERTY_UNAVAILABLE
;
1641 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1644 case M_PROPERTY_STEP_UP
:
1645 case M_PROPERTY_STEP_DOWN
: {
1646 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1647 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1648 int step
= (step_all
> 0) ? 1 : -1;
1649 int cur_source
= sub_source(mpctx
);
1650 source
= cur_source
;
1653 if (source
>= SUB_SOURCES
)
1655 else if (source
< -1)
1656 source
= SUB_SOURCES
- 1;
1657 if (source
== cur_source
|| source
== -1 ||
1658 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1661 if (source
== cur_source
)
1662 return M_PROPERTY_OK
;
1664 mpctx
->global_sub_pos
= -1;
1666 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1670 return M_PROPERTY_NOT_IMPLEMENTED
;
1672 --mpctx
->global_sub_pos
;
1673 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1676 /// Selected subtitles from specific source (RW)
1677 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1680 int source
, is_cur_source
, offset
;
1681 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1682 return M_PROPERTY_UNAVAILABLE
;
1684 if (!strcmp(prop
->name
, "sub_file"))
1685 source
= SUB_SOURCE_SUBS
;
1686 else if (!strcmp(prop
->name
, "sub_vob"))
1687 source
= SUB_SOURCE_VOBSUB
;
1688 else if (!strcmp(prop
->name
, "sub_demux"))
1689 source
= SUB_SOURCE_DEMUX
;
1691 return M_PROPERTY_ERROR
;
1693 offset
= mpctx
->global_sub_indices
[source
];
1694 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1695 return M_PROPERTY_UNAVAILABLE
;
1697 is_cur_source
= sub_source(mpctx
) == source
;
1699 case M_PROPERTY_GET
:
1701 return M_PROPERTY_ERROR
;
1702 if (is_cur_source
) {
1703 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1704 if (source
== SUB_SOURCE_VOBSUB
)
1705 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1709 return M_PROPERTY_OK
;
1710 case M_PROPERTY_PRINT
:
1712 return M_PROPERTY_ERROR
;
1714 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1715 *(char **) arg
= malloc(64);
1716 (*(char **) arg
)[63] = 0;
1717 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1718 return M_PROPERTY_OK
;
1719 case M_PROPERTY_SET
:
1721 return M_PROPERTY_ERROR
;
1722 if (*(int *) arg
>= 0) {
1723 int index
= *(int *)arg
;
1724 if (source
== SUB_SOURCE_VOBSUB
)
1725 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1726 mpctx
->global_sub_pos
= offset
+ index
;
1727 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1728 || sub_source(mpctx
) != source
) {
1729 mpctx
->global_sub_pos
= -1;
1734 mpctx
->global_sub_pos
= -1;
1736 case M_PROPERTY_STEP_UP
:
1737 case M_PROPERTY_STEP_DOWN
: {
1738 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1739 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1740 int step
= (step_all
> 0) ? 1 : -1;
1741 int max_sub_pos_for_source
= -1;
1743 mpctx
->global_sub_pos
= -1;
1745 if (mpctx
->global_sub_pos
== -1) {
1747 mpctx
->global_sub_pos
= offset
;
1748 else if (max_sub_pos_for_source
== -1) {
1749 // Find max pos for specific source
1750 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1751 while (mpctx
->global_sub_pos
>= 0
1752 && sub_source(mpctx
) != source
)
1753 --mpctx
->global_sub_pos
;
1756 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1759 mpctx
->global_sub_pos
+= step
;
1760 if (mpctx
->global_sub_pos
< offset
||
1761 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1762 sub_source(mpctx
) != source
)
1763 mpctx
->global_sub_pos
= -1;
1770 return M_PROPERTY_NOT_IMPLEMENTED
;
1772 --mpctx
->global_sub_pos
;
1773 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1776 /// Subtitle delay (RW)
1777 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1780 if (!mpctx
->sh_video
)
1781 return M_PROPERTY_UNAVAILABLE
;
1782 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1785 /// Alignment of text subtitles (RW)
1786 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1787 void *arg
, MPContext
*mpctx
)
1789 char *name
[] = { _("top"), _("center"), _("bottom") };
1791 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1792 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1793 return M_PROPERTY_UNAVAILABLE
;
1796 case M_PROPERTY_PRINT
:
1798 return M_PROPERTY_ERROR
;
1799 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1800 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1801 return M_PROPERTY_OK
;
1802 case M_PROPERTY_SET
:
1804 return M_PROPERTY_ERROR
;
1805 case M_PROPERTY_STEP_UP
:
1806 case M_PROPERTY_STEP_DOWN
:
1807 vo_osd_changed(OSDTYPE_SUBTITLE
);
1809 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1813 /// Subtitle visibility (RW)
1814 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1815 void *arg
, MPContext
*mpctx
)
1817 if (!mpctx
->sh_video
)
1818 return M_PROPERTY_UNAVAILABLE
;
1821 case M_PROPERTY_SET
:
1823 return M_PROPERTY_ERROR
;
1824 case M_PROPERTY_STEP_UP
:
1825 case M_PROPERTY_STEP_DOWN
:
1826 vo_osd_changed(OSDTYPE_SUBTITLE
);
1828 vo_osd_changed(OSDTYPE_SPU
);
1830 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1835 /// Use margins for libass subtitles (RW)
1836 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1837 void *arg
, MPContext
*mpctx
)
1839 if (!mpctx
->sh_video
)
1840 return M_PROPERTY_UNAVAILABLE
;
1843 case M_PROPERTY_SET
:
1845 return M_PROPERTY_ERROR
;
1846 case M_PROPERTY_STEP_UP
:
1847 case M_PROPERTY_STEP_DOWN
:
1848 ass_force_reload
= 1;
1850 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1855 /// Show only forced subtitles (RW)
1856 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1857 void *arg
, MPContext
*mpctx
)
1860 return M_PROPERTY_UNAVAILABLE
;
1863 case M_PROPERTY_SET
:
1865 return M_PROPERTY_ERROR
;
1866 case M_PROPERTY_STEP_UP
:
1867 case M_PROPERTY_STEP_DOWN
:
1868 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1869 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1870 return M_PROPERTY_OK
;
1872 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1877 #ifdef CONFIG_FREETYPE
1878 /// Subtitle scale (RW)
1879 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1882 struct MPOpts
*opts
= &mpctx
->opts
;
1885 case M_PROPERTY_SET
:
1887 return M_PROPERTY_ERROR
;
1888 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1890 if (opts
->ass_enabled
) {
1891 ass_font_scale
= *(float *) arg
;
1892 ass_force_reload
= 1;
1895 text_font_scale_factor
= *(float *) arg
;
1896 force_load_font
= 1;
1897 return M_PROPERTY_OK
;
1898 case M_PROPERTY_STEP_UP
:
1899 case M_PROPERTY_STEP_DOWN
:
1901 if (opts
->ass_enabled
) {
1902 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1903 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1904 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1905 ass_force_reload
= 1;
1908 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1909 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1910 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1911 force_load_font
= 1;
1912 return M_PROPERTY_OK
;
1915 if (opts
->ass_enabled
)
1916 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1919 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1926 /// \defgroup TVProperties TV properties
1927 /// \ingroup Properties
1932 /// TV color settings (RW)
1933 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1937 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1938 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1939 return M_PROPERTY_UNAVAILABLE
;
1942 case M_PROPERTY_SET
:
1944 return M_PROPERTY_ERROR
;
1945 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1946 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1947 case M_PROPERTY_GET
:
1948 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1949 case M_PROPERTY_STEP_UP
:
1950 case M_PROPERTY_STEP_DOWN
:
1951 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1953 return M_PROPERTY_ERROR
;
1954 val
+= (arg
? *(int *) arg
: 1) *
1955 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1956 M_PROPERTY_CLAMP(prop
, val
);
1957 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1959 return M_PROPERTY_ERROR
;
1961 return M_PROPERTY_NOT_IMPLEMENTED
;
1966 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1970 int base_ioctl
=(int)prop
->priv
;
1972 for teletext's GET,SET,STEP ioctls this is not 0
1976 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1977 return M_PROPERTY_UNAVAILABLE
;
1979 return M_PROPERTY_ERROR
;
1982 case M_PROPERTY_GET
:
1984 return M_PROPERTY_ERROR
;
1985 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1987 case M_PROPERTY_SET
:
1989 return M_PROPERTY_ERROR
;
1990 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1991 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1993 case M_PROPERTY_STEP_UP
:
1994 case M_PROPERTY_STEP_DOWN
:
1995 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1996 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1997 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2000 return M_PROPERTY_NOT_IMPLEMENTED
;
2003 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2006 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2012 //with tvh==NULL will fail too
2013 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2014 if(result
!=M_PROPERTY_OK
)
2017 if(teletext_control(mpctx
->demuxer
->teletext
,
2018 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
2019 mp_input_set_section(mpctx
->input
, "teletext");
2021 mp_input_set_section(mpctx
->input
, "tv");
2022 return M_PROPERTY_OK
;
2025 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2030 if (!mpctx
->demuxer
->teletext
)
2031 return M_PROPERTY_UNAVAILABLE
;
2033 case M_PROPERTY_STEP_UP
:
2034 case M_PROPERTY_STEP_DOWN
:
2035 //This should be handled separately
2036 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2037 result
=teletext_control(mpctx
->demuxer
->teletext
,
2038 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2041 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2048 /// All properties available in MPlayer.
2049 /** \ingroup Properties
2051 static const m_option_t mp_properties
[] = {
2053 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2054 M_OPT_RANGE
, 0, 3, NULL
},
2055 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2056 M_OPT_MIN
, -1, 0, NULL
},
2057 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2058 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2059 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2061 { "path", mp_property_path
, CONF_TYPE_STRING
,
2063 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2065 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2066 M_OPT_MIN
, 0, 0, NULL
},
2067 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2068 M_OPT_MIN
, 0, 0, NULL
},
2069 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2070 M_OPT_MIN
, 0, 0, NULL
},
2071 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2072 M_OPT_MIN
, 0, 0, NULL
},
2073 { "length", mp_property_length
, CONF_TYPE_TIME
,
2074 M_OPT_MIN
, 0, 0, NULL
},
2075 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2076 M_OPT_RANGE
, 0, 100, NULL
},
2077 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2078 M_OPT_MIN
, 0, 0, NULL
},
2079 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2080 M_OPT_MIN
, 0, 0, NULL
},
2081 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2083 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2084 CONF_RANGE
, -2, 10, NULL
},
2085 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2087 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2088 M_OPT_RANGE
, 0, 1, NULL
},
2091 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2092 M_OPT_RANGE
, 0, 100, NULL
},
2093 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2094 M_OPT_RANGE
, 0, 1, NULL
},
2095 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2096 M_OPT_RANGE
, -100, 100, NULL
},
2097 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2099 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2101 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2103 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2105 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2107 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2108 CONF_RANGE
, -2, 65535, NULL
},
2109 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2110 M_OPT_RANGE
, -1, 1, NULL
},
2113 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2114 M_OPT_RANGE
, 0, 1, NULL
},
2115 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2116 M_OPT_RANGE
, 0, 1, NULL
},
2117 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2118 M_OPT_RANGE
, 0, 2, NULL
},
2119 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2120 M_OPT_RANGE
, 0, 1, NULL
},
2121 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2122 M_OPT_RANGE
, 0, 1, NULL
},
2123 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2124 M_OPT_RANGE
, 0, 1, NULL
},
2125 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2126 M_OPT_RANGE
, 0, 2, NULL
},
2127 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2128 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2129 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2130 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2131 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2132 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2133 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2134 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2135 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2136 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2137 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2138 M_OPT_RANGE
, 0, 1, NULL
},
2139 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2140 M_OPT_RANGE
, 0, 1, NULL
},
2141 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2143 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2145 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2147 { "width", mp_property_width
, CONF_TYPE_INT
,
2149 { "height", mp_property_height
, CONF_TYPE_INT
,
2151 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2153 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2155 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2156 CONF_RANGE
, -2, 65535, NULL
},
2157 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2158 CONF_RANGE
, -1, 65535, NULL
},
2161 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2162 M_OPT_MIN
, -1, 0, NULL
},
2163 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2164 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2165 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2166 M_OPT_MIN
, -1, 0, NULL
},
2167 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2168 M_OPT_MIN
, -1, 0, NULL
},
2169 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2170 M_OPT_MIN
, -1, 0, NULL
},
2171 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2173 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2174 M_OPT_RANGE
, 0, 100, NULL
},
2175 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2176 M_OPT_RANGE
, 0, 2, NULL
},
2177 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2178 M_OPT_RANGE
, 0, 1, NULL
},
2179 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2180 M_OPT_RANGE
, 0, 1, NULL
},
2181 #ifdef CONFIG_FREETYPE
2182 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2183 M_OPT_RANGE
, 0, 100, NULL
},
2186 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2187 M_OPT_RANGE
, 0, 1, NULL
},
2191 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2192 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2193 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2194 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2195 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2196 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2197 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2198 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2200 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2201 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2202 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2203 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2204 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2205 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2206 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2207 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2208 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2209 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2210 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2214 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2216 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2219 char* mp_property_print(const char *name
, void* ctx
)
2222 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2227 char *property_expand_string(MPContext
*mpctx
, char *str
)
2229 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2232 void property_print_help(void)
2234 m_properties_print_help_list(mp_properties
);
2238 /* List of default ways to show a property on OSD.
2240 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2241 * a bar showing the current position between min/max values of the
2242 * property. In this case osd_msg is only used for terminal output
2243 * if there is no video; it'll be a label shown together with percentage.
2245 * Otherwise setting osd_msg will show the string on OSD, formatted with
2246 * the text value of the property as argument.
2248 static struct property_osd_display
{
2251 /// progressbar type
2252 int osd_progbar
; // -1 is special value for seek indicators
2253 /// osd msg id if it must be shared
2255 /// osd msg template
2256 const char *osd_msg
;
2257 } property_osd_display
[] = {
2259 { "loop", 0, -1, _("Loop: %s") },
2260 { "chapter", -1, -1, NULL
},
2262 { "volume", OSD_VOLUME
, -1, _("Volume") },
2263 { "mute", 0, -1, _("Mute: %s") },
2264 { "audio_delay", 0, -1, _("A-V delay: %s") },
2265 { "switch_audio", 0, -1, _("Audio: %s") },
2266 { "balance", OSD_BALANCE
, -1, _("Balance") },
2268 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2269 { "ontop", 0, -1, _("Stay on top: %s") },
2270 { "rootwin", 0, -1, _("Rootwin: %s") },
2271 { "border", 0, -1, _("Border: %s") },
2272 { "framedropping", 0, -1, _("Framedropping: %s") },
2273 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2274 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2275 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2276 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2277 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2278 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2279 { "hue", OSD_HUE
, -1, _("Hue") },
2280 { "vsync", 0, -1, _("VSync: %s") },
2282 { "sub", 0, -1, _("Subtitles: %s") },
2283 { "sub_source", 0, -1, _("Sub source: %s") },
2284 { "sub_vob", 0, -1, _("Subtitles: %s") },
2285 { "sub_demux", 0, -1, _("Subtitles: %s") },
2286 { "sub_file", 0, -1, _("Subtitles: %s") },
2287 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2288 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2289 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2290 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2291 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2292 #ifdef CONFIG_FREETYPE
2293 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2296 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2297 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2298 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2299 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2304 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2306 struct MPOpts
*opts
= &mpctx
->opts
;
2309 struct property_osd_display
*p
;
2311 // look for the command
2312 for (p
= property_osd_display
; p
->name
; p
++)
2313 if (!strcmp(p
->name
, pname
))
2318 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2321 if (p
->osd_progbar
== -1)
2322 mpctx
->add_osd_seek_info
= true;
2323 else if (p
->osd_progbar
) {
2324 if (prop
->type
== CONF_TYPE_INT
) {
2325 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2326 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2327 prop
->min
, prop
->max
, r
);
2328 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2330 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2331 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2332 prop
->min
, prop
->max
, f
);
2334 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2335 "Property use an unsupported type.\n");
2342 char *val
= mp_property_print(pname
, mpctx
);
2344 int index
= p
- property_osd_display
;
2345 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2346 1, opts
->osd_duration
, p
->osd_msg
, val
);
2355 * \defgroup Command2Property Command to property bridge
2357 * It is used to handle most commands that just set a property
2358 * and optionally display something on the OSD.
2359 * Two kinds of commands are handled: adjust or toggle.
2361 * Adjust commands take 1 or 2 parameters: <value> <abs>
2362 * If <abs> is non-zero the property is set to the given value
2363 * otherwise it is adjusted.
2365 * Toggle commands take 0 or 1 parameters. With no parameter
2366 * or a value less than the property minimum it just steps the
2367 * property to its next value. Otherwise it sets it to the given
2373 /// List of the commands that can be handled by setting a property.
2379 /// set/adjust or toggle command
2381 } set_prop_cmd
[] = {
2383 { "loop", MP_CMD_LOOP
, 0},
2384 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2385 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2386 { "pause", MP_CMD_PAUSE
, 0},
2388 { "volume", MP_CMD_VOLUME
, 0},
2389 { "mute", MP_CMD_MUTE
, 1},
2390 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2391 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2392 { "balance", MP_CMD_BALANCE
, 0},
2394 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2395 { "panscan", MP_CMD_PANSCAN
, 0},
2396 { "ontop", MP_CMD_VO_ONTOP
, 1},
2397 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2398 { "border", MP_CMD_VO_BORDER
, 1},
2399 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2400 { "gamma", MP_CMD_GAMMA
, 0},
2401 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2402 { "contrast", MP_CMD_CONTRAST
, 0},
2403 { "saturation", MP_CMD_SATURATION
, 0},
2404 { "hue", MP_CMD_HUE
, 0},
2405 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2407 { "sub", MP_CMD_SUB_SELECT
, 1},
2408 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2409 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2410 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2411 { "sub_file", MP_CMD_SUB_FILE
, 1},
2412 { "sub_pos", MP_CMD_SUB_POS
, 0},
2413 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2414 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2415 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2416 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2417 #ifdef CONFIG_FREETYPE
2418 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2421 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2424 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2425 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2426 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2427 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2432 /// Handle commands that set a property.
2433 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2439 // look for the command
2440 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2441 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2443 if (!(pname
= set_prop_cmd
[i
].name
))
2446 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2450 if (set_prop_cmd
[i
].toggle
) {
2452 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2453 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2455 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2456 } else if (cmd
->args
[1].v
.i
) //set
2457 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2459 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2464 show_property_osd(mpctx
, pname
);
2469 #ifdef CONFIG_DVDNAV
2470 static const struct {
2472 const mp_command_type cmd
;
2473 } mp_dvdnav_bindings
[] = {
2474 { "up", MP_CMD_DVDNAV_UP
},
2475 { "down", MP_CMD_DVDNAV_DOWN
},
2476 { "left", MP_CMD_DVDNAV_LEFT
},
2477 { "right", MP_CMD_DVDNAV_RIGHT
},
2478 { "menu", MP_CMD_DVDNAV_MENU
},
2479 { "select", MP_CMD_DVDNAV_SELECT
},
2480 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2481 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2484 * keep old dvdnav sub-command options for a while in order not to
2485 * break slave-mode API too suddenly.
2487 { "1", MP_CMD_DVDNAV_UP
},
2488 { "2", MP_CMD_DVDNAV_DOWN
},
2489 { "3", MP_CMD_DVDNAV_LEFT
},
2490 { "4", MP_CMD_DVDNAV_RIGHT
},
2491 { "5", MP_CMD_DVDNAV_MENU
},
2492 { "6", MP_CMD_DVDNAV_SELECT
},
2493 { "7", MP_CMD_DVDNAV_PREVMENU
},
2494 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2499 static const char *property_error_string(int error_value
)
2501 switch (error_value
) {
2502 case M_PROPERTY_ERROR
:
2504 case M_PROPERTY_UNAVAILABLE
:
2505 return "PROPERTY_UNAVAILABLE";
2506 case M_PROPERTY_NOT_IMPLEMENTED
:
2507 return "NOT_IMPLEMENTED";
2508 case M_PROPERTY_UNKNOWN
:
2509 return "PROPERTY_UNKNOWN";
2510 case M_PROPERTY_DISABLED
:
2516 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2519 int end
= start
+ count
;
2520 int after
= mpctx
->set_of_sub_size
- end
;
2521 sub_data
**subs
= mpctx
->set_of_subtitles
;
2523 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2525 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2526 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2527 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2528 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2531 for (idx
= start
; idx
< end
; idx
++) {
2532 sub_data
*subd
= subs
[idx
];
2533 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2534 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2535 filename_recode(subd
->filename
));
2539 if (ass_tracks
[idx
])
2540 ass_free_track(ass_tracks
[idx
]);
2541 ass_tracks
[idx
] = NULL
;
2545 mpctx
->global_sub_size
-= count
;
2546 mpctx
->set_of_sub_size
-= count
;
2547 if (mpctx
->set_of_sub_size
<= 0)
2548 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2550 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2551 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2553 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2554 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2557 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2558 mpctx
->global_sub_pos
= -2;
2563 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2564 } else if (mpctx
->set_of_sub_pos
>= end
) {
2565 mpctx
->set_of_sub_pos
-= count
;
2566 mpctx
->global_sub_pos
-= count
;
2570 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2572 struct MPOpts
*opts
= &mpctx
->opts
;
2573 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2574 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2575 int osd_duration
= opts
->osd_duration
;
2576 int case_fallthrough_hack
= 0;
2577 if (!set_property_command(mpctx
, cmd
))
2582 mpctx
->add_osd_seek_info
= true;
2583 v
= cmd
->args
[0].v
.f
;
2584 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2585 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2586 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2588 mpctx
->osd_function
=
2589 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2590 mpctx
->rel_seek_secs
= v
;
2591 } else if (abs
) { /* Absolute seek by percentage */
2592 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2594 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2595 mpctx
->rel_seek_secs
= v
/ 100.0;
2597 mpctx
->rel_seek_secs
+= v
;
2598 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2603 case MP_CMD_SET_PROPERTY_OSD
:
2604 case_fallthrough_hack
= 1;
2606 case MP_CMD_SET_PROPERTY
:{
2607 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2608 cmd
->args
[1].v
.s
, mpctx
);
2609 if (r
== M_PROPERTY_UNKNOWN
)
2610 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2611 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2613 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2614 "Failed to set property '%s' to '%s'.\n",
2615 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2616 else if (case_fallthrough_hack
)
2617 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2619 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2623 case MP_CMD_STEP_PROPERTY_OSD
:
2624 case_fallthrough_hack
= 1;
2626 case MP_CMD_STEP_PROPERTY
:{
2631 if (cmd
->args
[1].v
.f
) {
2633 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2634 M_PROPERTY_GET_TYPE
,
2635 &prop
, mpctx
)) <= 0)
2637 if(prop
->type
== CONF_TYPE_INT
||
2638 prop
->type
== CONF_TYPE_FLAG
)
2639 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2640 else if(prop
->type
== CONF_TYPE_FLOAT
)
2641 arg
= &cmd
->args
[1].v
.f
;
2642 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2643 prop
->type
== CONF_TYPE_TIME
)
2644 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2645 else if(prop
->type
== CONF_TYPE_POSITION
)
2646 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2648 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2649 "Ignoring step size stepping property '%s'.\n",
2652 r
= mp_property_do(cmd
->args
[0].v
.s
,
2653 cmd
->args
[2].v
.i
< 0 ?
2654 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2657 if (r
== M_PROPERTY_UNKNOWN
)
2658 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2659 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2661 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2662 "Failed to increment property '%s' by %f.\n",
2663 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2664 else if (case_fallthrough_hack
)
2665 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2667 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2671 case MP_CMD_GET_PROPERTY
:{
2673 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2676 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2677 "Failed to get value of property '%s'.\n",
2679 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2682 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2683 cmd
->args
[0].v
.s
, tmp
);
2688 case MP_CMD_EDL_MARK
:
2690 float v
= sh_video
? sh_video
->pts
:
2691 playing_audio_pts(mpctx
);
2692 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2693 mpctx
->begin_skip
= v
;
2694 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2696 if (mpctx
->begin_skip
> v
)
2697 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2699 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2700 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2702 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2707 case MP_CMD_SWITCH_RATIO
:
2710 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2711 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2713 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2714 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2717 case MP_CMD_SPEED_INCR
:{
2718 float v
= cmd
->args
[0].v
.f
;
2719 opts
->playback_speed
+= v
;
2720 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2721 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2722 opts
->playback_speed
);
2725 case MP_CMD_SPEED_MULT
:{
2726 float v
= cmd
->args
[0].v
.f
;
2727 opts
->playback_speed
*= v
;
2728 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2729 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2730 opts
->playback_speed
);
2733 case MP_CMD_SPEED_SET
:{
2734 float v
= cmd
->args
[0].v
.f
;
2735 opts
->playback_speed
= v
;
2736 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2737 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2738 opts
->playback_speed
);
2741 case MP_CMD_FRAME_STEP
:
2742 add_step_frame(mpctx
);
2745 case MP_CMD_FILE_FILTER
:
2746 file_filter
= cmd
->args
[0].v
.i
;
2750 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2751 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2753 case MP_CMD_PLAY_TREE_STEP
:{
2754 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2755 int force
= cmd
->args
[1].v
.i
;
2758 if (!force
&& mpctx
->playtree_iter
) {
2759 play_tree_iter_t
*i
=
2760 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2761 if (play_tree_iter_step(i
, n
, 0) ==
2762 PLAY_TREE_ITER_ENTRY
)
2764 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2765 play_tree_iter_free(i
);
2767 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2768 if (mpctx
->stop_play
)
2769 mpctx
->play_tree_step
= n
;
2774 case MP_CMD_PLAY_TREE_UP_STEP
:{
2775 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2776 int force
= cmd
->args
[1].v
.i
;
2778 if (!force
&& mpctx
->playtree_iter
) {
2779 play_tree_iter_t
*i
=
2780 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2781 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2782 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2783 play_tree_iter_free(i
);
2785 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2789 case MP_CMD_PLAY_ALT_SRC_STEP
:
2790 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2791 int v
= cmd
->args
[0].v
.i
;
2793 && mpctx
->playtree_iter
->file
<
2794 mpctx
->playtree_iter
->num_files
)
2795 mpctx
->stop_play
= PT_NEXT_SRC
;
2796 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2797 mpctx
->stop_play
= PT_PREV_SRC
;
2801 case MP_CMD_SUB_STEP
:
2803 int movement
= cmd
->args
[0].v
.i
;
2804 step_sub(subdata
, sh_video
->pts
, movement
);
2808 ass_step_sub(ass_track
,
2810 sub_delay
) * 1000 + .5, movement
) / 1000.;
2812 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2813 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2817 case MP_CMD_SUB_LOG
:
2822 int v
= cmd
->args
[0].v
.i
;
2824 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2825 if (opts
->osd_level
> max
)
2826 opts
->osd_level
= max
;
2828 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2830 opts
->osd_level
= v
> max
? max
: v
;
2831 /* Show OSD state when disabled, but not when an explicit
2832 argument is given to the OSD command, i.e. in slave mode. */
2833 if (v
== -1 && opts
->osd_level
<= 1)
2834 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2836 opts
->osd_level
? mp_gtext("enabled") :
2837 mp_gtext("disabled"));
2839 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2843 case MP_CMD_OSD_SHOW_TEXT
:
2844 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2846 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2847 "%-.63s", cmd
->args
[0].v
.s
);
2850 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2851 char *txt
= m_properties_expand_string(mp_properties
,
2854 /* if no argument supplied take default osd_duration, else <arg> ms. */
2856 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2858 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2865 case MP_CMD_LOADFILE
:{
2866 play_tree_t
*e
= play_tree_new();
2867 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2869 if (cmd
->args
[1].v
.i
) // append
2870 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2872 // Go back to the starting point.
2873 while (play_tree_iter_up_step
2874 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2876 play_tree_free_list(mpctx
->playtree
->child
, 1);
2877 play_tree_set_child(mpctx
->playtree
, e
);
2878 pt_iter_goto_head(mpctx
->playtree_iter
);
2879 mpctx
->stop_play
= PT_NEXT_SRC
;
2884 case MP_CMD_LOADLIST
:{
2885 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2887 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2888 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2890 if (cmd
->args
[1].v
.i
) // append
2891 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2893 // Go back to the starting point.
2894 while (play_tree_iter_up_step
2895 (mpctx
->playtree_iter
, 0, 1)
2896 != PLAY_TREE_ITER_END
)
2898 play_tree_free_list(mpctx
->playtree
->child
, 1);
2899 play_tree_set_child(mpctx
->playtree
, e
);
2900 pt_iter_goto_head(mpctx
->playtree_iter
);
2901 mpctx
->stop_play
= PT_NEXT_SRC
;
2908 // Go back to the starting point.
2909 while (play_tree_iter_up_step
2910 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2912 mpctx
->stop_play
= PT_STOP
;
2915 case MP_CMD_OSD_SHOW_PROGRESSION
:{
2916 int len
= demuxer_get_time_length(mpctx
->demuxer
);
2917 int pts
= demuxer_get_current_time(mpctx
->demuxer
);
2918 set_osd_bar(mpctx
, 0, "Position", 0, 100, demuxer_get_percent_pos(mpctx
->demuxer
));
2919 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2920 "%c %02d:%02d:%02d / %02d:%02d:%02d",
2921 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
2922 len
/3600, (len
/60)%60, len
%60);
2927 case MP_CMD_RADIO_STEP_CHANNEL
:
2928 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2929 int v
= cmd
->args
[0].v
.i
;
2931 radio_step_channel(mpctx
->demuxer
->stream
,
2932 RADIO_CHANNEL_HIGHER
);
2934 radio_step_channel(mpctx
->demuxer
->stream
,
2935 RADIO_CHANNEL_LOWER
);
2936 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2937 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2939 radio_get_channel_name(mpctx
->demuxer
->stream
));
2944 case MP_CMD_RADIO_SET_CHANNEL
:
2945 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2946 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2947 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2948 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2950 radio_get_channel_name(mpctx
->demuxer
->stream
));
2955 case MP_CMD_RADIO_SET_FREQ
:
2956 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2957 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2960 case MP_CMD_RADIO_STEP_FREQ
:
2961 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2962 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2967 case MP_CMD_TV_START_SCAN
:
2968 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2969 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2971 case MP_CMD_TV_SET_FREQ
:
2972 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2973 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2974 cmd
->args
[0].v
.f
* 16.0);
2976 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2977 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2978 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2979 pvr_get_current_channelname (mpctx
->stream
),
2980 pvr_get_current_stationname (mpctx
->stream
));
2982 #endif /* CONFIG_PVR */
2985 case MP_CMD_TV_STEP_FREQ
:
2986 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2987 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2988 cmd
->args
[0].v
.f
* 16.0);
2990 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2991 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2992 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2993 pvr_get_current_channelname (mpctx
->stream
),
2994 pvr_get_current_frequency (mpctx
->stream
));
2996 #endif /* CONFIG_PVR */
2999 case MP_CMD_TV_SET_NORM
:
3000 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3001 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3005 case MP_CMD_TV_STEP_CHANNEL
:{
3006 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3007 int v
= cmd
->args
[0].v
.i
;
3009 tv_step_channel((tvi_handle_t
*) (mpctx
->
3013 tv_step_channel((tvi_handle_t
*) (mpctx
->
3017 if (tv_channel_list
) {
3018 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3019 "Channel: %s", tv_channel_current
->name
);
3020 //vo_osd_changed(OSDTYPE_SUBTITLE);
3024 else if (mpctx
->stream
&&
3025 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3026 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3027 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3028 pvr_get_current_channelname (mpctx
->stream
),
3029 pvr_get_current_stationname (mpctx
->stream
));
3031 #endif /* CONFIG_PVR */
3034 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3036 int v
= cmd
->args
[0].v
.i
;
3038 mpctx
->last_dvb_step
= v
;
3040 dir
= DVB_CHANNEL_HIGHER
;
3042 dir
= DVB_CHANNEL_LOWER
;
3045 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3046 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3047 mpctx
->dvbin_reopen
= 1;
3050 #endif /* CONFIG_DVBIN */
3053 case MP_CMD_TV_SET_CHANNEL
:
3054 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3055 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3057 if (tv_channel_list
) {
3058 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3059 "Channel: %s", tv_channel_current
->name
);
3060 //vo_osd_changed(OSDTYPE_SUBTITLE);
3064 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3065 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3066 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3067 pvr_get_current_channelname (mpctx
->stream
),
3068 pvr_get_current_stationname (mpctx
->stream
));
3070 #endif /* CONFIG_PVR */
3074 case MP_CMD_DVB_SET_CHANNEL
:
3075 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3076 mpctx
->last_dvb_step
= 1;
3078 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3079 cmd
->args
[0].v
.i
)) {
3080 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3081 mpctx
->dvbin_reopen
= 1;
3085 #endif /* CONFIG_DVBIN */
3087 case MP_CMD_TV_LAST_CHANNEL
:
3088 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3089 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3090 if (tv_channel_list
) {
3091 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3092 "Channel: %s", tv_channel_current
->name
);
3093 //vo_osd_changed(OSDTYPE_SUBTITLE);
3097 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3098 pvr_set_lastchannel (mpctx
->stream
);
3099 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3100 pvr_get_current_channelname (mpctx
->stream
),
3101 pvr_get_current_stationname (mpctx
->stream
));
3103 #endif /* CONFIG_PVR */
3106 case MP_CMD_TV_STEP_NORM
:
3107 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3108 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3111 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3112 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3113 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3115 #endif /* CONFIG_TV */
3116 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3118 if (mpctx
->demuxer
->teletext
)
3119 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3120 &(cmd
->args
[0].v
.s
));
3123 case MP_CMD_TV_TELETEXT_GO_LINK
:
3125 if (mpctx
->demuxer
->teletext
)
3126 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3127 &(cmd
->args
[0].v
.i
));
3131 case MP_CMD_SUB_LOAD
:
3133 int n
= mpctx
->set_of_sub_size
;
3134 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3135 if (n
!= mpctx
->set_of_sub_size
) {
3136 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
3137 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
3138 mpctx
->global_sub_size
;
3139 ++mpctx
->global_sub_size
;
3144 case MP_CMD_SUB_REMOVE
:
3146 int v
= cmd
->args
[0].v
.i
;
3148 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3149 } else if (v
< mpctx
->set_of_sub_size
) {
3150 remove_subtitle_range(mpctx
, v
, 1);
3155 case MP_CMD_GET_SUB_VISIBILITY
:
3157 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3158 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3162 case MP_CMD_SCREENSHOT
:
3163 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3164 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3166 ((vf_instance_t
*) sh_video
->vfilter
)->
3167 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3169 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3173 case MP_CMD_VF_CHANGE_RECTANGLE
:
3176 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3179 case MP_CMD_GET_TIME_LENGTH
:{
3180 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3181 demuxer_get_time_length(mpctx
->demuxer
));
3185 case MP_CMD_GET_FILENAME
:{
3186 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3187 get_metadata(mpctx
, META_NAME
));
3191 case MP_CMD_GET_VIDEO_CODEC
:{
3192 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3195 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3200 case MP_CMD_GET_VIDEO_BITRATE
:{
3201 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3204 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3209 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3210 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3213 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3214 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3219 case MP_CMD_GET_AUDIO_CODEC
:{
3220 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3223 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3228 case MP_CMD_GET_AUDIO_BITRATE
:{
3229 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3232 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3237 case MP_CMD_GET_AUDIO_SAMPLES
:{
3238 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3241 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3246 case MP_CMD_GET_META_TITLE
:{
3247 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3250 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3255 case MP_CMD_GET_META_ARTIST
:{
3256 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3259 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3264 case MP_CMD_GET_META_ALBUM
:{
3265 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3268 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3273 case MP_CMD_GET_META_YEAR
:{
3274 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3277 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3282 case MP_CMD_GET_META_COMMENT
:{
3283 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3286 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3291 case MP_CMD_GET_META_TRACK
:{
3292 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3295 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3300 case MP_CMD_GET_META_GENRE
:{
3301 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3304 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3309 case MP_CMD_GET_VO_FULLSCREEN
:
3310 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3311 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3314 case MP_CMD_GET_PERCENT_POS
:
3315 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3316 demuxer_get_percent_pos(mpctx
->demuxer
));
3319 case MP_CMD_GET_TIME_POS
:{
3322 pos
= sh_video
->pts
;
3323 else if (sh_audio
&& mpctx
->audio_out
)
3324 pos
= playing_audio_pts(mpctx
);
3325 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3332 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3338 case MP_CMD_KEYDOWN_EVENTS
:
3339 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3342 case MP_CMD_SET_MOUSE_POS
:{
3343 int pointer_x
, pointer_y
;
3345 pointer_x
= cmd
->args
[0].v
.i
;
3346 pointer_y
= cmd
->args
[1].v
.i
;
3347 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3348 #ifdef CONFIG_DVDNAV
3349 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3350 && dx
> 0.0 && dy
> 0.0) {
3352 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3353 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3354 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3355 pointer_x
, pointer_y
, &button
);
3356 if (opts
->osd_level
> 1 && button
> 0)
3357 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3358 "Selected button number %d", button
);
3362 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3363 menu_update_mouse_pos(dx
, dy
);
3368 #ifdef CONFIG_DVDNAV
3369 case MP_CMD_DVDNAV
:{
3372 mp_command_type command
= 0;
3373 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3376 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3377 if (cmd
->args
[0].v
.s
&&
3378 !strcasecmp (cmd
->args
[0].v
.s
,
3379 mp_dvdnav_bindings
[i
].name
))
3380 command
= mp_dvdnav_bindings
[i
].cmd
;
3382 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3383 if (opts
->osd_level
> 1 && button
> 0)
3384 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3385 "Selected button number %d", button
);
3389 case MP_CMD_SWITCH_TITLE
:
3390 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3391 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3396 case MP_CMD_AF_SWITCH
:
3399 af_uninit(mpctx
->mixer
.afilter
);
3400 af_init(mpctx
->mixer
.afilter
);
3407 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3408 char* af_commands
= af_args
;
3411 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3413 if (cmd
->id
== MP_CMD_AF_DEL
)
3415 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3417 af_remove(mpctx
->mixer
.afilter
, af
);
3420 af_add(mpctx
->mixer
.afilter
, af_command
);
3422 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3429 af_uninit(mpctx
->mixer
.afilter
);
3430 af_init(mpctx
->mixer
.afilter
);
3431 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3434 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3435 "Received unknown cmd %s\n", cmd
->name
);
3438 switch (cmd
->pausing
) {
3439 case 1: // "pausing"
3440 pause_player(mpctx
);
3442 case 3: // "pausing_toggle"
3444 unpause_player(mpctx
);
3446 pause_player(mpctx
);