7 #include "input/input.h"
8 #include "stream/stream.h"
9 #include "libmpdemux/demuxer.h"
10 #include "libmpdemux/stheader.h"
11 #include "codec-cfg.h"
13 #include "libvo/sub.h"
15 #include "m_property.h"
18 #include "libmpcodecs/mp_image.h"
19 #include "libmpcodecs/vf.h"
20 #include "libmpcodecs/vd.h"
21 #include "libvo/video_out.h"
22 #include "libvo/font_load.h"
24 #include "libao2/audio_out.h"
27 #include "libmpdemux/matroska.h"
28 #include "libmpcodecs/dec_video.h"
33 #include "stream/tv.h"
36 #include "stream/stream_radio.h"
39 #include "stream/pvr.h"
41 #ifdef HAS_DVBIN_SUPPORT
42 #include "stream/dvbin.h"
45 #include "stream/stream_dvd.h"
48 #include "stream/stream_dvdnav.h"
51 #include "libass/ass.h"
52 #include "libass/ass_mp.h"
56 #include "libmenu/menu.h"
59 #include "gui/interface.h"
65 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
69 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
71 //remove the borders, if any, and rescale to the range [0,1],[0,1]
72 if (vo_fs
) { //we are in full-screen mode
73 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
74 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
75 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
76 iy
-= (vo_screenheight
- vo_dheight
) / 2;
78 if (ix
< 0 || ix
> vo_dwidth
) {
81 } //we are on one of the borders
82 if (iy
< 0 || iy
> vo_dheight
) {
85 } //we are on one of the borders
88 *dx
= (double) ix
/ (double) vo_dwidth
;
89 *dy
= (double) iy
/ (double) vo_dheight
;
91 mp_msg(MSGT_CPLAYER
, MSGL_V
,
92 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
93 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
97 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
102 for (i
= 0; i
< SUB_SOURCES
; i
++) {
103 int j
= mpctx
->global_sub_indices
[i
];
104 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
112 static int sub_source(MPContext
* mpctx
)
114 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
118 * \brief Log the currently displayed subtitle to a file
120 * Logs the current or last displayed subtitle together with filename
121 * and time information to ~/.mplayer/subtitle_log
123 * Intended purpose is to allow convenient marking of bogus subtitles
124 * which need to be fixed while watching the movie.
127 static void log_sub(void)
133 if (subdata
== NULL
|| vo_sub_last
== NULL
)
135 fname
= get_path("subtitle_log");
136 f
= fopen(fname
, "a");
139 fprintf(f
, "----------------------------------------------------------\n");
140 if (subdata
->sub_uses_time
) {
142 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
143 filename
, vo_sub_last
->start
/ 360000,
144 (vo_sub_last
->start
/ 6000) % 60,
145 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
146 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
147 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
149 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
152 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
153 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
159 /// \defgroup Properties
162 /// \defgroup GeneralProperties General properties
163 /// \ingroup Properties
167 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
170 return m_property_choice(prop
, action
, arg
, &osd_level
);
174 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
178 case M_PROPERTY_PRINT
:
179 if (!arg
) return M_PROPERTY_ERROR
;
180 if (mpctx
->loop_times
< 0)
181 *(char**)arg
= strdup("off");
182 else if (mpctx
->loop_times
== 0)
183 *(char**)arg
= strdup("inf");
186 return M_PROPERTY_OK
;
188 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
191 /// Playback speed (RW)
192 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
193 void *arg
, MPContext
* mpctx
)
198 return M_PROPERTY_ERROR
;
199 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
200 playback_speed
= *(float *) arg
;
201 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
202 return M_PROPERTY_OK
;
203 case M_PROPERTY_STEP_UP
:
204 case M_PROPERTY_STEP_DOWN
:
205 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
206 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
207 M_PROPERTY_CLAMP(prop
, playback_speed
);
208 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
209 return M_PROPERTY_OK
;
211 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
214 /// filename with path (RO)
215 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
218 return m_property_string_ro(prop
, action
, arg
, filename
);
221 /// filename without path (RO)
222 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
227 return M_PROPERTY_UNAVAILABLE
;
228 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
232 return m_property_string_ro(prop
, action
, arg
, f
);
235 /// Demuxer name (RO)
236 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
240 return M_PROPERTY_UNAVAILABLE
;
241 return m_property_string_ro(prop
, action
, arg
,
242 (char *) mpctx
->demuxer
->desc
->name
);
245 /// Position in the stream (RW)
246 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
249 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
250 return M_PROPERTY_UNAVAILABLE
;
252 return M_PROPERTY_ERROR
;
255 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
256 return M_PROPERTY_OK
;
258 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
259 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
260 return M_PROPERTY_OK
;
262 return M_PROPERTY_NOT_IMPLEMENTED
;
265 /// Stream start offset (RO)
266 static int mp_property_stream_start(m_option_t
* prop
, int action
,
267 void *arg
, MPContext
* mpctx
)
269 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
270 return M_PROPERTY_UNAVAILABLE
;
273 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
274 return M_PROPERTY_OK
;
276 return M_PROPERTY_NOT_IMPLEMENTED
;
279 /// Stream end offset (RO)
280 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
283 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
284 return M_PROPERTY_UNAVAILABLE
;
287 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
288 return M_PROPERTY_OK
;
290 return M_PROPERTY_NOT_IMPLEMENTED
;
293 /// Stream length (RO)
294 static int mp_property_stream_length(m_option_t
* prop
, int action
,
295 void *arg
, MPContext
* mpctx
)
297 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
298 return M_PROPERTY_UNAVAILABLE
;
302 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
303 return M_PROPERTY_OK
;
305 return M_PROPERTY_NOT_IMPLEMENTED
;
308 /// Media length in seconds (RO)
309 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
314 if (!mpctx
->demuxer
||
315 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
316 return M_PROPERTY_UNAVAILABLE
;
318 return m_property_time_ro(prop
, action
, arg
, len
);
321 /// Current position in percent (RW)
322 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
323 void *arg
, MPContext
* mpctx
) {
327 return M_PROPERTY_UNAVAILABLE
;
331 if(!arg
) return M_PROPERTY_ERROR
;
332 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
335 case M_PROPERTY_STEP_UP
:
336 case M_PROPERTY_STEP_DOWN
:
337 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
338 pos
+= (arg
? *(int*)arg
: 10) *
339 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
340 M_PROPERTY_CLAMP(prop
, pos
);
343 return m_property_int_ro(prop
, action
, arg
,
344 demuxer_get_percent_pos(mpctx
->demuxer
));
348 rel_seek_secs
= pos
/ 100.0;
349 return M_PROPERTY_OK
;
352 /// Current position in seconds (RW)
353 static int mp_property_time_pos(m_option_t
* prop
, int action
,
354 void *arg
, MPContext
* mpctx
) {
355 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
356 return M_PROPERTY_UNAVAILABLE
;
360 if(!arg
) return M_PROPERTY_ERROR
;
361 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
363 rel_seek_secs
= *(double*)arg
;
364 return M_PROPERTY_OK
;
365 case M_PROPERTY_STEP_UP
:
366 case M_PROPERTY_STEP_DOWN
:
367 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
368 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
369 return M_PROPERTY_OK
;
371 return m_property_time_ro(prop
, action
, arg
,
372 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
373 playing_audio_pts(mpctx
->sh_audio
,
378 /// Current chapter (RW)
379 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
386 char *chapter_name
= NULL
;
388 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
390 return M_PROPERTY_UNAVAILABLE
;
395 return M_PROPERTY_ERROR
;
396 *(int *) arg
= chapter
;
397 return M_PROPERTY_OK
;
398 case M_PROPERTY_PRINT
: {
400 return M_PROPERTY_ERROR
;
401 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
403 return M_PROPERTY_UNAVAILABLE
;
404 *(char **) arg
= chapter_name
;
405 return M_PROPERTY_OK
;
409 return M_PROPERTY_ERROR
;
410 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
411 step_all
= *(int *)arg
- (chapter
+ 1);
414 case M_PROPERTY_STEP_UP
:
415 case M_PROPERTY_STEP_DOWN
: {
416 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
417 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
424 return M_PROPERTY_NOT_IMPLEMENTED
;
428 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
429 &next_pts
, &chapter_num
, &chapter_name
);
431 if (next_pts
> -1.0) {
433 rel_seek_secs
= next_pts
;
436 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
437 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
439 else if (step_all
> 0)
440 rel_seek_secs
= 1000000000.;
442 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
443 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
446 return M_PROPERTY_OK
;
449 /// Current dvd angle (RW)
450 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
455 char *angle_name
= NULL
;
457 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
459 return M_PROPERTY_UNAVAILABLE
;
460 angles
= demuxer_angles_count(mpctx
->demuxer
);
462 return M_PROPERTY_UNAVAILABLE
;
467 return M_PROPERTY_ERROR
;
468 *(int *) arg
= angle
;
469 return M_PROPERTY_OK
;
470 case M_PROPERTY_PRINT
: {
472 return M_PROPERTY_ERROR
;
473 angle_name
= calloc(1, 64);
475 return M_PROPERTY_UNAVAILABLE
;
476 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
477 *(char **) arg
= angle_name
;
478 return M_PROPERTY_OK
;
482 return M_PROPERTY_ERROR
;
484 M_PROPERTY_CLAMP(prop
, angle
);
486 case M_PROPERTY_STEP_UP
:
487 case M_PROPERTY_STEP_DOWN
: {
493 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
495 if (angle
< 1) //cycle
500 return M_PROPERTY_NOT_IMPLEMENTED
;
502 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
503 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
504 MSGTR_OSDAngle
, angle
, angles
);
507 return M_PROPERTY_OK
;
510 /// Demuxer meta data
511 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
513 m_property_action_t
* ka
;
515 static m_option_t key_type
=
516 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
518 return M_PROPERTY_UNAVAILABLE
;
522 if(!arg
) return M_PROPERTY_ERROR
;
523 *(char***)arg
= mpctx
->demuxer
->info
;
524 return M_PROPERTY_OK
;
525 case M_PROPERTY_KEY_ACTION
:
526 if(!arg
) return M_PROPERTY_ERROR
;
528 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
529 return M_PROPERTY_UNKNOWN
;
532 if(!ka
->arg
) return M_PROPERTY_ERROR
;
533 *(char**)ka
->arg
= meta
;
534 return M_PROPERTY_OK
;
535 case M_PROPERTY_GET_TYPE
:
536 if(!ka
->arg
) return M_PROPERTY_ERROR
;
537 *(m_option_t
**)ka
->arg
= &key_type
;
538 return M_PROPERTY_OK
;
541 return M_PROPERTY_NOT_IMPLEMENTED
;
547 /// \defgroup AudioProperties Audio properties
548 /// \ingroup Properties
552 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
556 if (!mpctx
->sh_audio
)
557 return M_PROPERTY_UNAVAILABLE
;
562 return M_PROPERTY_ERROR
;
563 mixer_getbothvolume(&mpctx
->mixer
, arg
);
564 return M_PROPERTY_OK
;
565 case M_PROPERTY_PRINT
:{
568 return M_PROPERTY_ERROR
;
569 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
570 return m_property_float_range(prop
, action
, arg
, &vol
);
572 case M_PROPERTY_STEP_UP
:
573 case M_PROPERTY_STEP_DOWN
:
577 return M_PROPERTY_NOT_IMPLEMENTED
;
580 if (mpctx
->edl_muted
)
581 return M_PROPERTY_DISABLED
;
582 mpctx
->user_muted
= 0;
587 return M_PROPERTY_ERROR
;
588 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
589 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
590 return M_PROPERTY_OK
;
591 case M_PROPERTY_STEP_UP
:
592 if (arg
&& *(float *) arg
<= 0)
593 mixer_decvolume(&mpctx
->mixer
);
595 mixer_incvolume(&mpctx
->mixer
);
596 return M_PROPERTY_OK
;
597 case M_PROPERTY_STEP_DOWN
:
598 if (arg
&& *(float *) arg
<= 0)
599 mixer_incvolume(&mpctx
->mixer
);
601 mixer_decvolume(&mpctx
->mixer
);
602 return M_PROPERTY_OK
;
604 return M_PROPERTY_NOT_IMPLEMENTED
;
608 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
612 if (!mpctx
->sh_audio
)
613 return M_PROPERTY_UNAVAILABLE
;
617 if (mpctx
->edl_muted
)
618 return M_PROPERTY_DISABLED
;
620 return M_PROPERTY_ERROR
;
621 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
622 mixer_mute(&mpctx
->mixer
);
623 mpctx
->user_muted
= mpctx
->mixer
.muted
;
624 return M_PROPERTY_OK
;
625 case M_PROPERTY_STEP_UP
:
626 case M_PROPERTY_STEP_DOWN
:
627 if (mpctx
->edl_muted
)
628 return M_PROPERTY_DISABLED
;
629 mixer_mute(&mpctx
->mixer
);
630 mpctx
->user_muted
= mpctx
->mixer
.muted
;
631 return M_PROPERTY_OK
;
632 case M_PROPERTY_PRINT
:
634 return M_PROPERTY_ERROR
;
635 if (mpctx
->edl_muted
) {
636 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
637 return M_PROPERTY_OK
;
640 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
646 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
647 void *arg
, MPContext
* mpctx
)
649 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
650 return M_PROPERTY_UNAVAILABLE
;
653 case M_PROPERTY_STEP_UP
:
654 case M_PROPERTY_STEP_DOWN
: {
656 float delay
= audio_delay
;
657 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
658 if (ret
!= M_PROPERTY_OK
)
661 mpctx
->delay
-= audio_delay
- delay
;
663 return M_PROPERTY_OK
;
665 return m_property_delay(prop
, action
, arg
, &audio_delay
);
669 /// Audio codec tag (RO)
670 static int mp_property_audio_format(m_option_t
* prop
, int action
,
671 void *arg
, MPContext
* mpctx
)
673 if (!mpctx
->sh_audio
)
674 return M_PROPERTY_UNAVAILABLE
;
675 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
678 /// Audio codec name (RO)
679 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
680 void *arg
, MPContext
* mpctx
)
682 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
683 return M_PROPERTY_UNAVAILABLE
;
684 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
687 /// Audio bitrate (RO)
688 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
689 void *arg
, MPContext
* mpctx
)
691 if (!mpctx
->sh_audio
)
692 return M_PROPERTY_UNAVAILABLE
;
693 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
697 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
700 if (!mpctx
->sh_audio
)
701 return M_PROPERTY_UNAVAILABLE
;
703 case M_PROPERTY_PRINT
:
704 if(!arg
) return M_PROPERTY_ERROR
;
705 *(char**)arg
= malloc(16);
706 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
707 return M_PROPERTY_OK
;
709 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
712 /// Number of channels (RO)
713 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
716 if (!mpctx
->sh_audio
)
717 return M_PROPERTY_UNAVAILABLE
;
719 case M_PROPERTY_PRINT
:
721 return M_PROPERTY_ERROR
;
722 switch (mpctx
->sh_audio
->channels
) {
724 *(char **) arg
= strdup("mono");
727 *(char **) arg
= strdup("stereo");
730 *(char **) arg
= malloc(32);
731 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
733 return M_PROPERTY_OK
;
735 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
739 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
744 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
745 return M_PROPERTY_UNAVAILABLE
;
750 return M_PROPERTY_ERROR
;
751 mixer_getbalance(&mpctx
->mixer
, arg
);
752 return M_PROPERTY_OK
;
753 case M_PROPERTY_PRINT
: {
756 return M_PROPERTY_ERROR
;
757 mixer_getbalance(&mpctx
->mixer
, &bal
);
759 *str
= strdup("center");
760 else if (bal
== -1.f
)
761 *str
= strdup("left only");
763 *str
= strdup("right only");
765 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
766 *str
= malloc(sizeof("left xxx%, right xxx%"));
767 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
769 return M_PROPERTY_OK
;
771 case M_PROPERTY_STEP_UP
:
772 case M_PROPERTY_STEP_DOWN
:
773 mixer_getbalance(&mpctx
->mixer
, &bal
);
774 bal
+= (arg
? *(float*)arg
: .1f
) *
775 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
776 M_PROPERTY_CLAMP(prop
, bal
);
777 mixer_setbalance(&mpctx
->mixer
, bal
);
778 return M_PROPERTY_OK
;
781 return M_PROPERTY_ERROR
;
782 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
783 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
784 return M_PROPERTY_OK
;
786 return M_PROPERTY_NOT_IMPLEMENTED
;
789 /// Selected audio id (RW)
790 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
793 int current_id
= -1, tmp
;
797 if (!mpctx
->sh_audio
)
798 return M_PROPERTY_UNAVAILABLE
;
800 return M_PROPERTY_ERROR
;
801 *(int *) arg
= audio_id
;
802 return M_PROPERTY_OK
;
803 case M_PROPERTY_PRINT
:
804 if (!mpctx
->sh_audio
)
805 return M_PROPERTY_UNAVAILABLE
;
807 return M_PROPERTY_ERROR
;
810 *(char **) arg
= strdup(MSGTR_Disabled
);
812 char lang
[40] = MSGTR_Unknown
;
813 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
814 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
816 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
817 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
827 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
828 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
830 *(char **) arg
= malloc(64);
831 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
833 return M_PROPERTY_OK
;
835 case M_PROPERTY_STEP_UP
:
837 if (action
== M_PROPERTY_SET
&& arg
)
838 tmp
= *((int *) arg
);
841 current_id
= mpctx
->demuxer
->audio
->id
;
842 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
845 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
846 uninit_player(INITED_AO
| INITED_ACODEC
);
847 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
849 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
851 sh2
->ds
= mpctx
->demuxer
->audio
;
852 mpctx
->sh_audio
= sh2
;
853 reinit_audio_chain();
856 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
857 return M_PROPERTY_OK
;
859 return M_PROPERTY_NOT_IMPLEMENTED
;
864 /// Selected video id (RW)
865 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
868 int current_id
= -1, tmp
;
872 if (!mpctx
->sh_video
)
873 return M_PROPERTY_UNAVAILABLE
;
875 return M_PROPERTY_ERROR
;
876 *(int *) arg
= video_id
;
877 return M_PROPERTY_OK
;
878 case M_PROPERTY_PRINT
:
879 if (!mpctx
->sh_video
)
880 return M_PROPERTY_UNAVAILABLE
;
882 return M_PROPERTY_ERROR
;
885 *(char **) arg
= strdup(MSGTR_Disabled
);
887 char lang
[40] = MSGTR_Unknown
;
888 *(char **) arg
= malloc(64);
889 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
891 return M_PROPERTY_OK
;
893 case M_PROPERTY_STEP_UP
:
895 current_id
= mpctx
->demuxer
->video
->id
;
896 if (action
== M_PROPERTY_SET
&& arg
)
897 tmp
= *((int *) arg
);
900 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
902 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
903 && current_id
!= -2))
904 uninit_player(INITED_VCODEC
|
905 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
906 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
908 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
910 sh2
->ds
= mpctx
->demuxer
->video
;
911 mpctx
->sh_video
= sh2
;
912 reinit_video_chain();
915 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
916 return M_PROPERTY_OK
;
919 return M_PROPERTY_NOT_IMPLEMENTED
;
923 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
926 demux_program_t prog
;
929 case M_PROPERTY_STEP_UP
:
931 if (action
== M_PROPERTY_SET
&& arg
)
932 prog
.progid
= *((int *) arg
);
936 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
937 &prog
) == DEMUXER_CTRL_NOTIMPL
)
938 return M_PROPERTY_ERROR
;
940 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
941 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
942 return M_PROPERTY_OK
;
945 return M_PROPERTY_NOT_IMPLEMENTED
;
951 /// \defgroup VideoProperties Video properties
952 /// \ingroup Properties
955 /// Fullscreen state (RW)
956 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
960 if (!mpctx
->video_out
)
961 return M_PROPERTY_UNAVAILABLE
;
966 return M_PROPERTY_ERROR
;
967 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
968 if (vo_fs
== !!*(int *) arg
)
969 return M_PROPERTY_OK
;
970 case M_PROPERTY_STEP_UP
:
971 case M_PROPERTY_STEP_DOWN
:
974 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
978 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
979 return M_PROPERTY_OK
;
981 return m_property_flag(prop
, action
, arg
, &vo_fs
);
985 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
986 void *arg
, MPContext
* mpctx
)
990 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
991 return M_PROPERTY_UNAVAILABLE
;
992 vf
= mpctx
->sh_video
->vfilter
;
996 return M_PROPERTY_ERROR
;
997 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
998 return M_PROPERTY_OK
;
1001 return M_PROPERTY_ERROR
;
1002 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1003 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1004 return M_PROPERTY_OK
;
1005 case M_PROPERTY_STEP_UP
:
1006 case M_PROPERTY_STEP_DOWN
:
1007 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1008 deinterlace
= !deinterlace
;
1009 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1010 return M_PROPERTY_OK
;
1012 return M_PROPERTY_NOT_IMPLEMENTED
;
1016 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1020 if (!mpctx
->video_out
1021 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1022 return M_PROPERTY_UNAVAILABLE
;
1025 case M_PROPERTY_SET
:
1027 return M_PROPERTY_ERROR
;
1028 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1029 vo_panscan
= *(float *) arg
;
1030 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1031 return M_PROPERTY_OK
;
1032 case M_PROPERTY_STEP_UP
:
1033 case M_PROPERTY_STEP_DOWN
:
1034 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1035 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1038 else if (vo_panscan
< 0)
1040 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1041 return M_PROPERTY_OK
;
1043 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1047 /// Helper to set vo flags.
1048 /** \ingroup PropertyImplHelper
1050 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1051 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1054 if (!mpctx
->video_out
)
1055 return M_PROPERTY_UNAVAILABLE
;
1058 case M_PROPERTY_SET
:
1060 return M_PROPERTY_ERROR
;
1061 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1062 if (*vo_var
== !!*(int *) arg
)
1063 return M_PROPERTY_OK
;
1064 case M_PROPERTY_STEP_UP
:
1065 case M_PROPERTY_STEP_DOWN
:
1066 if (vo_config_count
)
1067 mpctx
->video_out
->control(vo_ctrl
, 0);
1068 return M_PROPERTY_OK
;
1070 return m_property_flag(prop
, action
, arg
, vo_var
);
1074 /// Window always on top (RW)
1075 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1078 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1082 /// Display in the root window (RW)
1083 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1086 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1087 &vo_rootwin
, mpctx
);
1090 /// Show window borders (RW)
1091 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1094 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1098 /// Framedropping state (RW)
1099 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1100 void *arg
, MPContext
* mpctx
)
1103 if (!mpctx
->sh_video
)
1104 return M_PROPERTY_UNAVAILABLE
;
1107 case M_PROPERTY_PRINT
:
1109 return M_PROPERTY_ERROR
;
1110 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1111 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1113 return M_PROPERTY_OK
;
1115 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1119 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1120 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1123 int *gamma
= prop
->priv
, r
, val
;
1125 if (!mpctx
->sh_video
)
1126 return M_PROPERTY_UNAVAILABLE
;
1128 if (gamma
[0] == 1000) {
1130 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1134 case M_PROPERTY_SET
:
1136 return M_PROPERTY_ERROR
;
1137 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1138 *gamma
= *(int *) arg
;
1139 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1143 case M_PROPERTY_GET
:
1144 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1146 return M_PROPERTY_ERROR
;
1148 return M_PROPERTY_OK
;
1151 case M_PROPERTY_STEP_UP
:
1152 case M_PROPERTY_STEP_DOWN
:
1153 *gamma
+= (arg
? *(int *) arg
: 1) *
1154 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1155 M_PROPERTY_CLAMP(prop
, *gamma
);
1156 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1161 return M_PROPERTY_NOT_IMPLEMENTED
;
1165 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1166 int l
= strlen(prop
->name
);
1167 char tv_prop
[3 + l
+ 1];
1168 sprintf(tv_prop
, "tv_%s", prop
->name
);
1169 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1173 return M_PROPERTY_UNAVAILABLE
;
1177 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1180 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1183 /// Video codec tag (RO)
1184 static int mp_property_video_format(m_option_t
* prop
, int action
,
1185 void *arg
, MPContext
* mpctx
)
1188 if (!mpctx
->sh_video
)
1189 return M_PROPERTY_UNAVAILABLE
;
1191 case M_PROPERTY_PRINT
:
1193 return M_PROPERTY_ERROR
;
1194 switch(mpctx
->sh_video
->format
) {
1196 meta
= strdup ("mpeg1"); break;
1198 meta
= strdup ("mpeg2"); break;
1200 meta
= strdup ("mpeg4"); break;
1202 meta
= strdup ("h264"); break;
1204 if(mpctx
->sh_video
->format
>= 0x20202020) {
1206 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1209 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1212 *(char**)arg
= meta
;
1213 return M_PROPERTY_OK
;
1215 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1218 /// Video codec name (RO)
1219 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1220 void *arg
, MPContext
* mpctx
)
1222 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1223 return M_PROPERTY_UNAVAILABLE
;
1224 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1228 /// Video bitrate (RO)
1229 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1230 void *arg
, MPContext
* mpctx
)
1232 if (!mpctx
->sh_video
)
1233 return M_PROPERTY_UNAVAILABLE
;
1234 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1237 /// Video display width (RO)
1238 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1241 if (!mpctx
->sh_video
)
1242 return M_PROPERTY_UNAVAILABLE
;
1243 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1246 /// Video display height (RO)
1247 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1250 if (!mpctx
->sh_video
)
1251 return M_PROPERTY_UNAVAILABLE
;
1252 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1256 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1259 if (!mpctx
->sh_video
)
1260 return M_PROPERTY_UNAVAILABLE
;
1261 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1264 /// Video aspect (RO)
1265 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1268 if (!mpctx
->sh_video
)
1269 return M_PROPERTY_UNAVAILABLE
;
1270 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1275 /// \defgroup SubProprties Subtitles properties
1276 /// \ingroup Properties
1279 /// Text subtitle position (RW)
1280 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1283 if (!mpctx
->sh_video
)
1284 return M_PROPERTY_UNAVAILABLE
;
1287 case M_PROPERTY_SET
:
1289 return M_PROPERTY_ERROR
;
1290 case M_PROPERTY_STEP_UP
:
1291 case M_PROPERTY_STEP_DOWN
:
1292 vo_osd_changed(OSDTYPE_SUBTITLE
);
1294 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1298 char *demux_lavf_sub_lang(demuxer_t
*demuxer
, int track_num
);
1300 /// Selected subtitles (RW)
1301 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1304 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1305 const int global_sub_size
= mpctx
->global_sub_size
;
1306 int source
= -1, reset_spu
= 0;
1309 if (global_sub_size
<= 0)
1310 return M_PROPERTY_UNAVAILABLE
;
1313 case M_PROPERTY_GET
:
1315 return M_PROPERTY_ERROR
;
1316 *(int *) arg
= mpctx
->global_sub_pos
;
1317 return M_PROPERTY_OK
;
1318 case M_PROPERTY_PRINT
:
1320 return M_PROPERTY_ERROR
;
1321 *(char **) arg
= malloc(64);
1322 (*(char **) arg
)[63] = 0;
1325 sub_name
= subdata
->filename
;
1327 if (ass_track
&& ass_track
->name
)
1328 sub_name
= ass_track
->name
;
1333 if ((tmp2
= strrchr(tmp
, '/')))
1336 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1337 mpctx
->set_of_sub_pos
+ 1,
1338 strlen(tmp
) < 20 ? "" : "...",
1339 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1340 return M_PROPERTY_OK
;
1343 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1344 if (vo_spudec
&& dvdsub_id
>= 0) {
1345 unsigned char lang
[3];
1346 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1347 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1348 return M_PROPERTY_OK
;
1354 #ifdef USE_LIBAVFORMAT
1355 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
&& dvdsub_id
>= 0) {
1356 char *lang
= demux_lavf_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1357 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1358 return M_PROPERTY_OK
;
1361 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1362 char lang
[40] = MSGTR_Unknown
;
1363 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1364 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1365 return M_PROPERTY_OK
;
1367 #ifdef HAVE_OGGVORBIS
1368 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1369 const char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1371 lang
= MSGTR_Unknown
;
1372 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1373 return M_PROPERTY_OK
;
1376 if (vo_vobsub
&& vobsub_id
>= 0) {
1377 const char *language
= MSGTR_Unknown
;
1378 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1379 snprintf(*(char **) arg
, 63, "(%d) %s",
1380 vobsub_id
, language
? language
: MSGTR_Unknown
);
1381 return M_PROPERTY_OK
;
1384 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1385 && dvdsub_id
>= 0) {
1387 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1388 lang
[0] = code
>> 8;
1391 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1392 return M_PROPERTY_OK
;
1395 if (dvdsub_id
>= 0) {
1396 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1397 return M_PROPERTY_OK
;
1399 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1400 return M_PROPERTY_OK
;
1402 case M_PROPERTY_SET
:
1404 return M_PROPERTY_ERROR
;
1405 if (*(int *) arg
< -1)
1407 else if (*(int *) arg
>= global_sub_size
)
1408 *(int *) arg
= global_sub_size
- 1;
1409 mpctx
->global_sub_pos
= *(int *) arg
;
1411 case M_PROPERTY_STEP_UP
:
1412 mpctx
->global_sub_pos
+= 2;
1413 mpctx
->global_sub_pos
=
1414 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1416 case M_PROPERTY_STEP_DOWN
:
1417 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1418 mpctx
->global_sub_pos
=
1419 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1422 return M_PROPERTY_NOT_IMPLEMENTED
;
1425 if (mpctx
->global_sub_pos
>= 0)
1426 source
= sub_source(mpctx
);
1428 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1429 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1431 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1432 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1433 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1434 mpctx
->global_sub_pos
, source
);
1436 mpctx
->set_of_sub_pos
= -1;
1450 if (source
== SUB_SOURCE_VOBSUB
) {
1451 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1452 } else if (source
== SUB_SOURCE_SUBS
) {
1453 mpctx
->set_of_sub_pos
=
1454 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1456 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1457 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1461 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1462 vo_osd_changed(OSDTYPE_SUBTITLE
);
1464 } else if (source
== SUB_SOURCE_DEMUX
) {
1466 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1467 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1469 // default: assume 1:1 mapping of sid and stream id
1470 d_sub
->id
= dvdsub_id
;
1471 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1472 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1473 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1474 if (sh
&& sh
->sid
== dvdsub_id
) {
1480 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1481 sh_sub_t
*sh
= d_sub
->sh
;
1482 if (sh
->type
== 'v')
1485 else if (ass_enabled
&& sh
->type
== 'a')
1486 ass_track
= sh
->ass_track
;
1496 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1497 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1498 && dvdsub_id
< 0 && reset_spu
) {
1500 d_sub
->id
= dvdsub_id
;
1503 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1505 return M_PROPERTY_OK
;
1508 /// Selected sub source (RW)
1509 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1513 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1514 return M_PROPERTY_UNAVAILABLE
;
1517 case M_PROPERTY_GET
:
1519 return M_PROPERTY_ERROR
;
1520 *(int *) arg
= sub_source(mpctx
);
1521 return M_PROPERTY_OK
;
1522 case M_PROPERTY_PRINT
:
1524 return M_PROPERTY_ERROR
;
1525 *(char **) arg
= malloc(64);
1526 (*(char **) arg
)[63] = 0;
1527 switch (sub_source(mpctx
))
1529 case SUB_SOURCE_SUBS
:
1530 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1532 case SUB_SOURCE_VOBSUB
:
1533 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1535 case SUB_SOURCE_DEMUX
:
1536 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1539 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1541 return M_PROPERTY_OK
;
1542 case M_PROPERTY_SET
:
1544 return M_PROPERTY_ERROR
;
1545 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1546 if (*(int *) arg
< 0)
1547 mpctx
->global_sub_pos
= -1;
1548 else if (*(int *) arg
!= sub_source(mpctx
)) {
1549 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1550 return M_PROPERTY_UNAVAILABLE
;
1551 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1554 case M_PROPERTY_STEP_UP
:
1555 case M_PROPERTY_STEP_DOWN
: {
1556 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1557 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1558 int step
= (step_all
> 0) ? 1 : -1;
1559 int cur_source
= sub_source(mpctx
);
1560 source
= cur_source
;
1563 if (source
>= SUB_SOURCES
)
1565 else if (source
< -1)
1566 source
= SUB_SOURCES
- 1;
1567 if (source
== cur_source
|| source
== -1 ||
1568 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1571 if (source
== cur_source
)
1572 return M_PROPERTY_OK
;
1574 mpctx
->global_sub_pos
= -1;
1576 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1580 return M_PROPERTY_NOT_IMPLEMENTED
;
1582 --mpctx
->global_sub_pos
;
1583 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1586 /// Selected subtitles from specific source (RW)
1587 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1590 int source
, is_cur_source
, offset
;
1591 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1592 return M_PROPERTY_UNAVAILABLE
;
1594 if (!strcmp(prop
->name
, "sub_file"))
1595 source
= SUB_SOURCE_SUBS
;
1596 else if (!strcmp(prop
->name
, "sub_vob"))
1597 source
= SUB_SOURCE_VOBSUB
;
1598 else if (!strcmp(prop
->name
, "sub_demux"))
1599 source
= SUB_SOURCE_DEMUX
;
1601 return M_PROPERTY_ERROR
;
1603 offset
= mpctx
->global_sub_indices
[source
];
1604 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1605 return M_PROPERTY_UNAVAILABLE
;
1607 is_cur_source
= sub_source(mpctx
) == source
;
1609 case M_PROPERTY_GET
:
1611 return M_PROPERTY_ERROR
;
1612 if (is_cur_source
) {
1613 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1614 if (source
== SUB_SOURCE_VOBSUB
)
1615 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1619 return M_PROPERTY_OK
;
1620 case M_PROPERTY_PRINT
:
1622 return M_PROPERTY_ERROR
;
1624 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1625 *(char **) arg
= malloc(64);
1626 (*(char **) arg
)[63] = 0;
1627 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1628 return M_PROPERTY_OK
;
1629 case M_PROPERTY_SET
:
1631 return M_PROPERTY_ERROR
;
1632 if (*(int *) arg
>= 0) {
1633 int index
= *(int *)arg
;
1634 if (source
== SUB_SOURCE_VOBSUB
)
1635 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1636 mpctx
->global_sub_pos
= offset
+ index
;
1637 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1638 || sub_source(mpctx
) != source
) {
1639 mpctx
->global_sub_pos
= -1;
1644 mpctx
->global_sub_pos
= -1;
1646 case M_PROPERTY_STEP_UP
:
1647 case M_PROPERTY_STEP_DOWN
: {
1648 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1649 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1650 int step
= (step_all
> 0) ? 1 : -1;
1651 int max_sub_pos_for_source
= -1;
1653 mpctx
->global_sub_pos
= -1;
1655 if (mpctx
->global_sub_pos
== -1) {
1657 mpctx
->global_sub_pos
= offset
;
1658 else if (max_sub_pos_for_source
== -1) {
1659 // Find max pos for specific source
1660 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1661 while (mpctx
->global_sub_pos
>= 0
1662 && sub_source(mpctx
) != source
)
1663 --mpctx
->global_sub_pos
;
1666 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1669 mpctx
->global_sub_pos
+= step
;
1670 if (mpctx
->global_sub_pos
< offset
||
1671 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1672 sub_source(mpctx
) != source
)
1673 mpctx
->global_sub_pos
= -1;
1680 return M_PROPERTY_NOT_IMPLEMENTED
;
1682 --mpctx
->global_sub_pos
;
1683 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1686 /// Subtitle delay (RW)
1687 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1690 if (!mpctx
->sh_video
)
1691 return M_PROPERTY_UNAVAILABLE
;
1692 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1695 /// Alignment of text subtitles (RW)
1696 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1697 void *arg
, MPContext
* mpctx
)
1699 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1701 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1702 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1703 return M_PROPERTY_UNAVAILABLE
;
1706 case M_PROPERTY_PRINT
:
1708 return M_PROPERTY_ERROR
;
1709 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1710 *(char **) arg
= strdup(name
[sub_alignment
]);
1711 return M_PROPERTY_OK
;
1712 case M_PROPERTY_SET
:
1714 return M_PROPERTY_ERROR
;
1715 case M_PROPERTY_STEP_UP
:
1716 case M_PROPERTY_STEP_DOWN
:
1717 vo_osd_changed(OSDTYPE_SUBTITLE
);
1719 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1723 /// Subtitle visibility (RW)
1724 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1725 void *arg
, MPContext
* mpctx
)
1727 if (!mpctx
->sh_video
)
1728 return M_PROPERTY_UNAVAILABLE
;
1731 case M_PROPERTY_SET
:
1733 return M_PROPERTY_ERROR
;
1734 case M_PROPERTY_STEP_UP
:
1735 case M_PROPERTY_STEP_DOWN
:
1736 vo_osd_changed(OSDTYPE_SUBTITLE
);
1738 vo_osd_changed(OSDTYPE_SPU
);
1740 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1744 /// Show only forced subtitles (RW)
1745 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1746 void *arg
, MPContext
* mpctx
)
1749 return M_PROPERTY_UNAVAILABLE
;
1752 case M_PROPERTY_SET
:
1754 return M_PROPERTY_ERROR
;
1755 case M_PROPERTY_STEP_UP
:
1756 case M_PROPERTY_STEP_DOWN
:
1757 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1758 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1759 return M_PROPERTY_OK
;
1761 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1766 #ifdef HAVE_FREETYPE
1767 /// Subtitle scale (RW)
1768 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1773 case M_PROPERTY_SET
:
1775 return M_PROPERTY_ERROR
;
1776 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1777 text_font_scale_factor
= *(float *) arg
;
1778 force_load_font
= 1;
1779 return M_PROPERTY_OK
;
1780 case M_PROPERTY_STEP_UP
:
1781 case M_PROPERTY_STEP_DOWN
:
1782 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1783 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1784 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1785 force_load_font
= 1;
1786 return M_PROPERTY_OK
;
1788 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1795 /// \defgroup TVProperties TV properties
1796 /// \ingroup Properties
1801 /// TV color settings (RW)
1802 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1806 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1807 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1808 return M_PROPERTY_UNAVAILABLE
;
1811 case M_PROPERTY_SET
:
1813 return M_PROPERTY_ERROR
;
1814 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1815 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1816 case M_PROPERTY_GET
:
1817 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1818 case M_PROPERTY_STEP_UP
:
1819 case M_PROPERTY_STEP_DOWN
:
1820 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1822 return M_PROPERTY_ERROR
;
1823 val
+= (arg
? *(int *) arg
: 1) *
1824 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1825 M_PROPERTY_CLAMP(prop
, val
);
1826 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1828 return M_PROPERTY_ERROR
;
1830 return M_PROPERTY_NOT_IMPLEMENTED
;
1835 #ifdef HAVE_TV_TELETEXT
1836 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1840 int base_ioctl
=(int)prop
->priv
;
1842 for teletext's GET,SET,STEP ioctls this is not 0
1846 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1847 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1848 return M_PROPERTY_UNAVAILABLE
;
1850 return M_PROPERTY_ERROR
;
1853 case M_PROPERTY_GET
:
1855 return M_PROPERTY_ERROR
;
1856 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1858 case M_PROPERTY_SET
:
1860 return M_PROPERTY_ERROR
;
1861 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1862 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1864 case M_PROPERTY_STEP_UP
:
1865 case M_PROPERTY_STEP_DOWN
:
1866 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1867 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1868 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1871 return M_PROPERTY_NOT_IMPLEMENTED
;
1874 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1877 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1880 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1884 //with tvh==NULL will fail too
1885 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1886 if(result
!=M_PROPERTY_OK
)
1889 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1890 mp_input_set_section("teletext");
1892 mp_input_set_section("tv");
1893 return M_PROPERTY_OK
;
1896 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1899 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1903 case M_PROPERTY_STEP_UP
:
1904 case M_PROPERTY_STEP_DOWN
:
1905 //This should be handled separately
1906 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1907 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1910 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1916 #endif /* HAVE_TV_TELETEXT */
1920 /// All properties available in MPlayer.
1921 /** \ingroup Properties
1923 static m_option_t mp_properties
[] = {
1925 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1926 M_OPT_RANGE
, 0, 3, NULL
},
1927 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1928 M_OPT_MIN
, -1, 0, NULL
},
1929 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1930 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1931 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1933 { "path", mp_property_path
, CONF_TYPE_STRING
,
1935 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1937 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1938 M_OPT_MIN
, 0, 0, NULL
},
1939 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1940 M_OPT_MIN
, 0, 0, NULL
},
1941 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1942 M_OPT_MIN
, 0, 0, NULL
},
1943 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1944 M_OPT_MIN
, 0, 0, NULL
},
1945 { "length", mp_property_length
, CONF_TYPE_TIME
,
1946 M_OPT_MIN
, 0, 0, NULL
},
1947 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1948 M_OPT_RANGE
, 0, 100, NULL
},
1949 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1950 M_OPT_MIN
, 0, 0, NULL
},
1951 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1952 M_OPT_MIN
, 1, 0, NULL
},
1953 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1954 CONF_RANGE
, -2, 10, NULL
},
1955 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1959 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1960 M_OPT_RANGE
, 0, 100, NULL
},
1961 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1962 M_OPT_RANGE
, 0, 1, NULL
},
1963 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1964 M_OPT_RANGE
, -100, 100, NULL
},
1965 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1967 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1969 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1971 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1973 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1975 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1976 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1977 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
1978 M_OPT_RANGE
, -1, 1, NULL
},
1981 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1982 M_OPT_RANGE
, 0, 1, NULL
},
1983 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1984 M_OPT_RANGE
, 0, 1, NULL
},
1985 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1986 M_OPT_RANGE
, 0, 1, NULL
},
1987 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1988 M_OPT_RANGE
, 0, 1, NULL
},
1989 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1990 M_OPT_RANGE
, 0, 1, NULL
},
1991 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1992 M_OPT_RANGE
, 0, 2, NULL
},
1993 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1994 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1995 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1996 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1997 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1998 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1999 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2000 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2001 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2002 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2003 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2004 M_OPT_RANGE
, 0, 1, NULL
},
2005 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2006 M_OPT_RANGE
, 0, 1, NULL
},
2007 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2009 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2011 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2013 { "width", mp_property_width
, CONF_TYPE_INT
,
2015 { "height", mp_property_height
, CONF_TYPE_INT
,
2017 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2019 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2021 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2022 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2023 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2024 CONF_RANGE
, -1, 65535, NULL
},
2027 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2028 M_OPT_MIN
, -1, 0, NULL
},
2029 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2030 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2031 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2032 M_OPT_MIN
, -1, 0, NULL
},
2033 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2034 M_OPT_MIN
, -1, 0, NULL
},
2035 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2036 M_OPT_MIN
, -1, 0, NULL
},
2037 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2039 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2040 M_OPT_RANGE
, 0, 100, NULL
},
2041 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2042 M_OPT_RANGE
, 0, 2, NULL
},
2043 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2044 M_OPT_RANGE
, 0, 1, NULL
},
2045 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2046 M_OPT_RANGE
, 0, 1, NULL
},
2047 #ifdef HAVE_FREETYPE
2048 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2049 M_OPT_RANGE
, 0, 100, NULL
},
2053 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2054 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2055 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2056 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2057 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2058 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2059 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2060 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2063 #ifdef HAVE_TV_TELETEXT
2064 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2065 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2066 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2067 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2068 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2069 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2070 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2071 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2072 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2073 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2076 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2080 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2082 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2085 char* mp_property_print(const char *name
, void* ctx
)
2088 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2093 char *property_expand_string(MPContext
* mpctx
, char *str
)
2095 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2098 void property_print_help(void)
2100 m_properties_print_help_list(mp_properties
);
2109 * \defgroup Command2Property Command to property bridge
2111 * It is used to handle most commands that just set a property
2112 * and optionally display something on the OSD.
2113 * Two kinds of commands are handled: adjust or toggle.
2115 * Adjust commands take 1 or 2 parameters: <value> <abs>
2116 * If <abs> is non-zero the property is set to the given value
2117 * otherwise it is adjusted.
2119 * Toggle commands take 0 or 1 parameters. With no parameter
2120 * or a value less than the property minimum it just steps the
2121 * property to its next value. Otherwise it sets it to the given
2127 /// List of the commands that can be handled by setting a property.
2133 /// set/adjust or toggle command
2135 /// progressbar type
2137 /// osd msg id if it must be shared
2139 /// osd msg template
2140 const char *osd_msg
;
2141 } set_prop_cmd
[] = {
2143 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2144 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2145 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2147 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2148 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2149 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2150 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2151 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2153 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2154 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2155 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2156 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2157 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2158 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2159 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2160 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2161 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2162 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2163 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2164 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2166 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2167 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2168 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2169 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2170 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2171 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2172 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2173 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2174 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2175 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2176 #ifdef HAVE_FREETYPE
2177 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2180 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2181 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2182 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2183 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2185 { NULL
, 0, 0, 0, -1, NULL
}
2189 /// Handle commands that set a property.
2190 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2196 // look for the command
2197 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2198 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2200 if (!(pname
= set_prop_cmd
[i
].name
))
2203 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2207 if (set_prop_cmd
[i
].toggle
) {
2209 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2210 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2212 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2213 } else if (cmd
->args
[1].v
.i
) //set
2214 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2216 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2221 if (set_prop_cmd
[i
].osd_progbar
) {
2222 if (prop
->type
== CONF_TYPE_INT
) {
2223 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2224 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2225 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2226 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2228 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2229 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2230 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2232 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2233 "Property use an unsupported type.\n");
2237 if (set_prop_cmd
[i
].osd_msg
) {
2238 char *val
= mp_property_print(pname
, mpctx
);
2240 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2241 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2242 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2250 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2252 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2253 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2255 if (!set_property_command(mpctx
, cmd
))
2261 mpctx
->osd_show_percentage
= sh_video
->fps
;
2262 v
= cmd
->args
[0].v
.f
;
2263 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2264 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2267 mpctx
->osd_function
=
2268 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2270 } else if (abs
) { /* Absolute seek by percentage */
2273 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2274 rel_seek_secs
= v
/ 100.0;
2277 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2283 case MP_CMD_SET_PROPERTY
:{
2284 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2285 cmd
->args
[1].v
.s
, mpctx
);
2286 if (r
== M_PROPERTY_UNKNOWN
)
2287 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2288 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2290 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2291 "Failed to set property '%s' to '%s'.\n",
2292 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2296 case MP_CMD_STEP_PROPERTY
:{
2301 if (cmd
->args
[1].v
.f
) {
2303 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2304 M_PROPERTY_GET_TYPE
,
2305 &prop
, mpctx
)) <= 0)
2307 if(prop
->type
== CONF_TYPE_INT
||
2308 prop
->type
== CONF_TYPE_FLAG
)
2309 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2310 else if(prop
->type
== CONF_TYPE_FLOAT
)
2311 arg
= &cmd
->args
[1].v
.f
;
2312 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2313 prop
->type
== CONF_TYPE_TIME
)
2314 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2315 else if(prop
->type
== CONF_TYPE_POSITION
)
2316 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2318 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2319 "Ignoring step size stepping property '%s'.\n",
2322 r
= mp_property_do(cmd
->args
[0].v
.s
,
2323 cmd
->args
[2].v
.i
< 0 ?
2324 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2327 if (r
== M_PROPERTY_UNKNOWN
)
2328 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2329 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2331 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2332 "Failed to increment property '%s' by %f.\n",
2333 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2337 case MP_CMD_GET_PROPERTY
:{
2339 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2340 &tmp
, mpctx
) <= 0) {
2341 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2342 "Failed to get value of property '%s'.\n",
2346 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2347 cmd
->args
[0].v
.s
, tmp
);
2352 case MP_CMD_EDL_MARK
:
2354 float v
= sh_video
? sh_video
->pts
:
2355 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2358 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2359 mpctx
->begin_skip
= v
;
2360 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2362 if (mpctx
->begin_skip
> v
)
2363 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2365 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2366 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2368 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2373 case MP_CMD_SWITCH_RATIO
:
2374 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2375 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2377 movie_aspect
= cmd
->args
[0].v
.f
;
2378 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2381 case MP_CMD_SPEED_INCR
:{
2382 float v
= cmd
->args
[0].v
.f
;
2383 playback_speed
+= v
;
2384 build_afilter_chain(sh_audio
, &ao_data
);
2385 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2389 case MP_CMD_SPEED_MULT
:{
2390 float v
= cmd
->args
[0].v
.f
;
2391 playback_speed
*= v
;
2392 build_afilter_chain(sh_audio
, &ao_data
);
2393 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2397 case MP_CMD_SPEED_SET
:{
2398 float v
= cmd
->args
[0].v
.f
;
2400 build_afilter_chain(sh_audio
, &ao_data
);
2401 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2405 case MP_CMD_FRAME_STEP
:
2411 case MP_CMD_FILE_FILTER
:
2412 file_filter
= cmd
->args
[0].v
.i
;
2416 exit_player_with_rc(MSGTR_Exit_quit
,
2417 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2419 case MP_CMD_PLAY_TREE_STEP
:{
2420 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2421 int force
= cmd
->args
[1].v
.i
;
2427 for (i
= 0; i
< n
; i
++)
2430 for (i
= 0; i
< -1 * n
; i
++)
2435 if (!force
&& mpctx
->playtree_iter
) {
2436 play_tree_iter_t
*i
=
2437 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2438 if (play_tree_iter_step(i
, n
, 0) ==
2439 PLAY_TREE_ITER_ENTRY
)
2441 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2442 play_tree_iter_free(i
);
2444 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2446 mpctx
->play_tree_step
= n
;
2452 case MP_CMD_PLAY_TREE_UP_STEP
:{
2453 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2454 int force
= cmd
->args
[1].v
.i
;
2456 if (!force
&& mpctx
->playtree_iter
) {
2457 play_tree_iter_t
*i
=
2458 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2459 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2460 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2461 play_tree_iter_free(i
);
2463 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2468 case MP_CMD_PLAY_ALT_SRC_STEP
:
2469 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2470 int v
= cmd
->args
[0].v
.i
;
2472 && mpctx
->playtree_iter
->file
<
2473 mpctx
->playtree_iter
->num_files
)
2474 mpctx
->eof
= PT_NEXT_SRC
;
2475 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2476 mpctx
->eof
= PT_PREV_SRC
;
2481 case MP_CMD_SUB_STEP
:
2483 int movement
= cmd
->args
[0].v
.i
;
2484 step_sub(subdata
, sh_video
->pts
, movement
);
2488 ass_step_sub(ass_track
,
2490 sub_delay
) * 1000 + .5, movement
) / 1000.;
2492 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2493 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2497 case MP_CMD_SUB_LOG
:
2502 int v
= cmd
->args
[0].v
.i
;
2504 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2505 if (osd_level
> max
)
2508 osd_level
= (osd_level
+ 1) % (max
+ 1);
2510 osd_level
= v
> max
? max
: v
;
2511 /* Show OSD state when disabled, but not when an explicit
2512 argument is given to the OSD command, i.e. in slave mode. */
2513 if (v
== -1 && osd_level
<= 1)
2514 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2516 osd_level
? MSGTR_OSDenabled
:
2519 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2523 case MP_CMD_OSD_SHOW_TEXT
:
2524 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2526 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2527 "%-.63s", cmd
->args
[0].v
.s
);
2530 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2531 char *txt
= m_properties_expand_string(mp_properties
,
2534 /* if no argument supplied take default osd_duration, else <arg> ms. */
2536 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2538 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2545 case MP_CMD_LOADFILE
:{
2546 play_tree_t
*e
= play_tree_new();
2547 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2549 if (cmd
->args
[1].v
.i
) // append
2550 play_tree_append_entry(mpctx
->playtree
, e
);
2552 // Go back to the starting point.
2553 while (play_tree_iter_up_step
2554 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2556 play_tree_free_list(mpctx
->playtree
->child
, 1);
2557 play_tree_set_child(mpctx
->playtree
, e
);
2558 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2559 mpctx
->eof
= PT_NEXT_SRC
;
2565 case MP_CMD_LOADLIST
:{
2566 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2568 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2569 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2571 if (cmd
->args
[1].v
.i
) // append
2572 play_tree_append_entry(mpctx
->playtree
, e
);
2574 // Go back to the starting point.
2575 while (play_tree_iter_up_step
2576 (mpctx
->playtree_iter
, 0, 1)
2577 != PLAY_TREE_ITER_END
)
2579 play_tree_free_list(mpctx
->playtree
->child
, 1);
2580 play_tree_set_child(mpctx
->playtree
, e
);
2581 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2582 mpctx
->eof
= PT_NEXT_SRC
;
2590 case MP_CMD_RADIO_STEP_CHANNEL
:
2591 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2592 int v
= cmd
->args
[0].v
.i
;
2594 radio_step_channel(mpctx
->demuxer
->stream
,
2595 RADIO_CHANNEL_HIGHER
);
2597 radio_step_channel(mpctx
->demuxer
->stream
,
2598 RADIO_CHANNEL_LOWER
);
2599 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2600 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2602 radio_get_channel_name(mpctx
->demuxer
->stream
));
2607 case MP_CMD_RADIO_SET_CHANNEL
:
2608 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2609 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2610 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2611 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2613 radio_get_channel_name(mpctx
->demuxer
->stream
));
2618 case MP_CMD_RADIO_SET_FREQ
:
2619 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2620 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2623 case MP_CMD_RADIO_STEP_FREQ
:
2624 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2625 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2630 case MP_CMD_TV_START_SCAN
:
2631 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2632 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2634 case MP_CMD_TV_SET_FREQ
:
2635 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2636 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2637 cmd
->args
[0].v
.f
* 16.0);
2639 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2640 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2641 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2642 pvr_get_current_channelname (mpctx
->stream
),
2643 pvr_get_current_stationname (mpctx
->stream
));
2645 #endif /* HAVE_PVR */
2648 case MP_CMD_TV_STEP_FREQ
:
2649 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2650 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2651 cmd
->args
[0].v
.f
* 16.0);
2653 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2654 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2655 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2656 pvr_get_current_channelname (mpctx
->stream
),
2657 pvr_get_current_frequency (mpctx
->stream
));
2659 #endif /* HAVE_PVR */
2662 case MP_CMD_TV_SET_NORM
:
2663 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2664 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2668 case MP_CMD_TV_STEP_CHANNEL
:{
2669 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2670 int v
= cmd
->args
[0].v
.i
;
2672 tv_step_channel((tvi_handle_t
*) (mpctx
->
2676 tv_step_channel((tvi_handle_t
*) (mpctx
->
2680 if (tv_channel_list
) {
2681 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2682 MSGTR_OSDChannel
, tv_channel_current
->name
);
2683 //vo_osd_changed(OSDTYPE_SUBTITLE);
2687 else if (mpctx
->stream
&&
2688 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2689 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2690 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2691 pvr_get_current_channelname (mpctx
->stream
),
2692 pvr_get_current_stationname (mpctx
->stream
));
2694 #endif /* HAVE_PVR */
2696 #ifdef HAS_DVBIN_SUPPORT
2697 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2699 int v
= cmd
->args
[0].v
.i
;
2701 mpctx
->last_dvb_step
= v
;
2703 dir
= DVB_CHANNEL_HIGHER
;
2705 dir
= DVB_CHANNEL_LOWER
;
2708 if (dvb_step_channel(mpctx
->stream
, dir
))
2709 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2711 #endif /* HAS_DVBIN_SUPPORT */
2714 case MP_CMD_TV_SET_CHANNEL
:
2715 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2716 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2718 if (tv_channel_list
) {
2719 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2720 MSGTR_OSDChannel
, tv_channel_current
->name
);
2721 //vo_osd_changed(OSDTYPE_SUBTITLE);
2725 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2726 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2727 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2728 pvr_get_current_channelname (mpctx
->stream
),
2729 pvr_get_current_stationname (mpctx
->stream
));
2731 #endif /* HAVE_PVR */
2734 #ifdef HAS_DVBIN_SUPPORT
2735 case MP_CMD_DVB_SET_CHANNEL
:
2736 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2737 mpctx
->last_dvb_step
= 1;
2740 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2741 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2744 #endif /* HAS_DVBIN_SUPPORT */
2746 case MP_CMD_TV_LAST_CHANNEL
:
2747 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2748 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2749 if (tv_channel_list
) {
2750 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2751 MSGTR_OSDChannel
, tv_channel_current
->name
);
2752 //vo_osd_changed(OSDTYPE_SUBTITLE);
2756 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2757 pvr_set_lastchannel (mpctx
->stream
);
2758 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2759 pvr_get_current_channelname (mpctx
->stream
),
2760 pvr_get_current_stationname (mpctx
->stream
));
2762 #endif /* HAVE_PVR */
2765 case MP_CMD_TV_STEP_NORM
:
2766 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2767 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2770 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2771 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2772 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2774 #ifdef HAVE_TV_TELETEXT
2775 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2777 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2778 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2779 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2782 case MP_CMD_TV_TELETEXT_GO_LINK
:
2784 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2785 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2786 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2789 #endif /* HAVE_TV_TELETEXT */
2792 case MP_CMD_SUB_LOAD
:
2794 int n
= mpctx
->set_of_sub_size
;
2795 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2796 if (n
!= mpctx
->set_of_sub_size
) {
2797 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2798 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2799 mpctx
->global_sub_size
;
2800 ++mpctx
->global_sub_size
;
2805 case MP_CMD_SUB_REMOVE
:
2807 int v
= cmd
->args
[0].v
.i
;
2810 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2811 subd
= mpctx
->set_of_subtitles
[v
];
2812 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2813 MSGTR_RemovedSubtitleFile
, v
+ 1,
2814 filename_recode(subd
->filename
));
2816 mpctx
->set_of_subtitles
[v
] = NULL
;
2818 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2819 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2820 mpctx
->set_of_sub_size
= 0;
2821 if (mpctx
->set_of_sub_pos
>= 0) {
2822 mpctx
->global_sub_pos
= -2;
2824 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2826 } else if (v
< mpctx
->set_of_sub_size
) {
2827 subd
= mpctx
->set_of_subtitles
[v
];
2828 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2829 MSGTR_RemovedSubtitleFile
, v
+ 1,
2830 filename_recode(subd
->filename
));
2832 if (mpctx
->set_of_sub_pos
== v
) {
2833 mpctx
->global_sub_pos
= -2;
2835 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2836 } else if (mpctx
->set_of_sub_pos
> v
) {
2837 --mpctx
->set_of_sub_pos
;
2838 --mpctx
->global_sub_pos
;
2840 while (++v
< mpctx
->set_of_sub_size
)
2841 mpctx
->set_of_subtitles
[v
- 1] =
2842 mpctx
->set_of_subtitles
[v
];
2843 --mpctx
->set_of_sub_size
;
2844 --mpctx
->global_sub_size
;
2845 if (mpctx
->set_of_sub_size
<= 0)
2846 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2847 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2852 case MP_CMD_GET_SUB_VISIBILITY
:
2854 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2855 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2859 case MP_CMD_SCREENSHOT
:
2860 if (vo_config_count
) {
2861 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2863 ((vf_instance_t
*) sh_video
->vfilter
)->
2864 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2866 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2870 case MP_CMD_VF_CHANGE_RECTANGLE
:
2871 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2874 case MP_CMD_GET_TIME_LENGTH
:{
2875 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2876 demuxer_get_time_length(mpctx
->demuxer
));
2880 case MP_CMD_GET_FILENAME
:{
2881 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2882 get_metadata(META_NAME
));
2886 case MP_CMD_GET_VIDEO_CODEC
:{
2887 char *inf
= get_metadata(META_VIDEO_CODEC
);
2890 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2895 case MP_CMD_GET_VIDEO_BITRATE
:{
2896 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2899 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2904 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2905 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2908 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2909 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2914 case MP_CMD_GET_AUDIO_CODEC
:{
2915 char *inf
= get_metadata(META_AUDIO_CODEC
);
2918 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2923 case MP_CMD_GET_AUDIO_BITRATE
:{
2924 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2927 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2932 case MP_CMD_GET_AUDIO_SAMPLES
:{
2933 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2936 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2941 case MP_CMD_GET_META_TITLE
:{
2942 char *inf
= get_metadata(META_INFO_TITLE
);
2945 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2950 case MP_CMD_GET_META_ARTIST
:{
2951 char *inf
= get_metadata(META_INFO_ARTIST
);
2954 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2959 case MP_CMD_GET_META_ALBUM
:{
2960 char *inf
= get_metadata(META_INFO_ALBUM
);
2963 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2968 case MP_CMD_GET_META_YEAR
:{
2969 char *inf
= get_metadata(META_INFO_YEAR
);
2972 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2977 case MP_CMD_GET_META_COMMENT
:{
2978 char *inf
= get_metadata(META_INFO_COMMENT
);
2981 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2986 case MP_CMD_GET_META_TRACK
:{
2987 char *inf
= get_metadata(META_INFO_TRACK
);
2990 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2995 case MP_CMD_GET_META_GENRE
:{
2996 char *inf
= get_metadata(META_INFO_GENRE
);
2999 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3004 case MP_CMD_GET_VO_FULLSCREEN
:
3005 if (mpctx
->video_out
&& vo_config_count
)
3006 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3009 case MP_CMD_GET_PERCENT_POS
:
3010 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3011 demuxer_get_percent_pos(mpctx
->demuxer
));
3014 case MP_CMD_GET_TIME_POS
:{
3017 pos
= sh_video
->pts
;
3018 else if (sh_audio
&& mpctx
->audio_out
)
3020 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3022 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3029 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3035 case MP_CMD_KEYDOWN_EVENTS
:
3036 mplayer_put_key(cmd
->args
[0].v
.i
);
3039 case MP_CMD_SET_MOUSE_POS
:{
3040 int pointer_x
, pointer_y
;
3042 pointer_x
= cmd
->args
[0].v
.i
;
3043 pointer_y
= cmd
->args
[1].v
.i
;
3044 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3046 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3047 && dx
> 0.0 && dy
> 0.0) {
3049 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3050 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3051 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3052 pointer_x
, pointer_y
, &button
);
3054 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3055 "Selected button number %d", button
);
3059 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3060 menu_update_mouse_pos(dx
, dy
);
3066 case MP_CMD_DVDNAV
:{
3068 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3071 if (mp_dvdnav_handle_input
3072 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
3073 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
3074 (fixed_vo
? INITED_VO
: 0)));
3076 } else if (button
> 0)
3077 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3078 "Selected button number %d", button
);
3085 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3086 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3089 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3090 "Received unknown cmd %s\n", cmd
->name
);
3093 switch (cmd
->pausing
) {
3094 case 1: // "pausing"
3095 mpctx
->osd_function
= OSD_PAUSE
;
3097 case 3: // "pausing_toggle"
3098 mpctx
->was_paused
= !mpctx
->was_paused
;
3099 if (mpctx
->was_paused
)
3100 mpctx
->osd_function
= OSD_PAUSE
;
3101 else if (mpctx
->osd_function
== OSD_PAUSE
)
3102 mpctx
->osd_function
= OSD_PLAY
;
3104 case 2: // "pausing_keep"
3105 if (mpctx
->was_paused
)
3106 mpctx
->osd_function
= OSD_PAUSE
;