2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "input/input.h"
29 #include "stream/stream.h"
30 #include "libmpdemux/demuxer.h"
31 #include "libmpdemux/stheader.h"
32 #include "codec-cfg.h"
34 #include "libvo/sub.h"
36 #include "m_property.h"
39 #include "libmpcodecs/vf.h"
40 #include "libmpcodecs/vd.h"
42 #include "libvo/video_out.h"
43 #include "libvo/font_load.h"
45 #include "libao2/audio_out.h"
48 #include "libmpcodecs/dec_video.h"
49 #include "libmpcodecs/dec_audio.h"
50 #include "libmpcodecs/dec_teletext.h"
55 #include "stream/tv.h"
56 #include "stream/stream_radio.h"
57 #include "stream/pvr.h"
59 #include "stream/dvbin.h"
62 #include "stream/stream_dvd.h"
64 #include "stream/stream_dvdnav.h"
66 #include "libmenu/menu.h"
70 #include "libavutil/avstring.h"
72 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
76 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
77 double *dx
, double *dy
)
79 struct MPOpts
*opts
= &mpctx
->opts
;
80 struct vo
*vo
= mpctx
->video_out
;
81 //remove the borders, if any, and rescale to the range [0,1],[0,1]
82 if (vo_fs
) { //we are in full-screen mode
83 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
84 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
85 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
86 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
88 if (ix
< 0 || ix
> vo
->dwidth
) {
91 } //we are on one of the borders
92 if (iy
< 0 || iy
> vo
->dheight
) {
95 } //we are on one of the borders
98 *dx
= (double) ix
/ (double) vo
->dwidth
;
99 *dy
= (double) iy
/ (double) vo
->dheight
;
101 mp_msg(MSGT_CPLAYER
, MSGL_V
,
102 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
103 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
107 static int sub_pos_by_source(MPContext
*mpctx
, int src
)
110 if (src
>= SUB_SOURCES
|| mpctx
->sub_counts
[src
] == 0)
112 for (i
= 0; i
< src
; i
++)
113 cnt
+= mpctx
->sub_counts
[i
];
117 static int sub_source_and_index_by_pos(MPContext
*mpctx
, int *pos
)
121 for (i
= 0; i
< SUB_SOURCES
; i
++) {
122 int cnt
= mpctx
->sub_counts
[i
];
123 if (*pos
>= start
&& *pos
< start
+ cnt
) {
133 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
135 return sub_source_and_index_by_pos(mpctx
, &pos
);
138 static int sub_source_pos(MPContext
*mpctx
)
140 int pos
= mpctx
->global_sub_pos
;
141 sub_source_and_index_by_pos(mpctx
, &pos
);
145 static int sub_source(MPContext
*mpctx
)
147 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
150 static void update_global_sub_size(MPContext
*mpctx
)
152 struct MPOpts
*opts
= &mpctx
->opts
;
156 // update number of demuxer sub streams
157 for (i
= 0; i
< MAX_S_STREAMS
; i
++)
158 if (mpctx
->d_sub
->demuxer
->s_streams
[i
])
160 if (cnt
> mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
161 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
] = cnt
;
163 // update global size
164 mpctx
->global_sub_size
= 0;
165 for (i
= 0; i
< SUB_SOURCES
; i
++)
166 mpctx
->global_sub_size
+= mpctx
->sub_counts
[i
];
168 // update global_sub_pos if we auto-detected a demuxer sub
169 if (mpctx
->global_sub_pos
== -1) {
171 if (mpctx
->demuxer
->sub
)
172 sub_id
= mpctx
->demuxer
->sub
->id
;
174 sub_id
= opts
->sub_id
;
175 if (sub_id
>= 0 && sub_id
< mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
176 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, SUB_SOURCE_DEMUX
) +
182 * \brief Log the currently displayed subtitle to a file
184 * Logs the current or last displayed subtitle together with filename
185 * and time information to ~/.mplayer/subtitle_log
187 * Intended purpose is to allow convenient marking of bogus subtitles
188 * which need to be fixed while watching the movie.
191 static void log_sub(struct MPContext
*mpctx
)
197 if (subdata
== NULL
|| vo_sub_last
== NULL
)
199 fname
= get_path("subtitle_log");
200 f
= fopen(fname
, "a");
203 fprintf(f
, "----------------------------------------------------------\n");
204 if (subdata
->sub_uses_time
) {
206 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
207 mpctx
->filename
, vo_sub_last
->start
/ 360000,
208 (vo_sub_last
->start
/ 6000) % 60,
209 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
210 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
211 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
213 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
214 vo_sub_last
->start
, vo_sub_last
->end
);
216 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
217 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
223 /// \defgroup Properties
226 /// \defgroup GeneralProperties General properties
227 /// \ingroup Properties
230 static int mp_property_generic_option(struct m_option
*prop
, int action
,
231 void *arg
, MPContext
*mpctx
)
233 char *optname
= prop
->priv
;
234 const struct m_option
*opt
= m_config_get_option(mpctx
->mconfig
, optname
);
235 void *valptr
= m_option_get_ptr(opt
, &mpctx
->opts
);
238 case M_PROPERTY_GET_TYPE
:
239 *(const struct m_option
**)arg
= opt
;
240 return M_PROPERTY_OK
;
242 m_option_copy(opt
, arg
, valptr
);
243 return M_PROPERTY_OK
;
245 m_option_copy(opt
, valptr
, arg
);
246 return M_PROPERTY_OK
;
247 case M_PROPERTY_STEP_UP
:
248 if (opt
->type
== &m_option_type_choice
) {
249 int v
= *(int *) valptr
;
251 struct m_opt_choice_alternatives
*alt
;
252 for (alt
= opt
->priv
; alt
->name
; alt
++)
253 if ((unsigned) alt
->value
- v
- 1 < (unsigned) best
- v
- 1)
255 *(int *) valptr
= best
;
256 return M_PROPERTY_OK
;
260 return M_PROPERTY_NOT_IMPLEMENTED
;
264 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
267 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
271 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
274 struct MPOpts
*opts
= &mpctx
->opts
;
276 case M_PROPERTY_PRINT
:
277 if (!arg
) return M_PROPERTY_ERROR
;
278 if (opts
->loop_times
< 0)
279 *(char**)arg
= strdup("off");
280 else if (opts
->loop_times
== 0)
281 *(char**)arg
= strdup("inf");
284 return M_PROPERTY_OK
;
286 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
289 /// Playback speed (RW)
290 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
291 void *arg
, MPContext
*mpctx
)
293 struct MPOpts
*opts
= &mpctx
->opts
;
297 return M_PROPERTY_ERROR
;
298 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
299 opts
->playback_speed
= *(float *) arg
;
300 reinit_audio_chain(mpctx
);
301 return M_PROPERTY_OK
;
302 case M_PROPERTY_STEP_UP
:
303 case M_PROPERTY_STEP_DOWN
:
304 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
305 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
306 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
307 reinit_audio_chain(mpctx
);
308 return M_PROPERTY_OK
;
310 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
313 /// filename with path (RO)
314 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
317 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
320 /// filename without path (RO)
321 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
325 if (!mpctx
->filename
)
326 return M_PROPERTY_UNAVAILABLE
;
327 f
= (char *)mp_basename(mpctx
->filename
);
330 return m_property_string_ro(prop
, action
, arg
, f
);
333 /// Demuxer name (RO)
334 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
338 return M_PROPERTY_UNAVAILABLE
;
339 return m_property_string_ro(prop
, action
, arg
,
340 (char *) mpctx
->demuxer
->desc
->name
);
343 /// Position in the stream (RW)
344 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
347 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
348 return M_PROPERTY_UNAVAILABLE
;
350 return M_PROPERTY_ERROR
;
353 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
354 return M_PROPERTY_OK
;
356 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
357 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
358 return M_PROPERTY_OK
;
360 return M_PROPERTY_NOT_IMPLEMENTED
;
363 /// Stream start offset (RO)
364 static int mp_property_stream_start(m_option_t
*prop
, int action
,
365 void *arg
, MPContext
*mpctx
)
367 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
368 return M_PROPERTY_UNAVAILABLE
;
371 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
372 return M_PROPERTY_OK
;
374 return M_PROPERTY_NOT_IMPLEMENTED
;
377 /// Stream end offset (RO)
378 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
381 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
382 return M_PROPERTY_UNAVAILABLE
;
385 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
386 return M_PROPERTY_OK
;
388 return M_PROPERTY_NOT_IMPLEMENTED
;
391 /// Stream length (RO)
392 static int mp_property_stream_length(m_option_t
*prop
, int action
,
393 void *arg
, MPContext
*mpctx
)
395 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
396 return M_PROPERTY_UNAVAILABLE
;
400 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
401 return M_PROPERTY_OK
;
403 return M_PROPERTY_NOT_IMPLEMENTED
;
406 /// Current stream position in seconds (RO)
407 static int mp_property_stream_time_pos(m_option_t
*prop
, int action
,
408 void *arg
, MPContext
*mpctx
)
410 if (!mpctx
->demuxer
|| mpctx
->demuxer
->stream_pts
== MP_NOPTS_VALUE
)
411 return M_PROPERTY_UNAVAILABLE
;
413 return m_property_time_ro(prop
, action
, arg
, mpctx
->demuxer
->stream_pts
);
417 /// Media length in seconds (RO)
418 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
423 if (!mpctx
->demuxer
||
424 !(int) (len
= get_time_length(mpctx
)))
425 return M_PROPERTY_UNAVAILABLE
;
427 return m_property_time_ro(prop
, action
, arg
, len
);
430 /// Current position in percent (RW)
431 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
432 void *arg
, MPContext
*mpctx
) {
436 return M_PROPERTY_UNAVAILABLE
;
440 if(!arg
) return M_PROPERTY_ERROR
;
441 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
444 case M_PROPERTY_STEP_UP
:
445 case M_PROPERTY_STEP_DOWN
:
446 pos
= get_percent_pos(mpctx
);
447 pos
+= (arg
? *(int*)arg
: 10) *
448 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
449 M_PROPERTY_CLAMP(prop
, pos
);
452 return m_property_int_ro(prop
, action
, arg
, get_percent_pos(mpctx
));
455 queue_seek(mpctx
, MPSEEK_FACTOR
, pos
/ 100.0, 0);
456 return M_PROPERTY_OK
;
459 /// Current position in seconds (RW)
460 static int mp_property_time_pos(m_option_t
*prop
, int action
,
461 void *arg
, MPContext
*mpctx
) {
462 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
463 return M_PROPERTY_UNAVAILABLE
;
467 if(!arg
) return M_PROPERTY_ERROR
;
468 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
469 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, *(double*)arg
, 0);
470 return M_PROPERTY_OK
;
471 case M_PROPERTY_STEP_UP
:
472 case M_PROPERTY_STEP_DOWN
:
473 queue_seek(mpctx
, MPSEEK_RELATIVE
, (arg
? *(double*)arg
: 10.0) *
474 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0), 0);
475 return M_PROPERTY_OK
;
477 return m_property_time_ro(prop
, action
, arg
, get_current_time(mpctx
));
480 /// Current chapter (RW)
481 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
484 struct MPOpts
*opts
= &mpctx
->opts
;
487 char *chapter_name
= NULL
;
490 chapter
= get_current_chapter(mpctx
);
492 return M_PROPERTY_UNAVAILABLE
;
497 return M_PROPERTY_ERROR
;
498 *(int *) arg
= chapter
;
499 return M_PROPERTY_OK
;
500 case M_PROPERTY_PRINT
: {
502 return M_PROPERTY_ERROR
;
503 chapter_name
= chapter_display_name(mpctx
, chapter
);
505 return M_PROPERTY_UNAVAILABLE
;
506 *(char **) arg
= chapter_name
;
507 return M_PROPERTY_OK
;
511 return M_PROPERTY_ERROR
;
512 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
513 step_all
= *(int *)arg
- chapter
;
516 case M_PROPERTY_STEP_UP
:
517 case M_PROPERTY_STEP_DOWN
: {
518 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
519 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
526 return M_PROPERTY_NOT_IMPLEMENTED
;
530 queue_seek(mpctx
, MPSEEK_NONE
, 0, 0);
531 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
534 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, next_pts
, 0);
536 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
537 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
538 } else if (step_all
> 0)
539 queue_seek(mpctx
, MPSEEK_RELATIVE
, 1000000000, 0);
541 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
542 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
543 talloc_free(chapter_name
);
544 return M_PROPERTY_OK
;
547 /// Number of chapters in file
548 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
552 return M_PROPERTY_UNAVAILABLE
;
553 if (mpctx
->demuxer
->num_chapters
== 0)
554 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
555 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
558 /// Current dvd angle (RW)
559 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
562 struct MPOpts
*opts
= &mpctx
->opts
;
565 char *angle_name
= NULL
;
568 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
570 return M_PROPERTY_UNAVAILABLE
;
571 angles
= demuxer_angles_count(mpctx
->demuxer
);
573 return M_PROPERTY_UNAVAILABLE
;
578 return M_PROPERTY_ERROR
;
579 *(int *) arg
= angle
;
580 return M_PROPERTY_OK
;
581 case M_PROPERTY_PRINT
: {
583 return M_PROPERTY_ERROR
;
584 angle_name
= calloc(1, 64);
586 return M_PROPERTY_UNAVAILABLE
;
587 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
588 *(char **) arg
= angle_name
;
589 return M_PROPERTY_OK
;
593 return M_PROPERTY_ERROR
;
595 M_PROPERTY_CLAMP(prop
, angle
);
597 case M_PROPERTY_STEP_UP
:
598 case M_PROPERTY_STEP_DOWN
: {
604 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
606 if (angle
< 1) //cycle
611 return M_PROPERTY_NOT_IMPLEMENTED
;
613 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
615 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
617 resync_video_stream(sh_video
);
619 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
621 resync_audio_stream(sh_audio
);
624 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
625 "Angle: %d/%d", angle
, angles
);
627 return M_PROPERTY_OK
;
630 /// Demuxer meta data
631 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
633 m_property_action_t
* ka
;
635 static const m_option_t key_type
=
636 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
638 return M_PROPERTY_UNAVAILABLE
;
642 if(!arg
) return M_PROPERTY_ERROR
;
643 *(char***)arg
= mpctx
->demuxer
->info
;
644 return M_PROPERTY_OK
;
645 case M_PROPERTY_KEY_ACTION
:
646 if(!arg
) return M_PROPERTY_ERROR
;
648 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
649 return M_PROPERTY_UNKNOWN
;
652 if(!ka
->arg
) return M_PROPERTY_ERROR
;
653 *(char**)ka
->arg
= meta
;
654 return M_PROPERTY_OK
;
655 case M_PROPERTY_GET_TYPE
:
656 if(!ka
->arg
) return M_PROPERTY_ERROR
;
657 *(const m_option_t
**)ka
->arg
= &key_type
;
658 return M_PROPERTY_OK
;
661 return M_PROPERTY_NOT_IMPLEMENTED
;
664 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
667 MPContext
*mpctx
= ctx
;
672 return M_PROPERTY_ERROR
;
673 if (mpctx
->paused
== (bool)*(int *) arg
)
674 return M_PROPERTY_OK
;
675 case M_PROPERTY_STEP_UP
:
676 case M_PROPERTY_STEP_DOWN
:
678 unpause_player(mpctx
);
679 mpctx
->osd_function
= OSD_PLAY
;
683 mpctx
->osd_function
= OSD_PAUSE
;
685 return M_PROPERTY_OK
;
687 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
694 /// \defgroup AudioProperties Audio properties
695 /// \ingroup Properties
699 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
703 if (!mpctx
->sh_audio
)
704 return M_PROPERTY_UNAVAILABLE
;
709 return M_PROPERTY_ERROR
;
710 mixer_getbothvolume(&mpctx
->mixer
, arg
);
711 return M_PROPERTY_OK
;
712 case M_PROPERTY_PRINT
:{
715 return M_PROPERTY_ERROR
;
716 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
717 return m_property_float_range(prop
, action
, arg
, &vol
);
719 case M_PROPERTY_STEP_UP
:
720 case M_PROPERTY_STEP_DOWN
:
724 return M_PROPERTY_NOT_IMPLEMENTED
;
727 if (mpctx
->edl_muted
)
728 return M_PROPERTY_DISABLED
;
729 mpctx
->user_muted
= 0;
734 return M_PROPERTY_ERROR
;
735 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
736 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
737 return M_PROPERTY_OK
;
738 case M_PROPERTY_STEP_UP
:
739 if (arg
&& *(float *) arg
<= 0)
740 mixer_decvolume(&mpctx
->mixer
);
742 mixer_incvolume(&mpctx
->mixer
);
743 return M_PROPERTY_OK
;
744 case M_PROPERTY_STEP_DOWN
:
745 if (arg
&& *(float *) arg
<= 0)
746 mixer_incvolume(&mpctx
->mixer
);
748 mixer_decvolume(&mpctx
->mixer
);
749 return M_PROPERTY_OK
;
751 return M_PROPERTY_NOT_IMPLEMENTED
;
755 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
759 if (!mpctx
->sh_audio
)
760 return M_PROPERTY_UNAVAILABLE
;
764 if (mpctx
->edl_muted
)
765 return M_PROPERTY_DISABLED
;
767 return M_PROPERTY_ERROR
;
768 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
769 mixer_mute(&mpctx
->mixer
);
770 mpctx
->user_muted
= mpctx
->mixer
.muted
;
771 return M_PROPERTY_OK
;
772 case M_PROPERTY_STEP_UP
:
773 case M_PROPERTY_STEP_DOWN
:
774 if (mpctx
->edl_muted
)
775 return M_PROPERTY_DISABLED
;
776 mixer_mute(&mpctx
->mixer
);
777 mpctx
->user_muted
= mpctx
->mixer
.muted
;
778 return M_PROPERTY_OK
;
779 case M_PROPERTY_PRINT
:
781 return M_PROPERTY_ERROR
;
782 if (mpctx
->edl_muted
) {
783 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
784 return M_PROPERTY_OK
;
787 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
793 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
794 void *arg
, MPContext
*mpctx
)
796 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
797 return M_PROPERTY_UNAVAILABLE
;
800 case M_PROPERTY_STEP_UP
:
801 case M_PROPERTY_STEP_DOWN
: {
803 float delay
= audio_delay
;
804 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
805 if (ret
!= M_PROPERTY_OK
)
808 mpctx
->delay
-= audio_delay
- delay
;
810 return M_PROPERTY_OK
;
812 return m_property_delay(prop
, action
, arg
, &audio_delay
);
816 /// Audio codec tag (RO)
817 static int mp_property_audio_format(m_option_t
*prop
, int action
,
818 void *arg
, MPContext
*mpctx
)
820 if (!mpctx
->sh_audio
)
821 return M_PROPERTY_UNAVAILABLE
;
822 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
825 /// Audio codec name (RO)
826 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
827 void *arg
, MPContext
*mpctx
)
829 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
830 return M_PROPERTY_UNAVAILABLE
;
831 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
834 /// Audio bitrate (RO)
835 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
836 void *arg
, MPContext
*mpctx
)
838 if (!mpctx
->sh_audio
)
839 return M_PROPERTY_UNAVAILABLE
;
840 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
844 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
847 if (!mpctx
->sh_audio
)
848 return M_PROPERTY_UNAVAILABLE
;
850 case M_PROPERTY_PRINT
:
851 if(!arg
) return M_PROPERTY_ERROR
;
852 *(char**)arg
= malloc(16);
853 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
854 return M_PROPERTY_OK
;
856 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
859 /// Number of channels (RO)
860 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
863 if (!mpctx
->sh_audio
)
864 return M_PROPERTY_UNAVAILABLE
;
866 case M_PROPERTY_PRINT
:
868 return M_PROPERTY_ERROR
;
869 switch (mpctx
->sh_audio
->channels
) {
871 *(char **) arg
= strdup("mono");
874 *(char **) arg
= strdup("stereo");
877 *(char **) arg
= malloc(32);
878 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
880 return M_PROPERTY_OK
;
882 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
886 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
891 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
892 return M_PROPERTY_UNAVAILABLE
;
897 return M_PROPERTY_ERROR
;
898 mixer_getbalance(&mpctx
->mixer
, arg
);
899 return M_PROPERTY_OK
;
900 case M_PROPERTY_PRINT
: {
903 return M_PROPERTY_ERROR
;
904 mixer_getbalance(&mpctx
->mixer
, &bal
);
906 *str
= strdup("center");
907 else if (bal
== -1.f
)
908 *str
= strdup("left only");
910 *str
= strdup("right only");
912 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
913 *str
= malloc(sizeof("left xxx%, right xxx%"));
914 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
916 return M_PROPERTY_OK
;
918 case M_PROPERTY_STEP_UP
:
919 case M_PROPERTY_STEP_DOWN
:
920 mixer_getbalance(&mpctx
->mixer
, &bal
);
921 bal
+= (arg
? *(float*)arg
: .1f
) *
922 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
923 M_PROPERTY_CLAMP(prop
, bal
);
924 mixer_setbalance(&mpctx
->mixer
, bal
);
925 return M_PROPERTY_OK
;
928 return M_PROPERTY_ERROR
;
929 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
930 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
931 return M_PROPERTY_OK
;
933 return M_PROPERTY_NOT_IMPLEMENTED
;
936 /// Selected audio id (RW)
937 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
941 if (!mpctx
->demuxer
|| !mpctx
->d_audio
)
942 return M_PROPERTY_UNAVAILABLE
;
943 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
948 return M_PROPERTY_ERROR
;
949 *(int *) arg
= current_id
;
950 return M_PROPERTY_OK
;
951 case M_PROPERTY_PRINT
:
953 return M_PROPERTY_ERROR
;
956 *(char **) arg
= strdup(mp_gtext("disabled"));
959 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
960 sh_audio_t
* sh
= mpctx
->sh_audio
;
962 av_strlcpy(lang
, sh
->lang
, 40);
963 #ifdef CONFIG_DVDREAD
964 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
965 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
975 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
976 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
978 *(char **) arg
= malloc(64);
979 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
981 return M_PROPERTY_OK
;
983 case M_PROPERTY_STEP_UP
:
985 if (action
== M_PROPERTY_SET
&& arg
)
986 tmp
= *((int *) arg
);
989 int new_id
= demuxer_switch_audio(mpctx
->d_audio
->demuxer
, tmp
);
990 if (new_id
!= current_id
)
991 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
992 if (new_id
!= current_id
&& new_id
>= 0) {
994 sh2
= mpctx
->d_audio
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
995 sh2
->ds
= mpctx
->demuxer
->audio
;
996 mpctx
->sh_audio
= sh2
;
997 reinit_audio_chain(mpctx
);
999 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
1000 return M_PROPERTY_OK
;
1002 return M_PROPERTY_NOT_IMPLEMENTED
;
1007 /// Selected video id (RW)
1008 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
1011 struct MPOpts
*opts
= &mpctx
->opts
;
1012 int current_id
, tmp
;
1013 if (!mpctx
->demuxer
|| !mpctx
->d_video
)
1014 return M_PROPERTY_UNAVAILABLE
;
1015 current_id
= mpctx
->d_video
->id
;
1018 case M_PROPERTY_GET
:
1020 return M_PROPERTY_ERROR
;
1021 *(int *) arg
= current_id
;
1022 return M_PROPERTY_OK
;
1023 case M_PROPERTY_PRINT
:
1025 return M_PROPERTY_ERROR
;
1028 *(char **) arg
= strdup(mp_gtext("disabled"));
1031 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1032 *(char **) arg
= malloc(64);
1033 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1035 return M_PROPERTY_OK
;
1037 case M_PROPERTY_STEP_UP
:
1038 case M_PROPERTY_SET
:
1039 if (action
== M_PROPERTY_SET
&& arg
)
1040 tmp
= *((int *) arg
);
1043 opts
->video_id
= demuxer_switch_video(mpctx
->d_video
->demuxer
, tmp
);
1044 if (opts
->video_id
== -2
1045 || (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
1046 && current_id
!= -2))
1047 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1048 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1049 if (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
) {
1051 sh2
= mpctx
->d_video
->demuxer
->v_streams
[mpctx
->d_video
->id
];
1053 sh2
->ds
= mpctx
->d_video
;
1054 mpctx
->sh_video
= sh2
;
1055 reinit_video_chain(mpctx
);
1058 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1059 return M_PROPERTY_OK
;
1062 return M_PROPERTY_NOT_IMPLEMENTED
;
1066 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1069 demux_program_t prog
;
1072 case M_PROPERTY_STEP_UP
:
1073 case M_PROPERTY_SET
:
1074 if (action
== M_PROPERTY_SET
&& arg
)
1075 prog
.progid
= *((int *) arg
);
1079 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1080 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1081 return M_PROPERTY_ERROR
;
1083 if (prog
.aid
< 0 && prog
.vid
< 0) {
1084 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1085 return M_PROPERTY_ERROR
;
1087 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1088 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1089 return M_PROPERTY_OK
;
1092 return M_PROPERTY_NOT_IMPLEMENTED
;
1098 /// \defgroup VideoProperties Video properties
1099 /// \ingroup Properties
1102 /// Fullscreen state (RW)
1103 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1107 if (!mpctx
->video_out
)
1108 return M_PROPERTY_UNAVAILABLE
;
1111 case M_PROPERTY_SET
:
1113 return M_PROPERTY_ERROR
;
1114 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1115 if (vo_fs
== !!*(int *) arg
)
1116 return M_PROPERTY_OK
;
1117 case M_PROPERTY_STEP_UP
:
1118 case M_PROPERTY_STEP_DOWN
:
1119 if (mpctx
->video_out
->config_ok
)
1120 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1121 mpctx
->opts
.fullscreen
= vo_fs
;
1122 return M_PROPERTY_OK
;
1124 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1128 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1129 void *arg
, MPContext
*mpctx
)
1133 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1134 return M_PROPERTY_UNAVAILABLE
;
1135 vf
= mpctx
->sh_video
->vfilter
;
1137 case M_PROPERTY_GET
:
1139 return M_PROPERTY_ERROR
;
1140 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1141 return M_PROPERTY_OK
;
1142 case M_PROPERTY_SET
:
1144 return M_PROPERTY_ERROR
;
1145 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1146 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1147 return M_PROPERTY_OK
;
1148 case M_PROPERTY_STEP_UP
:
1149 case M_PROPERTY_STEP_DOWN
:
1150 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1151 deinterlace
= !deinterlace
;
1152 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1153 return M_PROPERTY_OK
;
1156 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1157 return m_property_flag_ro(prop
, action
, arg
, value
);
1160 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1161 void *arg
, MPContext
*mpctx
)
1163 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1164 return M_PROPERTY_UNAVAILABLE
;
1166 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1169 case M_PROPERTY_GET
:
1171 return M_PROPERTY_ERROR
;
1172 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1173 return M_PROPERTY_UNAVAILABLE
;
1174 return M_PROPERTY_OK
;
1175 case M_PROPERTY_PRINT
:
1177 return M_PROPERTY_ERROR
;
1178 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1179 return M_PROPERTY_UNAVAILABLE
;
1180 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1181 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1182 *(char **)arg
= strdup("Unknown");
1184 *(char**)arg
= strdup(names
[colorspace
]);
1185 return M_PROPERTY_OK
;
1186 case M_PROPERTY_SET
:
1188 return M_PROPERTY_ERROR
;
1189 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1190 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1191 return M_PROPERTY_OK
;
1192 case M_PROPERTY_STEP_UP
:;
1193 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1194 return M_PROPERTY_UNAVAILABLE
;
1196 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1197 return M_PROPERTY_OK
;
1199 return M_PROPERTY_NOT_IMPLEMENTED
;
1202 static int mp_property_capture(m_option_t
*prop
, int action
,
1203 void *arg
, MPContext
*mpctx
)
1205 struct MPOpts
*opts
= &mpctx
->opts
;
1208 return M_PROPERTY_UNAVAILABLE
;
1210 if (!opts
->capture_dump
) {
1211 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1212 "Capturing not enabled (forgot -capture parameter?)\n");
1213 return M_PROPERTY_ERROR
;
1216 int capturing
= !!mpctx
->stream
->capture_file
;
1218 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1219 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1221 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1222 if (!mpctx
->stream
->capture_file
) {
1223 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1224 "Error opening capture file: %s\n", strerror(errno
));
1225 ret
= M_PROPERTY_ERROR
;
1228 fclose(mpctx
->stream
->capture_file
);
1229 mpctx
->stream
->capture_file
= NULL
;
1237 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1241 if (!mpctx
->video_out
1242 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1243 return M_PROPERTY_UNAVAILABLE
;
1246 case M_PROPERTY_SET
:
1248 return M_PROPERTY_ERROR
;
1249 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1250 vo_panscan
= *(float *) arg
;
1251 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1252 return M_PROPERTY_OK
;
1253 case M_PROPERTY_STEP_UP
:
1254 case M_PROPERTY_STEP_DOWN
:
1255 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1256 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1259 else if (vo_panscan
< 0)
1261 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1262 return M_PROPERTY_OK
;
1264 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1268 /// Helper to set vo flags.
1269 /** \ingroup PropertyImplHelper
1271 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1272 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1275 if (!mpctx
->video_out
)
1276 return M_PROPERTY_UNAVAILABLE
;
1279 case M_PROPERTY_SET
:
1281 return M_PROPERTY_ERROR
;
1282 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1283 if (*vo_var
== !!*(int *) arg
)
1284 return M_PROPERTY_OK
;
1285 case M_PROPERTY_STEP_UP
:
1286 case M_PROPERTY_STEP_DOWN
:
1287 if (mpctx
->video_out
->config_ok
)
1288 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1289 return M_PROPERTY_OK
;
1291 return m_property_flag(prop
, action
, arg
, vo_var
);
1295 /// Window always on top (RW)
1296 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1299 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1300 &mpctx
->opts
.vo_ontop
, mpctx
);
1303 /// Display in the root window (RW)
1304 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1307 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1308 &vo_rootwin
, mpctx
);
1311 /// Show window borders (RW)
1312 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1315 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1319 /// Framedropping state (RW)
1320 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1321 void *arg
, MPContext
*mpctx
)
1324 if (!mpctx
->sh_video
)
1325 return M_PROPERTY_UNAVAILABLE
;
1328 case M_PROPERTY_PRINT
:
1330 return M_PROPERTY_ERROR
;
1331 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1332 (frame_dropping
== 2 ? mp_gtext("hard") :
1333 mp_gtext("disabled")));
1334 return M_PROPERTY_OK
;
1336 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1340 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1341 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1344 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1347 if (!mpctx
->sh_video
)
1348 return M_PROPERTY_UNAVAILABLE
;
1350 if (gamma
[0] == 1000) {
1352 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1356 case M_PROPERTY_SET
:
1358 return M_PROPERTY_ERROR
;
1359 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1360 *gamma
= *(int *) arg
;
1361 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1365 case M_PROPERTY_GET
:
1366 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1368 return M_PROPERTY_ERROR
;
1370 return M_PROPERTY_OK
;
1373 case M_PROPERTY_STEP_UP
:
1374 case M_PROPERTY_STEP_DOWN
:
1375 *gamma
+= (arg
? *(int *) arg
: 1) *
1376 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1377 M_PROPERTY_CLAMP(prop
, *gamma
);
1378 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1383 return M_PROPERTY_NOT_IMPLEMENTED
;
1387 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1388 int l
= strlen(prop
->name
);
1389 char tv_prop
[3 + l
+ 1];
1390 sprintf(tv_prop
, "tv_%s", prop
->name
);
1391 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1395 return M_PROPERTY_UNAVAILABLE
;
1399 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1402 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1405 /// Video codec tag (RO)
1406 static int mp_property_video_format(m_option_t
*prop
, int action
,
1407 void *arg
, MPContext
*mpctx
)
1410 if (!mpctx
->sh_video
)
1411 return M_PROPERTY_UNAVAILABLE
;
1413 case M_PROPERTY_PRINT
:
1415 return M_PROPERTY_ERROR
;
1416 switch(mpctx
->sh_video
->format
) {
1418 meta
= strdup ("mpeg1"); break;
1420 meta
= strdup ("mpeg2"); break;
1422 meta
= strdup ("mpeg4"); break;
1424 meta
= strdup ("h264"); break;
1426 if(mpctx
->sh_video
->format
>= 0x20202020) {
1428 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1431 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1434 *(char**)arg
= meta
;
1435 return M_PROPERTY_OK
;
1437 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1440 /// Video codec name (RO)
1441 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1442 void *arg
, MPContext
*mpctx
)
1444 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1445 return M_PROPERTY_UNAVAILABLE
;
1446 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1450 /// Video bitrate (RO)
1451 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1452 void *arg
, MPContext
*mpctx
)
1454 if (!mpctx
->sh_video
)
1455 return M_PROPERTY_UNAVAILABLE
;
1456 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1459 /// Video display width (RO)
1460 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1463 if (!mpctx
->sh_video
)
1464 return M_PROPERTY_UNAVAILABLE
;
1465 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1468 /// Video display height (RO)
1469 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1472 if (!mpctx
->sh_video
)
1473 return M_PROPERTY_UNAVAILABLE
;
1474 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1478 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1481 if (!mpctx
->sh_video
)
1482 return M_PROPERTY_UNAVAILABLE
;
1483 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1486 /// Video aspect (RO)
1487 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1490 if (!mpctx
->sh_video
)
1491 return M_PROPERTY_UNAVAILABLE
;
1492 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1497 /// \defgroup SubProprties Subtitles properties
1498 /// \ingroup Properties
1501 /// Text subtitle position (RW)
1502 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1506 case M_PROPERTY_SET
:
1508 return M_PROPERTY_ERROR
;
1509 case M_PROPERTY_STEP_UP
:
1510 case M_PROPERTY_STEP_DOWN
:
1511 vo_osd_changed(OSDTYPE_SUBTITLE
);
1513 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1517 /// Selected subtitles (RW)
1518 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1521 struct MPOpts
*opts
= &mpctx
->opts
;
1522 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1523 int source
= -1, reset_spu
= 0;
1524 int source_pos
= -1;
1527 update_global_sub_size(mpctx
);
1528 const int global_sub_size
= mpctx
->global_sub_size
;
1530 if (global_sub_size
<= 0)
1531 return M_PROPERTY_UNAVAILABLE
;
1534 case M_PROPERTY_GET
:
1536 return M_PROPERTY_ERROR
;
1537 *(int *) arg
= mpctx
->global_sub_pos
;
1538 return M_PROPERTY_OK
;
1539 case M_PROPERTY_PRINT
:
1541 return M_PROPERTY_ERROR
;
1542 *(char **) arg
= malloc(64);
1543 (*(char **) arg
)[63] = 0;
1546 sub_name
= subdata
->filename
;
1548 if (ass_track
&& ass_track
->name
)
1549 sub_name
= ass_track
->name
;
1552 const char *tmp
= mp_basename(sub_name
);
1554 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1555 mpctx
->set_of_sub_pos
+ 1,
1556 strlen(tmp
) < 20 ? "" : "...",
1557 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1558 return M_PROPERTY_OK
;
1560 #ifdef CONFIG_DVDNAV
1561 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1562 if (vo_spudec
&& opts
->sub_id
>= 0) {
1563 unsigned char lang
[3];
1564 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1565 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1566 return M_PROPERTY_OK
;
1572 if ((d_sub
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1573 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF
1574 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1575 || d_sub
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1576 && d_sub
->sh
&& opts
->sub_id
>= 0) {
1577 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1578 if (!lang
) lang
= mp_gtext("unknown");
1579 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1580 return M_PROPERTY_OK
;
1583 if (vo_vobsub
&& vobsub_id
>= 0) {
1584 const char *language
= mp_gtext("unknown");
1585 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1586 snprintf(*(char **) arg
, 63, "(%d) %s",
1587 vobsub_id
, language
? language
: mp_gtext("unknown"));
1588 return M_PROPERTY_OK
;
1590 #ifdef CONFIG_DVDREAD
1591 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1592 && opts
->sub_id
>= 0) {
1594 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1595 lang
[0] = code
>> 8;
1598 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1599 return M_PROPERTY_OK
;
1602 if (opts
->sub_id
>= 0) {
1603 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1604 mp_gtext("unknown"));
1605 return M_PROPERTY_OK
;
1607 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1608 return M_PROPERTY_OK
;
1610 case M_PROPERTY_SET
:
1612 return M_PROPERTY_ERROR
;
1613 if (*(int *) arg
< -1)
1615 else if (*(int *) arg
>= global_sub_size
)
1616 *(int *) arg
= global_sub_size
- 1;
1617 mpctx
->global_sub_pos
= *(int *) arg
;
1619 case M_PROPERTY_STEP_UP
:
1620 mpctx
->global_sub_pos
+= 2;
1621 mpctx
->global_sub_pos
=
1622 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1624 case M_PROPERTY_STEP_DOWN
:
1625 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1626 mpctx
->global_sub_pos
=
1627 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1630 return M_PROPERTY_NOT_IMPLEMENTED
;
1633 if (mpctx
->global_sub_pos
>= 0) {
1634 source
= sub_source(mpctx
);
1635 source_pos
= sub_source_pos(mpctx
);
1638 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1639 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1641 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1642 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1643 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1644 mpctx
->global_sub_pos
, source
);
1646 mpctx
->set_of_sub_pos
= -1;
1660 if (source
== SUB_SOURCE_VOBSUB
) {
1661 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1662 } else if (source
== SUB_SOURCE_SUBS
) {
1663 mpctx
->set_of_sub_pos
= source_pos
;
1665 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1666 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1670 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1671 vo_osd_changed(OSDTYPE_SUBTITLE
);
1673 } else if (source
== SUB_SOURCE_DEMUX
) {
1674 opts
->sub_id
= source_pos
;
1675 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1677 // default: assume 1:1 mapping of sid and stream id
1678 d_sub
->id
= opts
->sub_id
;
1679 d_sub
->sh
= mpctx
->d_sub
->demuxer
->s_streams
[d_sub
->id
];
1680 ds_free_packs(d_sub
);
1681 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1682 sh_sub_t
*sh
= mpctx
->d_sub
->demuxer
->s_streams
[i
];
1683 if (sh
&& sh
->sid
== opts
->sub_id
) {
1689 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1690 sh_sub_t
*sh
= d_sub
->sh
;
1691 if (sh
->type
== 'v')
1692 init_vo_spudec(mpctx
);
1694 else if (opts
->ass_enabled
)
1695 ass_track
= sh
->ass_track
;
1703 #ifdef CONFIG_DVDREAD
1705 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1706 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1707 && opts
->sub_id
< 0 && reset_spu
) {
1713 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1715 return M_PROPERTY_OK
;
1718 /// Selected sub source (RW)
1719 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1723 update_global_sub_size(mpctx
);
1724 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1725 return M_PROPERTY_UNAVAILABLE
;
1728 case M_PROPERTY_GET
:
1730 return M_PROPERTY_ERROR
;
1731 *(int *) arg
= sub_source(mpctx
);
1732 return M_PROPERTY_OK
;
1733 case M_PROPERTY_PRINT
:
1735 return M_PROPERTY_ERROR
;
1736 *(char **) arg
= malloc(64);
1737 (*(char **) arg
)[63] = 0;
1738 switch (sub_source(mpctx
))
1740 case SUB_SOURCE_SUBS
:
1741 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1743 case SUB_SOURCE_VOBSUB
:
1744 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1746 case SUB_SOURCE_DEMUX
:
1747 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1750 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1752 return M_PROPERTY_OK
;
1753 case M_PROPERTY_SET
:
1755 return M_PROPERTY_ERROR
;
1756 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1757 if (*(int *) arg
< 0)
1758 mpctx
->global_sub_pos
= -1;
1759 else if (*(int *) arg
!= sub_source(mpctx
)) {
1760 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1762 return M_PROPERTY_UNAVAILABLE
;
1763 mpctx
->global_sub_pos
= new_pos
;
1766 case M_PROPERTY_STEP_UP
:
1767 case M_PROPERTY_STEP_DOWN
: {
1768 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1769 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1770 int step
= (step_all
> 0) ? 1 : -1;
1771 int cur_source
= sub_source(mpctx
);
1772 source
= cur_source
;
1775 if (source
>= SUB_SOURCES
)
1777 else if (source
< -1)
1778 source
= SUB_SOURCES
- 1;
1779 if (source
== cur_source
|| source
== -1 ||
1780 mpctx
->sub_counts
[source
])
1783 if (source
== cur_source
)
1784 return M_PROPERTY_OK
;
1786 mpctx
->global_sub_pos
= -1;
1788 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1792 return M_PROPERTY_NOT_IMPLEMENTED
;
1794 --mpctx
->global_sub_pos
;
1795 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1798 /// Selected subtitles from specific source (RW)
1799 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1802 int source
, is_cur_source
, offset
, new_pos
;
1803 update_global_sub_size(mpctx
);
1804 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1805 return M_PROPERTY_UNAVAILABLE
;
1807 if (!strcmp(prop
->name
, "sub_file"))
1808 source
= SUB_SOURCE_SUBS
;
1809 else if (!strcmp(prop
->name
, "sub_vob"))
1810 source
= SUB_SOURCE_VOBSUB
;
1811 else if (!strcmp(prop
->name
, "sub_demux"))
1812 source
= SUB_SOURCE_DEMUX
;
1814 return M_PROPERTY_ERROR
;
1816 offset
= sub_pos_by_source(mpctx
, source
);
1818 return M_PROPERTY_UNAVAILABLE
;
1820 is_cur_source
= sub_source(mpctx
) == source
;
1821 new_pos
= mpctx
->global_sub_pos
;
1823 case M_PROPERTY_GET
:
1825 return M_PROPERTY_ERROR
;
1826 if (is_cur_source
) {
1827 *(int *) arg
= sub_source_pos(mpctx
);
1828 if (source
== SUB_SOURCE_VOBSUB
)
1829 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1833 return M_PROPERTY_OK
;
1834 case M_PROPERTY_PRINT
:
1836 return M_PROPERTY_ERROR
;
1838 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1839 *(char **) arg
= malloc(64);
1840 (*(char **) arg
)[63] = 0;
1841 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1842 return M_PROPERTY_OK
;
1843 case M_PROPERTY_SET
:
1845 return M_PROPERTY_ERROR
;
1846 if (*(int *) arg
>= 0) {
1847 int index
= *(int *)arg
;
1848 if (source
== SUB_SOURCE_VOBSUB
)
1849 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1850 new_pos
= offset
+ index
;
1851 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1859 case M_PROPERTY_STEP_UP
:
1860 case M_PROPERTY_STEP_DOWN
: {
1861 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1862 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1863 int step
= (step_all
> 0) ? 1 : -1;
1864 int max_sub_pos_for_source
= -1;
1868 if (new_pos
== -1) {
1871 else if (max_sub_pos_for_source
== -1) {
1872 // Find max pos for specific source
1873 new_pos
= mpctx
->global_sub_size
- 1;
1875 && sub_source(mpctx
) != source
)
1879 new_pos
= max_sub_pos_for_source
;
1883 if (new_pos
< offset
||
1884 new_pos
>= mpctx
->global_sub_size
||
1885 sub_source(mpctx
) != source
)
1893 return M_PROPERTY_NOT_IMPLEMENTED
;
1895 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1898 /// Subtitle delay (RW)
1899 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1902 if (!mpctx
->sh_video
)
1903 return M_PROPERTY_UNAVAILABLE
;
1904 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1907 /// Alignment of text subtitles (RW)
1908 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1909 void *arg
, MPContext
*mpctx
)
1911 char *name
[] = { _("top"), _("center"), _("bottom") };
1913 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1914 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1915 return M_PROPERTY_UNAVAILABLE
;
1918 case M_PROPERTY_PRINT
:
1920 return M_PROPERTY_ERROR
;
1921 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1922 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1923 return M_PROPERTY_OK
;
1924 case M_PROPERTY_SET
:
1926 return M_PROPERTY_ERROR
;
1927 case M_PROPERTY_STEP_UP
:
1928 case M_PROPERTY_STEP_DOWN
:
1929 vo_osd_changed(OSDTYPE_SUBTITLE
);
1931 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1935 /// Subtitle visibility (RW)
1936 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1937 void *arg
, MPContext
*mpctx
)
1939 if (!mpctx
->sh_video
)
1940 return M_PROPERTY_UNAVAILABLE
;
1943 case M_PROPERTY_SET
:
1945 return M_PROPERTY_ERROR
;
1946 case M_PROPERTY_STEP_UP
:
1947 case M_PROPERTY_STEP_DOWN
:
1948 vo_osd_changed(OSDTYPE_SUBTITLE
);
1950 vo_osd_changed(OSDTYPE_SPU
);
1952 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1957 /// Use margins for libass subtitles (RW)
1958 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1959 void *arg
, MPContext
*mpctx
)
1961 if (!mpctx
->sh_video
)
1962 return M_PROPERTY_UNAVAILABLE
;
1965 case M_PROPERTY_SET
:
1967 return M_PROPERTY_ERROR
;
1968 case M_PROPERTY_STEP_UP
:
1969 case M_PROPERTY_STEP_DOWN
:
1970 ass_force_reload
= 1;
1972 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1977 /// Show only forced subtitles (RW)
1978 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1979 void *arg
, MPContext
*mpctx
)
1982 return M_PROPERTY_UNAVAILABLE
;
1985 case M_PROPERTY_SET
:
1987 return M_PROPERTY_ERROR
;
1988 case M_PROPERTY_STEP_UP
:
1989 case M_PROPERTY_STEP_DOWN
:
1990 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1991 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1992 return M_PROPERTY_OK
;
1994 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1999 #ifdef CONFIG_FREETYPE
2000 /// Subtitle scale (RW)
2001 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
2004 struct MPOpts
*opts
= &mpctx
->opts
;
2007 case M_PROPERTY_SET
:
2009 return M_PROPERTY_ERROR
;
2010 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
2012 if (opts
->ass_enabled
) {
2013 ass_font_scale
= *(float *) arg
;
2014 ass_force_reload
= 1;
2017 text_font_scale_factor
= *(float *) arg
;
2018 force_load_font
= 1;
2019 return M_PROPERTY_OK
;
2020 case M_PROPERTY_STEP_UP
:
2021 case M_PROPERTY_STEP_DOWN
:
2023 if (opts
->ass_enabled
) {
2024 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
2025 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2026 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
2027 ass_force_reload
= 1;
2030 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
2031 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2032 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2033 force_load_font
= 1;
2034 return M_PROPERTY_OK
;
2037 if (opts
->ass_enabled
)
2038 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
2041 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2048 /// \defgroup TVProperties TV properties
2049 /// \ingroup Properties
2054 /// TV color settings (RW)
2055 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2059 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2060 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2061 return M_PROPERTY_UNAVAILABLE
;
2064 case M_PROPERTY_SET
:
2066 return M_PROPERTY_ERROR
;
2067 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2068 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2069 case M_PROPERTY_GET
:
2070 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2071 case M_PROPERTY_STEP_UP
:
2072 case M_PROPERTY_STEP_DOWN
:
2073 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2075 return M_PROPERTY_ERROR
;
2076 val
+= (arg
? *(int *) arg
: 1) *
2077 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2078 M_PROPERTY_CLAMP(prop
, val
);
2079 return tv_set_color_options(tvh
, prop
->offset
, val
);
2081 return M_PROPERTY_ERROR
;
2083 return M_PROPERTY_NOT_IMPLEMENTED
;
2088 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2092 int base_ioctl
= prop
->offset
;
2094 for teletext's GET,SET,STEP ioctls this is not 0
2098 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2099 return M_PROPERTY_UNAVAILABLE
;
2101 return M_PROPERTY_ERROR
;
2104 case M_PROPERTY_GET
:
2106 return M_PROPERTY_ERROR
;
2107 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2109 case M_PROPERTY_SET
:
2111 return M_PROPERTY_ERROR
;
2112 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2113 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2115 case M_PROPERTY_STEP_UP
:
2116 case M_PROPERTY_STEP_DOWN
:
2117 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2118 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2119 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2122 return M_PROPERTY_NOT_IMPLEMENTED
;
2125 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2128 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2134 //with tvh==NULL will fail too
2135 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2136 if(result
!=M_PROPERTY_OK
)
2139 if(teletext_control(mpctx
->demuxer
->teletext
,
2140 prop
->offset
, &val
)==VBI_CONTROL_TRUE
&& val
)
2141 mp_input_set_section(mpctx
->input
, "teletext");
2143 mp_input_set_section(mpctx
->input
, "tv");
2144 return M_PROPERTY_OK
;
2147 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2152 if (!mpctx
->demuxer
->teletext
)
2153 return M_PROPERTY_UNAVAILABLE
;
2155 case M_PROPERTY_STEP_UP
:
2156 case M_PROPERTY_STEP_DOWN
:
2157 //This should be handled separately
2158 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2159 result
=teletext_control(mpctx
->demuxer
->teletext
,
2160 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2163 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2170 /// All properties available in MPlayer.
2171 /** \ingroup Properties
2173 static const m_option_t mp_properties
[] = {
2175 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2176 M_OPT_RANGE
, 0, 3, NULL
},
2177 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2178 M_OPT_MIN
, -1, 0, NULL
},
2179 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2180 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2181 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2183 { "path", mp_property_path
, CONF_TYPE_STRING
,
2185 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2187 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2188 M_OPT_MIN
, 0, 0, NULL
},
2189 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2190 M_OPT_MIN
, 0, 0, NULL
},
2191 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2192 M_OPT_MIN
, 0, 0, NULL
},
2193 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2194 M_OPT_MIN
, 0, 0, NULL
},
2195 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2196 M_OPT_MIN
, 0, 0, NULL
},
2197 { "length", mp_property_length
, CONF_TYPE_TIME
,
2198 M_OPT_MIN
, 0, 0, NULL
},
2199 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2200 M_OPT_RANGE
, 0, 100, NULL
},
2201 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2202 M_OPT_MIN
, 0, 0, NULL
},
2203 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2204 M_OPT_MIN
, 0, 0, NULL
},
2205 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2207 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2208 CONF_RANGE
, -2, 10, NULL
},
2209 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2211 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2212 M_OPT_RANGE
, 0, 1, NULL
},
2213 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2214 M_OPT_RANGE
, 0, 1, NULL
},
2215 { "pts_association_mode", mp_property_generic_option
, &m_option_type_choice
,
2216 0, 0, 0, "pts-association-mode" },
2217 { "hr_seek", mp_property_generic_option
, &m_option_type_choice
,
2218 0, 0, 0, "hr-seek" },
2221 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2222 M_OPT_RANGE
, 0, 100, NULL
},
2223 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2224 M_OPT_RANGE
, 0, 1, NULL
},
2225 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2226 M_OPT_RANGE
, -100, 100, NULL
},
2227 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2229 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2231 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2233 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2235 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2237 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2238 CONF_RANGE
, -2, 65535, NULL
},
2239 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2240 M_OPT_RANGE
, -1, 1, NULL
},
2243 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2244 M_OPT_RANGE
, 0, 1, NULL
},
2245 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2246 M_OPT_RANGE
, 0, 1, NULL
},
2247 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2248 M_OPT_RANGE
, 0, 2, NULL
},
2249 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2250 M_OPT_RANGE
, 0, 1, NULL
},
2251 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2252 M_OPT_RANGE
, 0, 1, NULL
},
2253 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2254 M_OPT_RANGE
, 0, 1, NULL
},
2255 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2256 M_OPT_RANGE
, 0, 2, NULL
},
2257 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2258 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_gamma
)},
2259 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2260 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_brightness
) },
2261 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2262 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_contrast
) },
2263 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2264 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_saturation
) },
2265 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2266 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_hue
) },
2267 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2268 M_OPT_RANGE
, 0, 1, NULL
},
2269 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2270 M_OPT_RANGE
, 0, 1, NULL
},
2271 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2273 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2275 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2277 { "width", mp_property_width
, CONF_TYPE_INT
,
2279 { "height", mp_property_height
, CONF_TYPE_INT
,
2281 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2283 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2285 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2286 CONF_RANGE
, -2, 65535, NULL
},
2287 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2288 CONF_RANGE
, -1, 65535, NULL
},
2291 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2292 M_OPT_MIN
, -1, 0, NULL
},
2293 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2294 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2295 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2296 M_OPT_MIN
, -1, 0, NULL
},
2297 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2298 M_OPT_MIN
, -1, 0, NULL
},
2299 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2300 M_OPT_MIN
, -1, 0, NULL
},
2301 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2303 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2304 M_OPT_RANGE
, 0, 100, NULL
},
2305 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2306 M_OPT_RANGE
, 0, 2, NULL
},
2307 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2308 M_OPT_RANGE
, 0, 1, NULL
},
2309 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2310 M_OPT_RANGE
, 0, 1, NULL
},
2311 #ifdef CONFIG_FREETYPE
2312 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2313 M_OPT_RANGE
, 0, 100, NULL
},
2316 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2317 M_OPT_RANGE
, 0, 1, NULL
},
2321 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2322 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_BRIGHTNESS
},
2323 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2324 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_CONTRAST
},
2325 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2326 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_SATURATION
},
2327 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2328 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_HUE
},
2330 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2331 M_OPT_RANGE
, 100, 899, .offset
=TV_VBI_CONTROL_GET_PAGE
},
2332 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2333 M_OPT_RANGE
, 0, 64, .offset
=TV_VBI_CONTROL_GET_SUBPAGE
},
2334 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2335 M_OPT_RANGE
, 0, 1, .offset
=TV_VBI_CONTROL_GET_MODE
},
2336 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2337 M_OPT_RANGE
, 0, 3, .offset
=TV_VBI_CONTROL_GET_FORMAT
},
2338 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2339 M_OPT_RANGE
, 0, 2, .offset
=TV_VBI_CONTROL_GET_HALF_PAGE
},
2340 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2344 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2346 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2349 char* mp_property_print(const char *name
, void* ctx
)
2352 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2357 char *property_expand_string(MPContext
*mpctx
, char *str
)
2359 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2362 void property_print_help(void)
2364 m_properties_print_help_list(mp_properties
);
2368 /* List of default ways to show a property on OSD.
2370 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2371 * a bar showing the current position between min/max values of the
2372 * property. In this case osd_msg is only used for terminal output
2373 * if there is no video; it'll be a label shown together with percentage.
2375 * Otherwise setting osd_msg will show the string on OSD, formatted with
2376 * the text value of the property as argument.
2378 static struct property_osd_display
{
2381 /// progressbar type
2382 int osd_progbar
; // -1 is special value for seek indicators
2383 /// osd msg id if it must be shared
2385 /// osd msg template
2386 const char *osd_msg
;
2387 } property_osd_display
[] = {
2389 { "loop", 0, -1, _("Loop: %s") },
2390 { "chapter", -1, -1, NULL
},
2391 { "capturing", 0, -1, _("Capturing: %s") },
2392 { "pts_association_mode", 0, -1, "PTS association mode: %s" },
2393 { "hr_seek", 0, -1, "hr-seek: %s" },
2395 { "volume", OSD_VOLUME
, -1, _("Volume") },
2396 { "mute", 0, -1, _("Mute: %s") },
2397 { "audio_delay", 0, -1, _("A-V delay: %s") },
2398 { "switch_audio", 0, -1, _("Audio: %s") },
2399 { "balance", OSD_BALANCE
, -1, _("Balance") },
2401 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2402 { "ontop", 0, -1, _("Stay on top: %s") },
2403 { "rootwin", 0, -1, _("Rootwin: %s") },
2404 { "border", 0, -1, _("Border: %s") },
2405 { "framedropping", 0, -1, _("Framedropping: %s") },
2406 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2407 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2408 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2409 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2410 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2411 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2412 { "hue", OSD_HUE
, -1, _("Hue") },
2413 { "vsync", 0, -1, _("VSync: %s") },
2415 { "sub", 0, -1, _("Subtitles: %s") },
2416 { "sub_source", 0, -1, _("Sub source: %s") },
2417 { "sub_vob", 0, -1, _("Subtitles: %s") },
2418 { "sub_demux", 0, -1, _("Subtitles: %s") },
2419 { "sub_file", 0, -1, _("Subtitles: %s") },
2420 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2421 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2422 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2423 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2424 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2425 #ifdef CONFIG_FREETYPE
2426 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2429 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2430 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2431 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2432 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2437 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2439 struct MPOpts
*opts
= &mpctx
->opts
;
2442 struct property_osd_display
*p
;
2444 // look for the command
2445 for (p
= property_osd_display
; p
->name
; p
++)
2446 if (!strcmp(p
->name
, pname
))
2451 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2454 if (p
->osd_progbar
== -1)
2455 mpctx
->add_osd_seek_info
= true;
2456 else if (p
->osd_progbar
) {
2457 if (prop
->type
== CONF_TYPE_INT
) {
2458 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2459 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2460 prop
->min
, prop
->max
, r
);
2461 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2463 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2464 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2465 prop
->min
, prop
->max
, f
);
2467 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2468 "Property use an unsupported type.\n");
2475 char *val
= mp_property_print(pname
, mpctx
);
2477 int index
= p
- property_osd_display
;
2478 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2479 1, opts
->osd_duration
, p
->osd_msg
, val
);
2488 * \defgroup Command2Property Command to property bridge
2490 * It is used to handle most commands that just set a property
2491 * and optionally display something on the OSD.
2492 * Two kinds of commands are handled: adjust or toggle.
2494 * Adjust commands take 1 or 2 parameters: <value> <abs>
2495 * If <abs> is non-zero the property is set to the given value
2496 * otherwise it is adjusted.
2498 * Toggle commands take 0 or 1 parameters. With no parameter
2499 * or a value less than the property minimum it just steps the
2500 * property to its next or previous value respectively.
2501 * Otherwise it sets it to the given value.
2506 /// List of the commands that can be handled by setting a property.
2512 /// set/adjust or toggle command
2514 } set_prop_cmd
[] = {
2516 { "loop", MP_CMD_LOOP
, 0},
2517 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2518 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2519 { "pause", MP_CMD_PAUSE
, 0},
2520 { "capturing", MP_CMD_CAPTURING
, 1},
2522 { "volume", MP_CMD_VOLUME
, 0},
2523 { "mute", MP_CMD_MUTE
, 1},
2524 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2525 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2526 { "balance", MP_CMD_BALANCE
, 0},
2528 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2529 { "panscan", MP_CMD_PANSCAN
, 0},
2530 { "ontop", MP_CMD_VO_ONTOP
, 1},
2531 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2532 { "border", MP_CMD_VO_BORDER
, 1},
2533 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2534 { "gamma", MP_CMD_GAMMA
, 0},
2535 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2536 { "contrast", MP_CMD_CONTRAST
, 0},
2537 { "saturation", MP_CMD_SATURATION
, 0},
2538 { "hue", MP_CMD_HUE
, 0},
2539 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2541 { "sub", MP_CMD_SUB_SELECT
, 1},
2542 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2543 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2544 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2545 { "sub_file", MP_CMD_SUB_FILE
, 1},
2546 { "sub_pos", MP_CMD_SUB_POS
, 0},
2547 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2548 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2549 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2550 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2551 #ifdef CONFIG_FREETYPE
2552 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2555 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2558 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2559 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2560 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2561 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2566 /// Handle commands that set a property.
2567 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2573 // look for the command
2574 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2575 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2577 if (!(pname
= set_prop_cmd
[i
].name
))
2580 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2584 if (set_prop_cmd
[i
].toggle
) {
2586 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2587 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2588 else if (cmd
->nargs
> 0)
2589 r
= mp_property_do(pname
, M_PROPERTY_STEP_DOWN
, NULL
, mpctx
);
2591 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2592 } else if (cmd
->args
[1].v
.i
) //set
2593 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2595 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2600 show_property_osd(mpctx
, pname
);
2605 #ifdef CONFIG_DVDNAV
2606 static const struct {
2608 const mp_command_type cmd
;
2609 } mp_dvdnav_bindings
[] = {
2610 { "up", MP_CMD_DVDNAV_UP
},
2611 { "down", MP_CMD_DVDNAV_DOWN
},
2612 { "left", MP_CMD_DVDNAV_LEFT
},
2613 { "right", MP_CMD_DVDNAV_RIGHT
},
2614 { "menu", MP_CMD_DVDNAV_MENU
},
2615 { "select", MP_CMD_DVDNAV_SELECT
},
2616 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2617 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2620 * keep old dvdnav sub-command options for a while in order not to
2621 * break slave-mode API too suddenly.
2623 { "1", MP_CMD_DVDNAV_UP
},
2624 { "2", MP_CMD_DVDNAV_DOWN
},
2625 { "3", MP_CMD_DVDNAV_LEFT
},
2626 { "4", MP_CMD_DVDNAV_RIGHT
},
2627 { "5", MP_CMD_DVDNAV_MENU
},
2628 { "6", MP_CMD_DVDNAV_SELECT
},
2629 { "7", MP_CMD_DVDNAV_PREVMENU
},
2630 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2635 static const char *property_error_string(int error_value
)
2637 switch (error_value
) {
2638 case M_PROPERTY_ERROR
:
2640 case M_PROPERTY_UNAVAILABLE
:
2641 return "PROPERTY_UNAVAILABLE";
2642 case M_PROPERTY_NOT_IMPLEMENTED
:
2643 return "NOT_IMPLEMENTED";
2644 case M_PROPERTY_UNKNOWN
:
2645 return "PROPERTY_UNKNOWN";
2646 case M_PROPERTY_DISABLED
:
2652 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2655 int end
= start
+ count
;
2656 int after
= mpctx
->set_of_sub_size
- end
;
2657 sub_data
**subs
= mpctx
->set_of_subtitles
;
2659 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2661 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2662 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2663 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2664 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2667 for (idx
= start
; idx
< end
; idx
++) {
2668 sub_data
*subd
= subs
[idx
];
2669 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2670 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2671 filename_recode(subd
->filename
));
2675 if (ass_tracks
[idx
])
2676 ass_free_track(ass_tracks
[idx
]);
2677 ass_tracks
[idx
] = NULL
;
2681 mpctx
->global_sub_size
-= count
;
2682 mpctx
->set_of_sub_size
-= count
;
2683 if (mpctx
->set_of_sub_size
<= 0)
2684 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2686 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2687 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2689 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2690 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2693 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2694 mpctx
->global_sub_pos
= -2;
2699 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2700 } else if (mpctx
->set_of_sub_pos
>= end
) {
2701 mpctx
->set_of_sub_pos
-= count
;
2702 mpctx
->global_sub_pos
-= count
;
2706 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2708 struct MPOpts
*opts
= &mpctx
->opts
;
2709 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2710 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2711 int osd_duration
= opts
->osd_duration
;
2712 int case_fallthrough_hack
= 0;
2713 if (!set_property_command(mpctx
, cmd
))
2716 mpctx
->add_osd_seek_info
= true;
2717 float v
= cmd
->args
[0].v
.f
;
2718 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2719 int exact
= (cmd
->nargs
> 2) ? cmd
->args
[2].v
.i
: 0;
2720 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2721 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, v
, exact
);
2722 mpctx
->osd_function
= v
> get_current_time(mpctx
) ?
2724 } else if (abs
) { /* Absolute seek by percentage */
2725 queue_seek(mpctx
, MPSEEK_FACTOR
, v
/ 100.0, exact
);
2726 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2728 queue_seek(mpctx
, MPSEEK_RELATIVE
, v
, exact
);
2729 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2734 case MP_CMD_SET_PROPERTY_OSD
:
2735 case_fallthrough_hack
= 1;
2737 case MP_CMD_SET_PROPERTY
:{
2738 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2739 cmd
->args
[1].v
.s
, mpctx
);
2740 if (r
== M_PROPERTY_UNKNOWN
)
2741 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2742 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2744 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2745 "Failed to set property '%s' to '%s'.\n",
2746 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2747 else if (case_fallthrough_hack
)
2748 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2750 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2754 case MP_CMD_STEP_PROPERTY_OSD
:
2755 case_fallthrough_hack
= 1;
2757 case MP_CMD_STEP_PROPERTY
:{
2762 if (cmd
->args
[1].v
.f
) {
2764 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2765 M_PROPERTY_GET_TYPE
,
2766 &prop
, mpctx
)) <= 0)
2768 if(prop
->type
== CONF_TYPE_INT
||
2769 prop
->type
== CONF_TYPE_FLAG
)
2770 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2771 else if(prop
->type
== CONF_TYPE_FLOAT
)
2772 arg
= &cmd
->args
[1].v
.f
;
2773 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2774 prop
->type
== CONF_TYPE_TIME
)
2775 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2776 else if(prop
->type
== CONF_TYPE_POSITION
)
2777 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2779 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2780 "Ignoring step size stepping property '%s'.\n",
2783 r
= mp_property_do(cmd
->args
[0].v
.s
,
2784 cmd
->args
[2].v
.i
< 0 ?
2785 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2788 if (r
== M_PROPERTY_UNKNOWN
)
2789 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2790 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2792 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2793 "Failed to increment property '%s' by %f.\n",
2794 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2795 else if (case_fallthrough_hack
)
2796 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2798 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2802 case MP_CMD_GET_PROPERTY
:{
2804 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2807 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2808 "Failed to get value of property '%s'.\n",
2810 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2813 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2814 cmd
->args
[0].v
.s
, tmp
);
2819 case MP_CMD_EDL_MARK
:
2821 float v
= get_current_time(mpctx
);
2822 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2823 mpctx
->begin_skip
= v
;
2824 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2826 if (mpctx
->begin_skip
> v
)
2827 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2829 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2830 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2832 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2837 case MP_CMD_SWITCH_RATIO
:
2840 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2841 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2843 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2844 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2847 case MP_CMD_SPEED_INCR
:{
2848 float v
= cmd
->args
[0].v
.f
;
2849 opts
->playback_speed
+= v
;
2850 reinit_audio_chain(mpctx
);
2851 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2852 opts
->playback_speed
);
2855 case MP_CMD_SPEED_MULT
:{
2856 float v
= cmd
->args
[0].v
.f
;
2857 opts
->playback_speed
*= v
;
2858 reinit_audio_chain(mpctx
);
2859 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2860 opts
->playback_speed
);
2863 case MP_CMD_SPEED_SET
:{
2864 float v
= cmd
->args
[0].v
.f
;
2865 opts
->playback_speed
= v
;
2866 reinit_audio_chain(mpctx
);
2867 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2868 opts
->playback_speed
);
2871 case MP_CMD_FRAME_STEP
:
2872 add_step_frame(mpctx
);
2875 case MP_CMD_FILE_FILTER
:
2876 file_filter
= cmd
->args
[0].v
.i
;
2880 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2881 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2883 case MP_CMD_PLAY_TREE_STEP
:{
2884 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2885 int force
= cmd
->args
[1].v
.i
;
2888 if (!force
&& mpctx
->playtree_iter
) {
2889 play_tree_iter_t
*i
=
2890 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2891 if (play_tree_iter_step(i
, n
, 0) ==
2892 PLAY_TREE_ITER_ENTRY
)
2894 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2895 play_tree_iter_free(i
);
2897 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2898 if (mpctx
->stop_play
)
2899 mpctx
->play_tree_step
= n
;
2904 case MP_CMD_PLAY_TREE_UP_STEP
:{
2905 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2906 int force
= cmd
->args
[1].v
.i
;
2908 if (!force
&& mpctx
->playtree_iter
) {
2909 play_tree_iter_t
*i
=
2910 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2911 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2912 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2913 play_tree_iter_free(i
);
2915 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2919 case MP_CMD_PLAY_ALT_SRC_STEP
:
2920 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2921 int v
= cmd
->args
[0].v
.i
;
2923 && mpctx
->playtree_iter
->file
<
2924 mpctx
->playtree_iter
->num_files
)
2925 mpctx
->stop_play
= PT_NEXT_SRC
;
2926 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2927 mpctx
->stop_play
= PT_PREV_SRC
;
2931 case MP_CMD_SUB_STEP
:
2933 int movement
= cmd
->args
[0].v
.i
;
2934 step_sub(subdata
, mpctx
->video_pts
, movement
);
2938 ass_step_sub(ass_track
,
2940 sub_delay
) * 1000 + .5, movement
) / 1000.;
2942 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2943 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2947 case MP_CMD_SUB_LOG
:
2952 int v
= cmd
->args
[0].v
.i
;
2953 int max
= (opts
->term_osd
2954 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2955 if (opts
->osd_level
> max
)
2956 opts
->osd_level
= max
;
2958 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2960 opts
->osd_level
= v
> max
? max
: v
;
2961 /* Show OSD state when disabled, but not when an explicit
2962 argument is given to the OSD command, i.e. in slave mode. */
2963 if (v
== -1 && opts
->osd_level
<= 1)
2964 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2966 opts
->osd_level
? mp_gtext("enabled") :
2967 mp_gtext("disabled"));
2969 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2973 case MP_CMD_OSD_SHOW_TEXT
:
2974 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2976 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2977 "%-.63s", cmd
->args
[0].v
.s
);
2980 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2981 char *txt
= m_properties_expand_string(mp_properties
,
2984 /* if no argument supplied take default osd_duration, else <arg> ms. */
2986 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2988 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2995 case MP_CMD_LOADFILE
:{
2996 play_tree_t
*e
= play_tree_new();
2997 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2999 if (cmd
->args
[1].v
.i
) // append
3000 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3002 // Go back to the starting point.
3003 while (play_tree_iter_up_step
3004 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3006 play_tree_free_list(mpctx
->playtree
->child
, 1);
3007 play_tree_set_child(mpctx
->playtree
, e
);
3008 pt_iter_goto_head(mpctx
->playtree_iter
);
3009 mpctx
->stop_play
= PT_NEXT_SRC
;
3014 case MP_CMD_LOADLIST
:{
3015 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
3017 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
3018 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
3020 if (cmd
->args
[1].v
.i
) // append
3021 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3023 // Go back to the starting point.
3024 while (play_tree_iter_up_step
3025 (mpctx
->playtree_iter
, 0, 1)
3026 != PLAY_TREE_ITER_END
)
3028 play_tree_free_list(mpctx
->playtree
->child
, 1);
3029 play_tree_set_child(mpctx
->playtree
, e
);
3030 pt_iter_goto_head(mpctx
->playtree_iter
);
3031 mpctx
->stop_play
= PT_NEXT_SRC
;
3038 // Go back to the starting point.
3039 while (play_tree_iter_up_step
3040 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3042 mpctx
->stop_play
= PT_STOP
;
3045 case MP_CMD_OSD_SHOW_PROGRESSION
:{
3046 int len
= get_time_length(mpctx
);
3047 int pts
= get_current_time(mpctx
);
3048 set_osd_bar(mpctx
, 0, "Position", 0, 100, get_percent_pos(mpctx
));
3049 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3050 "%c %02d:%02d:%02d / %02d:%02d:%02d",
3051 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
3052 len
/3600, (len
/60)%60, len
%60);
3057 case MP_CMD_RADIO_STEP_CHANNEL
:
3058 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3059 int v
= cmd
->args
[0].v
.i
;
3061 radio_step_channel(mpctx
->demuxer
->stream
,
3062 RADIO_CHANNEL_HIGHER
);
3064 radio_step_channel(mpctx
->demuxer
->stream
,
3065 RADIO_CHANNEL_LOWER
);
3066 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3067 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3069 radio_get_channel_name(mpctx
->demuxer
->stream
));
3074 case MP_CMD_RADIO_SET_CHANNEL
:
3075 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3076 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3077 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3078 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3080 radio_get_channel_name(mpctx
->demuxer
->stream
));
3085 case MP_CMD_RADIO_SET_FREQ
:
3086 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3087 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3090 case MP_CMD_RADIO_STEP_FREQ
:
3091 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3092 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3097 case MP_CMD_TV_START_SCAN
:
3098 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3099 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3101 case MP_CMD_TV_SET_FREQ
:
3102 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3103 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3104 cmd
->args
[0].v
.f
* 16.0);
3106 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3107 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3108 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3109 pvr_get_current_channelname (mpctx
->stream
),
3110 pvr_get_current_stationname (mpctx
->stream
));
3112 #endif /* CONFIG_PVR */
3115 case MP_CMD_TV_STEP_FREQ
:
3116 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3117 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3118 cmd
->args
[0].v
.f
* 16.0);
3120 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3121 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3122 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3123 pvr_get_current_channelname (mpctx
->stream
),
3124 pvr_get_current_frequency (mpctx
->stream
));
3126 #endif /* CONFIG_PVR */
3129 case MP_CMD_TV_SET_NORM
:
3130 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3131 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3135 case MP_CMD_TV_STEP_CHANNEL
:{
3136 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3137 int v
= cmd
->args
[0].v
.i
;
3139 tv_step_channel((tvi_handle_t
*) (mpctx
->
3143 tv_step_channel((tvi_handle_t
*) (mpctx
->
3147 if (tv_channel_list
) {
3148 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3149 "Channel: %s", tv_channel_current
->name
);
3150 //vo_osd_changed(OSDTYPE_SUBTITLE);
3154 else if (mpctx
->stream
&&
3155 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3156 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3157 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3158 pvr_get_current_channelname (mpctx
->stream
),
3159 pvr_get_current_stationname (mpctx
->stream
));
3161 #endif /* CONFIG_PVR */
3164 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3166 int v
= cmd
->args
[0].v
.i
;
3168 mpctx
->last_dvb_step
= v
;
3170 dir
= DVB_CHANNEL_HIGHER
;
3172 dir
= DVB_CHANNEL_LOWER
;
3175 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3176 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3177 mpctx
->dvbin_reopen
= 1;
3180 #endif /* CONFIG_DVBIN */
3183 case MP_CMD_TV_SET_CHANNEL
:
3184 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3185 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3187 if (tv_channel_list
) {
3188 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3189 "Channel: %s", tv_channel_current
->name
);
3190 //vo_osd_changed(OSDTYPE_SUBTITLE);
3194 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3195 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3196 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3197 pvr_get_current_channelname (mpctx
->stream
),
3198 pvr_get_current_stationname (mpctx
->stream
));
3200 #endif /* CONFIG_PVR */
3204 case MP_CMD_DVB_SET_CHANNEL
:
3205 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3206 mpctx
->last_dvb_step
= 1;
3208 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3209 cmd
->args
[0].v
.i
)) {
3210 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3211 mpctx
->dvbin_reopen
= 1;
3215 #endif /* CONFIG_DVBIN */
3217 case MP_CMD_TV_LAST_CHANNEL
:
3218 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3219 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3220 if (tv_channel_list
) {
3221 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3222 "Channel: %s", tv_channel_current
->name
);
3223 //vo_osd_changed(OSDTYPE_SUBTITLE);
3227 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3228 pvr_set_lastchannel (mpctx
->stream
);
3229 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3230 pvr_get_current_channelname (mpctx
->stream
),
3231 pvr_get_current_stationname (mpctx
->stream
));
3233 #endif /* CONFIG_PVR */
3236 case MP_CMD_TV_STEP_NORM
:
3237 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3238 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3241 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3242 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3243 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3245 #endif /* CONFIG_TV */
3246 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3247 if (mpctx
->demuxer
->teletext
)
3248 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3249 &(cmd
->args
[0].v
.s
));
3251 case MP_CMD_TV_TELETEXT_GO_LINK
:
3252 if (mpctx
->demuxer
->teletext
)
3253 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3254 &(cmd
->args
[0].v
.i
));
3257 case MP_CMD_SUB_LOAD
:
3259 int n
= mpctx
->set_of_sub_size
;
3260 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3261 if (n
!= mpctx
->set_of_sub_size
) {
3262 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3263 ++mpctx
->global_sub_size
;
3268 case MP_CMD_SUB_REMOVE
:
3270 int v
= cmd
->args
[0].v
.i
;
3272 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3273 } else if (v
< mpctx
->set_of_sub_size
) {
3274 remove_subtitle_range(mpctx
, v
, 1);
3279 case MP_CMD_GET_SUB_VISIBILITY
:
3281 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3282 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3286 case MP_CMD_SCREENSHOT
:
3287 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3288 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3290 ((vf_instance_t
*) sh_video
->vfilter
)->
3291 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3293 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3297 case MP_CMD_VF_CHANGE_RECTANGLE
:
3300 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3303 case MP_CMD_GET_TIME_LENGTH
:{
3304 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3305 get_time_length(mpctx
));
3309 case MP_CMD_GET_FILENAME
:{
3310 char *inf
= get_metadata(mpctx
, META_NAME
);
3311 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n", inf
);
3316 case MP_CMD_GET_VIDEO_CODEC
:{
3317 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3318 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3323 case MP_CMD_GET_VIDEO_BITRATE
:{
3324 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3325 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3330 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3331 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3332 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3337 case MP_CMD_GET_AUDIO_CODEC
:{
3338 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3339 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3344 case MP_CMD_GET_AUDIO_BITRATE
:{
3345 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3346 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3351 case MP_CMD_GET_AUDIO_SAMPLES
:{
3352 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3353 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3358 case MP_CMD_GET_META_TITLE
:{
3359 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3360 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3365 case MP_CMD_GET_META_ARTIST
:{
3366 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3367 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3372 case MP_CMD_GET_META_ALBUM
:{
3373 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3374 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3379 case MP_CMD_GET_META_YEAR
:{
3380 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3381 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3386 case MP_CMD_GET_META_COMMENT
:{
3387 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3388 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3393 case MP_CMD_GET_META_TRACK
:{
3394 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3395 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3400 case MP_CMD_GET_META_GENRE
:{
3401 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3402 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3407 case MP_CMD_GET_VO_FULLSCREEN
:
3408 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3409 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3412 case MP_CMD_GET_PERCENT_POS
:
3413 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3414 get_percent_pos(mpctx
));
3417 case MP_CMD_GET_TIME_POS
:{
3418 float pos
= get_current_time(mpctx
);
3419 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3426 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3432 case MP_CMD_KEYDOWN_EVENTS
:
3433 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3436 case MP_CMD_SET_MOUSE_POS
:{
3437 int pointer_x
, pointer_y
;
3439 pointer_x
= cmd
->args
[0].v
.i
;
3440 pointer_y
= cmd
->args
[1].v
.i
;
3441 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3442 #ifdef CONFIG_DVDNAV
3443 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3444 && dx
> 0.0 && dy
> 0.0) {
3446 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3447 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3448 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3449 pointer_x
, pointer_y
, &button
);
3450 if (opts
->osd_level
> 1 && button
> 0)
3451 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3452 "Selected button number %d", button
);
3456 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3457 menu_update_mouse_pos(dx
, dy
);
3462 #ifdef CONFIG_DVDNAV
3463 case MP_CMD_DVDNAV
:{
3466 mp_command_type command
= 0;
3467 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3470 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3471 if (cmd
->args
[0].v
.s
&&
3472 !strcasecmp (cmd
->args
[0].v
.s
,
3473 mp_dvdnav_bindings
[i
].name
))
3474 command
= mp_dvdnav_bindings
[i
].cmd
;
3476 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3477 if (opts
->osd_level
> 1 && button
> 0)
3478 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3479 "Selected button number %d", button
);
3483 case MP_CMD_SWITCH_TITLE
:
3484 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3485 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3490 case MP_CMD_AF_SWITCH
:
3493 af_uninit(mpctx
->mixer
.afilter
);
3494 af_init(mpctx
->mixer
.afilter
);
3501 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3502 char* af_commands
= af_args
;
3505 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3507 if (cmd
->id
== MP_CMD_AF_DEL
)
3509 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3511 af_remove(mpctx
->mixer
.afilter
, af
);
3514 af_add(mpctx
->mixer
.afilter
, af_command
);
3516 reinit_audio_chain(mpctx
);
3523 af_uninit(mpctx
->mixer
.afilter
);
3524 af_init(mpctx
->mixer
.afilter
);
3525 reinit_audio_chain(mpctx
);
3527 case MP_CMD_AF_CMDLINE
:
3529 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3531 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3532 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3535 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3536 af_reinit(sh_audio
->afilter
, af
);
3541 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3542 "Received unknown cmd %s\n", cmd
->name
);
3545 switch (cmd
->pausing
) {
3546 case 1: // "pausing"
3547 pause_player(mpctx
);
3549 case 3: // "pausing_toggle"
3551 unpause_player(mpctx
);
3553 pause_player(mpctx
);