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"
35 #include "sub/dec_sub.h"
37 #include "m_property.h"
40 #include "libmpcodecs/vf.h"
41 #include "libmpcodecs/vd.h"
43 #include "libvo/video_out.h"
44 #include "libvo/font_load.h"
46 #include "libao2/audio_out.h"
49 #include "libmpcodecs/dec_video.h"
50 #include "libmpcodecs/dec_audio.h"
51 #include "libmpcodecs/dec_teletext.h"
56 #include "stream/tv.h"
57 #include "stream/stream_radio.h"
58 #include "stream/pvr.h"
60 #include "stream/dvbin.h"
63 #include "stream/stream_dvd.h"
65 #include "stream/stream_dvdnav.h"
67 #include "libmenu/menu.h"
71 #include "libavutil/avstring.h"
73 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
77 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
78 double *dx
, double *dy
)
80 struct MPOpts
*opts
= &mpctx
->opts
;
81 struct vo
*vo
= mpctx
->video_out
;
82 //remove the borders, if any, and rescale to the range [0,1],[0,1]
83 if (vo_fs
) { //we are in full-screen mode
84 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
85 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
86 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
87 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
89 if (ix
< 0 || ix
> vo
->dwidth
) {
92 } //we are on one of the borders
93 if (iy
< 0 || iy
> vo
->dheight
) {
96 } //we are on one of the borders
99 *dx
= (double) ix
/ (double) vo
->dwidth
;
100 *dy
= (double) iy
/ (double) vo
->dheight
;
102 mp_msg(MSGT_CPLAYER
, MSGL_V
,
103 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
104 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
108 static int sub_pos_by_source(MPContext
*mpctx
, int src
)
111 if (src
>= SUB_SOURCES
|| mpctx
->sub_counts
[src
] == 0)
113 for (i
= 0; i
< src
; i
++)
114 cnt
+= mpctx
->sub_counts
[i
];
118 static int sub_source_and_index_by_pos(MPContext
*mpctx
, int *pos
)
122 for (i
= 0; i
< SUB_SOURCES
; i
++) {
123 int cnt
= mpctx
->sub_counts
[i
];
124 if (*pos
>= start
&& *pos
< start
+ cnt
) {
134 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
136 return sub_source_and_index_by_pos(mpctx
, &pos
);
139 static int sub_source_pos(MPContext
*mpctx
)
141 int pos
= mpctx
->global_sub_pos
;
142 sub_source_and_index_by_pos(mpctx
, &pos
);
146 static int sub_source(MPContext
*mpctx
)
148 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
151 static void update_global_sub_size(MPContext
*mpctx
)
153 struct MPOpts
*opts
= &mpctx
->opts
;
157 // update number of demuxer sub streams
158 for (i
= 0; i
< MAX_S_STREAMS
; i
++)
159 if (mpctx
->d_sub
->demuxer
->s_streams
[i
])
161 if (cnt
> mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
162 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
] = cnt
;
164 // update global size
165 mpctx
->global_sub_size
= 0;
166 for (i
= 0; i
< SUB_SOURCES
; i
++)
167 mpctx
->global_sub_size
+= mpctx
->sub_counts
[i
];
169 // update global_sub_pos if we auto-detected a demuxer sub
170 if (mpctx
->global_sub_pos
== -1) {
172 if (mpctx
->demuxer
->sub
)
173 sub_id
= mpctx
->demuxer
->sub
->id
;
175 sub_id
= opts
->sub_id
;
176 if (sub_id
>= 0 && sub_id
< mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
177 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, SUB_SOURCE_DEMUX
) +
183 * \brief Log the currently displayed subtitle to a file
185 * Logs the current or last displayed subtitle together with filename
186 * and time information to ~/.mplayer/subtitle_log
188 * Intended purpose is to allow convenient marking of bogus subtitles
189 * which need to be fixed while watching the movie.
192 static void log_sub(struct MPContext
*mpctx
)
197 struct subtitle
*vo_sub_last
= mpctx
->vo_sub_last
;
199 if (mpctx
->subdata
== NULL
|| vo_sub_last
== NULL
)
201 fname
= get_path("subtitle_log");
202 f
= fopen(fname
, "a");
205 fprintf(f
, "----------------------------------------------------------\n");
206 if (mpctx
->subdata
->sub_uses_time
) {
208 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
209 mpctx
->filename
, vo_sub_last
->start
/ 360000,
210 (vo_sub_last
->start
/ 6000) % 60,
211 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
212 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
213 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
215 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
216 vo_sub_last
->start
, vo_sub_last
->end
);
218 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
219 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
225 /// \defgroup Properties
228 /// \defgroup GeneralProperties General properties
229 /// \ingroup Properties
232 static int mp_property_generic_option(struct m_option
*prop
, int action
,
233 void *arg
, MPContext
*mpctx
)
235 char *optname
= prop
->priv
;
236 const struct m_option
*opt
= m_config_get_option(mpctx
->mconfig
, optname
);
237 void *valptr
= m_option_get_ptr(opt
, &mpctx
->opts
);
240 case M_PROPERTY_GET_TYPE
:
241 *(const struct m_option
**)arg
= opt
;
242 return M_PROPERTY_OK
;
244 m_option_copy(opt
, arg
, valptr
);
245 return M_PROPERTY_OK
;
247 m_option_copy(opt
, valptr
, arg
);
248 return M_PROPERTY_OK
;
249 case M_PROPERTY_STEP_UP
:
250 if (opt
->type
== &m_option_type_choice
) {
251 int v
= *(int *) valptr
;
253 struct m_opt_choice_alternatives
*alt
;
254 for (alt
= opt
->priv
; alt
->name
; alt
++)
255 if ((unsigned) alt
->value
- v
- 1 < (unsigned) best
- v
- 1)
257 *(int *) valptr
= best
;
258 return M_PROPERTY_OK
;
262 return M_PROPERTY_NOT_IMPLEMENTED
;
266 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
269 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
273 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
276 struct MPOpts
*opts
= &mpctx
->opts
;
278 case M_PROPERTY_PRINT
:
279 if (!arg
) return M_PROPERTY_ERROR
;
280 if (opts
->loop_times
< 0)
281 *(char**)arg
= strdup("off");
282 else if (opts
->loop_times
== 0)
283 *(char**)arg
= strdup("inf");
286 return M_PROPERTY_OK
;
288 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
291 /// Playback speed (RW)
292 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
293 void *arg
, MPContext
*mpctx
)
295 struct MPOpts
*opts
= &mpctx
->opts
;
299 return M_PROPERTY_ERROR
;
300 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
301 opts
->playback_speed
= *(float *) arg
;
302 reinit_audio_chain(mpctx
);
303 return M_PROPERTY_OK
;
304 case M_PROPERTY_STEP_UP
:
305 case M_PROPERTY_STEP_DOWN
:
306 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
307 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
308 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
309 reinit_audio_chain(mpctx
);
310 return M_PROPERTY_OK
;
312 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
315 /// filename with path (RO)
316 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
319 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
322 /// filename without path (RO)
323 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
327 if (!mpctx
->filename
)
328 return M_PROPERTY_UNAVAILABLE
;
329 f
= (char *)mp_basename(mpctx
->filename
);
332 return m_property_string_ro(prop
, action
, arg
, f
);
335 /// Demuxer name (RO)
336 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
340 return M_PROPERTY_UNAVAILABLE
;
341 return m_property_string_ro(prop
, action
, arg
,
342 (char *) mpctx
->demuxer
->desc
->name
);
345 /// Position in the stream (RW)
346 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
349 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
350 return M_PROPERTY_UNAVAILABLE
;
352 return M_PROPERTY_ERROR
;
355 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
356 return M_PROPERTY_OK
;
358 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
359 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
360 return M_PROPERTY_OK
;
362 return M_PROPERTY_NOT_IMPLEMENTED
;
365 /// Stream start offset (RO)
366 static int mp_property_stream_start(m_option_t
*prop
, int action
,
367 void *arg
, MPContext
*mpctx
)
369 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
370 return M_PROPERTY_UNAVAILABLE
;
373 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
374 return M_PROPERTY_OK
;
376 return M_PROPERTY_NOT_IMPLEMENTED
;
379 /// Stream end offset (RO)
380 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
383 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
384 return M_PROPERTY_UNAVAILABLE
;
387 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
388 return M_PROPERTY_OK
;
390 return M_PROPERTY_NOT_IMPLEMENTED
;
393 /// Stream length (RO)
394 static int mp_property_stream_length(m_option_t
*prop
, int action
,
395 void *arg
, MPContext
*mpctx
)
397 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
398 return M_PROPERTY_UNAVAILABLE
;
402 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
403 return M_PROPERTY_OK
;
405 return M_PROPERTY_NOT_IMPLEMENTED
;
408 /// Current stream position in seconds (RO)
409 static int mp_property_stream_time_pos(m_option_t
*prop
, int action
,
410 void *arg
, MPContext
*mpctx
)
412 if (!mpctx
->demuxer
|| mpctx
->demuxer
->stream_pts
== MP_NOPTS_VALUE
)
413 return M_PROPERTY_UNAVAILABLE
;
415 return m_property_time_ro(prop
, action
, arg
, mpctx
->demuxer
->stream_pts
);
419 /// Media length in seconds (RO)
420 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
425 if (!mpctx
->demuxer
||
426 !(int) (len
= get_time_length(mpctx
)))
427 return M_PROPERTY_UNAVAILABLE
;
429 return m_property_time_ro(prop
, action
, arg
, len
);
432 /// Current position in percent (RW)
433 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
434 void *arg
, MPContext
*mpctx
) {
438 return M_PROPERTY_UNAVAILABLE
;
442 if(!arg
) return M_PROPERTY_ERROR
;
443 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
446 case M_PROPERTY_STEP_UP
:
447 case M_PROPERTY_STEP_DOWN
:
448 pos
= get_percent_pos(mpctx
);
449 pos
+= (arg
? *(int*)arg
: 10) *
450 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
451 M_PROPERTY_CLAMP(prop
, pos
);
454 return m_property_int_ro(prop
, action
, arg
, get_percent_pos(mpctx
));
457 queue_seek(mpctx
, MPSEEK_FACTOR
, pos
/ 100.0, 0);
458 return M_PROPERTY_OK
;
461 /// Current position in seconds (RW)
462 static int mp_property_time_pos(m_option_t
*prop
, int action
,
463 void *arg
, MPContext
*mpctx
) {
464 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
465 return M_PROPERTY_UNAVAILABLE
;
469 if(!arg
) return M_PROPERTY_ERROR
;
470 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
471 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, *(double*)arg
, 0);
472 return M_PROPERTY_OK
;
473 case M_PROPERTY_STEP_UP
:
474 case M_PROPERTY_STEP_DOWN
:
475 queue_seek(mpctx
, MPSEEK_RELATIVE
, (arg
? *(double*)arg
: 10.0) *
476 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0), 0);
477 return M_PROPERTY_OK
;
479 return m_property_time_ro(prop
, action
, arg
, get_current_time(mpctx
));
482 /// Current chapter (RW)
483 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
486 struct MPOpts
*opts
= &mpctx
->opts
;
489 char *chapter_name
= NULL
;
492 chapter
= get_current_chapter(mpctx
);
494 return M_PROPERTY_UNAVAILABLE
;
499 return M_PROPERTY_ERROR
;
500 *(int *) arg
= chapter
;
501 return M_PROPERTY_OK
;
502 case M_PROPERTY_PRINT
: {
504 return M_PROPERTY_ERROR
;
505 chapter_name
= chapter_display_name(mpctx
, chapter
);
507 return M_PROPERTY_UNAVAILABLE
;
508 *(char **) arg
= chapter_name
;
509 return M_PROPERTY_OK
;
513 return M_PROPERTY_ERROR
;
514 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
515 step_all
= *(int *)arg
- chapter
;
518 case M_PROPERTY_STEP_UP
:
519 case M_PROPERTY_STEP_DOWN
: {
520 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
521 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
528 return M_PROPERTY_NOT_IMPLEMENTED
;
532 queue_seek(mpctx
, MPSEEK_NONE
, 0, 0);
533 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
536 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, next_pts
, 0);
538 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
539 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
540 } else if (step_all
> 0)
541 queue_seek(mpctx
, MPSEEK_RELATIVE
, 1000000000, 0);
543 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
544 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
545 talloc_free(chapter_name
);
546 return M_PROPERTY_OK
;
549 /// Number of chapters in file
550 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
554 return M_PROPERTY_UNAVAILABLE
;
555 if (mpctx
->demuxer
->num_chapters
== 0)
556 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
557 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
560 /// Current dvd angle (RW)
561 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
564 struct MPOpts
*opts
= &mpctx
->opts
;
567 char *angle_name
= NULL
;
570 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
572 return M_PROPERTY_UNAVAILABLE
;
573 angles
= demuxer_angles_count(mpctx
->demuxer
);
575 return M_PROPERTY_UNAVAILABLE
;
580 return M_PROPERTY_ERROR
;
581 *(int *) arg
= angle
;
582 return M_PROPERTY_OK
;
583 case M_PROPERTY_PRINT
: {
585 return M_PROPERTY_ERROR
;
586 angle_name
= calloc(1, 64);
588 return M_PROPERTY_UNAVAILABLE
;
589 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
590 *(char **) arg
= angle_name
;
591 return M_PROPERTY_OK
;
595 return M_PROPERTY_ERROR
;
597 M_PROPERTY_CLAMP(prop
, angle
);
599 case M_PROPERTY_STEP_UP
:
600 case M_PROPERTY_STEP_DOWN
: {
606 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
608 if (angle
< 1) //cycle
613 return M_PROPERTY_NOT_IMPLEMENTED
;
615 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
617 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
619 resync_video_stream(sh_video
);
621 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
623 resync_audio_stream(sh_audio
);
626 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
627 "Angle: %d/%d", angle
, angles
);
629 return M_PROPERTY_OK
;
632 /// Demuxer meta data
633 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
635 m_property_action_t
* ka
;
637 static const m_option_t key_type
=
638 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
640 return M_PROPERTY_UNAVAILABLE
;
644 if(!arg
) return M_PROPERTY_ERROR
;
645 *(char***)arg
= mpctx
->demuxer
->info
;
646 return M_PROPERTY_OK
;
647 case M_PROPERTY_KEY_ACTION
:
648 if(!arg
) return M_PROPERTY_ERROR
;
650 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
651 return M_PROPERTY_UNKNOWN
;
654 if(!ka
->arg
) return M_PROPERTY_ERROR
;
655 *(char**)ka
->arg
= meta
;
656 return M_PROPERTY_OK
;
657 case M_PROPERTY_GET_TYPE
:
658 if(!ka
->arg
) return M_PROPERTY_ERROR
;
659 *(const m_option_t
**)ka
->arg
= &key_type
;
660 return M_PROPERTY_OK
;
663 return M_PROPERTY_NOT_IMPLEMENTED
;
666 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
669 MPContext
*mpctx
= ctx
;
674 return M_PROPERTY_ERROR
;
675 if (mpctx
->paused
== (bool)*(int *) arg
)
676 return M_PROPERTY_OK
;
677 case M_PROPERTY_STEP_UP
:
678 case M_PROPERTY_STEP_DOWN
:
680 unpause_player(mpctx
);
681 mpctx
->osd_function
= OSD_PLAY
;
685 mpctx
->osd_function
= OSD_PAUSE
;
687 return M_PROPERTY_OK
;
689 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
696 /// \defgroup AudioProperties Audio properties
697 /// \ingroup Properties
701 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
705 if (!mpctx
->sh_audio
)
706 return M_PROPERTY_UNAVAILABLE
;
711 return M_PROPERTY_ERROR
;
712 mixer_getbothvolume(&mpctx
->mixer
, arg
);
713 return M_PROPERTY_OK
;
714 case M_PROPERTY_PRINT
:{
717 return M_PROPERTY_ERROR
;
718 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
719 return m_property_float_range(prop
, action
, arg
, &vol
);
721 case M_PROPERTY_STEP_UP
:
722 case M_PROPERTY_STEP_DOWN
:
726 return M_PROPERTY_NOT_IMPLEMENTED
;
729 if (mpctx
->edl_muted
)
730 return M_PROPERTY_DISABLED
;
731 mpctx
->user_muted
= 0;
736 return M_PROPERTY_ERROR
;
737 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
738 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
739 return M_PROPERTY_OK
;
740 case M_PROPERTY_STEP_UP
:
741 if (arg
&& *(float *) arg
<= 0)
742 mixer_decvolume(&mpctx
->mixer
);
744 mixer_incvolume(&mpctx
->mixer
);
745 return M_PROPERTY_OK
;
746 case M_PROPERTY_STEP_DOWN
:
747 if (arg
&& *(float *) arg
<= 0)
748 mixer_incvolume(&mpctx
->mixer
);
750 mixer_decvolume(&mpctx
->mixer
);
751 return M_PROPERTY_OK
;
753 return M_PROPERTY_NOT_IMPLEMENTED
;
757 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
761 if (!mpctx
->sh_audio
)
762 return M_PROPERTY_UNAVAILABLE
;
766 if (mpctx
->edl_muted
)
767 return M_PROPERTY_DISABLED
;
769 return M_PROPERTY_ERROR
;
770 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
771 mixer_mute(&mpctx
->mixer
);
772 mpctx
->user_muted
= mpctx
->mixer
.muted
;
773 return M_PROPERTY_OK
;
774 case M_PROPERTY_STEP_UP
:
775 case M_PROPERTY_STEP_DOWN
:
776 if (mpctx
->edl_muted
)
777 return M_PROPERTY_DISABLED
;
778 mixer_mute(&mpctx
->mixer
);
779 mpctx
->user_muted
= mpctx
->mixer
.muted
;
780 return M_PROPERTY_OK
;
781 case M_PROPERTY_PRINT
:
783 return M_PROPERTY_ERROR
;
784 if (mpctx
->edl_muted
) {
785 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
786 return M_PROPERTY_OK
;
789 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
795 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
796 void *arg
, MPContext
*mpctx
)
798 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
799 return M_PROPERTY_UNAVAILABLE
;
802 case M_PROPERTY_STEP_UP
:
803 case M_PROPERTY_STEP_DOWN
: {
805 float delay
= audio_delay
;
806 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
807 if (ret
!= M_PROPERTY_OK
)
810 mpctx
->delay
-= audio_delay
- delay
;
812 return M_PROPERTY_OK
;
814 return m_property_delay(prop
, action
, arg
, &audio_delay
);
818 /// Audio codec tag (RO)
819 static int mp_property_audio_format(m_option_t
*prop
, int action
,
820 void *arg
, MPContext
*mpctx
)
822 if (!mpctx
->sh_audio
)
823 return M_PROPERTY_UNAVAILABLE
;
824 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
827 /// Audio codec name (RO)
828 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
829 void *arg
, MPContext
*mpctx
)
831 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
832 return M_PROPERTY_UNAVAILABLE
;
833 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
836 /// Audio bitrate (RO)
837 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
838 void *arg
, MPContext
*mpctx
)
840 if (!mpctx
->sh_audio
)
841 return M_PROPERTY_UNAVAILABLE
;
842 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
846 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
849 if (!mpctx
->sh_audio
)
850 return M_PROPERTY_UNAVAILABLE
;
852 case M_PROPERTY_PRINT
:
853 if(!arg
) return M_PROPERTY_ERROR
;
854 *(char**)arg
= malloc(16);
855 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
856 return M_PROPERTY_OK
;
858 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
861 /// Number of channels (RO)
862 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
865 if (!mpctx
->sh_audio
)
866 return M_PROPERTY_UNAVAILABLE
;
868 case M_PROPERTY_PRINT
:
870 return M_PROPERTY_ERROR
;
871 switch (mpctx
->sh_audio
->channels
) {
873 *(char **) arg
= strdup("mono");
876 *(char **) arg
= strdup("stereo");
879 *(char **) arg
= malloc(32);
880 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
882 return M_PROPERTY_OK
;
884 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
888 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
893 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
894 return M_PROPERTY_UNAVAILABLE
;
899 return M_PROPERTY_ERROR
;
900 mixer_getbalance(&mpctx
->mixer
, arg
);
901 return M_PROPERTY_OK
;
902 case M_PROPERTY_PRINT
: {
905 return M_PROPERTY_ERROR
;
906 mixer_getbalance(&mpctx
->mixer
, &bal
);
908 *str
= strdup("center");
909 else if (bal
== -1.f
)
910 *str
= strdup("left only");
912 *str
= strdup("right only");
914 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
915 *str
= malloc(sizeof("left xxx%, right xxx%"));
916 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
918 return M_PROPERTY_OK
;
920 case M_PROPERTY_STEP_UP
:
921 case M_PROPERTY_STEP_DOWN
:
922 mixer_getbalance(&mpctx
->mixer
, &bal
);
923 bal
+= (arg
? *(float*)arg
: .1f
) *
924 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
925 M_PROPERTY_CLAMP(prop
, bal
);
926 mixer_setbalance(&mpctx
->mixer
, bal
);
927 return M_PROPERTY_OK
;
930 return M_PROPERTY_ERROR
;
931 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
932 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
933 return M_PROPERTY_OK
;
935 return M_PROPERTY_NOT_IMPLEMENTED
;
938 /// Selected audio id (RW)
939 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
943 if (!mpctx
->demuxer
|| !mpctx
->d_audio
)
944 return M_PROPERTY_UNAVAILABLE
;
945 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
950 return M_PROPERTY_ERROR
;
951 *(int *) arg
= current_id
;
952 return M_PROPERTY_OK
;
953 case M_PROPERTY_PRINT
:
955 return M_PROPERTY_ERROR
;
958 *(char **) arg
= strdup(mp_gtext("disabled"));
961 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
962 sh_audio_t
* sh
= mpctx
->sh_audio
;
964 av_strlcpy(lang
, sh
->lang
, 40);
965 #ifdef CONFIG_DVDREAD
966 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
967 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
977 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
978 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
980 *(char **) arg
= malloc(64);
981 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
983 return M_PROPERTY_OK
;
985 case M_PROPERTY_STEP_UP
:
987 if (action
== M_PROPERTY_SET
&& arg
)
988 tmp
= *((int *) arg
);
991 int new_id
= demuxer_switch_audio(mpctx
->d_audio
->demuxer
, tmp
);
992 if (new_id
!= current_id
)
993 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
994 if (new_id
!= current_id
&& new_id
>= 0) {
996 sh2
= mpctx
->d_audio
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
997 sh2
->ds
= mpctx
->demuxer
->audio
;
998 mpctx
->sh_audio
= sh2
;
999 reinit_audio_chain(mpctx
);
1001 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
1002 return M_PROPERTY_OK
;
1004 return M_PROPERTY_NOT_IMPLEMENTED
;
1009 /// Selected video id (RW)
1010 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
1013 struct MPOpts
*opts
= &mpctx
->opts
;
1014 int current_id
, tmp
;
1015 if (!mpctx
->demuxer
|| !mpctx
->d_video
)
1016 return M_PROPERTY_UNAVAILABLE
;
1017 current_id
= mpctx
->d_video
->id
;
1020 case M_PROPERTY_GET
:
1022 return M_PROPERTY_ERROR
;
1023 *(int *) arg
= current_id
;
1024 return M_PROPERTY_OK
;
1025 case M_PROPERTY_PRINT
:
1027 return M_PROPERTY_ERROR
;
1030 *(char **) arg
= strdup(mp_gtext("disabled"));
1033 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1034 *(char **) arg
= malloc(64);
1035 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1037 return M_PROPERTY_OK
;
1039 case M_PROPERTY_STEP_UP
:
1040 case M_PROPERTY_SET
:
1041 if (action
== M_PROPERTY_SET
&& arg
)
1042 tmp
= *((int *) arg
);
1045 opts
->video_id
= demuxer_switch_video(mpctx
->d_video
->demuxer
, tmp
);
1046 if (opts
->video_id
== -2
1047 || (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
1048 && current_id
!= -2))
1049 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1050 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1051 if (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
) {
1053 sh2
= mpctx
->d_video
->demuxer
->v_streams
[mpctx
->d_video
->id
];
1055 sh2
->ds
= mpctx
->d_video
;
1056 mpctx
->sh_video
= sh2
;
1057 reinit_video_chain(mpctx
);
1060 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1061 return M_PROPERTY_OK
;
1064 return M_PROPERTY_NOT_IMPLEMENTED
;
1068 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1071 demux_program_t prog
;
1074 case M_PROPERTY_STEP_UP
:
1075 case M_PROPERTY_SET
:
1076 if (action
== M_PROPERTY_SET
&& arg
)
1077 prog
.progid
= *((int *) arg
);
1081 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1082 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1083 return M_PROPERTY_ERROR
;
1085 if (prog
.aid
< 0 && prog
.vid
< 0) {
1086 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1087 return M_PROPERTY_ERROR
;
1089 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1090 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1091 return M_PROPERTY_OK
;
1094 return M_PROPERTY_NOT_IMPLEMENTED
;
1100 /// \defgroup VideoProperties Video properties
1101 /// \ingroup Properties
1104 /// Fullscreen state (RW)
1105 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1109 if (!mpctx
->video_out
)
1110 return M_PROPERTY_UNAVAILABLE
;
1113 case M_PROPERTY_SET
:
1115 return M_PROPERTY_ERROR
;
1116 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1117 if (vo_fs
== !!*(int *) arg
)
1118 return M_PROPERTY_OK
;
1119 case M_PROPERTY_STEP_UP
:
1120 case M_PROPERTY_STEP_DOWN
:
1121 if (mpctx
->video_out
->config_ok
)
1122 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1123 mpctx
->opts
.fullscreen
= vo_fs
;
1124 return M_PROPERTY_OK
;
1126 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1130 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1131 void *arg
, MPContext
*mpctx
)
1135 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1136 return M_PROPERTY_UNAVAILABLE
;
1137 vf
= mpctx
->sh_video
->vfilter
;
1139 case M_PROPERTY_GET
:
1141 return M_PROPERTY_ERROR
;
1142 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1143 return M_PROPERTY_OK
;
1144 case M_PROPERTY_SET
:
1146 return M_PROPERTY_ERROR
;
1147 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1148 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1149 return M_PROPERTY_OK
;
1150 case M_PROPERTY_STEP_UP
:
1151 case M_PROPERTY_STEP_DOWN
:
1152 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1153 deinterlace
= !deinterlace
;
1154 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1155 return M_PROPERTY_OK
;
1158 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1159 return m_property_flag_ro(prop
, action
, arg
, value
);
1162 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1163 void *arg
, MPContext
*mpctx
)
1165 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1166 return M_PROPERTY_UNAVAILABLE
;
1168 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1171 case M_PROPERTY_GET
:
1173 return M_PROPERTY_ERROR
;
1174 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1175 return M_PROPERTY_UNAVAILABLE
;
1176 return M_PROPERTY_OK
;
1177 case M_PROPERTY_PRINT
:
1179 return M_PROPERTY_ERROR
;
1180 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1181 return M_PROPERTY_UNAVAILABLE
;
1182 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1183 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1184 *(char **)arg
= strdup("Unknown");
1186 *(char**)arg
= strdup(names
[colorspace
]);
1187 return M_PROPERTY_OK
;
1188 case M_PROPERTY_SET
:
1190 return M_PROPERTY_ERROR
;
1191 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1192 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1193 return M_PROPERTY_OK
;
1194 case M_PROPERTY_STEP_UP
:;
1195 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1196 return M_PROPERTY_UNAVAILABLE
;
1198 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1199 return M_PROPERTY_OK
;
1201 return M_PROPERTY_NOT_IMPLEMENTED
;
1204 static int mp_property_capture(m_option_t
*prop
, int action
,
1205 void *arg
, MPContext
*mpctx
)
1207 struct MPOpts
*opts
= &mpctx
->opts
;
1210 return M_PROPERTY_UNAVAILABLE
;
1212 if (!opts
->capture_dump
) {
1213 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1214 "Capturing not enabled (forgot -capture parameter?)\n");
1215 return M_PROPERTY_ERROR
;
1218 int capturing
= !!mpctx
->stream
->capture_file
;
1220 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1221 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1223 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1224 if (!mpctx
->stream
->capture_file
) {
1225 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1226 "Error opening capture file: %s\n", strerror(errno
));
1227 ret
= M_PROPERTY_ERROR
;
1230 fclose(mpctx
->stream
->capture_file
);
1231 mpctx
->stream
->capture_file
= NULL
;
1239 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1243 if (!mpctx
->video_out
1244 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1245 return M_PROPERTY_UNAVAILABLE
;
1248 case M_PROPERTY_SET
:
1250 return M_PROPERTY_ERROR
;
1251 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1252 vo_panscan
= *(float *) arg
;
1253 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1254 return M_PROPERTY_OK
;
1255 case M_PROPERTY_STEP_UP
:
1256 case M_PROPERTY_STEP_DOWN
:
1257 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1258 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1261 else if (vo_panscan
< 0)
1263 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1264 return M_PROPERTY_OK
;
1266 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1270 /// Helper to set vo flags.
1271 /** \ingroup PropertyImplHelper
1273 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1274 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1277 if (!mpctx
->video_out
)
1278 return M_PROPERTY_UNAVAILABLE
;
1281 case M_PROPERTY_SET
:
1283 return M_PROPERTY_ERROR
;
1284 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1285 if (*vo_var
== !!*(int *) arg
)
1286 return M_PROPERTY_OK
;
1287 case M_PROPERTY_STEP_UP
:
1288 case M_PROPERTY_STEP_DOWN
:
1289 if (mpctx
->video_out
->config_ok
)
1290 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1291 return M_PROPERTY_OK
;
1293 return m_property_flag(prop
, action
, arg
, vo_var
);
1297 /// Window always on top (RW)
1298 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1301 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1302 &mpctx
->opts
.vo_ontop
, mpctx
);
1305 /// Display in the root window (RW)
1306 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1309 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1310 &vo_rootwin
, mpctx
);
1313 /// Show window borders (RW)
1314 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1317 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1321 /// Framedropping state (RW)
1322 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1323 void *arg
, MPContext
*mpctx
)
1326 if (!mpctx
->sh_video
)
1327 return M_PROPERTY_UNAVAILABLE
;
1330 case M_PROPERTY_PRINT
:
1332 return M_PROPERTY_ERROR
;
1333 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1334 (frame_dropping
== 2 ? mp_gtext("hard") :
1335 mp_gtext("disabled")));
1336 return M_PROPERTY_OK
;
1338 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1342 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1343 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1346 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1349 if (!mpctx
->sh_video
)
1350 return M_PROPERTY_UNAVAILABLE
;
1352 if (gamma
[0] == 1000) {
1354 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1358 case M_PROPERTY_SET
:
1360 return M_PROPERTY_ERROR
;
1361 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1362 *gamma
= *(int *) arg
;
1363 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1367 case M_PROPERTY_GET
:
1368 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1370 return M_PROPERTY_ERROR
;
1372 return M_PROPERTY_OK
;
1375 case M_PROPERTY_STEP_UP
:
1376 case M_PROPERTY_STEP_DOWN
:
1377 *gamma
+= (arg
? *(int *) arg
: 1) *
1378 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1379 M_PROPERTY_CLAMP(prop
, *gamma
);
1380 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1385 return M_PROPERTY_NOT_IMPLEMENTED
;
1389 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1390 int l
= strlen(prop
->name
);
1391 char tv_prop
[3 + l
+ 1];
1392 sprintf(tv_prop
, "tv_%s", prop
->name
);
1393 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1397 return M_PROPERTY_UNAVAILABLE
;
1401 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1404 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1407 /// Video codec tag (RO)
1408 static int mp_property_video_format(m_option_t
*prop
, int action
,
1409 void *arg
, MPContext
*mpctx
)
1412 if (!mpctx
->sh_video
)
1413 return M_PROPERTY_UNAVAILABLE
;
1415 case M_PROPERTY_PRINT
:
1417 return M_PROPERTY_ERROR
;
1418 switch(mpctx
->sh_video
->format
) {
1420 meta
= strdup ("mpeg1"); break;
1422 meta
= strdup ("mpeg2"); break;
1424 meta
= strdup ("mpeg4"); break;
1426 meta
= strdup ("h264"); break;
1428 if(mpctx
->sh_video
->format
>= 0x20202020) {
1430 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1433 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1436 *(char**)arg
= meta
;
1437 return M_PROPERTY_OK
;
1439 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1442 /// Video codec name (RO)
1443 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1444 void *arg
, MPContext
*mpctx
)
1446 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1447 return M_PROPERTY_UNAVAILABLE
;
1448 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1452 /// Video bitrate (RO)
1453 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1454 void *arg
, MPContext
*mpctx
)
1456 if (!mpctx
->sh_video
)
1457 return M_PROPERTY_UNAVAILABLE
;
1458 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1461 /// Video display width (RO)
1462 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1465 if (!mpctx
->sh_video
)
1466 return M_PROPERTY_UNAVAILABLE
;
1467 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1470 /// Video display height (RO)
1471 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1474 if (!mpctx
->sh_video
)
1475 return M_PROPERTY_UNAVAILABLE
;
1476 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1480 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1483 if (!mpctx
->sh_video
)
1484 return M_PROPERTY_UNAVAILABLE
;
1485 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1488 /// Video aspect (RO)
1489 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1492 if (!mpctx
->sh_video
)
1493 return M_PROPERTY_UNAVAILABLE
;
1494 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1499 /// \defgroup SubProprties Subtitles properties
1500 /// \ingroup Properties
1503 /// Text subtitle position (RW)
1504 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1508 case M_PROPERTY_SET
:
1510 return M_PROPERTY_ERROR
;
1511 case M_PROPERTY_STEP_UP
:
1512 case M_PROPERTY_STEP_DOWN
:
1513 vo_osd_changed(OSDTYPE_SUBTITLE
);
1515 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1519 /// Selected subtitles (RW)
1520 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1523 struct MPOpts
*opts
= &mpctx
->opts
;
1524 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1525 int source
= -1, reset_spu
= 0;
1526 int source_pos
= -1;
1528 update_global_sub_size(mpctx
);
1529 const int global_sub_size
= mpctx
->global_sub_size
;
1531 if (global_sub_size
<= 0)
1532 return M_PROPERTY_UNAVAILABLE
;
1535 case M_PROPERTY_GET
:
1537 return M_PROPERTY_ERROR
;
1538 *(int *) arg
= mpctx
->global_sub_pos
;
1539 return M_PROPERTY_OK
;
1540 case M_PROPERTY_PRINT
:
1542 return M_PROPERTY_ERROR
;
1543 *(char **) arg
= malloc(64);
1544 (*(char **) arg
)[63] = 0;
1545 char *sub_name
= NULL
;
1547 sub_name
= mpctx
->subdata
->filename
;
1549 if (mpctx
->osd
->ass_track
)
1550 sub_name
= mpctx
->osd
->ass_track
->name
;
1552 if (!sub_name
&& mpctx
->subdata
)
1553 sub_name
= mpctx
->subdata
->filename
;
1555 const char *tmp
= mp_basename(sub_name
);
1557 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1558 mpctx
->set_of_sub_pos
+ 1,
1559 strlen(tmp
) < 20 ? "" : "...",
1560 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1561 return M_PROPERTY_OK
;
1563 #ifdef CONFIG_DVDNAV
1564 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1565 if (vo_spudec
&& opts
->sub_id
>= 0) {
1566 unsigned char lang
[3];
1567 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1568 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1569 return M_PROPERTY_OK
;
1575 if ((d_sub
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1576 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF
1577 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1578 || d_sub
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1579 && d_sub
->sh
&& opts
->sub_id
>= 0) {
1580 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1581 if (!lang
) lang
= mp_gtext("unknown");
1582 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1583 return M_PROPERTY_OK
;
1586 if (vo_vobsub
&& vobsub_id
>= 0) {
1587 const char *language
= mp_gtext("unknown");
1588 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1589 snprintf(*(char **) arg
, 63, "(%d) %s",
1590 vobsub_id
, language
? language
: mp_gtext("unknown"));
1591 return M_PROPERTY_OK
;
1593 #ifdef CONFIG_DVDREAD
1594 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1595 && opts
->sub_id
>= 0) {
1597 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1598 lang
[0] = code
>> 8;
1601 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1602 return M_PROPERTY_OK
;
1605 if (opts
->sub_id
>= 0) {
1606 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1607 mp_gtext("unknown"));
1608 return M_PROPERTY_OK
;
1610 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1611 return M_PROPERTY_OK
;
1613 case M_PROPERTY_SET
:
1615 return M_PROPERTY_ERROR
;
1616 if (*(int *) arg
< -1)
1618 else if (*(int *) arg
>= global_sub_size
)
1619 *(int *) arg
= global_sub_size
- 1;
1620 mpctx
->global_sub_pos
= *(int *) arg
;
1622 case M_PROPERTY_STEP_UP
:
1623 mpctx
->global_sub_pos
+= 2;
1624 mpctx
->global_sub_pos
=
1625 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1627 case M_PROPERTY_STEP_DOWN
:
1628 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1629 mpctx
->global_sub_pos
=
1630 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1633 return M_PROPERTY_NOT_IMPLEMENTED
;
1636 if (mpctx
->global_sub_pos
>= 0) {
1637 source
= sub_source(mpctx
);
1638 source_pos
= sub_source_pos(mpctx
);
1641 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1642 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1644 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1645 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1646 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1647 mpctx
->global_sub_pos
, source
);
1649 mpctx
->set_of_sub_pos
= -1;
1650 mpctx
->subdata
= NULL
;
1659 mpctx
->osd
->ass_track
= NULL
;
1660 uninit_player(mpctx
, INITIALIZED_SUB
);
1662 if (source
== SUB_SOURCE_VOBSUB
) {
1663 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1664 } else if (source
== SUB_SOURCE_SUBS
) {
1665 mpctx
->set_of_sub_pos
= source_pos
;
1667 if (opts
->ass_enabled
1668 && mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
]) {
1669 mpctx
->osd
->ass_track
=
1670 mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1671 mpctx
->osd
->ass_track_changed
= true;
1672 mpctx
->osd
->vsfilter_aspect
=
1673 mpctx
->track_was_native_ass
[mpctx
->set_of_sub_pos
];
1677 mpctx
->subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1678 vo_osd_changed(OSDTYPE_SUBTITLE
);
1680 } else if (source
== SUB_SOURCE_DEMUX
) {
1681 opts
->sub_id
= source_pos
;
1682 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1684 // default: assume 1:1 mapping of sid and stream id
1685 d_sub
->id
= opts
->sub_id
;
1686 d_sub
->sh
= mpctx
->d_sub
->demuxer
->s_streams
[d_sub
->id
];
1687 ds_free_packs(d_sub
);
1688 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1689 sh_sub_t
*sh
= mpctx
->d_sub
->demuxer
->s_streams
[i
];
1690 if (sh
&& sh
->sid
== opts
->sub_id
) {
1696 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1697 sh_sub_t
*sh
= d_sub
->sh
;
1698 if (sh
->type
== 'v')
1699 init_vo_spudec(mpctx
);
1701 sub_init(sh
, mpctx
->osd
);
1702 mpctx
->initialized_flags
|= INITIALIZED_SUB
;
1710 #ifdef CONFIG_DVDREAD
1712 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1713 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1714 && opts
->sub_id
< 0 && reset_spu
) {
1720 update_subtitles(mpctx
, 0, 0, true);
1722 return M_PROPERTY_OK
;
1725 /// Selected sub source (RW)
1726 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1730 update_global_sub_size(mpctx
);
1731 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1732 return M_PROPERTY_UNAVAILABLE
;
1735 case M_PROPERTY_GET
:
1737 return M_PROPERTY_ERROR
;
1738 *(int *) arg
= sub_source(mpctx
);
1739 return M_PROPERTY_OK
;
1740 case M_PROPERTY_PRINT
:
1742 return M_PROPERTY_ERROR
;
1743 *(char **) arg
= malloc(64);
1744 (*(char **) arg
)[63] = 0;
1745 switch (sub_source(mpctx
))
1747 case SUB_SOURCE_SUBS
:
1748 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1750 case SUB_SOURCE_VOBSUB
:
1751 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1753 case SUB_SOURCE_DEMUX
:
1754 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1757 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1759 return M_PROPERTY_OK
;
1760 case M_PROPERTY_SET
:
1762 return M_PROPERTY_ERROR
;
1763 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1764 if (*(int *) arg
< 0)
1765 mpctx
->global_sub_pos
= -1;
1766 else if (*(int *) arg
!= sub_source(mpctx
)) {
1767 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1769 return M_PROPERTY_UNAVAILABLE
;
1770 mpctx
->global_sub_pos
= new_pos
;
1773 case M_PROPERTY_STEP_UP
:
1774 case M_PROPERTY_STEP_DOWN
: {
1775 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1776 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1777 int step
= (step_all
> 0) ? 1 : -1;
1778 int cur_source
= sub_source(mpctx
);
1779 source
= cur_source
;
1782 if (source
>= SUB_SOURCES
)
1784 else if (source
< -1)
1785 source
= SUB_SOURCES
- 1;
1786 if (source
== cur_source
|| source
== -1 ||
1787 mpctx
->sub_counts
[source
])
1790 if (source
== cur_source
)
1791 return M_PROPERTY_OK
;
1793 mpctx
->global_sub_pos
= -1;
1795 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1799 return M_PROPERTY_NOT_IMPLEMENTED
;
1801 --mpctx
->global_sub_pos
;
1802 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1805 /// Selected subtitles from specific source (RW)
1806 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1809 int source
, is_cur_source
, offset
, new_pos
;
1810 update_global_sub_size(mpctx
);
1811 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1812 return M_PROPERTY_UNAVAILABLE
;
1814 if (!strcmp(prop
->name
, "sub_file"))
1815 source
= SUB_SOURCE_SUBS
;
1816 else if (!strcmp(prop
->name
, "sub_vob"))
1817 source
= SUB_SOURCE_VOBSUB
;
1818 else if (!strcmp(prop
->name
, "sub_demux"))
1819 source
= SUB_SOURCE_DEMUX
;
1821 return M_PROPERTY_ERROR
;
1823 offset
= sub_pos_by_source(mpctx
, source
);
1825 return M_PROPERTY_UNAVAILABLE
;
1827 is_cur_source
= sub_source(mpctx
) == source
;
1828 new_pos
= mpctx
->global_sub_pos
;
1830 case M_PROPERTY_GET
:
1832 return M_PROPERTY_ERROR
;
1833 if (is_cur_source
) {
1834 *(int *) arg
= sub_source_pos(mpctx
);
1835 if (source
== SUB_SOURCE_VOBSUB
)
1836 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1840 return M_PROPERTY_OK
;
1841 case M_PROPERTY_PRINT
:
1843 return M_PROPERTY_ERROR
;
1845 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1846 *(char **) arg
= malloc(64);
1847 (*(char **) arg
)[63] = 0;
1848 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1849 return M_PROPERTY_OK
;
1850 case M_PROPERTY_SET
:
1852 return M_PROPERTY_ERROR
;
1853 if (*(int *) arg
>= 0) {
1854 int index
= *(int *)arg
;
1855 if (source
== SUB_SOURCE_VOBSUB
)
1856 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1857 new_pos
= offset
+ index
;
1858 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1866 case M_PROPERTY_STEP_UP
:
1867 case M_PROPERTY_STEP_DOWN
: {
1868 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1869 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1870 int step
= (step_all
> 0) ? 1 : -1;
1871 int max_sub_pos_for_source
= -1;
1875 if (new_pos
== -1) {
1878 else if (max_sub_pos_for_source
== -1) {
1879 // Find max pos for specific source
1880 new_pos
= mpctx
->global_sub_size
- 1;
1882 && sub_source(mpctx
) != source
)
1886 new_pos
= max_sub_pos_for_source
;
1890 if (new_pos
< offset
||
1891 new_pos
>= mpctx
->global_sub_size
||
1892 sub_source(mpctx
) != source
)
1900 return M_PROPERTY_NOT_IMPLEMENTED
;
1902 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1905 /// Subtitle delay (RW)
1906 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1909 if (!mpctx
->sh_video
)
1910 return M_PROPERTY_UNAVAILABLE
;
1911 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1914 /// Alignment of text subtitles (RW)
1915 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1916 void *arg
, MPContext
*mpctx
)
1918 char *name
[] = { _("top"), _("center"), _("bottom") };
1920 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1921 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1922 return M_PROPERTY_UNAVAILABLE
;
1925 case M_PROPERTY_PRINT
:
1927 return M_PROPERTY_ERROR
;
1928 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1929 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1930 return M_PROPERTY_OK
;
1931 case M_PROPERTY_SET
:
1933 return M_PROPERTY_ERROR
;
1934 case M_PROPERTY_STEP_UP
:
1935 case M_PROPERTY_STEP_DOWN
:
1936 vo_osd_changed(OSDTYPE_SUBTITLE
);
1938 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1942 /// Subtitle visibility (RW)
1943 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1944 void *arg
, MPContext
*mpctx
)
1946 if (!mpctx
->sh_video
)
1947 return M_PROPERTY_UNAVAILABLE
;
1950 case M_PROPERTY_SET
:
1952 return M_PROPERTY_ERROR
;
1953 case M_PROPERTY_STEP_UP
:
1954 case M_PROPERTY_STEP_DOWN
:
1955 vo_osd_changed(OSDTYPE_SUBTITLE
);
1957 vo_osd_changed(OSDTYPE_SPU
);
1959 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1964 /// Use margins for libass subtitles (RW)
1965 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1966 void *arg
, MPContext
*mpctx
)
1968 if (!mpctx
->sh_video
)
1969 return M_PROPERTY_UNAVAILABLE
;
1972 case M_PROPERTY_SET
:
1974 return M_PROPERTY_ERROR
;
1975 case M_PROPERTY_STEP_UP
:
1976 case M_PROPERTY_STEP_DOWN
:
1977 ass_force_reload
= 1;
1979 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1984 /// Show only forced subtitles (RW)
1985 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1986 void *arg
, MPContext
*mpctx
)
1989 return M_PROPERTY_UNAVAILABLE
;
1992 case M_PROPERTY_SET
:
1994 return M_PROPERTY_ERROR
;
1995 case M_PROPERTY_STEP_UP
:
1996 case M_PROPERTY_STEP_DOWN
:
1997 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1998 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1999 return M_PROPERTY_OK
;
2001 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
2006 #ifdef CONFIG_FREETYPE
2007 /// Subtitle scale (RW)
2008 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
2011 struct MPOpts
*opts
= &mpctx
->opts
;
2014 case M_PROPERTY_SET
:
2016 return M_PROPERTY_ERROR
;
2017 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
2019 if (opts
->ass_enabled
) {
2020 ass_font_scale
= *(float *) arg
;
2021 ass_force_reload
= 1;
2024 text_font_scale_factor
= *(float *) arg
;
2025 force_load_font
= 1;
2026 return M_PROPERTY_OK
;
2027 case M_PROPERTY_STEP_UP
:
2028 case M_PROPERTY_STEP_DOWN
:
2030 if (opts
->ass_enabled
) {
2031 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
2032 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2033 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
2034 ass_force_reload
= 1;
2037 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
2038 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2039 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2040 force_load_font
= 1;
2041 return M_PROPERTY_OK
;
2044 if (opts
->ass_enabled
)
2045 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
2048 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2055 /// \defgroup TVProperties TV properties
2056 /// \ingroup Properties
2061 /// TV color settings (RW)
2062 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2066 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2067 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2068 return M_PROPERTY_UNAVAILABLE
;
2071 case M_PROPERTY_SET
:
2073 return M_PROPERTY_ERROR
;
2074 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2075 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2076 case M_PROPERTY_GET
:
2077 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2078 case M_PROPERTY_STEP_UP
:
2079 case M_PROPERTY_STEP_DOWN
:
2080 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2082 return M_PROPERTY_ERROR
;
2083 val
+= (arg
? *(int *) arg
: 1) *
2084 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2085 M_PROPERTY_CLAMP(prop
, val
);
2086 return tv_set_color_options(tvh
, prop
->offset
, val
);
2088 return M_PROPERTY_ERROR
;
2090 return M_PROPERTY_NOT_IMPLEMENTED
;
2095 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2099 int base_ioctl
= prop
->offset
;
2101 for teletext's GET,SET,STEP ioctls this is not 0
2105 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2106 return M_PROPERTY_UNAVAILABLE
;
2108 return M_PROPERTY_ERROR
;
2111 case M_PROPERTY_GET
:
2113 return M_PROPERTY_ERROR
;
2114 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2116 case M_PROPERTY_SET
:
2118 return M_PROPERTY_ERROR
;
2119 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2120 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2122 case M_PROPERTY_STEP_UP
:
2123 case M_PROPERTY_STEP_DOWN
:
2124 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2125 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2126 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2129 return M_PROPERTY_NOT_IMPLEMENTED
;
2132 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2135 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2141 //with tvh==NULL will fail too
2142 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2143 if(result
!=M_PROPERTY_OK
)
2146 if(teletext_control(mpctx
->demuxer
->teletext
,
2147 prop
->offset
, &val
)==VBI_CONTROL_TRUE
&& val
)
2148 mp_input_set_section(mpctx
->input
, "teletext");
2150 mp_input_set_section(mpctx
->input
, "tv");
2151 return M_PROPERTY_OK
;
2154 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2159 if (!mpctx
->demuxer
->teletext
)
2160 return M_PROPERTY_UNAVAILABLE
;
2162 case M_PROPERTY_STEP_UP
:
2163 case M_PROPERTY_STEP_DOWN
:
2164 //This should be handled separately
2165 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2166 result
=teletext_control(mpctx
->demuxer
->teletext
,
2167 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2170 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2177 /// All properties available in MPlayer.
2178 /** \ingroup Properties
2180 static const m_option_t mp_properties
[] = {
2182 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2183 M_OPT_RANGE
, 0, 3, NULL
},
2184 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2185 M_OPT_MIN
, -1, 0, NULL
},
2186 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2187 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2188 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2190 { "path", mp_property_path
, CONF_TYPE_STRING
,
2192 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2194 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2195 M_OPT_MIN
, 0, 0, NULL
},
2196 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2197 M_OPT_MIN
, 0, 0, NULL
},
2198 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2199 M_OPT_MIN
, 0, 0, NULL
},
2200 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2201 M_OPT_MIN
, 0, 0, NULL
},
2202 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2203 M_OPT_MIN
, 0, 0, NULL
},
2204 { "length", mp_property_length
, CONF_TYPE_TIME
,
2205 M_OPT_MIN
, 0, 0, NULL
},
2206 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2207 M_OPT_RANGE
, 0, 100, NULL
},
2208 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2209 M_OPT_MIN
, 0, 0, NULL
},
2210 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2211 M_OPT_MIN
, 0, 0, NULL
},
2212 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2214 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2215 CONF_RANGE
, -2, 10, NULL
},
2216 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2218 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2219 M_OPT_RANGE
, 0, 1, NULL
},
2220 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2221 M_OPT_RANGE
, 0, 1, NULL
},
2222 { "pts_association_mode", mp_property_generic_option
, &m_option_type_choice
,
2223 0, 0, 0, "pts-association-mode" },
2224 { "hr_seek", mp_property_generic_option
, &m_option_type_choice
,
2225 0, 0, 0, "hr-seek" },
2228 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2229 M_OPT_RANGE
, 0, 100, NULL
},
2230 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2231 M_OPT_RANGE
, 0, 1, NULL
},
2232 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2233 M_OPT_RANGE
, -100, 100, NULL
},
2234 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2236 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2238 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2240 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2242 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2244 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2245 CONF_RANGE
, -2, 65535, NULL
},
2246 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2247 M_OPT_RANGE
, -1, 1, NULL
},
2250 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2251 M_OPT_RANGE
, 0, 1, NULL
},
2252 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2253 M_OPT_RANGE
, 0, 1, NULL
},
2254 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2255 M_OPT_RANGE
, 0, 2, NULL
},
2256 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2257 M_OPT_RANGE
, 0, 1, NULL
},
2258 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2259 M_OPT_RANGE
, 0, 1, NULL
},
2260 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2261 M_OPT_RANGE
, 0, 1, NULL
},
2262 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2263 M_OPT_RANGE
, 0, 2, NULL
},
2264 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2265 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_gamma
)},
2266 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2267 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_brightness
) },
2268 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2269 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_contrast
) },
2270 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2271 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_saturation
) },
2272 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2273 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_hue
) },
2274 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2275 M_OPT_RANGE
, 0, 1, NULL
},
2276 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2277 M_OPT_RANGE
, 0, 1, NULL
},
2278 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2280 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2282 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2284 { "width", mp_property_width
, CONF_TYPE_INT
,
2286 { "height", mp_property_height
, CONF_TYPE_INT
,
2288 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2290 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2292 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2293 CONF_RANGE
, -2, 65535, NULL
},
2294 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2295 CONF_RANGE
, -1, 65535, NULL
},
2298 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2299 M_OPT_MIN
, -1, 0, NULL
},
2300 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2301 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2302 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2303 M_OPT_MIN
, -1, 0, NULL
},
2304 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2305 M_OPT_MIN
, -1, 0, NULL
},
2306 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2307 M_OPT_MIN
, -1, 0, NULL
},
2308 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2310 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2311 M_OPT_RANGE
, 0, 100, NULL
},
2312 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2313 M_OPT_RANGE
, 0, 2, NULL
},
2314 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2315 M_OPT_RANGE
, 0, 1, NULL
},
2316 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2317 M_OPT_RANGE
, 0, 1, NULL
},
2318 #ifdef CONFIG_FREETYPE
2319 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2320 M_OPT_RANGE
, 0, 100, NULL
},
2323 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2324 M_OPT_RANGE
, 0, 1, NULL
},
2328 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2329 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_BRIGHTNESS
},
2330 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2331 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_CONTRAST
},
2332 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2333 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_SATURATION
},
2334 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2335 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_HUE
},
2337 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2338 M_OPT_RANGE
, 100, 899, .offset
=TV_VBI_CONTROL_GET_PAGE
},
2339 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2340 M_OPT_RANGE
, 0, 64, .offset
=TV_VBI_CONTROL_GET_SUBPAGE
},
2341 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2342 M_OPT_RANGE
, 0, 1, .offset
=TV_VBI_CONTROL_GET_MODE
},
2343 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2344 M_OPT_RANGE
, 0, 3, .offset
=TV_VBI_CONTROL_GET_FORMAT
},
2345 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2346 M_OPT_RANGE
, 0, 2, .offset
=TV_VBI_CONTROL_GET_HALF_PAGE
},
2347 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2351 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2353 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2356 char* mp_property_print(const char *name
, void* ctx
)
2359 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2364 char *property_expand_string(MPContext
*mpctx
, char *str
)
2366 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2369 void property_print_help(void)
2371 m_properties_print_help_list(mp_properties
);
2375 /* List of default ways to show a property on OSD.
2377 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2378 * a bar showing the current position between min/max values of the
2379 * property. In this case osd_msg is only used for terminal output
2380 * if there is no video; it'll be a label shown together with percentage.
2382 * Otherwise setting osd_msg will show the string on OSD, formatted with
2383 * the text value of the property as argument.
2385 static struct property_osd_display
{
2388 /// progressbar type
2389 int osd_progbar
; // -1 is special value for seek indicators
2390 /// osd msg id if it must be shared
2392 /// osd msg template
2393 const char *osd_msg
;
2394 } property_osd_display
[] = {
2396 { "loop", 0, -1, _("Loop: %s") },
2397 { "chapter", -1, -1, NULL
},
2398 { "capturing", 0, -1, _("Capturing: %s") },
2399 { "pts_association_mode", 0, -1, "PTS association mode: %s" },
2400 { "hr_seek", 0, -1, "hr-seek: %s" },
2402 { "volume", OSD_VOLUME
, -1, _("Volume") },
2403 { "mute", 0, -1, _("Mute: %s") },
2404 { "audio_delay", 0, -1, _("A-V delay: %s") },
2405 { "switch_audio", 0, -1, _("Audio: %s") },
2406 { "balance", OSD_BALANCE
, -1, _("Balance") },
2408 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2409 { "ontop", 0, -1, _("Stay on top: %s") },
2410 { "rootwin", 0, -1, _("Rootwin: %s") },
2411 { "border", 0, -1, _("Border: %s") },
2412 { "framedropping", 0, -1, _("Framedropping: %s") },
2413 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2414 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2415 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2416 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2417 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2418 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2419 { "hue", OSD_HUE
, -1, _("Hue") },
2420 { "vsync", 0, -1, _("VSync: %s") },
2422 { "sub", 0, -1, _("Subtitles: %s") },
2423 { "sub_source", 0, -1, _("Sub source: %s") },
2424 { "sub_vob", 0, -1, _("Subtitles: %s") },
2425 { "sub_demux", 0, -1, _("Subtitles: %s") },
2426 { "sub_file", 0, -1, _("Subtitles: %s") },
2427 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2428 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2429 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2430 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2431 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2432 #ifdef CONFIG_FREETYPE
2433 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2436 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2437 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2438 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2439 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2444 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2446 struct MPOpts
*opts
= &mpctx
->opts
;
2449 struct property_osd_display
*p
;
2451 // look for the command
2452 for (p
= property_osd_display
; p
->name
; p
++)
2453 if (!strcmp(p
->name
, pname
))
2458 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2461 if (p
->osd_progbar
== -1)
2462 mpctx
->add_osd_seek_info
= true;
2463 else if (p
->osd_progbar
) {
2464 if (prop
->type
== CONF_TYPE_INT
) {
2465 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2466 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2467 prop
->min
, prop
->max
, r
);
2468 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2470 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2471 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2472 prop
->min
, prop
->max
, f
);
2474 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2475 "Property use an unsupported type.\n");
2482 char *val
= mp_property_print(pname
, mpctx
);
2484 int index
= p
- property_osd_display
;
2485 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2486 1, opts
->osd_duration
, p
->osd_msg
, val
);
2495 * \defgroup Command2Property Command to property bridge
2497 * It is used to handle most commands that just set a property
2498 * and optionally display something on the OSD.
2499 * Two kinds of commands are handled: adjust or toggle.
2501 * Adjust commands take 1 or 2 parameters: <value> <abs>
2502 * If <abs> is non-zero the property is set to the given value
2503 * otherwise it is adjusted.
2505 * Toggle commands take 0 or 1 parameters. With no parameter
2506 * or a value less than the property minimum it just steps the
2507 * property to its next or previous value respectively.
2508 * Otherwise it sets it to the given value.
2513 /// List of the commands that can be handled by setting a property.
2519 /// set/adjust or toggle command
2521 } set_prop_cmd
[] = {
2523 { "loop", MP_CMD_LOOP
, 0},
2524 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2525 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2526 { "pause", MP_CMD_PAUSE
, 0},
2527 { "capturing", MP_CMD_CAPTURING
, 1},
2529 { "volume", MP_CMD_VOLUME
, 0},
2530 { "mute", MP_CMD_MUTE
, 1},
2531 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2532 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2533 { "balance", MP_CMD_BALANCE
, 0},
2535 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2536 { "panscan", MP_CMD_PANSCAN
, 0},
2537 { "ontop", MP_CMD_VO_ONTOP
, 1},
2538 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2539 { "border", MP_CMD_VO_BORDER
, 1},
2540 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2541 { "gamma", MP_CMD_GAMMA
, 0},
2542 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2543 { "contrast", MP_CMD_CONTRAST
, 0},
2544 { "saturation", MP_CMD_SATURATION
, 0},
2545 { "hue", MP_CMD_HUE
, 0},
2546 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2548 { "sub", MP_CMD_SUB_SELECT
, 1},
2549 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2550 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2551 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2552 { "sub_file", MP_CMD_SUB_FILE
, 1},
2553 { "sub_pos", MP_CMD_SUB_POS
, 0},
2554 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2555 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2556 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2557 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2558 #ifdef CONFIG_FREETYPE
2559 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2562 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2565 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2566 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2567 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2568 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2573 /// Handle commands that set a property.
2574 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2580 // look for the command
2581 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2582 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2584 if (!(pname
= set_prop_cmd
[i
].name
))
2587 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2591 if (set_prop_cmd
[i
].toggle
) {
2593 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2594 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2595 else if (cmd
->nargs
> 0)
2596 r
= mp_property_do(pname
, M_PROPERTY_STEP_DOWN
, NULL
, mpctx
);
2598 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2599 } else if (cmd
->args
[1].v
.i
) //set
2600 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2602 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2607 show_property_osd(mpctx
, pname
);
2612 #ifdef CONFIG_DVDNAV
2613 static const struct {
2615 const mp_command_type cmd
;
2616 } mp_dvdnav_bindings
[] = {
2617 { "up", MP_CMD_DVDNAV_UP
},
2618 { "down", MP_CMD_DVDNAV_DOWN
},
2619 { "left", MP_CMD_DVDNAV_LEFT
},
2620 { "right", MP_CMD_DVDNAV_RIGHT
},
2621 { "menu", MP_CMD_DVDNAV_MENU
},
2622 { "select", MP_CMD_DVDNAV_SELECT
},
2623 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2624 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2627 * keep old dvdnav sub-command options for a while in order not to
2628 * break slave-mode API too suddenly.
2630 { "1", MP_CMD_DVDNAV_UP
},
2631 { "2", MP_CMD_DVDNAV_DOWN
},
2632 { "3", MP_CMD_DVDNAV_LEFT
},
2633 { "4", MP_CMD_DVDNAV_RIGHT
},
2634 { "5", MP_CMD_DVDNAV_MENU
},
2635 { "6", MP_CMD_DVDNAV_SELECT
},
2636 { "7", MP_CMD_DVDNAV_PREVMENU
},
2637 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2642 static const char *property_error_string(int error_value
)
2644 switch (error_value
) {
2645 case M_PROPERTY_ERROR
:
2647 case M_PROPERTY_UNAVAILABLE
:
2648 return "PROPERTY_UNAVAILABLE";
2649 case M_PROPERTY_NOT_IMPLEMENTED
:
2650 return "NOT_IMPLEMENTED";
2651 case M_PROPERTY_UNKNOWN
:
2652 return "PROPERTY_UNKNOWN";
2653 case M_PROPERTY_DISABLED
:
2659 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2662 int end
= start
+ count
;
2663 int after
= mpctx
->set_of_sub_size
- end
;
2664 sub_data
**subs
= mpctx
->set_of_subtitles
;
2666 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2668 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2669 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2670 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2671 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2674 for (idx
= start
; idx
< end
; idx
++) {
2675 sub_data
*subd
= subs
[idx
];
2676 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2677 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2678 filename_recode(subd
->filename
));
2682 if (ass_tracks
[idx
])
2683 ass_free_track(ass_tracks
[idx
]);
2684 ass_tracks
[idx
] = NULL
;
2688 mpctx
->global_sub_size
-= count
;
2689 mpctx
->set_of_sub_size
-= count
;
2690 if (mpctx
->set_of_sub_size
<= 0)
2691 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2693 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2694 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2696 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2697 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2700 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2701 mpctx
->global_sub_pos
= -2;
2702 mpctx
->subdata
= NULL
;
2703 mpctx
->osd
->ass_track
= NULL
;
2704 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2705 } else if (mpctx
->set_of_sub_pos
>= end
) {
2706 mpctx
->set_of_sub_pos
-= count
;
2707 mpctx
->global_sub_pos
-= count
;
2711 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2713 struct MPOpts
*opts
= &mpctx
->opts
;
2714 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2715 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2716 int osd_duration
= opts
->osd_duration
;
2717 int case_fallthrough_hack
= 0;
2718 if (!set_property_command(mpctx
, cmd
))
2721 mpctx
->add_osd_seek_info
= true;
2722 float v
= cmd
->args
[0].v
.f
;
2723 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2724 int exact
= (cmd
->nargs
> 2) ? cmd
->args
[2].v
.i
: 0;
2725 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2726 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, v
, exact
);
2727 mpctx
->osd_function
= v
> get_current_time(mpctx
) ?
2729 } else if (abs
) { /* Absolute seek by percentage */
2730 queue_seek(mpctx
, MPSEEK_FACTOR
, v
/ 100.0, exact
);
2731 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2733 queue_seek(mpctx
, MPSEEK_RELATIVE
, v
, exact
);
2734 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2739 case MP_CMD_SET_PROPERTY_OSD
:
2740 case_fallthrough_hack
= 1;
2742 case MP_CMD_SET_PROPERTY
:{
2743 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2744 cmd
->args
[1].v
.s
, mpctx
);
2745 if (r
== M_PROPERTY_UNKNOWN
)
2746 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2747 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2749 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2750 "Failed to set property '%s' to '%s'.\n",
2751 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2752 else if (case_fallthrough_hack
)
2753 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2755 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2759 case MP_CMD_STEP_PROPERTY_OSD
:
2760 case_fallthrough_hack
= 1;
2762 case MP_CMD_STEP_PROPERTY
:{
2767 if (cmd
->args
[1].v
.f
) {
2769 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2770 M_PROPERTY_GET_TYPE
,
2771 &prop
, mpctx
)) <= 0)
2773 if(prop
->type
== CONF_TYPE_INT
||
2774 prop
->type
== CONF_TYPE_FLAG
)
2775 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2776 else if(prop
->type
== CONF_TYPE_FLOAT
)
2777 arg
= &cmd
->args
[1].v
.f
;
2778 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2779 prop
->type
== CONF_TYPE_TIME
)
2780 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2781 else if(prop
->type
== CONF_TYPE_POSITION
)
2782 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2784 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2785 "Ignoring step size stepping property '%s'.\n",
2788 r
= mp_property_do(cmd
->args
[0].v
.s
,
2789 cmd
->args
[2].v
.i
< 0 ?
2790 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2793 if (r
== M_PROPERTY_UNKNOWN
)
2794 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2795 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2797 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2798 "Failed to increment property '%s' by %f.\n",
2799 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2800 else if (case_fallthrough_hack
)
2801 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2803 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2807 case MP_CMD_GET_PROPERTY
:{
2809 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2812 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2813 "Failed to get value of property '%s'.\n",
2815 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2818 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2819 cmd
->args
[0].v
.s
, tmp
);
2824 case MP_CMD_EDL_MARK
:
2826 float v
= get_current_time(mpctx
);
2827 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2828 mpctx
->begin_skip
= v
;
2829 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2831 if (mpctx
->begin_skip
> v
)
2832 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2834 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2835 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2837 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2842 case MP_CMD_SWITCH_RATIO
:
2845 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2846 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2848 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2849 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2852 case MP_CMD_SPEED_INCR
:{
2853 float v
= cmd
->args
[0].v
.f
;
2854 opts
->playback_speed
+= v
;
2855 reinit_audio_chain(mpctx
);
2856 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2857 opts
->playback_speed
);
2860 case MP_CMD_SPEED_MULT
:{
2861 float v
= cmd
->args
[0].v
.f
;
2862 opts
->playback_speed
*= v
;
2863 reinit_audio_chain(mpctx
);
2864 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2865 opts
->playback_speed
);
2868 case MP_CMD_SPEED_SET
:{
2869 float v
= cmd
->args
[0].v
.f
;
2870 opts
->playback_speed
= v
;
2871 reinit_audio_chain(mpctx
);
2872 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2873 opts
->playback_speed
);
2876 case MP_CMD_FRAME_STEP
:
2877 add_step_frame(mpctx
);
2880 case MP_CMD_FILE_FILTER
:
2881 file_filter
= cmd
->args
[0].v
.i
;
2885 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2886 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2888 case MP_CMD_PLAY_TREE_STEP
:{
2889 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2890 int force
= cmd
->args
[1].v
.i
;
2893 if (!force
&& mpctx
->playtree_iter
) {
2894 play_tree_iter_t
*i
=
2895 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2896 if (play_tree_iter_step(i
, n
, 0) ==
2897 PLAY_TREE_ITER_ENTRY
)
2899 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2900 play_tree_iter_free(i
);
2902 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2903 if (mpctx
->stop_play
)
2904 mpctx
->play_tree_step
= n
;
2909 case MP_CMD_PLAY_TREE_UP_STEP
:{
2910 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2911 int force
= cmd
->args
[1].v
.i
;
2913 if (!force
&& mpctx
->playtree_iter
) {
2914 play_tree_iter_t
*i
=
2915 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2916 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2917 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2918 play_tree_iter_free(i
);
2920 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2924 case MP_CMD_PLAY_ALT_SRC_STEP
:
2925 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2926 int v
= cmd
->args
[0].v
.i
;
2928 && mpctx
->playtree_iter
->file
<
2929 mpctx
->playtree_iter
->num_files
)
2930 mpctx
->stop_play
= PT_NEXT_SRC
;
2931 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2932 mpctx
->stop_play
= PT_PREV_SRC
;
2936 case MP_CMD_SUB_STEP
:
2938 int movement
= cmd
->args
[0].v
.i
;
2939 step_sub(mpctx
->subdata
, mpctx
->video_pts
, movement
);
2941 if (mpctx
->osd
->ass_track
)
2943 ass_step_sub(mpctx
->osd
->ass_track
,
2945 sub_delay
) * 1000 + .5, movement
) / 1000.;
2947 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2948 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2952 case MP_CMD_SUB_LOG
:
2957 int v
= cmd
->args
[0].v
.i
;
2958 int max
= (opts
->term_osd
2959 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2960 if (opts
->osd_level
> max
)
2961 opts
->osd_level
= max
;
2963 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2965 opts
->osd_level
= v
> max
? max
: v
;
2966 /* Show OSD state when disabled, but not when an explicit
2967 argument is given to the OSD command, i.e. in slave mode. */
2968 if (v
== -1 && opts
->osd_level
<= 1)
2969 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2971 opts
->osd_level
? mp_gtext("enabled") :
2972 mp_gtext("disabled"));
2974 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2978 case MP_CMD_OSD_SHOW_TEXT
:
2979 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2981 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2982 "%-.63s", cmd
->args
[0].v
.s
);
2985 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2986 char *txt
= m_properties_expand_string(mp_properties
,
2989 /* if no argument supplied take default osd_duration, else <arg> ms. */
2991 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2993 0 ? osd_duration
: cmd
->args
[1].v
.i
),
3000 case MP_CMD_LOADFILE
:{
3001 play_tree_t
*e
= play_tree_new();
3002 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
3004 if (cmd
->args
[1].v
.i
) // append
3005 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3007 // Go back to the starting point.
3008 while (play_tree_iter_up_step
3009 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3011 play_tree_free_list(mpctx
->playtree
->child
, 1);
3012 play_tree_set_child(mpctx
->playtree
, e
);
3013 pt_iter_goto_head(mpctx
->playtree_iter
);
3014 mpctx
->stop_play
= PT_NEXT_SRC
;
3019 case MP_CMD_LOADLIST
:{
3020 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
3022 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
3023 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
3025 if (cmd
->args
[1].v
.i
) // append
3026 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3028 // Go back to the starting point.
3029 while (play_tree_iter_up_step
3030 (mpctx
->playtree_iter
, 0, 1)
3031 != PLAY_TREE_ITER_END
)
3033 play_tree_free_list(mpctx
->playtree
->child
, 1);
3034 play_tree_set_child(mpctx
->playtree
, e
);
3035 pt_iter_goto_head(mpctx
->playtree_iter
);
3036 mpctx
->stop_play
= PT_NEXT_SRC
;
3043 // Go back to the starting point.
3044 while (play_tree_iter_up_step
3045 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3047 mpctx
->stop_play
= PT_STOP
;
3050 case MP_CMD_OSD_SHOW_PROGRESSION
:{
3051 int len
= get_time_length(mpctx
);
3052 int pts
= get_current_time(mpctx
);
3053 set_osd_bar(mpctx
, 0, "Position", 0, 100, get_percent_pos(mpctx
));
3054 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3055 "%c %02d:%02d:%02d / %02d:%02d:%02d",
3056 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
3057 len
/3600, (len
/60)%60, len
%60);
3062 case MP_CMD_RADIO_STEP_CHANNEL
:
3063 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3064 int v
= cmd
->args
[0].v
.i
;
3066 radio_step_channel(mpctx
->demuxer
->stream
,
3067 RADIO_CHANNEL_HIGHER
);
3069 radio_step_channel(mpctx
->demuxer
->stream
,
3070 RADIO_CHANNEL_LOWER
);
3071 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3072 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3074 radio_get_channel_name(mpctx
->demuxer
->stream
));
3079 case MP_CMD_RADIO_SET_CHANNEL
:
3080 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3081 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3082 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3083 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3085 radio_get_channel_name(mpctx
->demuxer
->stream
));
3090 case MP_CMD_RADIO_SET_FREQ
:
3091 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3092 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3095 case MP_CMD_RADIO_STEP_FREQ
:
3096 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3097 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3102 case MP_CMD_TV_START_SCAN
:
3103 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3104 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3106 case MP_CMD_TV_SET_FREQ
:
3107 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3108 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3109 cmd
->args
[0].v
.f
* 16.0);
3111 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3112 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3113 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3114 pvr_get_current_channelname (mpctx
->stream
),
3115 pvr_get_current_stationname (mpctx
->stream
));
3117 #endif /* CONFIG_PVR */
3120 case MP_CMD_TV_STEP_FREQ
:
3121 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3122 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3123 cmd
->args
[0].v
.f
* 16.0);
3125 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3126 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3127 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3128 pvr_get_current_channelname (mpctx
->stream
),
3129 pvr_get_current_frequency (mpctx
->stream
));
3131 #endif /* CONFIG_PVR */
3134 case MP_CMD_TV_SET_NORM
:
3135 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3136 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3140 case MP_CMD_TV_STEP_CHANNEL
:{
3141 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3142 int v
= cmd
->args
[0].v
.i
;
3144 tv_step_channel((tvi_handle_t
*) (mpctx
->
3148 tv_step_channel((tvi_handle_t
*) (mpctx
->
3152 if (tv_channel_list
) {
3153 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3154 "Channel: %s", tv_channel_current
->name
);
3155 //vo_osd_changed(OSDTYPE_SUBTITLE);
3159 else if (mpctx
->stream
&&
3160 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3161 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3162 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3163 pvr_get_current_channelname (mpctx
->stream
),
3164 pvr_get_current_stationname (mpctx
->stream
));
3166 #endif /* CONFIG_PVR */
3169 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3171 int v
= cmd
->args
[0].v
.i
;
3173 mpctx
->last_dvb_step
= v
;
3175 dir
= DVB_CHANNEL_HIGHER
;
3177 dir
= DVB_CHANNEL_LOWER
;
3180 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3181 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3182 mpctx
->dvbin_reopen
= 1;
3185 #endif /* CONFIG_DVBIN */
3188 case MP_CMD_TV_SET_CHANNEL
:
3189 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3190 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3192 if (tv_channel_list
) {
3193 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3194 "Channel: %s", tv_channel_current
->name
);
3195 //vo_osd_changed(OSDTYPE_SUBTITLE);
3199 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3200 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3201 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3202 pvr_get_current_channelname (mpctx
->stream
),
3203 pvr_get_current_stationname (mpctx
->stream
));
3205 #endif /* CONFIG_PVR */
3209 case MP_CMD_DVB_SET_CHANNEL
:
3210 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3211 mpctx
->last_dvb_step
= 1;
3213 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3214 cmd
->args
[0].v
.i
)) {
3215 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3216 mpctx
->dvbin_reopen
= 1;
3220 #endif /* CONFIG_DVBIN */
3222 case MP_CMD_TV_LAST_CHANNEL
:
3223 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3224 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3225 if (tv_channel_list
) {
3226 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3227 "Channel: %s", tv_channel_current
->name
);
3228 //vo_osd_changed(OSDTYPE_SUBTITLE);
3232 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3233 pvr_set_lastchannel (mpctx
->stream
);
3234 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3235 pvr_get_current_channelname (mpctx
->stream
),
3236 pvr_get_current_stationname (mpctx
->stream
));
3238 #endif /* CONFIG_PVR */
3241 case MP_CMD_TV_STEP_NORM
:
3242 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3243 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3246 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3247 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3248 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3250 #endif /* CONFIG_TV */
3251 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3252 if (mpctx
->demuxer
->teletext
)
3253 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3254 &(cmd
->args
[0].v
.s
));
3256 case MP_CMD_TV_TELETEXT_GO_LINK
:
3257 if (mpctx
->demuxer
->teletext
)
3258 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3259 &(cmd
->args
[0].v
.i
));
3262 case MP_CMD_SUB_LOAD
:
3264 int n
= mpctx
->set_of_sub_size
;
3265 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3266 if (n
!= mpctx
->set_of_sub_size
) {
3267 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3268 ++mpctx
->global_sub_size
;
3273 case MP_CMD_SUB_REMOVE
:
3275 int v
= cmd
->args
[0].v
.i
;
3277 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3278 } else if (v
< mpctx
->set_of_sub_size
) {
3279 remove_subtitle_range(mpctx
, v
, 1);
3284 case MP_CMD_GET_SUB_VISIBILITY
:
3286 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3287 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3291 case MP_CMD_SCREENSHOT
:
3292 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3293 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3295 ((vf_instance_t
*) sh_video
->vfilter
)->
3296 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3298 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3302 case MP_CMD_VF_CHANGE_RECTANGLE
:
3305 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3308 case MP_CMD_GET_TIME_LENGTH
:{
3309 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3310 get_time_length(mpctx
));
3314 case MP_CMD_GET_FILENAME
:{
3315 char *inf
= get_metadata(mpctx
, META_NAME
);
3316 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n", inf
);
3321 case MP_CMD_GET_VIDEO_CODEC
:{
3322 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3323 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3328 case MP_CMD_GET_VIDEO_BITRATE
:{
3329 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3330 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3335 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3336 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3337 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3342 case MP_CMD_GET_AUDIO_CODEC
:{
3343 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3344 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3349 case MP_CMD_GET_AUDIO_BITRATE
:{
3350 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3351 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3356 case MP_CMD_GET_AUDIO_SAMPLES
:{
3357 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3358 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3363 case MP_CMD_GET_META_TITLE
:{
3364 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3365 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3370 case MP_CMD_GET_META_ARTIST
:{
3371 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3372 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3377 case MP_CMD_GET_META_ALBUM
:{
3378 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3379 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3384 case MP_CMD_GET_META_YEAR
:{
3385 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3386 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3391 case MP_CMD_GET_META_COMMENT
:{
3392 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3393 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3398 case MP_CMD_GET_META_TRACK
:{
3399 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3400 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3405 case MP_CMD_GET_META_GENRE
:{
3406 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3407 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3412 case MP_CMD_GET_VO_FULLSCREEN
:
3413 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3414 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3417 case MP_CMD_GET_PERCENT_POS
:
3418 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3419 get_percent_pos(mpctx
));
3422 case MP_CMD_GET_TIME_POS
:{
3423 float pos
= get_current_time(mpctx
);
3424 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3431 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3437 case MP_CMD_KEYDOWN_EVENTS
:
3438 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3441 case MP_CMD_SET_MOUSE_POS
:{
3442 int pointer_x
, pointer_y
;
3444 pointer_x
= cmd
->args
[0].v
.i
;
3445 pointer_y
= cmd
->args
[1].v
.i
;
3446 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3447 #ifdef CONFIG_DVDNAV
3448 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3449 && dx
> 0.0 && dy
> 0.0) {
3451 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3452 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3453 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3454 pointer_x
, pointer_y
, &button
);
3455 if (opts
->osd_level
> 1 && button
> 0)
3456 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3457 "Selected button number %d", button
);
3461 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3462 menu_update_mouse_pos(dx
, dy
);
3467 #ifdef CONFIG_DVDNAV
3468 case MP_CMD_DVDNAV
:{
3471 mp_command_type command
= 0;
3472 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3475 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3476 if (cmd
->args
[0].v
.s
&&
3477 !strcasecmp (cmd
->args
[0].v
.s
,
3478 mp_dvdnav_bindings
[i
].name
))
3479 command
= mp_dvdnav_bindings
[i
].cmd
;
3481 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3482 if (opts
->osd_level
> 1 && button
> 0)
3483 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3484 "Selected button number %d", button
);
3488 case MP_CMD_SWITCH_TITLE
:
3489 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3490 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3495 case MP_CMD_AF_SWITCH
:
3498 af_uninit(mpctx
->mixer
.afilter
);
3499 af_init(mpctx
->mixer
.afilter
);
3506 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3507 char* af_commands
= af_args
;
3510 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3512 if (cmd
->id
== MP_CMD_AF_DEL
)
3514 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3516 af_remove(mpctx
->mixer
.afilter
, af
);
3519 af_add(mpctx
->mixer
.afilter
, af_command
);
3521 reinit_audio_chain(mpctx
);
3528 af_uninit(mpctx
->mixer
.afilter
);
3529 af_init(mpctx
->mixer
.afilter
);
3530 reinit_audio_chain(mpctx
);
3532 case MP_CMD_AF_CMDLINE
:
3534 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3536 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3537 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3540 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3541 af_reinit(sh_audio
->afilter
, af
);
3546 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3547 "Received unknown cmd %s\n", cmd
->name
);
3550 switch (cmd
->pausing
) {
3551 case 1: // "pausing"
3552 pause_player(mpctx
);
3554 case 3: // "pausing_toggle"
3556 unpause_player(mpctx
);
3558 pause_player(mpctx
);