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
,
854 struct MPOpts
*opts
= &mpctx
->opts
;
856 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
857 return M_PROPERTY_UNAVAILABLE
;
858 current_id
= mpctx
->demuxer
->audio
->id
;
863 return M_PROPERTY_ERROR
;
864 *(int *) arg
= current_id
;
865 return M_PROPERTY_OK
;
866 case M_PROPERTY_PRINT
:
868 return M_PROPERTY_ERROR
;
871 *(char **) arg
= strdup(mp_gtext("disabled"));
874 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
875 sh_audio_t
* sh
= mpctx
->sh_audio
;
877 av_strlcpy(lang
, sh
->lang
, 40);
878 #ifdef CONFIG_DVDREAD
879 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
880 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
890 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
891 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
893 *(char **) arg
= malloc(64);
894 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
896 return M_PROPERTY_OK
;
898 case M_PROPERTY_STEP_UP
:
900 if (action
== M_PROPERTY_SET
&& arg
)
901 tmp
= *((int *) arg
);
904 opts
->audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
905 if (opts
->audio_id
== -2
906 || (opts
->audio_id
> -1
907 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
908 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
909 if (opts
->audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
911 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
913 sh2
->ds
= mpctx
->demuxer
->audio
;
914 mpctx
->sh_audio
= sh2
;
915 reinit_audio_chain(mpctx
);
918 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", opts
->audio_id
);
919 return M_PROPERTY_OK
;
921 return M_PROPERTY_NOT_IMPLEMENTED
;
926 /// Selected video id (RW)
927 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
930 struct MPOpts
*opts
= &mpctx
->opts
;
932 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
933 return M_PROPERTY_UNAVAILABLE
;
934 current_id
= mpctx
->demuxer
->video
->id
;
939 return M_PROPERTY_ERROR
;
940 *(int *) arg
= current_id
;
941 return M_PROPERTY_OK
;
942 case M_PROPERTY_PRINT
:
944 return M_PROPERTY_ERROR
;
947 *(char **) arg
= strdup(mp_gtext("disabled"));
950 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
951 *(char **) arg
= malloc(64);
952 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
954 return M_PROPERTY_OK
;
956 case M_PROPERTY_STEP_UP
:
958 if (action
== M_PROPERTY_SET
&& arg
)
959 tmp
= *((int *) arg
);
962 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
963 if (opts
->video_id
== -2
964 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
965 && current_id
!= -2))
966 uninit_player(mpctx
, INITIALIZED_VCODEC
|
967 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
968 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
970 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
972 sh2
->ds
= mpctx
->demuxer
->video
;
973 mpctx
->sh_video
= sh2
;
974 reinit_video_chain(mpctx
);
977 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
978 return M_PROPERTY_OK
;
981 return M_PROPERTY_NOT_IMPLEMENTED
;
985 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
988 demux_program_t prog
;
991 case M_PROPERTY_STEP_UP
:
993 if (action
== M_PROPERTY_SET
&& arg
)
994 prog
.progid
= *((int *) arg
);
998 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
999 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1000 return M_PROPERTY_ERROR
;
1002 if (prog
.aid
< 0 && prog
.vid
< 0) {
1003 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1004 return M_PROPERTY_ERROR
;
1006 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1007 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1008 return M_PROPERTY_OK
;
1011 return M_PROPERTY_NOT_IMPLEMENTED
;
1017 /// \defgroup VideoProperties Video properties
1018 /// \ingroup Properties
1021 /// Fullscreen state (RW)
1022 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1026 if (!mpctx
->video_out
)
1027 return M_PROPERTY_UNAVAILABLE
;
1030 case M_PROPERTY_SET
:
1032 return M_PROPERTY_ERROR
;
1033 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1034 if (vo_fs
== !!*(int *) arg
)
1035 return M_PROPERTY_OK
;
1036 case M_PROPERTY_STEP_UP
:
1037 case M_PROPERTY_STEP_DOWN
:
1038 if (mpctx
->video_out
->config_ok
)
1039 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1040 mpctx
->opts
.fullscreen
= vo_fs
;
1041 return M_PROPERTY_OK
;
1043 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1047 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1048 void *arg
, MPContext
*mpctx
)
1052 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1053 return M_PROPERTY_UNAVAILABLE
;
1054 vf
= mpctx
->sh_video
->vfilter
;
1056 case M_PROPERTY_GET
:
1058 return M_PROPERTY_ERROR
;
1059 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1060 return M_PROPERTY_OK
;
1061 case M_PROPERTY_SET
:
1063 return M_PROPERTY_ERROR
;
1064 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1065 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1066 return M_PROPERTY_OK
;
1067 case M_PROPERTY_STEP_UP
:
1068 case M_PROPERTY_STEP_DOWN
:
1069 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1070 deinterlace
= !deinterlace
;
1071 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1072 return M_PROPERTY_OK
;
1075 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1076 return m_property_flag_ro(prop
, action
, arg
, value
);
1079 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1080 void *arg
, MPContext
*mpctx
)
1082 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1083 return M_PROPERTY_UNAVAILABLE
;
1085 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1088 case M_PROPERTY_GET
:
1090 return M_PROPERTY_ERROR
;
1091 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1092 return M_PROPERTY_UNAVAILABLE
;
1093 return M_PROPERTY_OK
;
1094 case M_PROPERTY_PRINT
:
1096 return M_PROPERTY_ERROR
;
1097 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1098 return M_PROPERTY_UNAVAILABLE
;
1099 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1100 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1101 *(char **)arg
= strdup("Unknown");
1103 *(char**)arg
= strdup(names
[colorspace
]);
1104 return M_PROPERTY_OK
;
1105 case M_PROPERTY_SET
:
1107 return M_PROPERTY_ERROR
;
1108 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1109 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1110 return M_PROPERTY_OK
;
1111 case M_PROPERTY_STEP_UP
:;
1112 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1113 return M_PROPERTY_UNAVAILABLE
;
1115 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1116 return M_PROPERTY_OK
;
1118 return M_PROPERTY_NOT_IMPLEMENTED
;
1122 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1126 if (!mpctx
->video_out
1127 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1128 return M_PROPERTY_UNAVAILABLE
;
1131 case M_PROPERTY_SET
:
1133 return M_PROPERTY_ERROR
;
1134 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1135 vo_panscan
= *(float *) arg
;
1136 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1137 return M_PROPERTY_OK
;
1138 case M_PROPERTY_STEP_UP
:
1139 case M_PROPERTY_STEP_DOWN
:
1140 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1141 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1144 else if (vo_panscan
< 0)
1146 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1147 return M_PROPERTY_OK
;
1149 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1153 /// Helper to set vo flags.
1154 /** \ingroup PropertyImplHelper
1156 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1157 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1160 if (!mpctx
->video_out
)
1161 return M_PROPERTY_UNAVAILABLE
;
1164 case M_PROPERTY_SET
:
1166 return M_PROPERTY_ERROR
;
1167 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1168 if (*vo_var
== !!*(int *) arg
)
1169 return M_PROPERTY_OK
;
1170 case M_PROPERTY_STEP_UP
:
1171 case M_PROPERTY_STEP_DOWN
:
1172 if (mpctx
->video_out
->config_ok
)
1173 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1174 return M_PROPERTY_OK
;
1176 return m_property_flag(prop
, action
, arg
, vo_var
);
1180 /// Window always on top (RW)
1181 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1184 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1185 &mpctx
->opts
.vo_ontop
, mpctx
);
1188 /// Display in the root window (RW)
1189 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1192 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1193 &vo_rootwin
, mpctx
);
1196 /// Show window borders (RW)
1197 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1200 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1204 /// Framedropping state (RW)
1205 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1206 void *arg
, MPContext
*mpctx
)
1209 if (!mpctx
->sh_video
)
1210 return M_PROPERTY_UNAVAILABLE
;
1213 case M_PROPERTY_PRINT
:
1215 return M_PROPERTY_ERROR
;
1216 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1217 (frame_dropping
== 2 ? mp_gtext("hard") :
1218 mp_gtext("disabled")));
1219 return M_PROPERTY_OK
;
1221 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1225 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1226 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1229 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1232 if (!mpctx
->sh_video
)
1233 return M_PROPERTY_UNAVAILABLE
;
1235 if (gamma
[0] == 1000) {
1237 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1241 case M_PROPERTY_SET
:
1243 return M_PROPERTY_ERROR
;
1244 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1245 *gamma
= *(int *) arg
;
1246 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1250 case M_PROPERTY_GET
:
1251 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1253 return M_PROPERTY_ERROR
;
1255 return M_PROPERTY_OK
;
1258 case M_PROPERTY_STEP_UP
:
1259 case M_PROPERTY_STEP_DOWN
:
1260 *gamma
+= (arg
? *(int *) arg
: 1) *
1261 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1262 M_PROPERTY_CLAMP(prop
, *gamma
);
1263 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1268 return M_PROPERTY_NOT_IMPLEMENTED
;
1272 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1273 int l
= strlen(prop
->name
);
1274 char tv_prop
[3 + l
+ 1];
1275 sprintf(tv_prop
, "tv_%s", prop
->name
);
1276 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1280 return M_PROPERTY_UNAVAILABLE
;
1284 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1287 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1290 /// Video codec tag (RO)
1291 static int mp_property_video_format(m_option_t
*prop
, int action
,
1292 void *arg
, MPContext
*mpctx
)
1295 if (!mpctx
->sh_video
)
1296 return M_PROPERTY_UNAVAILABLE
;
1298 case M_PROPERTY_PRINT
:
1300 return M_PROPERTY_ERROR
;
1301 switch(mpctx
->sh_video
->format
) {
1303 meta
= strdup ("mpeg1"); break;
1305 meta
= strdup ("mpeg2"); break;
1307 meta
= strdup ("mpeg4"); break;
1309 meta
= strdup ("h264"); break;
1311 if(mpctx
->sh_video
->format
>= 0x20202020) {
1313 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1316 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1319 *(char**)arg
= meta
;
1320 return M_PROPERTY_OK
;
1322 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1325 /// Video codec name (RO)
1326 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1327 void *arg
, MPContext
*mpctx
)
1329 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1330 return M_PROPERTY_UNAVAILABLE
;
1331 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1335 /// Video bitrate (RO)
1336 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1337 void *arg
, MPContext
*mpctx
)
1339 if (!mpctx
->sh_video
)
1340 return M_PROPERTY_UNAVAILABLE
;
1341 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1344 /// Video display width (RO)
1345 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1348 if (!mpctx
->sh_video
)
1349 return M_PROPERTY_UNAVAILABLE
;
1350 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1353 /// Video display height (RO)
1354 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1357 if (!mpctx
->sh_video
)
1358 return M_PROPERTY_UNAVAILABLE
;
1359 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1363 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1366 if (!mpctx
->sh_video
)
1367 return M_PROPERTY_UNAVAILABLE
;
1368 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1371 /// Video aspect (RO)
1372 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1375 if (!mpctx
->sh_video
)
1376 return M_PROPERTY_UNAVAILABLE
;
1377 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1382 /// \defgroup SubProprties Subtitles properties
1383 /// \ingroup Properties
1386 /// Text subtitle position (RW)
1387 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1391 case M_PROPERTY_SET
:
1393 return M_PROPERTY_ERROR
;
1394 case M_PROPERTY_STEP_UP
:
1395 case M_PROPERTY_STEP_DOWN
:
1396 vo_osd_changed(OSDTYPE_SUBTITLE
);
1398 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1402 /// Selected subtitles (RW)
1403 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1406 struct MPOpts
*opts
= &mpctx
->opts
;
1407 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1408 const int global_sub_size
= mpctx
->global_sub_size
;
1409 int source
= -1, reset_spu
= 0;
1412 if (global_sub_size
<= 0)
1413 return M_PROPERTY_UNAVAILABLE
;
1416 case M_PROPERTY_GET
:
1418 return M_PROPERTY_ERROR
;
1419 *(int *) arg
= mpctx
->global_sub_pos
;
1420 return M_PROPERTY_OK
;
1421 case M_PROPERTY_PRINT
:
1423 return M_PROPERTY_ERROR
;
1424 *(char **) arg
= malloc(64);
1425 (*(char **) arg
)[63] = 0;
1428 sub_name
= subdata
->filename
;
1430 if (ass_track
&& ass_track
->name
)
1431 sub_name
= ass_track
->name
;
1436 if ((tmp2
= strrchr(tmp
, '/')))
1439 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1440 mpctx
->set_of_sub_pos
+ 1,
1441 strlen(tmp
) < 20 ? "" : "...",
1442 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1443 return M_PROPERTY_OK
;
1445 #ifdef CONFIG_DVDNAV
1446 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1447 if (vo_spudec
&& opts
->sub_id
>= 0) {
1448 unsigned char lang
[3];
1449 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1450 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1451 return M_PROPERTY_OK
;
1457 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1458 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1459 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1460 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1461 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1462 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1463 if (!lang
) lang
= mp_gtext("unknown");
1464 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1465 return M_PROPERTY_OK
;
1468 if (vo_vobsub
&& vobsub_id
>= 0) {
1469 const char *language
= mp_gtext("unknown");
1470 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1471 snprintf(*(char **) arg
, 63, "(%d) %s",
1472 vobsub_id
, language
? language
: mp_gtext("unknown"));
1473 return M_PROPERTY_OK
;
1475 #ifdef CONFIG_DVDREAD
1476 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1477 && opts
->sub_id
>= 0) {
1479 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1480 lang
[0] = code
>> 8;
1483 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1484 return M_PROPERTY_OK
;
1487 if (opts
->sub_id
>= 0) {
1488 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1489 mp_gtext("unknown"));
1490 return M_PROPERTY_OK
;
1492 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1493 return M_PROPERTY_OK
;
1495 case M_PROPERTY_SET
:
1497 return M_PROPERTY_ERROR
;
1498 if (*(int *) arg
< -1)
1500 else if (*(int *) arg
>= global_sub_size
)
1501 *(int *) arg
= global_sub_size
- 1;
1502 mpctx
->global_sub_pos
= *(int *) arg
;
1504 case M_PROPERTY_STEP_UP
:
1505 mpctx
->global_sub_pos
+= 2;
1506 mpctx
->global_sub_pos
=
1507 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1509 case M_PROPERTY_STEP_DOWN
:
1510 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1511 mpctx
->global_sub_pos
=
1512 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1515 return M_PROPERTY_NOT_IMPLEMENTED
;
1518 if (mpctx
->global_sub_pos
>= 0)
1519 source
= sub_source(mpctx
);
1521 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1522 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1524 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1525 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1526 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1527 mpctx
->global_sub_pos
, source
);
1529 mpctx
->set_of_sub_pos
= -1;
1543 if (source
== SUB_SOURCE_VOBSUB
) {
1544 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1545 } else if (source
== SUB_SOURCE_SUBS
) {
1546 mpctx
->set_of_sub_pos
=
1547 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1549 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1550 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1554 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1555 vo_osd_changed(OSDTYPE_SUBTITLE
);
1557 } else if (source
== SUB_SOURCE_DEMUX
) {
1559 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1560 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1562 // default: assume 1:1 mapping of sid and stream id
1563 d_sub
->id
= opts
->sub_id
;
1564 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1565 ds_free_packs(d_sub
);
1566 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1567 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1568 if (sh
&& sh
->sid
== opts
->sub_id
) {
1574 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1575 sh_sub_t
*sh
= d_sub
->sh
;
1576 if (sh
->type
== 'v')
1577 init_vo_spudec(mpctx
);
1579 else if (opts
->ass_enabled
)
1580 ass_track
= sh
->ass_track
;
1588 #ifdef CONFIG_DVDREAD
1590 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1591 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1592 && opts
->sub_id
< 0 && reset_spu
) {
1598 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1600 return M_PROPERTY_OK
;
1603 /// Selected sub source (RW)
1604 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1608 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1609 return M_PROPERTY_UNAVAILABLE
;
1612 case M_PROPERTY_GET
:
1614 return M_PROPERTY_ERROR
;
1615 *(int *) arg
= sub_source(mpctx
);
1616 return M_PROPERTY_OK
;
1617 case M_PROPERTY_PRINT
:
1619 return M_PROPERTY_ERROR
;
1620 *(char **) arg
= malloc(64);
1621 (*(char **) arg
)[63] = 0;
1622 switch (sub_source(mpctx
))
1624 case SUB_SOURCE_SUBS
:
1625 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1627 case SUB_SOURCE_VOBSUB
:
1628 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1630 case SUB_SOURCE_DEMUX
:
1631 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1634 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1636 return M_PROPERTY_OK
;
1637 case M_PROPERTY_SET
:
1639 return M_PROPERTY_ERROR
;
1640 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1641 if (*(int *) arg
< 0)
1642 mpctx
->global_sub_pos
= -1;
1643 else if (*(int *) arg
!= sub_source(mpctx
)) {
1644 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1645 return M_PROPERTY_UNAVAILABLE
;
1646 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1649 case M_PROPERTY_STEP_UP
:
1650 case M_PROPERTY_STEP_DOWN
: {
1651 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1652 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1653 int step
= (step_all
> 0) ? 1 : -1;
1654 int cur_source
= sub_source(mpctx
);
1655 source
= cur_source
;
1658 if (source
>= SUB_SOURCES
)
1660 else if (source
< -1)
1661 source
= SUB_SOURCES
- 1;
1662 if (source
== cur_source
|| source
== -1 ||
1663 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1666 if (source
== cur_source
)
1667 return M_PROPERTY_OK
;
1669 mpctx
->global_sub_pos
= -1;
1671 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1675 return M_PROPERTY_NOT_IMPLEMENTED
;
1677 --mpctx
->global_sub_pos
;
1678 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1681 /// Selected subtitles from specific source (RW)
1682 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1685 int source
, is_cur_source
, offset
;
1686 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1687 return M_PROPERTY_UNAVAILABLE
;
1689 if (!strcmp(prop
->name
, "sub_file"))
1690 source
= SUB_SOURCE_SUBS
;
1691 else if (!strcmp(prop
->name
, "sub_vob"))
1692 source
= SUB_SOURCE_VOBSUB
;
1693 else if (!strcmp(prop
->name
, "sub_demux"))
1694 source
= SUB_SOURCE_DEMUX
;
1696 return M_PROPERTY_ERROR
;
1698 offset
= mpctx
->global_sub_indices
[source
];
1699 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1700 return M_PROPERTY_UNAVAILABLE
;
1702 is_cur_source
= sub_source(mpctx
) == source
;
1704 case M_PROPERTY_GET
:
1706 return M_PROPERTY_ERROR
;
1707 if (is_cur_source
) {
1708 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1709 if (source
== SUB_SOURCE_VOBSUB
)
1710 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1714 return M_PROPERTY_OK
;
1715 case M_PROPERTY_PRINT
:
1717 return M_PROPERTY_ERROR
;
1719 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1720 *(char **) arg
= malloc(64);
1721 (*(char **) arg
)[63] = 0;
1722 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1723 return M_PROPERTY_OK
;
1724 case M_PROPERTY_SET
:
1726 return M_PROPERTY_ERROR
;
1727 if (*(int *) arg
>= 0) {
1728 int index
= *(int *)arg
;
1729 if (source
== SUB_SOURCE_VOBSUB
)
1730 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1731 mpctx
->global_sub_pos
= offset
+ index
;
1732 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1733 || sub_source(mpctx
) != source
) {
1734 mpctx
->global_sub_pos
= -1;
1739 mpctx
->global_sub_pos
= -1;
1741 case M_PROPERTY_STEP_UP
:
1742 case M_PROPERTY_STEP_DOWN
: {
1743 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1744 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1745 int step
= (step_all
> 0) ? 1 : -1;
1746 int max_sub_pos_for_source
= -1;
1748 mpctx
->global_sub_pos
= -1;
1750 if (mpctx
->global_sub_pos
== -1) {
1752 mpctx
->global_sub_pos
= offset
;
1753 else if (max_sub_pos_for_source
== -1) {
1754 // Find max pos for specific source
1755 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1756 while (mpctx
->global_sub_pos
>= 0
1757 && sub_source(mpctx
) != source
)
1758 --mpctx
->global_sub_pos
;
1761 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1764 mpctx
->global_sub_pos
+= step
;
1765 if (mpctx
->global_sub_pos
< offset
||
1766 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1767 sub_source(mpctx
) != source
)
1768 mpctx
->global_sub_pos
= -1;
1775 return M_PROPERTY_NOT_IMPLEMENTED
;
1777 --mpctx
->global_sub_pos
;
1778 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1781 /// Subtitle delay (RW)
1782 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1785 if (!mpctx
->sh_video
)
1786 return M_PROPERTY_UNAVAILABLE
;
1787 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1790 /// Alignment of text subtitles (RW)
1791 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1792 void *arg
, MPContext
*mpctx
)
1794 char *name
[] = { _("top"), _("center"), _("bottom") };
1796 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1797 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1798 return M_PROPERTY_UNAVAILABLE
;
1801 case M_PROPERTY_PRINT
:
1803 return M_PROPERTY_ERROR
;
1804 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1805 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1806 return M_PROPERTY_OK
;
1807 case M_PROPERTY_SET
:
1809 return M_PROPERTY_ERROR
;
1810 case M_PROPERTY_STEP_UP
:
1811 case M_PROPERTY_STEP_DOWN
:
1812 vo_osd_changed(OSDTYPE_SUBTITLE
);
1814 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1818 /// Subtitle visibility (RW)
1819 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1820 void *arg
, MPContext
*mpctx
)
1822 if (!mpctx
->sh_video
)
1823 return M_PROPERTY_UNAVAILABLE
;
1826 case M_PROPERTY_SET
:
1828 return M_PROPERTY_ERROR
;
1829 case M_PROPERTY_STEP_UP
:
1830 case M_PROPERTY_STEP_DOWN
:
1831 vo_osd_changed(OSDTYPE_SUBTITLE
);
1833 vo_osd_changed(OSDTYPE_SPU
);
1835 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1840 /// Use margins for libass subtitles (RW)
1841 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1842 void *arg
, MPContext
*mpctx
)
1844 if (!mpctx
->sh_video
)
1845 return M_PROPERTY_UNAVAILABLE
;
1848 case M_PROPERTY_SET
:
1850 return M_PROPERTY_ERROR
;
1851 case M_PROPERTY_STEP_UP
:
1852 case M_PROPERTY_STEP_DOWN
:
1853 ass_force_reload
= 1;
1855 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1860 /// Show only forced subtitles (RW)
1861 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1862 void *arg
, MPContext
*mpctx
)
1865 return M_PROPERTY_UNAVAILABLE
;
1868 case M_PROPERTY_SET
:
1870 return M_PROPERTY_ERROR
;
1871 case M_PROPERTY_STEP_UP
:
1872 case M_PROPERTY_STEP_DOWN
:
1873 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1874 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1875 return M_PROPERTY_OK
;
1877 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1882 #ifdef CONFIG_FREETYPE
1883 /// Subtitle scale (RW)
1884 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1887 struct MPOpts
*opts
= &mpctx
->opts
;
1890 case M_PROPERTY_SET
:
1892 return M_PROPERTY_ERROR
;
1893 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1895 if (opts
->ass_enabled
) {
1896 ass_font_scale
= *(float *) arg
;
1897 ass_force_reload
= 1;
1900 text_font_scale_factor
= *(float *) arg
;
1901 force_load_font
= 1;
1902 return M_PROPERTY_OK
;
1903 case M_PROPERTY_STEP_UP
:
1904 case M_PROPERTY_STEP_DOWN
:
1906 if (opts
->ass_enabled
) {
1907 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1908 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1909 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1910 ass_force_reload
= 1;
1913 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1914 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1915 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1916 force_load_font
= 1;
1917 return M_PROPERTY_OK
;
1920 if (opts
->ass_enabled
)
1921 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1924 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1931 /// \defgroup TVProperties TV properties
1932 /// \ingroup Properties
1937 /// TV color settings (RW)
1938 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1942 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1943 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1944 return M_PROPERTY_UNAVAILABLE
;
1947 case M_PROPERTY_SET
:
1949 return M_PROPERTY_ERROR
;
1950 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1951 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1952 case M_PROPERTY_GET
:
1953 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1954 case M_PROPERTY_STEP_UP
:
1955 case M_PROPERTY_STEP_DOWN
:
1956 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1958 return M_PROPERTY_ERROR
;
1959 val
+= (arg
? *(int *) arg
: 1) *
1960 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1961 M_PROPERTY_CLAMP(prop
, val
);
1962 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1964 return M_PROPERTY_ERROR
;
1966 return M_PROPERTY_NOT_IMPLEMENTED
;
1971 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
1975 int base_ioctl
=(int)prop
->priv
;
1977 for teletext's GET,SET,STEP ioctls this is not 0
1981 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1982 return M_PROPERTY_UNAVAILABLE
;
1984 return M_PROPERTY_ERROR
;
1987 case M_PROPERTY_GET
:
1989 return M_PROPERTY_ERROR
;
1990 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1992 case M_PROPERTY_SET
:
1994 return M_PROPERTY_ERROR
;
1995 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1996 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1998 case M_PROPERTY_STEP_UP
:
1999 case M_PROPERTY_STEP_DOWN
:
2000 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2001 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2002 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2005 return M_PROPERTY_NOT_IMPLEMENTED
;
2008 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2011 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2017 //with tvh==NULL will fail too
2018 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2019 if(result
!=M_PROPERTY_OK
)
2022 if(teletext_control(mpctx
->demuxer
->teletext
,
2023 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
2024 mp_input_set_section(mpctx
->input
, "teletext");
2026 mp_input_set_section(mpctx
->input
, "tv");
2027 return M_PROPERTY_OK
;
2030 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2035 if (!mpctx
->demuxer
->teletext
)
2036 return M_PROPERTY_UNAVAILABLE
;
2038 case M_PROPERTY_STEP_UP
:
2039 case M_PROPERTY_STEP_DOWN
:
2040 //This should be handled separately
2041 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2042 result
=teletext_control(mpctx
->demuxer
->teletext
,
2043 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2046 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2053 /// All properties available in MPlayer.
2054 /** \ingroup Properties
2056 static const m_option_t mp_properties
[] = {
2058 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2059 M_OPT_RANGE
, 0, 3, NULL
},
2060 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2061 M_OPT_MIN
, -1, 0, NULL
},
2062 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2063 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2064 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2066 { "path", mp_property_path
, CONF_TYPE_STRING
,
2068 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2070 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2071 M_OPT_MIN
, 0, 0, NULL
},
2072 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2073 M_OPT_MIN
, 0, 0, NULL
},
2074 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2075 M_OPT_MIN
, 0, 0, NULL
},
2076 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2077 M_OPT_MIN
, 0, 0, NULL
},
2078 { "length", mp_property_length
, CONF_TYPE_TIME
,
2079 M_OPT_MIN
, 0, 0, NULL
},
2080 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2081 M_OPT_RANGE
, 0, 100, NULL
},
2082 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2083 M_OPT_MIN
, 0, 0, NULL
},
2084 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2085 M_OPT_MIN
, 0, 0, NULL
},
2086 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2088 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2089 CONF_RANGE
, -2, 10, NULL
},
2090 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2092 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2093 M_OPT_RANGE
, 0, 1, NULL
},
2096 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2097 M_OPT_RANGE
, 0, 100, NULL
},
2098 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2099 M_OPT_RANGE
, 0, 1, NULL
},
2100 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2101 M_OPT_RANGE
, -100, 100, NULL
},
2102 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2104 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2106 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2108 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2110 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2112 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2113 CONF_RANGE
, -2, 65535, NULL
},
2114 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2115 M_OPT_RANGE
, -1, 1, NULL
},
2118 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2119 M_OPT_RANGE
, 0, 1, NULL
},
2120 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2121 M_OPT_RANGE
, 0, 1, NULL
},
2122 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2123 M_OPT_RANGE
, 0, 2, NULL
},
2124 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2125 M_OPT_RANGE
, 0, 1, NULL
},
2126 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2127 M_OPT_RANGE
, 0, 1, NULL
},
2128 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2129 M_OPT_RANGE
, 0, 1, NULL
},
2130 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2131 M_OPT_RANGE
, 0, 2, NULL
},
2132 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2133 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2134 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2135 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2136 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2137 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2138 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2139 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2140 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2141 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2142 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2143 M_OPT_RANGE
, 0, 1, NULL
},
2144 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2145 M_OPT_RANGE
, 0, 1, NULL
},
2146 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2148 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2150 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2152 { "width", mp_property_width
, CONF_TYPE_INT
,
2154 { "height", mp_property_height
, CONF_TYPE_INT
,
2156 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2158 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2160 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2161 CONF_RANGE
, -2, 65535, NULL
},
2162 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2163 CONF_RANGE
, -1, 65535, NULL
},
2166 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2167 M_OPT_MIN
, -1, 0, NULL
},
2168 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2169 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2170 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2171 M_OPT_MIN
, -1, 0, NULL
},
2172 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2173 M_OPT_MIN
, -1, 0, NULL
},
2174 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2175 M_OPT_MIN
, -1, 0, NULL
},
2176 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2178 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2179 M_OPT_RANGE
, 0, 100, NULL
},
2180 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2181 M_OPT_RANGE
, 0, 2, NULL
},
2182 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2183 M_OPT_RANGE
, 0, 1, NULL
},
2184 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2185 M_OPT_RANGE
, 0, 1, NULL
},
2186 #ifdef CONFIG_FREETYPE
2187 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2188 M_OPT_RANGE
, 0, 100, NULL
},
2191 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2192 M_OPT_RANGE
, 0, 1, NULL
},
2196 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2197 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2198 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2199 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2200 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2201 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2202 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2203 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2205 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2206 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2207 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2208 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2209 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2210 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2211 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2212 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2213 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2214 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2215 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2219 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2221 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2224 char* mp_property_print(const char *name
, void* ctx
)
2227 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2232 char *property_expand_string(MPContext
*mpctx
, char *str
)
2234 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2237 void property_print_help(void)
2239 m_properties_print_help_list(mp_properties
);
2243 /* List of default ways to show a property on OSD.
2245 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2246 * a bar showing the current position between min/max values of the
2247 * property. In this case osd_msg is only used for terminal output
2248 * if there is no video; it'll be a label shown together with percentage.
2250 * Otherwise setting osd_msg will show the string on OSD, formatted with
2251 * the text value of the property as argument.
2253 static struct property_osd_display
{
2256 /// progressbar type
2257 int osd_progbar
; // -1 is special value for seek indicators
2258 /// osd msg id if it must be shared
2260 /// osd msg template
2261 const char *osd_msg
;
2262 } property_osd_display
[] = {
2264 { "loop", 0, -1, _("Loop: %s") },
2265 { "chapter", -1, -1, NULL
},
2267 { "volume", OSD_VOLUME
, -1, _("Volume") },
2268 { "mute", 0, -1, _("Mute: %s") },
2269 { "audio_delay", 0, -1, _("A-V delay: %s") },
2270 { "switch_audio", 0, -1, _("Audio: %s") },
2271 { "balance", OSD_BALANCE
, -1, _("Balance") },
2273 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2274 { "ontop", 0, -1, _("Stay on top: %s") },
2275 { "rootwin", 0, -1, _("Rootwin: %s") },
2276 { "border", 0, -1, _("Border: %s") },
2277 { "framedropping", 0, -1, _("Framedropping: %s") },
2278 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2279 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2280 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2281 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2282 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2283 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2284 { "hue", OSD_HUE
, -1, _("Hue") },
2285 { "vsync", 0, -1, _("VSync: %s") },
2287 { "sub", 0, -1, _("Subtitles: %s") },
2288 { "sub_source", 0, -1, _("Sub source: %s") },
2289 { "sub_vob", 0, -1, _("Subtitles: %s") },
2290 { "sub_demux", 0, -1, _("Subtitles: %s") },
2291 { "sub_file", 0, -1, _("Subtitles: %s") },
2292 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2293 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2294 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2295 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2296 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2297 #ifdef CONFIG_FREETYPE
2298 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2301 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2302 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2303 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2304 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2309 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2311 struct MPOpts
*opts
= &mpctx
->opts
;
2314 struct property_osd_display
*p
;
2316 // look for the command
2317 for (p
= property_osd_display
; p
->name
; p
++)
2318 if (!strcmp(p
->name
, pname
))
2323 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2326 if (p
->osd_progbar
== -1)
2327 mpctx
->add_osd_seek_info
= true;
2328 else if (p
->osd_progbar
) {
2329 if (prop
->type
== CONF_TYPE_INT
) {
2330 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2331 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2332 prop
->min
, prop
->max
, r
);
2333 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2335 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2336 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2337 prop
->min
, prop
->max
, f
);
2339 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2340 "Property use an unsupported type.\n");
2347 char *val
= mp_property_print(pname
, mpctx
);
2349 int index
= p
- property_osd_display
;
2350 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2351 1, opts
->osd_duration
, p
->osd_msg
, val
);
2360 * \defgroup Command2Property Command to property bridge
2362 * It is used to handle most commands that just set a property
2363 * and optionally display something on the OSD.
2364 * Two kinds of commands are handled: adjust or toggle.
2366 * Adjust commands take 1 or 2 parameters: <value> <abs>
2367 * If <abs> is non-zero the property is set to the given value
2368 * otherwise it is adjusted.
2370 * Toggle commands take 0 or 1 parameters. With no parameter
2371 * or a value less than the property minimum it just steps the
2372 * property to its next value. Otherwise it sets it to the given
2378 /// List of the commands that can be handled by setting a property.
2384 /// set/adjust or toggle command
2386 } set_prop_cmd
[] = {
2388 { "loop", MP_CMD_LOOP
, 0},
2389 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2390 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2391 { "pause", MP_CMD_PAUSE
, 0},
2393 { "volume", MP_CMD_VOLUME
, 0},
2394 { "mute", MP_CMD_MUTE
, 1},
2395 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2396 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2397 { "balance", MP_CMD_BALANCE
, 0},
2399 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2400 { "panscan", MP_CMD_PANSCAN
, 0},
2401 { "ontop", MP_CMD_VO_ONTOP
, 1},
2402 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2403 { "border", MP_CMD_VO_BORDER
, 1},
2404 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2405 { "gamma", MP_CMD_GAMMA
, 0},
2406 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2407 { "contrast", MP_CMD_CONTRAST
, 0},
2408 { "saturation", MP_CMD_SATURATION
, 0},
2409 { "hue", MP_CMD_HUE
, 0},
2410 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2412 { "sub", MP_CMD_SUB_SELECT
, 1},
2413 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2414 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2415 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2416 { "sub_file", MP_CMD_SUB_FILE
, 1},
2417 { "sub_pos", MP_CMD_SUB_POS
, 0},
2418 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2419 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2420 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2421 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2422 #ifdef CONFIG_FREETYPE
2423 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2426 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2429 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2430 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2431 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2432 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2437 /// Handle commands that set a property.
2438 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2444 // look for the command
2445 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2446 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2448 if (!(pname
= set_prop_cmd
[i
].name
))
2451 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2455 if (set_prop_cmd
[i
].toggle
) {
2457 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2458 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2460 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2461 } else if (cmd
->args
[1].v
.i
) //set
2462 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2464 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2469 show_property_osd(mpctx
, pname
);
2474 #ifdef CONFIG_DVDNAV
2475 static const struct {
2477 const mp_command_type cmd
;
2478 } mp_dvdnav_bindings
[] = {
2479 { "up", MP_CMD_DVDNAV_UP
},
2480 { "down", MP_CMD_DVDNAV_DOWN
},
2481 { "left", MP_CMD_DVDNAV_LEFT
},
2482 { "right", MP_CMD_DVDNAV_RIGHT
},
2483 { "menu", MP_CMD_DVDNAV_MENU
},
2484 { "select", MP_CMD_DVDNAV_SELECT
},
2485 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2486 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2489 * keep old dvdnav sub-command options for a while in order not to
2490 * break slave-mode API too suddenly.
2492 { "1", MP_CMD_DVDNAV_UP
},
2493 { "2", MP_CMD_DVDNAV_DOWN
},
2494 { "3", MP_CMD_DVDNAV_LEFT
},
2495 { "4", MP_CMD_DVDNAV_RIGHT
},
2496 { "5", MP_CMD_DVDNAV_MENU
},
2497 { "6", MP_CMD_DVDNAV_SELECT
},
2498 { "7", MP_CMD_DVDNAV_PREVMENU
},
2499 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2504 static const char *property_error_string(int error_value
)
2506 switch (error_value
) {
2507 case M_PROPERTY_ERROR
:
2509 case M_PROPERTY_UNAVAILABLE
:
2510 return "PROPERTY_UNAVAILABLE";
2511 case M_PROPERTY_NOT_IMPLEMENTED
:
2512 return "NOT_IMPLEMENTED";
2513 case M_PROPERTY_UNKNOWN
:
2514 return "PROPERTY_UNKNOWN";
2515 case M_PROPERTY_DISABLED
:
2521 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2524 int end
= start
+ count
;
2525 int after
= mpctx
->set_of_sub_size
- end
;
2526 sub_data
**subs
= mpctx
->set_of_subtitles
;
2528 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2530 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2531 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2532 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2533 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2536 for (idx
= start
; idx
< end
; idx
++) {
2537 sub_data
*subd
= subs
[idx
];
2538 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2539 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2540 filename_recode(subd
->filename
));
2544 if (ass_tracks
[idx
])
2545 ass_free_track(ass_tracks
[idx
]);
2546 ass_tracks
[idx
] = NULL
;
2550 mpctx
->global_sub_size
-= count
;
2551 mpctx
->set_of_sub_size
-= count
;
2552 if (mpctx
->set_of_sub_size
<= 0)
2553 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2555 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2556 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2558 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2559 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2562 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2563 mpctx
->global_sub_pos
= -2;
2568 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2569 } else if (mpctx
->set_of_sub_pos
>= end
) {
2570 mpctx
->set_of_sub_pos
-= count
;
2571 mpctx
->global_sub_pos
-= count
;
2575 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2577 struct MPOpts
*opts
= &mpctx
->opts
;
2578 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2579 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2580 int osd_duration
= opts
->osd_duration
;
2581 int case_fallthrough_hack
= 0;
2582 if (!set_property_command(mpctx
, cmd
))
2587 mpctx
->add_osd_seek_info
= true;
2588 v
= cmd
->args
[0].v
.f
;
2589 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2590 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2591 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2593 mpctx
->osd_function
=
2594 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2595 mpctx
->rel_seek_secs
= v
;
2596 } else if (abs
) { /* Absolute seek by percentage */
2597 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2599 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2600 mpctx
->rel_seek_secs
= v
/ 100.0;
2602 mpctx
->rel_seek_secs
+= v
;
2603 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2608 case MP_CMD_SET_PROPERTY_OSD
:
2609 case_fallthrough_hack
= 1;
2611 case MP_CMD_SET_PROPERTY
:{
2612 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2613 cmd
->args
[1].v
.s
, mpctx
);
2614 if (r
== M_PROPERTY_UNKNOWN
)
2615 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2616 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2618 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2619 "Failed to set property '%s' to '%s'.\n",
2620 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2621 else if (case_fallthrough_hack
)
2622 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2624 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2628 case MP_CMD_STEP_PROPERTY_OSD
:
2629 case_fallthrough_hack
= 1;
2631 case MP_CMD_STEP_PROPERTY
:{
2636 if (cmd
->args
[1].v
.f
) {
2638 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2639 M_PROPERTY_GET_TYPE
,
2640 &prop
, mpctx
)) <= 0)
2642 if(prop
->type
== CONF_TYPE_INT
||
2643 prop
->type
== CONF_TYPE_FLAG
)
2644 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2645 else if(prop
->type
== CONF_TYPE_FLOAT
)
2646 arg
= &cmd
->args
[1].v
.f
;
2647 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2648 prop
->type
== CONF_TYPE_TIME
)
2649 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2650 else if(prop
->type
== CONF_TYPE_POSITION
)
2651 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2653 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2654 "Ignoring step size stepping property '%s'.\n",
2657 r
= mp_property_do(cmd
->args
[0].v
.s
,
2658 cmd
->args
[2].v
.i
< 0 ?
2659 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2662 if (r
== M_PROPERTY_UNKNOWN
)
2663 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2664 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2666 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2667 "Failed to increment property '%s' by %f.\n",
2668 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2669 else if (case_fallthrough_hack
)
2670 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2672 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2676 case MP_CMD_GET_PROPERTY
:{
2678 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2681 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2682 "Failed to get value of property '%s'.\n",
2684 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2687 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2688 cmd
->args
[0].v
.s
, tmp
);
2693 case MP_CMD_EDL_MARK
:
2695 float v
= sh_video
? sh_video
->pts
:
2696 playing_audio_pts(mpctx
);
2697 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2698 mpctx
->begin_skip
= v
;
2699 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2701 if (mpctx
->begin_skip
> v
)
2702 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2704 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2705 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2707 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2712 case MP_CMD_SWITCH_RATIO
:
2715 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2716 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2718 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2719 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2722 case MP_CMD_SPEED_INCR
:{
2723 float v
= cmd
->args
[0].v
.f
;
2724 opts
->playback_speed
+= v
;
2725 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2726 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2727 opts
->playback_speed
);
2730 case MP_CMD_SPEED_MULT
:{
2731 float v
= cmd
->args
[0].v
.f
;
2732 opts
->playback_speed
*= v
;
2733 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2734 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2735 opts
->playback_speed
);
2738 case MP_CMD_SPEED_SET
:{
2739 float v
= cmd
->args
[0].v
.f
;
2740 opts
->playback_speed
= v
;
2741 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2742 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2743 opts
->playback_speed
);
2746 case MP_CMD_FRAME_STEP
:
2747 add_step_frame(mpctx
);
2750 case MP_CMD_FILE_FILTER
:
2751 file_filter
= cmd
->args
[0].v
.i
;
2755 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2756 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2758 case MP_CMD_PLAY_TREE_STEP
:{
2759 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2760 int force
= cmd
->args
[1].v
.i
;
2763 if (!force
&& mpctx
->playtree_iter
) {
2764 play_tree_iter_t
*i
=
2765 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2766 if (play_tree_iter_step(i
, n
, 0) ==
2767 PLAY_TREE_ITER_ENTRY
)
2769 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2770 play_tree_iter_free(i
);
2772 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2773 if (mpctx
->stop_play
)
2774 mpctx
->play_tree_step
= n
;
2779 case MP_CMD_PLAY_TREE_UP_STEP
:{
2780 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2781 int force
= cmd
->args
[1].v
.i
;
2783 if (!force
&& mpctx
->playtree_iter
) {
2784 play_tree_iter_t
*i
=
2785 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2786 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2787 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2788 play_tree_iter_free(i
);
2790 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2794 case MP_CMD_PLAY_ALT_SRC_STEP
:
2795 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2796 int v
= cmd
->args
[0].v
.i
;
2798 && mpctx
->playtree_iter
->file
<
2799 mpctx
->playtree_iter
->num_files
)
2800 mpctx
->stop_play
= PT_NEXT_SRC
;
2801 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2802 mpctx
->stop_play
= PT_PREV_SRC
;
2806 case MP_CMD_SUB_STEP
:
2808 int movement
= cmd
->args
[0].v
.i
;
2809 step_sub(subdata
, sh_video
->pts
, movement
);
2813 ass_step_sub(ass_track
,
2815 sub_delay
) * 1000 + .5, movement
) / 1000.;
2817 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2818 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2822 case MP_CMD_SUB_LOG
:
2827 int v
= cmd
->args
[0].v
.i
;
2829 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2830 if (opts
->osd_level
> max
)
2831 opts
->osd_level
= max
;
2833 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2835 opts
->osd_level
= v
> max
? max
: v
;
2836 /* Show OSD state when disabled, but not when an explicit
2837 argument is given to the OSD command, i.e. in slave mode. */
2838 if (v
== -1 && opts
->osd_level
<= 1)
2839 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2841 opts
->osd_level
? mp_gtext("enabled") :
2842 mp_gtext("disabled"));
2844 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2848 case MP_CMD_OSD_SHOW_TEXT
:
2849 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2851 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2852 "%-.63s", cmd
->args
[0].v
.s
);
2855 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2856 char *txt
= m_properties_expand_string(mp_properties
,
2859 /* if no argument supplied take default osd_duration, else <arg> ms. */
2861 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2863 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2870 case MP_CMD_LOADFILE
:{
2871 play_tree_t
*e
= play_tree_new();
2872 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2874 if (cmd
->args
[1].v
.i
) // append
2875 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2877 // Go back to the starting point.
2878 while (play_tree_iter_up_step
2879 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2881 play_tree_free_list(mpctx
->playtree
->child
, 1);
2882 play_tree_set_child(mpctx
->playtree
, e
);
2883 pt_iter_goto_head(mpctx
->playtree_iter
);
2884 mpctx
->stop_play
= PT_NEXT_SRC
;
2889 case MP_CMD_LOADLIST
:{
2890 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2892 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2893 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2895 if (cmd
->args
[1].v
.i
) // append
2896 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2898 // Go back to the starting point.
2899 while (play_tree_iter_up_step
2900 (mpctx
->playtree_iter
, 0, 1)
2901 != PLAY_TREE_ITER_END
)
2903 play_tree_free_list(mpctx
->playtree
->child
, 1);
2904 play_tree_set_child(mpctx
->playtree
, e
);
2905 pt_iter_goto_head(mpctx
->playtree_iter
);
2906 mpctx
->stop_play
= PT_NEXT_SRC
;
2913 // Go back to the starting point.
2914 while (play_tree_iter_up_step
2915 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2917 mpctx
->stop_play
= PT_STOP
;
2921 case MP_CMD_RADIO_STEP_CHANNEL
:
2922 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2923 int v
= cmd
->args
[0].v
.i
;
2925 radio_step_channel(mpctx
->demuxer
->stream
,
2926 RADIO_CHANNEL_HIGHER
);
2928 radio_step_channel(mpctx
->demuxer
->stream
,
2929 RADIO_CHANNEL_LOWER
);
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_CHANNEL
:
2939 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2940 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2941 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2942 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2944 radio_get_channel_name(mpctx
->demuxer
->stream
));
2949 case MP_CMD_RADIO_SET_FREQ
:
2950 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2951 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2954 case MP_CMD_RADIO_STEP_FREQ
:
2955 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2956 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2961 case MP_CMD_TV_START_SCAN
:
2962 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2963 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2965 case MP_CMD_TV_SET_FREQ
:
2966 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2967 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2968 cmd
->args
[0].v
.f
* 16.0);
2970 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2971 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2972 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2973 pvr_get_current_channelname (mpctx
->stream
),
2974 pvr_get_current_stationname (mpctx
->stream
));
2976 #endif /* CONFIG_PVR */
2979 case MP_CMD_TV_STEP_FREQ
:
2980 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2981 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2982 cmd
->args
[0].v
.f
* 16.0);
2984 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2985 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2986 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2987 pvr_get_current_channelname (mpctx
->stream
),
2988 pvr_get_current_frequency (mpctx
->stream
));
2990 #endif /* CONFIG_PVR */
2993 case MP_CMD_TV_SET_NORM
:
2994 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2995 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2999 case MP_CMD_TV_STEP_CHANNEL
:{
3000 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3001 int v
= cmd
->args
[0].v
.i
;
3003 tv_step_channel((tvi_handle_t
*) (mpctx
->
3007 tv_step_channel((tvi_handle_t
*) (mpctx
->
3011 if (tv_channel_list
) {
3012 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3013 "Channel: %s", tv_channel_current
->name
);
3014 //vo_osd_changed(OSDTYPE_SUBTITLE);
3018 else if (mpctx
->stream
&&
3019 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3020 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3021 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3022 pvr_get_current_channelname (mpctx
->stream
),
3023 pvr_get_current_stationname (mpctx
->stream
));
3025 #endif /* CONFIG_PVR */
3028 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3030 int v
= cmd
->args
[0].v
.i
;
3032 mpctx
->last_dvb_step
= v
;
3034 dir
= DVB_CHANNEL_HIGHER
;
3036 dir
= DVB_CHANNEL_LOWER
;
3039 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3040 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3041 mpctx
->dvbin_reopen
= 1;
3044 #endif /* CONFIG_DVBIN */
3047 case MP_CMD_TV_SET_CHANNEL
:
3048 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3049 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3051 if (tv_channel_list
) {
3052 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3053 "Channel: %s", tv_channel_current
->name
);
3054 //vo_osd_changed(OSDTYPE_SUBTITLE);
3058 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3059 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3060 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3061 pvr_get_current_channelname (mpctx
->stream
),
3062 pvr_get_current_stationname (mpctx
->stream
));
3064 #endif /* CONFIG_PVR */
3068 case MP_CMD_DVB_SET_CHANNEL
:
3069 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3070 mpctx
->last_dvb_step
= 1;
3072 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3073 cmd
->args
[0].v
.i
)) {
3074 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3075 mpctx
->dvbin_reopen
= 1;
3079 #endif /* CONFIG_DVBIN */
3081 case MP_CMD_TV_LAST_CHANNEL
:
3082 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3083 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3084 if (tv_channel_list
) {
3085 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3086 "Channel: %s", tv_channel_current
->name
);
3087 //vo_osd_changed(OSDTYPE_SUBTITLE);
3091 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3092 pvr_set_lastchannel (mpctx
->stream
);
3093 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3094 pvr_get_current_channelname (mpctx
->stream
),
3095 pvr_get_current_stationname (mpctx
->stream
));
3097 #endif /* CONFIG_PVR */
3100 case MP_CMD_TV_STEP_NORM
:
3101 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3102 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3105 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3106 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3107 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3109 #endif /* CONFIG_TV */
3110 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3112 if (mpctx
->demuxer
->teletext
)
3113 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3114 &(cmd
->args
[0].v
.s
));
3117 case MP_CMD_TV_TELETEXT_GO_LINK
:
3119 if (mpctx
->demuxer
->teletext
)
3120 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3121 &(cmd
->args
[0].v
.i
));
3125 case MP_CMD_SUB_LOAD
:
3127 int n
= mpctx
->set_of_sub_size
;
3128 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3129 if (n
!= mpctx
->set_of_sub_size
) {
3130 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
3131 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
3132 mpctx
->global_sub_size
;
3133 ++mpctx
->global_sub_size
;
3138 case MP_CMD_SUB_REMOVE
:
3140 int v
= cmd
->args
[0].v
.i
;
3142 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3143 } else if (v
< mpctx
->set_of_sub_size
) {
3144 remove_subtitle_range(mpctx
, v
, 1);
3149 case MP_CMD_GET_SUB_VISIBILITY
:
3151 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3152 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3156 case MP_CMD_SCREENSHOT
:
3157 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3158 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3160 ((vf_instance_t
*) sh_video
->vfilter
)->
3161 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3163 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3167 case MP_CMD_VF_CHANGE_RECTANGLE
:
3170 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3173 case MP_CMD_GET_TIME_LENGTH
:{
3174 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3175 demuxer_get_time_length(mpctx
->demuxer
));
3179 case MP_CMD_GET_FILENAME
:{
3180 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3181 get_metadata(mpctx
, META_NAME
));
3185 case MP_CMD_GET_VIDEO_CODEC
:{
3186 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3189 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3194 case MP_CMD_GET_VIDEO_BITRATE
:{
3195 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3198 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3203 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3204 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3207 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3208 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3213 case MP_CMD_GET_AUDIO_CODEC
:{
3214 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3217 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3222 case MP_CMD_GET_AUDIO_BITRATE
:{
3223 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3226 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3231 case MP_CMD_GET_AUDIO_SAMPLES
:{
3232 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3235 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3240 case MP_CMD_GET_META_TITLE
:{
3241 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3244 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3249 case MP_CMD_GET_META_ARTIST
:{
3250 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3253 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3258 case MP_CMD_GET_META_ALBUM
:{
3259 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3262 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3267 case MP_CMD_GET_META_YEAR
:{
3268 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3271 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3276 case MP_CMD_GET_META_COMMENT
:{
3277 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3280 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3285 case MP_CMD_GET_META_TRACK
:{
3286 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3289 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3294 case MP_CMD_GET_META_GENRE
:{
3295 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3298 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3303 case MP_CMD_GET_VO_FULLSCREEN
:
3304 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3305 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3308 case MP_CMD_GET_PERCENT_POS
:
3309 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3310 demuxer_get_percent_pos(mpctx
->demuxer
));
3313 case MP_CMD_GET_TIME_POS
:{
3316 pos
= sh_video
->pts
;
3317 else if (sh_audio
&& mpctx
->audio_out
)
3318 pos
= playing_audio_pts(mpctx
);
3319 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3326 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3332 case MP_CMD_KEYDOWN_EVENTS
:
3333 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3336 case MP_CMD_SET_MOUSE_POS
:{
3337 int pointer_x
, pointer_y
;
3339 pointer_x
= cmd
->args
[0].v
.i
;
3340 pointer_y
= cmd
->args
[1].v
.i
;
3341 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3342 #ifdef CONFIG_DVDNAV
3343 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3344 && dx
> 0.0 && dy
> 0.0) {
3346 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3347 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3348 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3349 pointer_x
, pointer_y
, &button
);
3350 if (opts
->osd_level
> 1 && button
> 0)
3351 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3352 "Selected button number %d", button
);
3356 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3357 menu_update_mouse_pos(dx
, dy
);
3362 #ifdef CONFIG_DVDNAV
3363 case MP_CMD_DVDNAV
:{
3366 mp_command_type command
= 0;
3367 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3370 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3371 if (cmd
->args
[0].v
.s
&&
3372 !strcasecmp (cmd
->args
[0].v
.s
,
3373 mp_dvdnav_bindings
[i
].name
))
3374 command
= mp_dvdnav_bindings
[i
].cmd
;
3376 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3377 if (opts
->osd_level
> 1 && button
> 0)
3378 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3379 "Selected button number %d", button
);
3383 case MP_CMD_SWITCH_TITLE
:
3384 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3385 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3391 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3392 "Received unknown cmd %s\n", cmd
->name
);
3395 switch (cmd
->pausing
) {
3396 case 1: // "pausing"
3397 pause_player(mpctx
);
3399 case 3: // "pausing_toggle"
3401 unpause_player(mpctx
);
3403 pause_player(mpctx
);