8 #include "input/input.h"
9 #include "stream/stream.h"
10 #include "libmpdemux/demuxer.h"
11 #include "libmpdemux/stheader.h"
12 #include "codec-cfg.h"
14 #include "libvo/sub.h"
16 #include "m_property.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 "libmpcodecs/dec_video.h"
32 #include "stream/tv.h"
35 #include "stream/stream_radio.h"
38 #include "stream/pvr.h"
41 #include "stream/dvbin.h"
44 #include "stream/stream_dvd.h"
47 #include "stream/stream_dvdnav.h"
50 #include "libass/ass.h"
51 #include "libass/ass_mp.h"
55 #include "libmenu/menu.h"
58 #include "gui/interface.h"
63 #include "libavutil/avstring.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
));
347 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
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
);
362 abs_seek_pos
= SEEK_ABSOLUTE
;
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
;
389 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
391 return M_PROPERTY_UNAVAILABLE
;
396 return M_PROPERTY_ERROR
;
397 *(int *) arg
= chapter
;
398 return M_PROPERTY_OK
;
399 case M_PROPERTY_PRINT
: {
401 return M_PROPERTY_ERROR
;
402 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
404 return M_PROPERTY_UNAVAILABLE
;
405 *(char **) arg
= chapter_name
;
406 return M_PROPERTY_OK
;
410 return M_PROPERTY_ERROR
;
411 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
412 step_all
= *(int *)arg
- (chapter
+ 1);
415 case M_PROPERTY_STEP_UP
:
416 case M_PROPERTY_STEP_DOWN
: {
417 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
418 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
425 return M_PROPERTY_NOT_IMPLEMENTED
;
429 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
430 &next_pts
, &chapter_num
, &chapter_name
);
432 if (next_pts
> -1.0) {
433 abs_seek_pos
= SEEK_ABSOLUTE
;
434 rel_seek_secs
= next_pts
;
437 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
438 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
440 else if (step_all
> 0)
441 rel_seek_secs
= 1000000000.;
443 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
444 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
447 return M_PROPERTY_OK
;
450 /// Number of chapters in file
451 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
455 return M_PROPERTY_UNAVAILABLE
;
456 if (mpctx
->demuxer
->num_chapters
== 0)
457 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
458 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
461 /// Current dvd angle (RW)
462 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
467 char *angle_name
= NULL
;
470 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
472 return M_PROPERTY_UNAVAILABLE
;
473 angles
= demuxer_angles_count(mpctx
->demuxer
);
475 return M_PROPERTY_UNAVAILABLE
;
480 return M_PROPERTY_ERROR
;
481 *(int *) arg
= angle
;
482 return M_PROPERTY_OK
;
483 case M_PROPERTY_PRINT
: {
485 return M_PROPERTY_ERROR
;
486 angle_name
= calloc(1, 64);
488 return M_PROPERTY_UNAVAILABLE
;
489 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
490 *(char **) arg
= angle_name
;
491 return M_PROPERTY_OK
;
495 return M_PROPERTY_ERROR
;
497 M_PROPERTY_CLAMP(prop
, angle
);
499 case M_PROPERTY_STEP_UP
:
500 case M_PROPERTY_STEP_DOWN
: {
506 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
508 if (angle
< 1) //cycle
513 return M_PROPERTY_NOT_IMPLEMENTED
;
515 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
516 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
517 MSGTR_OSDAngle
, angle
, angles
);
520 return M_PROPERTY_OK
;
523 /// Demuxer meta data
524 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
526 m_property_action_t
* ka
;
528 static m_option_t key_type
=
529 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
531 return M_PROPERTY_UNAVAILABLE
;
535 if(!arg
) return M_PROPERTY_ERROR
;
536 *(char***)arg
= mpctx
->demuxer
->info
;
537 return M_PROPERTY_OK
;
538 case M_PROPERTY_KEY_ACTION
:
539 if(!arg
) return M_PROPERTY_ERROR
;
541 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
542 return M_PROPERTY_UNKNOWN
;
545 if(!ka
->arg
) return M_PROPERTY_ERROR
;
546 *(char**)ka
->arg
= meta
;
547 return M_PROPERTY_OK
;
548 case M_PROPERTY_GET_TYPE
:
549 if(!ka
->arg
) return M_PROPERTY_ERROR
;
550 *(m_option_t
**)ka
->arg
= &key_type
;
551 return M_PROPERTY_OK
;
554 return M_PROPERTY_NOT_IMPLEMENTED
;
557 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
560 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
566 /// \defgroup AudioProperties Audio properties
567 /// \ingroup Properties
571 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
575 if (!mpctx
->sh_audio
)
576 return M_PROPERTY_UNAVAILABLE
;
581 return M_PROPERTY_ERROR
;
582 mixer_getbothvolume(&mpctx
->mixer
, arg
);
583 return M_PROPERTY_OK
;
584 case M_PROPERTY_PRINT
:{
587 return M_PROPERTY_ERROR
;
588 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
589 return m_property_float_range(prop
, action
, arg
, &vol
);
591 case M_PROPERTY_STEP_UP
:
592 case M_PROPERTY_STEP_DOWN
:
596 return M_PROPERTY_NOT_IMPLEMENTED
;
599 if (mpctx
->edl_muted
)
600 return M_PROPERTY_DISABLED
;
601 mpctx
->user_muted
= 0;
606 return M_PROPERTY_ERROR
;
607 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
608 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
609 return M_PROPERTY_OK
;
610 case M_PROPERTY_STEP_UP
:
611 if (arg
&& *(float *) arg
<= 0)
612 mixer_decvolume(&mpctx
->mixer
);
614 mixer_incvolume(&mpctx
->mixer
);
615 return M_PROPERTY_OK
;
616 case M_PROPERTY_STEP_DOWN
:
617 if (arg
&& *(float *) arg
<= 0)
618 mixer_incvolume(&mpctx
->mixer
);
620 mixer_decvolume(&mpctx
->mixer
);
621 return M_PROPERTY_OK
;
623 return M_PROPERTY_NOT_IMPLEMENTED
;
627 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
631 if (!mpctx
->sh_audio
)
632 return M_PROPERTY_UNAVAILABLE
;
636 if (mpctx
->edl_muted
)
637 return M_PROPERTY_DISABLED
;
639 return M_PROPERTY_ERROR
;
640 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
641 mixer_mute(&mpctx
->mixer
);
642 mpctx
->user_muted
= mpctx
->mixer
.muted
;
643 return M_PROPERTY_OK
;
644 case M_PROPERTY_STEP_UP
:
645 case M_PROPERTY_STEP_DOWN
:
646 if (mpctx
->edl_muted
)
647 return M_PROPERTY_DISABLED
;
648 mixer_mute(&mpctx
->mixer
);
649 mpctx
->user_muted
= mpctx
->mixer
.muted
;
650 return M_PROPERTY_OK
;
651 case M_PROPERTY_PRINT
:
653 return M_PROPERTY_ERROR
;
654 if (mpctx
->edl_muted
) {
655 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
656 return M_PROPERTY_OK
;
659 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
665 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
666 void *arg
, MPContext
* mpctx
)
668 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
669 return M_PROPERTY_UNAVAILABLE
;
672 case M_PROPERTY_STEP_UP
:
673 case M_PROPERTY_STEP_DOWN
: {
675 float delay
= audio_delay
;
676 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
677 if (ret
!= M_PROPERTY_OK
)
680 mpctx
->delay
-= audio_delay
- delay
;
682 return M_PROPERTY_OK
;
684 return m_property_delay(prop
, action
, arg
, &audio_delay
);
688 /// Audio codec tag (RO)
689 static int mp_property_audio_format(m_option_t
* prop
, int action
,
690 void *arg
, MPContext
* mpctx
)
692 if (!mpctx
->sh_audio
)
693 return M_PROPERTY_UNAVAILABLE
;
694 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
697 /// Audio codec name (RO)
698 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
699 void *arg
, MPContext
* mpctx
)
701 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
702 return M_PROPERTY_UNAVAILABLE
;
703 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
706 /// Audio bitrate (RO)
707 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
708 void *arg
, MPContext
* mpctx
)
710 if (!mpctx
->sh_audio
)
711 return M_PROPERTY_UNAVAILABLE
;
712 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
716 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
719 if (!mpctx
->sh_audio
)
720 return M_PROPERTY_UNAVAILABLE
;
722 case M_PROPERTY_PRINT
:
723 if(!arg
) return M_PROPERTY_ERROR
;
724 *(char**)arg
= malloc(16);
725 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
726 return M_PROPERTY_OK
;
728 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
731 /// Number of channels (RO)
732 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
735 if (!mpctx
->sh_audio
)
736 return M_PROPERTY_UNAVAILABLE
;
738 case M_PROPERTY_PRINT
:
740 return M_PROPERTY_ERROR
;
741 switch (mpctx
->sh_audio
->channels
) {
743 *(char **) arg
= strdup("mono");
746 *(char **) arg
= strdup("stereo");
749 *(char **) arg
= malloc(32);
750 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
752 return M_PROPERTY_OK
;
754 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
758 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
763 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
764 return M_PROPERTY_UNAVAILABLE
;
769 return M_PROPERTY_ERROR
;
770 mixer_getbalance(&mpctx
->mixer
, arg
);
771 return M_PROPERTY_OK
;
772 case M_PROPERTY_PRINT
: {
775 return M_PROPERTY_ERROR
;
776 mixer_getbalance(&mpctx
->mixer
, &bal
);
778 *str
= strdup("center");
779 else if (bal
== -1.f
)
780 *str
= strdup("left only");
782 *str
= strdup("right only");
784 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
785 *str
= malloc(sizeof("left xxx%, right xxx%"));
786 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
788 return M_PROPERTY_OK
;
790 case M_PROPERTY_STEP_UP
:
791 case M_PROPERTY_STEP_DOWN
:
792 mixer_getbalance(&mpctx
->mixer
, &bal
);
793 bal
+= (arg
? *(float*)arg
: .1f
) *
794 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
795 M_PROPERTY_CLAMP(prop
, bal
);
796 mixer_setbalance(&mpctx
->mixer
, bal
);
797 return M_PROPERTY_OK
;
800 return M_PROPERTY_ERROR
;
801 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
802 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
803 return M_PROPERTY_OK
;
805 return M_PROPERTY_NOT_IMPLEMENTED
;
808 /// Selected audio id (RW)
809 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
812 int current_id
= -1, tmp
;
816 if (!mpctx
->sh_audio
)
817 return M_PROPERTY_UNAVAILABLE
;
819 return M_PROPERTY_ERROR
;
820 *(int *) arg
= audio_id
;
821 return M_PROPERTY_OK
;
822 case M_PROPERTY_PRINT
:
823 if (!mpctx
->sh_audio
)
824 return M_PROPERTY_UNAVAILABLE
;
826 return M_PROPERTY_ERROR
;
829 *(char **) arg
= strdup(MSGTR_Disabled
);
831 char lang
[40] = MSGTR_Unknown
;
832 sh_audio_t
* sh
= mpctx
->sh_audio
;
834 av_strlcpy(lang
, sh
->lang
, 40);
835 #ifdef CONFIG_DVDREAD
836 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
837 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
847 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
848 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
850 *(char **) arg
= malloc(64);
851 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
853 return M_PROPERTY_OK
;
855 case M_PROPERTY_STEP_UP
:
858 return M_PROPERTY_UNAVAILABLE
;
859 if (action
== M_PROPERTY_SET
&& arg
)
860 tmp
= *((int *) arg
);
863 current_id
= mpctx
->demuxer
->audio
->id
;
864 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
867 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
868 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
869 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
871 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
873 sh2
->ds
= mpctx
->demuxer
->audio
;
874 mpctx
->sh_audio
= sh2
;
875 reinit_audio_chain();
878 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
879 return M_PROPERTY_OK
;
881 return M_PROPERTY_NOT_IMPLEMENTED
;
886 /// Selected video id (RW)
887 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
890 int current_id
= -1, tmp
;
894 if (!mpctx
->sh_video
)
895 return M_PROPERTY_UNAVAILABLE
;
897 return M_PROPERTY_ERROR
;
898 *(int *) arg
= video_id
;
899 return M_PROPERTY_OK
;
900 case M_PROPERTY_PRINT
:
901 if (!mpctx
->sh_video
)
902 return M_PROPERTY_UNAVAILABLE
;
904 return M_PROPERTY_ERROR
;
907 *(char **) arg
= strdup(MSGTR_Disabled
);
909 char lang
[40] = MSGTR_Unknown
;
910 *(char **) arg
= malloc(64);
911 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
913 return M_PROPERTY_OK
;
915 case M_PROPERTY_STEP_UP
:
917 current_id
= mpctx
->demuxer
->video
->id
;
918 if (action
== M_PROPERTY_SET
&& arg
)
919 tmp
= *((int *) arg
);
922 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
924 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
925 && current_id
!= -2))
926 uninit_player(INITIALIZED_VCODEC
|
927 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
928 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
930 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
932 sh2
->ds
= mpctx
->demuxer
->video
;
933 mpctx
->sh_video
= sh2
;
934 reinit_video_chain();
937 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
938 return M_PROPERTY_OK
;
941 return M_PROPERTY_NOT_IMPLEMENTED
;
945 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
948 demux_program_t prog
;
951 case M_PROPERTY_STEP_UP
:
953 if (action
== M_PROPERTY_SET
&& arg
)
954 prog
.progid
= *((int *) arg
);
958 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
959 &prog
) == DEMUXER_CTRL_NOTIMPL
)
960 return M_PROPERTY_ERROR
;
962 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
963 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
964 return M_PROPERTY_OK
;
967 return M_PROPERTY_NOT_IMPLEMENTED
;
973 /// \defgroup VideoProperties Video properties
974 /// \ingroup Properties
977 /// Fullscreen state (RW)
978 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
982 if (!mpctx
->video_out
)
983 return M_PROPERTY_UNAVAILABLE
;
988 return M_PROPERTY_ERROR
;
989 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
990 if (vo_fs
== !!*(int *) arg
)
991 return M_PROPERTY_OK
;
992 case M_PROPERTY_STEP_UP
:
993 case M_PROPERTY_STEP_DOWN
:
996 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
1000 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
1001 return M_PROPERTY_OK
;
1003 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1007 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
1008 void *arg
, MPContext
* mpctx
)
1012 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1013 return M_PROPERTY_UNAVAILABLE
;
1014 vf
= mpctx
->sh_video
->vfilter
;
1016 case M_PROPERTY_GET
:
1018 return M_PROPERTY_ERROR
;
1019 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1020 return M_PROPERTY_OK
;
1021 case M_PROPERTY_SET
:
1023 return M_PROPERTY_ERROR
;
1024 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1025 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1026 return M_PROPERTY_OK
;
1027 case M_PROPERTY_STEP_UP
:
1028 case M_PROPERTY_STEP_DOWN
:
1029 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1030 deinterlace
= !deinterlace
;
1031 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1032 return M_PROPERTY_OK
;
1034 return M_PROPERTY_NOT_IMPLEMENTED
;
1038 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1042 if (!mpctx
->video_out
1043 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1044 return M_PROPERTY_UNAVAILABLE
;
1047 case M_PROPERTY_SET
:
1049 return M_PROPERTY_ERROR
;
1050 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1051 vo_panscan
= *(float *) arg
;
1052 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1053 return M_PROPERTY_OK
;
1054 case M_PROPERTY_STEP_UP
:
1055 case M_PROPERTY_STEP_DOWN
:
1056 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1057 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1060 else if (vo_panscan
< 0)
1062 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1063 return M_PROPERTY_OK
;
1065 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1069 /// Helper to set vo flags.
1070 /** \ingroup PropertyImplHelper
1072 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1073 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1076 if (!mpctx
->video_out
)
1077 return M_PROPERTY_UNAVAILABLE
;
1080 case M_PROPERTY_SET
:
1082 return M_PROPERTY_ERROR
;
1083 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1084 if (*vo_var
== !!*(int *) arg
)
1085 return M_PROPERTY_OK
;
1086 case M_PROPERTY_STEP_UP
:
1087 case M_PROPERTY_STEP_DOWN
:
1088 if (vo_config_count
)
1089 mpctx
->video_out
->control(vo_ctrl
, 0);
1090 return M_PROPERTY_OK
;
1092 return m_property_flag(prop
, action
, arg
, vo_var
);
1096 /// Window always on top (RW)
1097 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1100 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1104 /// Display in the root window (RW)
1105 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1108 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1109 &vo_rootwin
, mpctx
);
1112 /// Show window borders (RW)
1113 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1116 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1120 /// Framedropping state (RW)
1121 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1122 void *arg
, MPContext
* mpctx
)
1125 if (!mpctx
->sh_video
)
1126 return M_PROPERTY_UNAVAILABLE
;
1129 case M_PROPERTY_PRINT
:
1131 return M_PROPERTY_ERROR
;
1132 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1133 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1135 return M_PROPERTY_OK
;
1137 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1141 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1142 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1145 int *gamma
= prop
->priv
, r
, val
;
1147 if (!mpctx
->sh_video
)
1148 return M_PROPERTY_UNAVAILABLE
;
1150 if (gamma
[0] == 1000) {
1152 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1156 case M_PROPERTY_SET
:
1158 return M_PROPERTY_ERROR
;
1159 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1160 *gamma
= *(int *) arg
;
1161 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1165 case M_PROPERTY_GET
:
1166 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1168 return M_PROPERTY_ERROR
;
1170 return M_PROPERTY_OK
;
1173 case M_PROPERTY_STEP_UP
:
1174 case M_PROPERTY_STEP_DOWN
:
1175 *gamma
+= (arg
? *(int *) arg
: 1) *
1176 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1177 M_PROPERTY_CLAMP(prop
, *gamma
);
1178 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1183 return M_PROPERTY_NOT_IMPLEMENTED
;
1187 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1188 int l
= strlen(prop
->name
);
1189 char tv_prop
[3 + l
+ 1];
1190 sprintf(tv_prop
, "tv_%s", prop
->name
);
1191 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1195 return M_PROPERTY_UNAVAILABLE
;
1199 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1202 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1205 /// Video codec tag (RO)
1206 static int mp_property_video_format(m_option_t
* prop
, int action
,
1207 void *arg
, MPContext
* mpctx
)
1210 if (!mpctx
->sh_video
)
1211 return M_PROPERTY_UNAVAILABLE
;
1213 case M_PROPERTY_PRINT
:
1215 return M_PROPERTY_ERROR
;
1216 switch(mpctx
->sh_video
->format
) {
1218 meta
= strdup ("mpeg1"); break;
1220 meta
= strdup ("mpeg2"); break;
1222 meta
= strdup ("mpeg4"); break;
1224 meta
= strdup ("h264"); break;
1226 if(mpctx
->sh_video
->format
>= 0x20202020) {
1228 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1231 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1234 *(char**)arg
= meta
;
1235 return M_PROPERTY_OK
;
1237 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1240 /// Video codec name (RO)
1241 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1242 void *arg
, MPContext
* mpctx
)
1244 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1245 return M_PROPERTY_UNAVAILABLE
;
1246 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1250 /// Video bitrate (RO)
1251 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1252 void *arg
, MPContext
* mpctx
)
1254 if (!mpctx
->sh_video
)
1255 return M_PROPERTY_UNAVAILABLE
;
1256 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1259 /// Video display width (RO)
1260 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1263 if (!mpctx
->sh_video
)
1264 return M_PROPERTY_UNAVAILABLE
;
1265 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1268 /// Video display height (RO)
1269 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1272 if (!mpctx
->sh_video
)
1273 return M_PROPERTY_UNAVAILABLE
;
1274 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1278 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1281 if (!mpctx
->sh_video
)
1282 return M_PROPERTY_UNAVAILABLE
;
1283 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1286 /// Video aspect (RO)
1287 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1290 if (!mpctx
->sh_video
)
1291 return M_PROPERTY_UNAVAILABLE
;
1292 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1297 /// \defgroup SubProprties Subtitles properties
1298 /// \ingroup Properties
1301 /// Text subtitle position (RW)
1302 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1305 if (!mpctx
->sh_video
)
1306 return M_PROPERTY_UNAVAILABLE
;
1309 case M_PROPERTY_SET
:
1311 return M_PROPERTY_ERROR
;
1312 case M_PROPERTY_STEP_UP
:
1313 case M_PROPERTY_STEP_DOWN
:
1314 vo_osd_changed(OSDTYPE_SUBTITLE
);
1316 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1320 /// Selected subtitles (RW)
1321 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1324 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1325 const int global_sub_size
= mpctx
->global_sub_size
;
1326 int source
= -1, reset_spu
= 0;
1329 if (global_sub_size
<= 0)
1330 return M_PROPERTY_UNAVAILABLE
;
1333 case M_PROPERTY_GET
:
1335 return M_PROPERTY_ERROR
;
1336 *(int *) arg
= mpctx
->global_sub_pos
;
1337 return M_PROPERTY_OK
;
1338 case M_PROPERTY_PRINT
:
1340 return M_PROPERTY_ERROR
;
1341 *(char **) arg
= malloc(64);
1342 (*(char **) arg
)[63] = 0;
1345 sub_name
= subdata
->filename
;
1347 if (ass_track
&& ass_track
->name
)
1348 sub_name
= ass_track
->name
;
1353 if ((tmp2
= strrchr(tmp
, '/')))
1356 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1357 mpctx
->set_of_sub_pos
+ 1,
1358 strlen(tmp
) < 20 ? "" : "...",
1359 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1360 return M_PROPERTY_OK
;
1362 #ifdef CONFIG_DVDNAV
1363 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1364 if (vo_spudec
&& dvdsub_id
>= 0) {
1365 unsigned char lang
[3];
1366 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1367 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1368 return M_PROPERTY_OK
;
1374 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1375 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1376 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1377 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1378 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1379 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1380 if (!lang
) lang
= MSGTR_Unknown
;
1381 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1382 return M_PROPERTY_OK
;
1385 if (vo_vobsub
&& vobsub_id
>= 0) {
1386 const char *language
= MSGTR_Unknown
;
1387 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1388 snprintf(*(char **) arg
, 63, "(%d) %s",
1389 vobsub_id
, language
? language
: MSGTR_Unknown
);
1390 return M_PROPERTY_OK
;
1392 #ifdef CONFIG_DVDREAD
1393 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1394 && dvdsub_id
>= 0) {
1396 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1397 lang
[0] = code
>> 8;
1400 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1401 return M_PROPERTY_OK
;
1404 if (dvdsub_id
>= 0) {
1405 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1406 return M_PROPERTY_OK
;
1408 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1409 return M_PROPERTY_OK
;
1411 case M_PROPERTY_SET
:
1413 return M_PROPERTY_ERROR
;
1414 if (*(int *) arg
< -1)
1416 else if (*(int *) arg
>= global_sub_size
)
1417 *(int *) arg
= global_sub_size
- 1;
1418 mpctx
->global_sub_pos
= *(int *) arg
;
1420 case M_PROPERTY_STEP_UP
:
1421 mpctx
->global_sub_pos
+= 2;
1422 mpctx
->global_sub_pos
=
1423 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1425 case M_PROPERTY_STEP_DOWN
:
1426 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1427 mpctx
->global_sub_pos
=
1428 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1431 return M_PROPERTY_NOT_IMPLEMENTED
;
1434 if (mpctx
->global_sub_pos
>= 0)
1435 source
= sub_source(mpctx
);
1437 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1438 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1440 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1441 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1442 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1443 mpctx
->global_sub_pos
, source
);
1445 mpctx
->set_of_sub_pos
= -1;
1459 if (source
== SUB_SOURCE_VOBSUB
) {
1460 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1461 } else if (source
== SUB_SOURCE_SUBS
) {
1462 mpctx
->set_of_sub_pos
=
1463 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1465 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1466 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1470 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1471 vo_osd_changed(OSDTYPE_SUBTITLE
);
1473 } else if (source
== SUB_SOURCE_DEMUX
) {
1475 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1476 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1478 // default: assume 1:1 mapping of sid and stream id
1479 d_sub
->id
= dvdsub_id
;
1480 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1481 ds_free_packs(d_sub
);
1482 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1483 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1484 if (sh
&& sh
->sid
== dvdsub_id
) {
1490 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1491 sh_sub_t
*sh
= d_sub
->sh
;
1492 if (sh
->type
== 'v')
1495 else if (ass_enabled
)
1496 ass_track
= sh
->ass_track
;
1504 #ifdef CONFIG_DVDREAD
1506 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1507 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1508 && dvdsub_id
< 0 && reset_spu
) {
1510 d_sub
->id
= dvdsub_id
;
1513 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1515 return M_PROPERTY_OK
;
1518 /// Selected sub source (RW)
1519 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1523 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1524 return M_PROPERTY_UNAVAILABLE
;
1527 case M_PROPERTY_GET
:
1529 return M_PROPERTY_ERROR
;
1530 *(int *) arg
= sub_source(mpctx
);
1531 return M_PROPERTY_OK
;
1532 case M_PROPERTY_PRINT
:
1534 return M_PROPERTY_ERROR
;
1535 *(char **) arg
= malloc(64);
1536 (*(char **) arg
)[63] = 0;
1537 switch (sub_source(mpctx
))
1539 case SUB_SOURCE_SUBS
:
1540 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1542 case SUB_SOURCE_VOBSUB
:
1543 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1545 case SUB_SOURCE_DEMUX
:
1546 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1549 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1551 return M_PROPERTY_OK
;
1552 case M_PROPERTY_SET
:
1554 return M_PROPERTY_ERROR
;
1555 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1556 if (*(int *) arg
< 0)
1557 mpctx
->global_sub_pos
= -1;
1558 else if (*(int *) arg
!= sub_source(mpctx
)) {
1559 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1560 return M_PROPERTY_UNAVAILABLE
;
1561 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1564 case M_PROPERTY_STEP_UP
:
1565 case M_PROPERTY_STEP_DOWN
: {
1566 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1567 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1568 int step
= (step_all
> 0) ? 1 : -1;
1569 int cur_source
= sub_source(mpctx
);
1570 source
= cur_source
;
1573 if (source
>= SUB_SOURCES
)
1575 else if (source
< -1)
1576 source
= SUB_SOURCES
- 1;
1577 if (source
== cur_source
|| source
== -1 ||
1578 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1581 if (source
== cur_source
)
1582 return M_PROPERTY_OK
;
1584 mpctx
->global_sub_pos
= -1;
1586 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1590 return M_PROPERTY_NOT_IMPLEMENTED
;
1592 --mpctx
->global_sub_pos
;
1593 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1596 /// Selected subtitles from specific source (RW)
1597 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1600 int source
, is_cur_source
, offset
;
1601 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1602 return M_PROPERTY_UNAVAILABLE
;
1604 if (!strcmp(prop
->name
, "sub_file"))
1605 source
= SUB_SOURCE_SUBS
;
1606 else if (!strcmp(prop
->name
, "sub_vob"))
1607 source
= SUB_SOURCE_VOBSUB
;
1608 else if (!strcmp(prop
->name
, "sub_demux"))
1609 source
= SUB_SOURCE_DEMUX
;
1611 return M_PROPERTY_ERROR
;
1613 offset
= mpctx
->global_sub_indices
[source
];
1614 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1615 return M_PROPERTY_UNAVAILABLE
;
1617 is_cur_source
= sub_source(mpctx
) == source
;
1619 case M_PROPERTY_GET
:
1621 return M_PROPERTY_ERROR
;
1622 if (is_cur_source
) {
1623 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1624 if (source
== SUB_SOURCE_VOBSUB
)
1625 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1629 return M_PROPERTY_OK
;
1630 case M_PROPERTY_PRINT
:
1632 return M_PROPERTY_ERROR
;
1634 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1635 *(char **) arg
= malloc(64);
1636 (*(char **) arg
)[63] = 0;
1637 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1638 return M_PROPERTY_OK
;
1639 case M_PROPERTY_SET
:
1641 return M_PROPERTY_ERROR
;
1642 if (*(int *) arg
>= 0) {
1643 int index
= *(int *)arg
;
1644 if (source
== SUB_SOURCE_VOBSUB
)
1645 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1646 mpctx
->global_sub_pos
= offset
+ index
;
1647 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1648 || sub_source(mpctx
) != source
) {
1649 mpctx
->global_sub_pos
= -1;
1654 mpctx
->global_sub_pos
= -1;
1656 case M_PROPERTY_STEP_UP
:
1657 case M_PROPERTY_STEP_DOWN
: {
1658 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1659 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1660 int step
= (step_all
> 0) ? 1 : -1;
1661 int max_sub_pos_for_source
= -1;
1663 mpctx
->global_sub_pos
= -1;
1665 if (mpctx
->global_sub_pos
== -1) {
1667 mpctx
->global_sub_pos
= offset
;
1668 else if (max_sub_pos_for_source
== -1) {
1669 // Find max pos for specific source
1670 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1671 while (mpctx
->global_sub_pos
>= 0
1672 && sub_source(mpctx
) != source
)
1673 --mpctx
->global_sub_pos
;
1676 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1679 mpctx
->global_sub_pos
+= step
;
1680 if (mpctx
->global_sub_pos
< offset
||
1681 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1682 sub_source(mpctx
) != source
)
1683 mpctx
->global_sub_pos
= -1;
1690 return M_PROPERTY_NOT_IMPLEMENTED
;
1692 --mpctx
->global_sub_pos
;
1693 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1696 /// Subtitle delay (RW)
1697 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1700 if (!mpctx
->sh_video
)
1701 return M_PROPERTY_UNAVAILABLE
;
1702 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1705 /// Alignment of text subtitles (RW)
1706 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1707 void *arg
, MPContext
* mpctx
)
1709 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1711 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1712 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1713 return M_PROPERTY_UNAVAILABLE
;
1716 case M_PROPERTY_PRINT
:
1718 return M_PROPERTY_ERROR
;
1719 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1720 *(char **) arg
= strdup(name
[sub_alignment
]);
1721 return M_PROPERTY_OK
;
1722 case M_PROPERTY_SET
:
1724 return M_PROPERTY_ERROR
;
1725 case M_PROPERTY_STEP_UP
:
1726 case M_PROPERTY_STEP_DOWN
:
1727 vo_osd_changed(OSDTYPE_SUBTITLE
);
1729 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1733 /// Subtitle visibility (RW)
1734 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1735 void *arg
, MPContext
* mpctx
)
1737 if (!mpctx
->sh_video
)
1738 return M_PROPERTY_UNAVAILABLE
;
1741 case M_PROPERTY_SET
:
1743 return M_PROPERTY_ERROR
;
1744 case M_PROPERTY_STEP_UP
:
1745 case M_PROPERTY_STEP_DOWN
:
1746 vo_osd_changed(OSDTYPE_SUBTITLE
);
1748 vo_osd_changed(OSDTYPE_SPU
);
1750 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1755 /// Use margins for libass subtitles (RW)
1756 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1757 void *arg
, MPContext
* mpctx
)
1759 if (!mpctx
->sh_video
)
1760 return M_PROPERTY_UNAVAILABLE
;
1763 case M_PROPERTY_SET
:
1765 return M_PROPERTY_ERROR
;
1766 case M_PROPERTY_STEP_UP
:
1767 case M_PROPERTY_STEP_DOWN
:
1768 ass_force_reload
= 1;
1770 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1775 /// Show only forced subtitles (RW)
1776 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1777 void *arg
, MPContext
* mpctx
)
1780 return M_PROPERTY_UNAVAILABLE
;
1783 case M_PROPERTY_SET
:
1785 return M_PROPERTY_ERROR
;
1786 case M_PROPERTY_STEP_UP
:
1787 case M_PROPERTY_STEP_DOWN
:
1788 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1789 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1790 return M_PROPERTY_OK
;
1792 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1797 #ifdef CONFIG_FREETYPE
1798 /// Subtitle scale (RW)
1799 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1804 case M_PROPERTY_SET
:
1806 return M_PROPERTY_ERROR
;
1807 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1810 ass_font_scale
= *(float *) arg
;
1811 ass_force_reload
= 1;
1814 text_font_scale_factor
= *(float *) arg
;
1815 force_load_font
= 1;
1816 return M_PROPERTY_OK
;
1817 case M_PROPERTY_STEP_UP
:
1818 case M_PROPERTY_STEP_DOWN
:
1821 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1822 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1823 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1824 ass_force_reload
= 1;
1827 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1828 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1829 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1830 force_load_font
= 1;
1831 return M_PROPERTY_OK
;
1835 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1838 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1845 /// \defgroup TVProperties TV properties
1846 /// \ingroup Properties
1851 /// TV color settings (RW)
1852 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1856 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1857 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1858 return M_PROPERTY_UNAVAILABLE
;
1861 case M_PROPERTY_SET
:
1863 return M_PROPERTY_ERROR
;
1864 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1865 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1866 case M_PROPERTY_GET
:
1867 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1868 case M_PROPERTY_STEP_UP
:
1869 case M_PROPERTY_STEP_DOWN
:
1870 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1872 return M_PROPERTY_ERROR
;
1873 val
+= (arg
? *(int *) arg
: 1) *
1874 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1875 M_PROPERTY_CLAMP(prop
, val
);
1876 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1878 return M_PROPERTY_ERROR
;
1880 return M_PROPERTY_NOT_IMPLEMENTED
;
1885 #ifdef CONFIG_TV_TELETEXT
1886 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1890 int base_ioctl
=(int)prop
->priv
;
1892 for teletext's GET,SET,STEP ioctls this is not 0
1896 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1897 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1898 return M_PROPERTY_UNAVAILABLE
;
1900 return M_PROPERTY_ERROR
;
1903 case M_PROPERTY_GET
:
1905 return M_PROPERTY_ERROR
;
1906 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1908 case M_PROPERTY_SET
:
1910 return M_PROPERTY_ERROR
;
1911 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1912 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1914 case M_PROPERTY_STEP_UP
:
1915 case M_PROPERTY_STEP_DOWN
:
1916 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1917 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1918 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1921 return M_PROPERTY_NOT_IMPLEMENTED
;
1924 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1927 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1930 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1934 //with tvh==NULL will fail too
1935 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1936 if(result
!=M_PROPERTY_OK
)
1939 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1940 mp_input_set_section("teletext");
1942 mp_input_set_section("tv");
1943 return M_PROPERTY_OK
;
1946 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1949 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1952 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1953 return M_PROPERTY_UNAVAILABLE
;
1955 case M_PROPERTY_STEP_UP
:
1956 case M_PROPERTY_STEP_DOWN
:
1957 //This should be handled separately
1958 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1959 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1962 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1968 #endif /* CONFIG_TV_TELETEXT */
1972 /// All properties available in MPlayer.
1973 /** \ingroup Properties
1975 static const m_option_t mp_properties
[] = {
1977 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1978 M_OPT_RANGE
, 0, 3, NULL
},
1979 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1980 M_OPT_MIN
, -1, 0, NULL
},
1981 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1982 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1983 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1985 { "path", mp_property_path
, CONF_TYPE_STRING
,
1987 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1989 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1990 M_OPT_MIN
, 0, 0, NULL
},
1991 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1992 M_OPT_MIN
, 0, 0, NULL
},
1993 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1994 M_OPT_MIN
, 0, 0, NULL
},
1995 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1996 M_OPT_MIN
, 0, 0, NULL
},
1997 { "length", mp_property_length
, CONF_TYPE_TIME
,
1998 M_OPT_MIN
, 0, 0, NULL
},
1999 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
2000 M_OPT_RANGE
, 0, 100, NULL
},
2001 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2002 M_OPT_MIN
, 0, 0, NULL
},
2003 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2004 M_OPT_MIN
, 1, 0, NULL
},
2005 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2007 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2008 CONF_RANGE
, -2, 10, NULL
},
2009 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2011 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2012 M_OPT_RANGE
, 0, 1, NULL
},
2015 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2016 M_OPT_RANGE
, 0, 100, NULL
},
2017 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2018 M_OPT_RANGE
, 0, 1, NULL
},
2019 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2020 M_OPT_RANGE
, -100, 100, NULL
},
2021 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2023 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2025 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2027 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2029 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2031 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2032 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2033 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2034 M_OPT_RANGE
, -1, 1, NULL
},
2037 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2038 M_OPT_RANGE
, 0, 1, NULL
},
2039 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2040 M_OPT_RANGE
, 0, 1, NULL
},
2041 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2042 M_OPT_RANGE
, 0, 1, NULL
},
2043 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2044 M_OPT_RANGE
, 0, 1, NULL
},
2045 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2046 M_OPT_RANGE
, 0, 1, NULL
},
2047 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2048 M_OPT_RANGE
, 0, 2, NULL
},
2049 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2050 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2051 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2052 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2053 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2054 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2055 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2056 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2057 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2058 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2059 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2060 M_OPT_RANGE
, 0, 1, NULL
},
2061 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2062 M_OPT_RANGE
, 0, 1, NULL
},
2063 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2065 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2067 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2069 { "width", mp_property_width
, CONF_TYPE_INT
,
2071 { "height", mp_property_height
, CONF_TYPE_INT
,
2073 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2075 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2077 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2078 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2079 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2080 CONF_RANGE
, -1, 65535, NULL
},
2083 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2084 M_OPT_MIN
, -1, 0, NULL
},
2085 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2086 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2087 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2088 M_OPT_MIN
, -1, 0, NULL
},
2089 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2090 M_OPT_MIN
, -1, 0, NULL
},
2091 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2092 M_OPT_MIN
, -1, 0, NULL
},
2093 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2095 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2096 M_OPT_RANGE
, 0, 100, NULL
},
2097 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2098 M_OPT_RANGE
, 0, 2, NULL
},
2099 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2100 M_OPT_RANGE
, 0, 1, NULL
},
2101 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2102 M_OPT_RANGE
, 0, 1, NULL
},
2103 #ifdef CONFIG_FREETYPE
2104 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2105 M_OPT_RANGE
, 0, 100, NULL
},
2108 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2109 M_OPT_RANGE
, 0, 1, NULL
},
2113 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2114 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2115 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2116 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2117 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2118 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2119 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2120 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2123 #ifdef CONFIG_TV_TELETEXT
2124 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2125 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2126 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2127 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2128 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2129 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2130 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2131 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2132 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2133 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2136 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2140 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2142 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2145 char* mp_property_print(const char *name
, void* ctx
)
2148 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2153 char *property_expand_string(MPContext
* mpctx
, char *str
)
2155 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2158 void property_print_help(void)
2160 m_properties_print_help_list(mp_properties
);
2169 * \defgroup Command2Property Command to property bridge
2171 * It is used to handle most commands that just set a property
2172 * and optionally display something on the OSD.
2173 * Two kinds of commands are handled: adjust or toggle.
2175 * Adjust commands take 1 or 2 parameters: <value> <abs>
2176 * If <abs> is non-zero the property is set to the given value
2177 * otherwise it is adjusted.
2179 * Toggle commands take 0 or 1 parameters. With no parameter
2180 * or a value less than the property minimum it just steps the
2181 * property to its next value. Otherwise it sets it to the given
2187 /// List of the commands that can be handled by setting a property.
2193 /// set/adjust or toggle command
2195 /// progressbar type
2197 /// osd msg id if it must be shared
2199 /// osd msg template
2200 const char *osd_msg
;
2201 } set_prop_cmd
[] = {
2203 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2204 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2205 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2207 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2208 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2209 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2210 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2211 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2213 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2214 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2215 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2216 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2217 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2218 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2219 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2220 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2221 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2222 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2223 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2224 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2226 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2227 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2228 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2229 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2230 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2231 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2232 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2233 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2234 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2235 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2236 #ifdef CONFIG_FREETYPE
2237 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2240 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2243 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2244 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2245 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2246 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2248 { NULL
, 0, 0, 0, -1, NULL
}
2252 /// Handle commands that set a property.
2253 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2259 // look for the command
2260 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2261 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2263 if (!(pname
= set_prop_cmd
[i
].name
))
2266 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2270 if (set_prop_cmd
[i
].toggle
) {
2272 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2273 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2275 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2276 } else if (cmd
->args
[1].v
.i
) //set
2277 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2279 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2284 if (set_prop_cmd
[i
].osd_progbar
) {
2285 if (prop
->type
== CONF_TYPE_INT
) {
2286 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2287 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2288 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2289 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2291 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2292 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2293 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2295 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2296 "Property use an unsupported type.\n");
2300 if (set_prop_cmd
[i
].osd_msg
) {
2301 char *val
= mp_property_print(pname
, mpctx
);
2303 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2304 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2305 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2312 #ifdef CONFIG_DVDNAV
2313 static const struct {
2315 const mp_command_type cmd
;
2316 } mp_dvdnav_bindings
[] = {
2317 { "up", MP_CMD_DVDNAV_UP
},
2318 { "down", MP_CMD_DVDNAV_DOWN
},
2319 { "left", MP_CMD_DVDNAV_LEFT
},
2320 { "right", MP_CMD_DVDNAV_RIGHT
},
2321 { "menu", MP_CMD_DVDNAV_MENU
},
2322 { "select", MP_CMD_DVDNAV_SELECT
},
2323 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2324 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2327 * keep old dvdnav sub-command options for a while in order not to
2328 * break slave-mode API too suddenly.
2330 { "1", MP_CMD_DVDNAV_UP
},
2331 { "2", MP_CMD_DVDNAV_DOWN
},
2332 { "3", MP_CMD_DVDNAV_LEFT
},
2333 { "4", MP_CMD_DVDNAV_RIGHT
},
2334 { "5", MP_CMD_DVDNAV_MENU
},
2335 { "6", MP_CMD_DVDNAV_SELECT
},
2336 { "7", MP_CMD_DVDNAV_PREVMENU
},
2337 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2342 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2344 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2345 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2347 if (!set_property_command(mpctx
, cmd
))
2353 mpctx
->osd_show_percentage
= sh_video
->fps
;
2354 v
= cmd
->args
[0].v
.f
;
2355 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2356 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2357 abs_seek_pos
= SEEK_ABSOLUTE
;
2359 mpctx
->osd_function
=
2360 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2362 } else if (abs
) { /* Absolute seek by percentage */
2363 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2365 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2366 rel_seek_secs
= v
/ 100.0;
2369 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2375 case MP_CMD_SET_PROPERTY
:{
2376 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2377 cmd
->args
[1].v
.s
, mpctx
);
2378 if (r
== M_PROPERTY_UNKNOWN
)
2379 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2380 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2382 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2383 "Failed to set property '%s' to '%s'.\n",
2384 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2388 case MP_CMD_STEP_PROPERTY
:{
2393 if (cmd
->args
[1].v
.f
) {
2395 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2396 M_PROPERTY_GET_TYPE
,
2397 &prop
, mpctx
)) <= 0)
2399 if(prop
->type
== CONF_TYPE_INT
||
2400 prop
->type
== CONF_TYPE_FLAG
)
2401 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2402 else if(prop
->type
== CONF_TYPE_FLOAT
)
2403 arg
= &cmd
->args
[1].v
.f
;
2404 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2405 prop
->type
== CONF_TYPE_TIME
)
2406 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2407 else if(prop
->type
== CONF_TYPE_POSITION
)
2408 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2410 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2411 "Ignoring step size stepping property '%s'.\n",
2414 r
= mp_property_do(cmd
->args
[0].v
.s
,
2415 cmd
->args
[2].v
.i
< 0 ?
2416 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2419 if (r
== M_PROPERTY_UNKNOWN
)
2420 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2421 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2423 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2424 "Failed to increment property '%s' by %f.\n",
2425 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2429 case MP_CMD_GET_PROPERTY
:{
2431 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2432 &tmp
, mpctx
) <= 0) {
2433 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2434 "Failed to get value of property '%s'.\n",
2438 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2439 cmd
->args
[0].v
.s
, tmp
);
2444 case MP_CMD_EDL_MARK
:
2446 float v
= sh_video
? sh_video
->pts
:
2447 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2450 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2451 mpctx
->begin_skip
= v
;
2452 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2454 if (mpctx
->begin_skip
> v
)
2455 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2457 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2458 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2460 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2465 case MP_CMD_SWITCH_RATIO
:
2466 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2467 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2469 movie_aspect
= cmd
->args
[0].v
.f
;
2470 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2473 case MP_CMD_SPEED_INCR
:{
2474 float v
= cmd
->args
[0].v
.f
;
2475 playback_speed
+= v
;
2476 build_afilter_chain(sh_audio
, &ao_data
);
2477 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2481 case MP_CMD_SPEED_MULT
:{
2482 float v
= cmd
->args
[0].v
.f
;
2483 playback_speed
*= v
;
2484 build_afilter_chain(sh_audio
, &ao_data
);
2485 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2489 case MP_CMD_SPEED_SET
:{
2490 float v
= cmd
->args
[0].v
.f
;
2492 build_afilter_chain(sh_audio
, &ao_data
);
2493 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2497 case MP_CMD_FRAME_STEP
:
2503 case MP_CMD_FILE_FILTER
:
2504 file_filter
= cmd
->args
[0].v
.i
;
2508 exit_player_with_rc(EXIT_QUIT
,
2509 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2511 case MP_CMD_PLAY_TREE_STEP
:{
2512 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2513 int force
= cmd
->args
[1].v
.i
;
2519 for (i
= 0; i
< n
; i
++)
2522 for (i
= 0; i
< -1 * n
; i
++)
2527 if (!force
&& mpctx
->playtree_iter
) {
2528 play_tree_iter_t
*i
=
2529 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2530 if (play_tree_iter_step(i
, n
, 0) ==
2531 PLAY_TREE_ITER_ENTRY
)
2533 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2534 play_tree_iter_free(i
);
2536 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2538 mpctx
->play_tree_step
= n
;
2544 case MP_CMD_PLAY_TREE_UP_STEP
:{
2545 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2546 int force
= cmd
->args
[1].v
.i
;
2548 if (!force
&& mpctx
->playtree_iter
) {
2549 play_tree_iter_t
*i
=
2550 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2551 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2552 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2553 play_tree_iter_free(i
);
2555 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2560 case MP_CMD_PLAY_ALT_SRC_STEP
:
2561 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2562 int v
= cmd
->args
[0].v
.i
;
2564 && mpctx
->playtree_iter
->file
<
2565 mpctx
->playtree_iter
->num_files
)
2566 mpctx
->eof
= PT_NEXT_SRC
;
2567 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2568 mpctx
->eof
= PT_PREV_SRC
;
2573 case MP_CMD_SUB_STEP
:
2575 int movement
= cmd
->args
[0].v
.i
;
2576 step_sub(subdata
, sh_video
->pts
, movement
);
2580 ass_step_sub(ass_track
,
2582 sub_delay
) * 1000 + .5, movement
) / 1000.;
2584 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2585 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2589 case MP_CMD_SUB_LOG
:
2594 int v
= cmd
->args
[0].v
.i
;
2596 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2597 if (osd_level
> max
)
2600 osd_level
= (osd_level
+ 1) % (max
+ 1);
2602 osd_level
= v
> max
? max
: v
;
2603 /* Show OSD state when disabled, but not when an explicit
2604 argument is given to the OSD command, i.e. in slave mode. */
2605 if (v
== -1 && osd_level
<= 1)
2606 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2608 osd_level
? MSGTR_OSDenabled
:
2611 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2615 case MP_CMD_OSD_SHOW_TEXT
:
2616 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2618 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2619 "%-.63s", cmd
->args
[0].v
.s
);
2622 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2623 char *txt
= m_properties_expand_string(mp_properties
,
2626 /* if no argument supplied take default osd_duration, else <arg> ms. */
2628 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2630 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2637 case MP_CMD_LOADFILE
:{
2638 play_tree_t
*e
= play_tree_new();
2639 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2641 if (cmd
->args
[1].v
.i
) // append
2642 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2644 // Go back to the starting point.
2645 while (play_tree_iter_up_step
2646 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2648 play_tree_free_list(mpctx
->playtree
->child
, 1);
2649 play_tree_set_child(mpctx
->playtree
, e
);
2650 pt_iter_goto_head(mpctx
->playtree_iter
);
2651 mpctx
->eof
= PT_NEXT_SRC
;
2657 case MP_CMD_LOADLIST
:{
2658 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2660 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2661 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2663 if (cmd
->args
[1].v
.i
) // append
2664 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2666 // Go back to the starting point.
2667 while (play_tree_iter_up_step
2668 (mpctx
->playtree_iter
, 0, 1)
2669 != PLAY_TREE_ITER_END
)
2671 play_tree_free_list(mpctx
->playtree
->child
, 1);
2672 play_tree_set_child(mpctx
->playtree
, e
);
2673 pt_iter_goto_head(mpctx
->playtree_iter
);
2674 mpctx
->eof
= PT_NEXT_SRC
;
2682 // Go back to the starting point.
2683 while (play_tree_iter_up_step
2684 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2686 mpctx
->eof
= PT_STOP
;
2691 case MP_CMD_RADIO_STEP_CHANNEL
:
2692 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2693 int v
= cmd
->args
[0].v
.i
;
2695 radio_step_channel(mpctx
->demuxer
->stream
,
2696 RADIO_CHANNEL_HIGHER
);
2698 radio_step_channel(mpctx
->demuxer
->stream
,
2699 RADIO_CHANNEL_LOWER
);
2700 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2701 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2703 radio_get_channel_name(mpctx
->demuxer
->stream
));
2708 case MP_CMD_RADIO_SET_CHANNEL
:
2709 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2710 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2711 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2712 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2714 radio_get_channel_name(mpctx
->demuxer
->stream
));
2719 case MP_CMD_RADIO_SET_FREQ
:
2720 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2721 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2724 case MP_CMD_RADIO_STEP_FREQ
:
2725 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2726 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2731 case MP_CMD_TV_START_SCAN
:
2732 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2733 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2735 case MP_CMD_TV_SET_FREQ
:
2736 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2737 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2738 cmd
->args
[0].v
.f
* 16.0);
2740 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2741 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2742 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2743 pvr_get_current_channelname (mpctx
->stream
),
2744 pvr_get_current_stationname (mpctx
->stream
));
2746 #endif /* CONFIG_PVR */
2749 case MP_CMD_TV_STEP_FREQ
:
2750 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2751 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2752 cmd
->args
[0].v
.f
* 16.0);
2754 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2755 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2756 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2757 pvr_get_current_channelname (mpctx
->stream
),
2758 pvr_get_current_frequency (mpctx
->stream
));
2760 #endif /* CONFIG_PVR */
2763 case MP_CMD_TV_SET_NORM
:
2764 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2765 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2769 case MP_CMD_TV_STEP_CHANNEL
:{
2770 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2771 int v
= cmd
->args
[0].v
.i
;
2773 tv_step_channel((tvi_handle_t
*) (mpctx
->
2777 tv_step_channel((tvi_handle_t
*) (mpctx
->
2781 if (tv_channel_list
) {
2782 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2783 MSGTR_OSDChannel
, tv_channel_current
->name
);
2784 //vo_osd_changed(OSDTYPE_SUBTITLE);
2788 else if (mpctx
->stream
&&
2789 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2790 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2791 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2792 pvr_get_current_channelname (mpctx
->stream
),
2793 pvr_get_current_stationname (mpctx
->stream
));
2795 #endif /* CONFIG_PVR */
2798 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2800 int v
= cmd
->args
[0].v
.i
;
2802 mpctx
->last_dvb_step
= v
;
2804 dir
= DVB_CHANNEL_HIGHER
;
2806 dir
= DVB_CHANNEL_LOWER
;
2809 if (dvb_step_channel(mpctx
->stream
, dir
))
2810 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2812 #endif /* CONFIG_DVBIN */
2815 case MP_CMD_TV_SET_CHANNEL
:
2816 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2817 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2819 if (tv_channel_list
) {
2820 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2821 MSGTR_OSDChannel
, tv_channel_current
->name
);
2822 //vo_osd_changed(OSDTYPE_SUBTITLE);
2826 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2827 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2828 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2829 pvr_get_current_channelname (mpctx
->stream
),
2830 pvr_get_current_stationname (mpctx
->stream
));
2832 #endif /* CONFIG_PVR */
2836 case MP_CMD_DVB_SET_CHANNEL
:
2837 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2838 mpctx
->last_dvb_step
= 1;
2841 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2842 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2845 #endif /* CONFIG_DVBIN */
2847 case MP_CMD_TV_LAST_CHANNEL
:
2848 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2849 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2850 if (tv_channel_list
) {
2851 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2852 MSGTR_OSDChannel
, tv_channel_current
->name
);
2853 //vo_osd_changed(OSDTYPE_SUBTITLE);
2857 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2858 pvr_set_lastchannel (mpctx
->stream
);
2859 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2860 pvr_get_current_channelname (mpctx
->stream
),
2861 pvr_get_current_stationname (mpctx
->stream
));
2863 #endif /* CONFIG_PVR */
2866 case MP_CMD_TV_STEP_NORM
:
2867 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2868 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2871 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2872 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2873 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2875 #ifdef CONFIG_TV_TELETEXT
2876 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2878 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2879 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2880 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2883 case MP_CMD_TV_TELETEXT_GO_LINK
:
2885 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2886 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2887 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2890 #endif /* CONFIG_TV_TELETEXT */
2891 #endif /* CONFIG_TV */
2893 case MP_CMD_SUB_LOAD
:
2895 int n
= mpctx
->set_of_sub_size
;
2896 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2897 if (n
!= mpctx
->set_of_sub_size
) {
2898 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2899 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2900 mpctx
->global_sub_size
;
2901 ++mpctx
->global_sub_size
;
2906 case MP_CMD_SUB_REMOVE
:
2908 int v
= cmd
->args
[0].v
.i
;
2911 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2912 subd
= mpctx
->set_of_subtitles
[v
];
2913 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2914 MSGTR_RemovedSubtitleFile
, v
+ 1,
2915 filename_recode(subd
->filename
));
2917 mpctx
->set_of_subtitles
[v
] = NULL
;
2919 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2920 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2921 mpctx
->set_of_sub_size
= 0;
2922 if (mpctx
->set_of_sub_pos
>= 0) {
2923 mpctx
->global_sub_pos
= -2;
2925 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2927 } else if (v
< mpctx
->set_of_sub_size
) {
2928 subd
= mpctx
->set_of_subtitles
[v
];
2929 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2930 MSGTR_RemovedSubtitleFile
, v
+ 1,
2931 filename_recode(subd
->filename
));
2933 if (mpctx
->set_of_sub_pos
== v
) {
2934 mpctx
->global_sub_pos
= -2;
2936 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2937 } else if (mpctx
->set_of_sub_pos
> v
) {
2938 --mpctx
->set_of_sub_pos
;
2939 --mpctx
->global_sub_pos
;
2941 while (++v
< mpctx
->set_of_sub_size
)
2942 mpctx
->set_of_subtitles
[v
- 1] =
2943 mpctx
->set_of_subtitles
[v
];
2944 --mpctx
->set_of_sub_size
;
2945 --mpctx
->global_sub_size
;
2946 if (mpctx
->set_of_sub_size
<= 0)
2947 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2948 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2953 case MP_CMD_GET_SUB_VISIBILITY
:
2955 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2956 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2960 case MP_CMD_SCREENSHOT
:
2961 if (vo_config_count
) {
2962 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2964 ((vf_instance_t
*) sh_video
->vfilter
)->
2965 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2967 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2971 case MP_CMD_VF_CHANGE_RECTANGLE
:
2972 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2975 case MP_CMD_GET_TIME_LENGTH
:{
2976 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2977 demuxer_get_time_length(mpctx
->demuxer
));
2981 case MP_CMD_GET_FILENAME
:{
2982 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2983 get_metadata(META_NAME
));
2987 case MP_CMD_GET_VIDEO_CODEC
:{
2988 char *inf
= get_metadata(META_VIDEO_CODEC
);
2991 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2996 case MP_CMD_GET_VIDEO_BITRATE
:{
2997 char *inf
= get_metadata(META_VIDEO_BITRATE
);
3000 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3005 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3006 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
3009 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3010 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3015 case MP_CMD_GET_AUDIO_CODEC
:{
3016 char *inf
= get_metadata(META_AUDIO_CODEC
);
3019 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3024 case MP_CMD_GET_AUDIO_BITRATE
:{
3025 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3028 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3033 case MP_CMD_GET_AUDIO_SAMPLES
:{
3034 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3037 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3042 case MP_CMD_GET_META_TITLE
:{
3043 char *inf
= get_metadata(META_INFO_TITLE
);
3046 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3051 case MP_CMD_GET_META_ARTIST
:{
3052 char *inf
= get_metadata(META_INFO_ARTIST
);
3055 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3060 case MP_CMD_GET_META_ALBUM
:{
3061 char *inf
= get_metadata(META_INFO_ALBUM
);
3064 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3069 case MP_CMD_GET_META_YEAR
:{
3070 char *inf
= get_metadata(META_INFO_YEAR
);
3073 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3078 case MP_CMD_GET_META_COMMENT
:{
3079 char *inf
= get_metadata(META_INFO_COMMENT
);
3082 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3087 case MP_CMD_GET_META_TRACK
:{
3088 char *inf
= get_metadata(META_INFO_TRACK
);
3091 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3096 case MP_CMD_GET_META_GENRE
:{
3097 char *inf
= get_metadata(META_INFO_GENRE
);
3100 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3105 case MP_CMD_GET_VO_FULLSCREEN
:
3106 if (mpctx
->video_out
&& vo_config_count
)
3107 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3110 case MP_CMD_GET_PERCENT_POS
:
3111 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3112 demuxer_get_percent_pos(mpctx
->demuxer
));
3115 case MP_CMD_GET_TIME_POS
:{
3118 pos
= sh_video
->pts
;
3119 else if (sh_audio
&& mpctx
->audio_out
)
3121 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3123 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3130 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3136 case MP_CMD_KEYDOWN_EVENTS
:
3137 mplayer_put_key(cmd
->args
[0].v
.i
);
3140 case MP_CMD_SET_MOUSE_POS
:{
3141 int pointer_x
, pointer_y
;
3143 pointer_x
= cmd
->args
[0].v
.i
;
3144 pointer_y
= cmd
->args
[1].v
.i
;
3145 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3146 #ifdef CONFIG_DVDNAV
3147 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3148 && dx
> 0.0 && dy
> 0.0) {
3150 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3151 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3152 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3153 pointer_x
, pointer_y
, &button
);
3154 if (osd_level
> 1 && button
> 0)
3155 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3156 "Selected button number %d", button
);
3160 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3161 menu_update_mouse_pos(dx
, dy
);
3166 #ifdef CONFIG_DVDNAV
3167 case MP_CMD_DVDNAV
:{
3170 mp_command_type command
= 0;
3171 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3174 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3175 if (cmd
->args
[0].v
.s
&&
3176 !strcasecmp (cmd
->args
[0].v
.s
,
3177 mp_dvdnav_bindings
[i
].name
))
3178 command
= mp_dvdnav_bindings
[i
].cmd
;
3180 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3181 if (osd_level
> 1 && button
> 0)
3182 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3183 "Selected button number %d", button
);
3187 case MP_CMD_SWITCH_TITLE
:
3188 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3189 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3196 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3197 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3200 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3201 "Received unknown cmd %s\n", cmd
->name
);
3204 switch (cmd
->pausing
) {
3205 case 1: // "pausing"
3206 mpctx
->osd_function
= OSD_PAUSE
;
3208 case 3: // "pausing_toggle"
3209 mpctx
->was_paused
= !mpctx
->was_paused
;
3210 if (mpctx
->was_paused
)
3211 mpctx
->osd_function
= OSD_PAUSE
;
3212 else if (mpctx
->osd_function
== OSD_PAUSE
)
3213 mpctx
->osd_function
= OSD_PLAY
;
3215 case 2: // "pausing_keep"
3216 if (mpctx
->was_paused
)
3217 mpctx
->osd_function
= OSD_PAUSE
;