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 reinit_audio_chain(mpctx
);
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 reinit_audio_chain(mpctx
);
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 f
= (char *)mp_basename(mpctx
->filename
);
296 return m_property_string_ro(prop
, action
, arg
, f
);
299 /// Demuxer name (RO)
300 static int mp_property_demuxer(m_option_t
*prop
, int action
, void *arg
,
304 return M_PROPERTY_UNAVAILABLE
;
305 return m_property_string_ro(prop
, action
, arg
,
306 (char *) mpctx
->demuxer
->desc
->name
);
309 /// Position in the stream (RW)
310 static int mp_property_stream_pos(m_option_t
*prop
, int action
, void *arg
,
313 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
314 return M_PROPERTY_UNAVAILABLE
;
316 return M_PROPERTY_ERROR
;
319 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
320 return M_PROPERTY_OK
;
322 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
323 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
324 return M_PROPERTY_OK
;
326 return M_PROPERTY_NOT_IMPLEMENTED
;
329 /// Stream start offset (RO)
330 static int mp_property_stream_start(m_option_t
*prop
, int action
,
331 void *arg
, MPContext
*mpctx
)
333 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
334 return M_PROPERTY_UNAVAILABLE
;
337 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
338 return M_PROPERTY_OK
;
340 return M_PROPERTY_NOT_IMPLEMENTED
;
343 /// Stream end offset (RO)
344 static int mp_property_stream_end(m_option_t
*prop
, int action
, void *arg
,
347 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
348 return M_PROPERTY_UNAVAILABLE
;
351 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
352 return M_PROPERTY_OK
;
354 return M_PROPERTY_NOT_IMPLEMENTED
;
357 /// Stream length (RO)
358 static int mp_property_stream_length(m_option_t
*prop
, int action
,
359 void *arg
, MPContext
*mpctx
)
361 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
362 return M_PROPERTY_UNAVAILABLE
;
366 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
367 return M_PROPERTY_OK
;
369 return M_PROPERTY_NOT_IMPLEMENTED
;
372 /// Current stream position in seconds (RO)
373 static int mp_property_stream_time_pos(m_option_t
*prop
, int action
,
374 void *arg
, MPContext
*mpctx
)
376 if (!mpctx
->demuxer
|| mpctx
->demuxer
->stream_pts
== MP_NOPTS_VALUE
)
377 return M_PROPERTY_UNAVAILABLE
;
379 return m_property_time_ro(prop
, action
, arg
, mpctx
->demuxer
->stream_pts
);
383 /// Media length in seconds (RO)
384 static int mp_property_length(m_option_t
*prop
, int action
, void *arg
,
389 if (!mpctx
->demuxer
||
390 !(int) (len
= get_time_length(mpctx
)))
391 return M_PROPERTY_UNAVAILABLE
;
393 return m_property_time_ro(prop
, action
, arg
, len
);
396 /// Current position in percent (RW)
397 static int mp_property_percent_pos(m_option_t
*prop
, int action
,
398 void *arg
, MPContext
*mpctx
) {
402 return M_PROPERTY_UNAVAILABLE
;
406 if(!arg
) return M_PROPERTY_ERROR
;
407 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
410 case M_PROPERTY_STEP_UP
:
411 case M_PROPERTY_STEP_DOWN
:
412 pos
= get_percent_pos(mpctx
);
413 pos
+= (arg
? *(int*)arg
: 10) *
414 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
415 M_PROPERTY_CLAMP(prop
, pos
);
418 return m_property_int_ro(prop
, action
, arg
, get_percent_pos(mpctx
));
421 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
422 mpctx
->rel_seek_secs
= pos
/ 100.0;
423 return M_PROPERTY_OK
;
426 /// Current position in seconds (RW)
427 static int mp_property_time_pos(m_option_t
*prop
, int action
,
428 void *arg
, MPContext
*mpctx
) {
429 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
430 return M_PROPERTY_UNAVAILABLE
;
434 if(!arg
) return M_PROPERTY_ERROR
;
435 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
436 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
437 mpctx
->rel_seek_secs
= *(double*)arg
;
438 return M_PROPERTY_OK
;
439 case M_PROPERTY_STEP_UP
:
440 case M_PROPERTY_STEP_DOWN
:
441 mpctx
->rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
442 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
443 return M_PROPERTY_OK
;
445 return m_property_time_ro(prop
, action
, arg
, get_current_time(mpctx
));
448 /// Current chapter (RW)
449 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
452 struct MPOpts
*opts
= &mpctx
->opts
;
455 char *chapter_name
= NULL
;
458 chapter
= get_current_chapter(mpctx
);
460 return M_PROPERTY_UNAVAILABLE
;
465 return M_PROPERTY_ERROR
;
466 *(int *) arg
= chapter
;
467 return M_PROPERTY_OK
;
468 case M_PROPERTY_PRINT
: {
470 return M_PROPERTY_ERROR
;
471 chapter_name
= chapter_display_name(mpctx
, chapter
);
473 return M_PROPERTY_UNAVAILABLE
;
474 *(char **) arg
= chapter_name
;
475 return M_PROPERTY_OK
;
479 return M_PROPERTY_ERROR
;
480 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
481 step_all
= *(int *)arg
- chapter
;
484 case M_PROPERTY_STEP_UP
:
485 case M_PROPERTY_STEP_DOWN
: {
486 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
487 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
494 return M_PROPERTY_NOT_IMPLEMENTED
;
498 chapter
= seek_chapter(mpctx
, chapter
, &next_pts
, &chapter_name
);
499 mpctx
->rel_seek_secs
= 0;
500 mpctx
->abs_seek_pos
= 0;
502 if (next_pts
> -1.0) {
503 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
504 mpctx
->rel_seek_secs
= next_pts
;
507 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
508 "Chapter: (%d) %s", chapter
+ 1, chapter_name
);
510 else if (step_all
> 0)
511 mpctx
->rel_seek_secs
= 1000000000.;
513 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
514 "Chapter: (%d) %s", 0, mp_gtext("unknown"));
515 talloc_free(chapter_name
);
516 return M_PROPERTY_OK
;
519 /// Number of chapters in file
520 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
524 return M_PROPERTY_UNAVAILABLE
;
525 if (mpctx
->demuxer
->num_chapters
== 0)
526 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
527 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
530 /// Current dvd angle (RW)
531 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
534 struct MPOpts
*opts
= &mpctx
->opts
;
537 char *angle_name
= NULL
;
540 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
542 return M_PROPERTY_UNAVAILABLE
;
543 angles
= demuxer_angles_count(mpctx
->demuxer
);
545 return M_PROPERTY_UNAVAILABLE
;
550 return M_PROPERTY_ERROR
;
551 *(int *) arg
= angle
;
552 return M_PROPERTY_OK
;
553 case M_PROPERTY_PRINT
: {
555 return M_PROPERTY_ERROR
;
556 angle_name
= calloc(1, 64);
558 return M_PROPERTY_UNAVAILABLE
;
559 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
560 *(char **) arg
= angle_name
;
561 return M_PROPERTY_OK
;
565 return M_PROPERTY_ERROR
;
567 M_PROPERTY_CLAMP(prop
, angle
);
569 case M_PROPERTY_STEP_UP
:
570 case M_PROPERTY_STEP_DOWN
: {
576 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
578 if (angle
< 1) //cycle
583 return M_PROPERTY_NOT_IMPLEMENTED
;
585 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
587 struct sh_video
*sh_video
= mpctx
->demuxer
->video
->sh
;
589 resync_video_stream(sh_video
);
591 struct sh_audio
*sh_audio
= mpctx
->demuxer
->audio
->sh
;
593 resync_audio_stream(sh_audio
);
596 set_osd_tmsg(OSD_MSG_TEXT
, 1, opts
->osd_duration
,
597 "Angle: %d/%d", angle
, angles
);
599 return M_PROPERTY_OK
;
602 /// Demuxer meta data
603 static int mp_property_metadata(m_option_t
*prop
, int action
, void *arg
,
605 m_property_action_t
* ka
;
607 static const m_option_t key_type
=
608 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
610 return M_PROPERTY_UNAVAILABLE
;
614 if(!arg
) return M_PROPERTY_ERROR
;
615 *(char***)arg
= mpctx
->demuxer
->info
;
616 return M_PROPERTY_OK
;
617 case M_PROPERTY_KEY_ACTION
:
618 if(!arg
) return M_PROPERTY_ERROR
;
620 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
621 return M_PROPERTY_UNKNOWN
;
624 if(!ka
->arg
) return M_PROPERTY_ERROR
;
625 *(char**)ka
->arg
= meta
;
626 return M_PROPERTY_OK
;
627 case M_PROPERTY_GET_TYPE
:
628 if(!ka
->arg
) return M_PROPERTY_ERROR
;
629 *(const m_option_t
**)ka
->arg
= &key_type
;
630 return M_PROPERTY_OK
;
633 return M_PROPERTY_NOT_IMPLEMENTED
;
636 static int mp_property_pause(m_option_t
*prop
, int action
, void *arg
,
639 MPContext
*mpctx
= ctx
;
644 return M_PROPERTY_ERROR
;
645 if (mpctx
->paused
== (bool)*(int *) arg
)
646 return M_PROPERTY_OK
;
647 case M_PROPERTY_STEP_UP
:
648 case M_PROPERTY_STEP_DOWN
:
650 unpause_player(mpctx
);
651 mpctx
->osd_function
= OSD_PLAY
;
655 mpctx
->osd_function
= OSD_PAUSE
;
657 return M_PROPERTY_OK
;
659 return m_property_flag(prop
, action
, arg
, &mpctx
->paused
);
666 /// \defgroup AudioProperties Audio properties
667 /// \ingroup Properties
671 static int mp_property_volume(m_option_t
*prop
, int action
, void *arg
,
675 if (!mpctx
->sh_audio
)
676 return M_PROPERTY_UNAVAILABLE
;
681 return M_PROPERTY_ERROR
;
682 mixer_getbothvolume(&mpctx
->mixer
, arg
);
683 return M_PROPERTY_OK
;
684 case M_PROPERTY_PRINT
:{
687 return M_PROPERTY_ERROR
;
688 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
689 return m_property_float_range(prop
, action
, arg
, &vol
);
691 case M_PROPERTY_STEP_UP
:
692 case M_PROPERTY_STEP_DOWN
:
696 return M_PROPERTY_NOT_IMPLEMENTED
;
699 if (mpctx
->edl_muted
)
700 return M_PROPERTY_DISABLED
;
701 mpctx
->user_muted
= 0;
706 return M_PROPERTY_ERROR
;
707 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
708 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
709 return M_PROPERTY_OK
;
710 case M_PROPERTY_STEP_UP
:
711 if (arg
&& *(float *) arg
<= 0)
712 mixer_decvolume(&mpctx
->mixer
);
714 mixer_incvolume(&mpctx
->mixer
);
715 return M_PROPERTY_OK
;
716 case M_PROPERTY_STEP_DOWN
:
717 if (arg
&& *(float *) arg
<= 0)
718 mixer_incvolume(&mpctx
->mixer
);
720 mixer_decvolume(&mpctx
->mixer
);
721 return M_PROPERTY_OK
;
723 return M_PROPERTY_NOT_IMPLEMENTED
;
727 static int mp_property_mute(m_option_t
*prop
, int action
, void *arg
,
731 if (!mpctx
->sh_audio
)
732 return M_PROPERTY_UNAVAILABLE
;
736 if (mpctx
->edl_muted
)
737 return M_PROPERTY_DISABLED
;
739 return M_PROPERTY_ERROR
;
740 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
741 mixer_mute(&mpctx
->mixer
);
742 mpctx
->user_muted
= mpctx
->mixer
.muted
;
743 return M_PROPERTY_OK
;
744 case M_PROPERTY_STEP_UP
:
745 case M_PROPERTY_STEP_DOWN
:
746 if (mpctx
->edl_muted
)
747 return M_PROPERTY_DISABLED
;
748 mixer_mute(&mpctx
->mixer
);
749 mpctx
->user_muted
= mpctx
->mixer
.muted
;
750 return M_PROPERTY_OK
;
751 case M_PROPERTY_PRINT
:
753 return M_PROPERTY_ERROR
;
754 if (mpctx
->edl_muted
) {
755 *(char **) arg
= strdup(mp_gtext("enabled (EDL)"));
756 return M_PROPERTY_OK
;
759 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
765 static int mp_property_audio_delay(m_option_t
*prop
, int action
,
766 void *arg
, MPContext
*mpctx
)
768 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
769 return M_PROPERTY_UNAVAILABLE
;
772 case M_PROPERTY_STEP_UP
:
773 case M_PROPERTY_STEP_DOWN
: {
775 float delay
= audio_delay
;
776 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
777 if (ret
!= M_PROPERTY_OK
)
780 mpctx
->delay
-= audio_delay
- delay
;
782 return M_PROPERTY_OK
;
784 return m_property_delay(prop
, action
, arg
, &audio_delay
);
788 /// Audio codec tag (RO)
789 static int mp_property_audio_format(m_option_t
*prop
, int action
,
790 void *arg
, MPContext
*mpctx
)
792 if (!mpctx
->sh_audio
)
793 return M_PROPERTY_UNAVAILABLE
;
794 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
797 /// Audio codec name (RO)
798 static int mp_property_audio_codec(m_option_t
*prop
, int action
,
799 void *arg
, MPContext
*mpctx
)
801 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
802 return M_PROPERTY_UNAVAILABLE
;
803 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
806 /// Audio bitrate (RO)
807 static int mp_property_audio_bitrate(m_option_t
*prop
, int action
,
808 void *arg
, MPContext
*mpctx
)
810 if (!mpctx
->sh_audio
)
811 return M_PROPERTY_UNAVAILABLE
;
812 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
816 static int mp_property_samplerate(m_option_t
*prop
, int action
, void *arg
,
819 if (!mpctx
->sh_audio
)
820 return M_PROPERTY_UNAVAILABLE
;
822 case M_PROPERTY_PRINT
:
823 if(!arg
) return M_PROPERTY_ERROR
;
824 *(char**)arg
= malloc(16);
825 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
826 return M_PROPERTY_OK
;
828 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
831 /// Number of channels (RO)
832 static int mp_property_channels(m_option_t
*prop
, int action
, void *arg
,
835 if (!mpctx
->sh_audio
)
836 return M_PROPERTY_UNAVAILABLE
;
838 case M_PROPERTY_PRINT
:
840 return M_PROPERTY_ERROR
;
841 switch (mpctx
->sh_audio
->channels
) {
843 *(char **) arg
= strdup("mono");
846 *(char **) arg
= strdup("stereo");
849 *(char **) arg
= malloc(32);
850 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
852 return M_PROPERTY_OK
;
854 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
858 static int mp_property_balance(m_option_t
*prop
, int action
, void *arg
,
863 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
864 return M_PROPERTY_UNAVAILABLE
;
869 return M_PROPERTY_ERROR
;
870 mixer_getbalance(&mpctx
->mixer
, arg
);
871 return M_PROPERTY_OK
;
872 case M_PROPERTY_PRINT
: {
875 return M_PROPERTY_ERROR
;
876 mixer_getbalance(&mpctx
->mixer
, &bal
);
878 *str
= strdup("center");
879 else if (bal
== -1.f
)
880 *str
= strdup("left only");
882 *str
= strdup("right only");
884 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
885 *str
= malloc(sizeof("left xxx%, right xxx%"));
886 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
888 return M_PROPERTY_OK
;
890 case M_PROPERTY_STEP_UP
:
891 case M_PROPERTY_STEP_DOWN
:
892 mixer_getbalance(&mpctx
->mixer
, &bal
);
893 bal
+= (arg
? *(float*)arg
: .1f
) *
894 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
895 M_PROPERTY_CLAMP(prop
, bal
);
896 mixer_setbalance(&mpctx
->mixer
, bal
);
897 return M_PROPERTY_OK
;
900 return M_PROPERTY_ERROR
;
901 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
902 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
903 return M_PROPERTY_OK
;
905 return M_PROPERTY_NOT_IMPLEMENTED
;
908 /// Selected audio id (RW)
909 static int mp_property_audio(m_option_t
*prop
, int action
, void *arg
,
913 if (!mpctx
->demuxer
|| !mpctx
->d_audio
)
914 return M_PROPERTY_UNAVAILABLE
;
915 current_id
= mpctx
->sh_audio
? mpctx
->sh_audio
->aid
: -2;
920 return M_PROPERTY_ERROR
;
921 *(int *) arg
= current_id
;
922 return M_PROPERTY_OK
;
923 case M_PROPERTY_PRINT
:
925 return M_PROPERTY_ERROR
;
928 *(char **) arg
= strdup(mp_gtext("disabled"));
931 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
932 sh_audio_t
* sh
= mpctx
->sh_audio
;
934 av_strlcpy(lang
, sh
->lang
, 40);
935 #ifdef CONFIG_DVDREAD
936 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
937 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
947 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
948 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
950 *(char **) arg
= malloc(64);
951 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
953 return M_PROPERTY_OK
;
955 case M_PROPERTY_STEP_UP
:
957 if (action
== M_PROPERTY_SET
&& arg
)
958 tmp
= *((int *) arg
);
961 int new_id
= demuxer_switch_audio(mpctx
->d_audio
->demuxer
, tmp
);
962 if (new_id
!= current_id
)
963 uninit_player(mpctx
, INITIALIZED_AO
| INITIALIZED_ACODEC
);
964 if (new_id
!= current_id
&& new_id
>= 0) {
966 sh2
= mpctx
->d_audio
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
967 sh2
->ds
= mpctx
->demuxer
->audio
;
968 mpctx
->sh_audio
= sh2
;
969 reinit_audio_chain(mpctx
);
971 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", new_id
);
972 return M_PROPERTY_OK
;
974 return M_PROPERTY_NOT_IMPLEMENTED
;
979 /// Selected video id (RW)
980 static int mp_property_video(m_option_t
*prop
, int action
, void *arg
,
983 struct MPOpts
*opts
= &mpctx
->opts
;
985 if (!mpctx
->demuxer
|| !mpctx
->d_video
)
986 return M_PROPERTY_UNAVAILABLE
;
987 current_id
= mpctx
->d_video
->id
;
992 return M_PROPERTY_ERROR
;
993 *(int *) arg
= current_id
;
994 return M_PROPERTY_OK
;
995 case M_PROPERTY_PRINT
:
997 return M_PROPERTY_ERROR
;
1000 *(char **) arg
= strdup(mp_gtext("disabled"));
1003 strncpy(lang
, mp_gtext("unknown"), sizeof(lang
));
1004 *(char **) arg
= malloc(64);
1005 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
1007 return M_PROPERTY_OK
;
1009 case M_PROPERTY_STEP_UP
:
1010 case M_PROPERTY_SET
:
1011 if (action
== M_PROPERTY_SET
&& arg
)
1012 tmp
= *((int *) arg
);
1015 opts
->video_id
= demuxer_switch_video(mpctx
->d_video
->demuxer
, tmp
);
1016 if (opts
->video_id
== -2
1017 || (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
1018 && current_id
!= -2))
1019 uninit_player(mpctx
, INITIALIZED_VCODEC
|
1020 (mpctx
->opts
.fixed_vo
&& opts
->video_id
!= -2 ? 0 : INITIALIZED_VO
));
1021 if (opts
->video_id
> -1 && mpctx
->d_video
->id
!= current_id
) {
1023 sh2
= mpctx
->d_video
->demuxer
->v_streams
[mpctx
->d_video
->id
];
1025 sh2
->ds
= mpctx
->d_video
;
1026 mpctx
->sh_video
= sh2
;
1027 reinit_video_chain(mpctx
);
1030 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", opts
->video_id
);
1031 return M_PROPERTY_OK
;
1034 return M_PROPERTY_NOT_IMPLEMENTED
;
1038 static int mp_property_program(m_option_t
*prop
, int action
, void *arg
,
1041 demux_program_t prog
;
1044 case M_PROPERTY_STEP_UP
:
1045 case M_PROPERTY_SET
:
1046 if (action
== M_PROPERTY_SET
&& arg
)
1047 prog
.progid
= *((int *) arg
);
1051 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
1052 &prog
) == DEMUXER_CTRL_NOTIMPL
)
1053 return M_PROPERTY_ERROR
;
1055 if (prog
.aid
< 0 && prog
.vid
< 0) {
1056 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
1057 return M_PROPERTY_ERROR
;
1059 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
1060 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
1061 return M_PROPERTY_OK
;
1064 return M_PROPERTY_NOT_IMPLEMENTED
;
1070 /// \defgroup VideoProperties Video properties
1071 /// \ingroup Properties
1074 /// Fullscreen state (RW)
1075 static int mp_property_fullscreen(m_option_t
*prop
, int action
, void *arg
,
1079 if (!mpctx
->video_out
)
1080 return M_PROPERTY_UNAVAILABLE
;
1083 case M_PROPERTY_SET
:
1085 return M_PROPERTY_ERROR
;
1086 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1087 if (vo_fs
== !!*(int *) arg
)
1088 return M_PROPERTY_OK
;
1089 case M_PROPERTY_STEP_UP
:
1090 case M_PROPERTY_STEP_DOWN
:
1091 if (mpctx
->video_out
->config_ok
)
1092 vo_control(mpctx
->video_out
, VOCTRL_FULLSCREEN
, 0);
1093 mpctx
->opts
.fullscreen
= vo_fs
;
1094 return M_PROPERTY_OK
;
1096 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1100 static int mp_property_deinterlace(m_option_t
*prop
, int action
,
1101 void *arg
, MPContext
*mpctx
)
1105 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1106 return M_PROPERTY_UNAVAILABLE
;
1107 vf
= mpctx
->sh_video
->vfilter
;
1109 case M_PROPERTY_GET
:
1111 return M_PROPERTY_ERROR
;
1112 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1113 return M_PROPERTY_OK
;
1114 case M_PROPERTY_SET
:
1116 return M_PROPERTY_ERROR
;
1117 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1118 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1119 return M_PROPERTY_OK
;
1120 case M_PROPERTY_STEP_UP
:
1121 case M_PROPERTY_STEP_DOWN
:
1122 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1123 deinterlace
= !deinterlace
;
1124 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1125 return M_PROPERTY_OK
;
1128 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &value
);
1129 return m_property_flag_ro(prop
, action
, arg
, value
);
1132 static int mp_property_yuv_colorspace(m_option_t
*prop
, int action
,
1133 void *arg
, MPContext
*mpctx
)
1135 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1136 return M_PROPERTY_UNAVAILABLE
;
1138 struct vf_instance
*vf
= mpctx
->sh_video
->vfilter
;
1141 case M_PROPERTY_GET
:
1143 return M_PROPERTY_ERROR
;
1144 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, arg
) != true)
1145 return M_PROPERTY_UNAVAILABLE
;
1146 return M_PROPERTY_OK
;
1147 case M_PROPERTY_PRINT
:
1149 return M_PROPERTY_ERROR
;
1150 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1151 return M_PROPERTY_UNAVAILABLE
;
1152 char * const names
[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
1153 if (colorspace
< 0 || colorspace
>= sizeof(names
) / sizeof(names
[0]))
1154 *(char **)arg
= strdup("Unknown");
1156 *(char**)arg
= strdup(names
[colorspace
]);
1157 return M_PROPERTY_OK
;
1158 case M_PROPERTY_SET
:
1160 return M_PROPERTY_ERROR
;
1161 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1162 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, arg
);
1163 return M_PROPERTY_OK
;
1164 case M_PROPERTY_STEP_UP
:;
1165 if (vf
->control(vf
, VFCTRL_GET_YUV_COLORSPACE
, &colorspace
) != true)
1166 return M_PROPERTY_UNAVAILABLE
;
1168 vf
->control(vf
, VFCTRL_SET_YUV_COLORSPACE
, &colorspace
);
1169 return M_PROPERTY_OK
;
1171 return M_PROPERTY_NOT_IMPLEMENTED
;
1174 static int mp_property_capture(m_option_t
*prop
, int action
,
1175 void *arg
, MPContext
*mpctx
)
1177 struct MPOpts
*opts
= &mpctx
->opts
;
1180 return M_PROPERTY_UNAVAILABLE
;
1182 if (!opts
->capture_dump
) {
1183 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1184 "Capturing not enabled (forgot -capture parameter?)\n");
1185 return M_PROPERTY_ERROR
;
1188 int capturing
= !!mpctx
->stream
->capture_file
;
1190 int ret
= m_property_flag(prop
, action
, arg
, &capturing
);
1191 if (ret
== M_PROPERTY_OK
&& capturing
!= !!mpctx
->stream
->capture_file
) {
1193 mpctx
->stream
->capture_file
= fopen(opts
->stream_dump_name
, "wb");
1194 if (!mpctx
->stream
->capture_file
) {
1195 mp_tmsg(MSGT_GLOBAL
, MSGL_ERR
,
1196 "Error opening capture file: %s\n", strerror(errno
));
1197 ret
= M_PROPERTY_ERROR
;
1200 fclose(mpctx
->stream
->capture_file
);
1201 mpctx
->stream
->capture_file
= NULL
;
1209 static int mp_property_panscan(m_option_t
*prop
, int action
, void *arg
,
1213 if (!mpctx
->video_out
1214 || vo_control(mpctx
->video_out
, VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1215 return M_PROPERTY_UNAVAILABLE
;
1218 case M_PROPERTY_SET
:
1220 return M_PROPERTY_ERROR
;
1221 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1222 vo_panscan
= *(float *) arg
;
1223 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1224 return M_PROPERTY_OK
;
1225 case M_PROPERTY_STEP_UP
:
1226 case M_PROPERTY_STEP_DOWN
:
1227 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1228 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1231 else if (vo_panscan
< 0)
1233 vo_control(mpctx
->video_out
, VOCTRL_SET_PANSCAN
, NULL
);
1234 return M_PROPERTY_OK
;
1236 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1240 /// Helper to set vo flags.
1241 /** \ingroup PropertyImplHelper
1243 static int mp_property_vo_flag(m_option_t
*prop
, int action
, void *arg
,
1244 int vo_ctrl
, int *vo_var
, MPContext
*mpctx
)
1247 if (!mpctx
->video_out
)
1248 return M_PROPERTY_UNAVAILABLE
;
1251 case M_PROPERTY_SET
:
1253 return M_PROPERTY_ERROR
;
1254 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1255 if (*vo_var
== !!*(int *) arg
)
1256 return M_PROPERTY_OK
;
1257 case M_PROPERTY_STEP_UP
:
1258 case M_PROPERTY_STEP_DOWN
:
1259 if (mpctx
->video_out
->config_ok
)
1260 vo_control(mpctx
->video_out
, vo_ctrl
, 0);
1261 return M_PROPERTY_OK
;
1263 return m_property_flag(prop
, action
, arg
, vo_var
);
1267 /// Window always on top (RW)
1268 static int mp_property_ontop(m_option_t
*prop
, int action
, void *arg
,
1271 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
,
1272 &mpctx
->opts
.vo_ontop
, mpctx
);
1275 /// Display in the root window (RW)
1276 static int mp_property_rootwin(m_option_t
*prop
, int action
, void *arg
,
1279 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1280 &vo_rootwin
, mpctx
);
1283 /// Show window borders (RW)
1284 static int mp_property_border(m_option_t
*prop
, int action
, void *arg
,
1287 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1291 /// Framedropping state (RW)
1292 static int mp_property_framedropping(m_option_t
*prop
, int action
,
1293 void *arg
, MPContext
*mpctx
)
1296 if (!mpctx
->sh_video
)
1297 return M_PROPERTY_UNAVAILABLE
;
1300 case M_PROPERTY_PRINT
:
1302 return M_PROPERTY_ERROR
;
1303 *(char **) arg
= strdup(frame_dropping
== 1 ? mp_gtext("enabled") :
1304 (frame_dropping
== 2 ? mp_gtext("hard") :
1305 mp_gtext("disabled")));
1306 return M_PROPERTY_OK
;
1308 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1312 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1313 static int mp_property_gamma(m_option_t
*prop
, int action
, void *arg
,
1316 int *gamma
= (int *)((char *)&mpctx
->opts
+ prop
->offset
);
1319 if (!mpctx
->sh_video
)
1320 return M_PROPERTY_UNAVAILABLE
;
1322 if (gamma
[0] == 1000) {
1324 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1328 case M_PROPERTY_SET
:
1330 return M_PROPERTY_ERROR
;
1331 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1332 *gamma
= *(int *) arg
;
1333 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1337 case M_PROPERTY_GET
:
1338 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1340 return M_PROPERTY_ERROR
;
1342 return M_PROPERTY_OK
;
1345 case M_PROPERTY_STEP_UP
:
1346 case M_PROPERTY_STEP_DOWN
:
1347 *gamma
+= (arg
? *(int *) arg
: 1) *
1348 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1349 M_PROPERTY_CLAMP(prop
, *gamma
);
1350 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1355 return M_PROPERTY_NOT_IMPLEMENTED
;
1359 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1360 int l
= strlen(prop
->name
);
1361 char tv_prop
[3 + l
+ 1];
1362 sprintf(tv_prop
, "tv_%s", prop
->name
);
1363 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1367 return M_PROPERTY_UNAVAILABLE
;
1371 static int mp_property_vsync(m_option_t
*prop
, int action
, void *arg
,
1374 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1377 /// Video codec tag (RO)
1378 static int mp_property_video_format(m_option_t
*prop
, int action
,
1379 void *arg
, MPContext
*mpctx
)
1382 if (!mpctx
->sh_video
)
1383 return M_PROPERTY_UNAVAILABLE
;
1385 case M_PROPERTY_PRINT
:
1387 return M_PROPERTY_ERROR
;
1388 switch(mpctx
->sh_video
->format
) {
1390 meta
= strdup ("mpeg1"); break;
1392 meta
= strdup ("mpeg2"); break;
1394 meta
= strdup ("mpeg4"); break;
1396 meta
= strdup ("h264"); break;
1398 if(mpctx
->sh_video
->format
>= 0x20202020) {
1400 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1403 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1406 *(char**)arg
= meta
;
1407 return M_PROPERTY_OK
;
1409 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1412 /// Video codec name (RO)
1413 static int mp_property_video_codec(m_option_t
*prop
, int action
,
1414 void *arg
, MPContext
*mpctx
)
1416 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1417 return M_PROPERTY_UNAVAILABLE
;
1418 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1422 /// Video bitrate (RO)
1423 static int mp_property_video_bitrate(m_option_t
*prop
, int action
,
1424 void *arg
, MPContext
*mpctx
)
1426 if (!mpctx
->sh_video
)
1427 return M_PROPERTY_UNAVAILABLE
;
1428 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1431 /// Video display width (RO)
1432 static int mp_property_width(m_option_t
*prop
, int action
, void *arg
,
1435 if (!mpctx
->sh_video
)
1436 return M_PROPERTY_UNAVAILABLE
;
1437 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1440 /// Video display height (RO)
1441 static int mp_property_height(m_option_t
*prop
, int action
, void *arg
,
1444 if (!mpctx
->sh_video
)
1445 return M_PROPERTY_UNAVAILABLE
;
1446 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1450 static int mp_property_fps(m_option_t
*prop
, int action
, void *arg
,
1453 if (!mpctx
->sh_video
)
1454 return M_PROPERTY_UNAVAILABLE
;
1455 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1458 /// Video aspect (RO)
1459 static int mp_property_aspect(m_option_t
*prop
, int action
, void *arg
,
1462 if (!mpctx
->sh_video
)
1463 return M_PROPERTY_UNAVAILABLE
;
1464 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1469 /// \defgroup SubProprties Subtitles properties
1470 /// \ingroup Properties
1473 /// Text subtitle position (RW)
1474 static int mp_property_sub_pos(m_option_t
*prop
, int action
, void *arg
,
1478 case M_PROPERTY_SET
:
1480 return M_PROPERTY_ERROR
;
1481 case M_PROPERTY_STEP_UP
:
1482 case M_PROPERTY_STEP_DOWN
:
1483 vo_osd_changed(OSDTYPE_SUBTITLE
);
1485 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1489 /// Selected subtitles (RW)
1490 static int mp_property_sub(m_option_t
*prop
, int action
, void *arg
,
1493 struct MPOpts
*opts
= &mpctx
->opts
;
1494 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1495 int source
= -1, reset_spu
= 0;
1496 int source_pos
= -1;
1499 update_global_sub_size(mpctx
);
1500 const int global_sub_size
= mpctx
->global_sub_size
;
1502 if (global_sub_size
<= 0)
1503 return M_PROPERTY_UNAVAILABLE
;
1506 case M_PROPERTY_GET
:
1508 return M_PROPERTY_ERROR
;
1509 *(int *) arg
= mpctx
->global_sub_pos
;
1510 return M_PROPERTY_OK
;
1511 case M_PROPERTY_PRINT
:
1513 return M_PROPERTY_ERROR
;
1514 *(char **) arg
= malloc(64);
1515 (*(char **) arg
)[63] = 0;
1518 sub_name
= subdata
->filename
;
1520 if (ass_track
&& ass_track
->name
)
1521 sub_name
= ass_track
->name
;
1524 const char *tmp
= mp_basename(sub_name
);
1526 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1527 mpctx
->set_of_sub_pos
+ 1,
1528 strlen(tmp
) < 20 ? "" : "...",
1529 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1530 return M_PROPERTY_OK
;
1532 #ifdef CONFIG_DVDNAV
1533 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1534 if (vo_spudec
&& opts
->sub_id
>= 0) {
1535 unsigned char lang
[3];
1536 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, opts
->sub_id
, lang
)) {
1537 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1538 return M_PROPERTY_OK
;
1544 if ((d_sub
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1545 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF
1546 || d_sub
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1547 || d_sub
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1548 && d_sub
->sh
&& opts
->sub_id
>= 0) {
1549 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1550 if (!lang
) lang
= mp_gtext("unknown");
1551 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1552 return M_PROPERTY_OK
;
1555 if (vo_vobsub
&& vobsub_id
>= 0) {
1556 const char *language
= mp_gtext("unknown");
1557 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1558 snprintf(*(char **) arg
, 63, "(%d) %s",
1559 vobsub_id
, language
? language
: mp_gtext("unknown"));
1560 return M_PROPERTY_OK
;
1562 #ifdef CONFIG_DVDREAD
1563 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1564 && opts
->sub_id
>= 0) {
1566 int code
= dvd_lang_from_sid(mpctx
->stream
, opts
->sub_id
);
1567 lang
[0] = code
>> 8;
1570 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
, lang
);
1571 return M_PROPERTY_OK
;
1574 if (opts
->sub_id
>= 0) {
1575 snprintf(*(char **) arg
, 63, "(%d) %s", opts
->sub_id
,
1576 mp_gtext("unknown"));
1577 return M_PROPERTY_OK
;
1579 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1580 return M_PROPERTY_OK
;
1582 case M_PROPERTY_SET
:
1584 return M_PROPERTY_ERROR
;
1585 if (*(int *) arg
< -1)
1587 else if (*(int *) arg
>= global_sub_size
)
1588 *(int *) arg
= global_sub_size
- 1;
1589 mpctx
->global_sub_pos
= *(int *) arg
;
1591 case M_PROPERTY_STEP_UP
:
1592 mpctx
->global_sub_pos
+= 2;
1593 mpctx
->global_sub_pos
=
1594 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1596 case M_PROPERTY_STEP_DOWN
:
1597 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1598 mpctx
->global_sub_pos
=
1599 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1602 return M_PROPERTY_NOT_IMPLEMENTED
;
1605 if (mpctx
->global_sub_pos
>= 0) {
1606 source
= sub_source(mpctx
);
1607 source_pos
= sub_source_pos(mpctx
);
1610 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1611 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1613 mpctx
->sub_counts
[SUB_SOURCE_VOBSUB
],
1614 mpctx
->sub_counts
[SUB_SOURCE_SUBS
],
1615 mpctx
->sub_counts
[SUB_SOURCE_DEMUX
],
1616 mpctx
->global_sub_pos
, source
);
1618 mpctx
->set_of_sub_pos
= -1;
1632 if (source
== SUB_SOURCE_VOBSUB
) {
1633 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, source_pos
);
1634 } else if (source
== SUB_SOURCE_SUBS
) {
1635 mpctx
->set_of_sub_pos
= source_pos
;
1637 if (opts
->ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1638 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1642 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1643 vo_osd_changed(OSDTYPE_SUBTITLE
);
1645 } else if (source
== SUB_SOURCE_DEMUX
) {
1646 opts
->sub_id
= source_pos
;
1647 if (d_sub
&& opts
->sub_id
< MAX_S_STREAMS
) {
1649 // default: assume 1:1 mapping of sid and stream id
1650 d_sub
->id
= opts
->sub_id
;
1651 d_sub
->sh
= mpctx
->d_sub
->demuxer
->s_streams
[d_sub
->id
];
1652 ds_free_packs(d_sub
);
1653 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1654 sh_sub_t
*sh
= mpctx
->d_sub
->demuxer
->s_streams
[i
];
1655 if (sh
&& sh
->sid
== opts
->sub_id
) {
1661 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1662 sh_sub_t
*sh
= d_sub
->sh
;
1663 if (sh
->type
== 'v')
1664 init_vo_spudec(mpctx
);
1666 else if (opts
->ass_enabled
)
1667 ass_track
= sh
->ass_track
;
1675 #ifdef CONFIG_DVDREAD
1677 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1678 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1679 && opts
->sub_id
< 0 && reset_spu
) {
1685 update_subtitles(mpctx
, &mpctx
->opts
, mpctx
->sh_video
, 0, 0, d_sub
, 1);
1687 return M_PROPERTY_OK
;
1690 /// Selected sub source (RW)
1691 static int mp_property_sub_source(m_option_t
*prop
, int action
, void *arg
,
1695 update_global_sub_size(mpctx
);
1696 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1697 return M_PROPERTY_UNAVAILABLE
;
1700 case M_PROPERTY_GET
:
1702 return M_PROPERTY_ERROR
;
1703 *(int *) arg
= sub_source(mpctx
);
1704 return M_PROPERTY_OK
;
1705 case M_PROPERTY_PRINT
:
1707 return M_PROPERTY_ERROR
;
1708 *(char **) arg
= malloc(64);
1709 (*(char **) arg
)[63] = 0;
1710 switch (sub_source(mpctx
))
1712 case SUB_SOURCE_SUBS
:
1713 snprintf(*(char **) arg
, 63, mp_gtext("file"));
1715 case SUB_SOURCE_VOBSUB
:
1716 snprintf(*(char **) arg
, 63, mp_gtext("vobsub"));
1718 case SUB_SOURCE_DEMUX
:
1719 snprintf(*(char **) arg
, 63, mp_gtext("embedded"));
1722 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1724 return M_PROPERTY_OK
;
1725 case M_PROPERTY_SET
:
1727 return M_PROPERTY_ERROR
;
1728 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1729 if (*(int *) arg
< 0)
1730 mpctx
->global_sub_pos
= -1;
1731 else if (*(int *) arg
!= sub_source(mpctx
)) {
1732 int new_pos
= sub_pos_by_source(mpctx
, *(int *)arg
);
1734 return M_PROPERTY_UNAVAILABLE
;
1735 mpctx
->global_sub_pos
= new_pos
;
1738 case M_PROPERTY_STEP_UP
:
1739 case M_PROPERTY_STEP_DOWN
: {
1740 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1741 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1742 int step
= (step_all
> 0) ? 1 : -1;
1743 int cur_source
= sub_source(mpctx
);
1744 source
= cur_source
;
1747 if (source
>= SUB_SOURCES
)
1749 else if (source
< -1)
1750 source
= SUB_SOURCES
- 1;
1751 if (source
== cur_source
|| source
== -1 ||
1752 mpctx
->sub_counts
[source
])
1755 if (source
== cur_source
)
1756 return M_PROPERTY_OK
;
1758 mpctx
->global_sub_pos
= -1;
1760 mpctx
->global_sub_pos
= sub_pos_by_source(mpctx
, source
);
1764 return M_PROPERTY_NOT_IMPLEMENTED
;
1766 --mpctx
->global_sub_pos
;
1767 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1770 /// Selected subtitles from specific source (RW)
1771 static int mp_property_sub_by_type(m_option_t
*prop
, int action
, void *arg
,
1774 int source
, is_cur_source
, offset
, new_pos
;
1775 update_global_sub_size(mpctx
);
1776 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1777 return M_PROPERTY_UNAVAILABLE
;
1779 if (!strcmp(prop
->name
, "sub_file"))
1780 source
= SUB_SOURCE_SUBS
;
1781 else if (!strcmp(prop
->name
, "sub_vob"))
1782 source
= SUB_SOURCE_VOBSUB
;
1783 else if (!strcmp(prop
->name
, "sub_demux"))
1784 source
= SUB_SOURCE_DEMUX
;
1786 return M_PROPERTY_ERROR
;
1788 offset
= sub_pos_by_source(mpctx
, source
);
1790 return M_PROPERTY_UNAVAILABLE
;
1792 is_cur_source
= sub_source(mpctx
) == source
;
1793 new_pos
= mpctx
->global_sub_pos
;
1795 case M_PROPERTY_GET
:
1797 return M_PROPERTY_ERROR
;
1798 if (is_cur_source
) {
1799 *(int *) arg
= sub_source_pos(mpctx
);
1800 if (source
== SUB_SOURCE_VOBSUB
)
1801 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1805 return M_PROPERTY_OK
;
1806 case M_PROPERTY_PRINT
:
1808 return M_PROPERTY_ERROR
;
1810 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1811 *(char **) arg
= malloc(64);
1812 (*(char **) arg
)[63] = 0;
1813 snprintf(*(char **) arg
, 63, mp_gtext("disabled"));
1814 return M_PROPERTY_OK
;
1815 case M_PROPERTY_SET
:
1817 return M_PROPERTY_ERROR
;
1818 if (*(int *) arg
>= 0) {
1819 int index
= *(int *)arg
;
1820 if (source
== SUB_SOURCE_VOBSUB
)
1821 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1822 new_pos
= offset
+ index
;
1823 if (index
< 0 || index
> mpctx
->sub_counts
[source
]) {
1831 case M_PROPERTY_STEP_UP
:
1832 case M_PROPERTY_STEP_DOWN
: {
1833 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1834 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1835 int step
= (step_all
> 0) ? 1 : -1;
1836 int max_sub_pos_for_source
= -1;
1840 if (new_pos
== -1) {
1843 else if (max_sub_pos_for_source
== -1) {
1844 // Find max pos for specific source
1845 new_pos
= mpctx
->global_sub_size
- 1;
1847 && sub_source(mpctx
) != source
)
1851 new_pos
= max_sub_pos_for_source
;
1855 if (new_pos
< offset
||
1856 new_pos
>= mpctx
->global_sub_size
||
1857 sub_source(mpctx
) != source
)
1865 return M_PROPERTY_NOT_IMPLEMENTED
;
1867 return mp_property_sub(prop
, M_PROPERTY_SET
, &new_pos
, mpctx
);
1870 /// Subtitle delay (RW)
1871 static int mp_property_sub_delay(m_option_t
*prop
, int action
, void *arg
,
1874 if (!mpctx
->sh_video
)
1875 return M_PROPERTY_UNAVAILABLE
;
1876 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1879 /// Alignment of text subtitles (RW)
1880 static int mp_property_sub_alignment(m_option_t
*prop
, int action
,
1881 void *arg
, MPContext
*mpctx
)
1883 char *name
[] = { _("top"), _("center"), _("bottom") };
1885 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1886 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1887 return M_PROPERTY_UNAVAILABLE
;
1890 case M_PROPERTY_PRINT
:
1892 return M_PROPERTY_ERROR
;
1893 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1894 *(char **) arg
= strdup(mp_gtext(name
[sub_alignment
]));
1895 return M_PROPERTY_OK
;
1896 case M_PROPERTY_SET
:
1898 return M_PROPERTY_ERROR
;
1899 case M_PROPERTY_STEP_UP
:
1900 case M_PROPERTY_STEP_DOWN
:
1901 vo_osd_changed(OSDTYPE_SUBTITLE
);
1903 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1907 /// Subtitle visibility (RW)
1908 static int mp_property_sub_visibility(m_option_t
*prop
, int action
,
1909 void *arg
, MPContext
*mpctx
)
1911 if (!mpctx
->sh_video
)
1912 return M_PROPERTY_UNAVAILABLE
;
1915 case M_PROPERTY_SET
:
1917 return M_PROPERTY_ERROR
;
1918 case M_PROPERTY_STEP_UP
:
1919 case M_PROPERTY_STEP_DOWN
:
1920 vo_osd_changed(OSDTYPE_SUBTITLE
);
1922 vo_osd_changed(OSDTYPE_SPU
);
1924 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1929 /// Use margins for libass subtitles (RW)
1930 static int mp_property_ass_use_margins(m_option_t
*prop
, int action
,
1931 void *arg
, MPContext
*mpctx
)
1933 if (!mpctx
->sh_video
)
1934 return M_PROPERTY_UNAVAILABLE
;
1937 case M_PROPERTY_SET
:
1939 return M_PROPERTY_ERROR
;
1940 case M_PROPERTY_STEP_UP
:
1941 case M_PROPERTY_STEP_DOWN
:
1942 ass_force_reload
= 1;
1944 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1949 /// Show only forced subtitles (RW)
1950 static int mp_property_sub_forced_only(m_option_t
*prop
, int action
,
1951 void *arg
, MPContext
*mpctx
)
1954 return M_PROPERTY_UNAVAILABLE
;
1957 case M_PROPERTY_SET
:
1959 return M_PROPERTY_ERROR
;
1960 case M_PROPERTY_STEP_UP
:
1961 case M_PROPERTY_STEP_DOWN
:
1962 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1963 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1964 return M_PROPERTY_OK
;
1966 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1971 #ifdef CONFIG_FREETYPE
1972 /// Subtitle scale (RW)
1973 static int mp_property_sub_scale(m_option_t
*prop
, int action
, void *arg
,
1976 struct MPOpts
*opts
= &mpctx
->opts
;
1979 case M_PROPERTY_SET
:
1981 return M_PROPERTY_ERROR
;
1982 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1984 if (opts
->ass_enabled
) {
1985 ass_font_scale
= *(float *) arg
;
1986 ass_force_reload
= 1;
1989 text_font_scale_factor
= *(float *) arg
;
1990 force_load_font
= 1;
1991 return M_PROPERTY_OK
;
1992 case M_PROPERTY_STEP_UP
:
1993 case M_PROPERTY_STEP_DOWN
:
1995 if (opts
->ass_enabled
) {
1996 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1997 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1998 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1999 ass_force_reload
= 1;
2002 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
2003 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
2004 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
2005 force_load_font
= 1;
2006 return M_PROPERTY_OK
;
2009 if (opts
->ass_enabled
)
2010 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
2013 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
2020 /// \defgroup TVProperties TV properties
2021 /// \ingroup Properties
2026 /// TV color settings (RW)
2027 static int mp_property_tv_color(m_option_t
*prop
, int action
, void *arg
,
2031 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
2032 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
2033 return M_PROPERTY_UNAVAILABLE
;
2036 case M_PROPERTY_SET
:
2038 return M_PROPERTY_ERROR
;
2039 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2040 return tv_set_color_options(tvh
, prop
->offset
, *(int *) arg
);
2041 case M_PROPERTY_GET
:
2042 return tv_get_color_options(tvh
, prop
->offset
, arg
);
2043 case M_PROPERTY_STEP_UP
:
2044 case M_PROPERTY_STEP_DOWN
:
2045 if ((r
= tv_get_color_options(tvh
, prop
->offset
, &val
)) >= 0) {
2047 return M_PROPERTY_ERROR
;
2048 val
+= (arg
? *(int *) arg
: 1) *
2049 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2050 M_PROPERTY_CLAMP(prop
, val
);
2051 return tv_set_color_options(tvh
, prop
->offset
, val
);
2053 return M_PROPERTY_ERROR
;
2055 return M_PROPERTY_NOT_IMPLEMENTED
;
2060 static int mp_property_teletext_common(m_option_t
*prop
, int action
, void *arg
,
2064 int base_ioctl
= prop
->offset
;
2066 for teletext's GET,SET,STEP ioctls this is not 0
2070 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
2071 return M_PROPERTY_UNAVAILABLE
;
2073 return M_PROPERTY_ERROR
;
2076 case M_PROPERTY_GET
:
2078 return M_PROPERTY_ERROR
;
2079 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
2081 case M_PROPERTY_SET
:
2083 return M_PROPERTY_ERROR
;
2084 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
2085 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
2087 case M_PROPERTY_STEP_UP
:
2088 case M_PROPERTY_STEP_DOWN
:
2089 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
2090 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2091 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
2094 return M_PROPERTY_NOT_IMPLEMENTED
;
2097 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
2100 static int mp_property_teletext_mode(m_option_t
*prop
, int action
, void *arg
,
2106 //with tvh==NULL will fail too
2107 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2108 if(result
!=M_PROPERTY_OK
)
2111 if(teletext_control(mpctx
->demuxer
->teletext
,
2112 prop
->offset
, &val
)==VBI_CONTROL_TRUE
&& val
)
2113 mp_input_set_section(mpctx
->input
, "teletext");
2115 mp_input_set_section(mpctx
->input
, "tv");
2116 return M_PROPERTY_OK
;
2119 static int mp_property_teletext_page(m_option_t
*prop
, int action
, void *arg
,
2124 if (!mpctx
->demuxer
->teletext
)
2125 return M_PROPERTY_UNAVAILABLE
;
2127 case M_PROPERTY_STEP_UP
:
2128 case M_PROPERTY_STEP_DOWN
:
2129 //This should be handled separately
2130 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
2131 result
=teletext_control(mpctx
->demuxer
->teletext
,
2132 TV_VBI_CONTROL_STEP_PAGE
, &val
);
2135 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
2142 /// All properties available in MPlayer.
2143 /** \ingroup Properties
2145 static const m_option_t mp_properties
[] = {
2147 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
2148 M_OPT_RANGE
, 0, 3, NULL
},
2149 { "loop", mp_property_loop
, CONF_TYPE_INT
,
2150 M_OPT_MIN
, -1, 0, NULL
},
2151 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
2152 M_OPT_RANGE
, 0.01, 100.0, NULL
},
2153 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
2155 { "path", mp_property_path
, CONF_TYPE_STRING
,
2157 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
2159 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
2160 M_OPT_MIN
, 0, 0, NULL
},
2161 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
2162 M_OPT_MIN
, 0, 0, NULL
},
2163 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
2164 M_OPT_MIN
, 0, 0, NULL
},
2165 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
2166 M_OPT_MIN
, 0, 0, NULL
},
2167 { "stream_time_pos", mp_property_stream_time_pos
, CONF_TYPE_TIME
,
2168 M_OPT_MIN
, 0, 0, NULL
},
2169 { "length", mp_property_length
, CONF_TYPE_TIME
,
2170 M_OPT_MIN
, 0, 0, NULL
},
2171 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2172 M_OPT_RANGE
, 0, 100, NULL
},
2173 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2174 M_OPT_MIN
, 0, 0, NULL
},
2175 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2176 M_OPT_MIN
, 0, 0, NULL
},
2177 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2179 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2180 CONF_RANGE
, -2, 10, NULL
},
2181 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2183 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2184 M_OPT_RANGE
, 0, 1, NULL
},
2185 { "capturing", mp_property_capture
, CONF_TYPE_FLAG
,
2186 M_OPT_RANGE
, 0, 1, NULL
},
2189 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2190 M_OPT_RANGE
, 0, 100, NULL
},
2191 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2192 M_OPT_RANGE
, 0, 1, NULL
},
2193 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2194 M_OPT_RANGE
, -100, 100, NULL
},
2195 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2197 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2199 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2201 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2203 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2205 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2206 CONF_RANGE
, -2, 65535, NULL
},
2207 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2208 M_OPT_RANGE
, -1, 1, NULL
},
2211 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2212 M_OPT_RANGE
, 0, 1, NULL
},
2213 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2214 M_OPT_RANGE
, 0, 1, NULL
},
2215 { "yuv_colorspace", mp_property_yuv_colorspace
, CONF_TYPE_INT
,
2216 M_OPT_RANGE
, 0, 2, NULL
},
2217 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2218 M_OPT_RANGE
, 0, 1, NULL
},
2219 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2220 M_OPT_RANGE
, 0, 1, NULL
},
2221 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2222 M_OPT_RANGE
, 0, 1, NULL
},
2223 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2224 M_OPT_RANGE
, 0, 2, NULL
},
2225 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2226 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_gamma
)},
2227 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2228 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_brightness
) },
2229 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2230 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_contrast
) },
2231 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2232 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_saturation
) },
2233 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2234 M_OPT_RANGE
, -100, 100, .offset
=offsetof(struct MPOpts
, vo_gamma_hue
) },
2235 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2236 M_OPT_RANGE
, 0, 1, NULL
},
2237 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2238 M_OPT_RANGE
, 0, 1, NULL
},
2239 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2241 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2243 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2245 { "width", mp_property_width
, CONF_TYPE_INT
,
2247 { "height", mp_property_height
, CONF_TYPE_INT
,
2249 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2251 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2253 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2254 CONF_RANGE
, -2, 65535, NULL
},
2255 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2256 CONF_RANGE
, -1, 65535, NULL
},
2259 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2260 M_OPT_MIN
, -1, 0, NULL
},
2261 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2262 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2263 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2264 M_OPT_MIN
, -1, 0, NULL
},
2265 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2266 M_OPT_MIN
, -1, 0, NULL
},
2267 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2268 M_OPT_MIN
, -1, 0, NULL
},
2269 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2271 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2272 M_OPT_RANGE
, 0, 100, NULL
},
2273 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2274 M_OPT_RANGE
, 0, 2, NULL
},
2275 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2276 M_OPT_RANGE
, 0, 1, NULL
},
2277 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2278 M_OPT_RANGE
, 0, 1, NULL
},
2279 #ifdef CONFIG_FREETYPE
2280 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2281 M_OPT_RANGE
, 0, 100, NULL
},
2284 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2285 M_OPT_RANGE
, 0, 1, NULL
},
2289 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2290 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_BRIGHTNESS
},
2291 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2292 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_CONTRAST
},
2293 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2294 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_SATURATION
},
2295 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2296 M_OPT_RANGE
, -100, 100, .offset
=TV_COLOR_HUE
},
2298 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2299 M_OPT_RANGE
, 100, 899, .offset
=TV_VBI_CONTROL_GET_PAGE
},
2300 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2301 M_OPT_RANGE
, 0, 64, .offset
=TV_VBI_CONTROL_GET_SUBPAGE
},
2302 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2303 M_OPT_RANGE
, 0, 1, .offset
=TV_VBI_CONTROL_GET_MODE
},
2304 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2305 M_OPT_RANGE
, 0, 3, .offset
=TV_VBI_CONTROL_GET_FORMAT
},
2306 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2307 M_OPT_RANGE
, 0, 2, .offset
=TV_VBI_CONTROL_GET_HALF_PAGE
},
2308 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2312 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2314 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2317 char* mp_property_print(const char *name
, void* ctx
)
2320 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2325 char *property_expand_string(MPContext
*mpctx
, char *str
)
2327 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2330 void property_print_help(void)
2332 m_properties_print_help_list(mp_properties
);
2336 /* List of default ways to show a property on OSD.
2338 * Setting osd_progbar to -1 displays seek bar, other nonzero displays
2339 * a bar showing the current position between min/max values of the
2340 * property. In this case osd_msg is only used for terminal output
2341 * if there is no video; it'll be a label shown together with percentage.
2343 * Otherwise setting osd_msg will show the string on OSD, formatted with
2344 * the text value of the property as argument.
2346 static struct property_osd_display
{
2349 /// progressbar type
2350 int osd_progbar
; // -1 is special value for seek indicators
2351 /// osd msg id if it must be shared
2353 /// osd msg template
2354 const char *osd_msg
;
2355 } property_osd_display
[] = {
2357 { "loop", 0, -1, _("Loop: %s") },
2358 { "chapter", -1, -1, NULL
},
2359 { "capturing", 0, -1, _("Capturing: %s") },
2361 { "volume", OSD_VOLUME
, -1, _("Volume") },
2362 { "mute", 0, -1, _("Mute: %s") },
2363 { "audio_delay", 0, -1, _("A-V delay: %s") },
2364 { "switch_audio", 0, -1, _("Audio: %s") },
2365 { "balance", OSD_BALANCE
, -1, _("Balance") },
2367 { "panscan", OSD_PANSCAN
, -1, _("Panscan") },
2368 { "ontop", 0, -1, _("Stay on top: %s") },
2369 { "rootwin", 0, -1, _("Rootwin: %s") },
2370 { "border", 0, -1, _("Border: %s") },
2371 { "framedropping", 0, -1, _("Framedropping: %s") },
2372 { "deinterlace", 0, -1, _("Deinterlace: %s") },
2373 { "yuv_colorspace", 0, -1, _("YUV colorspace: %s") },
2374 { "gamma", OSD_BRIGHTNESS
, -1, _("Gamma") },
2375 { "brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2376 { "contrast", OSD_CONTRAST
, -1, _("Contrast") },
2377 { "saturation", OSD_SATURATION
, -1, _("Saturation") },
2378 { "hue", OSD_HUE
, -1, _("Hue") },
2379 { "vsync", 0, -1, _("VSync: %s") },
2381 { "sub", 0, -1, _("Subtitles: %s") },
2382 { "sub_source", 0, -1, _("Sub source: %s") },
2383 { "sub_vob", 0, -1, _("Subtitles: %s") },
2384 { "sub_demux", 0, -1, _("Subtitles: %s") },
2385 { "sub_file", 0, -1, _("Subtitles: %s") },
2386 { "sub_pos", 0, -1, _("Sub position: %s/100") },
2387 { "sub_alignment", 0, -1, _("Sub alignment: %s") },
2388 { "sub_delay", 0, OSD_MSG_SUB_DELAY
, _("Sub delay: %s") },
2389 { "sub_visibility", 0, -1, _("Subtitles: %s") },
2390 { "sub_forced_only", 0, -1, _("Forced sub only: %s") },
2391 #ifdef CONFIG_FREETYPE
2392 { "sub_scale", 0, -1, _("Sub Scale: %s")},
2395 { "tv_brightness", OSD_BRIGHTNESS
, -1, _("Brightness") },
2396 { "tv_hue", OSD_HUE
, -1, _("Hue") },
2397 { "tv_saturation", OSD_SATURATION
, -1, _("Saturation") },
2398 { "tv_contrast", OSD_CONTRAST
, -1, _("Contrast") },
2403 static int show_property_osd(MPContext
*mpctx
, const char *pname
)
2405 struct MPOpts
*opts
= &mpctx
->opts
;
2408 struct property_osd_display
*p
;
2410 // look for the command
2411 for (p
= property_osd_display
; p
->name
; p
++)
2412 if (!strcmp(p
->name
, pname
))
2417 if (mp_property_do(pname
, M_PROPERTY_GET_TYPE
, &prop
, mpctx
) <= 0 || !prop
)
2420 if (p
->osd_progbar
== -1)
2421 mpctx
->add_osd_seek_info
= true;
2422 else if (p
->osd_progbar
) {
2423 if (prop
->type
== CONF_TYPE_INT
) {
2424 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2425 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2426 prop
->min
, prop
->max
, r
);
2427 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2429 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2430 set_osd_bar(mpctx
, p
->osd_progbar
, mp_gtext(p
->osd_msg
),
2431 prop
->min
, prop
->max
, f
);
2433 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2434 "Property use an unsupported type.\n");
2441 char *val
= mp_property_print(pname
, mpctx
);
2443 int index
= p
- property_osd_display
;
2444 set_osd_tmsg(p
->osd_id
>= 0 ? p
->osd_id
: OSD_MSG_PROPERTY
+ index
,
2445 1, opts
->osd_duration
, p
->osd_msg
, val
);
2454 * \defgroup Command2Property Command to property bridge
2456 * It is used to handle most commands that just set a property
2457 * and optionally display something on the OSD.
2458 * Two kinds of commands are handled: adjust or toggle.
2460 * Adjust commands take 1 or 2 parameters: <value> <abs>
2461 * If <abs> is non-zero the property is set to the given value
2462 * otherwise it is adjusted.
2464 * Toggle commands take 0 or 1 parameters. With no parameter
2465 * or a value less than the property minimum it just steps the
2466 * property to its next or previous value respectively.
2467 * Otherwise it sets it to the given value.
2472 /// List of the commands that can be handled by setting a property.
2478 /// set/adjust or toggle command
2480 } set_prop_cmd
[] = {
2482 { "loop", MP_CMD_LOOP
, 0},
2483 { "chapter", MP_CMD_SEEK_CHAPTER
, 0},
2484 { "angle", MP_CMD_SWITCH_ANGLE
, 0},
2485 { "pause", MP_CMD_PAUSE
, 0},
2486 { "capturing", MP_CMD_CAPTURING
, 1},
2488 { "volume", MP_CMD_VOLUME
, 0},
2489 { "mute", MP_CMD_MUTE
, 1},
2490 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0},
2491 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1},
2492 { "balance", MP_CMD_BALANCE
, 0},
2494 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1},
2495 { "panscan", MP_CMD_PANSCAN
, 0},
2496 { "ontop", MP_CMD_VO_ONTOP
, 1},
2497 { "rootwin", MP_CMD_VO_ROOTWIN
, 1},
2498 { "border", MP_CMD_VO_BORDER
, 1},
2499 { "framedropping", MP_CMD_FRAMEDROPPING
, 1},
2500 { "gamma", MP_CMD_GAMMA
, 0},
2501 { "brightness", MP_CMD_BRIGHTNESS
, 0},
2502 { "contrast", MP_CMD_CONTRAST
, 0},
2503 { "saturation", MP_CMD_SATURATION
, 0},
2504 { "hue", MP_CMD_HUE
, 0},
2505 { "vsync", MP_CMD_SWITCH_VSYNC
, 1},
2507 { "sub", MP_CMD_SUB_SELECT
, 1},
2508 { "sub_source", MP_CMD_SUB_SOURCE
, 1},
2509 { "sub_vob", MP_CMD_SUB_VOB
, 1},
2510 { "sub_demux", MP_CMD_SUB_DEMUX
, 1},
2511 { "sub_file", MP_CMD_SUB_FILE
, 1},
2512 { "sub_pos", MP_CMD_SUB_POS
, 0},
2513 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1},
2514 { "sub_delay", MP_CMD_SUB_DELAY
, 0},
2515 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1},
2516 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1},
2517 #ifdef CONFIG_FREETYPE
2518 { "sub_scale", MP_CMD_SUB_SCALE
, 0},
2521 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1},
2524 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0},
2525 { "tv_hue", MP_CMD_TV_SET_HUE
, 0},
2526 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0},
2527 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0},
2532 /// Handle commands that set a property.
2533 static int set_property_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2539 // look for the command
2540 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2541 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2543 if (!(pname
= set_prop_cmd
[i
].name
))
2546 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2550 if (set_prop_cmd
[i
].toggle
) {
2552 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2553 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2554 else if (cmd
->nargs
> 0)
2555 r
= mp_property_do(pname
, M_PROPERTY_STEP_DOWN
, NULL
, mpctx
);
2557 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2558 } else if (cmd
->args
[1].v
.i
) //set
2559 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2561 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2566 show_property_osd(mpctx
, pname
);
2571 #ifdef CONFIG_DVDNAV
2572 static const struct {
2574 const mp_command_type cmd
;
2575 } mp_dvdnav_bindings
[] = {
2576 { "up", MP_CMD_DVDNAV_UP
},
2577 { "down", MP_CMD_DVDNAV_DOWN
},
2578 { "left", MP_CMD_DVDNAV_LEFT
},
2579 { "right", MP_CMD_DVDNAV_RIGHT
},
2580 { "menu", MP_CMD_DVDNAV_MENU
},
2581 { "select", MP_CMD_DVDNAV_SELECT
},
2582 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2583 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2586 * keep old dvdnav sub-command options for a while in order not to
2587 * break slave-mode API too suddenly.
2589 { "1", MP_CMD_DVDNAV_UP
},
2590 { "2", MP_CMD_DVDNAV_DOWN
},
2591 { "3", MP_CMD_DVDNAV_LEFT
},
2592 { "4", MP_CMD_DVDNAV_RIGHT
},
2593 { "5", MP_CMD_DVDNAV_MENU
},
2594 { "6", MP_CMD_DVDNAV_SELECT
},
2595 { "7", MP_CMD_DVDNAV_PREVMENU
},
2596 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2601 static const char *property_error_string(int error_value
)
2603 switch (error_value
) {
2604 case M_PROPERTY_ERROR
:
2606 case M_PROPERTY_UNAVAILABLE
:
2607 return "PROPERTY_UNAVAILABLE";
2608 case M_PROPERTY_NOT_IMPLEMENTED
:
2609 return "NOT_IMPLEMENTED";
2610 case M_PROPERTY_UNKNOWN
:
2611 return "PROPERTY_UNKNOWN";
2612 case M_PROPERTY_DISABLED
:
2618 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2621 int end
= start
+ count
;
2622 int after
= mpctx
->set_of_sub_size
- end
;
2623 sub_data
**subs
= mpctx
->set_of_subtitles
;
2625 struct ass_track
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2627 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2628 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2629 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2630 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2633 for (idx
= start
; idx
< end
; idx
++) {
2634 sub_data
*subd
= subs
[idx
];
2635 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2636 "SUB: Removed subtitle file (%d): %s\n", idx
+ 1,
2637 filename_recode(subd
->filename
));
2641 if (ass_tracks
[idx
])
2642 ass_free_track(ass_tracks
[idx
]);
2643 ass_tracks
[idx
] = NULL
;
2647 mpctx
->global_sub_size
-= count
;
2648 mpctx
->set_of_sub_size
-= count
;
2649 if (mpctx
->set_of_sub_size
<= 0)
2650 mpctx
->sub_counts
[SUB_SOURCE_SUBS
] = 0;
2652 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2653 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2655 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2656 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2659 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2660 mpctx
->global_sub_pos
= -2;
2665 mp_input_queue_cmd(mpctx
->input
, mp_input_parse_cmd("sub_select"));
2666 } else if (mpctx
->set_of_sub_pos
>= end
) {
2667 mpctx
->set_of_sub_pos
-= count
;
2668 mpctx
->global_sub_pos
-= count
;
2672 void run_command(MPContext
*mpctx
, mp_cmd_t
*cmd
)
2674 struct MPOpts
*opts
= &mpctx
->opts
;
2675 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2676 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2677 int osd_duration
= opts
->osd_duration
;
2678 int case_fallthrough_hack
= 0;
2679 if (!set_property_command(mpctx
, cmd
))
2684 mpctx
->add_osd_seek_info
= true;
2685 v
= cmd
->args
[0].v
.f
;
2686 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2687 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2688 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
;
2690 mpctx
->osd_function
=
2691 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2692 mpctx
->rel_seek_secs
= v
;
2693 } else if (abs
) { /* Absolute seek by percentage */
2694 mpctx
->abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2696 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2697 mpctx
->rel_seek_secs
= v
/ 100.0;
2699 mpctx
->rel_seek_secs
+= v
;
2700 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2705 case MP_CMD_SET_PROPERTY_OSD
:
2706 case_fallthrough_hack
= 1;
2708 case MP_CMD_SET_PROPERTY
:{
2709 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2710 cmd
->args
[1].v
.s
, mpctx
);
2711 if (r
== M_PROPERTY_UNKNOWN
)
2712 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2713 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2715 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2716 "Failed to set property '%s' to '%s'.\n",
2717 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2718 else if (case_fallthrough_hack
)
2719 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2721 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2725 case MP_CMD_STEP_PROPERTY_OSD
:
2726 case_fallthrough_hack
= 1;
2728 case MP_CMD_STEP_PROPERTY
:{
2733 if (cmd
->args
[1].v
.f
) {
2735 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2736 M_PROPERTY_GET_TYPE
,
2737 &prop
, mpctx
)) <= 0)
2739 if(prop
->type
== CONF_TYPE_INT
||
2740 prop
->type
== CONF_TYPE_FLAG
)
2741 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2742 else if(prop
->type
== CONF_TYPE_FLOAT
)
2743 arg
= &cmd
->args
[1].v
.f
;
2744 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2745 prop
->type
== CONF_TYPE_TIME
)
2746 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2747 else if(prop
->type
== CONF_TYPE_POSITION
)
2748 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2750 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2751 "Ignoring step size stepping property '%s'.\n",
2754 r
= mp_property_do(cmd
->args
[0].v
.s
,
2755 cmd
->args
[2].v
.i
< 0 ?
2756 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2759 if (r
== M_PROPERTY_UNKNOWN
)
2760 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2761 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2763 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2764 "Failed to increment property '%s' by %f.\n",
2765 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2766 else if (case_fallthrough_hack
)
2767 show_property_osd(mpctx
, cmd
->args
[0].v
.s
);
2769 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2773 case MP_CMD_GET_PROPERTY
:{
2775 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2778 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2779 "Failed to get value of property '%s'.\n",
2781 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2784 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2785 cmd
->args
[0].v
.s
, tmp
);
2790 case MP_CMD_EDL_MARK
:
2792 float v
= get_current_time(mpctx
);
2793 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2794 mpctx
->begin_skip
= v
;
2795 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip start, press 'i' again to end block.\n");
2797 if (mpctx
->begin_skip
> v
)
2798 mp_tmsg(MSGT_CPLAYER
, MSGL_WARN
, "EDL skip canceled, last start > stop\n");
2800 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2801 mp_tmsg(MSGT_CPLAYER
, MSGL_INFO
, "EDL skip end, line written.\n");
2803 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2808 case MP_CMD_SWITCH_RATIO
:
2811 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2812 opts
->movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2814 opts
->movie_aspect
= cmd
->args
[0].v
.f
;
2815 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2818 case MP_CMD_SPEED_INCR
:{
2819 float v
= cmd
->args
[0].v
.f
;
2820 opts
->playback_speed
+= v
;
2821 reinit_audio_chain(mpctx
);
2822 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2823 opts
->playback_speed
);
2826 case MP_CMD_SPEED_MULT
:{
2827 float v
= cmd
->args
[0].v
.f
;
2828 opts
->playback_speed
*= v
;
2829 reinit_audio_chain(mpctx
);
2830 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2831 opts
->playback_speed
);
2834 case MP_CMD_SPEED_SET
:{
2835 float v
= cmd
->args
[0].v
.f
;
2836 opts
->playback_speed
= v
;
2837 reinit_audio_chain(mpctx
);
2838 set_osd_tmsg(OSD_MSG_SPEED
, 1, osd_duration
, "Speed: x %6.2f",
2839 opts
->playback_speed
);
2842 case MP_CMD_FRAME_STEP
:
2843 add_step_frame(mpctx
);
2846 case MP_CMD_FILE_FILTER
:
2847 file_filter
= cmd
->args
[0].v
.i
;
2851 exit_player_with_rc(mpctx
, EXIT_QUIT
,
2852 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2854 case MP_CMD_PLAY_TREE_STEP
:{
2855 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2856 int force
= cmd
->args
[1].v
.i
;
2859 if (!force
&& mpctx
->playtree_iter
) {
2860 play_tree_iter_t
*i
=
2861 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2862 if (play_tree_iter_step(i
, n
, 0) ==
2863 PLAY_TREE_ITER_ENTRY
)
2865 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2866 play_tree_iter_free(i
);
2868 mpctx
->stop_play
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2869 if (mpctx
->stop_play
)
2870 mpctx
->play_tree_step
= n
;
2875 case MP_CMD_PLAY_TREE_UP_STEP
:{
2876 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2877 int force
= cmd
->args
[1].v
.i
;
2879 if (!force
&& mpctx
->playtree_iter
) {
2880 play_tree_iter_t
*i
=
2881 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2882 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2883 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2884 play_tree_iter_free(i
);
2886 mpctx
->stop_play
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2890 case MP_CMD_PLAY_ALT_SRC_STEP
:
2891 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2892 int v
= cmd
->args
[0].v
.i
;
2894 && mpctx
->playtree_iter
->file
<
2895 mpctx
->playtree_iter
->num_files
)
2896 mpctx
->stop_play
= PT_NEXT_SRC
;
2897 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2898 mpctx
->stop_play
= PT_PREV_SRC
;
2902 case MP_CMD_SUB_STEP
:
2904 int movement
= cmd
->args
[0].v
.i
;
2905 step_sub(subdata
, sh_video
->pts
, movement
);
2909 ass_step_sub(ass_track
,
2911 sub_delay
) * 1000 + .5, movement
) / 1000.;
2913 set_osd_tmsg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2914 "Sub delay: %d ms", ROUND(sub_delay
* 1000));
2918 case MP_CMD_SUB_LOG
:
2923 int v
= cmd
->args
[0].v
.i
;
2924 int max
= (opts
->term_osd
2925 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2926 if (opts
->osd_level
> max
)
2927 opts
->osd_level
= max
;
2929 opts
->osd_level
= (opts
->osd_level
+ 1) % (max
+ 1);
2931 opts
->osd_level
= v
> max
? max
: v
;
2932 /* Show OSD state when disabled, but not when an explicit
2933 argument is given to the OSD command, i.e. in slave mode. */
2934 if (v
== -1 && opts
->osd_level
<= 1)
2935 set_osd_tmsg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2937 opts
->osd_level
? mp_gtext("enabled") :
2938 mp_gtext("disabled"));
2940 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2944 case MP_CMD_OSD_SHOW_TEXT
:
2945 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2947 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2948 "%-.63s", cmd
->args
[0].v
.s
);
2951 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2952 char *txt
= m_properties_expand_string(mp_properties
,
2955 /* if no argument supplied take default osd_duration, else <arg> ms. */
2957 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2959 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2966 case MP_CMD_LOADFILE
:{
2967 play_tree_t
*e
= play_tree_new();
2968 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2970 if (cmd
->args
[1].v
.i
) // append
2971 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2973 // Go back to the starting point.
2974 while (play_tree_iter_up_step
2975 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2977 play_tree_free_list(mpctx
->playtree
->child
, 1);
2978 play_tree_set_child(mpctx
->playtree
, e
);
2979 pt_iter_goto_head(mpctx
->playtree_iter
);
2980 mpctx
->stop_play
= PT_NEXT_SRC
;
2985 case MP_CMD_LOADLIST
:{
2986 play_tree_t
*e
= parse_playlist_file(mpctx
->mconfig
, cmd
->args
[0].v
.s
);
2988 mp_tmsg(MSGT_CPLAYER
, MSGL_ERR
,
2989 "\nUnable to load playlist %s.\n", cmd
->args
[0].v
.s
);
2991 if (cmd
->args
[1].v
.i
) // append
2992 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2994 // Go back to the starting point.
2995 while (play_tree_iter_up_step
2996 (mpctx
->playtree_iter
, 0, 1)
2997 != PLAY_TREE_ITER_END
)
2999 play_tree_free_list(mpctx
->playtree
->child
, 1);
3000 play_tree_set_child(mpctx
->playtree
, e
);
3001 pt_iter_goto_head(mpctx
->playtree_iter
);
3002 mpctx
->stop_play
= PT_NEXT_SRC
;
3009 // Go back to the starting point.
3010 while (play_tree_iter_up_step
3011 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
3013 mpctx
->stop_play
= PT_STOP
;
3016 case MP_CMD_OSD_SHOW_PROGRESSION
:{
3017 int len
= get_time_length(mpctx
);
3018 int pts
= get_current_time(mpctx
);
3019 set_osd_bar(mpctx
, 0, "Position", 0, 100, get_percent_pos(mpctx
));
3020 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3021 "%c %02d:%02d:%02d / %02d:%02d:%02d",
3022 mpctx
->osd_function
, pts
/3600, (pts
/60)%60, pts
%60,
3023 len
/3600, (len
/60)%60, len
%60);
3028 case MP_CMD_RADIO_STEP_CHANNEL
:
3029 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3030 int v
= cmd
->args
[0].v
.i
;
3032 radio_step_channel(mpctx
->demuxer
->stream
,
3033 RADIO_CHANNEL_HIGHER
);
3035 radio_step_channel(mpctx
->demuxer
->stream
,
3036 RADIO_CHANNEL_LOWER
);
3037 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3038 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3040 radio_get_channel_name(mpctx
->demuxer
->stream
));
3045 case MP_CMD_RADIO_SET_CHANNEL
:
3046 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
3047 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
3048 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
3049 set_osd_tmsg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
3051 radio_get_channel_name(mpctx
->demuxer
->stream
));
3056 case MP_CMD_RADIO_SET_FREQ
:
3057 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3058 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3061 case MP_CMD_RADIO_STEP_FREQ
:
3062 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
3063 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
3068 case MP_CMD_TV_START_SCAN
:
3069 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3070 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
3072 case MP_CMD_TV_SET_FREQ
:
3073 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3074 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3075 cmd
->args
[0].v
.f
* 16.0);
3077 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3078 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3079 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3080 pvr_get_current_channelname (mpctx
->stream
),
3081 pvr_get_current_stationname (mpctx
->stream
));
3083 #endif /* CONFIG_PVR */
3086 case MP_CMD_TV_STEP_FREQ
:
3087 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3088 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3089 cmd
->args
[0].v
.f
* 16.0);
3091 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3092 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
3093 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
3094 pvr_get_current_channelname (mpctx
->stream
),
3095 pvr_get_current_frequency (mpctx
->stream
));
3097 #endif /* CONFIG_PVR */
3100 case MP_CMD_TV_SET_NORM
:
3101 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3102 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3106 case MP_CMD_TV_STEP_CHANNEL
:{
3107 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3108 int v
= cmd
->args
[0].v
.i
;
3110 tv_step_channel((tvi_handle_t
*) (mpctx
->
3114 tv_step_channel((tvi_handle_t
*) (mpctx
->
3118 if (tv_channel_list
) {
3119 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3120 "Channel: %s", tv_channel_current
->name
);
3121 //vo_osd_changed(OSDTYPE_SUBTITLE);
3125 else if (mpctx
->stream
&&
3126 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3127 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
3128 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3129 pvr_get_current_channelname (mpctx
->stream
),
3130 pvr_get_current_stationname (mpctx
->stream
));
3132 #endif /* CONFIG_PVR */
3135 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3137 int v
= cmd
->args
[0].v
.i
;
3139 mpctx
->last_dvb_step
= v
;
3141 dir
= DVB_CHANNEL_HIGHER
;
3143 dir
= DVB_CHANNEL_LOWER
;
3146 if (dvb_step_channel(mpctx
->stream
, dir
)) {
3147 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3148 mpctx
->dvbin_reopen
= 1;
3151 #endif /* CONFIG_DVBIN */
3154 case MP_CMD_TV_SET_CHANNEL
:
3155 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3156 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
3158 if (tv_channel_list
) {
3159 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3160 "Channel: %s", tv_channel_current
->name
);
3161 //vo_osd_changed(OSDTYPE_SUBTITLE);
3165 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3166 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
3167 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3168 pvr_get_current_channelname (mpctx
->stream
),
3169 pvr_get_current_stationname (mpctx
->stream
));
3171 #endif /* CONFIG_PVR */
3175 case MP_CMD_DVB_SET_CHANNEL
:
3176 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
3177 mpctx
->last_dvb_step
= 1;
3179 if (dvb_set_channel(mpctx
->stream
, cmd
->args
[1].v
.i
,
3180 cmd
->args
[0].v
.i
)) {
3181 mpctx
->stop_play
= PT_NEXT_ENTRY
;
3182 mpctx
->dvbin_reopen
= 1;
3186 #endif /* CONFIG_DVBIN */
3188 case MP_CMD_TV_LAST_CHANNEL
:
3189 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
3190 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3191 if (tv_channel_list
) {
3192 set_osd_tmsg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
3193 "Channel: %s", tv_channel_current
->name
);
3194 //vo_osd_changed(OSDTYPE_SUBTITLE);
3198 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
3199 pvr_set_lastchannel (mpctx
->stream
);
3200 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
3201 pvr_get_current_channelname (mpctx
->stream
),
3202 pvr_get_current_stationname (mpctx
->stream
));
3204 #endif /* CONFIG_PVR */
3207 case MP_CMD_TV_STEP_NORM
:
3208 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3209 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3212 case MP_CMD_TV_STEP_CHANNEL_LIST
:
3213 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
3214 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
3216 #endif /* CONFIG_TV */
3217 case MP_CMD_TV_TELETEXT_ADD_DEC
:
3218 if (mpctx
->demuxer
->teletext
)
3219 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
3220 &(cmd
->args
[0].v
.s
));
3222 case MP_CMD_TV_TELETEXT_GO_LINK
:
3223 if (mpctx
->demuxer
->teletext
)
3224 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
3225 &(cmd
->args
[0].v
.i
));
3228 case MP_CMD_SUB_LOAD
:
3230 int n
= mpctx
->set_of_sub_size
;
3231 add_subtitles(mpctx
, cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
3232 if (n
!= mpctx
->set_of_sub_size
) {
3233 mpctx
->sub_counts
[SUB_SOURCE_SUBS
]++;
3234 ++mpctx
->global_sub_size
;
3239 case MP_CMD_SUB_REMOVE
:
3241 int v
= cmd
->args
[0].v
.i
;
3243 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
3244 } else if (v
< mpctx
->set_of_sub_size
) {
3245 remove_subtitle_range(mpctx
, v
, 1);
3250 case MP_CMD_GET_SUB_VISIBILITY
:
3252 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3253 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
3257 case MP_CMD_SCREENSHOT
:
3258 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
) {
3259 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
3261 ((vf_instance_t
*) sh_video
->vfilter
)->
3262 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
3264 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
3268 case MP_CMD_VF_CHANGE_RECTANGLE
:
3271 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3274 case MP_CMD_GET_TIME_LENGTH
:{
3275 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2f\n",
3276 get_time_length(mpctx
));
3280 case MP_CMD_GET_FILENAME
:{
3281 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3282 get_metadata(mpctx
, META_NAME
));
3286 case MP_CMD_GET_VIDEO_CODEC
:{
3287 char *inf
= get_metadata(mpctx
, META_VIDEO_CODEC
);
3290 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3295 case MP_CMD_GET_VIDEO_BITRATE
:{
3296 char *inf
= get_metadata(mpctx
, META_VIDEO_BITRATE
);
3299 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3304 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3305 char *inf
= get_metadata(mpctx
, META_VIDEO_RESOLUTION
);
3308 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3309 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3314 case MP_CMD_GET_AUDIO_CODEC
:{
3315 char *inf
= get_metadata(mpctx
, META_AUDIO_CODEC
);
3318 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3323 case MP_CMD_GET_AUDIO_BITRATE
:{
3324 char *inf
= get_metadata(mpctx
, META_AUDIO_BITRATE
);
3327 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3332 case MP_CMD_GET_AUDIO_SAMPLES
:{
3333 char *inf
= get_metadata(mpctx
, META_AUDIO_SAMPLES
);
3336 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3341 case MP_CMD_GET_META_TITLE
:{
3342 char *inf
= get_metadata(mpctx
, META_INFO_TITLE
);
3345 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3350 case MP_CMD_GET_META_ARTIST
:{
3351 char *inf
= get_metadata(mpctx
, META_INFO_ARTIST
);
3354 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3359 case MP_CMD_GET_META_ALBUM
:{
3360 char *inf
= get_metadata(mpctx
, META_INFO_ALBUM
);
3363 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3368 case MP_CMD_GET_META_YEAR
:{
3369 char *inf
= get_metadata(mpctx
, META_INFO_YEAR
);
3372 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3377 case MP_CMD_GET_META_COMMENT
:{
3378 char *inf
= get_metadata(mpctx
, META_INFO_COMMENT
);
3381 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3386 case MP_CMD_GET_META_TRACK
:{
3387 char *inf
= get_metadata(mpctx
, META_INFO_TRACK
);
3390 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3395 case MP_CMD_GET_META_GENRE
:{
3396 char *inf
= get_metadata(mpctx
, META_INFO_GENRE
);
3399 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3404 case MP_CMD_GET_VO_FULLSCREEN
:
3405 if (mpctx
->video_out
&& mpctx
->video_out
->config_ok
)
3406 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3409 case MP_CMD_GET_PERCENT_POS
:
3410 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3411 get_percent_pos(mpctx
));
3414 case MP_CMD_GET_TIME_POS
:{
3415 float pos
= get_current_time(mpctx
);
3416 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3423 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3429 case MP_CMD_KEYDOWN_EVENTS
:
3430 mplayer_put_key(mpctx
->key_fifo
, cmd
->args
[0].v
.i
);
3433 case MP_CMD_SET_MOUSE_POS
:{
3434 int pointer_x
, pointer_y
;
3436 pointer_x
= cmd
->args
[0].v
.i
;
3437 pointer_y
= cmd
->args
[1].v
.i
;
3438 rescale_input_coordinates(mpctx
, pointer_x
, pointer_y
, &dx
, &dy
);
3439 #ifdef CONFIG_DVDNAV
3440 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3441 && dx
> 0.0 && dy
> 0.0) {
3443 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3444 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3445 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3446 pointer_x
, pointer_y
, &button
);
3447 if (opts
->osd_level
> 1 && button
> 0)
3448 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3449 "Selected button number %d", button
);
3453 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3454 menu_update_mouse_pos(dx
, dy
);
3459 #ifdef CONFIG_DVDNAV
3460 case MP_CMD_DVDNAV
:{
3463 mp_command_type command
= 0;
3464 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3467 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3468 if (cmd
->args
[0].v
.s
&&
3469 !strcasecmp (cmd
->args
[0].v
.s
,
3470 mp_dvdnav_bindings
[i
].name
))
3471 command
= mp_dvdnav_bindings
[i
].cmd
;
3473 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3474 if (opts
->osd_level
> 1 && button
> 0)
3475 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3476 "Selected button number %d", button
);
3480 case MP_CMD_SWITCH_TITLE
:
3481 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3482 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3487 case MP_CMD_AF_SWITCH
:
3490 af_uninit(mpctx
->mixer
.afilter
);
3491 af_init(mpctx
->mixer
.afilter
);
3498 char* af_args
= strdup(cmd
->args
[0].v
.s
);
3499 char* af_commands
= af_args
;
3502 while ((af_command
= strsep(&af_commands
, ",")) != NULL
)
3504 if (cmd
->id
== MP_CMD_AF_DEL
)
3506 af
= af_get(mpctx
->mixer
.afilter
, af_command
);
3508 af_remove(mpctx
->mixer
.afilter
, af
);
3511 af_add(mpctx
->mixer
.afilter
, af_command
);
3513 reinit_audio_chain(mpctx
);
3520 af_uninit(mpctx
->mixer
.afilter
);
3521 af_init(mpctx
->mixer
.afilter
);
3522 reinit_audio_chain(mpctx
);
3524 case MP_CMD_AF_CMDLINE
:
3526 af_instance_t
*af
= af_get(sh_audio
->afilter
, cmd
->args
[0].v
.s
);
3528 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
3529 "Filter '%s' not found in chain.\n", cmd
->args
[0].v
.s
);
3532 af
->control(af
, AF_CONTROL_COMMAND_LINE
, cmd
->args
[1].v
.s
);
3533 af_reinit(sh_audio
->afilter
, af
);
3538 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3539 "Received unknown cmd %s\n", cmd
->name
);
3542 switch (cmd
->pausing
) {
3543 case 1: // "pausing"
3544 pause_player(mpctx
);
3546 case 3: // "pausing_toggle"
3548 unpause_player(mpctx
);
3550 pause_player(mpctx
);