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
)
196 struct subtitle
*vo_sub_last
= mpctx
->vo_sub_last
;
198 if (mpctx
->subdata
== NULL
|| vo_sub_last
== NULL
)
200 fname
= get_path("subtitle_log");
201 f
= fopen(fname
, "a");
204 fprintf(f
, "----------------------------------------------------------\n");
205 if (mpctx
->subdata
->sub_uses_time
) {
207 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
208 mpctx
->filename
, vo_sub_last
->start
/ 360000,
209 (vo_sub_last
->start
/ 6000) % 60,
210 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
211 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
212 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
214 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
215 vo_sub_last
->start
, vo_sub_last
->end
);
217 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
218 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
224 /// \defgroup Properties
227 /// \defgroup GeneralProperties General properties
228 /// \ingroup Properties
231 static int mp_property_generic_option(struct m_option
*prop
, int action
,
232 void *arg
, MPContext
*mpctx
)
234 char *optname
= prop
->priv
;
235 const struct m_option
*opt
= m_config_get_option(mpctx
->mconfig
, optname
);
236 void *valptr
= m_option_get_ptr(opt
, &mpctx
->opts
);
239 case M_PROPERTY_GET_TYPE
:
240 *(const struct m_option
**)arg
= opt
;
241 return M_PROPERTY_OK
;
243 m_option_copy(opt
, arg
, valptr
);
244 return M_PROPERTY_OK
;
246 m_option_copy(opt
, valptr
, arg
);
247 return M_PROPERTY_OK
;
248 case M_PROPERTY_STEP_UP
:
249 if (opt
->type
== &m_option_type_choice
) {
250 int v
= *(int *) valptr
;
252 struct m_opt_choice_alternatives
*alt
;
253 for (alt
= opt
->priv
; alt
->name
; alt
++)
254 if ((unsigned) alt
->value
- v
- 1 < (unsigned) best
- v
- 1)
256 *(int *) valptr
= best
;
257 return M_PROPERTY_OK
;
261 return M_PROPERTY_NOT_IMPLEMENTED
;
265 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
268 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
272 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
275 struct MPOpts
*opts
= &mpctx
->opts
;
277 case M_PROPERTY_PRINT
:
278 if (!arg
) return M_PROPERTY_ERROR
;
279 if (opts
->loop_times
< 0)
280 *(char**)arg
= strdup("off");
281 else if (opts
->loop_times
== 0)
282 *(char**)arg
= strdup("inf");
285 return M_PROPERTY_OK
;
287 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
290 /// Playback speed (RW)
291 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
292 void *arg
, MPContext
*mpctx
)
294 struct MPOpts
*opts
= &mpctx
->opts
;
298 return M_PROPERTY_ERROR
;
299 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
300 opts
->playback_speed
= *(float *) arg
;
301 reinit_audio_chain(mpctx
);
302 return M_PROPERTY_OK
;
303 case M_PROPERTY_STEP_UP
:
304 case M_PROPERTY_STEP_DOWN
:
305 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
306 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
307 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
308 reinit_audio_chain(mpctx
);
309 return M_PROPERTY_OK
;
311 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
314 /// filename with path (RO)
315 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
318 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
321 /// filename without path (RO)
322 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
326 if (!mpctx
->filename
)
327 return M_PROPERTY_UNAVAILABLE
;
328 f
= (char *)mp_basename(mpctx
->filename
);
331 return m_property_string_ro(prop
, action
, arg
, f
);
334 /// Demuxer name (RO)
335 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
339 return M_PROPERTY_UNAVAILABLE
;
340 return m_property_string_ro(prop
, action
, arg
,
341 (char *) mpctx
->demuxer
->desc
->name
);
344 /// Position in the stream (RW)
345 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
348 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
349 return M_PROPERTY_UNAVAILABLE
;
351 return M_PROPERTY_ERROR
;
354 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
355 return M_PROPERTY_OK
;
357 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
358 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
359 return M_PROPERTY_OK
;
361 return M_PROPERTY_NOT_IMPLEMENTED
;
364 /// Stream start offset (RO)
365 static int mp_property_stream_start(m_option_t
*prop
, int action
,
366 void *arg
, MPContext
*mpctx
)
368 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
369 return M_PROPERTY_UNAVAILABLE
;
372 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
373 return M_PROPERTY_OK
;
375 return M_PROPERTY_NOT_IMPLEMENTED
;
378 /// Stream end offset (RO)
379 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
382 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
383 return M_PROPERTY_UNAVAILABLE
;
386 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
387 return M_PROPERTY_OK
;
389 return M_PROPERTY_NOT_IMPLEMENTED
;
392 /// Stream length (RO)
393 static int mp_property_stream_length(m_option_t
*prop
, int action
,
394 void *arg
, MPContext
*mpctx
)
396 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
397 return M_PROPERTY_UNAVAILABLE
;
401 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
402 return M_PROPERTY_OK
;
404 return M_PROPERTY_NOT_IMPLEMENTED
;
407 /// Current stream position in seconds (RO)
408 static int mp_property_stream_time_pos(m_option_t
*prop
, int action
,
409 void *arg
, MPContext
*mpctx
)
411 if (!mpctx
->demuxer
|| mpctx
->demuxer
->stream_pts
== MP_NOPTS_VALUE
)
412 return M_PROPERTY_UNAVAILABLE
;
414 return m_property_time_ro(prop
, action
, arg
, mpctx
->demuxer
->stream_pts
);
418 /// Media length in seconds (RO)
419 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
424 if (!mpctx
->demuxer
||
425 !(int) (len
= get_time_length(mpctx
)))
426 return M_PROPERTY_UNAVAILABLE
;
428 return m_property_time_ro(prop
, action
, arg
, len
);
431 /// Current position in percent (RW)
432 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
433 void *arg
, MPContext
*mpctx
) {
437 return M_PROPERTY_UNAVAILABLE
;
441 if(!arg
) return M_PROPERTY_ERROR
;
442 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
445 case M_PROPERTY_STEP_UP
:
446 case M_PROPERTY_STEP_DOWN
:
447 pos
= get_percent_pos(mpctx
);
448 pos
+= (arg
? *(int*)arg
: 10) *
449 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
450 M_PROPERTY_CLAMP(prop
, pos
);
453 return m_property_int_ro(prop
, action
, arg
, get_percent_pos(mpctx
));
456 queue_seek(mpctx
, MPSEEK_FACTOR
, pos
/ 100.0, 0);
457 return M_PROPERTY_OK
;
460 /// Current position in seconds (RW)
461 static int mp_property_time_pos(m_option_t
*prop
, int action
,
462 void *arg
, MPContext
*mpctx
) {
463 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
464 return M_PROPERTY_UNAVAILABLE
;
468 if(!arg
) return M_PROPERTY_ERROR
;
469 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
470 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, *(double*)arg
, 0);
471 return M_PROPERTY_OK
;
472 case M_PROPERTY_STEP_UP
:
473 case M_PROPERTY_STEP_DOWN
:
474 queue_seek(mpctx
, MPSEEK_RELATIVE
, (arg
? *(double*)arg
: 10.0) *
475 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0), 0);
476 return M_PROPERTY_OK
;
478 return m_property_time_ro(prop
, action
, arg
, get_current_time(mpctx
));
481 /// Current chapter (RW)
482 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
485 struct MPOpts
*opts
= &mpctx
->opts
;
488 char *chapter_name
= NULL
;
491 chapter
= get_current_chapter(mpctx
);
493 return M_PROPERTY_UNAVAILABLE
;
498 return M_PROPERTY_ERROR
;
499 *(int *) arg
= chapter
;
500 return M_PROPERTY_OK
;
501 case M_PROPERTY_PRINT
: {
503 return M_PROPERTY_ERROR
;
504 chapter_name
= chapter_display_name(mpctx
, chapter
);
506 return M_PROPERTY_UNAVAILABLE
;
507 *(char **) arg
= chapter_name
;
508 return M_PROPERTY_OK
;
512 return M_PROPERTY_ERROR
;
513 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
514 step_all
= *(int *)arg
- chapter
;
517 case M_PROPERTY_STEP_UP
:
518 case M_PROPERTY_STEP_DOWN
: {
519 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
520 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
527 return M_PROPERTY_NOT_IMPLEMENTED
;
531 queue_seek(mpctx
, MPSEEK_NONE
, 0, 0);
532 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
535 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, next_pts
, 0);
537 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
538 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
539 } else if (step_all
> 0)
540 queue_seek(mpctx
, MPSEEK_RELATIVE
, 1000000000, 0);
542 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
543 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
544 talloc_free(chapter_name
);
545 return M_PROPERTY_OK
;
548 /// Number of chapters in file
549 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
553 return M_PROPERTY_UNAVAILABLE
;
554 if (mpctx
->demuxer
->num_chapters
== 0)
555 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
556 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
559 /// Current dvd angle (RW)
560 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
563 struct MPOpts
*opts
= &mpctx
->opts
;
566 char *angle_name
= NULL
;
569 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
571 return M_PROPERTY_UNAVAILABLE
;
572 angles
= demuxer_angles_count(mpctx
->demuxer
);
574 return M_PROPERTY_UNAVAILABLE
;
579 return M_PROPERTY_ERROR
;
580 *(int *) arg
= angle
;
581 return M_PROPERTY_OK
;
582 case M_PROPERTY_PRINT
: {
584 return M_PROPERTY_ERROR
;
585 angle_name
= calloc(1, 64);
587 return M_PROPERTY_UNAVAILABLE
;
588 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
589 *(char **) arg
= angle_name
;
590 return M_PROPERTY_OK
;
594 return M_PROPERTY_ERROR
;
596 M_PROPERTY_CLAMP(prop
, angle
);
598 case M_PROPERTY_STEP_UP
:
599 case M_PROPERTY_STEP_DOWN
: {
605 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
607 if (angle
< 1) //cycle
612 return M_PROPERTY_NOT_IMPLEMENTED
;
614 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
616 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
618 resync_video_stream(sh_video
);
620 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
622 resync_audio_stream(sh_audio
);
625 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
626 "Angle: %d/%d", angle
, angles
);
628 return M_PROPERTY_OK
;
631 /// Demuxer meta data
632 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
634 m_property_action_t
* ka
;
636 static const m_option_t key_type
=
637 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
639 return M_PROPERTY_UNAVAILABLE
;
643 if(!arg
) return M_PROPERTY_ERROR
;
644 *(char***)arg
= mpctx
->demuxer
->info
;
645 return M_PROPERTY_OK
;
646 case M_PROPERTY_KEY_ACTION
:
647 if(!arg
) return M_PROPERTY_ERROR
;
649 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
650 return M_PROPERTY_UNKNOWN
;
653 if(!ka
->arg
) return M_PROPERTY_ERROR
;
654 *(char**)ka
->arg
= meta
;
655 return M_PROPERTY_OK
;
656 case M_PROPERTY_GET_TYPE
:
657 if(!ka
->arg
) return M_PROPERTY_ERROR
;
658 *(const m_option_t
**)ka
->arg
= &key_type
;
659 return M_PROPERTY_OK
;
662 return M_PROPERTY_NOT_IMPLEMENTED
;
665 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
668 MPContext
*mpctx
= ctx
;
673 return M_PROPERTY_ERROR
;
674 if (mpctx
->paused
== (bool)*(int *) arg
)
675 return M_PROPERTY_OK
;
676 case M_PROPERTY_STEP_UP
:
677 case M_PROPERTY_STEP_DOWN
:
679 unpause_player(mpctx
);
680 mpctx
->osd_function
= OSD_PLAY
;
684 mpctx
->osd_function
= OSD_PAUSE
;
686 return M_PROPERTY_OK
;
688 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
695 /// \defgroup AudioProperties Audio properties
696 /// \ingroup Properties
700 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
704 if (!mpctx
->sh_audio
)
705 return M_PROPERTY_UNAVAILABLE
;
710 return M_PROPERTY_ERROR
;
711 mixer_getbothvolume(&mpctx
->mixer
, arg
);
712 return M_PROPERTY_OK
;
713 case M_PROPERTY_PRINT
:{
716 return M_PROPERTY_ERROR
;
717 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
718 return m_property_float_range(prop
, action
, arg
, &vol
);
720 case M_PROPERTY_STEP_UP
:
721 case M_PROPERTY_STEP_DOWN
:
725 return M_PROPERTY_NOT_IMPLEMENTED
;
728 if (mpctx
->edl_muted
)
729 return M_PROPERTY_DISABLED
;
730 mpctx
->user_muted
= 0;
735 return M_PROPERTY_ERROR
;
736 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
737 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
738 return M_PROPERTY_OK
;
739 case M_PROPERTY_STEP_UP
:
740 if (arg
&& *(float *) arg
<= 0)
741 mixer_decvolume(&mpctx
->mixer
);
743 mixer_incvolume(&mpctx
->mixer
);
744 return M_PROPERTY_OK
;
745 case M_PROPERTY_STEP_DOWN
:
746 if (arg
&& *(float *) arg
<= 0)
747 mixer_incvolume(&mpctx
->mixer
);
749 mixer_decvolume(&mpctx
->mixer
);
750 return M_PROPERTY_OK
;
752 return M_PROPERTY_NOT_IMPLEMENTED
;
756 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
760 if (!mpctx
->sh_audio
)
761 return M_PROPERTY_UNAVAILABLE
;
765 if (mpctx
->edl_muted
)
766 return M_PROPERTY_DISABLED
;
768 return M_PROPERTY_ERROR
;
769 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
770 mixer_mute(&mpctx
->mixer
);
771 mpctx
->user_muted
= mpctx
->mixer
.muted
;
772 return M_PROPERTY_OK
;
773 case M_PROPERTY_STEP_UP
:
774 case M_PROPERTY_STEP_DOWN
:
775 if (mpctx
->edl_muted
)
776 return M_PROPERTY_DISABLED
;
777 mixer_mute(&mpctx
->mixer
);
778 mpctx
->user_muted
= mpctx
->mixer
.muted
;
779 return M_PROPERTY_OK
;
780 case M_PROPERTY_PRINT
:
782 return M_PROPERTY_ERROR
;
783 if (mpctx
->edl_muted
) {
784 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
785 return M_PROPERTY_OK
;
788 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
794 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
795 void *arg
, MPContext
*mpctx
)
797 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
798 return M_PROPERTY_UNAVAILABLE
;
801 case M_PROPERTY_STEP_UP
:
802 case M_PROPERTY_STEP_DOWN
: {
804 float delay
= audio_delay
;
805 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
806 if (ret
!= M_PROPERTY_OK
)
809 mpctx
->delay
-= audio_delay
- delay
;
811 return M_PROPERTY_OK
;
813 return m_property_delay(prop
, action
, arg
, &audio_delay
);
817 /// Audio codec tag (RO)
818 static int mp_property_audio_format(m_option_t
*prop
, int action
,
819 void *arg
, MPContext
*mpctx
)
821 if (!mpctx
->sh_audio
)
822 return M_PROPERTY_UNAVAILABLE
;
823 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
826 /// Audio codec name (RO)
827 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
828 void *arg
, MPContext
*mpctx
)
830 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
831 return M_PROPERTY_UNAVAILABLE
;
832 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
835 /// Audio bitrate (RO)
836 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
837 void *arg
, MPContext
*mpctx
)
839 if (!mpctx
->sh_audio
)
840 return M_PROPERTY_UNAVAILABLE
;
841 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
845 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
848 if (!mpctx
->sh_audio
)
849 return M_PROPERTY_UNAVAILABLE
;
851 case M_PROPERTY_PRINT
:
852 if(!arg
) return M_PROPERTY_ERROR
;
853 *(char**)arg
= malloc(16);
854 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
855 return M_PROPERTY_OK
;
857 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
860 /// Number of channels (RO)
861 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
864 if (!mpctx
->sh_audio
)
865 return M_PROPERTY_UNAVAILABLE
;
867 case M_PROPERTY_PRINT
:
869 return M_PROPERTY_ERROR
;
870 switch (mpctx
->sh_audio
->channels
) {
872 *(char **) arg
= strdup("mono");
875 *(char **) arg
= strdup("stereo");
878 *(char **) arg
= malloc(32);
879 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
881 return M_PROPERTY_OK
;
883 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
887 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
892 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
893 return M_PROPERTY_UNAVAILABLE
;
898 return M_PROPERTY_ERROR
;
899 mixer_getbalance(&mpctx
->mixer
, arg
);
900 return M_PROPERTY_OK
;
901 case M_PROPERTY_PRINT
: {
904 return M_PROPERTY_ERROR
;
905 mixer_getbalance(&mpctx
->mixer
, &bal
);
907 *str
= strdup("center");
908 else if (bal
== -1.f
)
909 *str
= strdup("left only");
911 *str
= strdup("right only");
913 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
914 *str
= malloc(sizeof("left xxx%, right xxx%"));
915 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
917 return M_PROPERTY_OK
;
919 case M_PROPERTY_STEP_UP
:
920 case M_PROPERTY_STEP_DOWN
:
921 mixer_getbalance(&mpctx
->mixer
, &bal
);
922 bal
+= (arg
? *(float*)arg
: .1f
) *
923 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
924 M_PROPERTY_CLAMP(prop
, bal
);
925 mixer_setbalance(&mpctx
->mixer
, bal
);
926 return M_PROPERTY_OK
;
929 return M_PROPERTY_ERROR
;
930 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
931 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
932 return M_PROPERTY_OK
;
934 return M_PROPERTY_NOT_IMPLEMENTED
;
937 /// Selected audio id (RW)
938 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
942 if (!mpctx
->demuxer
|| !mpctx
->d_audio
)
943 return M_PROPERTY_UNAVAILABLE
;
944 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
949 return M_PROPERTY_ERROR
;
950 *(int *) arg
= current_id
;
951 return M_PROPERTY_OK
;
952 case M_PROPERTY_PRINT
:
954 return M_PROPERTY_ERROR
;
957 *(char **) arg
= strdup(mp_gtext("disabled"));
960 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
961 sh_audio_t
* sh
= mpctx
->sh_audio
;
963 av_strlcpy(lang
, sh
->lang
, 40);
964 #ifdef CONFIG_DVDREAD
965 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
966 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
976 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
977 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
979 *(char **) arg
= malloc(64);
980 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
982 return M_PROPERTY_OK
;
984 case M_PROPERTY_STEP_UP
:
986 if (action
== M_PROPERTY_SET
&& arg
)
987 tmp
= *((int *) arg
);
990 int new_id
= demuxer_switch_audio(mpctx
->d_audio
->demuxer
, tmp
);
991 if (new_id
!= current_id
)
992 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
993 if (new_id
!= current_id
&& new_id
>= 0) {
995 sh2
= mpctx
->d_audio
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
996 sh2
->ds
= mpctx
->demuxer
->audio
;
997 mpctx
->sh_audio
= sh2
;
998 reinit_audio_chain(mpctx
);
1000 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
1001 return M_PROPERTY_OK
;
1003 return M_PROPERTY_NOT_IMPLEMENTED
;
1008 /// Selected video id (RW)
1009 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
1012 struct MPOpts
*opts
= &mpctx
->opts
;
1013 int current_id
, tmp
;
1014 if (!mpctx
->demuxer
|| !mpctx
->d_video
)
1015 return M_PROPERTY_UNAVAILABLE
;
1016 current_id
= mpctx
->d_video
->id
;
1019 case M_PROPERTY_GET
:
1021 return M_PROPERTY_ERROR
;
1022 *(int *) arg
= current_id
;
1023 return M_PROPERTY_OK
;
1024 case M_PROPERTY_PRINT
:
1026 return M_PROPERTY_ERROR
;
1029 *(char **) arg
= strdup(mp_gtext("disabled"));
1032 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1033 *(char **) arg
= malloc(64);
1034 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1036 return M_PROPERTY_OK
;
1038 case M_PROPERTY_STEP_UP
:
1039 case M_PROPERTY_SET
:
1040 if (action
== M_PROPERTY_SET
&& arg
)
1041 tmp
= *((int *) arg
);
1044 opts
->video_id
= demuxer_switch_video(mpctx
->d_video
->demuxer
, tmp
);
1045 if (opts
->video_id
== -2
1046 || (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
1047 && current_id
!= -2))
1048 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1049 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1050 if (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
) {
1052 sh2
= mpctx
->d_video
->demuxer
->v_streams
[mpctx
->d_video
->id
];
1054 sh2
->ds
= mpctx
->d_video
;
1055 mpctx
->sh_video
= sh2
;
1056 reinit_video_chain(mpctx
);
1059 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1060 return M_PROPERTY_OK
;
1063 return M_PROPERTY_NOT_IMPLEMENTED
;
1067 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1070 demux_program_t prog
;
1073 case M_PROPERTY_STEP_UP
:
1074 case M_PROPERTY_SET
:
1075 if (action
== M_PROPERTY_SET
&& arg
)
1076 prog
.progid
= *((int *) arg
);
1080 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1081 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1082 return M_PROPERTY_ERROR
;
1084 if (prog
.aid
< 0 && prog
.vid
< 0) {
1085 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1086 return M_PROPERTY_ERROR
;
1088 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1089 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1090 return M_PROPERTY_OK
;
1093 return M_PROPERTY_NOT_IMPLEMENTED
;
1099 /// \defgroup VideoProperties Video properties
1100 /// \ingroup Properties
1103 /// Fullscreen state (RW)
1104 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1108 if (!mpctx
->video_out
)
1109 return M_PROPERTY_UNAVAILABLE
;
1112 case M_PROPERTY_SET
:
1114 return M_PROPERTY_ERROR
;
1115 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1116 if (vo_fs
== !!*(int *) arg
)
1117 return M_PROPERTY_OK
;
1118 case M_PROPERTY_STEP_UP
:
1119 case M_PROPERTY_STEP_DOWN
:
1120 if (mpctx
->video_out
->config_ok
)
1121 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1122 mpctx
->opts
.fullscreen
= vo_fs
;
1123 return M_PROPERTY_OK
;
1125 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1129 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1130 void *arg
, MPContext
*mpctx
)
1134 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1135 return M_PROPERTY_UNAVAILABLE
;
1136 vf
= mpctx
->sh_video
->vfilter
;
1138 case M_PROPERTY_GET
:
1140 return M_PROPERTY_ERROR
;
1141 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1142 return M_PROPERTY_OK
;
1143 case M_PROPERTY_SET
:
1145 return M_PROPERTY_ERROR
;
1146 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1147 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1148 return M_PROPERTY_OK
;
1149 case M_PROPERTY_STEP_UP
:
1150 case M_PROPERTY_STEP_DOWN
:
1151 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1152 deinterlace
= !deinterlace
;
1153 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1154 return M_PROPERTY_OK
;
1157 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1158 return m_property_flag_ro(prop
, action
, arg
, value
);
1161 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1162 void *arg
, MPContext
*mpctx
)
1164 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1165 return M_PROPERTY_UNAVAILABLE
;
1167 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1170 case M_PROPERTY_GET
:
1172 return M_PROPERTY_ERROR
;
1173 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1174 return M_PROPERTY_UNAVAILABLE
;
1175 return M_PROPERTY_OK
;
1176 case M_PROPERTY_PRINT
:
1178 return M_PROPERTY_ERROR
;
1179 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1180 return M_PROPERTY_UNAVAILABLE
;
1181 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1182 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1183 *(char **)arg
= strdup("Unknown");
1185 *(char**)arg
= strdup(names
[colorspace
]);
1186 return M_PROPERTY_OK
;
1187 case M_PROPERTY_SET
:
1189 return M_PROPERTY_ERROR
;
1190 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1191 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1192 return M_PROPERTY_OK
;
1193 case M_PROPERTY_STEP_UP
:;
1194 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1195 return M_PROPERTY_UNAVAILABLE
;
1197 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1198 return M_PROPERTY_OK
;
1200 return M_PROPERTY_NOT_IMPLEMENTED
;
1203 static int mp_property_capture(m_option_t
*prop
, int action
,
1204 void *arg
, MPContext
*mpctx
)
1206 struct MPOpts
*opts
= &mpctx
->opts
;
1209 return M_PROPERTY_UNAVAILABLE
;
1211 if (!opts
->capture_dump
) {
1212 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1213 "Capturing not enabled (forgot -capture parameter?)\n");
1214 return M_PROPERTY_ERROR
;
1217 int capturing
= !!mpctx
->stream
->capture_file
;
1219 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1220 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1222 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1223 if (!mpctx
->stream
->capture_file
) {
1224 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1225 "Error opening capture file: %s\n", strerror(errno
));
1226 ret
= M_PROPERTY_ERROR
;
1229 fclose(mpctx
->stream
->capture_file
);
1230 mpctx
->stream
->capture_file
= NULL
;
1238 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1242 if (!mpctx
->video_out
1243 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1244 return M_PROPERTY_UNAVAILABLE
;
1247 case M_PROPERTY_SET
:
1249 return M_PROPERTY_ERROR
;
1250 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1251 vo_panscan
= *(float *) arg
;
1252 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1253 return M_PROPERTY_OK
;
1254 case M_PROPERTY_STEP_UP
:
1255 case M_PROPERTY_STEP_DOWN
:
1256 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1257 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1260 else if (vo_panscan
< 0)
1262 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1263 return M_PROPERTY_OK
;
1265 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1269 /// Helper to set vo flags.
1270 /** \ingroup PropertyImplHelper
1272 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1273 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1276 if (!mpctx
->video_out
)
1277 return M_PROPERTY_UNAVAILABLE
;
1280 case M_PROPERTY_SET
:
1282 return M_PROPERTY_ERROR
;
1283 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1284 if (*vo_var
== !!*(int *) arg
)
1285 return M_PROPERTY_OK
;
1286 case M_PROPERTY_STEP_UP
:
1287 case M_PROPERTY_STEP_DOWN
:
1288 if (mpctx
->video_out
->config_ok
)
1289 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1290 return M_PROPERTY_OK
;
1292 return m_property_flag(prop
, action
, arg
, vo_var
);
1296 /// Window always on top (RW)
1297 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1300 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1301 &mpctx
->opts
.vo_ontop
, mpctx
);
1304 /// Display in the root window (RW)
1305 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1308 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1309 &vo_rootwin
, mpctx
);
1312 /// Show window borders (RW)
1313 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1316 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1320 /// Framedropping state (RW)
1321 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1322 void *arg
, MPContext
*mpctx
)
1325 if (!mpctx
->sh_video
)
1326 return M_PROPERTY_UNAVAILABLE
;
1329 case M_PROPERTY_PRINT
:
1331 return M_PROPERTY_ERROR
;
1332 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1333 (frame_dropping
== 2 ? mp_gtext("hard") :
1334 mp_gtext("disabled")));
1335 return M_PROPERTY_OK
;
1337 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1341 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1342 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1345 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1348 if (!mpctx
->sh_video
)
1349 return M_PROPERTY_UNAVAILABLE
;
1351 if (gamma
[0] == 1000) {
1353 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1357 case M_PROPERTY_SET
:
1359 return M_PROPERTY_ERROR
;
1360 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1361 *gamma
= *(int *) arg
;
1362 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1366 case M_PROPERTY_GET
:
1367 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1369 return M_PROPERTY_ERROR
;
1371 return M_PROPERTY_OK
;
1374 case M_PROPERTY_STEP_UP
:
1375 case M_PROPERTY_STEP_DOWN
:
1376 *gamma
+= (arg
? *(int *) arg
: 1) *
1377 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1378 M_PROPERTY_CLAMP(prop
, *gamma
);
1379 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1384 return M_PROPERTY_NOT_IMPLEMENTED
;
1388 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1389 int l
= strlen(prop
->name
);
1390 char tv_prop
[3 + l
+ 1];
1391 sprintf(tv_prop
, "tv_%s", prop
->name
);
1392 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1396 return M_PROPERTY_UNAVAILABLE
;
1400 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1403 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1406 /// Video codec tag (RO)
1407 static int mp_property_video_format(m_option_t
*prop
, int action
,
1408 void *arg
, MPContext
*mpctx
)
1411 if (!mpctx
->sh_video
)
1412 return M_PROPERTY_UNAVAILABLE
;
1414 case M_PROPERTY_PRINT
:
1416 return M_PROPERTY_ERROR
;
1417 switch(mpctx
->sh_video
->format
) {
1419 meta
= strdup ("mpeg1"); break;
1421 meta
= strdup ("mpeg2"); break;
1423 meta
= strdup ("mpeg4"); break;
1425 meta
= strdup ("h264"); break;
1427 if(mpctx
->sh_video
->format
>= 0x20202020) {
1429 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1432 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1435 *(char**)arg
= meta
;
1436 return M_PROPERTY_OK
;
1438 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1441 /// Video codec name (RO)
1442 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1443 void *arg
, MPContext
*mpctx
)
1445 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1446 return M_PROPERTY_UNAVAILABLE
;
1447 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1451 /// Video bitrate (RO)
1452 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1453 void *arg
, MPContext
*mpctx
)
1455 if (!mpctx
->sh_video
)
1456 return M_PROPERTY_UNAVAILABLE
;
1457 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1460 /// Video display width (RO)
1461 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1464 if (!mpctx
->sh_video
)
1465 return M_PROPERTY_UNAVAILABLE
;
1466 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1469 /// Video display height (RO)
1470 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1473 if (!mpctx
->sh_video
)
1474 return M_PROPERTY_UNAVAILABLE
;
1475 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1479 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1482 if (!mpctx
->sh_video
)
1483 return M_PROPERTY_UNAVAILABLE
;
1484 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1487 /// Video aspect (RO)
1488 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1491 if (!mpctx
->sh_video
)
1492 return M_PROPERTY_UNAVAILABLE
;
1493 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1498 /// \defgroup SubProprties Subtitles properties
1499 /// \ingroup Properties
1502 /// Text subtitle position (RW)
1503 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1507 case M_PROPERTY_SET
:
1509 return M_PROPERTY_ERROR
;
1510 case M_PROPERTY_STEP_UP
:
1511 case M_PROPERTY_STEP_DOWN
:
1512 vo_osd_changed(OSDTYPE_SUBTITLE
);
1514 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1518 /// Selected subtitles (RW)
1519 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1522 struct MPOpts
*opts
= &mpctx
->opts
;
1523 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1524 int source
= -1, reset_spu
= 0;
1525 int source_pos
= -1;
1528 update_global_sub_size(mpctx
);
1529 const int global_sub_size
= mpctx
->global_sub_size
;
1531 if (global_sub_size
<= 0)
1532 return M_PROPERTY_UNAVAILABLE
;
1535 case M_PROPERTY_GET
:
1537 return M_PROPERTY_ERROR
;
1538 *(int *) arg
= mpctx
->global_sub_pos
;
1539 return M_PROPERTY_OK
;
1540 case M_PROPERTY_PRINT
:
1542 return M_PROPERTY_ERROR
;
1543 *(char **) arg
= malloc(64);
1544 (*(char **) arg
)[63] = 0;
1547 sub_name
= mpctx
->subdata
->filename
;
1549 if (ass_track
&& ass_track
->name
)
1550 sub_name
= ass_track
->name
;
1553 const char *tmp
= mp_basename(sub_name
);
1555 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1556 mpctx
->set_of_sub_pos
+ 1,
1557 strlen(tmp
) < 20 ? "" : "...",
1558 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1559 return M_PROPERTY_OK
;
1561 #ifdef CONFIG_DVDNAV
1562 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1563 if (vo_spudec
&& opts
->sub_id
>= 0) {
1564 unsigned char lang
[3];
1565 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1566 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1567 return M_PROPERTY_OK
;
1573 if ((d_sub
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1574 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF
1575 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1576 || d_sub
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1577 && d_sub
->sh
&& opts
->sub_id
>= 0) {
1578 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1579 if (!lang
) lang
= mp_gtext("unknown");
1580 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1581 return M_PROPERTY_OK
;
1584 if (vo_vobsub
&& vobsub_id
>= 0) {
1585 const char *language
= mp_gtext("unknown");
1586 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1587 snprintf(*(char **) arg
, 63, "(%d) %s",
1588 vobsub_id
, language
? language
: mp_gtext("unknown"));
1589 return M_PROPERTY_OK
;
1591 #ifdef CONFIG_DVDREAD
1592 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1593 && opts
->sub_id
>= 0) {
1595 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1596 lang
[0] = code
>> 8;
1599 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1600 return M_PROPERTY_OK
;
1603 if (opts
->sub_id
>= 0) {
1604 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1605 mp_gtext("unknown"));
1606 return M_PROPERTY_OK
;
1608 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1609 return M_PROPERTY_OK
;
1611 case M_PROPERTY_SET
:
1613 return M_PROPERTY_ERROR
;
1614 if (*(int *) arg
< -1)
1616 else if (*(int *) arg
>= global_sub_size
)
1617 *(int *) arg
= global_sub_size
- 1;
1618 mpctx
->global_sub_pos
= *(int *) arg
;
1620 case M_PROPERTY_STEP_UP
:
1621 mpctx
->global_sub_pos
+= 2;
1622 mpctx
->global_sub_pos
=
1623 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1625 case M_PROPERTY_STEP_DOWN
:
1626 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1627 mpctx
->global_sub_pos
=
1628 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1631 return M_PROPERTY_NOT_IMPLEMENTED
;
1634 if (mpctx
->global_sub_pos
>= 0) {
1635 source
= sub_source(mpctx
);
1636 source_pos
= sub_source_pos(mpctx
);
1639 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1640 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1642 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1643 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1644 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1645 mpctx
->global_sub_pos
, source
);
1647 mpctx
->set_of_sub_pos
= -1;
1648 mpctx
->subdata
= NULL
;
1661 if (source
== SUB_SOURCE_VOBSUB
) {
1662 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1663 } else if (source
== SUB_SOURCE_SUBS
) {
1664 mpctx
->set_of_sub_pos
= source_pos
;
1666 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1667 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1671 mpctx
->subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1672 vo_osd_changed(OSDTYPE_SUBTITLE
);
1674 } else if (source
== SUB_SOURCE_DEMUX
) {
1675 opts
->sub_id
= source_pos
;
1676 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1678 // default: assume 1:1 mapping of sid and stream id
1679 d_sub
->id
= opts
->sub_id
;
1680 d_sub
->sh
= mpctx
->d_sub
->demuxer
->s_streams
[d_sub
->id
];
1681 ds_free_packs(d_sub
);
1682 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1683 sh_sub_t
*sh
= mpctx
->d_sub
->demuxer
->s_streams
[i
];
1684 if (sh
&& sh
->sid
== opts
->sub_id
) {
1690 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1691 sh_sub_t
*sh
= d_sub
->sh
;
1692 if (sh
->type
== 'v')
1693 init_vo_spudec(mpctx
);
1695 else if (opts
->ass_enabled
)
1696 ass_track
= sh
->ass_track
;
1704 #ifdef CONFIG_DVDREAD
1706 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1707 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1708 && opts
->sub_id
< 0 && reset_spu
) {
1714 update_subtitles(mpctx
, 0, 0, true);
1716 return M_PROPERTY_OK
;
1719 /// Selected sub source (RW)
1720 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1724 update_global_sub_size(mpctx
);
1725 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1726 return M_PROPERTY_UNAVAILABLE
;
1729 case M_PROPERTY_GET
:
1731 return M_PROPERTY_ERROR
;
1732 *(int *) arg
= sub_source(mpctx
);
1733 return M_PROPERTY_OK
;
1734 case M_PROPERTY_PRINT
:
1736 return M_PROPERTY_ERROR
;
1737 *(char **) arg
= malloc(64);
1738 (*(char **) arg
)[63] = 0;
1739 switch (sub_source(mpctx
))
1741 case SUB_SOURCE_SUBS
:
1742 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1744 case SUB_SOURCE_VOBSUB
:
1745 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1747 case SUB_SOURCE_DEMUX
:
1748 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1751 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1753 return M_PROPERTY_OK
;
1754 case M_PROPERTY_SET
:
1756 return M_PROPERTY_ERROR
;
1757 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1758 if (*(int *) arg
< 0)
1759 mpctx
->global_sub_pos
= -1;
1760 else if (*(int *) arg
!= sub_source(mpctx
)) {
1761 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1763 return M_PROPERTY_UNAVAILABLE
;
1764 mpctx
->global_sub_pos
= new_pos
;
1767 case M_PROPERTY_STEP_UP
:
1768 case M_PROPERTY_STEP_DOWN
: {
1769 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1770 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1771 int step
= (step_all
> 0) ? 1 : -1;
1772 int cur_source
= sub_source(mpctx
);
1773 source
= cur_source
;
1776 if (source
>= SUB_SOURCES
)
1778 else if (source
< -1)
1779 source
= SUB_SOURCES
- 1;
1780 if (source
== cur_source
|| source
== -1 ||
1781 mpctx
->sub_counts
[source
])
1784 if (source
== cur_source
)
1785 return M_PROPERTY_OK
;
1787 mpctx
->global_sub_pos
= -1;
1789 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1793 return M_PROPERTY_NOT_IMPLEMENTED
;
1795 --mpctx
->global_sub_pos
;
1796 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1799 /// Selected subtitles from specific source (RW)
1800 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1803 int source
, is_cur_source
, offset
, new_pos
;
1804 update_global_sub_size(mpctx
);
1805 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1806 return M_PROPERTY_UNAVAILABLE
;
1808 if (!strcmp(prop
->name
, "sub_file"))
1809 source
= SUB_SOURCE_SUBS
;
1810 else if (!strcmp(prop
->name
, "sub_vob"))
1811 source
= SUB_SOURCE_VOBSUB
;
1812 else if (!strcmp(prop
->name
, "sub_demux"))
1813 source
= SUB_SOURCE_DEMUX
;
1815 return M_PROPERTY_ERROR
;
1817 offset
= sub_pos_by_source(mpctx
, source
);
1819 return M_PROPERTY_UNAVAILABLE
;
1821 is_cur_source
= sub_source(mpctx
) == source
;
1822 new_pos
= mpctx
->global_sub_pos
;
1824 case M_PROPERTY_GET
:
1826 return M_PROPERTY_ERROR
;
1827 if (is_cur_source
) {
1828 *(int *) arg
= sub_source_pos(mpctx
);
1829 if (source
== SUB_SOURCE_VOBSUB
)
1830 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1834 return M_PROPERTY_OK
;
1835 case M_PROPERTY_PRINT
:
1837 return M_PROPERTY_ERROR
;
1839 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1840 *(char **) arg
= malloc(64);
1841 (*(char **) arg
)[63] = 0;
1842 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1843 return M_PROPERTY_OK
;
1844 case M_PROPERTY_SET
:
1846 return M_PROPERTY_ERROR
;
1847 if (*(int *) arg
>= 0) {
1848 int index
= *(int *)arg
;
1849 if (source
== SUB_SOURCE_VOBSUB
)
1850 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1851 new_pos
= offset
+ index
;
1852 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1860 case M_PROPERTY_STEP_UP
:
1861 case M_PROPERTY_STEP_DOWN
: {
1862 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1863 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1864 int step
= (step_all
> 0) ? 1 : -1;
1865 int max_sub_pos_for_source
= -1;
1869 if (new_pos
== -1) {
1872 else if (max_sub_pos_for_source
== -1) {
1873 // Find max pos for specific source
1874 new_pos
= mpctx
->global_sub_size
- 1;
1876 && sub_source(mpctx
) != source
)
1880 new_pos
= max_sub_pos_for_source
;
1884 if (new_pos
< offset
||
1885 new_pos
>= mpctx
->global_sub_size
||
1886 sub_source(mpctx
) != source
)
1894 return M_PROPERTY_NOT_IMPLEMENTED
;
1896 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1899 /// Subtitle delay (RW)
1900 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1903 if (!mpctx
->sh_video
)
1904 return M_PROPERTY_UNAVAILABLE
;
1905 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1908 /// Alignment of text subtitles (RW)
1909 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1910 void *arg
, MPContext
*mpctx
)
1912 char *name
[] = { _("top"), _("center"), _("bottom") };
1914 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1915 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1916 return M_PROPERTY_UNAVAILABLE
;
1919 case M_PROPERTY_PRINT
:
1921 return M_PROPERTY_ERROR
;
1922 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1923 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1924 return M_PROPERTY_OK
;
1925 case M_PROPERTY_SET
:
1927 return M_PROPERTY_ERROR
;
1928 case M_PROPERTY_STEP_UP
:
1929 case M_PROPERTY_STEP_DOWN
:
1930 vo_osd_changed(OSDTYPE_SUBTITLE
);
1932 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1936 /// Subtitle visibility (RW)
1937 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1938 void *arg
, MPContext
*mpctx
)
1940 if (!mpctx
->sh_video
)
1941 return M_PROPERTY_UNAVAILABLE
;
1944 case M_PROPERTY_SET
:
1946 return M_PROPERTY_ERROR
;
1947 case M_PROPERTY_STEP_UP
:
1948 case M_PROPERTY_STEP_DOWN
:
1949 vo_osd_changed(OSDTYPE_SUBTITLE
);
1951 vo_osd_changed(OSDTYPE_SPU
);
1953 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1958 /// Use margins for libass subtitles (RW)
1959 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1960 void *arg
, MPContext
*mpctx
)
1962 if (!mpctx
->sh_video
)
1963 return M_PROPERTY_UNAVAILABLE
;
1966 case M_PROPERTY_SET
:
1968 return M_PROPERTY_ERROR
;
1969 case M_PROPERTY_STEP_UP
:
1970 case M_PROPERTY_STEP_DOWN
:
1971 ass_force_reload
= 1;
1973 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1978 /// Show only forced subtitles (RW)
1979 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1980 void *arg
, MPContext
*mpctx
)
1983 return M_PROPERTY_UNAVAILABLE
;
1986 case M_PROPERTY_SET
:
1988 return M_PROPERTY_ERROR
;
1989 case M_PROPERTY_STEP_UP
:
1990 case M_PROPERTY_STEP_DOWN
:
1991 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1992 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1993 return M_PROPERTY_OK
;
1995 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
2000 #ifdef CONFIG_FREETYPE
2001 /// Subtitle scale (RW)
2002 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
2005 struct MPOpts
*opts
= &mpctx
->opts
;
2008 case M_PROPERTY_SET
:
2010 return M_PROPERTY_ERROR
;
2011 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
2013 if (opts
->ass_enabled
) {
2014 ass_font_scale
= *(float *) arg
;
2015 ass_force_reload
= 1;
2018 text_font_scale_factor
= *(float *) arg
;
2019 force_load_font
= 1;
2020 return M_PROPERTY_OK
;
2021 case M_PROPERTY_STEP_UP
:
2022 case M_PROPERTY_STEP_DOWN
:
2024 if (opts
->ass_enabled
) {
2025 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
2026 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2027 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
2028 ass_force_reload
= 1;
2031 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
2032 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2033 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2034 force_load_font
= 1;
2035 return M_PROPERTY_OK
;
2038 if (opts
->ass_enabled
)
2039 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
2042 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2049 /// \defgroup TVProperties TV properties
2050 /// \ingroup Properties
2055 /// TV color settings (RW)
2056 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2060 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2061 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2062 return M_PROPERTY_UNAVAILABLE
;
2065 case M_PROPERTY_SET
:
2067 return M_PROPERTY_ERROR
;
2068 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2069 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2070 case M_PROPERTY_GET
:
2071 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2072 case M_PROPERTY_STEP_UP
:
2073 case M_PROPERTY_STEP_DOWN
:
2074 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2076 return M_PROPERTY_ERROR
;
2077 val
+= (arg
? *(int *) arg
: 1) *
2078 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2079 M_PROPERTY_CLAMP(prop
, val
);
2080 return tv_set_color_options(tvh
, prop
->offset
, val
);
2082 return M_PROPERTY_ERROR
;
2084 return M_PROPERTY_NOT_IMPLEMENTED
;
2089 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2093 int base_ioctl
= prop
->offset
;
2095 for teletext's GET,SET,STEP ioctls this is not 0
2099 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2100 return M_PROPERTY_UNAVAILABLE
;
2102 return M_PROPERTY_ERROR
;
2105 case M_PROPERTY_GET
:
2107 return M_PROPERTY_ERROR
;
2108 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2110 case M_PROPERTY_SET
:
2112 return M_PROPERTY_ERROR
;
2113 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2114 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2116 case M_PROPERTY_STEP_UP
:
2117 case M_PROPERTY_STEP_DOWN
:
2118 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2119 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2120 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2123 return M_PROPERTY_NOT_IMPLEMENTED
;
2126 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2129 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2135 //with tvh==NULL will fail too
2136 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2137 if(result
!=M_PROPERTY_OK
)
2140 if(teletext_control(mpctx
->demuxer
->teletext
,
2141 prop
->offset
, &val
)==VBI_CONTROL_TRUE
&& val
)
2142 mp_input_set_section(mpctx
->input
, "teletext");
2144 mp_input_set_section(mpctx
->input
, "tv");
2145 return M_PROPERTY_OK
;
2148 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2153 if (!mpctx
->demuxer
->teletext
)
2154 return M_PROPERTY_UNAVAILABLE
;
2156 case M_PROPERTY_STEP_UP
:
2157 case M_PROPERTY_STEP_DOWN
:
2158 //This should be handled separately
2159 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2160 result
=teletext_control(mpctx
->demuxer
->teletext
,
2161 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2164 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2171 /// All properties available in MPlayer.
2172 /** \ingroup Properties
2174 static const m_option_t mp_properties
[] = {
2176 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2177 M_OPT_RANGE
, 0, 3, NULL
},
2178 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2179 M_OPT_MIN
, -1, 0, NULL
},
2180 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2181 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2182 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2184 { "path", mp_property_path
, CONF_TYPE_STRING
,
2186 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2188 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2189 M_OPT_MIN
, 0, 0, NULL
},
2190 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2191 M_OPT_MIN
, 0, 0, NULL
},
2192 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2193 M_OPT_MIN
, 0, 0, NULL
},
2194 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2195 M_OPT_MIN
, 0, 0, NULL
},
2196 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2197 M_OPT_MIN
, 0, 0, NULL
},
2198 { "length", mp_property_length
, CONF_TYPE_TIME
,
2199 M_OPT_MIN
, 0, 0, NULL
},
2200 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2201 M_OPT_RANGE
, 0, 100, NULL
},
2202 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2203 M_OPT_MIN
, 0, 0, NULL
},
2204 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2205 M_OPT_MIN
, 0, 0, NULL
},
2206 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2208 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2209 CONF_RANGE
, -2, 10, NULL
},
2210 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2212 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2213 M_OPT_RANGE
, 0, 1, NULL
},
2214 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2215 M_OPT_RANGE
, 0, 1, NULL
},
2216 { "pts_association_mode", mp_property_generic_option
, &m_option_type_choice
,
2217 0, 0, 0, "pts-association-mode" },
2218 { "hr_seek", mp_property_generic_option
, &m_option_type_choice
,
2219 0, 0, 0, "hr-seek" },
2222 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2223 M_OPT_RANGE
, 0, 100, NULL
},
2224 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2225 M_OPT_RANGE
, 0, 1, NULL
},
2226 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2227 M_OPT_RANGE
, -100, 100, NULL
},
2228 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2230 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2232 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2234 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2236 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2238 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2239 CONF_RANGE
, -2, 65535, NULL
},
2240 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2241 M_OPT_RANGE
, -1, 1, NULL
},
2244 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2245 M_OPT_RANGE
, 0, 1, NULL
},
2246 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2247 M_OPT_RANGE
, 0, 1, NULL
},
2248 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2249 M_OPT_RANGE
, 0, 2, NULL
},
2250 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2251 M_OPT_RANGE
, 0, 1, NULL
},
2252 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2253 M_OPT_RANGE
, 0, 1, NULL
},
2254 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2255 M_OPT_RANGE
, 0, 1, NULL
},
2256 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2257 M_OPT_RANGE
, 0, 2, NULL
},
2258 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2259 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_gamma
)},
2260 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2261 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_brightness
) },
2262 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2263 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_contrast
) },
2264 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2265 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_saturation
) },
2266 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2267 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_hue
) },
2268 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2269 M_OPT_RANGE
, 0, 1, NULL
},
2270 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2271 M_OPT_RANGE
, 0, 1, NULL
},
2272 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2274 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2276 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2278 { "width", mp_property_width
, CONF_TYPE_INT
,
2280 { "height", mp_property_height
, CONF_TYPE_INT
,
2282 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2284 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2286 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2287 CONF_RANGE
, -2, 65535, NULL
},
2288 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2289 CONF_RANGE
, -1, 65535, NULL
},
2292 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2293 M_OPT_MIN
, -1, 0, NULL
},
2294 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2295 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2296 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2297 M_OPT_MIN
, -1, 0, NULL
},
2298 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2299 M_OPT_MIN
, -1, 0, NULL
},
2300 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2301 M_OPT_MIN
, -1, 0, NULL
},
2302 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2304 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2305 M_OPT_RANGE
, 0, 100, NULL
},
2306 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2307 M_OPT_RANGE
, 0, 2, NULL
},
2308 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2309 M_OPT_RANGE
, 0, 1, NULL
},
2310 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2311 M_OPT_RANGE
, 0, 1, NULL
},
2312 #ifdef CONFIG_FREETYPE
2313 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2314 M_OPT_RANGE
, 0, 100, NULL
},
2317 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2318 M_OPT_RANGE
, 0, 1, NULL
},
2322 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2323 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_BRIGHTNESS
},
2324 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2325 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_CONTRAST
},
2326 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2327 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_SATURATION
},
2328 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2329 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_HUE
},
2331 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2332 M_OPT_RANGE
, 100, 899, .offset
=TV_VBI_CONTROL_GET_PAGE
},
2333 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2334 M_OPT_RANGE
, 0, 64, .offset
=TV_VBI_CONTROL_GET_SUBPAGE
},
2335 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2336 M_OPT_RANGE
, 0, 1, .offset
=TV_VBI_CONTROL_GET_MODE
},
2337 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2338 M_OPT_RANGE
, 0, 3, .offset
=TV_VBI_CONTROL_GET_FORMAT
},
2339 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2340 M_OPT_RANGE
, 0, 2, .offset
=TV_VBI_CONTROL_GET_HALF_PAGE
},
2341 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2345 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2347 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2350 char* mp_property_print(const char *name
, void* ctx
)
2353 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2358 char *property_expand_string(MPContext
*mpctx
, char *str
)
2360 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2363 void property_print_help(void)
2365 m_properties_print_help_list(mp_properties
);
2369 /* List of default ways to show a property on OSD.
2371 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2372 * a bar showing the current position between min/max values of the
2373 * property. In this case osd_msg is only used for terminal output
2374 * if there is no video; it'll be a label shown together with percentage.
2376 * Otherwise setting osd_msg will show the string on OSD, formatted with
2377 * the text value of the property as argument.
2379 static struct property_osd_display
{
2382 /// progressbar type
2383 int osd_progbar
; // -1 is special value for seek indicators
2384 /// osd msg id if it must be shared
2386 /// osd msg template
2387 const char *osd_msg
;
2388 } property_osd_display
[] = {
2390 { "loop", 0, -1, _("Loop: %s") },
2391 { "chapter", -1, -1, NULL
},
2392 { "capturing", 0, -1, _("Capturing: %s") },
2393 { "pts_association_mode", 0, -1, "PTS association mode: %s" },
2394 { "hr_seek", 0, -1, "hr-seek: %s" },
2396 { "volume", OSD_VOLUME
, -1, _("Volume") },
2397 { "mute", 0, -1, _("Mute: %s") },
2398 { "audio_delay", 0, -1, _("A-V delay: %s") },
2399 { "switch_audio", 0, -1, _("Audio: %s") },
2400 { "balance", OSD_BALANCE
, -1, _("Balance") },
2402 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2403 { "ontop", 0, -1, _("Stay on top: %s") },
2404 { "rootwin", 0, -1, _("Rootwin: %s") },
2405 { "border", 0, -1, _("Border: %s") },
2406 { "framedropping", 0, -1, _("Framedropping: %s") },
2407 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2408 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2409 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2410 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2411 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2412 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2413 { "hue", OSD_HUE
, -1, _("Hue") },
2414 { "vsync", 0, -1, _("VSync: %s") },
2416 { "sub", 0, -1, _("Subtitles: %s") },
2417 { "sub_source", 0, -1, _("Sub source: %s") },
2418 { "sub_vob", 0, -1, _("Subtitles: %s") },
2419 { "sub_demux", 0, -1, _("Subtitles: %s") },
2420 { "sub_file", 0, -1, _("Subtitles: %s") },
2421 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2422 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2423 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2424 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2425 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2426 #ifdef CONFIG_FREETYPE
2427 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2430 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2431 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2432 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2433 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2438 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2440 struct MPOpts
*opts
= &mpctx
->opts
;
2443 struct property_osd_display
*p
;
2445 // look for the command
2446 for (p
= property_osd_display
; p
->name
; p
++)
2447 if (!strcmp(p
->name
, pname
))
2452 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2455 if (p
->osd_progbar
== -1)
2456 mpctx
->add_osd_seek_info
= true;
2457 else if (p
->osd_progbar
) {
2458 if (prop
->type
== CONF_TYPE_INT
) {
2459 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2460 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2461 prop
->min
, prop
->max
, r
);
2462 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2464 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2465 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2466 prop
->min
, prop
->max
, f
);
2468 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2469 "Property use an unsupported type.\n");
2476 char *val
= mp_property_print(pname
, mpctx
);
2478 int index
= p
- property_osd_display
;
2479 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2480 1, opts
->osd_duration
, p
->osd_msg
, val
);
2489 * \defgroup Command2Property Command to property bridge
2491 * It is used to handle most commands that just set a property
2492 * and optionally display something on the OSD.
2493 * Two kinds of commands are handled: adjust or toggle.
2495 * Adjust commands take 1 or 2 parameters: <value> <abs>
2496 * If <abs> is non-zero the property is set to the given value
2497 * otherwise it is adjusted.
2499 * Toggle commands take 0 or 1 parameters. With no parameter
2500 * or a value less than the property minimum it just steps the
2501 * property to its next or previous value respectively.
2502 * Otherwise it sets it to the given value.
2507 /// List of the commands that can be handled by setting a property.
2513 /// set/adjust or toggle command
2515 } set_prop_cmd
[] = {
2517 { "loop", MP_CMD_LOOP
, 0},
2518 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2519 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2520 { "pause", MP_CMD_PAUSE
, 0},
2521 { "capturing", MP_CMD_CAPTURING
, 1},
2523 { "volume", MP_CMD_VOLUME
, 0},
2524 { "mute", MP_CMD_MUTE
, 1},
2525 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2526 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2527 { "balance", MP_CMD_BALANCE
, 0},
2529 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2530 { "panscan", MP_CMD_PANSCAN
, 0},
2531 { "ontop", MP_CMD_VO_ONTOP
, 1},
2532 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2533 { "border", MP_CMD_VO_BORDER
, 1},
2534 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2535 { "gamma", MP_CMD_GAMMA
, 0},
2536 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2537 { "contrast", MP_CMD_CONTRAST
, 0},
2538 { "saturation", MP_CMD_SATURATION
, 0},
2539 { "hue", MP_CMD_HUE
, 0},
2540 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2542 { "sub", MP_CMD_SUB_SELECT
, 1},
2543 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2544 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2545 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2546 { "sub_file", MP_CMD_SUB_FILE
, 1},
2547 { "sub_pos", MP_CMD_SUB_POS
, 0},
2548 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2549 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2550 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2551 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2552 #ifdef CONFIG_FREETYPE
2553 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2556 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2559 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2560 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2561 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2562 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2567 /// Handle commands that set a property.
2568 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2574 // look for the command
2575 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2576 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2578 if (!(pname
= set_prop_cmd
[i
].name
))
2581 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2585 if (set_prop_cmd
[i
].toggle
) {
2587 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2588 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2589 else if (cmd
->nargs
> 0)
2590 r
= mp_property_do(pname
, M_PROPERTY_STEP_DOWN
, NULL
, mpctx
);
2592 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2593 } else if (cmd
->args
[1].v
.i
) //set
2594 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2596 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2601 show_property_osd(mpctx
, pname
);
2606 #ifdef CONFIG_DVDNAV
2607 static const struct {
2609 const mp_command_type cmd
;
2610 } mp_dvdnav_bindings
[] = {
2611 { "up", MP_CMD_DVDNAV_UP
},
2612 { "down", MP_CMD_DVDNAV_DOWN
},
2613 { "left", MP_CMD_DVDNAV_LEFT
},
2614 { "right", MP_CMD_DVDNAV_RIGHT
},
2615 { "menu", MP_CMD_DVDNAV_MENU
},
2616 { "select", MP_CMD_DVDNAV_SELECT
},
2617 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2618 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2621 * keep old dvdnav sub-command options for a while in order not to
2622 * break slave-mode API too suddenly.
2624 { "1", MP_CMD_DVDNAV_UP
},
2625 { "2", MP_CMD_DVDNAV_DOWN
},
2626 { "3", MP_CMD_DVDNAV_LEFT
},
2627 { "4", MP_CMD_DVDNAV_RIGHT
},
2628 { "5", MP_CMD_DVDNAV_MENU
},
2629 { "6", MP_CMD_DVDNAV_SELECT
},
2630 { "7", MP_CMD_DVDNAV_PREVMENU
},
2631 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2636 static const char *property_error_string(int error_value
)
2638 switch (error_value
) {
2639 case M_PROPERTY_ERROR
:
2641 case M_PROPERTY_UNAVAILABLE
:
2642 return "PROPERTY_UNAVAILABLE";
2643 case M_PROPERTY_NOT_IMPLEMENTED
:
2644 return "NOT_IMPLEMENTED";
2645 case M_PROPERTY_UNKNOWN
:
2646 return "PROPERTY_UNKNOWN";
2647 case M_PROPERTY_DISABLED
:
2653 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2656 int end
= start
+ count
;
2657 int after
= mpctx
->set_of_sub_size
- end
;
2658 sub_data
**subs
= mpctx
->set_of_subtitles
;
2660 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2662 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2663 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2664 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2665 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2668 for (idx
= start
; idx
< end
; idx
++) {
2669 sub_data
*subd
= subs
[idx
];
2670 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2671 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2672 filename_recode(subd
->filename
));
2676 if (ass_tracks
[idx
])
2677 ass_free_track(ass_tracks
[idx
]);
2678 ass_tracks
[idx
] = NULL
;
2682 mpctx
->global_sub_size
-= count
;
2683 mpctx
->set_of_sub_size
-= count
;
2684 if (mpctx
->set_of_sub_size
<= 0)
2685 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2687 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2688 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2690 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2691 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2694 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2695 mpctx
->global_sub_pos
= -2;
2696 mpctx
->subdata
= NULL
;
2700 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2701 } else if (mpctx
->set_of_sub_pos
>= end
) {
2702 mpctx
->set_of_sub_pos
-= count
;
2703 mpctx
->global_sub_pos
-= count
;
2707 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2709 struct MPOpts
*opts
= &mpctx
->opts
;
2710 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2711 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2712 int osd_duration
= opts
->osd_duration
;
2713 int case_fallthrough_hack
= 0;
2714 if (!set_property_command(mpctx
, cmd
))
2717 mpctx
->add_osd_seek_info
= true;
2718 float v
= cmd
->args
[0].v
.f
;
2719 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2720 int exact
= (cmd
->nargs
> 2) ? cmd
->args
[2].v
.i
: 0;
2721 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2722 queue_seek(mpctx
, MPSEEK_ABSOLUTE
, v
, exact
);
2723 mpctx
->osd_function
= v
> get_current_time(mpctx
) ?
2725 } else if (abs
) { /* Absolute seek by percentage */
2726 queue_seek(mpctx
, MPSEEK_FACTOR
, v
/ 100.0, exact
);
2727 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2729 queue_seek(mpctx
, MPSEEK_RELATIVE
, v
, exact
);
2730 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2735 case MP_CMD_SET_PROPERTY_OSD
:
2736 case_fallthrough_hack
= 1;
2738 case MP_CMD_SET_PROPERTY
:{
2739 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2740 cmd
->args
[1].v
.s
, mpctx
);
2741 if (r
== M_PROPERTY_UNKNOWN
)
2742 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2743 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2745 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2746 "Failed to set property '%s' to '%s'.\n",
2747 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2748 else if (case_fallthrough_hack
)
2749 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2751 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2755 case MP_CMD_STEP_PROPERTY_OSD
:
2756 case_fallthrough_hack
= 1;
2758 case MP_CMD_STEP_PROPERTY
:{
2763 if (cmd
->args
[1].v
.f
) {
2765 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2766 M_PROPERTY_GET_TYPE
,
2767 &prop
, mpctx
)) <= 0)
2769 if(prop
->type
== CONF_TYPE_INT
||
2770 prop
->type
== CONF_TYPE_FLAG
)
2771 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2772 else if(prop
->type
== CONF_TYPE_FLOAT
)
2773 arg
= &cmd
->args
[1].v
.f
;
2774 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2775 prop
->type
== CONF_TYPE_TIME
)
2776 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2777 else if(prop
->type
== CONF_TYPE_POSITION
)
2778 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2780 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2781 "Ignoring step size stepping property '%s'.\n",
2784 r
= mp_property_do(cmd
->args
[0].v
.s
,
2785 cmd
->args
[2].v
.i
< 0 ?
2786 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2789 if (r
== M_PROPERTY_UNKNOWN
)
2790 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2791 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2793 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2794 "Failed to increment property '%s' by %f.\n",
2795 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2796 else if (case_fallthrough_hack
)
2797 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2799 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2803 case MP_CMD_GET_PROPERTY
:{
2805 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2808 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2809 "Failed to get value of property '%s'.\n",
2811 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2814 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2815 cmd
->args
[0].v
.s
, tmp
);
2820 case MP_CMD_EDL_MARK
:
2822 float v
= get_current_time(mpctx
);
2823 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2824 mpctx
->begin_skip
= v
;
2825 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2827 if (mpctx
->begin_skip
> v
)
2828 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2830 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2831 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2833 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2838 case MP_CMD_SWITCH_RATIO
:
2841 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2842 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2844 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2845 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2848 case MP_CMD_SPEED_INCR
:{
2849 float v
= cmd
->args
[0].v
.f
;
2850 opts
->playback_speed
+= v
;
2851 reinit_audio_chain(mpctx
);
2852 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2853 opts
->playback_speed
);
2856 case MP_CMD_SPEED_MULT
:{
2857 float v
= cmd
->args
[0].v
.f
;
2858 opts
->playback_speed
*= v
;
2859 reinit_audio_chain(mpctx
);
2860 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2861 opts
->playback_speed
);
2864 case MP_CMD_SPEED_SET
:{
2865 float v
= cmd
->args
[0].v
.f
;
2866 opts
->playback_speed
= v
;
2867 reinit_audio_chain(mpctx
);
2868 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2869 opts
->playback_speed
);
2872 case MP_CMD_FRAME_STEP
:
2873 add_step_frame(mpctx
);
2876 case MP_CMD_FILE_FILTER
:
2877 file_filter
= cmd
->args
[0].v
.i
;
2881 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2882 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2884 case MP_CMD_PLAY_TREE_STEP
:{
2885 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2886 int force
= cmd
->args
[1].v
.i
;
2889 if (!force
&& mpctx
->playtree_iter
) {
2890 play_tree_iter_t
*i
=
2891 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2892 if (play_tree_iter_step(i
, n
, 0) ==
2893 PLAY_TREE_ITER_ENTRY
)
2895 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2896 play_tree_iter_free(i
);
2898 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2899 if (mpctx
->stop_play
)
2900 mpctx
->play_tree_step
= n
;
2905 case MP_CMD_PLAY_TREE_UP_STEP
:{
2906 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2907 int force
= cmd
->args
[1].v
.i
;
2909 if (!force
&& mpctx
->playtree_iter
) {
2910 play_tree_iter_t
*i
=
2911 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2912 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2913 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2914 play_tree_iter_free(i
);
2916 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2920 case MP_CMD_PLAY_ALT_SRC_STEP
:
2921 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2922 int v
= cmd
->args
[0].v
.i
;
2924 && mpctx
->playtree_iter
->file
<
2925 mpctx
->playtree_iter
->num_files
)
2926 mpctx
->stop_play
= PT_NEXT_SRC
;
2927 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2928 mpctx
->stop_play
= PT_PREV_SRC
;
2932 case MP_CMD_SUB_STEP
:
2934 int movement
= cmd
->args
[0].v
.i
;
2935 step_sub(mpctx
->subdata
, mpctx
->video_pts
, movement
);
2939 ass_step_sub(ass_track
,
2941 sub_delay
) * 1000 + .5, movement
) / 1000.;
2943 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2944 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2948 case MP_CMD_SUB_LOG
:
2953 int v
= cmd
->args
[0].v
.i
;
2954 int max
= (opts
->term_osd
2955 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2956 if (opts
->osd_level
> max
)
2957 opts
->osd_level
= max
;
2959 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2961 opts
->osd_level
= v
> max
? max
: v
;
2962 /* Show OSD state when disabled, but not when an explicit
2963 argument is given to the OSD command, i.e. in slave mode. */
2964 if (v
== -1 && opts
->osd_level
<= 1)
2965 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2967 opts
->osd_level
? mp_gtext("enabled") :
2968 mp_gtext("disabled"));
2970 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2974 case MP_CMD_OSD_SHOW_TEXT
:
2975 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2977 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2978 "%-.63s", cmd
->args
[0].v
.s
);
2981 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2982 char *txt
= m_properties_expand_string(mp_properties
,
2985 /* if no argument supplied take default osd_duration, else <arg> ms. */
2987 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2989 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2996 case MP_CMD_LOADFILE
:{
2997 play_tree_t
*e
= play_tree_new();
2998 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
3000 if (cmd
->args
[1].v
.i
) // append
3001 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3003 // Go back to the starting point.
3004 while (play_tree_iter_up_step
3005 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3007 play_tree_free_list(mpctx
->playtree
->child
, 1);
3008 play_tree_set_child(mpctx
->playtree
, e
);
3009 pt_iter_goto_head(mpctx
->playtree_iter
);
3010 mpctx
->stop_play
= PT_NEXT_SRC
;
3015 case MP_CMD_LOADLIST
:{
3016 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
3018 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
3019 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
3021 if (cmd
->args
[1].v
.i
) // append
3022 play_tree_append_entry(mpctx
->playtree
->child
, e
);
3024 // Go back to the starting point.
3025 while (play_tree_iter_up_step
3026 (mpctx
->playtree_iter
, 0, 1)
3027 != PLAY_TREE_ITER_END
)
3029 play_tree_free_list(mpctx
->playtree
->child
, 1);
3030 play_tree_set_child(mpctx
->playtree
, e
);
3031 pt_iter_goto_head(mpctx
->playtree_iter
);
3032 mpctx
->stop_play
= PT_NEXT_SRC
;
3039 // Go back to the starting point.
3040 while (play_tree_iter_up_step
3041 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3043 mpctx
->stop_play
= PT_STOP
;
3046 case MP_CMD_OSD_SHOW_PROGRESSION
:{
3047 int len
= get_time_length(mpctx
);
3048 int pts
= get_current_time(mpctx
);
3049 set_osd_bar(mpctx
, 0, "Position", 0, 100, get_percent_pos(mpctx
));
3050 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3051 "%c %02d:%02d:%02d / %02d:%02d:%02d",
3052 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
3053 len
/3600, (len
/60)%60, len
%60);
3058 case MP_CMD_RADIO_STEP_CHANNEL
:
3059 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3060 int v
= cmd
->args
[0].v
.i
;
3062 radio_step_channel(mpctx
->demuxer
->stream
,
3063 RADIO_CHANNEL_HIGHER
);
3065 radio_step_channel(mpctx
->demuxer
->stream
,
3066 RADIO_CHANNEL_LOWER
);
3067 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3068 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3070 radio_get_channel_name(mpctx
->demuxer
->stream
));
3075 case MP_CMD_RADIO_SET_CHANNEL
:
3076 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3077 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3078 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3079 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3081 radio_get_channel_name(mpctx
->demuxer
->stream
));
3086 case MP_CMD_RADIO_SET_FREQ
:
3087 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3088 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3091 case MP_CMD_RADIO_STEP_FREQ
:
3092 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3093 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3098 case MP_CMD_TV_START_SCAN
:
3099 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3100 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3102 case MP_CMD_TV_SET_FREQ
:
3103 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3104 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3105 cmd
->args
[0].v
.f
* 16.0);
3107 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3108 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3109 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3110 pvr_get_current_channelname (mpctx
->stream
),
3111 pvr_get_current_stationname (mpctx
->stream
));
3113 #endif /* CONFIG_PVR */
3116 case MP_CMD_TV_STEP_FREQ
:
3117 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3118 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3119 cmd
->args
[0].v
.f
* 16.0);
3121 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3122 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3123 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3124 pvr_get_current_channelname (mpctx
->stream
),
3125 pvr_get_current_frequency (mpctx
->stream
));
3127 #endif /* CONFIG_PVR */
3130 case MP_CMD_TV_SET_NORM
:
3131 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3132 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3136 case MP_CMD_TV_STEP_CHANNEL
:{
3137 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3138 int v
= cmd
->args
[0].v
.i
;
3140 tv_step_channel((tvi_handle_t
*) (mpctx
->
3144 tv_step_channel((tvi_handle_t
*) (mpctx
->
3148 if (tv_channel_list
) {
3149 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3150 "Channel: %s", tv_channel_current
->name
);
3151 //vo_osd_changed(OSDTYPE_SUBTITLE);
3155 else if (mpctx
->stream
&&
3156 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3157 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3158 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3159 pvr_get_current_channelname (mpctx
->stream
),
3160 pvr_get_current_stationname (mpctx
->stream
));
3162 #endif /* CONFIG_PVR */
3165 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3167 int v
= cmd
->args
[0].v
.i
;
3169 mpctx
->last_dvb_step
= v
;
3171 dir
= DVB_CHANNEL_HIGHER
;
3173 dir
= DVB_CHANNEL_LOWER
;
3176 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3177 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3178 mpctx
->dvbin_reopen
= 1;
3181 #endif /* CONFIG_DVBIN */
3184 case MP_CMD_TV_SET_CHANNEL
:
3185 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3186 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3188 if (tv_channel_list
) {
3189 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3190 "Channel: %s", tv_channel_current
->name
);
3191 //vo_osd_changed(OSDTYPE_SUBTITLE);
3195 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3196 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3197 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3198 pvr_get_current_channelname (mpctx
->stream
),
3199 pvr_get_current_stationname (mpctx
->stream
));
3201 #endif /* CONFIG_PVR */
3205 case MP_CMD_DVB_SET_CHANNEL
:
3206 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3207 mpctx
->last_dvb_step
= 1;
3209 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3210 cmd
->args
[0].v
.i
)) {
3211 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3212 mpctx
->dvbin_reopen
= 1;
3216 #endif /* CONFIG_DVBIN */
3218 case MP_CMD_TV_LAST_CHANNEL
:
3219 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3220 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3221 if (tv_channel_list
) {
3222 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3223 "Channel: %s", tv_channel_current
->name
);
3224 //vo_osd_changed(OSDTYPE_SUBTITLE);
3228 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3229 pvr_set_lastchannel (mpctx
->stream
);
3230 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3231 pvr_get_current_channelname (mpctx
->stream
),
3232 pvr_get_current_stationname (mpctx
->stream
));
3234 #endif /* CONFIG_PVR */
3237 case MP_CMD_TV_STEP_NORM
:
3238 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3239 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3242 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3243 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3244 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3246 #endif /* CONFIG_TV */
3247 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3248 if (mpctx
->demuxer
->teletext
)
3249 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3250 &(cmd
->args
[0].v
.s
));
3252 case MP_CMD_TV_TELETEXT_GO_LINK
:
3253 if (mpctx
->demuxer
->teletext
)
3254 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3255 &(cmd
->args
[0].v
.i
));
3258 case MP_CMD_SUB_LOAD
:
3260 int n
= mpctx
->set_of_sub_size
;
3261 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3262 if (n
!= mpctx
->set_of_sub_size
) {
3263 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3264 ++mpctx
->global_sub_size
;
3269 case MP_CMD_SUB_REMOVE
:
3271 int v
= cmd
->args
[0].v
.i
;
3273 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3274 } else if (v
< mpctx
->set_of_sub_size
) {
3275 remove_subtitle_range(mpctx
, v
, 1);
3280 case MP_CMD_GET_SUB_VISIBILITY
:
3282 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3283 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3287 case MP_CMD_SCREENSHOT
:
3288 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3289 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3291 ((vf_instance_t
*) sh_video
->vfilter
)->
3292 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3294 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3298 case MP_CMD_VF_CHANGE_RECTANGLE
:
3301 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3304 case MP_CMD_GET_TIME_LENGTH
:{
3305 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3306 get_time_length(mpctx
));
3310 case MP_CMD_GET_FILENAME
:{
3311 char *inf
= get_metadata(mpctx
, META_NAME
);
3312 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n", inf
);
3317 case MP_CMD_GET_VIDEO_CODEC
:{
3318 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3319 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3324 case MP_CMD_GET_VIDEO_BITRATE
:{
3325 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3326 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3331 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3332 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3333 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3338 case MP_CMD_GET_AUDIO_CODEC
:{
3339 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3340 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3345 case MP_CMD_GET_AUDIO_BITRATE
:{
3346 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3347 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3352 case MP_CMD_GET_AUDIO_SAMPLES
:{
3353 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3354 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3359 case MP_CMD_GET_META_TITLE
:{
3360 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3361 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3366 case MP_CMD_GET_META_ARTIST
:{
3367 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3368 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3373 case MP_CMD_GET_META_ALBUM
:{
3374 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3375 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3380 case MP_CMD_GET_META_YEAR
:{
3381 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3382 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3387 case MP_CMD_GET_META_COMMENT
:{
3388 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3389 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3394 case MP_CMD_GET_META_TRACK
:{
3395 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3396 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3401 case MP_CMD_GET_META_GENRE
:{
3402 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3403 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3408 case MP_CMD_GET_VO_FULLSCREEN
:
3409 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3410 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3413 case MP_CMD_GET_PERCENT_POS
:
3414 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3415 get_percent_pos(mpctx
));
3418 case MP_CMD_GET_TIME_POS
:{
3419 float pos
= get_current_time(mpctx
);
3420 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3427 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3433 case MP_CMD_KEYDOWN_EVENTS
:
3434 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3437 case MP_CMD_SET_MOUSE_POS
:{
3438 int pointer_x
, pointer_y
;
3440 pointer_x
= cmd
->args
[0].v
.i
;
3441 pointer_y
= cmd
->args
[1].v
.i
;
3442 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3443 #ifdef CONFIG_DVDNAV
3444 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3445 && dx
> 0.0 && dy
> 0.0) {
3447 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3448 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3449 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3450 pointer_x
, pointer_y
, &button
);
3451 if (opts
->osd_level
> 1 && button
> 0)
3452 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3453 "Selected button number %d", button
);
3457 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3458 menu_update_mouse_pos(dx
, dy
);
3463 #ifdef CONFIG_DVDNAV
3464 case MP_CMD_DVDNAV
:{
3467 mp_command_type command
= 0;
3468 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3471 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3472 if (cmd
->args
[0].v
.s
&&
3473 !strcasecmp (cmd
->args
[0].v
.s
,
3474 mp_dvdnav_bindings
[i
].name
))
3475 command
= mp_dvdnav_bindings
[i
].cmd
;
3477 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3478 if (opts
->osd_level
> 1 && button
> 0)
3479 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3480 "Selected button number %d", button
);
3484 case MP_CMD_SWITCH_TITLE
:
3485 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3486 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3491 case MP_CMD_AF_SWITCH
:
3494 af_uninit(mpctx
->mixer
.afilter
);
3495 af_init(mpctx
->mixer
.afilter
);
3502 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3503 char* af_commands
= af_args
;
3506 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3508 if (cmd
->id
== MP_CMD_AF_DEL
)
3510 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3512 af_remove(mpctx
->mixer
.afilter
, af
);
3515 af_add(mpctx
->mixer
.afilter
, af_command
);
3517 reinit_audio_chain(mpctx
);
3524 af_uninit(mpctx
->mixer
.afilter
);
3525 af_init(mpctx
->mixer
.afilter
);
3526 reinit_audio_chain(mpctx
);
3528 case MP_CMD_AF_CMDLINE
:
3530 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3532 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3533 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3536 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3537 af_reinit(sh_audio
->afilter
, af
);
3542 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3543 "Received unknown cmd %s\n", cmd
->name
);
3546 switch (cmd
->pausing
) {
3547 case 1: // "pausing"
3548 pause_player(mpctx
);
3550 case 3: // "pausing_toggle"
3552 unpause_player(mpctx
);
3554 pause_player(mpctx
);