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 /// Media length in seconds (RO)
375 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
380 if (!mpctx
->demuxer
||
381 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
382 return M_PROPERTY_UNAVAILABLE
;
384 return m_property_time_ro(prop
, action
, arg
, len
);
387 /// Current position in percent (RW)
388 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
389 void *arg
, MPContext
*mpctx
) {
393 return M_PROPERTY_UNAVAILABLE
;
397 if(!arg
) return M_PROPERTY_ERROR
;
398 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
401 case M_PROPERTY_STEP_UP
:
402 case M_PROPERTY_STEP_DOWN
:
403 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
404 pos
+= (arg
? *(int*)arg
: 10) *
405 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
406 M_PROPERTY_CLAMP(prop
, pos
);
409 return m_property_int_ro(prop
, action
, arg
,
410 demuxer_get_percent_pos(mpctx
->demuxer
));
413 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
414 mpctx
->rel_seek_secs
= pos
/ 100.0;
415 return M_PROPERTY_OK
;
418 /// Current position in seconds (RW)
419 static int mp_property_time_pos(m_option_t
*prop
, int action
,
420 void *arg
, MPContext
*mpctx
) {
421 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
422 return M_PROPERTY_UNAVAILABLE
;
426 if(!arg
) return M_PROPERTY_ERROR
;
427 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
428 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
429 mpctx
->rel_seek_secs
= *(double*)arg
;
430 return M_PROPERTY_OK
;
431 case M_PROPERTY_STEP_UP
:
432 case M_PROPERTY_STEP_DOWN
:
433 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
434 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
435 return M_PROPERTY_OK
;
437 return m_property_time_ro(prop
, action
, arg
,
438 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
439 playing_audio_pts(mpctx
));
442 /// Current chapter (RW)
443 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
446 struct MPOpts
*opts
= &mpctx
->opts
;
449 char *chapter_name
= NULL
;
452 chapter
= get_current_chapter(mpctx
);
454 return M_PROPERTY_UNAVAILABLE
;
459 return M_PROPERTY_ERROR
;
460 *(int *) arg
= chapter
;
461 return M_PROPERTY_OK
;
462 case M_PROPERTY_PRINT
: {
464 return M_PROPERTY_ERROR
;
465 chapter_name
= chapter_display_name(mpctx
, chapter
);
467 return M_PROPERTY_UNAVAILABLE
;
468 *(char **) arg
= chapter_name
;
469 return M_PROPERTY_OK
;
473 return M_PROPERTY_ERROR
;
474 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
475 step_all
= *(int *)arg
- chapter
;
478 case M_PROPERTY_STEP_UP
:
479 case M_PROPERTY_STEP_DOWN
: {
480 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
481 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
488 return M_PROPERTY_NOT_IMPLEMENTED
;
492 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
493 mpctx
->rel_seek_secs
= 0;
494 mpctx
->abs_seek_pos
= 0;
496 if (next_pts
> -1.0) {
497 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
498 mpctx
->rel_seek_secs
= next_pts
;
501 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
502 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
504 else if (step_all
> 0)
505 mpctx
->rel_seek_secs
= 1000000000.;
507 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
508 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
510 talloc_free(chapter_name
);
511 return M_PROPERTY_OK
;
514 /// Number of chapters in file
515 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
519 return M_PROPERTY_UNAVAILABLE
;
520 if (mpctx
->demuxer
->num_chapters
== 0)
521 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
522 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
525 /// Current dvd angle (RW)
526 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
529 struct MPOpts
*opts
= &mpctx
->opts
;
532 char *angle_name
= NULL
;
535 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
537 return M_PROPERTY_UNAVAILABLE
;
538 angles
= demuxer_angles_count(mpctx
->demuxer
);
540 return M_PROPERTY_UNAVAILABLE
;
545 return M_PROPERTY_ERROR
;
546 *(int *) arg
= angle
;
547 return M_PROPERTY_OK
;
548 case M_PROPERTY_PRINT
: {
550 return M_PROPERTY_ERROR
;
551 angle_name
= calloc(1, 64);
553 return M_PROPERTY_UNAVAILABLE
;
554 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
555 *(char **) arg
= angle_name
;
556 return M_PROPERTY_OK
;
560 return M_PROPERTY_ERROR
;
562 M_PROPERTY_CLAMP(prop
, angle
);
564 case M_PROPERTY_STEP_UP
:
565 case M_PROPERTY_STEP_DOWN
: {
571 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
573 if (angle
< 1) //cycle
578 return M_PROPERTY_NOT_IMPLEMENTED
;
580 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
582 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
584 resync_video_stream(sh_video
);
586 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
588 resync_audio_stream(sh_audio
);
591 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
592 "Angle: %d/%d", angle
, angles
);
595 return M_PROPERTY_OK
;
598 /// Demuxer meta data
599 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
601 m_property_action_t
* ka
;
603 static const m_option_t key_type
=
604 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
606 return M_PROPERTY_UNAVAILABLE
;
610 if(!arg
) return M_PROPERTY_ERROR
;
611 *(char***)arg
= mpctx
->demuxer
->info
;
612 return M_PROPERTY_OK
;
613 case M_PROPERTY_KEY_ACTION
:
614 if(!arg
) return M_PROPERTY_ERROR
;
616 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
617 return M_PROPERTY_UNKNOWN
;
620 if(!ka
->arg
) return M_PROPERTY_ERROR
;
621 *(char**)ka
->arg
= meta
;
622 return M_PROPERTY_OK
;
623 case M_PROPERTY_GET_TYPE
:
624 if(!ka
->arg
) return M_PROPERTY_ERROR
;
625 *(m_option_t
**)ka
->arg
= &key_type
;
626 return M_PROPERTY_OK
;
629 return M_PROPERTY_NOT_IMPLEMENTED
;
632 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
635 MPContext
*mpctx
= ctx
;
640 return M_PROPERTY_ERROR
;
641 if (mpctx
->paused
== (bool)*(int *) arg
)
642 return M_PROPERTY_OK
;
643 case M_PROPERTY_STEP_UP
:
644 case M_PROPERTY_STEP_DOWN
:
646 unpause_player(mpctx
);
647 mpctx
->osd_function
= OSD_PLAY
;
651 mpctx
->osd_function
= OSD_PAUSE
;
653 return M_PROPERTY_OK
;
655 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
662 /// \defgroup AudioProperties Audio properties
663 /// \ingroup Properties
667 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
671 if (!mpctx
->sh_audio
)
672 return M_PROPERTY_UNAVAILABLE
;
677 return M_PROPERTY_ERROR
;
678 mixer_getbothvolume(&mpctx
->mixer
, arg
);
679 return M_PROPERTY_OK
;
680 case M_PROPERTY_PRINT
:{
683 return M_PROPERTY_ERROR
;
684 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
685 return m_property_float_range(prop
, action
, arg
, &vol
);
687 case M_PROPERTY_STEP_UP
:
688 case M_PROPERTY_STEP_DOWN
:
692 return M_PROPERTY_NOT_IMPLEMENTED
;
695 if (mpctx
->edl_muted
)
696 return M_PROPERTY_DISABLED
;
697 mpctx
->user_muted
= 0;
702 return M_PROPERTY_ERROR
;
703 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
704 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
705 return M_PROPERTY_OK
;
706 case M_PROPERTY_STEP_UP
:
707 if (arg
&& *(float *) arg
<= 0)
708 mixer_decvolume(&mpctx
->mixer
);
710 mixer_incvolume(&mpctx
->mixer
);
711 return M_PROPERTY_OK
;
712 case M_PROPERTY_STEP_DOWN
:
713 if (arg
&& *(float *) arg
<= 0)
714 mixer_incvolume(&mpctx
->mixer
);
716 mixer_decvolume(&mpctx
->mixer
);
717 return M_PROPERTY_OK
;
719 return M_PROPERTY_NOT_IMPLEMENTED
;
723 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
727 if (!mpctx
->sh_audio
)
728 return M_PROPERTY_UNAVAILABLE
;
732 if (mpctx
->edl_muted
)
733 return M_PROPERTY_DISABLED
;
735 return M_PROPERTY_ERROR
;
736 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
737 mixer_mute(&mpctx
->mixer
);
738 mpctx
->user_muted
= mpctx
->mixer
.muted
;
739 return M_PROPERTY_OK
;
740 case M_PROPERTY_STEP_UP
:
741 case M_PROPERTY_STEP_DOWN
:
742 if (mpctx
->edl_muted
)
743 return M_PROPERTY_DISABLED
;
744 mixer_mute(&mpctx
->mixer
);
745 mpctx
->user_muted
= mpctx
->mixer
.muted
;
746 return M_PROPERTY_OK
;
747 case M_PROPERTY_PRINT
:
749 return M_PROPERTY_ERROR
;
750 if (mpctx
->edl_muted
) {
751 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
752 return M_PROPERTY_OK
;
755 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
761 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
762 void *arg
, MPContext
*mpctx
)
764 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
765 return M_PROPERTY_UNAVAILABLE
;
768 case M_PROPERTY_STEP_UP
:
769 case M_PROPERTY_STEP_DOWN
: {
771 float delay
= audio_delay
;
772 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
773 if (ret
!= M_PROPERTY_OK
)
776 mpctx
->delay
-= audio_delay
- delay
;
778 return M_PROPERTY_OK
;
780 return m_property_delay(prop
, action
, arg
, &audio_delay
);
784 /// Audio codec tag (RO)
785 static int mp_property_audio_format(m_option_t
*prop
, int action
,
786 void *arg
, MPContext
*mpctx
)
788 if (!mpctx
->sh_audio
)
789 return M_PROPERTY_UNAVAILABLE
;
790 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
793 /// Audio codec name (RO)
794 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
795 void *arg
, MPContext
*mpctx
)
797 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
798 return M_PROPERTY_UNAVAILABLE
;
799 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
802 /// Audio bitrate (RO)
803 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
804 void *arg
, MPContext
*mpctx
)
806 if (!mpctx
->sh_audio
)
807 return M_PROPERTY_UNAVAILABLE
;
808 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
812 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
815 if (!mpctx
->sh_audio
)
816 return M_PROPERTY_UNAVAILABLE
;
818 case M_PROPERTY_PRINT
:
819 if(!arg
) return M_PROPERTY_ERROR
;
820 *(char**)arg
= malloc(16);
821 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
822 return M_PROPERTY_OK
;
824 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
827 /// Number of channels (RO)
828 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
831 if (!mpctx
->sh_audio
)
832 return M_PROPERTY_UNAVAILABLE
;
834 case M_PROPERTY_PRINT
:
836 return M_PROPERTY_ERROR
;
837 switch (mpctx
->sh_audio
->channels
) {
839 *(char **) arg
= strdup("mono");
842 *(char **) arg
= strdup("stereo");
845 *(char **) arg
= malloc(32);
846 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
848 return M_PROPERTY_OK
;
850 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
854 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
859 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
860 return M_PROPERTY_UNAVAILABLE
;
865 return M_PROPERTY_ERROR
;
866 mixer_getbalance(&mpctx
->mixer
, arg
);
867 return M_PROPERTY_OK
;
868 case M_PROPERTY_PRINT
: {
871 return M_PROPERTY_ERROR
;
872 mixer_getbalance(&mpctx
->mixer
, &bal
);
874 *str
= strdup("center");
875 else if (bal
== -1.f
)
876 *str
= strdup("left only");
878 *str
= strdup("right only");
880 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
881 *str
= malloc(sizeof("left xxx%, right xxx%"));
882 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
884 return M_PROPERTY_OK
;
886 case M_PROPERTY_STEP_UP
:
887 case M_PROPERTY_STEP_DOWN
:
888 mixer_getbalance(&mpctx
->mixer
, &bal
);
889 bal
+= (arg
? *(float*)arg
: .1f
) *
890 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
891 M_PROPERTY_CLAMP(prop
, bal
);
892 mixer_setbalance(&mpctx
->mixer
, bal
);
893 return M_PROPERTY_OK
;
896 return M_PROPERTY_ERROR
;
897 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
898 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
899 return M_PROPERTY_OK
;
901 return M_PROPERTY_NOT_IMPLEMENTED
;
904 /// Selected audio id (RW)
905 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
909 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
910 return M_PROPERTY_UNAVAILABLE
;
911 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
916 return M_PROPERTY_ERROR
;
917 *(int *) arg
= current_id
;
918 return M_PROPERTY_OK
;
919 case M_PROPERTY_PRINT
:
921 return M_PROPERTY_ERROR
;
924 *(char **) arg
= strdup(mp_gtext("disabled"));
927 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
928 sh_audio_t
* sh
= mpctx
->sh_audio
;
930 av_strlcpy(lang
, sh
->lang
, 40);
931 #ifdef CONFIG_DVDREAD
932 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
933 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
943 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
944 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
946 *(char **) arg
= malloc(64);
947 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
949 return M_PROPERTY_OK
;
951 case M_PROPERTY_STEP_UP
:
953 if (action
== M_PROPERTY_SET
&& arg
)
954 tmp
= *((int *) arg
);
957 int new_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
958 if (new_id
!= current_id
)
959 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
960 if (new_id
!= current_id
&& new_id
>= 0) {
962 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
963 sh2
->ds
= mpctx
->demuxer
->audio
;
964 mpctx
->sh_audio
= sh2
;
965 reinit_audio_chain(mpctx
);
967 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
968 return M_PROPERTY_OK
;
970 return M_PROPERTY_NOT_IMPLEMENTED
;
975 /// Selected video id (RW)
976 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
979 struct MPOpts
*opts
= &mpctx
->opts
;
981 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
982 return M_PROPERTY_UNAVAILABLE
;
983 current_id
= mpctx
->demuxer
->video
->id
;
988 return M_PROPERTY_ERROR
;
989 *(int *) arg
= current_id
;
990 return M_PROPERTY_OK
;
991 case M_PROPERTY_PRINT
:
993 return M_PROPERTY_ERROR
;
996 *(char **) arg
= strdup(mp_gtext("disabled"));
999 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1000 *(char **) arg
= malloc(64);
1001 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1003 return M_PROPERTY_OK
;
1005 case M_PROPERTY_STEP_UP
:
1006 case M_PROPERTY_SET
:
1007 if (action
== M_PROPERTY_SET
&& arg
)
1008 tmp
= *((int *) arg
);
1011 opts
->video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
1012 if (opts
->video_id
== -2
1013 || (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
1014 && current_id
!= -2))
1015 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1016 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1017 if (opts
->video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
1019 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
1021 sh2
->ds
= mpctx
->demuxer
->video
;
1022 mpctx
->sh_video
= sh2
;
1023 reinit_video_chain(mpctx
);
1026 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1027 return M_PROPERTY_OK
;
1030 return M_PROPERTY_NOT_IMPLEMENTED
;
1034 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1037 demux_program_t prog
;
1040 case M_PROPERTY_STEP_UP
:
1041 case M_PROPERTY_SET
:
1042 if (action
== M_PROPERTY_SET
&& arg
)
1043 prog
.progid
= *((int *) arg
);
1047 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1048 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1049 return M_PROPERTY_ERROR
;
1051 if (prog
.aid
< 0 && prog
.vid
< 0) {
1052 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1053 return M_PROPERTY_ERROR
;
1055 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1056 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1057 return M_PROPERTY_OK
;
1060 return M_PROPERTY_NOT_IMPLEMENTED
;
1066 /// \defgroup VideoProperties Video properties
1067 /// \ingroup Properties
1070 /// Fullscreen state (RW)
1071 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1075 if (!mpctx
->video_out
)
1076 return M_PROPERTY_UNAVAILABLE
;
1079 case M_PROPERTY_SET
:
1081 return M_PROPERTY_ERROR
;
1082 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1083 if (vo_fs
== !!*(int *) arg
)
1084 return M_PROPERTY_OK
;
1085 case M_PROPERTY_STEP_UP
:
1086 case M_PROPERTY_STEP_DOWN
:
1087 if (mpctx
->video_out
->config_ok
)
1088 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1089 mpctx
->opts
.fullscreen
= vo_fs
;
1090 return M_PROPERTY_OK
;
1092 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1096 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1097 void *arg
, MPContext
*mpctx
)
1101 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1102 return M_PROPERTY_UNAVAILABLE
;
1103 vf
= mpctx
->sh_video
->vfilter
;
1105 case M_PROPERTY_GET
:
1107 return M_PROPERTY_ERROR
;
1108 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1109 return M_PROPERTY_OK
;
1110 case M_PROPERTY_SET
:
1112 return M_PROPERTY_ERROR
;
1113 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1114 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1115 return M_PROPERTY_OK
;
1116 case M_PROPERTY_STEP_UP
:
1117 case M_PROPERTY_STEP_DOWN
:
1118 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1119 deinterlace
= !deinterlace
;
1120 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1121 return M_PROPERTY_OK
;
1124 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1125 return m_property_flag_ro(prop
, action
, arg
, value
);
1128 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1129 void *arg
, MPContext
*mpctx
)
1131 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1132 return M_PROPERTY_UNAVAILABLE
;
1134 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1137 case M_PROPERTY_GET
:
1139 return M_PROPERTY_ERROR
;
1140 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1141 return M_PROPERTY_UNAVAILABLE
;
1142 return M_PROPERTY_OK
;
1143 case M_PROPERTY_PRINT
:
1145 return M_PROPERTY_ERROR
;
1146 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1147 return M_PROPERTY_UNAVAILABLE
;
1148 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1149 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1150 *(char **)arg
= strdup("Unknown");
1152 *(char**)arg
= strdup(names
[colorspace
]);
1153 return M_PROPERTY_OK
;
1154 case M_PROPERTY_SET
:
1156 return M_PROPERTY_ERROR
;
1157 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1158 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1159 return M_PROPERTY_OK
;
1160 case M_PROPERTY_STEP_UP
:;
1161 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1162 return M_PROPERTY_UNAVAILABLE
;
1164 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1165 return M_PROPERTY_OK
;
1167 return M_PROPERTY_NOT_IMPLEMENTED
;
1171 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1175 if (!mpctx
->video_out
1176 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1177 return M_PROPERTY_UNAVAILABLE
;
1180 case M_PROPERTY_SET
:
1182 return M_PROPERTY_ERROR
;
1183 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1184 vo_panscan
= *(float *) arg
;
1185 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1186 return M_PROPERTY_OK
;
1187 case M_PROPERTY_STEP_UP
:
1188 case M_PROPERTY_STEP_DOWN
:
1189 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1190 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1193 else if (vo_panscan
< 0)
1195 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1196 return M_PROPERTY_OK
;
1198 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1202 /// Helper to set vo flags.
1203 /** \ingroup PropertyImplHelper
1205 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1206 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1209 if (!mpctx
->video_out
)
1210 return M_PROPERTY_UNAVAILABLE
;
1213 case M_PROPERTY_SET
:
1215 return M_PROPERTY_ERROR
;
1216 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1217 if (*vo_var
== !!*(int *) arg
)
1218 return M_PROPERTY_OK
;
1219 case M_PROPERTY_STEP_UP
:
1220 case M_PROPERTY_STEP_DOWN
:
1221 if (mpctx
->video_out
->config_ok
)
1222 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1223 return M_PROPERTY_OK
;
1225 return m_property_flag(prop
, action
, arg
, vo_var
);
1229 /// Window always on top (RW)
1230 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1233 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1234 &mpctx
->opts
.vo_ontop
, mpctx
);
1237 /// Display in the root window (RW)
1238 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1241 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1242 &vo_rootwin
, mpctx
);
1245 /// Show window borders (RW)
1246 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1249 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1253 /// Framedropping state (RW)
1254 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1255 void *arg
, MPContext
*mpctx
)
1258 if (!mpctx
->sh_video
)
1259 return M_PROPERTY_UNAVAILABLE
;
1262 case M_PROPERTY_PRINT
:
1264 return M_PROPERTY_ERROR
;
1265 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1266 (frame_dropping
== 2 ? mp_gtext("hard") :
1267 mp_gtext("disabled")));
1268 return M_PROPERTY_OK
;
1270 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1274 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1275 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1278 int *gamma
= (int *)((char *)&mpctx
->opts
+ (int)prop
->priv
);
1281 if (!mpctx
->sh_video
)
1282 return M_PROPERTY_UNAVAILABLE
;
1284 if (gamma
[0] == 1000) {
1286 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1290 case M_PROPERTY_SET
:
1292 return M_PROPERTY_ERROR
;
1293 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1294 *gamma
= *(int *) arg
;
1295 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1299 case M_PROPERTY_GET
:
1300 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1302 return M_PROPERTY_ERROR
;
1304 return M_PROPERTY_OK
;
1307 case M_PROPERTY_STEP_UP
:
1308 case M_PROPERTY_STEP_DOWN
:
1309 *gamma
+= (arg
? *(int *) arg
: 1) *
1310 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1311 M_PROPERTY_CLAMP(prop
, *gamma
);
1312 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1317 return M_PROPERTY_NOT_IMPLEMENTED
;
1321 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1322 int l
= strlen(prop
->name
);
1323 char tv_prop
[3 + l
+ 1];
1324 sprintf(tv_prop
, "tv_%s", prop
->name
);
1325 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1329 return M_PROPERTY_UNAVAILABLE
;
1333 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1336 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1339 /// Video codec tag (RO)
1340 static int mp_property_video_format(m_option_t
*prop
, int action
,
1341 void *arg
, MPContext
*mpctx
)
1344 if (!mpctx
->sh_video
)
1345 return M_PROPERTY_UNAVAILABLE
;
1347 case M_PROPERTY_PRINT
:
1349 return M_PROPERTY_ERROR
;
1350 switch(mpctx
->sh_video
->format
) {
1352 meta
= strdup ("mpeg1"); break;
1354 meta
= strdup ("mpeg2"); break;
1356 meta
= strdup ("mpeg4"); break;
1358 meta
= strdup ("h264"); break;
1360 if(mpctx
->sh_video
->format
>= 0x20202020) {
1362 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1365 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1368 *(char**)arg
= meta
;
1369 return M_PROPERTY_OK
;
1371 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1374 /// Video codec name (RO)
1375 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1376 void *arg
, MPContext
*mpctx
)
1378 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1379 return M_PROPERTY_UNAVAILABLE
;
1380 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1384 /// Video bitrate (RO)
1385 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1386 void *arg
, MPContext
*mpctx
)
1388 if (!mpctx
->sh_video
)
1389 return M_PROPERTY_UNAVAILABLE
;
1390 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1393 /// Video display width (RO)
1394 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1397 if (!mpctx
->sh_video
)
1398 return M_PROPERTY_UNAVAILABLE
;
1399 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1402 /// Video display height (RO)
1403 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1406 if (!mpctx
->sh_video
)
1407 return M_PROPERTY_UNAVAILABLE
;
1408 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1412 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1415 if (!mpctx
->sh_video
)
1416 return M_PROPERTY_UNAVAILABLE
;
1417 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1420 /// Video aspect (RO)
1421 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1424 if (!mpctx
->sh_video
)
1425 return M_PROPERTY_UNAVAILABLE
;
1426 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1431 /// \defgroup SubProprties Subtitles properties
1432 /// \ingroup Properties
1435 /// Text subtitle position (RW)
1436 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1440 case M_PROPERTY_SET
:
1442 return M_PROPERTY_ERROR
;
1443 case M_PROPERTY_STEP_UP
:
1444 case M_PROPERTY_STEP_DOWN
:
1445 vo_osd_changed(OSDTYPE_SUBTITLE
);
1447 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1451 /// Selected subtitles (RW)
1452 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1455 struct MPOpts
*opts
= &mpctx
->opts
;
1456 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1457 int source
= -1, reset_spu
= 0;
1458 int source_pos
= -1;
1461 update_global_sub_size(mpctx
);
1462 const int global_sub_size
= mpctx
->global_sub_size
;
1464 if (global_sub_size
<= 0)
1465 return M_PROPERTY_UNAVAILABLE
;
1468 case M_PROPERTY_GET
:
1470 return M_PROPERTY_ERROR
;
1471 *(int *) arg
= mpctx
->global_sub_pos
;
1472 return M_PROPERTY_OK
;
1473 case M_PROPERTY_PRINT
:
1475 return M_PROPERTY_ERROR
;
1476 *(char **) arg
= malloc(64);
1477 (*(char **) arg
)[63] = 0;
1480 sub_name
= subdata
->filename
;
1482 if (ass_track
&& ass_track
->name
)
1483 sub_name
= ass_track
->name
;
1488 if ((tmp2
= strrchr(tmp
, '/')))
1491 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1492 mpctx
->set_of_sub_pos
+ 1,
1493 strlen(tmp
) < 20 ? "" : "...",
1494 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1495 return M_PROPERTY_OK
;
1497 #ifdef CONFIG_DVDNAV
1498 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1499 if (vo_spudec
&& opts
->sub_id
>= 0) {
1500 unsigned char lang
[3];
1501 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1502 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1503 return M_PROPERTY_OK
;
1509 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1510 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1511 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1512 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1513 && d_sub
&& d_sub
->sh
&& opts
->sub_id
>= 0) {
1514 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1515 if (!lang
) lang
= mp_gtext("unknown");
1516 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1517 return M_PROPERTY_OK
;
1520 if (vo_vobsub
&& vobsub_id
>= 0) {
1521 const char *language
= mp_gtext("unknown");
1522 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1523 snprintf(*(char **) arg
, 63, "(%d) %s",
1524 vobsub_id
, language
? language
: mp_gtext("unknown"));
1525 return M_PROPERTY_OK
;
1527 #ifdef CONFIG_DVDREAD
1528 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1529 && opts
->sub_id
>= 0) {
1531 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1532 lang
[0] = code
>> 8;
1535 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1536 return M_PROPERTY_OK
;
1539 if (opts
->sub_id
>= 0) {
1540 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1541 mp_gtext("unknown"));
1542 return M_PROPERTY_OK
;
1544 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1545 return M_PROPERTY_OK
;
1547 case M_PROPERTY_SET
:
1549 return M_PROPERTY_ERROR
;
1550 if (*(int *) arg
< -1)
1552 else if (*(int *) arg
>= global_sub_size
)
1553 *(int *) arg
= global_sub_size
- 1;
1554 mpctx
->global_sub_pos
= *(int *) arg
;
1556 case M_PROPERTY_STEP_UP
:
1557 mpctx
->global_sub_pos
+= 2;
1558 mpctx
->global_sub_pos
=
1559 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1561 case M_PROPERTY_STEP_DOWN
:
1562 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1563 mpctx
->global_sub_pos
=
1564 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1567 return M_PROPERTY_NOT_IMPLEMENTED
;
1570 if (mpctx
->global_sub_pos
>= 0) {
1571 source
= sub_source(mpctx
);
1572 source_pos
= sub_source_pos(mpctx
);
1575 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1576 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1578 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1579 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1580 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1581 mpctx
->global_sub_pos
, source
);
1583 mpctx
->set_of_sub_pos
= -1;
1597 if (source
== SUB_SOURCE_VOBSUB
) {
1598 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1599 } else if (source
== SUB_SOURCE_SUBS
) {
1600 mpctx
->set_of_sub_pos
= source_pos
;
1602 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1603 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1607 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1608 vo_osd_changed(OSDTYPE_SUBTITLE
);
1610 } else if (source
== SUB_SOURCE_DEMUX
) {
1611 opts
->sub_id
= source_pos
;
1612 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1614 // default: assume 1:1 mapping of sid and stream id
1615 d_sub
->id
= opts
->sub_id
;
1616 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1617 ds_free_packs(d_sub
);
1618 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1619 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1620 if (sh
&& sh
->sid
== opts
->sub_id
) {
1626 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1627 sh_sub_t
*sh
= d_sub
->sh
;
1628 if (sh
->type
== 'v')
1629 init_vo_spudec(mpctx
);
1631 else if (opts
->ass_enabled
)
1632 ass_track
= sh
->ass_track
;
1640 #ifdef CONFIG_DVDREAD
1642 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1643 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1644 && opts
->sub_id
< 0 && reset_spu
) {
1650 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1652 return M_PROPERTY_OK
;
1655 /// Selected sub source (RW)
1656 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1660 update_global_sub_size(mpctx
);
1661 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1662 return M_PROPERTY_UNAVAILABLE
;
1665 case M_PROPERTY_GET
:
1667 return M_PROPERTY_ERROR
;
1668 *(int *) arg
= sub_source(mpctx
);
1669 return M_PROPERTY_OK
;
1670 case M_PROPERTY_PRINT
:
1672 return M_PROPERTY_ERROR
;
1673 *(char **) arg
= malloc(64);
1674 (*(char **) arg
)[63] = 0;
1675 switch (sub_source(mpctx
))
1677 case SUB_SOURCE_SUBS
:
1678 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1680 case SUB_SOURCE_VOBSUB
:
1681 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1683 case SUB_SOURCE_DEMUX
:
1684 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1687 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1689 return M_PROPERTY_OK
;
1690 case M_PROPERTY_SET
:
1692 return M_PROPERTY_ERROR
;
1693 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1694 if (*(int *) arg
< 0)
1695 mpctx
->global_sub_pos
= -1;
1696 else if (*(int *) arg
!= sub_source(mpctx
)) {
1697 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1699 return M_PROPERTY_UNAVAILABLE
;
1700 mpctx
->global_sub_pos
= new_pos
;
1703 case M_PROPERTY_STEP_UP
:
1704 case M_PROPERTY_STEP_DOWN
: {
1705 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1706 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1707 int step
= (step_all
> 0) ? 1 : -1;
1708 int cur_source
= sub_source(mpctx
);
1709 source
= cur_source
;
1712 if (source
>= SUB_SOURCES
)
1714 else if (source
< -1)
1715 source
= SUB_SOURCES
- 1;
1716 if (source
== cur_source
|| source
== -1 ||
1717 mpctx
->sub_counts
[source
])
1720 if (source
== cur_source
)
1721 return M_PROPERTY_OK
;
1723 mpctx
->global_sub_pos
= -1;
1725 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1729 return M_PROPERTY_NOT_IMPLEMENTED
;
1731 --mpctx
->global_sub_pos
;
1732 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1735 /// Selected subtitles from specific source (RW)
1736 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1739 int source
, is_cur_source
, offset
, new_pos
;
1740 update_global_sub_size(mpctx
);
1741 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1742 return M_PROPERTY_UNAVAILABLE
;
1744 if (!strcmp(prop
->name
, "sub_file"))
1745 source
= SUB_SOURCE_SUBS
;
1746 else if (!strcmp(prop
->name
, "sub_vob"))
1747 source
= SUB_SOURCE_VOBSUB
;
1748 else if (!strcmp(prop
->name
, "sub_demux"))
1749 source
= SUB_SOURCE_DEMUX
;
1751 return M_PROPERTY_ERROR
;
1753 offset
= sub_pos_by_source(mpctx
, source
);
1755 return M_PROPERTY_UNAVAILABLE
;
1757 is_cur_source
= sub_source(mpctx
) == source
;
1758 new_pos
= mpctx
->global_sub_pos
;
1760 case M_PROPERTY_GET
:
1762 return M_PROPERTY_ERROR
;
1763 if (is_cur_source
) {
1764 *(int *) arg
= sub_source_pos(mpctx
);
1765 if (source
== SUB_SOURCE_VOBSUB
)
1766 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1770 return M_PROPERTY_OK
;
1771 case M_PROPERTY_PRINT
:
1773 return M_PROPERTY_ERROR
;
1775 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1776 *(char **) arg
= malloc(64);
1777 (*(char **) arg
)[63] = 0;
1778 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1779 return M_PROPERTY_OK
;
1780 case M_PROPERTY_SET
:
1782 return M_PROPERTY_ERROR
;
1783 if (*(int *) arg
>= 0) {
1784 int index
= *(int *)arg
;
1785 if (source
== SUB_SOURCE_VOBSUB
)
1786 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1787 new_pos
= offset
+ index
;
1788 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1796 case M_PROPERTY_STEP_UP
:
1797 case M_PROPERTY_STEP_DOWN
: {
1798 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1799 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1800 int step
= (step_all
> 0) ? 1 : -1;
1801 int max_sub_pos_for_source
= -1;
1805 if (new_pos
== -1) {
1808 else if (max_sub_pos_for_source
== -1) {
1809 // Find max pos for specific source
1810 new_pos
= mpctx
->global_sub_size
- 1;
1812 && sub_source(mpctx
) != source
)
1816 new_pos
= max_sub_pos_for_source
;
1820 if (new_pos
< offset
||
1821 new_pos
>= mpctx
->global_sub_size
||
1822 sub_source(mpctx
) != source
)
1830 return M_PROPERTY_NOT_IMPLEMENTED
;
1832 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1835 /// Subtitle delay (RW)
1836 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1839 if (!mpctx
->sh_video
)
1840 return M_PROPERTY_UNAVAILABLE
;
1841 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1844 /// Alignment of text subtitles (RW)
1845 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1846 void *arg
, MPContext
*mpctx
)
1848 char *name
[] = { _("top"), _("center"), _("bottom") };
1850 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1851 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1852 return M_PROPERTY_UNAVAILABLE
;
1855 case M_PROPERTY_PRINT
:
1857 return M_PROPERTY_ERROR
;
1858 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1859 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1860 return M_PROPERTY_OK
;
1861 case M_PROPERTY_SET
:
1863 return M_PROPERTY_ERROR
;
1864 case M_PROPERTY_STEP_UP
:
1865 case M_PROPERTY_STEP_DOWN
:
1866 vo_osd_changed(OSDTYPE_SUBTITLE
);
1868 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1872 /// Subtitle visibility (RW)
1873 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1874 void *arg
, MPContext
*mpctx
)
1876 if (!mpctx
->sh_video
)
1877 return M_PROPERTY_UNAVAILABLE
;
1880 case M_PROPERTY_SET
:
1882 return M_PROPERTY_ERROR
;
1883 case M_PROPERTY_STEP_UP
:
1884 case M_PROPERTY_STEP_DOWN
:
1885 vo_osd_changed(OSDTYPE_SUBTITLE
);
1887 vo_osd_changed(OSDTYPE_SPU
);
1889 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1894 /// Use margins for libass subtitles (RW)
1895 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1896 void *arg
, MPContext
*mpctx
)
1898 if (!mpctx
->sh_video
)
1899 return M_PROPERTY_UNAVAILABLE
;
1902 case M_PROPERTY_SET
:
1904 return M_PROPERTY_ERROR
;
1905 case M_PROPERTY_STEP_UP
:
1906 case M_PROPERTY_STEP_DOWN
:
1907 ass_force_reload
= 1;
1909 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1914 /// Show only forced subtitles (RW)
1915 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1916 void *arg
, MPContext
*mpctx
)
1919 return M_PROPERTY_UNAVAILABLE
;
1922 case M_PROPERTY_SET
:
1924 return M_PROPERTY_ERROR
;
1925 case M_PROPERTY_STEP_UP
:
1926 case M_PROPERTY_STEP_DOWN
:
1927 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1928 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1929 return M_PROPERTY_OK
;
1931 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1936 #ifdef CONFIG_FREETYPE
1937 /// Subtitle scale (RW)
1938 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1941 struct MPOpts
*opts
= &mpctx
->opts
;
1944 case M_PROPERTY_SET
:
1946 return M_PROPERTY_ERROR
;
1947 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1949 if (opts
->ass_enabled
) {
1950 ass_font_scale
= *(float *) arg
;
1951 ass_force_reload
= 1;
1954 text_font_scale_factor
= *(float *) arg
;
1955 force_load_font
= 1;
1956 return M_PROPERTY_OK
;
1957 case M_PROPERTY_STEP_UP
:
1958 case M_PROPERTY_STEP_DOWN
:
1960 if (opts
->ass_enabled
) {
1961 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1962 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1963 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1964 ass_force_reload
= 1;
1967 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1968 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1969 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1970 force_load_font
= 1;
1971 return M_PROPERTY_OK
;
1974 if (opts
->ass_enabled
)
1975 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1978 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1985 /// \defgroup TVProperties TV properties
1986 /// \ingroup Properties
1991 /// TV color settings (RW)
1992 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
1996 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1997 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1998 return M_PROPERTY_UNAVAILABLE
;
2001 case M_PROPERTY_SET
:
2003 return M_PROPERTY_ERROR
;
2004 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2005 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
2006 case M_PROPERTY_GET
:
2007 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
2008 case M_PROPERTY_STEP_UP
:
2009 case M_PROPERTY_STEP_DOWN
:
2010 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
2012 return M_PROPERTY_ERROR
;
2013 val
+= (arg
? *(int *) arg
: 1) *
2014 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2015 M_PROPERTY_CLAMP(prop
, val
);
2016 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
2018 return M_PROPERTY_ERROR
;
2020 return M_PROPERTY_NOT_IMPLEMENTED
;
2025 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2029 int base_ioctl
=(int)prop
->priv
;
2031 for teletext's GET,SET,STEP ioctls this is not 0
2035 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2036 return M_PROPERTY_UNAVAILABLE
;
2038 return M_PROPERTY_ERROR
;
2041 case M_PROPERTY_GET
:
2043 return M_PROPERTY_ERROR
;
2044 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2046 case M_PROPERTY_SET
:
2048 return M_PROPERTY_ERROR
;
2049 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2050 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2052 case M_PROPERTY_STEP_UP
:
2053 case M_PROPERTY_STEP_DOWN
:
2054 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2055 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2056 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2059 return M_PROPERTY_NOT_IMPLEMENTED
;
2062 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2065 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2071 //with tvh==NULL will fail too
2072 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2073 if(result
!=M_PROPERTY_OK
)
2076 if(teletext_control(mpctx
->demuxer
->teletext
,
2077 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
2078 mp_input_set_section(mpctx
->input
, "teletext");
2080 mp_input_set_section(mpctx
->input
, "tv");
2081 return M_PROPERTY_OK
;
2084 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2089 if (!mpctx
->demuxer
->teletext
)
2090 return M_PROPERTY_UNAVAILABLE
;
2092 case M_PROPERTY_STEP_UP
:
2093 case M_PROPERTY_STEP_DOWN
:
2094 //This should be handled separately
2095 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2096 result
=teletext_control(mpctx
->demuxer
->teletext
,
2097 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2100 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2107 /// All properties available in MPlayer.
2108 /** \ingroup Properties
2110 static const m_option_t mp_properties
[] = {
2112 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, 0, 3, NULL
},
2114 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2115 M_OPT_MIN
, -1, 0, NULL
},
2116 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2117 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2118 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2120 { "path", mp_property_path
, CONF_TYPE_STRING
,
2122 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2124 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2125 M_OPT_MIN
, 0, 0, NULL
},
2126 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2127 M_OPT_MIN
, 0, 0, NULL
},
2128 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2129 M_OPT_MIN
, 0, 0, NULL
},
2130 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2131 M_OPT_MIN
, 0, 0, NULL
},
2132 { "length", mp_property_length
, CONF_TYPE_TIME
,
2133 M_OPT_MIN
, 0, 0, NULL
},
2134 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2135 M_OPT_RANGE
, 0, 100, NULL
},
2136 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2137 M_OPT_MIN
, 0, 0, NULL
},
2138 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2139 M_OPT_MIN
, 0, 0, NULL
},
2140 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2142 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2143 CONF_RANGE
, -2, 10, NULL
},
2144 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2146 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2147 M_OPT_RANGE
, 0, 1, NULL
},
2150 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2151 M_OPT_RANGE
, 0, 100, NULL
},
2152 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2153 M_OPT_RANGE
, 0, 1, NULL
},
2154 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2155 M_OPT_RANGE
, -100, 100, NULL
},
2156 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2158 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2160 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2162 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2164 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2166 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2167 CONF_RANGE
, -2, 65535, NULL
},
2168 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2169 M_OPT_RANGE
, -1, 1, NULL
},
2172 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2173 M_OPT_RANGE
, 0, 1, NULL
},
2174 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2175 M_OPT_RANGE
, 0, 1, NULL
},
2176 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2177 M_OPT_RANGE
, 0, 2, NULL
},
2178 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2179 M_OPT_RANGE
, 0, 1, NULL
},
2180 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2181 M_OPT_RANGE
, 0, 1, NULL
},
2182 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2183 M_OPT_RANGE
, 0, 1, NULL
},
2184 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2185 M_OPT_RANGE
, 0, 2, NULL
},
2186 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2187 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_gamma
)},
2188 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2189 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_brightness
) },
2190 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2191 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_contrast
) },
2192 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2193 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_saturation
) },
2194 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2195 M_OPT_RANGE
, -100, 100, (void *)offsetof(struct MPOpts
, vo_gamma_hue
) },
2196 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2197 M_OPT_RANGE
, 0, 1, NULL
},
2198 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2199 M_OPT_RANGE
, 0, 1, NULL
},
2200 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2202 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2204 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2206 { "width", mp_property_width
, CONF_TYPE_INT
,
2208 { "height", mp_property_height
, CONF_TYPE_INT
,
2210 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2212 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2214 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2215 CONF_RANGE
, -2, 65535, NULL
},
2216 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2217 CONF_RANGE
, -1, 65535, NULL
},
2220 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2221 M_OPT_MIN
, -1, 0, NULL
},
2222 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2223 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2224 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2225 M_OPT_MIN
, -1, 0, NULL
},
2226 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2227 M_OPT_MIN
, -1, 0, NULL
},
2228 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2229 M_OPT_MIN
, -1, 0, NULL
},
2230 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2232 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2233 M_OPT_RANGE
, 0, 100, NULL
},
2234 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2235 M_OPT_RANGE
, 0, 2, NULL
},
2236 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2237 M_OPT_RANGE
, 0, 1, NULL
},
2238 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2239 M_OPT_RANGE
, 0, 1, NULL
},
2240 #ifdef CONFIG_FREETYPE
2241 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2242 M_OPT_RANGE
, 0, 100, NULL
},
2245 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2246 M_OPT_RANGE
, 0, 1, NULL
},
2250 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2251 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2252 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2253 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2254 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2255 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2256 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2257 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2259 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2260 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2261 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2262 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2263 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2264 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2265 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2266 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2267 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2268 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2269 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2273 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2275 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2278 char* mp_property_print(const char *name
, void* ctx
)
2281 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2286 char *property_expand_string(MPContext
*mpctx
, char *str
)
2288 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2291 void property_print_help(void)
2293 m_properties_print_help_list(mp_properties
);
2297 /* List of default ways to show a property on OSD.
2299 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2300 * a bar showing the current position between min/max values of the
2301 * property. In this case osd_msg is only used for terminal output
2302 * if there is no video; it'll be a label shown together with percentage.
2304 * Otherwise setting osd_msg will show the string on OSD, formatted with
2305 * the text value of the property as argument.
2307 static struct property_osd_display
{
2310 /// progressbar type
2311 int osd_progbar
; // -1 is special value for seek indicators
2312 /// osd msg id if it must be shared
2314 /// osd msg template
2315 const char *osd_msg
;
2316 } property_osd_display
[] = {
2318 { "loop", 0, -1, _("Loop: %s") },
2319 { "chapter", -1, -1, NULL
},
2321 { "volume", OSD_VOLUME
, -1, _("Volume") },
2322 { "mute", 0, -1, _("Mute: %s") },
2323 { "audio_delay", 0, -1, _("A-V delay: %s") },
2324 { "switch_audio", 0, -1, _("Audio: %s") },
2325 { "balance", OSD_BALANCE
, -1, _("Balance") },
2327 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2328 { "ontop", 0, -1, _("Stay on top: %s") },
2329 { "rootwin", 0, -1, _("Rootwin: %s") },
2330 { "border", 0, -1, _("Border: %s") },
2331 { "framedropping", 0, -1, _("Framedropping: %s") },
2332 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2333 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2334 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2335 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2336 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2337 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2338 { "hue", OSD_HUE
, -1, _("Hue") },
2339 { "vsync", 0, -1, _("VSync: %s") },
2341 { "sub", 0, -1, _("Subtitles: %s") },
2342 { "sub_source", 0, -1, _("Sub source: %s") },
2343 { "sub_vob", 0, -1, _("Subtitles: %s") },
2344 { "sub_demux", 0, -1, _("Subtitles: %s") },
2345 { "sub_file", 0, -1, _("Subtitles: %s") },
2346 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2347 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2348 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2349 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2350 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2351 #ifdef CONFIG_FREETYPE
2352 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2355 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2356 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2357 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2358 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2363 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2365 struct MPOpts
*opts
= &mpctx
->opts
;
2368 struct property_osd_display
*p
;
2370 // look for the command
2371 for (p
= property_osd_display
; p
->name
; p
++)
2372 if (!strcmp(p
->name
, pname
))
2377 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2380 if (p
->osd_progbar
== -1)
2381 mpctx
->add_osd_seek_info
= true;
2382 else if (p
->osd_progbar
) {
2383 if (prop
->type
== CONF_TYPE_INT
) {
2384 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2385 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2386 prop
->min
, prop
->max
, r
);
2387 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2389 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2390 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2391 prop
->min
, prop
->max
, f
);
2393 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2394 "Property use an unsupported type.\n");
2401 char *val
= mp_property_print(pname
, mpctx
);
2403 int index
= p
- property_osd_display
;
2404 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2405 1, opts
->osd_duration
, p
->osd_msg
, val
);
2414 * \defgroup Command2Property Command to property bridge
2416 * It is used to handle most commands that just set a property
2417 * and optionally display something on the OSD.
2418 * Two kinds of commands are handled: adjust or toggle.
2420 * Adjust commands take 1 or 2 parameters: <value> <abs>
2421 * If <abs> is non-zero the property is set to the given value
2422 * otherwise it is adjusted.
2424 * Toggle commands take 0 or 1 parameters. With no parameter
2425 * or a value less than the property minimum it just steps the
2426 * property to its next value. Otherwise it sets it to the given
2432 /// List of the commands that can be handled by setting a property.
2438 /// set/adjust or toggle command
2440 } set_prop_cmd
[] = {
2442 { "loop", MP_CMD_LOOP
, 0},
2443 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2444 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2445 { "pause", MP_CMD_PAUSE
, 0},
2447 { "volume", MP_CMD_VOLUME
, 0},
2448 { "mute", MP_CMD_MUTE
, 1},
2449 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2450 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2451 { "balance", MP_CMD_BALANCE
, 0},
2453 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2454 { "panscan", MP_CMD_PANSCAN
, 0},
2455 { "ontop", MP_CMD_VO_ONTOP
, 1},
2456 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2457 { "border", MP_CMD_VO_BORDER
, 1},
2458 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2459 { "gamma", MP_CMD_GAMMA
, 0},
2460 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2461 { "contrast", MP_CMD_CONTRAST
, 0},
2462 { "saturation", MP_CMD_SATURATION
, 0},
2463 { "hue", MP_CMD_HUE
, 0},
2464 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2466 { "sub", MP_CMD_SUB_SELECT
, 1},
2467 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2468 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2469 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2470 { "sub_file", MP_CMD_SUB_FILE
, 1},
2471 { "sub_pos", MP_CMD_SUB_POS
, 0},
2472 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2473 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2474 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2475 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2476 #ifdef CONFIG_FREETYPE
2477 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2480 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2483 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2484 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2485 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2486 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2491 /// Handle commands that set a property.
2492 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2498 // look for the command
2499 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2500 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2502 if (!(pname
= set_prop_cmd
[i
].name
))
2505 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2509 if (set_prop_cmd
[i
].toggle
) {
2511 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2512 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2514 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2515 } else if (cmd
->args
[1].v
.i
) //set
2516 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2518 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2523 show_property_osd(mpctx
, pname
);
2528 #ifdef CONFIG_DVDNAV
2529 static const struct {
2531 const mp_command_type cmd
;
2532 } mp_dvdnav_bindings
[] = {
2533 { "up", MP_CMD_DVDNAV_UP
},
2534 { "down", MP_CMD_DVDNAV_DOWN
},
2535 { "left", MP_CMD_DVDNAV_LEFT
},
2536 { "right", MP_CMD_DVDNAV_RIGHT
},
2537 { "menu", MP_CMD_DVDNAV_MENU
},
2538 { "select", MP_CMD_DVDNAV_SELECT
},
2539 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2540 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2543 * keep old dvdnav sub-command options for a while in order not to
2544 * break slave-mode API too suddenly.
2546 { "1", MP_CMD_DVDNAV_UP
},
2547 { "2", MP_CMD_DVDNAV_DOWN
},
2548 { "3", MP_CMD_DVDNAV_LEFT
},
2549 { "4", MP_CMD_DVDNAV_RIGHT
},
2550 { "5", MP_CMD_DVDNAV_MENU
},
2551 { "6", MP_CMD_DVDNAV_SELECT
},
2552 { "7", MP_CMD_DVDNAV_PREVMENU
},
2553 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2558 static const char *property_error_string(int error_value
)
2560 switch (error_value
) {
2561 case M_PROPERTY_ERROR
:
2563 case M_PROPERTY_UNAVAILABLE
:
2564 return "PROPERTY_UNAVAILABLE";
2565 case M_PROPERTY_NOT_IMPLEMENTED
:
2566 return "NOT_IMPLEMENTED";
2567 case M_PROPERTY_UNKNOWN
:
2568 return "PROPERTY_UNKNOWN";
2569 case M_PROPERTY_DISABLED
:
2575 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2578 int end
= start
+ count
;
2579 int after
= mpctx
->set_of_sub_size
- end
;
2580 sub_data
**subs
= mpctx
->set_of_subtitles
;
2582 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2584 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2585 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2586 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2587 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2590 for (idx
= start
; idx
< end
; idx
++) {
2591 sub_data
*subd
= subs
[idx
];
2592 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2593 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2594 filename_recode(subd
->filename
));
2598 if (ass_tracks
[idx
])
2599 ass_free_track(ass_tracks
[idx
]);
2600 ass_tracks
[idx
] = NULL
;
2604 mpctx
->global_sub_size
-= count
;
2605 mpctx
->set_of_sub_size
-= count
;
2606 if (mpctx
->set_of_sub_size
<= 0)
2607 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2609 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2610 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2612 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2613 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2616 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2617 mpctx
->global_sub_pos
= -2;
2622 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2623 } else if (mpctx
->set_of_sub_pos
>= end
) {
2624 mpctx
->set_of_sub_pos
-= count
;
2625 mpctx
->global_sub_pos
-= count
;
2629 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2631 struct MPOpts
*opts
= &mpctx
->opts
;
2632 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2633 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2634 int osd_duration
= opts
->osd_duration
;
2635 int case_fallthrough_hack
= 0;
2636 if (!set_property_command(mpctx
, cmd
))
2641 mpctx
->add_osd_seek_info
= true;
2642 v
= cmd
->args
[0].v
.f
;
2643 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2644 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2645 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2647 mpctx
->osd_function
=
2648 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2649 mpctx
->rel_seek_secs
= v
;
2650 } else if (abs
) { /* Absolute seek by percentage */
2651 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2653 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2654 mpctx
->rel_seek_secs
= v
/ 100.0;
2656 mpctx
->rel_seek_secs
+= v
;
2657 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2662 case MP_CMD_SET_PROPERTY_OSD
:
2663 case_fallthrough_hack
= 1;
2665 case MP_CMD_SET_PROPERTY
:{
2666 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2667 cmd
->args
[1].v
.s
, mpctx
);
2668 if (r
== M_PROPERTY_UNKNOWN
)
2669 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2670 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2672 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2673 "Failed to set property '%s' to '%s'.\n",
2674 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2675 else if (case_fallthrough_hack
)
2676 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2678 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2682 case MP_CMD_STEP_PROPERTY_OSD
:
2683 case_fallthrough_hack
= 1;
2685 case MP_CMD_STEP_PROPERTY
:{
2690 if (cmd
->args
[1].v
.f
) {
2692 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2693 M_PROPERTY_GET_TYPE
,
2694 &prop
, mpctx
)) <= 0)
2696 if(prop
->type
== CONF_TYPE_INT
||
2697 prop
->type
== CONF_TYPE_FLAG
)
2698 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2699 else if(prop
->type
== CONF_TYPE_FLOAT
)
2700 arg
= &cmd
->args
[1].v
.f
;
2701 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2702 prop
->type
== CONF_TYPE_TIME
)
2703 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2704 else if(prop
->type
== CONF_TYPE_POSITION
)
2705 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2707 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2708 "Ignoring step size stepping property '%s'.\n",
2711 r
= mp_property_do(cmd
->args
[0].v
.s
,
2712 cmd
->args
[2].v
.i
< 0 ?
2713 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2716 if (r
== M_PROPERTY_UNKNOWN
)
2717 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2718 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2720 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2721 "Failed to increment property '%s' by %f.\n",
2722 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2723 else if (case_fallthrough_hack
)
2724 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2726 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2730 case MP_CMD_GET_PROPERTY
:{
2732 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2735 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2736 "Failed to get value of property '%s'.\n",
2738 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2741 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2742 cmd
->args
[0].v
.s
, tmp
);
2747 case MP_CMD_EDL_MARK
:
2749 float v
= sh_video
? sh_video
->pts
:
2750 playing_audio_pts(mpctx
);
2751 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2752 mpctx
->begin_skip
= v
;
2753 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2755 if (mpctx
->begin_skip
> v
)
2756 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2758 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2759 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2761 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2766 case MP_CMD_SWITCH_RATIO
:
2769 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2770 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2772 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2773 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2776 case MP_CMD_SPEED_INCR
:{
2777 float v
= cmd
->args
[0].v
.f
;
2778 opts
->playback_speed
+= v
;
2779 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2780 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2781 opts
->playback_speed
);
2784 case MP_CMD_SPEED_MULT
:{
2785 float v
= cmd
->args
[0].v
.f
;
2786 opts
->playback_speed
*= v
;
2787 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2788 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2789 opts
->playback_speed
);
2792 case MP_CMD_SPEED_SET
:{
2793 float v
= cmd
->args
[0].v
.f
;
2794 opts
->playback_speed
= v
;
2795 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2796 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2797 opts
->playback_speed
);
2800 case MP_CMD_FRAME_STEP
:
2801 add_step_frame(mpctx
);
2804 case MP_CMD_FILE_FILTER
:
2805 file_filter
= cmd
->args
[0].v
.i
;
2809 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2810 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2812 case MP_CMD_PLAY_TREE_STEP
:{
2813 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2814 int force
= cmd
->args
[1].v
.i
;
2817 if (!force
&& mpctx
->playtree_iter
) {
2818 play_tree_iter_t
*i
=
2819 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2820 if (play_tree_iter_step(i
, n
, 0) ==
2821 PLAY_TREE_ITER_ENTRY
)
2823 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2824 play_tree_iter_free(i
);
2826 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2827 if (mpctx
->stop_play
)
2828 mpctx
->play_tree_step
= n
;
2833 case MP_CMD_PLAY_TREE_UP_STEP
:{
2834 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2835 int force
= cmd
->args
[1].v
.i
;
2837 if (!force
&& mpctx
->playtree_iter
) {
2838 play_tree_iter_t
*i
=
2839 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2840 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2841 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2842 play_tree_iter_free(i
);
2844 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2848 case MP_CMD_PLAY_ALT_SRC_STEP
:
2849 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2850 int v
= cmd
->args
[0].v
.i
;
2852 && mpctx
->playtree_iter
->file
<
2853 mpctx
->playtree_iter
->num_files
)
2854 mpctx
->stop_play
= PT_NEXT_SRC
;
2855 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2856 mpctx
->stop_play
= PT_PREV_SRC
;
2860 case MP_CMD_SUB_STEP
:
2862 int movement
= cmd
->args
[0].v
.i
;
2863 step_sub(subdata
, sh_video
->pts
, movement
);
2867 ass_step_sub(ass_track
,
2869 sub_delay
) * 1000 + .5, movement
) / 1000.;
2871 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2872 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2876 case MP_CMD_SUB_LOG
:
2881 int v
= cmd
->args
[0].v
.i
;
2883 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2884 if (opts
->osd_level
> max
)
2885 opts
->osd_level
= max
;
2887 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2889 opts
->osd_level
= v
> max
? max
: v
;
2890 /* Show OSD state when disabled, but not when an explicit
2891 argument is given to the OSD command, i.e. in slave mode. */
2892 if (v
== -1 && opts
->osd_level
<= 1)
2893 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2895 opts
->osd_level
? mp_gtext("enabled") :
2896 mp_gtext("disabled"));
2898 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2902 case MP_CMD_OSD_SHOW_TEXT
:
2903 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2905 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2906 "%-.63s", cmd
->args
[0].v
.s
);
2909 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2910 char *txt
= m_properties_expand_string(mp_properties
,
2913 /* if no argument supplied take default osd_duration, else <arg> ms. */
2915 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2917 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2924 case MP_CMD_LOADFILE
:{
2925 play_tree_t
*e
= play_tree_new();
2926 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2928 if (cmd
->args
[1].v
.i
) // append
2929 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2931 // Go back to the starting point.
2932 while (play_tree_iter_up_step
2933 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2935 play_tree_free_list(mpctx
->playtree
->child
, 1);
2936 play_tree_set_child(mpctx
->playtree
, e
);
2937 pt_iter_goto_head(mpctx
->playtree_iter
);
2938 mpctx
->stop_play
= PT_NEXT_SRC
;
2943 case MP_CMD_LOADLIST
:{
2944 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2946 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2947 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2949 if (cmd
->args
[1].v
.i
) // append
2950 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2952 // Go back to the starting point.
2953 while (play_tree_iter_up_step
2954 (mpctx
->playtree_iter
, 0, 1)
2955 != PLAY_TREE_ITER_END
)
2957 play_tree_free_list(mpctx
->playtree
->child
, 1);
2958 play_tree_set_child(mpctx
->playtree
, e
);
2959 pt_iter_goto_head(mpctx
->playtree_iter
);
2960 mpctx
->stop_play
= PT_NEXT_SRC
;
2967 // Go back to the starting point.
2968 while (play_tree_iter_up_step
2969 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2971 mpctx
->stop_play
= PT_STOP
;
2974 case MP_CMD_OSD_SHOW_PROGRESSION
:{
2975 int len
= demuxer_get_time_length(mpctx
->demuxer
);
2976 int pts
= demuxer_get_current_time(mpctx
->demuxer
);
2977 set_osd_bar(mpctx
, 0, "Position", 0, 100, demuxer_get_percent_pos(mpctx
->demuxer
));
2978 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2979 "%c %02d:%02d:%02d / %02d:%02d:%02d",
2980 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
2981 len
/3600, (len
/60)%60, len
%60);
2986 case MP_CMD_RADIO_STEP_CHANNEL
:
2987 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2988 int v
= cmd
->args
[0].v
.i
;
2990 radio_step_channel(mpctx
->demuxer
->stream
,
2991 RADIO_CHANNEL_HIGHER
);
2993 radio_step_channel(mpctx
->demuxer
->stream
,
2994 RADIO_CHANNEL_LOWER
);
2995 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2996 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2998 radio_get_channel_name(mpctx
->demuxer
->stream
));
3003 case MP_CMD_RADIO_SET_CHANNEL
:
3004 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3005 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3006 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3007 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3009 radio_get_channel_name(mpctx
->demuxer
->stream
));
3014 case MP_CMD_RADIO_SET_FREQ
:
3015 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3016 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3019 case MP_CMD_RADIO_STEP_FREQ
:
3020 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3021 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3026 case MP_CMD_TV_START_SCAN
:
3027 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3028 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3030 case MP_CMD_TV_SET_FREQ
:
3031 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3032 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3033 cmd
->args
[0].v
.f
* 16.0);
3035 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3036 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3037 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3038 pvr_get_current_channelname (mpctx
->stream
),
3039 pvr_get_current_stationname (mpctx
->stream
));
3041 #endif /* CONFIG_PVR */
3044 case MP_CMD_TV_STEP_FREQ
:
3045 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3046 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3047 cmd
->args
[0].v
.f
* 16.0);
3049 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3050 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3051 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3052 pvr_get_current_channelname (mpctx
->stream
),
3053 pvr_get_current_frequency (mpctx
->stream
));
3055 #endif /* CONFIG_PVR */
3058 case MP_CMD_TV_SET_NORM
:
3059 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3060 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3064 case MP_CMD_TV_STEP_CHANNEL
:{
3065 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3066 int v
= cmd
->args
[0].v
.i
;
3068 tv_step_channel((tvi_handle_t
*) (mpctx
->
3072 tv_step_channel((tvi_handle_t
*) (mpctx
->
3076 if (tv_channel_list
) {
3077 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3078 "Channel: %s", tv_channel_current
->name
);
3079 //vo_osd_changed(OSDTYPE_SUBTITLE);
3083 else if (mpctx
->stream
&&
3084 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3085 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3086 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3087 pvr_get_current_channelname (mpctx
->stream
),
3088 pvr_get_current_stationname (mpctx
->stream
));
3090 #endif /* CONFIG_PVR */
3093 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3095 int v
= cmd
->args
[0].v
.i
;
3097 mpctx
->last_dvb_step
= v
;
3099 dir
= DVB_CHANNEL_HIGHER
;
3101 dir
= DVB_CHANNEL_LOWER
;
3104 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3105 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3106 mpctx
->dvbin_reopen
= 1;
3109 #endif /* CONFIG_DVBIN */
3112 case MP_CMD_TV_SET_CHANNEL
:
3113 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3114 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3116 if (tv_channel_list
) {
3117 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3118 "Channel: %s", tv_channel_current
->name
);
3119 //vo_osd_changed(OSDTYPE_SUBTITLE);
3123 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3124 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3125 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3126 pvr_get_current_channelname (mpctx
->stream
),
3127 pvr_get_current_stationname (mpctx
->stream
));
3129 #endif /* CONFIG_PVR */
3133 case MP_CMD_DVB_SET_CHANNEL
:
3134 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3135 mpctx
->last_dvb_step
= 1;
3137 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3138 cmd
->args
[0].v
.i
)) {
3139 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3140 mpctx
->dvbin_reopen
= 1;
3144 #endif /* CONFIG_DVBIN */
3146 case MP_CMD_TV_LAST_CHANNEL
:
3147 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3148 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3149 if (tv_channel_list
) {
3150 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3151 "Channel: %s", tv_channel_current
->name
);
3152 //vo_osd_changed(OSDTYPE_SUBTITLE);
3156 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3157 pvr_set_lastchannel (mpctx
->stream
);
3158 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3159 pvr_get_current_channelname (mpctx
->stream
),
3160 pvr_get_current_stationname (mpctx
->stream
));
3162 #endif /* CONFIG_PVR */
3165 case MP_CMD_TV_STEP_NORM
:
3166 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3167 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3170 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3171 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3172 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3174 #endif /* CONFIG_TV */
3175 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3177 if (mpctx
->demuxer
->teletext
)
3178 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3179 &(cmd
->args
[0].v
.s
));
3182 case MP_CMD_TV_TELETEXT_GO_LINK
:
3184 if (mpctx
->demuxer
->teletext
)
3185 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3186 &(cmd
->args
[0].v
.i
));
3190 case MP_CMD_SUB_LOAD
:
3192 int n
= mpctx
->set_of_sub_size
;
3193 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3194 if (n
!= mpctx
->set_of_sub_size
) {
3195 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3196 ++mpctx
->global_sub_size
;
3201 case MP_CMD_SUB_REMOVE
:
3203 int v
= cmd
->args
[0].v
.i
;
3205 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3206 } else if (v
< mpctx
->set_of_sub_size
) {
3207 remove_subtitle_range(mpctx
, v
, 1);
3212 case MP_CMD_GET_SUB_VISIBILITY
:
3214 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3215 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3219 case MP_CMD_SCREENSHOT
:
3220 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3221 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3223 ((vf_instance_t
*) sh_video
->vfilter
)->
3224 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3226 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3230 case MP_CMD_VF_CHANGE_RECTANGLE
:
3233 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3236 case MP_CMD_GET_TIME_LENGTH
:{
3237 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3238 demuxer_get_time_length(mpctx
->demuxer
));
3242 case MP_CMD_GET_FILENAME
:{
3243 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3244 get_metadata(mpctx
, META_NAME
));
3248 case MP_CMD_GET_VIDEO_CODEC
:{
3249 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3252 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3257 case MP_CMD_GET_VIDEO_BITRATE
:{
3258 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3261 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3266 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3267 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3270 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3271 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3276 case MP_CMD_GET_AUDIO_CODEC
:{
3277 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3280 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3285 case MP_CMD_GET_AUDIO_BITRATE
:{
3286 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3289 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3294 case MP_CMD_GET_AUDIO_SAMPLES
:{
3295 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3298 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3303 case MP_CMD_GET_META_TITLE
:{
3304 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3307 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3312 case MP_CMD_GET_META_ARTIST
:{
3313 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3316 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3321 case MP_CMD_GET_META_ALBUM
:{
3322 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3325 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3330 case MP_CMD_GET_META_YEAR
:{
3331 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3334 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3339 case MP_CMD_GET_META_COMMENT
:{
3340 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3343 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3348 case MP_CMD_GET_META_TRACK
:{
3349 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3352 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3357 case MP_CMD_GET_META_GENRE
:{
3358 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3361 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3366 case MP_CMD_GET_VO_FULLSCREEN
:
3367 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3368 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3371 case MP_CMD_GET_PERCENT_POS
:
3372 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3373 demuxer_get_percent_pos(mpctx
->demuxer
));
3376 case MP_CMD_GET_TIME_POS
:{
3379 pos
= sh_video
->pts
;
3380 else if (sh_audio
&& mpctx
->audio_out
)
3381 pos
= playing_audio_pts(mpctx
);
3382 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3389 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3395 case MP_CMD_KEYDOWN_EVENTS
:
3396 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3399 case MP_CMD_SET_MOUSE_POS
:{
3400 int pointer_x
, pointer_y
;
3402 pointer_x
= cmd
->args
[0].v
.i
;
3403 pointer_y
= cmd
->args
[1].v
.i
;
3404 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3405 #ifdef CONFIG_DVDNAV
3406 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3407 && dx
> 0.0 && dy
> 0.0) {
3409 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3410 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3411 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3412 pointer_x
, pointer_y
, &button
);
3413 if (opts
->osd_level
> 1 && button
> 0)
3414 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3415 "Selected button number %d", button
);
3419 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3420 menu_update_mouse_pos(dx
, dy
);
3425 #ifdef CONFIG_DVDNAV
3426 case MP_CMD_DVDNAV
:{
3429 mp_command_type command
= 0;
3430 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3433 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3434 if (cmd
->args
[0].v
.s
&&
3435 !strcasecmp (cmd
->args
[0].v
.s
,
3436 mp_dvdnav_bindings
[i
].name
))
3437 command
= mp_dvdnav_bindings
[i
].cmd
;
3439 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3440 if (opts
->osd_level
> 1 && button
> 0)
3441 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3442 "Selected button number %d", button
);
3446 case MP_CMD_SWITCH_TITLE
:
3447 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3448 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3453 case MP_CMD_AF_SWITCH
:
3456 af_uninit(mpctx
->mixer
.afilter
);
3457 af_init(mpctx
->mixer
.afilter
);
3464 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3465 char* af_commands
= af_args
;
3468 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3470 if (cmd
->id
== MP_CMD_AF_DEL
)
3472 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3474 af_remove(mpctx
->mixer
.afilter
, af
);
3477 af_add(mpctx
->mixer
.afilter
, af_command
);
3479 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3486 af_uninit(mpctx
->mixer
.afilter
);
3487 af_init(mpctx
->mixer
.afilter
);
3488 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3491 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3492 "Received unknown cmd %s\n", cmd
->name
);
3495 switch (cmd
->pausing
) {
3496 case 1: // "pausing"
3497 pause_player(mpctx
);
3499 case 3: // "pausing_toggle"
3501 unpause_player(mpctx
);
3503 pause_player(mpctx
);