2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "input/input.h"
29 #include "stream/stream.h"
30 #include "libmpdemux/demuxer.h"
31 #include "libmpdemux/stheader.h"
32 #include "codec-cfg.h"
34 #include "libvo/sub.h"
36 #include "m_property.h"
38 #include "libmpcodecs/vf.h"
39 #include "libmpcodecs/vd.h"
41 #include "libvo/video_out.h"
42 #include "libvo/font_load.h"
44 #include "libao2/audio_out.h"
47 #include "libmpcodecs/dec_video.h"
48 #include "libmpcodecs/dec_audio.h"
49 #include "libmpcodecs/dec_teletext.h"
54 #include "stream/tv.h"
55 #include "stream/stream_radio.h"
56 #include "stream/pvr.h"
58 #include "stream/dvbin.h"
61 #include "stream/stream_dvd.h"
63 #include "stream/stream_dvdnav.h"
65 #include "libmenu/menu.h"
69 #include "libavutil/avstring.h"
71 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
75 static void rescale_input_coordinates(struct MPContext
*mpctx
, int ix
, int iy
,
76 double *dx
, double *dy
)
78 struct MPOpts
*opts
= &mpctx
->opts
;
79 struct vo
*vo
= mpctx
->video_out
;
80 //remove the borders, if any, and rescale to the range [0,1],[0,1]
81 if (vo_fs
) { //we are in full-screen mode
82 if (opts
->vo_screenwidth
> vo
->dwidth
) //there are borders along the x axis
83 ix
-= (opts
->vo_screenwidth
- vo
->dwidth
) / 2;
84 if (opts
->vo_screenheight
> vo
->dheight
) //there are borders along the y axis (usual way)
85 iy
-= (opts
->vo_screenheight
- vo
->dheight
) / 2;
87 if (ix
< 0 || ix
> vo
->dwidth
) {
90 } //we are on one of the borders
91 if (iy
< 0 || iy
> vo
->dheight
) {
94 } //we are on one of the borders
97 *dx
= (double) ix
/ (double) vo
->dwidth
;
98 *dy
= (double) iy
/ (double) vo
->dheight
;
100 mp_msg(MSGT_CPLAYER
, MSGL_V
,
101 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
102 *dx
, *dy
, opts
->vo_screenwidth
, opts
->vo_screenheight
, vo
->dwidth
,
106 static int sub_pos_by_source(MPContext
*mpctx
, int src
)
109 if (src
>= SUB_SOURCES
|| mpctx
->sub_counts
[src
] == 0)
111 for (i
= 0; i
< src
; i
++)
112 cnt
+= mpctx
->sub_counts
[i
];
116 static int sub_source_and_index_by_pos(MPContext
*mpctx
, int *pos
)
120 for (i
= 0; i
< SUB_SOURCES
; i
++) {
121 int cnt
= mpctx
->sub_counts
[i
];
122 if (*pos
>= start
&& *pos
< start
+ cnt
) {
132 static int sub_source_by_pos(MPContext
*mpctx
, int pos
)
134 return sub_source_and_index_by_pos(mpctx
, &pos
);
137 static int sub_source_pos(MPContext
*mpctx
)
139 int pos
= mpctx
->global_sub_pos
;
140 sub_source_and_index_by_pos(mpctx
, &pos
);
144 static int sub_source(MPContext
*mpctx
)
146 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
149 static void update_global_sub_size(MPContext
*mpctx
)
151 struct MPOpts
*opts
= &mpctx
->opts
;
155 // update number of demuxer sub streams
156 for (i
= 0; i
< MAX_S_STREAMS
; i
++)
157 if (mpctx
->demuxer
->s_streams
[i
])
159 if (cnt
> mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
160 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
] = cnt
;
162 // update global size
163 mpctx
->global_sub_size
= 0;
164 for (i
= 0; i
< SUB_SOURCES
; i
++)
165 mpctx
->global_sub_size
+= mpctx
->sub_counts
[i
];
167 // update global_sub_pos if we auto-detected a demuxer sub
168 if (mpctx
->global_sub_pos
== -1) {
170 if (mpctx
->demuxer
->sub
)
171 sub_id
= mpctx
->demuxer
->sub
->id
;
173 sub_id
= opts
->sub_id
;
174 if (sub_id
>= 0 && sub_id
< mpctx
->sub_counts
[SUB_SOURCE_DEMUX
])
175 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, SUB_SOURCE_DEMUX
) +
181 * \brief Log the currently displayed subtitle to a file
183 * Logs the current or last displayed subtitle together with filename
184 * and time information to ~/.mplayer/subtitle_log
186 * Intended purpose is to allow convenient marking of bogus subtitles
187 * which need to be fixed while watching the movie.
190 static void log_sub(struct MPContext
*mpctx
)
196 if (subdata
== NULL
|| vo_sub_last
== NULL
)
198 fname
= get_path("subtitle_log");
199 f
= fopen(fname
, "a");
202 fprintf(f
, "----------------------------------------------------------\n");
203 if (subdata
->sub_uses_time
) {
205 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
206 mpctx
->filename
, vo_sub_last
->start
/ 360000,
207 (vo_sub_last
->start
/ 6000) % 60,
208 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
209 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
210 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
212 fprintf(f
, "N: %s S: %ld E: %ld\n", mpctx
->filename
,
213 vo_sub_last
->start
, vo_sub_last
->end
);
215 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
216 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
222 /// \defgroup Properties
225 /// \defgroup GeneralProperties General properties
226 /// \ingroup Properties
230 static int mp_property_osdlevel(m_option_t
*prop
, int action
, void *arg
,
233 return m_property_choice(prop
, action
, arg
, &mpctx
->opts
.osd_level
);
237 static int mp_property_loop(m_option_t
*prop
, int action
, void *arg
,
240 struct MPOpts
*opts
= &mpctx
->opts
;
242 case M_PROPERTY_PRINT
:
243 if (!arg
) return M_PROPERTY_ERROR
;
244 if (opts
->loop_times
< 0)
245 *(char**)arg
= strdup("off");
246 else if (opts
->loop_times
== 0)
247 *(char**)arg
= strdup("inf");
250 return M_PROPERTY_OK
;
252 return m_property_int_range(prop
, action
, arg
, &opts
->loop_times
);
255 /// Playback speed (RW)
256 static int mp_property_playback_speed(m_option_t
*prop
, int action
,
257 void *arg
, MPContext
*mpctx
)
259 struct MPOpts
*opts
= &mpctx
->opts
;
263 return M_PROPERTY_ERROR
;
264 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
265 opts
->playback_speed
= *(float *) arg
;
266 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
267 return M_PROPERTY_OK
;
268 case M_PROPERTY_STEP_UP
:
269 case M_PROPERTY_STEP_DOWN
:
270 opts
->playback_speed
+= (arg
? *(float *) arg
: 0.1) *
271 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
272 M_PROPERTY_CLAMP(prop
, opts
->playback_speed
);
273 build_afilter_chain(mpctx
, mpctx
->sh_audio
, &ao_data
);
274 return M_PROPERTY_OK
;
276 return m_property_float_range(prop
, action
, arg
, &opts
->playback_speed
);
279 /// filename with path (RO)
280 static int mp_property_path(m_option_t
*prop
, int action
, void *arg
,
283 return m_property_string_ro(prop
, action
, arg
, mpctx
->filename
);
286 /// filename without path (RO)
287 static int mp_property_filename(m_option_t
*prop
, int action
, void *arg
,
291 if (!mpctx
->filename
)
292 return M_PROPERTY_UNAVAILABLE
;
293 if (((f
= strrchr(mpctx
->filename
, '/'))
294 || (f
= strrchr(mpctx
->filename
, '\\'))) && f
[1])
298 return m_property_string_ro(prop
, action
, arg
, f
);
301 /// Demuxer name (RO)
302 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
306 return M_PROPERTY_UNAVAILABLE
;
307 return m_property_string_ro(prop
, action
, arg
,
308 (char *) mpctx
->demuxer
->desc
->name
);
311 /// Position in the stream (RW)
312 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
315 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
316 return M_PROPERTY_UNAVAILABLE
;
318 return M_PROPERTY_ERROR
;
321 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
322 return M_PROPERTY_OK
;
324 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
325 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
326 return M_PROPERTY_OK
;
328 return M_PROPERTY_NOT_IMPLEMENTED
;
331 /// Stream start offset (RO)
332 static int mp_property_stream_start(m_option_t
*prop
, int action
,
333 void *arg
, MPContext
*mpctx
)
335 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
336 return M_PROPERTY_UNAVAILABLE
;
339 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
340 return M_PROPERTY_OK
;
342 return M_PROPERTY_NOT_IMPLEMENTED
;
345 /// Stream end offset (RO)
346 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
349 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
350 return M_PROPERTY_UNAVAILABLE
;
353 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
354 return M_PROPERTY_OK
;
356 return M_PROPERTY_NOT_IMPLEMENTED
;
359 /// Stream length (RO)
360 static int mp_property_stream_length(m_option_t
*prop
, int action
,
361 void *arg
, MPContext
*mpctx
)
363 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
364 return M_PROPERTY_UNAVAILABLE
;
368 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
369 return M_PROPERTY_OK
;
371 return M_PROPERTY_NOT_IMPLEMENTED
;
374 /// Current stream position in seconds (RO)
375 static int mp_property_stream_time_pos(m_option_t
*prop
, int action
,
376 void *arg
, MPContext
*mpctx
)
378 if (!mpctx
->demuxer
|| mpctx
->demuxer
->stream_pts
== MP_NOPTS_VALUE
)
379 return M_PROPERTY_UNAVAILABLE
;
381 return m_property_time_ro(prop
, action
, arg
, mpctx
->demuxer
->stream_pts
);
385 /// Media length in seconds (RO)
386 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
391 if (!mpctx
->demuxer
||
392 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
393 return M_PROPERTY_UNAVAILABLE
;
395 return m_property_time_ro(prop
, action
, arg
, len
);
398 /// Current position in percent (RW)
399 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
400 void *arg
, MPContext
*mpctx
) {
404 return M_PROPERTY_UNAVAILABLE
;
408 if(!arg
) return M_PROPERTY_ERROR
;
409 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
412 case M_PROPERTY_STEP_UP
:
413 case M_PROPERTY_STEP_DOWN
:
414 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
415 pos
+= (arg
? *(int*)arg
: 10) *
416 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
417 M_PROPERTY_CLAMP(prop
, pos
);
420 return m_property_int_ro(prop
, action
, arg
,
421 demuxer_get_percent_pos(mpctx
->demuxer
));
424 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
425 mpctx
->rel_seek_secs
= pos
/ 100.0;
426 return M_PROPERTY_OK
;
429 /// Current position in seconds (RW)
430 static int mp_property_time_pos(m_option_t
*prop
, int action
,
431 void *arg
, MPContext
*mpctx
) {
432 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
433 return M_PROPERTY_UNAVAILABLE
;
437 if(!arg
) return M_PROPERTY_ERROR
;
438 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
439 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
440 mpctx
->rel_seek_secs
= *(double*)arg
;
441 return M_PROPERTY_OK
;
442 case M_PROPERTY_STEP_UP
:
443 case M_PROPERTY_STEP_DOWN
:
444 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
445 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
446 return M_PROPERTY_OK
;
448 return m_property_time_ro(prop
, action
, arg
,
449 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
450 playing_audio_pts(mpctx
));
453 /// Current chapter (RW)
454 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
457 struct MPOpts
*opts
= &mpctx
->opts
;
460 char *chapter_name
= NULL
;
463 chapter
= get_current_chapter(mpctx
);
465 return M_PROPERTY_UNAVAILABLE
;
470 return M_PROPERTY_ERROR
;
471 *(int *) arg
= chapter
;
472 return M_PROPERTY_OK
;
473 case M_PROPERTY_PRINT
: {
475 return M_PROPERTY_ERROR
;
476 chapter_name
= chapter_display_name(mpctx
, chapter
);
478 return M_PROPERTY_UNAVAILABLE
;
479 *(char **) arg
= chapter_name
;
480 return M_PROPERTY_OK
;
484 return M_PROPERTY_ERROR
;
485 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
486 step_all
= *(int *)arg
- chapter
;
489 case M_PROPERTY_STEP_UP
:
490 case M_PROPERTY_STEP_DOWN
: {
491 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
492 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
499 return M_PROPERTY_NOT_IMPLEMENTED
;
503 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
504 mpctx
->rel_seek_secs
= 0;
505 mpctx
->abs_seek_pos
= 0;
507 if (next_pts
> -1.0) {
508 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
509 mpctx
->rel_seek_secs
= next_pts
;
512 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
513 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
515 else if (step_all
> 0)
516 mpctx
->rel_seek_secs
= 1000000000.;
518 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
519 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
521 talloc_free(chapter_name
);
522 return M_PROPERTY_OK
;
525 /// Number of chapters in file
526 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
530 return M_PROPERTY_UNAVAILABLE
;
531 if (mpctx
->demuxer
->num_chapters
== 0)
532 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
533 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
536 /// Current dvd angle (RW)
537 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
540 struct MPOpts
*opts
= &mpctx
->opts
;
543 char *angle_name
= NULL
;
546 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
548 return M_PROPERTY_UNAVAILABLE
;
549 angles
= demuxer_angles_count(mpctx
->demuxer
);
551 return M_PROPERTY_UNAVAILABLE
;
556 return M_PROPERTY_ERROR
;
557 *(int *) arg
= angle
;
558 return M_PROPERTY_OK
;
559 case M_PROPERTY_PRINT
: {
561 return M_PROPERTY_ERROR
;
562 angle_name
= calloc(1, 64);
564 return M_PROPERTY_UNAVAILABLE
;
565 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
566 *(char **) arg
= angle_name
;
567 return M_PROPERTY_OK
;
571 return M_PROPERTY_ERROR
;
573 M_PROPERTY_CLAMP(prop
, angle
);
575 case M_PROPERTY_STEP_UP
:
576 case M_PROPERTY_STEP_DOWN
: {
582 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
584 if (angle
< 1) //cycle
589 return M_PROPERTY_NOT_IMPLEMENTED
;
591 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
593 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
595 resync_video_stream(sh_video
);
597 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
599 resync_audio_stream(sh_audio
);
602 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
603 "Angle: %d/%d", angle
, angles
);
606 return M_PROPERTY_OK
;
609 /// Demuxer meta data
610 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
612 m_property_action_t
* ka
;
614 static const m_option_t key_type
=
615 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
617 return M_PROPERTY_UNAVAILABLE
;
621 if(!arg
) return M_PROPERTY_ERROR
;
622 *(char***)arg
= mpctx
->demuxer
->info
;
623 return M_PROPERTY_OK
;
624 case M_PROPERTY_KEY_ACTION
:
625 if(!arg
) return M_PROPERTY_ERROR
;
627 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
628 return M_PROPERTY_UNKNOWN
;
631 if(!ka
->arg
) return M_PROPERTY_ERROR
;
632 *(char**)ka
->arg
= meta
;
633 return M_PROPERTY_OK
;
634 case M_PROPERTY_GET_TYPE
:
635 if(!ka
->arg
) return M_PROPERTY_ERROR
;
636 *(m_option_t
**)ka
->arg
= &key_type
;
637 return M_PROPERTY_OK
;
640 return M_PROPERTY_NOT_IMPLEMENTED
;
643 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
646 MPContext
*mpctx
= ctx
;
651 return M_PROPERTY_ERROR
;
652 if (mpctx
->paused
== (bool)*(int *) arg
)
653 return M_PROPERTY_OK
;
654 case M_PROPERTY_STEP_UP
:
655 case M_PROPERTY_STEP_DOWN
:
657 unpause_player(mpctx
);
658 mpctx
->osd_function
= OSD_PLAY
;
662 mpctx
->osd_function
= OSD_PAUSE
;
664 return M_PROPERTY_OK
;
666 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
673 /// \defgroup AudioProperties Audio properties
674 /// \ingroup Properties
678 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
682 if (!mpctx
->sh_audio
)
683 return M_PROPERTY_UNAVAILABLE
;
688 return M_PROPERTY_ERROR
;
689 mixer_getbothvolume(&mpctx
->mixer
, arg
);
690 return M_PROPERTY_OK
;
691 case M_PROPERTY_PRINT
:{
694 return M_PROPERTY_ERROR
;
695 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
696 return m_property_float_range(prop
, action
, arg
, &vol
);
698 case M_PROPERTY_STEP_UP
:
699 case M_PROPERTY_STEP_DOWN
:
703 return M_PROPERTY_NOT_IMPLEMENTED
;
706 if (mpctx
->edl_muted
)
707 return M_PROPERTY_DISABLED
;
708 mpctx
->user_muted
= 0;
713 return M_PROPERTY_ERROR
;
714 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
715 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
716 return M_PROPERTY_OK
;
717 case M_PROPERTY_STEP_UP
:
718 if (arg
&& *(float *) arg
<= 0)
719 mixer_decvolume(&mpctx
->mixer
);
721 mixer_incvolume(&mpctx
->mixer
);
722 return M_PROPERTY_OK
;
723 case M_PROPERTY_STEP_DOWN
:
724 if (arg
&& *(float *) arg
<= 0)
725 mixer_incvolume(&mpctx
->mixer
);
727 mixer_decvolume(&mpctx
->mixer
);
728 return M_PROPERTY_OK
;
730 return M_PROPERTY_NOT_IMPLEMENTED
;
734 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
738 if (!mpctx
->sh_audio
)
739 return M_PROPERTY_UNAVAILABLE
;
743 if (mpctx
->edl_muted
)
744 return M_PROPERTY_DISABLED
;
746 return M_PROPERTY_ERROR
;
747 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
748 mixer_mute(&mpctx
->mixer
);
749 mpctx
->user_muted
= mpctx
->mixer
.muted
;
750 return M_PROPERTY_OK
;
751 case M_PROPERTY_STEP_UP
:
752 case M_PROPERTY_STEP_DOWN
:
753 if (mpctx
->edl_muted
)
754 return M_PROPERTY_DISABLED
;
755 mixer_mute(&mpctx
->mixer
);
756 mpctx
->user_muted
= mpctx
->mixer
.muted
;
757 return M_PROPERTY_OK
;
758 case M_PROPERTY_PRINT
:
760 return M_PROPERTY_ERROR
;
761 if (mpctx
->edl_muted
) {
762 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
763 return M_PROPERTY_OK
;
766 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
772 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
773 void *arg
, MPContext
*mpctx
)
775 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
776 return M_PROPERTY_UNAVAILABLE
;
779 case M_PROPERTY_STEP_UP
:
780 case M_PROPERTY_STEP_DOWN
: {
782 float delay
= audio_delay
;
783 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
784 if (ret
!= M_PROPERTY_OK
)
787 mpctx
->delay
-= audio_delay
- delay
;
789 return M_PROPERTY_OK
;
791 return m_property_delay(prop
, action
, arg
, &audio_delay
);
795 /// Audio codec tag (RO)
796 static int mp_property_audio_format(m_option_t
*prop
, int action
,
797 void *arg
, MPContext
*mpctx
)
799 if (!mpctx
->sh_audio
)
800 return M_PROPERTY_UNAVAILABLE
;
801 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
804 /// Audio codec name (RO)
805 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
806 void *arg
, MPContext
*mpctx
)
808 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
809 return M_PROPERTY_UNAVAILABLE
;
810 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
813 /// Audio bitrate (RO)
814 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
815 void *arg
, MPContext
*mpctx
)
817 if (!mpctx
->sh_audio
)
818 return M_PROPERTY_UNAVAILABLE
;
819 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
823 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
826 if (!mpctx
->sh_audio
)
827 return M_PROPERTY_UNAVAILABLE
;
829 case M_PROPERTY_PRINT
:
830 if(!arg
) return M_PROPERTY_ERROR
;
831 *(char**)arg
= malloc(16);
832 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
833 return M_PROPERTY_OK
;
835 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
838 /// Number of channels (RO)
839 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
842 if (!mpctx
->sh_audio
)
843 return M_PROPERTY_UNAVAILABLE
;
845 case M_PROPERTY_PRINT
:
847 return M_PROPERTY_ERROR
;
848 switch (mpctx
->sh_audio
->channels
) {
850 *(char **) arg
= strdup("mono");
853 *(char **) arg
= strdup("stereo");
856 *(char **) arg
= malloc(32);
857 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
859 return M_PROPERTY_OK
;
861 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
865 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
870 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
871 return M_PROPERTY_UNAVAILABLE
;
876 return M_PROPERTY_ERROR
;
877 mixer_getbalance(&mpctx
->mixer
, arg
);
878 return M_PROPERTY_OK
;
879 case M_PROPERTY_PRINT
: {
882 return M_PROPERTY_ERROR
;
883 mixer_getbalance(&mpctx
->mixer
, &bal
);
885 *str
= strdup("center");
886 else if (bal
== -1.f
)
887 *str
= strdup("left only");
889 *str
= strdup("right only");
891 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
892 *str
= malloc(sizeof("left xxx%, right xxx%"));
893 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
895 return M_PROPERTY_OK
;
897 case M_PROPERTY_STEP_UP
:
898 case M_PROPERTY_STEP_DOWN
:
899 mixer_getbalance(&mpctx
->mixer
, &bal
);
900 bal
+= (arg
? *(float*)arg
: .1f
) *
901 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
902 M_PROPERTY_CLAMP(prop
, bal
);
903 mixer_setbalance(&mpctx
->mixer
, bal
);
904 return M_PROPERTY_OK
;
907 return M_PROPERTY_ERROR
;
908 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
909 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
910 return M_PROPERTY_OK
;
912 return M_PROPERTY_NOT_IMPLEMENTED
;
915 /// Selected audio id (RW)
916 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
920 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
921 return M_PROPERTY_UNAVAILABLE
;
922 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
927 return M_PROPERTY_ERROR
;
928 *(int *) arg
= current_id
;
929 return M_PROPERTY_OK
;
930 case M_PROPERTY_PRINT
:
932 return M_PROPERTY_ERROR
;
935 *(char **) arg
= strdup(mp_gtext("disabled"));
938 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
939 sh_audio_t
* sh
= mpctx
->sh_audio
;
941 av_strlcpy(lang
, sh
->lang
, 40);
942 #ifdef CONFIG_DVDREAD
943 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
944 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
954 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
955 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
957 *(char **) arg
= malloc(64);
958 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
960 return M_PROPERTY_OK
;
962 case M_PROPERTY_STEP_UP
:
964 if (action
== M_PROPERTY_SET
&& arg
)
965 tmp
= *((int *) arg
);
968 int new_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
969 if (new_id
!= current_id
)
970 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
971 if (new_id
!= current_id
&& new_id
>= 0) {
973 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
974 sh2
->ds
= mpctx
->demuxer
->audio
;
975 mpctx
->sh_audio
= sh2
;
976 reinit_audio_chain(mpctx
);
978 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
979 return M_PROPERTY_OK
;
981 return M_PROPERTY_NOT_IMPLEMENTED
;
986 /// Selected video id (RW)
987 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
990 struct MPOpts
*opts
= &mpctx
->opts
;
992 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
993 return M_PROPERTY_UNAVAILABLE
;
994 current_id
= mpctx
->demuxer
->video
->id
;
999 return M_PROPERTY_ERROR
;
1000 *(int *) arg
= current_id
;
1001 return M_PROPERTY_OK
;
1002 case M_PROPERTY_PRINT
:
1004 return M_PROPERTY_ERROR
;
1007 *(char **) arg
= strdup(mp_gtext("disabled"));
1010 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1011 *(char **) arg
= malloc(64);
1012 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1014 return M_PROPERTY_OK
;
1016 case M_PROPERTY_STEP_UP
:
1017 case M_PROPERTY_SET
:
1018 if (action
== M_PROPERTY_SET
&& arg
)
1019 tmp
= *((int *) arg
);
1022 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
1023 if (opts
->video_id
== -2
1024 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
1025 && current_id
!= -2))
1026 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1027 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1028 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
1030 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
1032 sh2
->ds
= mpctx
->demuxer
->video
;
1033 mpctx
->sh_video
= sh2
;
1034 reinit_video_chain(mpctx
);
1037 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1038 return M_PROPERTY_OK
;
1041 return M_PROPERTY_NOT_IMPLEMENTED
;
1045 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1048 demux_program_t prog
;
1051 case M_PROPERTY_STEP_UP
:
1052 case M_PROPERTY_SET
:
1053 if (action
== M_PROPERTY_SET
&& arg
)
1054 prog
.progid
= *((int *) arg
);
1058 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1059 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1060 return M_PROPERTY_ERROR
;
1062 if (prog
.aid
< 0 && prog
.vid
< 0) {
1063 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1064 return M_PROPERTY_ERROR
;
1066 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1067 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1068 return M_PROPERTY_OK
;
1071 return M_PROPERTY_NOT_IMPLEMENTED
;
1077 /// \defgroup VideoProperties Video properties
1078 /// \ingroup Properties
1081 /// Fullscreen state (RW)
1082 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1086 if (!mpctx
->video_out
)
1087 return M_PROPERTY_UNAVAILABLE
;
1090 case M_PROPERTY_SET
:
1092 return M_PROPERTY_ERROR
;
1093 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1094 if (vo_fs
== !!*(int *) arg
)
1095 return M_PROPERTY_OK
;
1096 case M_PROPERTY_STEP_UP
:
1097 case M_PROPERTY_STEP_DOWN
:
1098 if (mpctx
->video_out
->config_ok
)
1099 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1100 mpctx
->opts
.fullscreen
= vo_fs
;
1101 return M_PROPERTY_OK
;
1103 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1107 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1108 void *arg
, MPContext
*mpctx
)
1112 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1113 return M_PROPERTY_UNAVAILABLE
;
1114 vf
= mpctx
->sh_video
->vfilter
;
1116 case M_PROPERTY_GET
:
1118 return M_PROPERTY_ERROR
;
1119 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1120 return M_PROPERTY_OK
;
1121 case M_PROPERTY_SET
:
1123 return M_PROPERTY_ERROR
;
1124 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1125 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1126 return M_PROPERTY_OK
;
1127 case M_PROPERTY_STEP_UP
:
1128 case M_PROPERTY_STEP_DOWN
:
1129 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1130 deinterlace
= !deinterlace
;
1131 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1132 return M_PROPERTY_OK
;
1135 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1136 return m_property_flag_ro(prop
, action
, arg
, value
);
1139 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1140 void *arg
, MPContext
*mpctx
)
1142 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1143 return M_PROPERTY_UNAVAILABLE
;
1145 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1148 case M_PROPERTY_GET
:
1150 return M_PROPERTY_ERROR
;
1151 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1152 return M_PROPERTY_UNAVAILABLE
;
1153 return M_PROPERTY_OK
;
1154 case M_PROPERTY_PRINT
:
1156 return M_PROPERTY_ERROR
;
1157 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1158 return M_PROPERTY_UNAVAILABLE
;
1159 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1160 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1161 *(char **)arg
= strdup("Unknown");
1163 *(char**)arg
= strdup(names
[colorspace
]);
1164 return M_PROPERTY_OK
;
1165 case M_PROPERTY_SET
:
1167 return M_PROPERTY_ERROR
;
1168 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1169 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1170 return M_PROPERTY_OK
;
1171 case M_PROPERTY_STEP_UP
:;
1172 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1173 return M_PROPERTY_UNAVAILABLE
;
1175 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1176 return M_PROPERTY_OK
;
1178 return M_PROPERTY_NOT_IMPLEMENTED
;
1182 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1186 if (!mpctx
->video_out
1187 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1188 return M_PROPERTY_UNAVAILABLE
;
1191 case M_PROPERTY_SET
:
1193 return M_PROPERTY_ERROR
;
1194 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1195 vo_panscan
= *(float *) arg
;
1196 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1197 return M_PROPERTY_OK
;
1198 case M_PROPERTY_STEP_UP
:
1199 case M_PROPERTY_STEP_DOWN
:
1200 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1201 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1204 else if (vo_panscan
< 0)
1206 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1207 return M_PROPERTY_OK
;
1209 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1213 /// Helper to set vo flags.
1214 /** \ingroup PropertyImplHelper
1216 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1217 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1220 if (!mpctx
->video_out
)
1221 return M_PROPERTY_UNAVAILABLE
;
1224 case M_PROPERTY_SET
:
1226 return M_PROPERTY_ERROR
;
1227 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1228 if (*vo_var
== !!*(int *) arg
)
1229 return M_PROPERTY_OK
;
1230 case M_PROPERTY_STEP_UP
:
1231 case M_PROPERTY_STEP_DOWN
:
1232 if (mpctx
->video_out
->config_ok
)
1233 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1234 return M_PROPERTY_OK
;
1236 return m_property_flag(prop
, action
, arg
, vo_var
);
1240 /// Window always on top (RW)
1241 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1244 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1245 &mpctx
->opts
.vo_ontop
, mpctx
);
1248 /// Display in the root window (RW)
1249 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1252 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1253 &vo_rootwin
, mpctx
);
1256 /// Show window borders (RW)
1257 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1260 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1264 /// Framedropping state (RW)
1265 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1266 void *arg
, MPContext
*mpctx
)
1269 if (!mpctx
->sh_video
)
1270 return M_PROPERTY_UNAVAILABLE
;
1273 case M_PROPERTY_PRINT
:
1275 return M_PROPERTY_ERROR
;
1276 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1277 (frame_dropping
== 2 ? mp_gtext("hard") :
1278 mp_gtext("disabled")));
1279 return M_PROPERTY_OK
;
1281 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1285 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1286 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1289 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1292 if (!mpctx
->sh_video
)
1293 return M_PROPERTY_UNAVAILABLE
;
1295 if (gamma
[0] == 1000) {
1297 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1301 case M_PROPERTY_SET
:
1303 return M_PROPERTY_ERROR
;
1304 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1305 *gamma
= *(int *) arg
;
1306 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1310 case M_PROPERTY_GET
:
1311 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1313 return M_PROPERTY_ERROR
;
1315 return M_PROPERTY_OK
;
1318 case M_PROPERTY_STEP_UP
:
1319 case M_PROPERTY_STEP_DOWN
:
1320 *gamma
+= (arg
? *(int *) arg
: 1) *
1321 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1322 M_PROPERTY_CLAMP(prop
, *gamma
);
1323 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1328 return M_PROPERTY_NOT_IMPLEMENTED
;
1332 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1333 int l
= strlen(prop
->name
);
1334 char tv_prop
[3 + l
+ 1];
1335 sprintf(tv_prop
, "tv_%s", prop
->name
);
1336 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1340 return M_PROPERTY_UNAVAILABLE
;
1344 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1347 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1350 /// Video codec tag (RO)
1351 static int mp_property_video_format(m_option_t
*prop
, int action
,
1352 void *arg
, MPContext
*mpctx
)
1355 if (!mpctx
->sh_video
)
1356 return M_PROPERTY_UNAVAILABLE
;
1358 case M_PROPERTY_PRINT
:
1360 return M_PROPERTY_ERROR
;
1361 switch(mpctx
->sh_video
->format
) {
1363 meta
= strdup ("mpeg1"); break;
1365 meta
= strdup ("mpeg2"); break;
1367 meta
= strdup ("mpeg4"); break;
1369 meta
= strdup ("h264"); break;
1371 if(mpctx
->sh_video
->format
>= 0x20202020) {
1373 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1376 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1379 *(char**)arg
= meta
;
1380 return M_PROPERTY_OK
;
1382 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1385 /// Video codec name (RO)
1386 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1387 void *arg
, MPContext
*mpctx
)
1389 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1390 return M_PROPERTY_UNAVAILABLE
;
1391 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1395 /// Video bitrate (RO)
1396 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1397 void *arg
, MPContext
*mpctx
)
1399 if (!mpctx
->sh_video
)
1400 return M_PROPERTY_UNAVAILABLE
;
1401 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1404 /// Video display width (RO)
1405 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1408 if (!mpctx
->sh_video
)
1409 return M_PROPERTY_UNAVAILABLE
;
1410 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1413 /// Video display height (RO)
1414 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1417 if (!mpctx
->sh_video
)
1418 return M_PROPERTY_UNAVAILABLE
;
1419 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1423 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1426 if (!mpctx
->sh_video
)
1427 return M_PROPERTY_UNAVAILABLE
;
1428 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1431 /// Video aspect (RO)
1432 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1435 if (!mpctx
->sh_video
)
1436 return M_PROPERTY_UNAVAILABLE
;
1437 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1442 /// \defgroup SubProprties Subtitles properties
1443 /// \ingroup Properties
1446 /// Text subtitle position (RW)
1447 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1451 case M_PROPERTY_SET
:
1453 return M_PROPERTY_ERROR
;
1454 case M_PROPERTY_STEP_UP
:
1455 case M_PROPERTY_STEP_DOWN
:
1456 vo_osd_changed(OSDTYPE_SUBTITLE
);
1458 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1462 /// Selected subtitles (RW)
1463 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1466 struct MPOpts
*opts
= &mpctx
->opts
;
1467 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1468 int source
= -1, reset_spu
= 0;
1469 int source_pos
= -1;
1472 update_global_sub_size(mpctx
);
1473 const int global_sub_size
= mpctx
->global_sub_size
;
1475 if (global_sub_size
<= 0)
1476 return M_PROPERTY_UNAVAILABLE
;
1479 case M_PROPERTY_GET
:
1481 return M_PROPERTY_ERROR
;
1482 *(int *) arg
= mpctx
->global_sub_pos
;
1483 return M_PROPERTY_OK
;
1484 case M_PROPERTY_PRINT
:
1486 return M_PROPERTY_ERROR
;
1487 *(char **) arg
= malloc(64);
1488 (*(char **) arg
)[63] = 0;
1491 sub_name
= subdata
->filename
;
1493 if (ass_track
&& ass_track
->name
)
1494 sub_name
= ass_track
->name
;
1499 if ((tmp2
= strrchr(tmp
, '/')))
1502 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1503 mpctx
->set_of_sub_pos
+ 1,
1504 strlen(tmp
) < 20 ? "" : "...",
1505 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1506 return M_PROPERTY_OK
;
1508 #ifdef CONFIG_DVDNAV
1509 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1510 if (vo_spudec
&& opts
->sub_id
>= 0) {
1511 unsigned char lang
[3];
1512 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1513 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1514 return M_PROPERTY_OK
;
1520 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1521 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1522 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1523 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1524 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1525 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1526 if (!lang
) lang
= mp_gtext("unknown");
1527 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1528 return M_PROPERTY_OK
;
1531 if (vo_vobsub
&& vobsub_id
>= 0) {
1532 const char *language
= mp_gtext("unknown");
1533 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1534 snprintf(*(char **) arg
, 63, "(%d) %s",
1535 vobsub_id
, language
? language
: mp_gtext("unknown"));
1536 return M_PROPERTY_OK
;
1538 #ifdef CONFIG_DVDREAD
1539 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1540 && opts
->sub_id
>= 0) {
1542 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1543 lang
[0] = code
>> 8;
1546 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1547 return M_PROPERTY_OK
;
1550 if (opts
->sub_id
>= 0) {
1551 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1552 mp_gtext("unknown"));
1553 return M_PROPERTY_OK
;
1555 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1556 return M_PROPERTY_OK
;
1558 case M_PROPERTY_SET
:
1560 return M_PROPERTY_ERROR
;
1561 if (*(int *) arg
< -1)
1563 else if (*(int *) arg
>= global_sub_size
)
1564 *(int *) arg
= global_sub_size
- 1;
1565 mpctx
->global_sub_pos
= *(int *) arg
;
1567 case M_PROPERTY_STEP_UP
:
1568 mpctx
->global_sub_pos
+= 2;
1569 mpctx
->global_sub_pos
=
1570 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1572 case M_PROPERTY_STEP_DOWN
:
1573 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1574 mpctx
->global_sub_pos
=
1575 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1578 return M_PROPERTY_NOT_IMPLEMENTED
;
1581 if (mpctx
->global_sub_pos
>= 0) {
1582 source
= sub_source(mpctx
);
1583 source_pos
= sub_source_pos(mpctx
);
1586 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1587 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1589 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1590 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1591 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1592 mpctx
->global_sub_pos
, source
);
1594 mpctx
->set_of_sub_pos
= -1;
1608 if (source
== SUB_SOURCE_VOBSUB
) {
1609 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1610 } else if (source
== SUB_SOURCE_SUBS
) {
1611 mpctx
->set_of_sub_pos
= source_pos
;
1613 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1614 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1618 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1619 vo_osd_changed(OSDTYPE_SUBTITLE
);
1621 } else if (source
== SUB_SOURCE_DEMUX
) {
1622 opts
->sub_id
= source_pos
;
1623 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1625 // default: assume 1:1 mapping of sid and stream id
1626 d_sub
->id
= opts
->sub_id
;
1627 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1628 ds_free_packs(d_sub
);
1629 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1630 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1631 if (sh
&& sh
->sid
== opts
->sub_id
) {
1637 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1638 sh_sub_t
*sh
= d_sub
->sh
;
1639 if (sh
->type
== 'v')
1640 init_vo_spudec(mpctx
);
1642 else if (opts
->ass_enabled
)
1643 ass_track
= sh
->ass_track
;
1651 #ifdef CONFIG_DVDREAD
1653 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1654 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1655 && opts
->sub_id
< 0 && reset_spu
) {
1661 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1663 return M_PROPERTY_OK
;
1666 /// Selected sub source (RW)
1667 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1671 update_global_sub_size(mpctx
);
1672 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1673 return M_PROPERTY_UNAVAILABLE
;
1676 case M_PROPERTY_GET
:
1678 return M_PROPERTY_ERROR
;
1679 *(int *) arg
= sub_source(mpctx
);
1680 return M_PROPERTY_OK
;
1681 case M_PROPERTY_PRINT
:
1683 return M_PROPERTY_ERROR
;
1684 *(char **) arg
= malloc(64);
1685 (*(char **) arg
)[63] = 0;
1686 switch (sub_source(mpctx
))
1688 case SUB_SOURCE_SUBS
:
1689 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1691 case SUB_SOURCE_VOBSUB
:
1692 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1694 case SUB_SOURCE_DEMUX
:
1695 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1698 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1700 return M_PROPERTY_OK
;
1701 case M_PROPERTY_SET
:
1703 return M_PROPERTY_ERROR
;
1704 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1705 if (*(int *) arg
< 0)
1706 mpctx
->global_sub_pos
= -1;
1707 else if (*(int *) arg
!= sub_source(mpctx
)) {
1708 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1710 return M_PROPERTY_UNAVAILABLE
;
1711 mpctx
->global_sub_pos
= new_pos
;
1714 case M_PROPERTY_STEP_UP
:
1715 case M_PROPERTY_STEP_DOWN
: {
1716 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1717 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1718 int step
= (step_all
> 0) ? 1 : -1;
1719 int cur_source
= sub_source(mpctx
);
1720 source
= cur_source
;
1723 if (source
>= SUB_SOURCES
)
1725 else if (source
< -1)
1726 source
= SUB_SOURCES
- 1;
1727 if (source
== cur_source
|| source
== -1 ||
1728 mpctx
->sub_counts
[source
])
1731 if (source
== cur_source
)
1732 return M_PROPERTY_OK
;
1734 mpctx
->global_sub_pos
= -1;
1736 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1740 return M_PROPERTY_NOT_IMPLEMENTED
;
1742 --mpctx
->global_sub_pos
;
1743 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1746 /// Selected subtitles from specific source (RW)
1747 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1750 int source
, is_cur_source
, offset
, new_pos
;
1751 update_global_sub_size(mpctx
);
1752 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1753 return M_PROPERTY_UNAVAILABLE
;
1755 if (!strcmp(prop
->name
, "sub_file"))
1756 source
= SUB_SOURCE_SUBS
;
1757 else if (!strcmp(prop
->name
, "sub_vob"))
1758 source
= SUB_SOURCE_VOBSUB
;
1759 else if (!strcmp(prop
->name
, "sub_demux"))
1760 source
= SUB_SOURCE_DEMUX
;
1762 return M_PROPERTY_ERROR
;
1764 offset
= sub_pos_by_source(mpctx
, source
);
1766 return M_PROPERTY_UNAVAILABLE
;
1768 is_cur_source
= sub_source(mpctx
) == source
;
1769 new_pos
= mpctx
->global_sub_pos
;
1771 case M_PROPERTY_GET
:
1773 return M_PROPERTY_ERROR
;
1774 if (is_cur_source
) {
1775 *(int *) arg
= sub_source_pos(mpctx
);
1776 if (source
== SUB_SOURCE_VOBSUB
)
1777 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1781 return M_PROPERTY_OK
;
1782 case M_PROPERTY_PRINT
:
1784 return M_PROPERTY_ERROR
;
1786 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1787 *(char **) arg
= malloc(64);
1788 (*(char **) arg
)[63] = 0;
1789 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1790 return M_PROPERTY_OK
;
1791 case M_PROPERTY_SET
:
1793 return M_PROPERTY_ERROR
;
1794 if (*(int *) arg
>= 0) {
1795 int index
= *(int *)arg
;
1796 if (source
== SUB_SOURCE_VOBSUB
)
1797 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1798 new_pos
= offset
+ index
;
1799 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1807 case M_PROPERTY_STEP_UP
:
1808 case M_PROPERTY_STEP_DOWN
: {
1809 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1810 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1811 int step
= (step_all
> 0) ? 1 : -1;
1812 int max_sub_pos_for_source
= -1;
1816 if (new_pos
== -1) {
1819 else if (max_sub_pos_for_source
== -1) {
1820 // Find max pos for specific source
1821 new_pos
= mpctx
->global_sub_size
- 1;
1823 && sub_source(mpctx
) != source
)
1827 new_pos
= max_sub_pos_for_source
;
1831 if (new_pos
< offset
||
1832 new_pos
>= mpctx
->global_sub_size
||
1833 sub_source(mpctx
) != source
)
1841 return M_PROPERTY_NOT_IMPLEMENTED
;
1843 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1846 /// Subtitle delay (RW)
1847 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1850 if (!mpctx
->sh_video
)
1851 return M_PROPERTY_UNAVAILABLE
;
1852 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1855 /// Alignment of text subtitles (RW)
1856 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1857 void *arg
, MPContext
*mpctx
)
1859 char *name
[] = { _("top"), _("center"), _("bottom") };
1861 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1862 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1863 return M_PROPERTY_UNAVAILABLE
;
1866 case M_PROPERTY_PRINT
:
1868 return M_PROPERTY_ERROR
;
1869 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1870 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1871 return M_PROPERTY_OK
;
1872 case M_PROPERTY_SET
:
1874 return M_PROPERTY_ERROR
;
1875 case M_PROPERTY_STEP_UP
:
1876 case M_PROPERTY_STEP_DOWN
:
1877 vo_osd_changed(OSDTYPE_SUBTITLE
);
1879 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1883 /// Subtitle visibility (RW)
1884 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1885 void *arg
, MPContext
*mpctx
)
1887 if (!mpctx
->sh_video
)
1888 return M_PROPERTY_UNAVAILABLE
;
1891 case M_PROPERTY_SET
:
1893 return M_PROPERTY_ERROR
;
1894 case M_PROPERTY_STEP_UP
:
1895 case M_PROPERTY_STEP_DOWN
:
1896 vo_osd_changed(OSDTYPE_SUBTITLE
);
1898 vo_osd_changed(OSDTYPE_SPU
);
1900 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1905 /// Use margins for libass subtitles (RW)
1906 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1907 void *arg
, MPContext
*mpctx
)
1909 if (!mpctx
->sh_video
)
1910 return M_PROPERTY_UNAVAILABLE
;
1913 case M_PROPERTY_SET
:
1915 return M_PROPERTY_ERROR
;
1916 case M_PROPERTY_STEP_UP
:
1917 case M_PROPERTY_STEP_DOWN
:
1918 ass_force_reload
= 1;
1920 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1925 /// Show only forced subtitles (RW)
1926 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1927 void *arg
, MPContext
*mpctx
)
1930 return M_PROPERTY_UNAVAILABLE
;
1933 case M_PROPERTY_SET
:
1935 return M_PROPERTY_ERROR
;
1936 case M_PROPERTY_STEP_UP
:
1937 case M_PROPERTY_STEP_DOWN
:
1938 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1939 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1940 return M_PROPERTY_OK
;
1942 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1947 #ifdef CONFIG_FREETYPE
1948 /// Subtitle scale (RW)
1949 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1952 struct MPOpts
*opts
= &mpctx
->opts
;
1955 case M_PROPERTY_SET
:
1957 return M_PROPERTY_ERROR
;
1958 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1960 if (opts
->ass_enabled
) {
1961 ass_font_scale
= *(float *) arg
;
1962 ass_force_reload
= 1;
1965 text_font_scale_factor
= *(float *) arg
;
1966 force_load_font
= 1;
1967 return M_PROPERTY_OK
;
1968 case M_PROPERTY_STEP_UP
:
1969 case M_PROPERTY_STEP_DOWN
:
1971 if (opts
->ass_enabled
) {
1972 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1973 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1974 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1975 ass_force_reload
= 1;
1978 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1979 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1980 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1981 force_load_font
= 1;
1982 return M_PROPERTY_OK
;
1985 if (opts
->ass_enabled
)
1986 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1989 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1996 /// \defgroup TVProperties TV properties
1997 /// \ingroup Properties
2002 /// TV color settings (RW)
2003 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2007 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2008 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2009 return M_PROPERTY_UNAVAILABLE
;
2012 case M_PROPERTY_SET
:
2014 return M_PROPERTY_ERROR
;
2015 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2016 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
2017 case M_PROPERTY_GET
:
2018 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
2019 case M_PROPERTY_STEP_UP
:
2020 case M_PROPERTY_STEP_DOWN
:
2021 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
2023 return M_PROPERTY_ERROR
;
2024 val
+= (arg
? *(int *) arg
: 1) *
2025 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2026 M_PROPERTY_CLAMP(prop
, val
);
2027 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
2029 return M_PROPERTY_ERROR
;
2031 return M_PROPERTY_NOT_IMPLEMENTED
;
2036 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2040 int base_ioctl
=(int)prop
->priv
;
2042 for teletext's GET,SET,STEP ioctls this is not 0
2046 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2047 return M_PROPERTY_UNAVAILABLE
;
2049 return M_PROPERTY_ERROR
;
2052 case M_PROPERTY_GET
:
2054 return M_PROPERTY_ERROR
;
2055 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2057 case M_PROPERTY_SET
:
2059 return M_PROPERTY_ERROR
;
2060 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2061 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2063 case M_PROPERTY_STEP_UP
:
2064 case M_PROPERTY_STEP_DOWN
:
2065 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2066 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2067 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2070 return M_PROPERTY_NOT_IMPLEMENTED
;
2073 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2076 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2082 //with tvh==NULL will fail too
2083 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2084 if(result
!=M_PROPERTY_OK
)
2087 if(teletext_control(mpctx
->demuxer
->teletext
,
2088 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
2089 mp_input_set_section(mpctx
->input
, "teletext");
2091 mp_input_set_section(mpctx
->input
, "tv");
2092 return M_PROPERTY_OK
;
2095 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2100 if (!mpctx
->demuxer
->teletext
)
2101 return M_PROPERTY_UNAVAILABLE
;
2103 case M_PROPERTY_STEP_UP
:
2104 case M_PROPERTY_STEP_DOWN
:
2105 //This should be handled separately
2106 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2107 result
=teletext_control(mpctx
->demuxer
->teletext
,
2108 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2111 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2118 /// All properties available in MPlayer.
2119 /** \ingroup Properties
2121 static const m_option_t mp_properties
[] = {
2123 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2124 M_OPT_RANGE
, 0, 3, NULL
},
2125 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2126 M_OPT_MIN
, -1, 0, NULL
},
2127 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2128 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2129 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2131 { "path", mp_property_path
, CONF_TYPE_STRING
,
2133 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2135 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2136 M_OPT_MIN
, 0, 0, NULL
},
2137 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2138 M_OPT_MIN
, 0, 0, NULL
},
2139 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2140 M_OPT_MIN
, 0, 0, NULL
},
2141 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2142 M_OPT_MIN
, 0, 0, NULL
},
2143 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2144 M_OPT_MIN
, 0, 0, NULL
},
2145 { "length", mp_property_length
, CONF_TYPE_TIME
,
2146 M_OPT_MIN
, 0, 0, NULL
},
2147 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2148 M_OPT_RANGE
, 0, 100, NULL
},
2149 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2150 M_OPT_MIN
, 0, 0, NULL
},
2151 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2152 M_OPT_MIN
, 0, 0, NULL
},
2153 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2155 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2156 CONF_RANGE
, -2, 10, NULL
},
2157 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2159 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2160 M_OPT_RANGE
, 0, 1, NULL
},
2163 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2164 M_OPT_RANGE
, 0, 100, NULL
},
2165 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2166 M_OPT_RANGE
, 0, 1, NULL
},
2167 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2168 M_OPT_RANGE
, -100, 100, NULL
},
2169 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2171 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2173 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2175 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2177 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2179 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2180 CONF_RANGE
, -2, 65535, NULL
},
2181 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2182 M_OPT_RANGE
, -1, 1, NULL
},
2185 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2186 M_OPT_RANGE
, 0, 1, NULL
},
2187 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2188 M_OPT_RANGE
, 0, 1, NULL
},
2189 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2190 M_OPT_RANGE
, 0, 2, NULL
},
2191 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2192 M_OPT_RANGE
, 0, 1, NULL
},
2193 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2194 M_OPT_RANGE
, 0, 1, NULL
},
2195 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2196 M_OPT_RANGE
, 0, 1, NULL
},
2197 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2198 M_OPT_RANGE
, 0, 2, NULL
},
2199 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2200 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2201 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2202 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2203 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2204 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2205 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2206 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2207 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2208 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2209 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2210 M_OPT_RANGE
, 0, 1, NULL
},
2211 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2212 M_OPT_RANGE
, 0, 1, NULL
},
2213 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2215 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2217 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2219 { "width", mp_property_width
, CONF_TYPE_INT
,
2221 { "height", mp_property_height
, CONF_TYPE_INT
,
2223 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2225 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2227 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2228 CONF_RANGE
, -2, 65535, NULL
},
2229 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2230 CONF_RANGE
, -1, 65535, NULL
},
2233 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2234 M_OPT_MIN
, -1, 0, NULL
},
2235 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2236 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2237 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2238 M_OPT_MIN
, -1, 0, NULL
},
2239 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2240 M_OPT_MIN
, -1, 0, NULL
},
2241 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2242 M_OPT_MIN
, -1, 0, NULL
},
2243 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2245 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2246 M_OPT_RANGE
, 0, 100, NULL
},
2247 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2248 M_OPT_RANGE
, 0, 2, NULL
},
2249 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2250 M_OPT_RANGE
, 0, 1, NULL
},
2251 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2252 M_OPT_RANGE
, 0, 1, NULL
},
2253 #ifdef CONFIG_FREETYPE
2254 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2255 M_OPT_RANGE
, 0, 100, NULL
},
2258 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2259 M_OPT_RANGE
, 0, 1, NULL
},
2263 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2264 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2265 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2266 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2267 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2268 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2269 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2270 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2272 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2273 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2274 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2275 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2276 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2277 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2278 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2279 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2280 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2281 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2282 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2286 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2288 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2291 char* mp_property_print(const char *name
, void* ctx
)
2294 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2299 char *property_expand_string(MPContext
*mpctx
, char *str
)
2301 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2304 void property_print_help(void)
2306 m_properties_print_help_list(mp_properties
);
2310 /* List of default ways to show a property on OSD.
2312 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2313 * a bar showing the current position between min/max values of the
2314 * property. In this case osd_msg is only used for terminal output
2315 * if there is no video; it'll be a label shown together with percentage.
2317 * Otherwise setting osd_msg will show the string on OSD, formatted with
2318 * the text value of the property as argument.
2320 static struct property_osd_display
{
2323 /// progressbar type
2324 int osd_progbar
; // -1 is special value for seek indicators
2325 /// osd msg id if it must be shared
2327 /// osd msg template
2328 const char *osd_msg
;
2329 } property_osd_display
[] = {
2331 { "loop", 0, -1, _("Loop: %s") },
2332 { "chapter", -1, -1, NULL
},
2334 { "volume", OSD_VOLUME
, -1, _("Volume") },
2335 { "mute", 0, -1, _("Mute: %s") },
2336 { "audio_delay", 0, -1, _("A-V delay: %s") },
2337 { "switch_audio", 0, -1, _("Audio: %s") },
2338 { "balance", OSD_BALANCE
, -1, _("Balance") },
2340 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2341 { "ontop", 0, -1, _("Stay on top: %s") },
2342 { "rootwin", 0, -1, _("Rootwin: %s") },
2343 { "border", 0, -1, _("Border: %s") },
2344 { "framedropping", 0, -1, _("Framedropping: %s") },
2345 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2346 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2347 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2348 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2349 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2350 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2351 { "hue", OSD_HUE
, -1, _("Hue") },
2352 { "vsync", 0, -1, _("VSync: %s") },
2354 { "sub", 0, -1, _("Subtitles: %s") },
2355 { "sub_source", 0, -1, _("Sub source: %s") },
2356 { "sub_vob", 0, -1, _("Subtitles: %s") },
2357 { "sub_demux", 0, -1, _("Subtitles: %s") },
2358 { "sub_file", 0, -1, _("Subtitles: %s") },
2359 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2360 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2361 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2362 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2363 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2364 #ifdef CONFIG_FREETYPE
2365 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2368 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2369 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2370 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2371 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2376 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2378 struct MPOpts
*opts
= &mpctx
->opts
;
2381 struct property_osd_display
*p
;
2383 // look for the command
2384 for (p
= property_osd_display
; p
->name
; p
++)
2385 if (!strcmp(p
->name
, pname
))
2390 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2393 if (p
->osd_progbar
== -1)
2394 mpctx
->add_osd_seek_info
= true;
2395 else if (p
->osd_progbar
) {
2396 if (prop
->type
== CONF_TYPE_INT
) {
2397 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2398 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2399 prop
->min
, prop
->max
, r
);
2400 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2402 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2403 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2404 prop
->min
, prop
->max
, f
);
2406 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2407 "Property use an unsupported type.\n");
2414 char *val
= mp_property_print(pname
, mpctx
);
2416 int index
= p
- property_osd_display
;
2417 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2418 1, opts
->osd_duration
, p
->osd_msg
, val
);
2427 * \defgroup Command2Property Command to property bridge
2429 * It is used to handle most commands that just set a property
2430 * and optionally display something on the OSD.
2431 * Two kinds of commands are handled: adjust or toggle.
2433 * Adjust commands take 1 or 2 parameters: <value> <abs>
2434 * If <abs> is non-zero the property is set to the given value
2435 * otherwise it is adjusted.
2437 * Toggle commands take 0 or 1 parameters. With no parameter
2438 * or a value less than the property minimum it just steps the
2439 * property to its next value. Otherwise it sets it to the given
2445 /// List of the commands that can be handled by setting a property.
2451 /// set/adjust or toggle command
2453 } set_prop_cmd
[] = {
2455 { "loop", MP_CMD_LOOP
, 0},
2456 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2457 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2458 { "pause", MP_CMD_PAUSE
, 0},
2460 { "volume", MP_CMD_VOLUME
, 0},
2461 { "mute", MP_CMD_MUTE
, 1},
2462 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2463 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2464 { "balance", MP_CMD_BALANCE
, 0},
2466 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2467 { "panscan", MP_CMD_PANSCAN
, 0},
2468 { "ontop", MP_CMD_VO_ONTOP
, 1},
2469 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2470 { "border", MP_CMD_VO_BORDER
, 1},
2471 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2472 { "gamma", MP_CMD_GAMMA
, 0},
2473 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2474 { "contrast", MP_CMD_CONTRAST
, 0},
2475 { "saturation", MP_CMD_SATURATION
, 0},
2476 { "hue", MP_CMD_HUE
, 0},
2477 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2479 { "sub", MP_CMD_SUB_SELECT
, 1},
2480 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2481 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2482 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2483 { "sub_file", MP_CMD_SUB_FILE
, 1},
2484 { "sub_pos", MP_CMD_SUB_POS
, 0},
2485 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2486 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2487 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2488 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2489 #ifdef CONFIG_FREETYPE
2490 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2493 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2496 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2497 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2498 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2499 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2504 /// Handle commands that set a property.
2505 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2511 // look for the command
2512 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2513 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2515 if (!(pname
= set_prop_cmd
[i
].name
))
2518 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2522 if (set_prop_cmd
[i
].toggle
) {
2524 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2525 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2527 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2528 } else if (cmd
->args
[1].v
.i
) //set
2529 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2531 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2536 show_property_osd(mpctx
, pname
);
2541 #ifdef CONFIG_DVDNAV
2542 static const struct {
2544 const mp_command_type cmd
;
2545 } mp_dvdnav_bindings
[] = {
2546 { "up", MP_CMD_DVDNAV_UP
},
2547 { "down", MP_CMD_DVDNAV_DOWN
},
2548 { "left", MP_CMD_DVDNAV_LEFT
},
2549 { "right", MP_CMD_DVDNAV_RIGHT
},
2550 { "menu", MP_CMD_DVDNAV_MENU
},
2551 { "select", MP_CMD_DVDNAV_SELECT
},
2552 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2553 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2556 * keep old dvdnav sub-command options for a while in order not to
2557 * break slave-mode API too suddenly.
2559 { "1", MP_CMD_DVDNAV_UP
},
2560 { "2", MP_CMD_DVDNAV_DOWN
},
2561 { "3", MP_CMD_DVDNAV_LEFT
},
2562 { "4", MP_CMD_DVDNAV_RIGHT
},
2563 { "5", MP_CMD_DVDNAV_MENU
},
2564 { "6", MP_CMD_DVDNAV_SELECT
},
2565 { "7", MP_CMD_DVDNAV_PREVMENU
},
2566 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2571 static const char *property_error_string(int error_value
)
2573 switch (error_value
) {
2574 case M_PROPERTY_ERROR
:
2576 case M_PROPERTY_UNAVAILABLE
:
2577 return "PROPERTY_UNAVAILABLE";
2578 case M_PROPERTY_NOT_IMPLEMENTED
:
2579 return "NOT_IMPLEMENTED";
2580 case M_PROPERTY_UNKNOWN
:
2581 return "PROPERTY_UNKNOWN";
2582 case M_PROPERTY_DISABLED
:
2588 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2591 int end
= start
+ count
;
2592 int after
= mpctx
->set_of_sub_size
- end
;
2593 sub_data
**subs
= mpctx
->set_of_subtitles
;
2595 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2597 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2598 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2599 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2600 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2603 for (idx
= start
; idx
< end
; idx
++) {
2604 sub_data
*subd
= subs
[idx
];
2605 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2606 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2607 filename_recode(subd
->filename
));
2611 if (ass_tracks
[idx
])
2612 ass_free_track(ass_tracks
[idx
]);
2613 ass_tracks
[idx
] = NULL
;
2617 mpctx
->global_sub_size
-= count
;
2618 mpctx
->set_of_sub_size
-= count
;
2619 if (mpctx
->set_of_sub_size
<= 0)
2620 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2622 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2623 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2625 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2626 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2629 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2630 mpctx
->global_sub_pos
= -2;
2635 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2636 } else if (mpctx
->set_of_sub_pos
>= end
) {
2637 mpctx
->set_of_sub_pos
-= count
;
2638 mpctx
->global_sub_pos
-= count
;
2642 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2644 struct MPOpts
*opts
= &mpctx
->opts
;
2645 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2646 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2647 int osd_duration
= opts
->osd_duration
;
2648 int case_fallthrough_hack
= 0;
2649 if (!set_property_command(mpctx
, cmd
))
2654 mpctx
->add_osd_seek_info
= true;
2655 v
= cmd
->args
[0].v
.f
;
2656 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2657 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2658 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2660 mpctx
->osd_function
=
2661 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2662 mpctx
->rel_seek_secs
= v
;
2663 } else if (abs
) { /* Absolute seek by percentage */
2664 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2666 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2667 mpctx
->rel_seek_secs
= v
/ 100.0;
2669 mpctx
->rel_seek_secs
+= v
;
2670 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2675 case MP_CMD_SET_PROPERTY_OSD
:
2676 case_fallthrough_hack
= 1;
2678 case MP_CMD_SET_PROPERTY
:{
2679 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2680 cmd
->args
[1].v
.s
, mpctx
);
2681 if (r
== M_PROPERTY_UNKNOWN
)
2682 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2683 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2685 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2686 "Failed to set property '%s' to '%s'.\n",
2687 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2688 else if (case_fallthrough_hack
)
2689 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2691 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2695 case MP_CMD_STEP_PROPERTY_OSD
:
2696 case_fallthrough_hack
= 1;
2698 case MP_CMD_STEP_PROPERTY
:{
2703 if (cmd
->args
[1].v
.f
) {
2705 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2706 M_PROPERTY_GET_TYPE
,
2707 &prop
, mpctx
)) <= 0)
2709 if(prop
->type
== CONF_TYPE_INT
||
2710 prop
->type
== CONF_TYPE_FLAG
)
2711 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2712 else if(prop
->type
== CONF_TYPE_FLOAT
)
2713 arg
= &cmd
->args
[1].v
.f
;
2714 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2715 prop
->type
== CONF_TYPE_TIME
)
2716 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2717 else if(prop
->type
== CONF_TYPE_POSITION
)
2718 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2720 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2721 "Ignoring step size stepping property '%s'.\n",
2724 r
= mp_property_do(cmd
->args
[0].v
.s
,
2725 cmd
->args
[2].v
.i
< 0 ?
2726 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2729 if (r
== M_PROPERTY_UNKNOWN
)
2730 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2731 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2733 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2734 "Failed to increment property '%s' by %f.\n",
2735 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2736 else if (case_fallthrough_hack
)
2737 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2739 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2743 case MP_CMD_GET_PROPERTY
:{
2745 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2748 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2749 "Failed to get value of property '%s'.\n",
2751 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2754 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2755 cmd
->args
[0].v
.s
, tmp
);
2760 case MP_CMD_EDL_MARK
:
2762 float v
= sh_video
? sh_video
->pts
:
2763 playing_audio_pts(mpctx
);
2764 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2765 mpctx
->begin_skip
= v
;
2766 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2768 if (mpctx
->begin_skip
> v
)
2769 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2771 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2772 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2774 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2779 case MP_CMD_SWITCH_RATIO
:
2782 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2783 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2785 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2786 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2789 case MP_CMD_SPEED_INCR
:{
2790 float v
= cmd
->args
[0].v
.f
;
2791 opts
->playback_speed
+= v
;
2792 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2793 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2794 opts
->playback_speed
);
2797 case MP_CMD_SPEED_MULT
:{
2798 float v
= cmd
->args
[0].v
.f
;
2799 opts
->playback_speed
*= v
;
2800 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2801 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2802 opts
->playback_speed
);
2805 case MP_CMD_SPEED_SET
:{
2806 float v
= cmd
->args
[0].v
.f
;
2807 opts
->playback_speed
= v
;
2808 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2809 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2810 opts
->playback_speed
);
2813 case MP_CMD_FRAME_STEP
:
2814 add_step_frame(mpctx
);
2817 case MP_CMD_FILE_FILTER
:
2818 file_filter
= cmd
->args
[0].v
.i
;
2822 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2823 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2825 case MP_CMD_PLAY_TREE_STEP
:{
2826 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2827 int force
= cmd
->args
[1].v
.i
;
2830 if (!force
&& mpctx
->playtree_iter
) {
2831 play_tree_iter_t
*i
=
2832 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2833 if (play_tree_iter_step(i
, n
, 0) ==
2834 PLAY_TREE_ITER_ENTRY
)
2836 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2837 play_tree_iter_free(i
);
2839 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2840 if (mpctx
->stop_play
)
2841 mpctx
->play_tree_step
= n
;
2846 case MP_CMD_PLAY_TREE_UP_STEP
:{
2847 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2848 int force
= cmd
->args
[1].v
.i
;
2850 if (!force
&& mpctx
->playtree_iter
) {
2851 play_tree_iter_t
*i
=
2852 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2853 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2854 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2855 play_tree_iter_free(i
);
2857 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2861 case MP_CMD_PLAY_ALT_SRC_STEP
:
2862 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2863 int v
= cmd
->args
[0].v
.i
;
2865 && mpctx
->playtree_iter
->file
<
2866 mpctx
->playtree_iter
->num_files
)
2867 mpctx
->stop_play
= PT_NEXT_SRC
;
2868 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2869 mpctx
->stop_play
= PT_PREV_SRC
;
2873 case MP_CMD_SUB_STEP
:
2875 int movement
= cmd
->args
[0].v
.i
;
2876 step_sub(subdata
, sh_video
->pts
, movement
);
2880 ass_step_sub(ass_track
,
2882 sub_delay
) * 1000 + .5, movement
) / 1000.;
2884 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2885 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2889 case MP_CMD_SUB_LOG
:
2894 int v
= cmd
->args
[0].v
.i
;
2896 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2897 if (opts
->osd_level
> max
)
2898 opts
->osd_level
= max
;
2900 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2902 opts
->osd_level
= v
> max
? max
: v
;
2903 /* Show OSD state when disabled, but not when an explicit
2904 argument is given to the OSD command, i.e. in slave mode. */
2905 if (v
== -1 && opts
->osd_level
<= 1)
2906 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2908 opts
->osd_level
? mp_gtext("enabled") :
2909 mp_gtext("disabled"));
2911 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2915 case MP_CMD_OSD_SHOW_TEXT
:
2916 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2918 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2919 "%-.63s", cmd
->args
[0].v
.s
);
2922 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2923 char *txt
= m_properties_expand_string(mp_properties
,
2926 /* if no argument supplied take default osd_duration, else <arg> ms. */
2928 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2930 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2937 case MP_CMD_LOADFILE
:{
2938 play_tree_t
*e
= play_tree_new();
2939 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2941 if (cmd
->args
[1].v
.i
) // append
2942 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2944 // Go back to the starting point.
2945 while (play_tree_iter_up_step
2946 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2948 play_tree_free_list(mpctx
->playtree
->child
, 1);
2949 play_tree_set_child(mpctx
->playtree
, e
);
2950 pt_iter_goto_head(mpctx
->playtree_iter
);
2951 mpctx
->stop_play
= PT_NEXT_SRC
;
2956 case MP_CMD_LOADLIST
:{
2957 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2959 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2960 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2962 if (cmd
->args
[1].v
.i
) // append
2963 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2965 // Go back to the starting point.
2966 while (play_tree_iter_up_step
2967 (mpctx
->playtree_iter
, 0, 1)
2968 != PLAY_TREE_ITER_END
)
2970 play_tree_free_list(mpctx
->playtree
->child
, 1);
2971 play_tree_set_child(mpctx
->playtree
, e
);
2972 pt_iter_goto_head(mpctx
->playtree_iter
);
2973 mpctx
->stop_play
= PT_NEXT_SRC
;
2980 // Go back to the starting point.
2981 while (play_tree_iter_up_step
2982 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2984 mpctx
->stop_play
= PT_STOP
;
2987 case MP_CMD_OSD_SHOW_PROGRESSION
:{
2988 int len
= demuxer_get_time_length(mpctx
->demuxer
);
2989 int pts
= demuxer_get_current_time(mpctx
->demuxer
);
2990 set_osd_bar(mpctx
, 0, "Position", 0, 100, demuxer_get_percent_pos(mpctx
->demuxer
));
2991 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2992 "%c %02d:%02d:%02d / %02d:%02d:%02d",
2993 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
2994 len
/3600, (len
/60)%60, len
%60);
2999 case MP_CMD_RADIO_STEP_CHANNEL
:
3000 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3001 int v
= cmd
->args
[0].v
.i
;
3003 radio_step_channel(mpctx
->demuxer
->stream
,
3004 RADIO_CHANNEL_HIGHER
);
3006 radio_step_channel(mpctx
->demuxer
->stream
,
3007 RADIO_CHANNEL_LOWER
);
3008 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3009 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3011 radio_get_channel_name(mpctx
->demuxer
->stream
));
3016 case MP_CMD_RADIO_SET_CHANNEL
:
3017 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3018 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3019 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3020 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3022 radio_get_channel_name(mpctx
->demuxer
->stream
));
3027 case MP_CMD_RADIO_SET_FREQ
:
3028 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3029 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3032 case MP_CMD_RADIO_STEP_FREQ
:
3033 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3034 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3039 case MP_CMD_TV_START_SCAN
:
3040 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3041 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3043 case MP_CMD_TV_SET_FREQ
:
3044 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3045 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3046 cmd
->args
[0].v
.f
* 16.0);
3048 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3049 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3050 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3051 pvr_get_current_channelname (mpctx
->stream
),
3052 pvr_get_current_stationname (mpctx
->stream
));
3054 #endif /* CONFIG_PVR */
3057 case MP_CMD_TV_STEP_FREQ
:
3058 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3059 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3060 cmd
->args
[0].v
.f
* 16.0);
3062 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3063 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3064 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3065 pvr_get_current_channelname (mpctx
->stream
),
3066 pvr_get_current_frequency (mpctx
->stream
));
3068 #endif /* CONFIG_PVR */
3071 case MP_CMD_TV_SET_NORM
:
3072 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3073 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3077 case MP_CMD_TV_STEP_CHANNEL
:{
3078 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3079 int v
= cmd
->args
[0].v
.i
;
3081 tv_step_channel((tvi_handle_t
*) (mpctx
->
3085 tv_step_channel((tvi_handle_t
*) (mpctx
->
3089 if (tv_channel_list
) {
3090 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3091 "Channel: %s", tv_channel_current
->name
);
3092 //vo_osd_changed(OSDTYPE_SUBTITLE);
3096 else if (mpctx
->stream
&&
3097 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3098 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3099 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3100 pvr_get_current_channelname (mpctx
->stream
),
3101 pvr_get_current_stationname (mpctx
->stream
));
3103 #endif /* CONFIG_PVR */
3106 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3108 int v
= cmd
->args
[0].v
.i
;
3110 mpctx
->last_dvb_step
= v
;
3112 dir
= DVB_CHANNEL_HIGHER
;
3114 dir
= DVB_CHANNEL_LOWER
;
3117 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3118 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3119 mpctx
->dvbin_reopen
= 1;
3122 #endif /* CONFIG_DVBIN */
3125 case MP_CMD_TV_SET_CHANNEL
:
3126 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3127 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3129 if (tv_channel_list
) {
3130 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3131 "Channel: %s", tv_channel_current
->name
);
3132 //vo_osd_changed(OSDTYPE_SUBTITLE);
3136 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3137 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3138 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3139 pvr_get_current_channelname (mpctx
->stream
),
3140 pvr_get_current_stationname (mpctx
->stream
));
3142 #endif /* CONFIG_PVR */
3146 case MP_CMD_DVB_SET_CHANNEL
:
3147 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3148 mpctx
->last_dvb_step
= 1;
3150 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3151 cmd
->args
[0].v
.i
)) {
3152 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3153 mpctx
->dvbin_reopen
= 1;
3157 #endif /* CONFIG_DVBIN */
3159 case MP_CMD_TV_LAST_CHANNEL
:
3160 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3161 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3162 if (tv_channel_list
) {
3163 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3164 "Channel: %s", tv_channel_current
->name
);
3165 //vo_osd_changed(OSDTYPE_SUBTITLE);
3169 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3170 pvr_set_lastchannel (mpctx
->stream
);
3171 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3172 pvr_get_current_channelname (mpctx
->stream
),
3173 pvr_get_current_stationname (mpctx
->stream
));
3175 #endif /* CONFIG_PVR */
3178 case MP_CMD_TV_STEP_NORM
:
3179 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3180 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3183 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3184 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3185 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3187 #endif /* CONFIG_TV */
3188 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3190 if (mpctx
->demuxer
->teletext
)
3191 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3192 &(cmd
->args
[0].v
.s
));
3195 case MP_CMD_TV_TELETEXT_GO_LINK
:
3197 if (mpctx
->demuxer
->teletext
)
3198 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3199 &(cmd
->args
[0].v
.i
));
3203 case MP_CMD_SUB_LOAD
:
3205 int n
= mpctx
->set_of_sub_size
;
3206 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3207 if (n
!= mpctx
->set_of_sub_size
) {
3208 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3209 ++mpctx
->global_sub_size
;
3214 case MP_CMD_SUB_REMOVE
:
3216 int v
= cmd
->args
[0].v
.i
;
3218 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3219 } else if (v
< mpctx
->set_of_sub_size
) {
3220 remove_subtitle_range(mpctx
, v
, 1);
3225 case MP_CMD_GET_SUB_VISIBILITY
:
3227 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3228 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3232 case MP_CMD_SCREENSHOT
:
3233 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3234 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3236 ((vf_instance_t
*) sh_video
->vfilter
)->
3237 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3239 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3243 case MP_CMD_VF_CHANGE_RECTANGLE
:
3246 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3249 case MP_CMD_GET_TIME_LENGTH
:{
3250 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3251 demuxer_get_time_length(mpctx
->demuxer
));
3255 case MP_CMD_GET_FILENAME
:{
3256 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3257 get_metadata(mpctx
, META_NAME
));
3261 case MP_CMD_GET_VIDEO_CODEC
:{
3262 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3265 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3270 case MP_CMD_GET_VIDEO_BITRATE
:{
3271 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3274 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3279 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3280 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3283 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3284 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3289 case MP_CMD_GET_AUDIO_CODEC
:{
3290 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3293 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3298 case MP_CMD_GET_AUDIO_BITRATE
:{
3299 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3302 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3307 case MP_CMD_GET_AUDIO_SAMPLES
:{
3308 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3311 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3316 case MP_CMD_GET_META_TITLE
:{
3317 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3320 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3325 case MP_CMD_GET_META_ARTIST
:{
3326 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3329 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3334 case MP_CMD_GET_META_ALBUM
:{
3335 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3338 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3343 case MP_CMD_GET_META_YEAR
:{
3344 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3347 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3352 case MP_CMD_GET_META_COMMENT
:{
3353 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3356 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3361 case MP_CMD_GET_META_TRACK
:{
3362 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3365 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3370 case MP_CMD_GET_META_GENRE
:{
3371 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3374 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3379 case MP_CMD_GET_VO_FULLSCREEN
:
3380 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3381 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3384 case MP_CMD_GET_PERCENT_POS
:
3385 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3386 demuxer_get_percent_pos(mpctx
->demuxer
));
3389 case MP_CMD_GET_TIME_POS
:{
3392 pos
= sh_video
->pts
;
3393 else if (sh_audio
&& mpctx
->audio_out
)
3394 pos
= playing_audio_pts(mpctx
);
3395 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3402 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3408 case MP_CMD_KEYDOWN_EVENTS
:
3409 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3412 case MP_CMD_SET_MOUSE_POS
:{
3413 int pointer_x
, pointer_y
;
3415 pointer_x
= cmd
->args
[0].v
.i
;
3416 pointer_y
= cmd
->args
[1].v
.i
;
3417 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3418 #ifdef CONFIG_DVDNAV
3419 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3420 && dx
> 0.0 && dy
> 0.0) {
3422 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3423 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3424 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3425 pointer_x
, pointer_y
, &button
);
3426 if (opts
->osd_level
> 1 && button
> 0)
3427 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3428 "Selected button number %d", button
);
3432 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3433 menu_update_mouse_pos(dx
, dy
);
3438 #ifdef CONFIG_DVDNAV
3439 case MP_CMD_DVDNAV
:{
3442 mp_command_type command
= 0;
3443 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3446 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3447 if (cmd
->args
[0].v
.s
&&
3448 !strcasecmp (cmd
->args
[0].v
.s
,
3449 mp_dvdnav_bindings
[i
].name
))
3450 command
= mp_dvdnav_bindings
[i
].cmd
;
3452 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3453 if (opts
->osd_level
> 1 && button
> 0)
3454 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3455 "Selected button number %d", button
);
3459 case MP_CMD_SWITCH_TITLE
:
3460 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3461 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3466 case MP_CMD_AF_SWITCH
:
3469 af_uninit(mpctx
->mixer
.afilter
);
3470 af_init(mpctx
->mixer
.afilter
);
3477 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3478 char* af_commands
= af_args
;
3481 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3483 if (cmd
->id
== MP_CMD_AF_DEL
)
3485 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3487 af_remove(mpctx
->mixer
.afilter
, af
);
3490 af_add(mpctx
->mixer
.afilter
, af_command
);
3492 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3499 af_uninit(mpctx
->mixer
.afilter
);
3500 af_init(mpctx
->mixer
.afilter
);
3501 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3504 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3505 "Received unknown cmd %s\n", cmd
->name
);
3508 switch (cmd
->pausing
) {
3509 case 1: // "pausing"
3510 pause_player(mpctx
);
3512 case 3: // "pausing_toggle"
3514 unpause_player(mpctx
);
3516 pause_player(mpctx
);