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
->d_sub
->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
= get_time_length(mpctx
)))
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
= get_percent_pos(mpctx
);
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
, get_percent_pos(mpctx
));
423 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
424 mpctx
->rel_seek_secs
= pos
/ 100.0;
425 return M_PROPERTY_OK
;
428 /// Current position in seconds (RW)
429 static int mp_property_time_pos(m_option_t
*prop
, int action
,
430 void *arg
, MPContext
*mpctx
) {
431 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
432 return M_PROPERTY_UNAVAILABLE
;
436 if(!arg
) return M_PROPERTY_ERROR
;
437 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
438 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
439 mpctx
->rel_seek_secs
= *(double*)arg
;
440 return M_PROPERTY_OK
;
441 case M_PROPERTY_STEP_UP
:
442 case M_PROPERTY_STEP_DOWN
:
443 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
444 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
445 return M_PROPERTY_OK
;
447 return m_property_time_ro(prop
, action
, arg
, get_current_time(mpctx
));
450 /// Current chapter (RW)
451 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
454 struct MPOpts
*opts
= &mpctx
->opts
;
457 char *chapter_name
= NULL
;
460 chapter
= get_current_chapter(mpctx
);
462 return M_PROPERTY_UNAVAILABLE
;
467 return M_PROPERTY_ERROR
;
468 *(int *) arg
= chapter
;
469 return M_PROPERTY_OK
;
470 case M_PROPERTY_PRINT
: {
472 return M_PROPERTY_ERROR
;
473 chapter_name
= chapter_display_name(mpctx
, chapter
);
475 return M_PROPERTY_UNAVAILABLE
;
476 *(char **) arg
= chapter_name
;
477 return M_PROPERTY_OK
;
481 return M_PROPERTY_ERROR
;
482 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
483 step_all
= *(int *)arg
- chapter
;
486 case M_PROPERTY_STEP_UP
:
487 case M_PROPERTY_STEP_DOWN
: {
488 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
489 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
496 return M_PROPERTY_NOT_IMPLEMENTED
;
500 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
501 mpctx
->rel_seek_secs
= 0;
502 mpctx
->abs_seek_pos
= 0;
504 if (next_pts
> -1.0) {
505 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
506 mpctx
->rel_seek_secs
= next_pts
;
509 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
510 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
512 else if (step_all
> 0)
513 mpctx
->rel_seek_secs
= 1000000000.;
515 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
516 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
517 talloc_free(chapter_name
);
518 return M_PROPERTY_OK
;
521 /// Number of chapters in file
522 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
526 return M_PROPERTY_UNAVAILABLE
;
527 if (mpctx
->demuxer
->num_chapters
== 0)
528 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
529 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
532 /// Current dvd angle (RW)
533 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
536 struct MPOpts
*opts
= &mpctx
->opts
;
539 char *angle_name
= NULL
;
542 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
544 return M_PROPERTY_UNAVAILABLE
;
545 angles
= demuxer_angles_count(mpctx
->demuxer
);
547 return M_PROPERTY_UNAVAILABLE
;
552 return M_PROPERTY_ERROR
;
553 *(int *) arg
= angle
;
554 return M_PROPERTY_OK
;
555 case M_PROPERTY_PRINT
: {
557 return M_PROPERTY_ERROR
;
558 angle_name
= calloc(1, 64);
560 return M_PROPERTY_UNAVAILABLE
;
561 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
562 *(char **) arg
= angle_name
;
563 return M_PROPERTY_OK
;
567 return M_PROPERTY_ERROR
;
569 M_PROPERTY_CLAMP(prop
, angle
);
571 case M_PROPERTY_STEP_UP
:
572 case M_PROPERTY_STEP_DOWN
: {
578 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
580 if (angle
< 1) //cycle
585 return M_PROPERTY_NOT_IMPLEMENTED
;
587 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
589 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
591 resync_video_stream(sh_video
);
593 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
595 resync_audio_stream(sh_audio
);
598 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
599 "Angle: %d/%d", angle
, angles
);
601 return M_PROPERTY_OK
;
604 /// Demuxer meta data
605 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
607 m_property_action_t
* ka
;
609 static const m_option_t key_type
=
610 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
612 return M_PROPERTY_UNAVAILABLE
;
616 if(!arg
) return M_PROPERTY_ERROR
;
617 *(char***)arg
= mpctx
->demuxer
->info
;
618 return M_PROPERTY_OK
;
619 case M_PROPERTY_KEY_ACTION
:
620 if(!arg
) return M_PROPERTY_ERROR
;
622 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
623 return M_PROPERTY_UNKNOWN
;
626 if(!ka
->arg
) return M_PROPERTY_ERROR
;
627 *(char**)ka
->arg
= meta
;
628 return M_PROPERTY_OK
;
629 case M_PROPERTY_GET_TYPE
:
630 if(!ka
->arg
) return M_PROPERTY_ERROR
;
631 *(const m_option_t
**)ka
->arg
= &key_type
;
632 return M_PROPERTY_OK
;
635 return M_PROPERTY_NOT_IMPLEMENTED
;
638 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
641 MPContext
*mpctx
= ctx
;
646 return M_PROPERTY_ERROR
;
647 if (mpctx
->paused
== (bool)*(int *) arg
)
648 return M_PROPERTY_OK
;
649 case M_PROPERTY_STEP_UP
:
650 case M_PROPERTY_STEP_DOWN
:
652 unpause_player(mpctx
);
653 mpctx
->osd_function
= OSD_PLAY
;
657 mpctx
->osd_function
= OSD_PAUSE
;
659 return M_PROPERTY_OK
;
661 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
668 /// \defgroup AudioProperties Audio properties
669 /// \ingroup Properties
673 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
677 if (!mpctx
->sh_audio
)
678 return M_PROPERTY_UNAVAILABLE
;
683 return M_PROPERTY_ERROR
;
684 mixer_getbothvolume(&mpctx
->mixer
, arg
);
685 return M_PROPERTY_OK
;
686 case M_PROPERTY_PRINT
:{
689 return M_PROPERTY_ERROR
;
690 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
691 return m_property_float_range(prop
, action
, arg
, &vol
);
693 case M_PROPERTY_STEP_UP
:
694 case M_PROPERTY_STEP_DOWN
:
698 return M_PROPERTY_NOT_IMPLEMENTED
;
701 if (mpctx
->edl_muted
)
702 return M_PROPERTY_DISABLED
;
703 mpctx
->user_muted
= 0;
708 return M_PROPERTY_ERROR
;
709 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
710 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
711 return M_PROPERTY_OK
;
712 case M_PROPERTY_STEP_UP
:
713 if (arg
&& *(float *) arg
<= 0)
714 mixer_decvolume(&mpctx
->mixer
);
716 mixer_incvolume(&mpctx
->mixer
);
717 return M_PROPERTY_OK
;
718 case M_PROPERTY_STEP_DOWN
:
719 if (arg
&& *(float *) arg
<= 0)
720 mixer_incvolume(&mpctx
->mixer
);
722 mixer_decvolume(&mpctx
->mixer
);
723 return M_PROPERTY_OK
;
725 return M_PROPERTY_NOT_IMPLEMENTED
;
729 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
733 if (!mpctx
->sh_audio
)
734 return M_PROPERTY_UNAVAILABLE
;
738 if (mpctx
->edl_muted
)
739 return M_PROPERTY_DISABLED
;
741 return M_PROPERTY_ERROR
;
742 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
743 mixer_mute(&mpctx
->mixer
);
744 mpctx
->user_muted
= mpctx
->mixer
.muted
;
745 return M_PROPERTY_OK
;
746 case M_PROPERTY_STEP_UP
:
747 case M_PROPERTY_STEP_DOWN
:
748 if (mpctx
->edl_muted
)
749 return M_PROPERTY_DISABLED
;
750 mixer_mute(&mpctx
->mixer
);
751 mpctx
->user_muted
= mpctx
->mixer
.muted
;
752 return M_PROPERTY_OK
;
753 case M_PROPERTY_PRINT
:
755 return M_PROPERTY_ERROR
;
756 if (mpctx
->edl_muted
) {
757 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
758 return M_PROPERTY_OK
;
761 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
767 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
768 void *arg
, MPContext
*mpctx
)
770 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
771 return M_PROPERTY_UNAVAILABLE
;
774 case M_PROPERTY_STEP_UP
:
775 case M_PROPERTY_STEP_DOWN
: {
777 float delay
= audio_delay
;
778 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
779 if (ret
!= M_PROPERTY_OK
)
782 mpctx
->delay
-= audio_delay
- delay
;
784 return M_PROPERTY_OK
;
786 return m_property_delay(prop
, action
, arg
, &audio_delay
);
790 /// Audio codec tag (RO)
791 static int mp_property_audio_format(m_option_t
*prop
, int action
,
792 void *arg
, MPContext
*mpctx
)
794 if (!mpctx
->sh_audio
)
795 return M_PROPERTY_UNAVAILABLE
;
796 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
799 /// Audio codec name (RO)
800 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
801 void *arg
, MPContext
*mpctx
)
803 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
804 return M_PROPERTY_UNAVAILABLE
;
805 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
808 /// Audio bitrate (RO)
809 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
810 void *arg
, MPContext
*mpctx
)
812 if (!mpctx
->sh_audio
)
813 return M_PROPERTY_UNAVAILABLE
;
814 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
818 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
821 if (!mpctx
->sh_audio
)
822 return M_PROPERTY_UNAVAILABLE
;
824 case M_PROPERTY_PRINT
:
825 if(!arg
) return M_PROPERTY_ERROR
;
826 *(char**)arg
= malloc(16);
827 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
828 return M_PROPERTY_OK
;
830 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
833 /// Number of channels (RO)
834 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
837 if (!mpctx
->sh_audio
)
838 return M_PROPERTY_UNAVAILABLE
;
840 case M_PROPERTY_PRINT
:
842 return M_PROPERTY_ERROR
;
843 switch (mpctx
->sh_audio
->channels
) {
845 *(char **) arg
= strdup("mono");
848 *(char **) arg
= strdup("stereo");
851 *(char **) arg
= malloc(32);
852 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
854 return M_PROPERTY_OK
;
856 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
860 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
865 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
866 return M_PROPERTY_UNAVAILABLE
;
871 return M_PROPERTY_ERROR
;
872 mixer_getbalance(&mpctx
->mixer
, arg
);
873 return M_PROPERTY_OK
;
874 case M_PROPERTY_PRINT
: {
877 return M_PROPERTY_ERROR
;
878 mixer_getbalance(&mpctx
->mixer
, &bal
);
880 *str
= strdup("center");
881 else if (bal
== -1.f
)
882 *str
= strdup("left only");
884 *str
= strdup("right only");
886 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
887 *str
= malloc(sizeof("left xxx%, right xxx%"));
888 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
890 return M_PROPERTY_OK
;
892 case M_PROPERTY_STEP_UP
:
893 case M_PROPERTY_STEP_DOWN
:
894 mixer_getbalance(&mpctx
->mixer
, &bal
);
895 bal
+= (arg
? *(float*)arg
: .1f
) *
896 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
897 M_PROPERTY_CLAMP(prop
, bal
);
898 mixer_setbalance(&mpctx
->mixer
, bal
);
899 return M_PROPERTY_OK
;
902 return M_PROPERTY_ERROR
;
903 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
904 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
905 return M_PROPERTY_OK
;
907 return M_PROPERTY_NOT_IMPLEMENTED
;
910 /// Selected audio id (RW)
911 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
915 if (!mpctx
->demuxer
|| !mpctx
->d_audio
)
916 return M_PROPERTY_UNAVAILABLE
;
917 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
922 return M_PROPERTY_ERROR
;
923 *(int *) arg
= current_id
;
924 return M_PROPERTY_OK
;
925 case M_PROPERTY_PRINT
:
927 return M_PROPERTY_ERROR
;
930 *(char **) arg
= strdup(mp_gtext("disabled"));
933 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
934 sh_audio_t
* sh
= mpctx
->sh_audio
;
936 av_strlcpy(lang
, sh
->lang
, 40);
937 #ifdef CONFIG_DVDREAD
938 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
939 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
949 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
950 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
952 *(char **) arg
= malloc(64);
953 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
955 return M_PROPERTY_OK
;
957 case M_PROPERTY_STEP_UP
:
959 if (action
== M_PROPERTY_SET
&& arg
)
960 tmp
= *((int *) arg
);
963 int new_id
= demuxer_switch_audio(mpctx
->d_audio
->demuxer
, tmp
);
964 if (new_id
!= current_id
)
965 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
966 if (new_id
!= current_id
&& new_id
>= 0) {
968 sh2
= mpctx
->d_audio
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
969 sh2
->ds
= mpctx
->demuxer
->audio
;
970 mpctx
->sh_audio
= sh2
;
971 reinit_audio_chain(mpctx
);
973 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
974 return M_PROPERTY_OK
;
976 return M_PROPERTY_NOT_IMPLEMENTED
;
981 /// Selected video id (RW)
982 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
985 struct MPOpts
*opts
= &mpctx
->opts
;
987 if (!mpctx
->demuxer
|| !mpctx
->d_video
)
988 return M_PROPERTY_UNAVAILABLE
;
989 current_id
= mpctx
->d_video
->id
;
994 return M_PROPERTY_ERROR
;
995 *(int *) arg
= current_id
;
996 return M_PROPERTY_OK
;
997 case M_PROPERTY_PRINT
:
999 return M_PROPERTY_ERROR
;
1002 *(char **) arg
= strdup(mp_gtext("disabled"));
1005 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1006 *(char **) arg
= malloc(64);
1007 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1009 return M_PROPERTY_OK
;
1011 case M_PROPERTY_STEP_UP
:
1012 case M_PROPERTY_SET
:
1013 if (action
== M_PROPERTY_SET
&& arg
)
1014 tmp
= *((int *) arg
);
1017 opts
->video_id
= demuxer_switch_video(mpctx
->d_video
->demuxer
, tmp
);
1018 if (opts
->video_id
== -2
1019 || (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
1020 && current_id
!= -2))
1021 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1022 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1023 if (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
) {
1025 sh2
= mpctx
->d_video
->demuxer
->v_streams
[mpctx
->d_video
->id
];
1027 sh2
->ds
= mpctx
->d_video
;
1028 mpctx
->sh_video
= sh2
;
1029 reinit_video_chain(mpctx
);
1032 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1033 return M_PROPERTY_OK
;
1036 return M_PROPERTY_NOT_IMPLEMENTED
;
1040 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1043 demux_program_t prog
;
1046 case M_PROPERTY_STEP_UP
:
1047 case M_PROPERTY_SET
:
1048 if (action
== M_PROPERTY_SET
&& arg
)
1049 prog
.progid
= *((int *) arg
);
1053 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1054 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1055 return M_PROPERTY_ERROR
;
1057 if (prog
.aid
< 0 && prog
.vid
< 0) {
1058 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1059 return M_PROPERTY_ERROR
;
1061 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1062 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1063 return M_PROPERTY_OK
;
1066 return M_PROPERTY_NOT_IMPLEMENTED
;
1072 /// \defgroup VideoProperties Video properties
1073 /// \ingroup Properties
1076 /// Fullscreen state (RW)
1077 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1081 if (!mpctx
->video_out
)
1082 return M_PROPERTY_UNAVAILABLE
;
1085 case M_PROPERTY_SET
:
1087 return M_PROPERTY_ERROR
;
1088 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1089 if (vo_fs
== !!*(int *) arg
)
1090 return M_PROPERTY_OK
;
1091 case M_PROPERTY_STEP_UP
:
1092 case M_PROPERTY_STEP_DOWN
:
1093 if (mpctx
->video_out
->config_ok
)
1094 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1095 mpctx
->opts
.fullscreen
= vo_fs
;
1096 return M_PROPERTY_OK
;
1098 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1102 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1103 void *arg
, MPContext
*mpctx
)
1107 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1108 return M_PROPERTY_UNAVAILABLE
;
1109 vf
= mpctx
->sh_video
->vfilter
;
1111 case M_PROPERTY_GET
:
1113 return M_PROPERTY_ERROR
;
1114 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1115 return M_PROPERTY_OK
;
1116 case M_PROPERTY_SET
:
1118 return M_PROPERTY_ERROR
;
1119 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1120 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1121 return M_PROPERTY_OK
;
1122 case M_PROPERTY_STEP_UP
:
1123 case M_PROPERTY_STEP_DOWN
:
1124 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1125 deinterlace
= !deinterlace
;
1126 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1127 return M_PROPERTY_OK
;
1130 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1131 return m_property_flag_ro(prop
, action
, arg
, value
);
1134 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1135 void *arg
, MPContext
*mpctx
)
1137 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1138 return M_PROPERTY_UNAVAILABLE
;
1140 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1143 case M_PROPERTY_GET
:
1145 return M_PROPERTY_ERROR
;
1146 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1147 return M_PROPERTY_UNAVAILABLE
;
1148 return M_PROPERTY_OK
;
1149 case M_PROPERTY_PRINT
:
1151 return M_PROPERTY_ERROR
;
1152 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1153 return M_PROPERTY_UNAVAILABLE
;
1154 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1155 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1156 *(char **)arg
= strdup("Unknown");
1158 *(char**)arg
= strdup(names
[colorspace
]);
1159 return M_PROPERTY_OK
;
1160 case M_PROPERTY_SET
:
1162 return M_PROPERTY_ERROR
;
1163 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1164 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1165 return M_PROPERTY_OK
;
1166 case M_PROPERTY_STEP_UP
:;
1167 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1168 return M_PROPERTY_UNAVAILABLE
;
1170 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1171 return M_PROPERTY_OK
;
1173 return M_PROPERTY_NOT_IMPLEMENTED
;
1176 static int mp_property_capture(m_option_t
*prop
, int action
,
1177 void *arg
, MPContext
*mpctx
)
1179 struct MPOpts
*opts
= &mpctx
->opts
;
1182 return M_PROPERTY_UNAVAILABLE
;
1184 if (!opts
->capture_dump
) {
1185 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1186 "Capturing not enabled (forgot -capture parameter?)\n");
1187 return M_PROPERTY_ERROR
;
1190 int capturing
= !!mpctx
->stream
->capture_file
;
1192 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1193 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1195 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1196 if (!mpctx
->stream
->capture_file
) {
1197 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1198 "Error opening capture file: %s\n", strerror(errno
));
1199 ret
= M_PROPERTY_ERROR
;
1202 fclose(mpctx
->stream
->capture_file
);
1203 mpctx
->stream
->capture_file
= NULL
;
1211 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1215 if (!mpctx
->video_out
1216 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1217 return M_PROPERTY_UNAVAILABLE
;
1220 case M_PROPERTY_SET
:
1222 return M_PROPERTY_ERROR
;
1223 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1224 vo_panscan
= *(float *) arg
;
1225 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1226 return M_PROPERTY_OK
;
1227 case M_PROPERTY_STEP_UP
:
1228 case M_PROPERTY_STEP_DOWN
:
1229 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1230 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1233 else if (vo_panscan
< 0)
1235 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1236 return M_PROPERTY_OK
;
1238 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1242 /// Helper to set vo flags.
1243 /** \ingroup PropertyImplHelper
1245 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1246 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1249 if (!mpctx
->video_out
)
1250 return M_PROPERTY_UNAVAILABLE
;
1253 case M_PROPERTY_SET
:
1255 return M_PROPERTY_ERROR
;
1256 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1257 if (*vo_var
== !!*(int *) arg
)
1258 return M_PROPERTY_OK
;
1259 case M_PROPERTY_STEP_UP
:
1260 case M_PROPERTY_STEP_DOWN
:
1261 if (mpctx
->video_out
->config_ok
)
1262 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1263 return M_PROPERTY_OK
;
1265 return m_property_flag(prop
, action
, arg
, vo_var
);
1269 /// Window always on top (RW)
1270 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1273 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1274 &mpctx
->opts
.vo_ontop
, mpctx
);
1277 /// Display in the root window (RW)
1278 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1281 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1282 &vo_rootwin
, mpctx
);
1285 /// Show window borders (RW)
1286 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1289 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1293 /// Framedropping state (RW)
1294 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1295 void *arg
, MPContext
*mpctx
)
1298 if (!mpctx
->sh_video
)
1299 return M_PROPERTY_UNAVAILABLE
;
1302 case M_PROPERTY_PRINT
:
1304 return M_PROPERTY_ERROR
;
1305 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1306 (frame_dropping
== 2 ? mp_gtext("hard") :
1307 mp_gtext("disabled")));
1308 return M_PROPERTY_OK
;
1310 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1314 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1315 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1318 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1321 if (!mpctx
->sh_video
)
1322 return M_PROPERTY_UNAVAILABLE
;
1324 if (gamma
[0] == 1000) {
1326 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1330 case M_PROPERTY_SET
:
1332 return M_PROPERTY_ERROR
;
1333 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1334 *gamma
= *(int *) arg
;
1335 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1339 case M_PROPERTY_GET
:
1340 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1342 return M_PROPERTY_ERROR
;
1344 return M_PROPERTY_OK
;
1347 case M_PROPERTY_STEP_UP
:
1348 case M_PROPERTY_STEP_DOWN
:
1349 *gamma
+= (arg
? *(int *) arg
: 1) *
1350 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1351 M_PROPERTY_CLAMP(prop
, *gamma
);
1352 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1357 return M_PROPERTY_NOT_IMPLEMENTED
;
1361 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1362 int l
= strlen(prop
->name
);
1363 char tv_prop
[3 + l
+ 1];
1364 sprintf(tv_prop
, "tv_%s", prop
->name
);
1365 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1369 return M_PROPERTY_UNAVAILABLE
;
1373 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1376 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1379 /// Video codec tag (RO)
1380 static int mp_property_video_format(m_option_t
*prop
, int action
,
1381 void *arg
, MPContext
*mpctx
)
1384 if (!mpctx
->sh_video
)
1385 return M_PROPERTY_UNAVAILABLE
;
1387 case M_PROPERTY_PRINT
:
1389 return M_PROPERTY_ERROR
;
1390 switch(mpctx
->sh_video
->format
) {
1392 meta
= strdup ("mpeg1"); break;
1394 meta
= strdup ("mpeg2"); break;
1396 meta
= strdup ("mpeg4"); break;
1398 meta
= strdup ("h264"); break;
1400 if(mpctx
->sh_video
->format
>= 0x20202020) {
1402 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1405 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1408 *(char**)arg
= meta
;
1409 return M_PROPERTY_OK
;
1411 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1414 /// Video codec name (RO)
1415 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1416 void *arg
, MPContext
*mpctx
)
1418 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1419 return M_PROPERTY_UNAVAILABLE
;
1420 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1424 /// Video bitrate (RO)
1425 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1426 void *arg
, MPContext
*mpctx
)
1428 if (!mpctx
->sh_video
)
1429 return M_PROPERTY_UNAVAILABLE
;
1430 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1433 /// Video display width (RO)
1434 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1437 if (!mpctx
->sh_video
)
1438 return M_PROPERTY_UNAVAILABLE
;
1439 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1442 /// Video display height (RO)
1443 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1446 if (!mpctx
->sh_video
)
1447 return M_PROPERTY_UNAVAILABLE
;
1448 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1452 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1455 if (!mpctx
->sh_video
)
1456 return M_PROPERTY_UNAVAILABLE
;
1457 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1460 /// Video aspect (RO)
1461 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1464 if (!mpctx
->sh_video
)
1465 return M_PROPERTY_UNAVAILABLE
;
1466 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1471 /// \defgroup SubProprties Subtitles properties
1472 /// \ingroup Properties
1475 /// Text subtitle position (RW)
1476 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1480 case M_PROPERTY_SET
:
1482 return M_PROPERTY_ERROR
;
1483 case M_PROPERTY_STEP_UP
:
1484 case M_PROPERTY_STEP_DOWN
:
1485 vo_osd_changed(OSDTYPE_SUBTITLE
);
1487 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1491 /// Selected subtitles (RW)
1492 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1495 struct MPOpts
*opts
= &mpctx
->opts
;
1496 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1497 int source
= -1, reset_spu
= 0;
1498 int source_pos
= -1;
1501 update_global_sub_size(mpctx
);
1502 const int global_sub_size
= mpctx
->global_sub_size
;
1504 if (global_sub_size
<= 0)
1505 return M_PROPERTY_UNAVAILABLE
;
1508 case M_PROPERTY_GET
:
1510 return M_PROPERTY_ERROR
;
1511 *(int *) arg
= mpctx
->global_sub_pos
;
1512 return M_PROPERTY_OK
;
1513 case M_PROPERTY_PRINT
:
1515 return M_PROPERTY_ERROR
;
1516 *(char **) arg
= malloc(64);
1517 (*(char **) arg
)[63] = 0;
1520 sub_name
= subdata
->filename
;
1522 if (ass_track
&& ass_track
->name
)
1523 sub_name
= ass_track
->name
;
1528 if ((tmp2
= strrchr(tmp
, '/')))
1531 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1532 mpctx
->set_of_sub_pos
+ 1,
1533 strlen(tmp
) < 20 ? "" : "...",
1534 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1535 return M_PROPERTY_OK
;
1537 #ifdef CONFIG_DVDNAV
1538 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1539 if (vo_spudec
&& opts
->sub_id
>= 0) {
1540 unsigned char lang
[3];
1541 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1542 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1543 return M_PROPERTY_OK
;
1549 if ((d_sub
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1550 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF
1551 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1552 || d_sub
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1553 && d_sub
->sh
&& opts
->sub_id
>= 0) {
1554 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1555 if (!lang
) lang
= mp_gtext("unknown");
1556 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1557 return M_PROPERTY_OK
;
1560 if (vo_vobsub
&& vobsub_id
>= 0) {
1561 const char *language
= mp_gtext("unknown");
1562 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1563 snprintf(*(char **) arg
, 63, "(%d) %s",
1564 vobsub_id
, language
? language
: mp_gtext("unknown"));
1565 return M_PROPERTY_OK
;
1567 #ifdef CONFIG_DVDREAD
1568 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1569 && opts
->sub_id
>= 0) {
1571 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1572 lang
[0] = code
>> 8;
1575 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1576 return M_PROPERTY_OK
;
1579 if (opts
->sub_id
>= 0) {
1580 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1581 mp_gtext("unknown"));
1582 return M_PROPERTY_OK
;
1584 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1585 return M_PROPERTY_OK
;
1587 case M_PROPERTY_SET
:
1589 return M_PROPERTY_ERROR
;
1590 if (*(int *) arg
< -1)
1592 else if (*(int *) arg
>= global_sub_size
)
1593 *(int *) arg
= global_sub_size
- 1;
1594 mpctx
->global_sub_pos
= *(int *) arg
;
1596 case M_PROPERTY_STEP_UP
:
1597 mpctx
->global_sub_pos
+= 2;
1598 mpctx
->global_sub_pos
=
1599 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1601 case M_PROPERTY_STEP_DOWN
:
1602 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1603 mpctx
->global_sub_pos
=
1604 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1607 return M_PROPERTY_NOT_IMPLEMENTED
;
1610 if (mpctx
->global_sub_pos
>= 0) {
1611 source
= sub_source(mpctx
);
1612 source_pos
= sub_source_pos(mpctx
);
1615 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1616 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1618 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1619 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1620 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1621 mpctx
->global_sub_pos
, source
);
1623 mpctx
->set_of_sub_pos
= -1;
1637 if (source
== SUB_SOURCE_VOBSUB
) {
1638 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1639 } else if (source
== SUB_SOURCE_SUBS
) {
1640 mpctx
->set_of_sub_pos
= source_pos
;
1642 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1643 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1647 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1648 vo_osd_changed(OSDTYPE_SUBTITLE
);
1650 } else if (source
== SUB_SOURCE_DEMUX
) {
1651 opts
->sub_id
= source_pos
;
1652 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1654 // default: assume 1:1 mapping of sid and stream id
1655 d_sub
->id
= opts
->sub_id
;
1656 d_sub
->sh
= mpctx
->d_sub
->demuxer
->s_streams
[d_sub
->id
];
1657 ds_free_packs(d_sub
);
1658 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1659 sh_sub_t
*sh
= mpctx
->d_sub
->demuxer
->s_streams
[i
];
1660 if (sh
&& sh
->sid
== opts
->sub_id
) {
1666 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1667 sh_sub_t
*sh
= d_sub
->sh
;
1668 if (sh
->type
== 'v')
1669 init_vo_spudec(mpctx
);
1671 else if (opts
->ass_enabled
)
1672 ass_track
= sh
->ass_track
;
1680 #ifdef CONFIG_DVDREAD
1682 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1683 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1684 && opts
->sub_id
< 0 && reset_spu
) {
1690 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1692 return M_PROPERTY_OK
;
1695 /// Selected sub source (RW)
1696 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1700 update_global_sub_size(mpctx
);
1701 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1702 return M_PROPERTY_UNAVAILABLE
;
1705 case M_PROPERTY_GET
:
1707 return M_PROPERTY_ERROR
;
1708 *(int *) arg
= sub_source(mpctx
);
1709 return M_PROPERTY_OK
;
1710 case M_PROPERTY_PRINT
:
1712 return M_PROPERTY_ERROR
;
1713 *(char **) arg
= malloc(64);
1714 (*(char **) arg
)[63] = 0;
1715 switch (sub_source(mpctx
))
1717 case SUB_SOURCE_SUBS
:
1718 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1720 case SUB_SOURCE_VOBSUB
:
1721 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1723 case SUB_SOURCE_DEMUX
:
1724 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1727 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1729 return M_PROPERTY_OK
;
1730 case M_PROPERTY_SET
:
1732 return M_PROPERTY_ERROR
;
1733 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1734 if (*(int *) arg
< 0)
1735 mpctx
->global_sub_pos
= -1;
1736 else if (*(int *) arg
!= sub_source(mpctx
)) {
1737 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1739 return M_PROPERTY_UNAVAILABLE
;
1740 mpctx
->global_sub_pos
= new_pos
;
1743 case M_PROPERTY_STEP_UP
:
1744 case M_PROPERTY_STEP_DOWN
: {
1745 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1746 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1747 int step
= (step_all
> 0) ? 1 : -1;
1748 int cur_source
= sub_source(mpctx
);
1749 source
= cur_source
;
1752 if (source
>= SUB_SOURCES
)
1754 else if (source
< -1)
1755 source
= SUB_SOURCES
- 1;
1756 if (source
== cur_source
|| source
== -1 ||
1757 mpctx
->sub_counts
[source
])
1760 if (source
== cur_source
)
1761 return M_PROPERTY_OK
;
1763 mpctx
->global_sub_pos
= -1;
1765 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1769 return M_PROPERTY_NOT_IMPLEMENTED
;
1771 --mpctx
->global_sub_pos
;
1772 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1775 /// Selected subtitles from specific source (RW)
1776 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1779 int source
, is_cur_source
, offset
, new_pos
;
1780 update_global_sub_size(mpctx
);
1781 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1782 return M_PROPERTY_UNAVAILABLE
;
1784 if (!strcmp(prop
->name
, "sub_file"))
1785 source
= SUB_SOURCE_SUBS
;
1786 else if (!strcmp(prop
->name
, "sub_vob"))
1787 source
= SUB_SOURCE_VOBSUB
;
1788 else if (!strcmp(prop
->name
, "sub_demux"))
1789 source
= SUB_SOURCE_DEMUX
;
1791 return M_PROPERTY_ERROR
;
1793 offset
= sub_pos_by_source(mpctx
, source
);
1795 return M_PROPERTY_UNAVAILABLE
;
1797 is_cur_source
= sub_source(mpctx
) == source
;
1798 new_pos
= mpctx
->global_sub_pos
;
1800 case M_PROPERTY_GET
:
1802 return M_PROPERTY_ERROR
;
1803 if (is_cur_source
) {
1804 *(int *) arg
= sub_source_pos(mpctx
);
1805 if (source
== SUB_SOURCE_VOBSUB
)
1806 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1810 return M_PROPERTY_OK
;
1811 case M_PROPERTY_PRINT
:
1813 return M_PROPERTY_ERROR
;
1815 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1816 *(char **) arg
= malloc(64);
1817 (*(char **) arg
)[63] = 0;
1818 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1819 return M_PROPERTY_OK
;
1820 case M_PROPERTY_SET
:
1822 return M_PROPERTY_ERROR
;
1823 if (*(int *) arg
>= 0) {
1824 int index
= *(int *)arg
;
1825 if (source
== SUB_SOURCE_VOBSUB
)
1826 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1827 new_pos
= offset
+ index
;
1828 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1836 case M_PROPERTY_STEP_UP
:
1837 case M_PROPERTY_STEP_DOWN
: {
1838 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1839 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1840 int step
= (step_all
> 0) ? 1 : -1;
1841 int max_sub_pos_for_source
= -1;
1845 if (new_pos
== -1) {
1848 else if (max_sub_pos_for_source
== -1) {
1849 // Find max pos for specific source
1850 new_pos
= mpctx
->global_sub_size
- 1;
1852 && sub_source(mpctx
) != source
)
1856 new_pos
= max_sub_pos_for_source
;
1860 if (new_pos
< offset
||
1861 new_pos
>= mpctx
->global_sub_size
||
1862 sub_source(mpctx
) != source
)
1870 return M_PROPERTY_NOT_IMPLEMENTED
;
1872 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1875 /// Subtitle delay (RW)
1876 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1879 if (!mpctx
->sh_video
)
1880 return M_PROPERTY_UNAVAILABLE
;
1881 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1884 /// Alignment of text subtitles (RW)
1885 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1886 void *arg
, MPContext
*mpctx
)
1888 char *name
[] = { _("top"), _("center"), _("bottom") };
1890 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1891 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1892 return M_PROPERTY_UNAVAILABLE
;
1895 case M_PROPERTY_PRINT
:
1897 return M_PROPERTY_ERROR
;
1898 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1899 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1900 return M_PROPERTY_OK
;
1901 case M_PROPERTY_SET
:
1903 return M_PROPERTY_ERROR
;
1904 case M_PROPERTY_STEP_UP
:
1905 case M_PROPERTY_STEP_DOWN
:
1906 vo_osd_changed(OSDTYPE_SUBTITLE
);
1908 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1912 /// Subtitle visibility (RW)
1913 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1914 void *arg
, MPContext
*mpctx
)
1916 if (!mpctx
->sh_video
)
1917 return M_PROPERTY_UNAVAILABLE
;
1920 case M_PROPERTY_SET
:
1922 return M_PROPERTY_ERROR
;
1923 case M_PROPERTY_STEP_UP
:
1924 case M_PROPERTY_STEP_DOWN
:
1925 vo_osd_changed(OSDTYPE_SUBTITLE
);
1927 vo_osd_changed(OSDTYPE_SPU
);
1929 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1934 /// Use margins for libass subtitles (RW)
1935 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1936 void *arg
, MPContext
*mpctx
)
1938 if (!mpctx
->sh_video
)
1939 return M_PROPERTY_UNAVAILABLE
;
1942 case M_PROPERTY_SET
:
1944 return M_PROPERTY_ERROR
;
1945 case M_PROPERTY_STEP_UP
:
1946 case M_PROPERTY_STEP_DOWN
:
1947 ass_force_reload
= 1;
1949 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1954 /// Show only forced subtitles (RW)
1955 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1956 void *arg
, MPContext
*mpctx
)
1959 return M_PROPERTY_UNAVAILABLE
;
1962 case M_PROPERTY_SET
:
1964 return M_PROPERTY_ERROR
;
1965 case M_PROPERTY_STEP_UP
:
1966 case M_PROPERTY_STEP_DOWN
:
1967 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1968 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1969 return M_PROPERTY_OK
;
1971 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1976 #ifdef CONFIG_FREETYPE
1977 /// Subtitle scale (RW)
1978 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1981 struct MPOpts
*opts
= &mpctx
->opts
;
1984 case M_PROPERTY_SET
:
1986 return M_PROPERTY_ERROR
;
1987 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1989 if (opts
->ass_enabled
) {
1990 ass_font_scale
= *(float *) arg
;
1991 ass_force_reload
= 1;
1994 text_font_scale_factor
= *(float *) arg
;
1995 force_load_font
= 1;
1996 return M_PROPERTY_OK
;
1997 case M_PROPERTY_STEP_UP
:
1998 case M_PROPERTY_STEP_DOWN
:
2000 if (opts
->ass_enabled
) {
2001 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
2002 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2003 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
2004 ass_force_reload
= 1;
2007 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
2008 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2009 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2010 force_load_font
= 1;
2011 return M_PROPERTY_OK
;
2014 if (opts
->ass_enabled
)
2015 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
2018 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2025 /// \defgroup TVProperties TV properties
2026 /// \ingroup Properties
2031 /// TV color settings (RW)
2032 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2036 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2037 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2038 return M_PROPERTY_UNAVAILABLE
;
2041 case M_PROPERTY_SET
:
2043 return M_PROPERTY_ERROR
;
2044 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2045 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2046 case M_PROPERTY_GET
:
2047 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2048 case M_PROPERTY_STEP_UP
:
2049 case M_PROPERTY_STEP_DOWN
:
2050 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2052 return M_PROPERTY_ERROR
;
2053 val
+= (arg
? *(int *) arg
: 1) *
2054 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2055 M_PROPERTY_CLAMP(prop
, val
);
2056 return tv_set_color_options(tvh
, prop
->offset
, val
);
2058 return M_PROPERTY_ERROR
;
2060 return M_PROPERTY_NOT_IMPLEMENTED
;
2065 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2069 int base_ioctl
= prop
->offset
;
2071 for teletext's GET,SET,STEP ioctls this is not 0
2075 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2076 return M_PROPERTY_UNAVAILABLE
;
2078 return M_PROPERTY_ERROR
;
2081 case M_PROPERTY_GET
:
2083 return M_PROPERTY_ERROR
;
2084 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2086 case M_PROPERTY_SET
:
2088 return M_PROPERTY_ERROR
;
2089 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2090 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2092 case M_PROPERTY_STEP_UP
:
2093 case M_PROPERTY_STEP_DOWN
:
2094 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2095 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2096 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2099 return M_PROPERTY_NOT_IMPLEMENTED
;
2102 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2105 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2111 //with tvh==NULL will fail too
2112 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2113 if(result
!=M_PROPERTY_OK
)
2116 if(teletext_control(mpctx
->demuxer
->teletext
,
2117 prop
->offset
, &val
)==VBI_CONTROL_TRUE
&& val
)
2118 mp_input_set_section(mpctx
->input
, "teletext");
2120 mp_input_set_section(mpctx
->input
, "tv");
2121 return M_PROPERTY_OK
;
2124 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2129 if (!mpctx
->demuxer
->teletext
)
2130 return M_PROPERTY_UNAVAILABLE
;
2132 case M_PROPERTY_STEP_UP
:
2133 case M_PROPERTY_STEP_DOWN
:
2134 //This should be handled separately
2135 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2136 result
=teletext_control(mpctx
->demuxer
->teletext
,
2137 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2140 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2147 /// All properties available in MPlayer.
2148 /** \ingroup Properties
2150 static const m_option_t mp_properties
[] = {
2152 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2153 M_OPT_RANGE
, 0, 3, NULL
},
2154 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2155 M_OPT_MIN
, -1, 0, NULL
},
2156 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2157 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2158 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2160 { "path", mp_property_path
, CONF_TYPE_STRING
,
2162 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2164 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2165 M_OPT_MIN
, 0, 0, NULL
},
2166 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2167 M_OPT_MIN
, 0, 0, NULL
},
2168 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2169 M_OPT_MIN
, 0, 0, NULL
},
2170 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2171 M_OPT_MIN
, 0, 0, NULL
},
2172 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2173 M_OPT_MIN
, 0, 0, NULL
},
2174 { "length", mp_property_length
, CONF_TYPE_TIME
,
2175 M_OPT_MIN
, 0, 0, NULL
},
2176 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2177 M_OPT_RANGE
, 0, 100, NULL
},
2178 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2179 M_OPT_MIN
, 0, 0, NULL
},
2180 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2181 M_OPT_MIN
, 0, 0, NULL
},
2182 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2184 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2185 CONF_RANGE
, -2, 10, NULL
},
2186 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2188 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2189 M_OPT_RANGE
, 0, 1, NULL
},
2190 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2191 M_OPT_RANGE
, 0, 1, NULL
},
2194 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2195 M_OPT_RANGE
, 0, 100, NULL
},
2196 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2197 M_OPT_RANGE
, 0, 1, NULL
},
2198 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2199 M_OPT_RANGE
, -100, 100, NULL
},
2200 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2202 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2204 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2206 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2208 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2210 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2211 CONF_RANGE
, -2, 65535, NULL
},
2212 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2213 M_OPT_RANGE
, -1, 1, NULL
},
2216 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2217 M_OPT_RANGE
, 0, 1, NULL
},
2218 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2219 M_OPT_RANGE
, 0, 1, NULL
},
2220 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2221 M_OPT_RANGE
, 0, 2, NULL
},
2222 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2223 M_OPT_RANGE
, 0, 1, NULL
},
2224 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2225 M_OPT_RANGE
, 0, 1, NULL
},
2226 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2227 M_OPT_RANGE
, 0, 1, NULL
},
2228 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2229 M_OPT_RANGE
, 0, 2, NULL
},
2230 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2231 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_gamma
)},
2232 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2233 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_brightness
) },
2234 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2235 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_contrast
) },
2236 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2237 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_saturation
) },
2238 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2239 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_hue
) },
2240 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2241 M_OPT_RANGE
, 0, 1, NULL
},
2242 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2243 M_OPT_RANGE
, 0, 1, NULL
},
2244 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2246 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2248 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2250 { "width", mp_property_width
, CONF_TYPE_INT
,
2252 { "height", mp_property_height
, CONF_TYPE_INT
,
2254 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2256 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2258 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2259 CONF_RANGE
, -2, 65535, NULL
},
2260 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2261 CONF_RANGE
, -1, 65535, NULL
},
2264 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2265 M_OPT_MIN
, -1, 0, NULL
},
2266 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2267 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2268 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2269 M_OPT_MIN
, -1, 0, NULL
},
2270 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2271 M_OPT_MIN
, -1, 0, NULL
},
2272 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2273 M_OPT_MIN
, -1, 0, NULL
},
2274 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2276 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2277 M_OPT_RANGE
, 0, 100, NULL
},
2278 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2279 M_OPT_RANGE
, 0, 2, NULL
},
2280 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2281 M_OPT_RANGE
, 0, 1, NULL
},
2282 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2283 M_OPT_RANGE
, 0, 1, NULL
},
2284 #ifdef CONFIG_FREETYPE
2285 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2286 M_OPT_RANGE
, 0, 100, NULL
},
2289 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2290 M_OPT_RANGE
, 0, 1, NULL
},
2294 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2295 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_BRIGHTNESS
},
2296 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2297 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_CONTRAST
},
2298 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2299 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_SATURATION
},
2300 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2301 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_HUE
},
2303 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2304 M_OPT_RANGE
, 100, 899, .offset
=TV_VBI_CONTROL_GET_PAGE
},
2305 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2306 M_OPT_RANGE
, 0, 64, .offset
=TV_VBI_CONTROL_GET_SUBPAGE
},
2307 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2308 M_OPT_RANGE
, 0, 1, .offset
=TV_VBI_CONTROL_GET_MODE
},
2309 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2310 M_OPT_RANGE
, 0, 3, .offset
=TV_VBI_CONTROL_GET_FORMAT
},
2311 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2312 M_OPT_RANGE
, 0, 2, .offset
=TV_VBI_CONTROL_GET_HALF_PAGE
},
2313 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2317 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2319 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2322 char* mp_property_print(const char *name
, void* ctx
)
2325 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2330 char *property_expand_string(MPContext
*mpctx
, char *str
)
2332 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2335 void property_print_help(void)
2337 m_properties_print_help_list(mp_properties
);
2341 /* List of default ways to show a property on OSD.
2343 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2344 * a bar showing the current position between min/max values of the
2345 * property. In this case osd_msg is only used for terminal output
2346 * if there is no video; it'll be a label shown together with percentage.
2348 * Otherwise setting osd_msg will show the string on OSD, formatted with
2349 * the text value of the property as argument.
2351 static struct property_osd_display
{
2354 /// progressbar type
2355 int osd_progbar
; // -1 is special value for seek indicators
2356 /// osd msg id if it must be shared
2358 /// osd msg template
2359 const char *osd_msg
;
2360 } property_osd_display
[] = {
2362 { "loop", 0, -1, _("Loop: %s") },
2363 { "chapter", -1, -1, NULL
},
2364 { "capturing", 0, -1, _("Capturing: %s") },
2366 { "volume", OSD_VOLUME
, -1, _("Volume") },
2367 { "mute", 0, -1, _("Mute: %s") },
2368 { "audio_delay", 0, -1, _("A-V delay: %s") },
2369 { "switch_audio", 0, -1, _("Audio: %s") },
2370 { "balance", OSD_BALANCE
, -1, _("Balance") },
2372 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2373 { "ontop", 0, -1, _("Stay on top: %s") },
2374 { "rootwin", 0, -1, _("Rootwin: %s") },
2375 { "border", 0, -1, _("Border: %s") },
2376 { "framedropping", 0, -1, _("Framedropping: %s") },
2377 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2378 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2379 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2380 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2381 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2382 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2383 { "hue", OSD_HUE
, -1, _("Hue") },
2384 { "vsync", 0, -1, _("VSync: %s") },
2386 { "sub", 0, -1, _("Subtitles: %s") },
2387 { "sub_source", 0, -1, _("Sub source: %s") },
2388 { "sub_vob", 0, -1, _("Subtitles: %s") },
2389 { "sub_demux", 0, -1, _("Subtitles: %s") },
2390 { "sub_file", 0, -1, _("Subtitles: %s") },
2391 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2392 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2393 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2394 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2395 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2396 #ifdef CONFIG_FREETYPE
2397 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2400 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2401 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2402 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2403 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2408 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2410 struct MPOpts
*opts
= &mpctx
->opts
;
2413 struct property_osd_display
*p
;
2415 // look for the command
2416 for (p
= property_osd_display
; p
->name
; p
++)
2417 if (!strcmp(p
->name
, pname
))
2422 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2425 if (p
->osd_progbar
== -1)
2426 mpctx
->add_osd_seek_info
= true;
2427 else if (p
->osd_progbar
) {
2428 if (prop
->type
== CONF_TYPE_INT
) {
2429 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2430 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2431 prop
->min
, prop
->max
, r
);
2432 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2434 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2435 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2436 prop
->min
, prop
->max
, f
);
2438 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2439 "Property use an unsupported type.\n");
2446 char *val
= mp_property_print(pname
, mpctx
);
2448 int index
= p
- property_osd_display
;
2449 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2450 1, opts
->osd_duration
, p
->osd_msg
, val
);
2459 * \defgroup Command2Property Command to property bridge
2461 * It is used to handle most commands that just set a property
2462 * and optionally display something on the OSD.
2463 * Two kinds of commands are handled: adjust or toggle.
2465 * Adjust commands take 1 or 2 parameters: <value> <abs>
2466 * If <abs> is non-zero the property is set to the given value
2467 * otherwise it is adjusted.
2469 * Toggle commands take 0 or 1 parameters. With no parameter
2470 * or a value less than the property minimum it just steps the
2471 * property to its next value. Otherwise it sets it to the given
2477 /// List of the commands that can be handled by setting a property.
2483 /// set/adjust or toggle command
2485 } set_prop_cmd
[] = {
2487 { "loop", MP_CMD_LOOP
, 0},
2488 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2489 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2490 { "pause", MP_CMD_PAUSE
, 0},
2491 { "capturing", MP_CMD_CAPTURING
, 1},
2493 { "volume", MP_CMD_VOLUME
, 0},
2494 { "mute", MP_CMD_MUTE
, 1},
2495 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2496 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2497 { "balance", MP_CMD_BALANCE
, 0},
2499 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2500 { "panscan", MP_CMD_PANSCAN
, 0},
2501 { "ontop", MP_CMD_VO_ONTOP
, 1},
2502 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2503 { "border", MP_CMD_VO_BORDER
, 1},
2504 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2505 { "gamma", MP_CMD_GAMMA
, 0},
2506 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2507 { "contrast", MP_CMD_CONTRAST
, 0},
2508 { "saturation", MP_CMD_SATURATION
, 0},
2509 { "hue", MP_CMD_HUE
, 0},
2510 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2512 { "sub", MP_CMD_SUB_SELECT
, 1},
2513 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2514 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2515 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2516 { "sub_file", MP_CMD_SUB_FILE
, 1},
2517 { "sub_pos", MP_CMD_SUB_POS
, 0},
2518 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2519 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2520 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2521 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2522 #ifdef CONFIG_FREETYPE
2523 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2526 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2529 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2530 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2531 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2532 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2537 /// Handle commands that set a property.
2538 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2544 // look for the command
2545 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2546 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2548 if (!(pname
= set_prop_cmd
[i
].name
))
2551 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2555 if (set_prop_cmd
[i
].toggle
) {
2557 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2558 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2560 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2561 } else if (cmd
->args
[1].v
.i
) //set
2562 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2564 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2569 show_property_osd(mpctx
, pname
);
2574 #ifdef CONFIG_DVDNAV
2575 static const struct {
2577 const mp_command_type cmd
;
2578 } mp_dvdnav_bindings
[] = {
2579 { "up", MP_CMD_DVDNAV_UP
},
2580 { "down", MP_CMD_DVDNAV_DOWN
},
2581 { "left", MP_CMD_DVDNAV_LEFT
},
2582 { "right", MP_CMD_DVDNAV_RIGHT
},
2583 { "menu", MP_CMD_DVDNAV_MENU
},
2584 { "select", MP_CMD_DVDNAV_SELECT
},
2585 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2586 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2589 * keep old dvdnav sub-command options for a while in order not to
2590 * break slave-mode API too suddenly.
2592 { "1", MP_CMD_DVDNAV_UP
},
2593 { "2", MP_CMD_DVDNAV_DOWN
},
2594 { "3", MP_CMD_DVDNAV_LEFT
},
2595 { "4", MP_CMD_DVDNAV_RIGHT
},
2596 { "5", MP_CMD_DVDNAV_MENU
},
2597 { "6", MP_CMD_DVDNAV_SELECT
},
2598 { "7", MP_CMD_DVDNAV_PREVMENU
},
2599 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2604 static const char *property_error_string(int error_value
)
2606 switch (error_value
) {
2607 case M_PROPERTY_ERROR
:
2609 case M_PROPERTY_UNAVAILABLE
:
2610 return "PROPERTY_UNAVAILABLE";
2611 case M_PROPERTY_NOT_IMPLEMENTED
:
2612 return "NOT_IMPLEMENTED";
2613 case M_PROPERTY_UNKNOWN
:
2614 return "PROPERTY_UNKNOWN";
2615 case M_PROPERTY_DISABLED
:
2621 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2624 int end
= start
+ count
;
2625 int after
= mpctx
->set_of_sub_size
- end
;
2626 sub_data
**subs
= mpctx
->set_of_subtitles
;
2628 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2630 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2631 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2632 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2633 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2636 for (idx
= start
; idx
< end
; idx
++) {
2637 sub_data
*subd
= subs
[idx
];
2638 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2639 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2640 filename_recode(subd
->filename
));
2644 if (ass_tracks
[idx
])
2645 ass_free_track(ass_tracks
[idx
]);
2646 ass_tracks
[idx
] = NULL
;
2650 mpctx
->global_sub_size
-= count
;
2651 mpctx
->set_of_sub_size
-= count
;
2652 if (mpctx
->set_of_sub_size
<= 0)
2653 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2655 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2656 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2658 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2659 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2662 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2663 mpctx
->global_sub_pos
= -2;
2668 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2669 } else if (mpctx
->set_of_sub_pos
>= end
) {
2670 mpctx
->set_of_sub_pos
-= count
;
2671 mpctx
->global_sub_pos
-= count
;
2675 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2677 struct MPOpts
*opts
= &mpctx
->opts
;
2678 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2679 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2680 int osd_duration
= opts
->osd_duration
;
2681 int case_fallthrough_hack
= 0;
2682 if (!set_property_command(mpctx
, cmd
))
2687 mpctx
->add_osd_seek_info
= true;
2688 v
= cmd
->args
[0].v
.f
;
2689 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2690 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2691 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2693 mpctx
->osd_function
=
2694 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2695 mpctx
->rel_seek_secs
= v
;
2696 } else if (abs
) { /* Absolute seek by percentage */
2697 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2699 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2700 mpctx
->rel_seek_secs
= v
/ 100.0;
2702 mpctx
->rel_seek_secs
+= v
;
2703 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2708 case MP_CMD_SET_PROPERTY_OSD
:
2709 case_fallthrough_hack
= 1;
2711 case MP_CMD_SET_PROPERTY
:{
2712 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2713 cmd
->args
[1].v
.s
, mpctx
);
2714 if (r
== M_PROPERTY_UNKNOWN
)
2715 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2716 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2718 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2719 "Failed to set property '%s' to '%s'.\n",
2720 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2721 else if (case_fallthrough_hack
)
2722 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2724 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2728 case MP_CMD_STEP_PROPERTY_OSD
:
2729 case_fallthrough_hack
= 1;
2731 case MP_CMD_STEP_PROPERTY
:{
2736 if (cmd
->args
[1].v
.f
) {
2738 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2739 M_PROPERTY_GET_TYPE
,
2740 &prop
, mpctx
)) <= 0)
2742 if(prop
->type
== CONF_TYPE_INT
||
2743 prop
->type
== CONF_TYPE_FLAG
)
2744 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2745 else if(prop
->type
== CONF_TYPE_FLOAT
)
2746 arg
= &cmd
->args
[1].v
.f
;
2747 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2748 prop
->type
== CONF_TYPE_TIME
)
2749 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2750 else if(prop
->type
== CONF_TYPE_POSITION
)
2751 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2753 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2754 "Ignoring step size stepping property '%s'.\n",
2757 r
= mp_property_do(cmd
->args
[0].v
.s
,
2758 cmd
->args
[2].v
.i
< 0 ?
2759 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2762 if (r
== M_PROPERTY_UNKNOWN
)
2763 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2764 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2766 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2767 "Failed to increment property '%s' by %f.\n",
2768 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2769 else if (case_fallthrough_hack
)
2770 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2772 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2776 case MP_CMD_GET_PROPERTY
:{
2778 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2781 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2782 "Failed to get value of property '%s'.\n",
2784 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2787 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2788 cmd
->args
[0].v
.s
, tmp
);
2793 case MP_CMD_EDL_MARK
:
2795 float v
= get_current_time(mpctx
);
2796 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2797 mpctx
->begin_skip
= v
;
2798 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2800 if (mpctx
->begin_skip
> v
)
2801 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2803 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2804 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2806 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2811 case MP_CMD_SWITCH_RATIO
:
2814 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2815 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2817 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2818 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2821 case MP_CMD_SPEED_INCR
:{
2822 float v
= cmd
->args
[0].v
.f
;
2823 opts
->playback_speed
+= v
;
2824 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2825 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2826 opts
->playback_speed
);
2829 case MP_CMD_SPEED_MULT
:{
2830 float v
= cmd
->args
[0].v
.f
;
2831 opts
->playback_speed
*= v
;
2832 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2833 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2834 opts
->playback_speed
);
2837 case MP_CMD_SPEED_SET
:{
2838 float v
= cmd
->args
[0].v
.f
;
2839 opts
->playback_speed
= v
;
2840 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
2841 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2842 opts
->playback_speed
);
2845 case MP_CMD_FRAME_STEP
:
2846 add_step_frame(mpctx
);
2849 case MP_CMD_FILE_FILTER
:
2850 file_filter
= cmd
->args
[0].v
.i
;
2854 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2855 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2857 case MP_CMD_PLAY_TREE_STEP
:{
2858 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2859 int force
= cmd
->args
[1].v
.i
;
2862 if (!force
&& mpctx
->playtree_iter
) {
2863 play_tree_iter_t
*i
=
2864 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2865 if (play_tree_iter_step(i
, n
, 0) ==
2866 PLAY_TREE_ITER_ENTRY
)
2868 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2869 play_tree_iter_free(i
);
2871 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2872 if (mpctx
->stop_play
)
2873 mpctx
->play_tree_step
= n
;
2878 case MP_CMD_PLAY_TREE_UP_STEP
:{
2879 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2880 int force
= cmd
->args
[1].v
.i
;
2882 if (!force
&& mpctx
->playtree_iter
) {
2883 play_tree_iter_t
*i
=
2884 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2885 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2886 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2887 play_tree_iter_free(i
);
2889 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2893 case MP_CMD_PLAY_ALT_SRC_STEP
:
2894 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2895 int v
= cmd
->args
[0].v
.i
;
2897 && mpctx
->playtree_iter
->file
<
2898 mpctx
->playtree_iter
->num_files
)
2899 mpctx
->stop_play
= PT_NEXT_SRC
;
2900 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2901 mpctx
->stop_play
= PT_PREV_SRC
;
2905 case MP_CMD_SUB_STEP
:
2907 int movement
= cmd
->args
[0].v
.i
;
2908 step_sub(subdata
, sh_video
->pts
, movement
);
2912 ass_step_sub(ass_track
,
2914 sub_delay
) * 1000 + .5, movement
) / 1000.;
2916 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2917 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2921 case MP_CMD_SUB_LOG
:
2926 int v
= cmd
->args
[0].v
.i
;
2927 int max
= (opts
->term_osd
2928 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2929 if (opts
->osd_level
> max
)
2930 opts
->osd_level
= max
;
2932 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2934 opts
->osd_level
= v
> max
? max
: v
;
2935 /* Show OSD state when disabled, but not when an explicit
2936 argument is given to the OSD command, i.e. in slave mode. */
2937 if (v
== -1 && opts
->osd_level
<= 1)
2938 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2940 opts
->osd_level
? mp_gtext("enabled") :
2941 mp_gtext("disabled"));
2943 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2947 case MP_CMD_OSD_SHOW_TEXT
:
2948 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2950 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2951 "%-.63s", cmd
->args
[0].v
.s
);
2954 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2955 char *txt
= m_properties_expand_string(mp_properties
,
2958 /* if no argument supplied take default osd_duration, else <arg> ms. */
2960 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2962 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2969 case MP_CMD_LOADFILE
:{
2970 play_tree_t
*e
= play_tree_new();
2971 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2973 if (cmd
->args
[1].v
.i
) // append
2974 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2976 // Go back to the starting point.
2977 while (play_tree_iter_up_step
2978 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2980 play_tree_free_list(mpctx
->playtree
->child
, 1);
2981 play_tree_set_child(mpctx
->playtree
, e
);
2982 pt_iter_goto_head(mpctx
->playtree_iter
);
2983 mpctx
->stop_play
= PT_NEXT_SRC
;
2988 case MP_CMD_LOADLIST
:{
2989 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2991 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2992 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2994 if (cmd
->args
[1].v
.i
) // append
2995 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2997 // Go back to the starting point.
2998 while (play_tree_iter_up_step
2999 (mpctx
->playtree_iter
, 0, 1)
3000 != PLAY_TREE_ITER_END
)
3002 play_tree_free_list(mpctx
->playtree
->child
, 1);
3003 play_tree_set_child(mpctx
->playtree
, e
);
3004 pt_iter_goto_head(mpctx
->playtree_iter
);
3005 mpctx
->stop_play
= PT_NEXT_SRC
;
3012 // Go back to the starting point.
3013 while (play_tree_iter_up_step
3014 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3016 mpctx
->stop_play
= PT_STOP
;
3019 case MP_CMD_OSD_SHOW_PROGRESSION
:{
3020 int len
= get_time_length(mpctx
);
3021 int pts
= get_current_time(mpctx
);
3022 set_osd_bar(mpctx
, 0, "Position", 0, 100, get_percent_pos(mpctx
));
3023 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3024 "%c %02d:%02d:%02d / %02d:%02d:%02d",
3025 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
3026 len
/3600, (len
/60)%60, len
%60);
3031 case MP_CMD_RADIO_STEP_CHANNEL
:
3032 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3033 int v
= cmd
->args
[0].v
.i
;
3035 radio_step_channel(mpctx
->demuxer
->stream
,
3036 RADIO_CHANNEL_HIGHER
);
3038 radio_step_channel(mpctx
->demuxer
->stream
,
3039 RADIO_CHANNEL_LOWER
);
3040 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3041 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3043 radio_get_channel_name(mpctx
->demuxer
->stream
));
3048 case MP_CMD_RADIO_SET_CHANNEL
:
3049 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3050 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3051 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3052 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3054 radio_get_channel_name(mpctx
->demuxer
->stream
));
3059 case MP_CMD_RADIO_SET_FREQ
:
3060 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3061 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3064 case MP_CMD_RADIO_STEP_FREQ
:
3065 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3066 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3071 case MP_CMD_TV_START_SCAN
:
3072 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3073 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3075 case MP_CMD_TV_SET_FREQ
:
3076 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3077 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3078 cmd
->args
[0].v
.f
* 16.0);
3080 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3081 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3082 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3083 pvr_get_current_channelname (mpctx
->stream
),
3084 pvr_get_current_stationname (mpctx
->stream
));
3086 #endif /* CONFIG_PVR */
3089 case MP_CMD_TV_STEP_FREQ
:
3090 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3091 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3092 cmd
->args
[0].v
.f
* 16.0);
3094 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3095 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3096 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3097 pvr_get_current_channelname (mpctx
->stream
),
3098 pvr_get_current_frequency (mpctx
->stream
));
3100 #endif /* CONFIG_PVR */
3103 case MP_CMD_TV_SET_NORM
:
3104 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3105 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3109 case MP_CMD_TV_STEP_CHANNEL
:{
3110 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3111 int v
= cmd
->args
[0].v
.i
;
3113 tv_step_channel((tvi_handle_t
*) (mpctx
->
3117 tv_step_channel((tvi_handle_t
*) (mpctx
->
3121 if (tv_channel_list
) {
3122 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3123 "Channel: %s", tv_channel_current
->name
);
3124 //vo_osd_changed(OSDTYPE_SUBTITLE);
3128 else if (mpctx
->stream
&&
3129 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3130 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3131 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3132 pvr_get_current_channelname (mpctx
->stream
),
3133 pvr_get_current_stationname (mpctx
->stream
));
3135 #endif /* CONFIG_PVR */
3138 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3140 int v
= cmd
->args
[0].v
.i
;
3142 mpctx
->last_dvb_step
= v
;
3144 dir
= DVB_CHANNEL_HIGHER
;
3146 dir
= DVB_CHANNEL_LOWER
;
3149 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3150 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3151 mpctx
->dvbin_reopen
= 1;
3154 #endif /* CONFIG_DVBIN */
3157 case MP_CMD_TV_SET_CHANNEL
:
3158 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3159 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3161 if (tv_channel_list
) {
3162 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3163 "Channel: %s", tv_channel_current
->name
);
3164 //vo_osd_changed(OSDTYPE_SUBTITLE);
3168 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3169 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3170 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3171 pvr_get_current_channelname (mpctx
->stream
),
3172 pvr_get_current_stationname (mpctx
->stream
));
3174 #endif /* CONFIG_PVR */
3178 case MP_CMD_DVB_SET_CHANNEL
:
3179 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3180 mpctx
->last_dvb_step
= 1;
3182 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3183 cmd
->args
[0].v
.i
)) {
3184 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3185 mpctx
->dvbin_reopen
= 1;
3189 #endif /* CONFIG_DVBIN */
3191 case MP_CMD_TV_LAST_CHANNEL
:
3192 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3193 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3194 if (tv_channel_list
) {
3195 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3196 "Channel: %s", tv_channel_current
->name
);
3197 //vo_osd_changed(OSDTYPE_SUBTITLE);
3201 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3202 pvr_set_lastchannel (mpctx
->stream
);
3203 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3204 pvr_get_current_channelname (mpctx
->stream
),
3205 pvr_get_current_stationname (mpctx
->stream
));
3207 #endif /* CONFIG_PVR */
3210 case MP_CMD_TV_STEP_NORM
:
3211 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3212 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3215 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3216 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3217 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3219 #endif /* CONFIG_TV */
3220 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3221 if (mpctx
->demuxer
->teletext
)
3222 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3223 &(cmd
->args
[0].v
.s
));
3225 case MP_CMD_TV_TELETEXT_GO_LINK
:
3226 if (mpctx
->demuxer
->teletext
)
3227 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3228 &(cmd
->args
[0].v
.i
));
3231 case MP_CMD_SUB_LOAD
:
3233 int n
= mpctx
->set_of_sub_size
;
3234 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3235 if (n
!= mpctx
->set_of_sub_size
) {
3236 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3237 ++mpctx
->global_sub_size
;
3242 case MP_CMD_SUB_REMOVE
:
3244 int v
= cmd
->args
[0].v
.i
;
3246 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3247 } else if (v
< mpctx
->set_of_sub_size
) {
3248 remove_subtitle_range(mpctx
, v
, 1);
3253 case MP_CMD_GET_SUB_VISIBILITY
:
3255 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3256 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3260 case MP_CMD_SCREENSHOT
:
3261 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3262 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3264 ((vf_instance_t
*) sh_video
->vfilter
)->
3265 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3267 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3271 case MP_CMD_VF_CHANGE_RECTANGLE
:
3274 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3277 case MP_CMD_GET_TIME_LENGTH
:{
3278 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3279 get_time_length(mpctx
));
3283 case MP_CMD_GET_FILENAME
:{
3284 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3285 get_metadata(mpctx
, META_NAME
));
3289 case MP_CMD_GET_VIDEO_CODEC
:{
3290 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3293 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3298 case MP_CMD_GET_VIDEO_BITRATE
:{
3299 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3302 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3307 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3308 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3311 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3312 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3317 case MP_CMD_GET_AUDIO_CODEC
:{
3318 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3321 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3326 case MP_CMD_GET_AUDIO_BITRATE
:{
3327 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3330 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3335 case MP_CMD_GET_AUDIO_SAMPLES
:{
3336 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3339 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3344 case MP_CMD_GET_META_TITLE
:{
3345 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3348 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3353 case MP_CMD_GET_META_ARTIST
:{
3354 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3357 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3362 case MP_CMD_GET_META_ALBUM
:{
3363 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3366 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3371 case MP_CMD_GET_META_YEAR
:{
3372 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3375 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3380 case MP_CMD_GET_META_COMMENT
:{
3381 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3384 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3389 case MP_CMD_GET_META_TRACK
:{
3390 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3393 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3398 case MP_CMD_GET_META_GENRE
:{
3399 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3402 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3407 case MP_CMD_GET_VO_FULLSCREEN
:
3408 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3409 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3412 case MP_CMD_GET_PERCENT_POS
:
3413 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3414 get_percent_pos(mpctx
));
3417 case MP_CMD_GET_TIME_POS
:{
3418 float pos
= get_current_time(mpctx
);
3419 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3426 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3432 case MP_CMD_KEYDOWN_EVENTS
:
3433 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3436 case MP_CMD_SET_MOUSE_POS
:{
3437 int pointer_x
, pointer_y
;
3439 pointer_x
= cmd
->args
[0].v
.i
;
3440 pointer_y
= cmd
->args
[1].v
.i
;
3441 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3442 #ifdef CONFIG_DVDNAV
3443 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3444 && dx
> 0.0 && dy
> 0.0) {
3446 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3447 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3448 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3449 pointer_x
, pointer_y
, &button
);
3450 if (opts
->osd_level
> 1 && button
> 0)
3451 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3452 "Selected button number %d", button
);
3456 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3457 menu_update_mouse_pos(dx
, dy
);
3462 #ifdef CONFIG_DVDNAV
3463 case MP_CMD_DVDNAV
:{
3466 mp_command_type command
= 0;
3467 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3470 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3471 if (cmd
->args
[0].v
.s
&&
3472 !strcasecmp (cmd
->args
[0].v
.s
,
3473 mp_dvdnav_bindings
[i
].name
))
3474 command
= mp_dvdnav_bindings
[i
].cmd
;
3476 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3477 if (opts
->osd_level
> 1 && button
> 0)
3478 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3479 "Selected button number %d", button
);
3483 case MP_CMD_SWITCH_TITLE
:
3484 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3485 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3490 case MP_CMD_AF_SWITCH
:
3493 af_uninit(mpctx
->mixer
.afilter
);
3494 af_init(mpctx
->mixer
.afilter
);
3501 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3502 char* af_commands
= af_args
;
3505 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3507 if (cmd
->id
== MP_CMD_AF_DEL
)
3509 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3511 af_remove(mpctx
->mixer
.afilter
, af
);
3514 af_add(mpctx
->mixer
.afilter
, af_command
);
3516 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3523 af_uninit(mpctx
->mixer
.afilter
);
3524 af_init(mpctx
->mixer
.afilter
);
3525 build_afilter_chain(mpctx
, sh_audio
, &ao_data
);
3527 case MP_CMD_AF_CMDLINE
:
3529 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3531 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3532 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3535 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3536 af_reinit(sh_audio
->afilter
, af
);
3541 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3542 "Received unknown cmd %s\n", cmd
->name
);
3545 switch (cmd
->pausing
) {
3546 case 1: // "pausing"
3547 pause_player(mpctx
);
3549 case 3: // "pausing_toggle"
3551 unpause_player(mpctx
);
3553 pause_player(mpctx
);