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 *(const 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
;
1181 static int mp_property_capture(m_option_t
*prop
, int action
,
1182 void *arg
, MPContext
*mpctx
)
1184 struct MPOpts
*opts
= &mpctx
->opts
;
1187 return M_PROPERTY_UNAVAILABLE
;
1189 if (!opts
->capture_dump
) {
1190 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1191 "Capturing not enabled (forgot -capture parameter?)\n");
1192 return M_PROPERTY_ERROR
;
1195 int capturing
= !!mpctx
->stream
->capture_file
;
1197 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1198 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1200 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1201 if (!mpctx
->stream
->capture_file
) {
1202 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1203 "Error opening capture file: %s\n", strerror(errno
));
1204 ret
= M_PROPERTY_ERROR
;
1207 fclose(mpctx
->stream
->capture_file
);
1208 mpctx
->stream
->capture_file
= NULL
;
1216 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1220 if (!mpctx
->video_out
1221 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1222 return M_PROPERTY_UNAVAILABLE
;
1225 case M_PROPERTY_SET
:
1227 return M_PROPERTY_ERROR
;
1228 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1229 vo_panscan
= *(float *) arg
;
1230 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1231 return M_PROPERTY_OK
;
1232 case M_PROPERTY_STEP_UP
:
1233 case M_PROPERTY_STEP_DOWN
:
1234 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1235 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1238 else if (vo_panscan
< 0)
1240 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1241 return M_PROPERTY_OK
;
1243 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1247 /// Helper to set vo flags.
1248 /** \ingroup PropertyImplHelper
1250 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1251 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1254 if (!mpctx
->video_out
)
1255 return M_PROPERTY_UNAVAILABLE
;
1258 case M_PROPERTY_SET
:
1260 return M_PROPERTY_ERROR
;
1261 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1262 if (*vo_var
== !!*(int *) arg
)
1263 return M_PROPERTY_OK
;
1264 case M_PROPERTY_STEP_UP
:
1265 case M_PROPERTY_STEP_DOWN
:
1266 if (mpctx
->video_out
->config_ok
)
1267 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1268 return M_PROPERTY_OK
;
1270 return m_property_flag(prop
, action
, arg
, vo_var
);
1274 /// Window always on top (RW)
1275 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1278 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1279 &mpctx
->opts
.vo_ontop
, mpctx
);
1282 /// Display in the root window (RW)
1283 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1286 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1287 &vo_rootwin
, mpctx
);
1290 /// Show window borders (RW)
1291 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1294 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1298 /// Framedropping state (RW)
1299 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1300 void *arg
, MPContext
*mpctx
)
1303 if (!mpctx
->sh_video
)
1304 return M_PROPERTY_UNAVAILABLE
;
1307 case M_PROPERTY_PRINT
:
1309 return M_PROPERTY_ERROR
;
1310 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1311 (frame_dropping
== 2 ? mp_gtext("hard") :
1312 mp_gtext("disabled")));
1313 return M_PROPERTY_OK
;
1315 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1319 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1320 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1323 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1326 if (!mpctx
->sh_video
)
1327 return M_PROPERTY_UNAVAILABLE
;
1329 if (gamma
[0] == 1000) {
1331 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1335 case M_PROPERTY_SET
:
1337 return M_PROPERTY_ERROR
;
1338 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1339 *gamma
= *(int *) arg
;
1340 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1344 case M_PROPERTY_GET
:
1345 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1347 return M_PROPERTY_ERROR
;
1349 return M_PROPERTY_OK
;
1352 case M_PROPERTY_STEP_UP
:
1353 case M_PROPERTY_STEP_DOWN
:
1354 *gamma
+= (arg
? *(int *) arg
: 1) *
1355 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1356 M_PROPERTY_CLAMP(prop
, *gamma
);
1357 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1362 return M_PROPERTY_NOT_IMPLEMENTED
;
1366 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1367 int l
= strlen(prop
->name
);
1368 char tv_prop
[3 + l
+ 1];
1369 sprintf(tv_prop
, "tv_%s", prop
->name
);
1370 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1374 return M_PROPERTY_UNAVAILABLE
;
1378 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1381 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1384 /// Video codec tag (RO)
1385 static int mp_property_video_format(m_option_t
*prop
, int action
,
1386 void *arg
, MPContext
*mpctx
)
1389 if (!mpctx
->sh_video
)
1390 return M_PROPERTY_UNAVAILABLE
;
1392 case M_PROPERTY_PRINT
:
1394 return M_PROPERTY_ERROR
;
1395 switch(mpctx
->sh_video
->format
) {
1397 meta
= strdup ("mpeg1"); break;
1399 meta
= strdup ("mpeg2"); break;
1401 meta
= strdup ("mpeg4"); break;
1403 meta
= strdup ("h264"); break;
1405 if(mpctx
->sh_video
->format
>= 0x20202020) {
1407 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1410 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1413 *(char**)arg
= meta
;
1414 return M_PROPERTY_OK
;
1416 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1419 /// Video codec name (RO)
1420 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1421 void *arg
, MPContext
*mpctx
)
1423 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1424 return M_PROPERTY_UNAVAILABLE
;
1425 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1429 /// Video bitrate (RO)
1430 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1431 void *arg
, MPContext
*mpctx
)
1433 if (!mpctx
->sh_video
)
1434 return M_PROPERTY_UNAVAILABLE
;
1435 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1438 /// Video display width (RO)
1439 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1442 if (!mpctx
->sh_video
)
1443 return M_PROPERTY_UNAVAILABLE
;
1444 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1447 /// Video display height (RO)
1448 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1451 if (!mpctx
->sh_video
)
1452 return M_PROPERTY_UNAVAILABLE
;
1453 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1457 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1460 if (!mpctx
->sh_video
)
1461 return M_PROPERTY_UNAVAILABLE
;
1462 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1465 /// Video aspect (RO)
1466 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1469 if (!mpctx
->sh_video
)
1470 return M_PROPERTY_UNAVAILABLE
;
1471 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1476 /// \defgroup SubProprties Subtitles properties
1477 /// \ingroup Properties
1480 /// Text subtitle position (RW)
1481 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1485 case M_PROPERTY_SET
:
1487 return M_PROPERTY_ERROR
;
1488 case M_PROPERTY_STEP_UP
:
1489 case M_PROPERTY_STEP_DOWN
:
1490 vo_osd_changed(OSDTYPE_SUBTITLE
);
1492 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1496 /// Selected subtitles (RW)
1497 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1500 struct MPOpts
*opts
= &mpctx
->opts
;
1501 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1502 int source
= -1, reset_spu
= 0;
1503 int source_pos
= -1;
1506 update_global_sub_size(mpctx
);
1507 const int global_sub_size
= mpctx
->global_sub_size
;
1509 if (global_sub_size
<= 0)
1510 return M_PROPERTY_UNAVAILABLE
;
1513 case M_PROPERTY_GET
:
1515 return M_PROPERTY_ERROR
;
1516 *(int *) arg
= mpctx
->global_sub_pos
;
1517 return M_PROPERTY_OK
;
1518 case M_PROPERTY_PRINT
:
1520 return M_PROPERTY_ERROR
;
1521 *(char **) arg
= malloc(64);
1522 (*(char **) arg
)[63] = 0;
1525 sub_name
= subdata
->filename
;
1527 if (ass_track
&& ass_track
->name
)
1528 sub_name
= ass_track
->name
;
1533 if ((tmp2
= strrchr(tmp
, '/')))
1536 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1537 mpctx
->set_of_sub_pos
+ 1,
1538 strlen(tmp
) < 20 ? "" : "...",
1539 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1540 return M_PROPERTY_OK
;
1542 #ifdef CONFIG_DVDNAV
1543 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1544 if (vo_spudec
&& opts
->sub_id
>= 0) {
1545 unsigned char lang
[3];
1546 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1547 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1548 return M_PROPERTY_OK
;
1554 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1555 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1556 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1557 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1558 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1559 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1560 if (!lang
) lang
= mp_gtext("unknown");
1561 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1562 return M_PROPERTY_OK
;
1565 if (vo_vobsub
&& vobsub_id
>= 0) {
1566 const char *language
= mp_gtext("unknown");
1567 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1568 snprintf(*(char **) arg
, 63, "(%d) %s",
1569 vobsub_id
, language
? language
: mp_gtext("unknown"));
1570 return M_PROPERTY_OK
;
1572 #ifdef CONFIG_DVDREAD
1573 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1574 && opts
->sub_id
>= 0) {
1576 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1577 lang
[0] = code
>> 8;
1580 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1581 return M_PROPERTY_OK
;
1584 if (opts
->sub_id
>= 0) {
1585 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1586 mp_gtext("unknown"));
1587 return M_PROPERTY_OK
;
1589 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1590 return M_PROPERTY_OK
;
1592 case M_PROPERTY_SET
:
1594 return M_PROPERTY_ERROR
;
1595 if (*(int *) arg
< -1)
1597 else if (*(int *) arg
>= global_sub_size
)
1598 *(int *) arg
= global_sub_size
- 1;
1599 mpctx
->global_sub_pos
= *(int *) arg
;
1601 case M_PROPERTY_STEP_UP
:
1602 mpctx
->global_sub_pos
+= 2;
1603 mpctx
->global_sub_pos
=
1604 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1606 case M_PROPERTY_STEP_DOWN
:
1607 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1608 mpctx
->global_sub_pos
=
1609 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1612 return M_PROPERTY_NOT_IMPLEMENTED
;
1615 if (mpctx
->global_sub_pos
>= 0) {
1616 source
= sub_source(mpctx
);
1617 source_pos
= sub_source_pos(mpctx
);
1620 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1621 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1623 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1624 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1625 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1626 mpctx
->global_sub_pos
, source
);
1628 mpctx
->set_of_sub_pos
= -1;
1642 if (source
== SUB_SOURCE_VOBSUB
) {
1643 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1644 } else if (source
== SUB_SOURCE_SUBS
) {
1645 mpctx
->set_of_sub_pos
= source_pos
;
1647 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1648 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1652 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1653 vo_osd_changed(OSDTYPE_SUBTITLE
);
1655 } else if (source
== SUB_SOURCE_DEMUX
) {
1656 opts
->sub_id
= source_pos
;
1657 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1659 // default: assume 1:1 mapping of sid and stream id
1660 d_sub
->id
= opts
->sub_id
;
1661 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1662 ds_free_packs(d_sub
);
1663 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1664 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1665 if (sh
&& sh
->sid
== opts
->sub_id
) {
1671 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1672 sh_sub_t
*sh
= d_sub
->sh
;
1673 if (sh
->type
== 'v')
1674 init_vo_spudec(mpctx
);
1676 else if (opts
->ass_enabled
)
1677 ass_track
= sh
->ass_track
;
1685 #ifdef CONFIG_DVDREAD
1687 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1688 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1689 && opts
->sub_id
< 0 && reset_spu
) {
1695 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1697 return M_PROPERTY_OK
;
1700 /// Selected sub source (RW)
1701 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1705 update_global_sub_size(mpctx
);
1706 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1707 return M_PROPERTY_UNAVAILABLE
;
1710 case M_PROPERTY_GET
:
1712 return M_PROPERTY_ERROR
;
1713 *(int *) arg
= sub_source(mpctx
);
1714 return M_PROPERTY_OK
;
1715 case M_PROPERTY_PRINT
:
1717 return M_PROPERTY_ERROR
;
1718 *(char **) arg
= malloc(64);
1719 (*(char **) arg
)[63] = 0;
1720 switch (sub_source(mpctx
))
1722 case SUB_SOURCE_SUBS
:
1723 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1725 case SUB_SOURCE_VOBSUB
:
1726 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1728 case SUB_SOURCE_DEMUX
:
1729 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1732 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1734 return M_PROPERTY_OK
;
1735 case M_PROPERTY_SET
:
1737 return M_PROPERTY_ERROR
;
1738 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1739 if (*(int *) arg
< 0)
1740 mpctx
->global_sub_pos
= -1;
1741 else if (*(int *) arg
!= sub_source(mpctx
)) {
1742 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1744 return M_PROPERTY_UNAVAILABLE
;
1745 mpctx
->global_sub_pos
= new_pos
;
1748 case M_PROPERTY_STEP_UP
:
1749 case M_PROPERTY_STEP_DOWN
: {
1750 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1751 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1752 int step
= (step_all
> 0) ? 1 : -1;
1753 int cur_source
= sub_source(mpctx
);
1754 source
= cur_source
;
1757 if (source
>= SUB_SOURCES
)
1759 else if (source
< -1)
1760 source
= SUB_SOURCES
- 1;
1761 if (source
== cur_source
|| source
== -1 ||
1762 mpctx
->sub_counts
[source
])
1765 if (source
== cur_source
)
1766 return M_PROPERTY_OK
;
1768 mpctx
->global_sub_pos
= -1;
1770 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1774 return M_PROPERTY_NOT_IMPLEMENTED
;
1776 --mpctx
->global_sub_pos
;
1777 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1780 /// Selected subtitles from specific source (RW)
1781 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1784 int source
, is_cur_source
, offset
, new_pos
;
1785 update_global_sub_size(mpctx
);
1786 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1787 return M_PROPERTY_UNAVAILABLE
;
1789 if (!strcmp(prop
->name
, "sub_file"))
1790 source
= SUB_SOURCE_SUBS
;
1791 else if (!strcmp(prop
->name
, "sub_vob"))
1792 source
= SUB_SOURCE_VOBSUB
;
1793 else if (!strcmp(prop
->name
, "sub_demux"))
1794 source
= SUB_SOURCE_DEMUX
;
1796 return M_PROPERTY_ERROR
;
1798 offset
= sub_pos_by_source(mpctx
, source
);
1800 return M_PROPERTY_UNAVAILABLE
;
1802 is_cur_source
= sub_source(mpctx
) == source
;
1803 new_pos
= mpctx
->global_sub_pos
;
1805 case M_PROPERTY_GET
:
1807 return M_PROPERTY_ERROR
;
1808 if (is_cur_source
) {
1809 *(int *) arg
= sub_source_pos(mpctx
);
1810 if (source
== SUB_SOURCE_VOBSUB
)
1811 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1815 return M_PROPERTY_OK
;
1816 case M_PROPERTY_PRINT
:
1818 return M_PROPERTY_ERROR
;
1820 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1821 *(char **) arg
= malloc(64);
1822 (*(char **) arg
)[63] = 0;
1823 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1824 return M_PROPERTY_OK
;
1825 case M_PROPERTY_SET
:
1827 return M_PROPERTY_ERROR
;
1828 if (*(int *) arg
>= 0) {
1829 int index
= *(int *)arg
;
1830 if (source
== SUB_SOURCE_VOBSUB
)
1831 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1832 new_pos
= offset
+ index
;
1833 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1841 case M_PROPERTY_STEP_UP
:
1842 case M_PROPERTY_STEP_DOWN
: {
1843 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1844 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1845 int step
= (step_all
> 0) ? 1 : -1;
1846 int max_sub_pos_for_source
= -1;
1850 if (new_pos
== -1) {
1853 else if (max_sub_pos_for_source
== -1) {
1854 // Find max pos for specific source
1855 new_pos
= mpctx
->global_sub_size
- 1;
1857 && sub_source(mpctx
) != source
)
1861 new_pos
= max_sub_pos_for_source
;
1865 if (new_pos
< offset
||
1866 new_pos
>= mpctx
->global_sub_size
||
1867 sub_source(mpctx
) != source
)
1875 return M_PROPERTY_NOT_IMPLEMENTED
;
1877 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1880 /// Subtitle delay (RW)
1881 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1884 if (!mpctx
->sh_video
)
1885 return M_PROPERTY_UNAVAILABLE
;
1886 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1889 /// Alignment of text subtitles (RW)
1890 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1891 void *arg
, MPContext
*mpctx
)
1893 char *name
[] = { _("top"), _("center"), _("bottom") };
1895 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1896 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1897 return M_PROPERTY_UNAVAILABLE
;
1900 case M_PROPERTY_PRINT
:
1902 return M_PROPERTY_ERROR
;
1903 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1904 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1905 return M_PROPERTY_OK
;
1906 case M_PROPERTY_SET
:
1908 return M_PROPERTY_ERROR
;
1909 case M_PROPERTY_STEP_UP
:
1910 case M_PROPERTY_STEP_DOWN
:
1911 vo_osd_changed(OSDTYPE_SUBTITLE
);
1913 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1917 /// Subtitle visibility (RW)
1918 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1919 void *arg
, MPContext
*mpctx
)
1921 if (!mpctx
->sh_video
)
1922 return M_PROPERTY_UNAVAILABLE
;
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 vo_osd_changed(OSDTYPE_SPU
);
1934 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1939 /// Use margins for libass subtitles (RW)
1940 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1941 void *arg
, MPContext
*mpctx
)
1943 if (!mpctx
->sh_video
)
1944 return M_PROPERTY_UNAVAILABLE
;
1947 case M_PROPERTY_SET
:
1949 return M_PROPERTY_ERROR
;
1950 case M_PROPERTY_STEP_UP
:
1951 case M_PROPERTY_STEP_DOWN
:
1952 ass_force_reload
= 1;
1954 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1959 /// Show only forced subtitles (RW)
1960 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1961 void *arg
, MPContext
*mpctx
)
1964 return M_PROPERTY_UNAVAILABLE
;
1967 case M_PROPERTY_SET
:
1969 return M_PROPERTY_ERROR
;
1970 case M_PROPERTY_STEP_UP
:
1971 case M_PROPERTY_STEP_DOWN
:
1972 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1973 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1974 return M_PROPERTY_OK
;
1976 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1981 #ifdef CONFIG_FREETYPE
1982 /// Subtitle scale (RW)
1983 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1986 struct MPOpts
*opts
= &mpctx
->opts
;
1989 case M_PROPERTY_SET
:
1991 return M_PROPERTY_ERROR
;
1992 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1994 if (opts
->ass_enabled
) {
1995 ass_font_scale
= *(float *) arg
;
1996 ass_force_reload
= 1;
1999 text_font_scale_factor
= *(float *) arg
;
2000 force_load_font
= 1;
2001 return M_PROPERTY_OK
;
2002 case M_PROPERTY_STEP_UP
:
2003 case M_PROPERTY_STEP_DOWN
:
2005 if (opts
->ass_enabled
) {
2006 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
2007 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2008 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
2009 ass_force_reload
= 1;
2012 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
2013 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2014 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2015 force_load_font
= 1;
2016 return M_PROPERTY_OK
;
2019 if (opts
->ass_enabled
)
2020 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
2023 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2030 /// \defgroup TVProperties TV properties
2031 /// \ingroup Properties
2036 /// TV color settings (RW)
2037 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2041 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2042 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2043 return M_PROPERTY_UNAVAILABLE
;
2046 case M_PROPERTY_SET
:
2048 return M_PROPERTY_ERROR
;
2049 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2050 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2051 case M_PROPERTY_GET
:
2052 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2053 case M_PROPERTY_STEP_UP
:
2054 case M_PROPERTY_STEP_DOWN
:
2055 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2057 return M_PROPERTY_ERROR
;
2058 val
+= (arg
? *(int *) arg
: 1) *
2059 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2060 M_PROPERTY_CLAMP(prop
, val
);
2061 return tv_set_color_options(tvh
, prop
->offset
, val
);
2063 return M_PROPERTY_ERROR
;
2065 return M_PROPERTY_NOT_IMPLEMENTED
;
2070 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2074 int base_ioctl
= prop
->offset
;
2076 for teletext's GET,SET,STEP ioctls this is not 0
2080 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2081 return M_PROPERTY_UNAVAILABLE
;
2083 return M_PROPERTY_ERROR
;
2086 case M_PROPERTY_GET
:
2088 return M_PROPERTY_ERROR
;
2089 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2091 case M_PROPERTY_SET
:
2093 return M_PROPERTY_ERROR
;
2094 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2095 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2097 case M_PROPERTY_STEP_UP
:
2098 case M_PROPERTY_STEP_DOWN
:
2099 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2100 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2101 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2104 return M_PROPERTY_NOT_IMPLEMENTED
;
2107 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2110 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2116 //with tvh==NULL will fail too
2117 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2118 if(result
!=M_PROPERTY_OK
)
2121 if(teletext_control(mpctx
->demuxer
->teletext
,
2122 prop
->offset
, &val
)==VBI_CONTROL_TRUE
&& val
)
2123 mp_input_set_section(mpctx
->input
, "teletext");
2125 mp_input_set_section(mpctx
->input
, "tv");
2126 return M_PROPERTY_OK
;
2129 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2134 if (!mpctx
->demuxer
->teletext
)
2135 return M_PROPERTY_UNAVAILABLE
;
2137 case M_PROPERTY_STEP_UP
:
2138 case M_PROPERTY_STEP_DOWN
:
2139 //This should be handled separately
2140 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2141 result
=teletext_control(mpctx
->demuxer
->teletext
,
2142 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2145 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2152 /// All properties available in MPlayer.
2153 /** \ingroup Properties
2155 static const m_option_t mp_properties
[] = {
2157 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2158 M_OPT_RANGE
, 0, 3, NULL
},
2159 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2160 M_OPT_MIN
, -1, 0, NULL
},
2161 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2162 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2163 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2165 { "path", mp_property_path
, CONF_TYPE_STRING
,
2167 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2169 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2170 M_OPT_MIN
, 0, 0, NULL
},
2171 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2172 M_OPT_MIN
, 0, 0, NULL
},
2173 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2174 M_OPT_MIN
, 0, 0, NULL
},
2175 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2176 M_OPT_MIN
, 0, 0, NULL
},
2177 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2178 M_OPT_MIN
, 0, 0, NULL
},
2179 { "length", mp_property_length
, CONF_TYPE_TIME
,
2180 M_OPT_MIN
, 0, 0, NULL
},
2181 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2182 M_OPT_RANGE
, 0, 100, NULL
},
2183 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2184 M_OPT_MIN
, 0, 0, NULL
},
2185 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2186 M_OPT_MIN
, 0, 0, NULL
},
2187 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2189 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2190 CONF_RANGE
, -2, 10, NULL
},
2191 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2193 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2194 M_OPT_RANGE
, 0, 1, NULL
},
2195 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2196 M_OPT_RANGE
, 0, 1, NULL
},
2199 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2200 M_OPT_RANGE
, 0, 100, NULL
},
2201 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2202 M_OPT_RANGE
, 0, 1, NULL
},
2203 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2204 M_OPT_RANGE
, -100, 100, NULL
},
2205 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2207 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2209 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2211 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2213 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2215 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2216 CONF_RANGE
, -2, 65535, NULL
},
2217 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2218 M_OPT_RANGE
, -1, 1, NULL
},
2221 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2222 M_OPT_RANGE
, 0, 1, NULL
},
2223 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2224 M_OPT_RANGE
, 0, 1, NULL
},
2225 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2226 M_OPT_RANGE
, 0, 2, NULL
},
2227 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2228 M_OPT_RANGE
, 0, 1, NULL
},
2229 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2230 M_OPT_RANGE
, 0, 1, NULL
},
2231 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2232 M_OPT_RANGE
, 0, 1, NULL
},
2233 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2234 M_OPT_RANGE
, 0, 2, NULL
},
2235 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2236 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_gamma
)},
2237 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2238 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_brightness
) },
2239 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2240 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_contrast
) },
2241 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2242 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_saturation
) },
2243 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2244 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_hue
) },
2245 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2246 M_OPT_RANGE
, 0, 1, NULL
},
2247 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2248 M_OPT_RANGE
, 0, 1, NULL
},
2249 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2251 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2253 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2255 { "width", mp_property_width
, CONF_TYPE_INT
,
2257 { "height", mp_property_height
, CONF_TYPE_INT
,
2259 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2261 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2263 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2264 CONF_RANGE
, -2, 65535, NULL
},
2265 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2266 CONF_RANGE
, -1, 65535, NULL
},
2269 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2270 M_OPT_MIN
, -1, 0, NULL
},
2271 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2272 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2273 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2274 M_OPT_MIN
, -1, 0, NULL
},
2275 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2276 M_OPT_MIN
, -1, 0, NULL
},
2277 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2278 M_OPT_MIN
, -1, 0, NULL
},
2279 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2281 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2282 M_OPT_RANGE
, 0, 100, NULL
},
2283 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2284 M_OPT_RANGE
, 0, 2, NULL
},
2285 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2286 M_OPT_RANGE
, 0, 1, NULL
},
2287 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2288 M_OPT_RANGE
, 0, 1, NULL
},
2289 #ifdef CONFIG_FREETYPE
2290 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2291 M_OPT_RANGE
, 0, 100, NULL
},
2294 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2295 M_OPT_RANGE
, 0, 1, NULL
},
2299 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2300 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_BRIGHTNESS
},
2301 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2302 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_CONTRAST
},
2303 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2304 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_SATURATION
},
2305 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2306 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_HUE
},
2308 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2309 M_OPT_RANGE
, 100, 899, .offset
=TV_VBI_CONTROL_GET_PAGE
},
2310 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2311 M_OPT_RANGE
, 0, 64, .offset
=TV_VBI_CONTROL_GET_SUBPAGE
},
2312 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2313 M_OPT_RANGE
, 0, 1, .offset
=TV_VBI_CONTROL_GET_MODE
},
2314 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2315 M_OPT_RANGE
, 0, 3, .offset
=TV_VBI_CONTROL_GET_FORMAT
},
2316 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2317 M_OPT_RANGE
, 0, 2, .offset
=TV_VBI_CONTROL_GET_HALF_PAGE
},
2318 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2322 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2324 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2327 char* mp_property_print(const char *name
, void* ctx
)
2330 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2335 char *property_expand_string(MPContext
*mpctx
, char *str
)
2337 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2340 void property_print_help(void)
2342 m_properties_print_help_list(mp_properties
);
2346 /* List of default ways to show a property on OSD.
2348 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2349 * a bar showing the current position between min/max values of the
2350 * property. In this case osd_msg is only used for terminal output
2351 * if there is no video; it'll be a label shown together with percentage.
2353 * Otherwise setting osd_msg will show the string on OSD, formatted with
2354 * the text value of the property as argument.
2356 static struct property_osd_display
{
2359 /// progressbar type
2360 int osd_progbar
; // -1 is special value for seek indicators
2361 /// osd msg id if it must be shared
2363 /// osd msg template
2364 const char *osd_msg
;
2365 } property_osd_display
[] = {
2367 { "loop", 0, -1, _("Loop: %s") },
2368 { "chapter", -1, -1, NULL
},
2369 { "capturing", 0, -1, _("Capturing: %s") },
2371 { "volume", OSD_VOLUME
, -1, _("Volume") },
2372 { "mute", 0, -1, _("Mute: %s") },
2373 { "audio_delay", 0, -1, _("A-V delay: %s") },
2374 { "switch_audio", 0, -1, _("Audio: %s") },
2375 { "balance", OSD_BALANCE
, -1, _("Balance") },
2377 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2378 { "ontop", 0, -1, _("Stay on top: %s") },
2379 { "rootwin", 0, -1, _("Rootwin: %s") },
2380 { "border", 0, -1, _("Border: %s") },
2381 { "framedropping", 0, -1, _("Framedropping: %s") },
2382 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2383 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2384 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2385 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2386 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2387 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2388 { "hue", OSD_HUE
, -1, _("Hue") },
2389 { "vsync", 0, -1, _("VSync: %s") },
2391 { "sub", 0, -1, _("Subtitles: %s") },
2392 { "sub_source", 0, -1, _("Sub source: %s") },
2393 { "sub_vob", 0, -1, _("Subtitles: %s") },
2394 { "sub_demux", 0, -1, _("Subtitles: %s") },
2395 { "sub_file", 0, -1, _("Subtitles: %s") },
2396 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2397 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2398 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2399 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2400 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2401 #ifdef CONFIG_FREETYPE
2402 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2405 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2406 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2407 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2408 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2413 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2415 struct MPOpts
*opts
= &mpctx
->opts
;
2418 struct property_osd_display
*p
;
2420 // look for the command
2421 for (p
= property_osd_display
; p
->name
; p
++)
2422 if (!strcmp(p
->name
, pname
))
2427 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2430 if (p
->osd_progbar
== -1)
2431 mpctx
->add_osd_seek_info
= true;
2432 else if (p
->osd_progbar
) {
2433 if (prop
->type
== CONF_TYPE_INT
) {
2434 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2435 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2436 prop
->min
, prop
->max
, r
);
2437 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2439 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2440 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2441 prop
->min
, prop
->max
, f
);
2443 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2444 "Property use an unsupported type.\n");
2451 char *val
= mp_property_print(pname
, mpctx
);
2453 int index
= p
- property_osd_display
;
2454 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2455 1, opts
->osd_duration
, p
->osd_msg
, val
);
2464 * \defgroup Command2Property Command to property bridge
2466 * It is used to handle most commands that just set a property
2467 * and optionally display something on the OSD.
2468 * Two kinds of commands are handled: adjust or toggle.
2470 * Adjust commands take 1 or 2 parameters: <value> <abs>
2471 * If <abs> is non-zero the property is set to the given value
2472 * otherwise it is adjusted.
2474 * Toggle commands take 0 or 1 parameters. With no parameter
2475 * or a value less than the property minimum it just steps the
2476 * property to its next value. Otherwise it sets it to the given
2482 /// List of the commands that can be handled by setting a property.
2488 /// set/adjust or toggle command
2490 } set_prop_cmd
[] = {
2492 { "loop", MP_CMD_LOOP
, 0},
2493 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2494 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2495 { "pause", MP_CMD_PAUSE
, 0},
2496 { "capturing", MP_CMD_CAPTURING
, 1},
2498 { "volume", MP_CMD_VOLUME
, 0},
2499 { "mute", MP_CMD_MUTE
, 1},
2500 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2501 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2502 { "balance", MP_CMD_BALANCE
, 0},
2504 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2505 { "panscan", MP_CMD_PANSCAN
, 0},
2506 { "ontop", MP_CMD_VO_ONTOP
, 1},
2507 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2508 { "border", MP_CMD_VO_BORDER
, 1},
2509 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2510 { "gamma", MP_CMD_GAMMA
, 0},
2511 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2512 { "contrast", MP_CMD_CONTRAST
, 0},
2513 { "saturation", MP_CMD_SATURATION
, 0},
2514 { "hue", MP_CMD_HUE
, 0},
2515 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2517 { "sub", MP_CMD_SUB_SELECT
, 1},
2518 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2519 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2520 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2521 { "sub_file", MP_CMD_SUB_FILE
, 1},
2522 { "sub_pos", MP_CMD_SUB_POS
, 0},
2523 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2524 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2525 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2526 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2527 #ifdef CONFIG_FREETYPE
2528 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2531 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2534 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2535 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2536 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2537 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2542 /// Handle commands that set a property.
2543 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2549 // look for the command
2550 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2551 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2553 if (!(pname
= set_prop_cmd
[i
].name
))
2556 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2560 if (set_prop_cmd
[i
].toggle
) {
2562 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2563 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2565 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2566 } else if (cmd
->args
[1].v
.i
) //set
2567 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2569 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2574 show_property_osd(mpctx
, pname
);
2579 #ifdef CONFIG_DVDNAV
2580 static const struct {
2582 const mp_command_type cmd
;
2583 } mp_dvdnav_bindings
[] = {
2584 { "up", MP_CMD_DVDNAV_UP
},
2585 { "down", MP_CMD_DVDNAV_DOWN
},
2586 { "left", MP_CMD_DVDNAV_LEFT
},
2587 { "right", MP_CMD_DVDNAV_RIGHT
},
2588 { "menu", MP_CMD_DVDNAV_MENU
},
2589 { "select", MP_CMD_DVDNAV_SELECT
},
2590 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2591 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2594 * keep old dvdnav sub-command options for a while in order not to
2595 * break slave-mode API too suddenly.
2597 { "1", MP_CMD_DVDNAV_UP
},
2598 { "2", MP_CMD_DVDNAV_DOWN
},
2599 { "3", MP_CMD_DVDNAV_LEFT
},
2600 { "4", MP_CMD_DVDNAV_RIGHT
},
2601 { "5", MP_CMD_DVDNAV_MENU
},
2602 { "6", MP_CMD_DVDNAV_SELECT
},
2603 { "7", MP_CMD_DVDNAV_PREVMENU
},
2604 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2609 static const char *property_error_string(int error_value
)
2611 switch (error_value
) {
2612 case M_PROPERTY_ERROR
:
2614 case M_PROPERTY_UNAVAILABLE
:
2615 return "PROPERTY_UNAVAILABLE";
2616 case M_PROPERTY_NOT_IMPLEMENTED
:
2617 return "NOT_IMPLEMENTED";
2618 case M_PROPERTY_UNKNOWN
:
2619 return "PROPERTY_UNKNOWN";
2620 case M_PROPERTY_DISABLED
:
2626 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2629 int end
= start
+ count
;
2630 int after
= mpctx
->set_of_sub_size
- end
;
2631 sub_data
**subs
= mpctx
->set_of_subtitles
;
2633 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2635 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2636 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2637 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2638 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2641 for (idx
= start
; idx
< end
; idx
++) {
2642 sub_data
*subd
= subs
[idx
];
2643 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2644 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2645 filename_recode(subd
->filename
));
2649 if (ass_tracks
[idx
])
2650 ass_free_track(ass_tracks
[idx
]);
2651 ass_tracks
[idx
] = NULL
;
2655 mpctx
->global_sub_size
-= count
;
2656 mpctx
->set_of_sub_size
-= count
;
2657 if (mpctx
->set_of_sub_size
<= 0)
2658 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2660 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2661 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2663 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2664 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2667 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2668 mpctx
->global_sub_pos
= -2;
2673 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2674 } else if (mpctx
->set_of_sub_pos
>= end
) {
2675 mpctx
->set_of_sub_pos
-= count
;
2676 mpctx
->global_sub_pos
-= count
;
2680 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2682 struct MPOpts
*opts
= &mpctx
->opts
;
2683 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2684 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2685 int osd_duration
= opts
->osd_duration
;
2686 int case_fallthrough_hack
= 0;
2687 if (!set_property_command(mpctx
, cmd
))
2692 mpctx
->add_osd_seek_info
= true;
2693 v
= cmd
->args
[0].v
.f
;
2694 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2695 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2696 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2698 mpctx
->osd_function
=
2699 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2700 mpctx
->rel_seek_secs
= v
;
2701 } else if (abs
) { /* Absolute seek by percentage */
2702 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2704 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2705 mpctx
->rel_seek_secs
= v
/ 100.0;
2707 mpctx
->rel_seek_secs
+= v
;
2708 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2713 case MP_CMD_SET_PROPERTY_OSD
:
2714 case_fallthrough_hack
= 1;
2716 case MP_CMD_SET_PROPERTY
:{
2717 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2718 cmd
->args
[1].v
.s
, mpctx
);
2719 if (r
== M_PROPERTY_UNKNOWN
)
2720 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2721 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2723 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2724 "Failed to set property '%s' to '%s'.\n",
2725 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2726 else if (case_fallthrough_hack
)
2727 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2729 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2733 case MP_CMD_STEP_PROPERTY_OSD
:
2734 case_fallthrough_hack
= 1;
2736 case MP_CMD_STEP_PROPERTY
:{
2741 if (cmd
->args
[1].v
.f
) {
2743 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2744 M_PROPERTY_GET_TYPE
,
2745 &prop
, mpctx
)) <= 0)
2747 if(prop
->type
== CONF_TYPE_INT
||
2748 prop
->type
== CONF_TYPE_FLAG
)
2749 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2750 else if(prop
->type
== CONF_TYPE_FLOAT
)
2751 arg
= &cmd
->args
[1].v
.f
;
2752 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2753 prop
->type
== CONF_TYPE_TIME
)
2754 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2755 else if(prop
->type
== CONF_TYPE_POSITION
)
2756 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2758 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2759 "Ignoring step size stepping property '%s'.\n",
2762 r
= mp_property_do(cmd
->args
[0].v
.s
,
2763 cmd
->args
[2].v
.i
< 0 ?
2764 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2767 if (r
== M_PROPERTY_UNKNOWN
)
2768 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2769 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2771 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2772 "Failed to increment property '%s' by %f.\n",
2773 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2774 else if (case_fallthrough_hack
)
2775 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2777 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2781 case MP_CMD_GET_PROPERTY
:{
2783 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2786 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2787 "Failed to get value of property '%s'.\n",
2789 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2792 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2793 cmd
->args
[0].v
.s
, tmp
);
2798 case MP_CMD_EDL_MARK
:
2800 float v
= sh_video
? sh_video
->pts
:
2801 playing_audio_pts(mpctx
);
2802 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2803 mpctx
->begin_skip
= v
;
2804 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2806 if (mpctx
->begin_skip
> v
)
2807 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2809 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2810 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2812 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2817 case MP_CMD_SWITCH_RATIO
:
2820 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2821 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2823 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2824 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2827 case MP_CMD_SPEED_INCR
:{
2828 float v
= cmd
->args
[0].v
.f
;
2829 opts
->playback_speed
+= v
;
2830 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2831 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2832 opts
->playback_speed
);
2835 case MP_CMD_SPEED_MULT
:{
2836 float v
= cmd
->args
[0].v
.f
;
2837 opts
->playback_speed
*= v
;
2838 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2839 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2840 opts
->playback_speed
);
2843 case MP_CMD_SPEED_SET
:{
2844 float v
= cmd
->args
[0].v
.f
;
2845 opts
->playback_speed
= v
;
2846 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2847 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2848 opts
->playback_speed
);
2851 case MP_CMD_FRAME_STEP
:
2852 add_step_frame(mpctx
);
2855 case MP_CMD_FILE_FILTER
:
2856 file_filter
= cmd
->args
[0].v
.i
;
2860 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2861 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2863 case MP_CMD_PLAY_TREE_STEP
:{
2864 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2865 int force
= cmd
->args
[1].v
.i
;
2868 if (!force
&& mpctx
->playtree_iter
) {
2869 play_tree_iter_t
*i
=
2870 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2871 if (play_tree_iter_step(i
, n
, 0) ==
2872 PLAY_TREE_ITER_ENTRY
)
2874 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2875 play_tree_iter_free(i
);
2877 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2878 if (mpctx
->stop_play
)
2879 mpctx
->play_tree_step
= n
;
2884 case MP_CMD_PLAY_TREE_UP_STEP
:{
2885 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2886 int force
= cmd
->args
[1].v
.i
;
2888 if (!force
&& mpctx
->playtree_iter
) {
2889 play_tree_iter_t
*i
=
2890 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2891 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2892 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2893 play_tree_iter_free(i
);
2895 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2899 case MP_CMD_PLAY_ALT_SRC_STEP
:
2900 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2901 int v
= cmd
->args
[0].v
.i
;
2903 && mpctx
->playtree_iter
->file
<
2904 mpctx
->playtree_iter
->num_files
)
2905 mpctx
->stop_play
= PT_NEXT_SRC
;
2906 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2907 mpctx
->stop_play
= PT_PREV_SRC
;
2911 case MP_CMD_SUB_STEP
:
2913 int movement
= cmd
->args
[0].v
.i
;
2914 step_sub(subdata
, sh_video
->pts
, movement
);
2918 ass_step_sub(ass_track
,
2920 sub_delay
) * 1000 + .5, movement
) / 1000.;
2922 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2923 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2927 case MP_CMD_SUB_LOG
:
2932 int v
= cmd
->args
[0].v
.i
;
2934 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2935 if (opts
->osd_level
> max
)
2936 opts
->osd_level
= max
;
2938 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2940 opts
->osd_level
= v
> max
? max
: v
;
2941 /* Show OSD state when disabled, but not when an explicit
2942 argument is given to the OSD command, i.e. in slave mode. */
2943 if (v
== -1 && opts
->osd_level
<= 1)
2944 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2946 opts
->osd_level
? mp_gtext("enabled") :
2947 mp_gtext("disabled"));
2949 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2953 case MP_CMD_OSD_SHOW_TEXT
:
2954 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2956 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2957 "%-.63s", cmd
->args
[0].v
.s
);
2960 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2961 char *txt
= m_properties_expand_string(mp_properties
,
2964 /* if no argument supplied take default osd_duration, else <arg> ms. */
2966 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2968 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2975 case MP_CMD_LOADFILE
:{
2976 play_tree_t
*e
= play_tree_new();
2977 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2979 if (cmd
->args
[1].v
.i
) // append
2980 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2982 // Go back to the starting point.
2983 while (play_tree_iter_up_step
2984 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2986 play_tree_free_list(mpctx
->playtree
->child
, 1);
2987 play_tree_set_child(mpctx
->playtree
, e
);
2988 pt_iter_goto_head(mpctx
->playtree_iter
);
2989 mpctx
->stop_play
= PT_NEXT_SRC
;
2994 case MP_CMD_LOADLIST
:{
2995 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2997 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2998 "\nUnable to load playlist %s.\n", 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)
3006 != PLAY_TREE_ITER_END
)
3008 play_tree_free_list(mpctx
->playtree
->child
, 1);
3009 play_tree_set_child(mpctx
->playtree
, e
);
3010 pt_iter_goto_head(mpctx
->playtree_iter
);
3011 mpctx
->stop_play
= PT_NEXT_SRC
;
3018 // Go back to the starting point.
3019 while (play_tree_iter_up_step
3020 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3022 mpctx
->stop_play
= PT_STOP
;
3025 case MP_CMD_OSD_SHOW_PROGRESSION
:{
3026 int len
= demuxer_get_time_length(mpctx
->demuxer
);
3027 int pts
= demuxer_get_current_time(mpctx
->demuxer
);
3028 set_osd_bar(mpctx
, 0, "Position", 0, 100, demuxer_get_percent_pos(mpctx
->demuxer
));
3029 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3030 "%c %02d:%02d:%02d / %02d:%02d:%02d",
3031 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
3032 len
/3600, (len
/60)%60, len
%60);
3037 case MP_CMD_RADIO_STEP_CHANNEL
:
3038 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3039 int v
= cmd
->args
[0].v
.i
;
3041 radio_step_channel(mpctx
->demuxer
->stream
,
3042 RADIO_CHANNEL_HIGHER
);
3044 radio_step_channel(mpctx
->demuxer
->stream
,
3045 RADIO_CHANNEL_LOWER
);
3046 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3047 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3049 radio_get_channel_name(mpctx
->demuxer
->stream
));
3054 case MP_CMD_RADIO_SET_CHANNEL
:
3055 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3056 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3057 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3058 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3060 radio_get_channel_name(mpctx
->demuxer
->stream
));
3065 case MP_CMD_RADIO_SET_FREQ
:
3066 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3067 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3070 case MP_CMD_RADIO_STEP_FREQ
:
3071 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3072 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3077 case MP_CMD_TV_START_SCAN
:
3078 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3079 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3081 case MP_CMD_TV_SET_FREQ
:
3082 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3083 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3084 cmd
->args
[0].v
.f
* 16.0);
3086 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3087 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3088 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3089 pvr_get_current_channelname (mpctx
->stream
),
3090 pvr_get_current_stationname (mpctx
->stream
));
3092 #endif /* CONFIG_PVR */
3095 case MP_CMD_TV_STEP_FREQ
:
3096 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3097 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3098 cmd
->args
[0].v
.f
* 16.0);
3100 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3101 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3102 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3103 pvr_get_current_channelname (mpctx
->stream
),
3104 pvr_get_current_frequency (mpctx
->stream
));
3106 #endif /* CONFIG_PVR */
3109 case MP_CMD_TV_SET_NORM
:
3110 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3111 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3115 case MP_CMD_TV_STEP_CHANNEL
:{
3116 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3117 int v
= cmd
->args
[0].v
.i
;
3119 tv_step_channel((tvi_handle_t
*) (mpctx
->
3123 tv_step_channel((tvi_handle_t
*) (mpctx
->
3127 if (tv_channel_list
) {
3128 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3129 "Channel: %s", tv_channel_current
->name
);
3130 //vo_osd_changed(OSDTYPE_SUBTITLE);
3134 else if (mpctx
->stream
&&
3135 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3136 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3137 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3138 pvr_get_current_channelname (mpctx
->stream
),
3139 pvr_get_current_stationname (mpctx
->stream
));
3141 #endif /* CONFIG_PVR */
3144 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3146 int v
= cmd
->args
[0].v
.i
;
3148 mpctx
->last_dvb_step
= v
;
3150 dir
= DVB_CHANNEL_HIGHER
;
3152 dir
= DVB_CHANNEL_LOWER
;
3155 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3156 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3157 mpctx
->dvbin_reopen
= 1;
3160 #endif /* CONFIG_DVBIN */
3163 case MP_CMD_TV_SET_CHANNEL
:
3164 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3165 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3167 if (tv_channel_list
) {
3168 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3169 "Channel: %s", tv_channel_current
->name
);
3170 //vo_osd_changed(OSDTYPE_SUBTITLE);
3174 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3175 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3176 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3177 pvr_get_current_channelname (mpctx
->stream
),
3178 pvr_get_current_stationname (mpctx
->stream
));
3180 #endif /* CONFIG_PVR */
3184 case MP_CMD_DVB_SET_CHANNEL
:
3185 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3186 mpctx
->last_dvb_step
= 1;
3188 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3189 cmd
->args
[0].v
.i
)) {
3190 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3191 mpctx
->dvbin_reopen
= 1;
3195 #endif /* CONFIG_DVBIN */
3197 case MP_CMD_TV_LAST_CHANNEL
:
3198 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3199 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3200 if (tv_channel_list
) {
3201 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3202 "Channel: %s", tv_channel_current
->name
);
3203 //vo_osd_changed(OSDTYPE_SUBTITLE);
3207 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3208 pvr_set_lastchannel (mpctx
->stream
);
3209 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3210 pvr_get_current_channelname (mpctx
->stream
),
3211 pvr_get_current_stationname (mpctx
->stream
));
3213 #endif /* CONFIG_PVR */
3216 case MP_CMD_TV_STEP_NORM
:
3217 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3218 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3221 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3222 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3223 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3225 #endif /* CONFIG_TV */
3226 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3227 if (mpctx
->demuxer
->teletext
)
3228 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3229 &(cmd
->args
[0].v
.s
));
3231 case MP_CMD_TV_TELETEXT_GO_LINK
:
3232 if (mpctx
->demuxer
->teletext
)
3233 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3234 &(cmd
->args
[0].v
.i
));
3237 case MP_CMD_SUB_LOAD
:
3239 int n
= mpctx
->set_of_sub_size
;
3240 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3241 if (n
!= mpctx
->set_of_sub_size
) {
3242 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3243 ++mpctx
->global_sub_size
;
3248 case MP_CMD_SUB_REMOVE
:
3250 int v
= cmd
->args
[0].v
.i
;
3252 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3253 } else if (v
< mpctx
->set_of_sub_size
) {
3254 remove_subtitle_range(mpctx
, v
, 1);
3259 case MP_CMD_GET_SUB_VISIBILITY
:
3261 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3262 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3266 case MP_CMD_SCREENSHOT
:
3267 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3268 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3270 ((vf_instance_t
*) sh_video
->vfilter
)->
3271 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3273 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3277 case MP_CMD_VF_CHANGE_RECTANGLE
:
3280 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3283 case MP_CMD_GET_TIME_LENGTH
:{
3284 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3285 demuxer_get_time_length(mpctx
->demuxer
));
3289 case MP_CMD_GET_FILENAME
:{
3290 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3291 get_metadata(mpctx
, META_NAME
));
3295 case MP_CMD_GET_VIDEO_CODEC
:{
3296 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3299 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3304 case MP_CMD_GET_VIDEO_BITRATE
:{
3305 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3308 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3313 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3314 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3317 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3318 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3323 case MP_CMD_GET_AUDIO_CODEC
:{
3324 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3327 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3332 case MP_CMD_GET_AUDIO_BITRATE
:{
3333 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3336 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3341 case MP_CMD_GET_AUDIO_SAMPLES
:{
3342 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3345 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3350 case MP_CMD_GET_META_TITLE
:{
3351 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3354 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3359 case MP_CMD_GET_META_ARTIST
:{
3360 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3363 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3368 case MP_CMD_GET_META_ALBUM
:{
3369 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3372 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3377 case MP_CMD_GET_META_YEAR
:{
3378 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3381 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3386 case MP_CMD_GET_META_COMMENT
:{
3387 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3390 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3395 case MP_CMD_GET_META_TRACK
:{
3396 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3399 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3404 case MP_CMD_GET_META_GENRE
:{
3405 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3408 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3413 case MP_CMD_GET_VO_FULLSCREEN
:
3414 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3415 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3418 case MP_CMD_GET_PERCENT_POS
:
3419 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3420 demuxer_get_percent_pos(mpctx
->demuxer
));
3423 case MP_CMD_GET_TIME_POS
:{
3426 pos
= sh_video
->pts
;
3427 else if (sh_audio
&& mpctx
->audio_out
)
3428 pos
= playing_audio_pts(mpctx
);
3429 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3436 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3442 case MP_CMD_KEYDOWN_EVENTS
:
3443 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3446 case MP_CMD_SET_MOUSE_POS
:{
3447 int pointer_x
, pointer_y
;
3449 pointer_x
= cmd
->args
[0].v
.i
;
3450 pointer_y
= cmd
->args
[1].v
.i
;
3451 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3452 #ifdef CONFIG_DVDNAV
3453 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3454 && dx
> 0.0 && dy
> 0.0) {
3456 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3457 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3458 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3459 pointer_x
, pointer_y
, &button
);
3460 if (opts
->osd_level
> 1 && button
> 0)
3461 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3462 "Selected button number %d", button
);
3466 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3467 menu_update_mouse_pos(dx
, dy
);
3472 #ifdef CONFIG_DVDNAV
3473 case MP_CMD_DVDNAV
:{
3476 mp_command_type command
= 0;
3477 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3480 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3481 if (cmd
->args
[0].v
.s
&&
3482 !strcasecmp (cmd
->args
[0].v
.s
,
3483 mp_dvdnav_bindings
[i
].name
))
3484 command
= mp_dvdnav_bindings
[i
].cmd
;
3486 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3487 if (opts
->osd_level
> 1 && button
> 0)
3488 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3489 "Selected button number %d", button
);
3493 case MP_CMD_SWITCH_TITLE
:
3494 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3495 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3500 case MP_CMD_AF_SWITCH
:
3503 af_uninit(mpctx
->mixer
.afilter
);
3504 af_init(mpctx
->mixer
.afilter
);
3511 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3512 char* af_commands
= af_args
;
3515 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3517 if (cmd
->id
== MP_CMD_AF_DEL
)
3519 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3521 af_remove(mpctx
->mixer
.afilter
, af
);
3524 af_add(mpctx
->mixer
.afilter
, af_command
);
3526 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3533 af_uninit(mpctx
->mixer
.afilter
);
3534 af_init(mpctx
->mixer
.afilter
);
3535 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3537 case MP_CMD_AF_CMDLINE
:
3539 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3541 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3542 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3545 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3546 af_reinit(sh_audio
->afilter
, af
);
3551 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3552 "Received unknown cmd %s\n", cmd
->name
);
3555 switch (cmd
->pausing
) {
3556 case 1: // "pausing"
3557 pause_player(mpctx
);
3559 case 3: // "pausing_toggle"
3561 unpause_player(mpctx
);
3563 pause_player(mpctx
);