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"
28 #include "libmpcodecs/dec_teletext.h"
32 #include "stream/tv.h"
33 #include "stream/stream_radio.h"
34 #include "stream/pvr.h"
36 #include "stream/dvbin.h"
39 #include "stream/stream_dvd.h"
41 #include "stream/stream_dvdnav.h"
42 #include "libass/ass.h"
43 #include "libass/ass_mp.h"
45 #include "libmenu/menu.h"
46 #include "gui/interface.h"
50 #include "libavutil/avstring.h"
52 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
56 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
58 //remove the borders, if any, and rescale to the range [0,1],[0,1]
59 if (vo_fs
) { //we are in full-screen mode
60 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
61 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
62 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
63 iy
-= (vo_screenheight
- vo_dheight
) / 2;
65 if (ix
< 0 || ix
> vo_dwidth
) {
68 } //we are on one of the borders
69 if (iy
< 0 || iy
> vo_dheight
) {
72 } //we are on one of the borders
75 *dx
= (double) ix
/ (double) vo_dwidth
;
76 *dy
= (double) iy
/ (double) vo_dheight
;
78 mp_msg(MSGT_CPLAYER
, MSGL_V
,
79 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
80 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
84 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
89 for (i
= 0; i
< SUB_SOURCES
; i
++) {
90 int j
= mpctx
->global_sub_indices
[i
];
91 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
99 static int sub_source(MPContext
* mpctx
)
101 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
105 * \brief Log the currently displayed subtitle to a file
107 * Logs the current or last displayed subtitle together with filename
108 * and time information to ~/.mplayer/subtitle_log
110 * Intended purpose is to allow convenient marking of bogus subtitles
111 * which need to be fixed while watching the movie.
114 static void log_sub(void)
120 if (subdata
== NULL
|| vo_sub_last
== NULL
)
122 fname
= get_path("subtitle_log");
123 f
= fopen(fname
, "a");
126 fprintf(f
, "----------------------------------------------------------\n");
127 if (subdata
->sub_uses_time
) {
129 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
130 filename
, vo_sub_last
->start
/ 360000,
131 (vo_sub_last
->start
/ 6000) % 60,
132 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
133 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
134 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
136 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
139 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
140 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
146 /// \defgroup Properties
149 /// \defgroup GeneralProperties General properties
150 /// \ingroup Properties
154 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
157 return m_property_choice(prop
, action
, arg
, &osd_level
);
161 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
165 case M_PROPERTY_PRINT
:
166 if (!arg
) return M_PROPERTY_ERROR
;
167 if (mpctx
->loop_times
< 0)
168 *(char**)arg
= strdup("off");
169 else if (mpctx
->loop_times
== 0)
170 *(char**)arg
= strdup("inf");
173 return M_PROPERTY_OK
;
175 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
178 /// Playback speed (RW)
179 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
180 void *arg
, MPContext
* mpctx
)
185 return M_PROPERTY_ERROR
;
186 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
187 playback_speed
= *(float *) arg
;
188 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
189 return M_PROPERTY_OK
;
190 case M_PROPERTY_STEP_UP
:
191 case M_PROPERTY_STEP_DOWN
:
192 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
193 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
194 M_PROPERTY_CLAMP(prop
, playback_speed
);
195 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
196 return M_PROPERTY_OK
;
198 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
201 /// filename with path (RO)
202 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
205 return m_property_string_ro(prop
, action
, arg
, filename
);
208 /// filename without path (RO)
209 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
214 return M_PROPERTY_UNAVAILABLE
;
215 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
219 return m_property_string_ro(prop
, action
, arg
, f
);
222 /// Demuxer name (RO)
223 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
227 return M_PROPERTY_UNAVAILABLE
;
228 return m_property_string_ro(prop
, action
, arg
,
229 (char *) mpctx
->demuxer
->desc
->name
);
232 /// Position in the stream (RW)
233 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
236 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
237 return M_PROPERTY_UNAVAILABLE
;
239 return M_PROPERTY_ERROR
;
242 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
243 return M_PROPERTY_OK
;
245 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
246 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
247 return M_PROPERTY_OK
;
249 return M_PROPERTY_NOT_IMPLEMENTED
;
252 /// Stream start offset (RO)
253 static int mp_property_stream_start(m_option_t
* prop
, int action
,
254 void *arg
, MPContext
* mpctx
)
256 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
257 return M_PROPERTY_UNAVAILABLE
;
260 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
261 return M_PROPERTY_OK
;
263 return M_PROPERTY_NOT_IMPLEMENTED
;
266 /// Stream end offset (RO)
267 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
270 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
271 return M_PROPERTY_UNAVAILABLE
;
274 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
275 return M_PROPERTY_OK
;
277 return M_PROPERTY_NOT_IMPLEMENTED
;
280 /// Stream length (RO)
281 static int mp_property_stream_length(m_option_t
* prop
, int action
,
282 void *arg
, MPContext
* mpctx
)
284 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
285 return M_PROPERTY_UNAVAILABLE
;
289 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
290 return M_PROPERTY_OK
;
292 return M_PROPERTY_NOT_IMPLEMENTED
;
295 /// Media length in seconds (RO)
296 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
301 if (!mpctx
->demuxer
||
302 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
303 return M_PROPERTY_UNAVAILABLE
;
305 return m_property_time_ro(prop
, action
, arg
, len
);
308 /// Current position in percent (RW)
309 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
310 void *arg
, MPContext
* mpctx
) {
314 return M_PROPERTY_UNAVAILABLE
;
318 if(!arg
) return M_PROPERTY_ERROR
;
319 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
322 case M_PROPERTY_STEP_UP
:
323 case M_PROPERTY_STEP_DOWN
:
324 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
325 pos
+= (arg
? *(int*)arg
: 10) *
326 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
327 M_PROPERTY_CLAMP(prop
, pos
);
330 return m_property_int_ro(prop
, action
, arg
,
331 demuxer_get_percent_pos(mpctx
->demuxer
));
334 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
335 rel_seek_secs
= pos
/ 100.0;
336 return M_PROPERTY_OK
;
339 /// Current position in seconds (RW)
340 static int mp_property_time_pos(m_option_t
* prop
, int action
,
341 void *arg
, MPContext
* mpctx
) {
342 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
343 return M_PROPERTY_UNAVAILABLE
;
347 if(!arg
) return M_PROPERTY_ERROR
;
348 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
349 abs_seek_pos
= SEEK_ABSOLUTE
;
350 rel_seek_secs
= *(double*)arg
;
351 return M_PROPERTY_OK
;
352 case M_PROPERTY_STEP_UP
:
353 case M_PROPERTY_STEP_DOWN
:
354 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
355 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
356 return M_PROPERTY_OK
;
358 return m_property_time_ro(prop
, action
, arg
,
359 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
360 playing_audio_pts(mpctx
->sh_audio
,
365 /// Current chapter (RW)
366 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
373 char *chapter_name
= NULL
;
376 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
378 return M_PROPERTY_UNAVAILABLE
;
383 return M_PROPERTY_ERROR
;
384 *(int *) arg
= chapter
;
385 return M_PROPERTY_OK
;
386 case M_PROPERTY_PRINT
: {
388 return M_PROPERTY_ERROR
;
389 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
391 return M_PROPERTY_UNAVAILABLE
;
392 *(char **) arg
= chapter_name
;
393 return M_PROPERTY_OK
;
397 return M_PROPERTY_ERROR
;
398 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
399 step_all
= *(int *)arg
- chapter
;
402 case M_PROPERTY_STEP_UP
:
403 case M_PROPERTY_STEP_DOWN
: {
404 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
405 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
412 return M_PROPERTY_NOT_IMPLEMENTED
;
416 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
417 &next_pts
, &chapter_num
, &chapter_name
);
419 if (next_pts
> -1.0) {
420 abs_seek_pos
= SEEK_ABSOLUTE
;
421 rel_seek_secs
= next_pts
;
424 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
425 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
427 else if (step_all
> 0)
428 rel_seek_secs
= 1000000000.;
430 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
431 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
434 return M_PROPERTY_OK
;
437 /// Number of chapters in file
438 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
442 return M_PROPERTY_UNAVAILABLE
;
443 if (mpctx
->demuxer
->num_chapters
== 0)
444 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
445 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
448 /// Current dvd angle (RW)
449 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
454 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
;
544 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
547 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
553 /// \defgroup AudioProperties Audio properties
554 /// \ingroup Properties
558 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
562 if (!mpctx
->sh_audio
)
563 return M_PROPERTY_UNAVAILABLE
;
568 return M_PROPERTY_ERROR
;
569 mixer_getbothvolume(&mpctx
->mixer
, arg
);
570 return M_PROPERTY_OK
;
571 case M_PROPERTY_PRINT
:{
574 return M_PROPERTY_ERROR
;
575 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
576 return m_property_float_range(prop
, action
, arg
, &vol
);
578 case M_PROPERTY_STEP_UP
:
579 case M_PROPERTY_STEP_DOWN
:
583 return M_PROPERTY_NOT_IMPLEMENTED
;
586 if (mpctx
->edl_muted
)
587 return M_PROPERTY_DISABLED
;
588 mpctx
->user_muted
= 0;
593 return M_PROPERTY_ERROR
;
594 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
595 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
596 return M_PROPERTY_OK
;
597 case M_PROPERTY_STEP_UP
:
598 if (arg
&& *(float *) arg
<= 0)
599 mixer_decvolume(&mpctx
->mixer
);
601 mixer_incvolume(&mpctx
->mixer
);
602 return M_PROPERTY_OK
;
603 case M_PROPERTY_STEP_DOWN
:
604 if (arg
&& *(float *) arg
<= 0)
605 mixer_incvolume(&mpctx
->mixer
);
607 mixer_decvolume(&mpctx
->mixer
);
608 return M_PROPERTY_OK
;
610 return M_PROPERTY_NOT_IMPLEMENTED
;
614 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
618 if (!mpctx
->sh_audio
)
619 return M_PROPERTY_UNAVAILABLE
;
623 if (mpctx
->edl_muted
)
624 return M_PROPERTY_DISABLED
;
626 return M_PROPERTY_ERROR
;
627 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
628 mixer_mute(&mpctx
->mixer
);
629 mpctx
->user_muted
= mpctx
->mixer
.muted
;
630 return M_PROPERTY_OK
;
631 case M_PROPERTY_STEP_UP
:
632 case M_PROPERTY_STEP_DOWN
:
633 if (mpctx
->edl_muted
)
634 return M_PROPERTY_DISABLED
;
635 mixer_mute(&mpctx
->mixer
);
636 mpctx
->user_muted
= mpctx
->mixer
.muted
;
637 return M_PROPERTY_OK
;
638 case M_PROPERTY_PRINT
:
640 return M_PROPERTY_ERROR
;
641 if (mpctx
->edl_muted
) {
642 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
643 return M_PROPERTY_OK
;
646 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
652 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
653 void *arg
, MPContext
* mpctx
)
655 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
656 return M_PROPERTY_UNAVAILABLE
;
659 case M_PROPERTY_STEP_UP
:
660 case M_PROPERTY_STEP_DOWN
: {
662 float delay
= audio_delay
;
663 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
664 if (ret
!= M_PROPERTY_OK
)
667 mpctx
->delay
-= audio_delay
- delay
;
669 return M_PROPERTY_OK
;
671 return m_property_delay(prop
, action
, arg
, &audio_delay
);
675 /// Audio codec tag (RO)
676 static int mp_property_audio_format(m_option_t
* prop
, int action
,
677 void *arg
, MPContext
* mpctx
)
679 if (!mpctx
->sh_audio
)
680 return M_PROPERTY_UNAVAILABLE
;
681 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
684 /// Audio codec name (RO)
685 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
686 void *arg
, MPContext
* mpctx
)
688 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
689 return M_PROPERTY_UNAVAILABLE
;
690 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
693 /// Audio bitrate (RO)
694 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
695 void *arg
, MPContext
* mpctx
)
697 if (!mpctx
->sh_audio
)
698 return M_PROPERTY_UNAVAILABLE
;
699 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
703 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
706 if (!mpctx
->sh_audio
)
707 return M_PROPERTY_UNAVAILABLE
;
709 case M_PROPERTY_PRINT
:
710 if(!arg
) return M_PROPERTY_ERROR
;
711 *(char**)arg
= malloc(16);
712 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
713 return M_PROPERTY_OK
;
715 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
718 /// Number of channels (RO)
719 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
722 if (!mpctx
->sh_audio
)
723 return M_PROPERTY_UNAVAILABLE
;
725 case M_PROPERTY_PRINT
:
727 return M_PROPERTY_ERROR
;
728 switch (mpctx
->sh_audio
->channels
) {
730 *(char **) arg
= strdup("mono");
733 *(char **) arg
= strdup("stereo");
736 *(char **) arg
= malloc(32);
737 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
739 return M_PROPERTY_OK
;
741 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
745 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
750 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
751 return M_PROPERTY_UNAVAILABLE
;
756 return M_PROPERTY_ERROR
;
757 mixer_getbalance(&mpctx
->mixer
, arg
);
758 return M_PROPERTY_OK
;
759 case M_PROPERTY_PRINT
: {
762 return M_PROPERTY_ERROR
;
763 mixer_getbalance(&mpctx
->mixer
, &bal
);
765 *str
= strdup("center");
766 else if (bal
== -1.f
)
767 *str
= strdup("left only");
769 *str
= strdup("right only");
771 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
772 *str
= malloc(sizeof("left xxx%, right xxx%"));
773 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
775 return M_PROPERTY_OK
;
777 case M_PROPERTY_STEP_UP
:
778 case M_PROPERTY_STEP_DOWN
:
779 mixer_getbalance(&mpctx
->mixer
, &bal
);
780 bal
+= (arg
? *(float*)arg
: .1f
) *
781 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
782 M_PROPERTY_CLAMP(prop
, bal
);
783 mixer_setbalance(&mpctx
->mixer
, bal
);
784 return M_PROPERTY_OK
;
787 return M_PROPERTY_ERROR
;
788 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
789 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
790 return M_PROPERTY_OK
;
792 return M_PROPERTY_NOT_IMPLEMENTED
;
795 /// Selected audio id (RW)
796 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
799 int current_id
= -1, tmp
;
803 if (!mpctx
->sh_audio
)
804 return M_PROPERTY_UNAVAILABLE
;
806 return M_PROPERTY_ERROR
;
807 *(int *) arg
= audio_id
;
808 return M_PROPERTY_OK
;
809 case M_PROPERTY_PRINT
:
810 if (!mpctx
->sh_audio
)
811 return M_PROPERTY_UNAVAILABLE
;
813 return M_PROPERTY_ERROR
;
816 *(char **) arg
= strdup(MSGTR_Disabled
);
818 char lang
[40] = MSGTR_Unknown
;
819 sh_audio_t
* sh
= mpctx
->sh_audio
;
821 av_strlcpy(lang
, sh
->lang
, 40);
822 #ifdef CONFIG_DVDREAD
823 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
824 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
834 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
835 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
837 *(char **) arg
= malloc(64);
838 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
840 return M_PROPERTY_OK
;
842 case M_PROPERTY_STEP_UP
:
845 return M_PROPERTY_UNAVAILABLE
;
846 if (action
== M_PROPERTY_SET
&& arg
)
847 tmp
= *((int *) arg
);
850 current_id
= mpctx
->demuxer
->audio
->id
;
851 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
854 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
855 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
856 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
858 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
860 sh2
->ds
= mpctx
->demuxer
->audio
;
861 mpctx
->sh_audio
= sh2
;
862 reinit_audio_chain();
865 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
866 return M_PROPERTY_OK
;
868 return M_PROPERTY_NOT_IMPLEMENTED
;
873 /// Selected video id (RW)
874 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
877 int current_id
= -1, tmp
;
881 if (!mpctx
->sh_video
)
882 return M_PROPERTY_UNAVAILABLE
;
884 return M_PROPERTY_ERROR
;
885 *(int *) arg
= video_id
;
886 return M_PROPERTY_OK
;
887 case M_PROPERTY_PRINT
:
888 if (!mpctx
->sh_video
)
889 return M_PROPERTY_UNAVAILABLE
;
891 return M_PROPERTY_ERROR
;
894 *(char **) arg
= strdup(MSGTR_Disabled
);
896 char lang
[40] = MSGTR_Unknown
;
897 *(char **) arg
= malloc(64);
898 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
900 return M_PROPERTY_OK
;
902 case M_PROPERTY_STEP_UP
:
904 current_id
= mpctx
->demuxer
->video
->id
;
905 if (action
== M_PROPERTY_SET
&& arg
)
906 tmp
= *((int *) arg
);
909 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
911 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
912 && current_id
!= -2))
913 uninit_player(INITIALIZED_VCODEC
|
914 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
915 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
917 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
919 sh2
->ds
= mpctx
->demuxer
->video
;
920 mpctx
->sh_video
= sh2
;
921 reinit_video_chain();
924 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
925 return M_PROPERTY_OK
;
928 return M_PROPERTY_NOT_IMPLEMENTED
;
932 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
935 demux_program_t prog
;
938 case M_PROPERTY_STEP_UP
:
940 if (action
== M_PROPERTY_SET
&& arg
)
941 prog
.progid
= *((int *) arg
);
945 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
946 &prog
) == DEMUXER_CTRL_NOTIMPL
)
947 return M_PROPERTY_ERROR
;
949 if (prog
.aid
< 0 && prog
.vid
< 0) {
950 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
951 return M_PROPERTY_ERROR
;
953 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
954 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
955 return M_PROPERTY_OK
;
958 return M_PROPERTY_NOT_IMPLEMENTED
;
964 /// \defgroup VideoProperties Video properties
965 /// \ingroup Properties
968 /// Fullscreen state (RW)
969 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
973 if (!mpctx
->video_out
)
974 return M_PROPERTY_UNAVAILABLE
;
979 return M_PROPERTY_ERROR
;
980 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
981 if (vo_fs
== !!*(int *) arg
)
982 return M_PROPERTY_OK
;
983 case M_PROPERTY_STEP_UP
:
984 case M_PROPERTY_STEP_DOWN
:
987 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
991 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
992 return M_PROPERTY_OK
;
994 return m_property_flag(prop
, action
, arg
, &vo_fs
);
998 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
999 void *arg
, MPContext
* mpctx
)
1003 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1004 return M_PROPERTY_UNAVAILABLE
;
1005 vf
= mpctx
->sh_video
->vfilter
;
1007 case M_PROPERTY_GET
:
1009 return M_PROPERTY_ERROR
;
1010 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1011 return M_PROPERTY_OK
;
1012 case M_PROPERTY_SET
:
1014 return M_PROPERTY_ERROR
;
1015 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1016 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1017 return M_PROPERTY_OK
;
1018 case M_PROPERTY_STEP_UP
:
1019 case M_PROPERTY_STEP_DOWN
:
1020 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1021 deinterlace
= !deinterlace
;
1022 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1023 return M_PROPERTY_OK
;
1025 return M_PROPERTY_NOT_IMPLEMENTED
;
1029 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1033 if (!mpctx
->video_out
1034 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1035 return M_PROPERTY_UNAVAILABLE
;
1038 case M_PROPERTY_SET
:
1040 return M_PROPERTY_ERROR
;
1041 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1042 vo_panscan
= *(float *) arg
;
1043 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1044 return M_PROPERTY_OK
;
1045 case M_PROPERTY_STEP_UP
:
1046 case M_PROPERTY_STEP_DOWN
:
1047 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1048 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1051 else if (vo_panscan
< 0)
1053 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1054 return M_PROPERTY_OK
;
1056 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1060 /// Helper to set vo flags.
1061 /** \ingroup PropertyImplHelper
1063 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1064 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1067 if (!mpctx
->video_out
)
1068 return M_PROPERTY_UNAVAILABLE
;
1071 case M_PROPERTY_SET
:
1073 return M_PROPERTY_ERROR
;
1074 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1075 if (*vo_var
== !!*(int *) arg
)
1076 return M_PROPERTY_OK
;
1077 case M_PROPERTY_STEP_UP
:
1078 case M_PROPERTY_STEP_DOWN
:
1079 if (vo_config_count
)
1080 mpctx
->video_out
->control(vo_ctrl
, 0);
1081 return M_PROPERTY_OK
;
1083 return m_property_flag(prop
, action
, arg
, vo_var
);
1087 /// Window always on top (RW)
1088 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1091 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1095 /// Display in the root window (RW)
1096 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1099 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1100 &vo_rootwin
, mpctx
);
1103 /// Show window borders (RW)
1104 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1107 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1111 /// Framedropping state (RW)
1112 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1113 void *arg
, MPContext
* mpctx
)
1116 if (!mpctx
->sh_video
)
1117 return M_PROPERTY_UNAVAILABLE
;
1120 case M_PROPERTY_PRINT
:
1122 return M_PROPERTY_ERROR
;
1123 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1124 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1126 return M_PROPERTY_OK
;
1128 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1132 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1133 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1136 int *gamma
= prop
->priv
, r
, val
;
1138 if (!mpctx
->sh_video
)
1139 return M_PROPERTY_UNAVAILABLE
;
1141 if (gamma
[0] == 1000) {
1143 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1147 case M_PROPERTY_SET
:
1149 return M_PROPERTY_ERROR
;
1150 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1151 *gamma
= *(int *) arg
;
1152 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1156 case M_PROPERTY_GET
:
1157 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1159 return M_PROPERTY_ERROR
;
1161 return M_PROPERTY_OK
;
1164 case M_PROPERTY_STEP_UP
:
1165 case M_PROPERTY_STEP_DOWN
:
1166 *gamma
+= (arg
? *(int *) arg
: 1) *
1167 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1168 M_PROPERTY_CLAMP(prop
, *gamma
);
1169 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1174 return M_PROPERTY_NOT_IMPLEMENTED
;
1178 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1179 int l
= strlen(prop
->name
);
1180 char tv_prop
[3 + l
+ 1];
1181 sprintf(tv_prop
, "tv_%s", prop
->name
);
1182 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1186 return M_PROPERTY_UNAVAILABLE
;
1190 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1193 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1196 /// Video codec tag (RO)
1197 static int mp_property_video_format(m_option_t
* prop
, int action
,
1198 void *arg
, MPContext
* mpctx
)
1201 if (!mpctx
->sh_video
)
1202 return M_PROPERTY_UNAVAILABLE
;
1204 case M_PROPERTY_PRINT
:
1206 return M_PROPERTY_ERROR
;
1207 switch(mpctx
->sh_video
->format
) {
1209 meta
= strdup ("mpeg1"); break;
1211 meta
= strdup ("mpeg2"); break;
1213 meta
= strdup ("mpeg4"); break;
1215 meta
= strdup ("h264"); break;
1217 if(mpctx
->sh_video
->format
>= 0x20202020) {
1219 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1222 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1225 *(char**)arg
= meta
;
1226 return M_PROPERTY_OK
;
1228 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1231 /// Video codec name (RO)
1232 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1233 void *arg
, MPContext
* mpctx
)
1235 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1236 return M_PROPERTY_UNAVAILABLE
;
1237 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1241 /// Video bitrate (RO)
1242 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1243 void *arg
, MPContext
* mpctx
)
1245 if (!mpctx
->sh_video
)
1246 return M_PROPERTY_UNAVAILABLE
;
1247 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1250 /// Video display width (RO)
1251 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1254 if (!mpctx
->sh_video
)
1255 return M_PROPERTY_UNAVAILABLE
;
1256 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1259 /// Video display height (RO)
1260 static int mp_property_height(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_h
);
1269 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1272 if (!mpctx
->sh_video
)
1273 return M_PROPERTY_UNAVAILABLE
;
1274 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1277 /// Video aspect (RO)
1278 static int mp_property_aspect(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
->aspect
);
1288 /// \defgroup SubProprties Subtitles properties
1289 /// \ingroup Properties
1292 /// Text subtitle position (RW)
1293 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1296 if (!mpctx
->sh_video
)
1297 return M_PROPERTY_UNAVAILABLE
;
1300 case M_PROPERTY_SET
:
1302 return M_PROPERTY_ERROR
;
1303 case M_PROPERTY_STEP_UP
:
1304 case M_PROPERTY_STEP_DOWN
:
1305 vo_osd_changed(OSDTYPE_SUBTITLE
);
1307 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1311 /// Selected subtitles (RW)
1312 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1315 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1316 const int global_sub_size
= mpctx
->global_sub_size
;
1317 int source
= -1, reset_spu
= 0;
1321 if (global_sub_size
<= 0)
1322 return M_PROPERTY_UNAVAILABLE
;
1325 case M_PROPERTY_GET
:
1327 return M_PROPERTY_ERROR
;
1328 *(int *) arg
= mpctx
->global_sub_pos
;
1329 return M_PROPERTY_OK
;
1330 case M_PROPERTY_PRINT
:
1332 return M_PROPERTY_ERROR
;
1333 *(char **) arg
= malloc(64);
1334 (*(char **) arg
)[63] = 0;
1337 sub_name
= subdata
->filename
;
1339 if (ass_track
&& ass_track
->name
)
1340 sub_name
= ass_track
->name
;
1345 if ((tmp2
= strrchr(tmp
, '/')))
1348 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1349 mpctx
->set_of_sub_pos
+ 1,
1350 strlen(tmp
) < 20 ? "" : "...",
1351 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1352 return M_PROPERTY_OK
;
1354 #ifdef CONFIG_DVDNAV
1355 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1356 if (vo_spudec
&& dvdsub_id
>= 0) {
1357 unsigned char lang
[3];
1358 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1359 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1360 return M_PROPERTY_OK
;
1366 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1367 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1368 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1369 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1370 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1371 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1372 if (!lang
) lang
= MSGTR_Unknown
;
1373 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1374 return M_PROPERTY_OK
;
1377 if (vo_vobsub
&& vobsub_id
>= 0) {
1378 const char *language
= MSGTR_Unknown
;
1379 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1380 snprintf(*(char **) arg
, 63, "(%d) %s",
1381 vobsub_id
, language
? language
: MSGTR_Unknown
);
1382 return M_PROPERTY_OK
;
1384 #ifdef CONFIG_DVDREAD
1385 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1386 && dvdsub_id
>= 0) {
1388 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1389 lang
[0] = code
>> 8;
1392 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1393 return M_PROPERTY_OK
;
1396 if (dvdsub_id
>= 0) {
1397 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1398 return M_PROPERTY_OK
;
1400 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1401 return M_PROPERTY_OK
;
1403 case M_PROPERTY_SET
:
1405 return M_PROPERTY_ERROR
;
1406 if (*(int *) arg
< -1)
1408 else if (*(int *) arg
>= global_sub_size
)
1409 *(int *) arg
= global_sub_size
- 1;
1410 mpctx
->global_sub_pos
= *(int *) arg
;
1412 case M_PROPERTY_STEP_UP
:
1413 mpctx
->global_sub_pos
+= 2;
1414 mpctx
->global_sub_pos
=
1415 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1417 case M_PROPERTY_STEP_DOWN
:
1418 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1419 mpctx
->global_sub_pos
=
1420 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1423 return M_PROPERTY_NOT_IMPLEMENTED
;
1426 if (mpctx
->global_sub_pos
>= 0)
1427 source
= sub_source(mpctx
);
1429 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1430 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1432 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1433 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1434 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1435 mpctx
->global_sub_pos
, source
);
1437 mpctx
->set_of_sub_pos
= -1;
1451 if (source
== SUB_SOURCE_VOBSUB
) {
1452 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1453 } else if (source
== SUB_SOURCE_SUBS
) {
1454 mpctx
->set_of_sub_pos
=
1455 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1457 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1458 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1462 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1463 vo_osd_changed(OSDTYPE_SUBTITLE
);
1465 } else if (source
== SUB_SOURCE_DEMUX
) {
1467 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1468 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1470 // default: assume 1:1 mapping of sid and stream id
1471 d_sub
->id
= dvdsub_id
;
1472 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1473 ds_free_packs(d_sub
);
1474 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1475 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1476 if (sh
&& sh
->sid
== dvdsub_id
) {
1482 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1483 sh_sub_t
*sh
= d_sub
->sh
;
1484 if (sh
->type
== 'v')
1487 else if (ass_enabled
)
1488 ass_track
= sh
->ass_track
;
1496 #ifdef CONFIG_DVDREAD
1498 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1499 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1500 && dvdsub_id
< 0 && reset_spu
) {
1502 d_sub
->id
= dvdsub_id
;
1505 if (mpctx
->sh_audio
)
1506 pts
= mpctx
->sh_audio
->pts
;
1507 if (mpctx
->sh_video
)
1508 pts
= mpctx
->sh_video
->pts
;
1509 update_subtitles(mpctx
->sh_video
, pts
, d_sub
, 1);
1511 return M_PROPERTY_OK
;
1514 /// Selected sub source (RW)
1515 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1519 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1520 return M_PROPERTY_UNAVAILABLE
;
1523 case M_PROPERTY_GET
:
1525 return M_PROPERTY_ERROR
;
1526 *(int *) arg
= sub_source(mpctx
);
1527 return M_PROPERTY_OK
;
1528 case M_PROPERTY_PRINT
:
1530 return M_PROPERTY_ERROR
;
1531 *(char **) arg
= malloc(64);
1532 (*(char **) arg
)[63] = 0;
1533 switch (sub_source(mpctx
))
1535 case SUB_SOURCE_SUBS
:
1536 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1538 case SUB_SOURCE_VOBSUB
:
1539 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1541 case SUB_SOURCE_DEMUX
:
1542 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1545 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1547 return M_PROPERTY_OK
;
1548 case M_PROPERTY_SET
:
1550 return M_PROPERTY_ERROR
;
1551 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1552 if (*(int *) arg
< 0)
1553 mpctx
->global_sub_pos
= -1;
1554 else if (*(int *) arg
!= sub_source(mpctx
)) {
1555 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1556 return M_PROPERTY_UNAVAILABLE
;
1557 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1560 case M_PROPERTY_STEP_UP
:
1561 case M_PROPERTY_STEP_DOWN
: {
1562 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1563 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1564 int step
= (step_all
> 0) ? 1 : -1;
1565 int cur_source
= sub_source(mpctx
);
1566 source
= cur_source
;
1569 if (source
>= SUB_SOURCES
)
1571 else if (source
< -1)
1572 source
= SUB_SOURCES
- 1;
1573 if (source
== cur_source
|| source
== -1 ||
1574 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1577 if (source
== cur_source
)
1578 return M_PROPERTY_OK
;
1580 mpctx
->global_sub_pos
= -1;
1582 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1586 return M_PROPERTY_NOT_IMPLEMENTED
;
1588 --mpctx
->global_sub_pos
;
1589 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1592 /// Selected subtitles from specific source (RW)
1593 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1596 int source
, is_cur_source
, offset
;
1597 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1598 return M_PROPERTY_UNAVAILABLE
;
1600 if (!strcmp(prop
->name
, "sub_file"))
1601 source
= SUB_SOURCE_SUBS
;
1602 else if (!strcmp(prop
->name
, "sub_vob"))
1603 source
= SUB_SOURCE_VOBSUB
;
1604 else if (!strcmp(prop
->name
, "sub_demux"))
1605 source
= SUB_SOURCE_DEMUX
;
1607 return M_PROPERTY_ERROR
;
1609 offset
= mpctx
->global_sub_indices
[source
];
1610 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1611 return M_PROPERTY_UNAVAILABLE
;
1613 is_cur_source
= sub_source(mpctx
) == source
;
1615 case M_PROPERTY_GET
:
1617 return M_PROPERTY_ERROR
;
1618 if (is_cur_source
) {
1619 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1620 if (source
== SUB_SOURCE_VOBSUB
)
1621 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1625 return M_PROPERTY_OK
;
1626 case M_PROPERTY_PRINT
:
1628 return M_PROPERTY_ERROR
;
1630 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1631 *(char **) arg
= malloc(64);
1632 (*(char **) arg
)[63] = 0;
1633 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1634 return M_PROPERTY_OK
;
1635 case M_PROPERTY_SET
:
1637 return M_PROPERTY_ERROR
;
1638 if (*(int *) arg
>= 0) {
1639 int index
= *(int *)arg
;
1640 if (source
== SUB_SOURCE_VOBSUB
)
1641 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1642 mpctx
->global_sub_pos
= offset
+ index
;
1643 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1644 || sub_source(mpctx
) != source
) {
1645 mpctx
->global_sub_pos
= -1;
1650 mpctx
->global_sub_pos
= -1;
1652 case M_PROPERTY_STEP_UP
:
1653 case M_PROPERTY_STEP_DOWN
: {
1654 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1655 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1656 int step
= (step_all
> 0) ? 1 : -1;
1657 int max_sub_pos_for_source
= -1;
1659 mpctx
->global_sub_pos
= -1;
1661 if (mpctx
->global_sub_pos
== -1) {
1663 mpctx
->global_sub_pos
= offset
;
1664 else if (max_sub_pos_for_source
== -1) {
1665 // Find max pos for specific source
1666 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1667 while (mpctx
->global_sub_pos
>= 0
1668 && sub_source(mpctx
) != source
)
1669 --mpctx
->global_sub_pos
;
1672 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1675 mpctx
->global_sub_pos
+= step
;
1676 if (mpctx
->global_sub_pos
< offset
||
1677 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1678 sub_source(mpctx
) != source
)
1679 mpctx
->global_sub_pos
= -1;
1686 return M_PROPERTY_NOT_IMPLEMENTED
;
1688 --mpctx
->global_sub_pos
;
1689 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1692 /// Subtitle delay (RW)
1693 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1696 if (!mpctx
->sh_video
)
1697 return M_PROPERTY_UNAVAILABLE
;
1698 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1701 /// Alignment of text subtitles (RW)
1702 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1703 void *arg
, MPContext
* mpctx
)
1705 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1707 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1708 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1709 return M_PROPERTY_UNAVAILABLE
;
1712 case M_PROPERTY_PRINT
:
1714 return M_PROPERTY_ERROR
;
1715 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1716 *(char **) arg
= strdup(name
[sub_alignment
]);
1717 return M_PROPERTY_OK
;
1718 case M_PROPERTY_SET
:
1720 return M_PROPERTY_ERROR
;
1721 case M_PROPERTY_STEP_UP
:
1722 case M_PROPERTY_STEP_DOWN
:
1723 vo_osd_changed(OSDTYPE_SUBTITLE
);
1725 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1729 /// Subtitle visibility (RW)
1730 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1731 void *arg
, MPContext
* mpctx
)
1733 if (!mpctx
->sh_video
)
1734 return M_PROPERTY_UNAVAILABLE
;
1737 case M_PROPERTY_SET
:
1739 return M_PROPERTY_ERROR
;
1740 case M_PROPERTY_STEP_UP
:
1741 case M_PROPERTY_STEP_DOWN
:
1742 vo_osd_changed(OSDTYPE_SUBTITLE
);
1744 vo_osd_changed(OSDTYPE_SPU
);
1746 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1751 /// Use margins for libass subtitles (RW)
1752 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1753 void *arg
, MPContext
* mpctx
)
1755 if (!mpctx
->sh_video
)
1756 return M_PROPERTY_UNAVAILABLE
;
1759 case M_PROPERTY_SET
:
1761 return M_PROPERTY_ERROR
;
1762 case M_PROPERTY_STEP_UP
:
1763 case M_PROPERTY_STEP_DOWN
:
1764 ass_force_reload
= 1;
1766 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1771 /// Show only forced subtitles (RW)
1772 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1773 void *arg
, MPContext
* mpctx
)
1776 return M_PROPERTY_UNAVAILABLE
;
1779 case M_PROPERTY_SET
:
1781 return M_PROPERTY_ERROR
;
1782 case M_PROPERTY_STEP_UP
:
1783 case M_PROPERTY_STEP_DOWN
:
1784 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1785 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1786 return M_PROPERTY_OK
;
1788 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1793 #ifdef CONFIG_FREETYPE
1794 /// Subtitle scale (RW)
1795 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1800 case M_PROPERTY_SET
:
1802 return M_PROPERTY_ERROR
;
1803 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1806 ass_font_scale
= *(float *) arg
;
1807 ass_force_reload
= 1;
1810 text_font_scale_factor
= *(float *) arg
;
1811 force_load_font
= 1;
1812 return M_PROPERTY_OK
;
1813 case M_PROPERTY_STEP_UP
:
1814 case M_PROPERTY_STEP_DOWN
:
1817 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1818 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1819 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1820 ass_force_reload
= 1;
1823 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1824 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1825 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1826 force_load_font
= 1;
1827 return M_PROPERTY_OK
;
1831 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1834 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1841 /// \defgroup TVProperties TV properties
1842 /// \ingroup Properties
1847 /// TV color settings (RW)
1848 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1852 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1853 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1854 return M_PROPERTY_UNAVAILABLE
;
1857 case M_PROPERTY_SET
:
1859 return M_PROPERTY_ERROR
;
1860 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1861 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1862 case M_PROPERTY_GET
:
1863 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1864 case M_PROPERTY_STEP_UP
:
1865 case M_PROPERTY_STEP_DOWN
:
1866 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1868 return M_PROPERTY_ERROR
;
1869 val
+= (arg
? *(int *) arg
: 1) *
1870 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1871 M_PROPERTY_CLAMP(prop
, val
);
1872 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1874 return M_PROPERTY_ERROR
;
1876 return M_PROPERTY_NOT_IMPLEMENTED
;
1881 #ifdef CONFIG_TV_TELETEXT
1882 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1886 int base_ioctl
=(int)prop
->priv
;
1888 for teletext's GET,SET,STEP ioctls this is not 0
1892 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1893 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1894 return M_PROPERTY_UNAVAILABLE
;
1896 return M_PROPERTY_ERROR
;
1899 case M_PROPERTY_GET
:
1901 return M_PROPERTY_ERROR
;
1902 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1904 case M_PROPERTY_SET
:
1906 return M_PROPERTY_ERROR
;
1907 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1908 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1910 case M_PROPERTY_STEP_UP
:
1911 case M_PROPERTY_STEP_DOWN
:
1912 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1913 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1914 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1917 return M_PROPERTY_NOT_IMPLEMENTED
;
1920 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1923 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1926 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1930 //with tvh==NULL will fail too
1931 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1932 if(result
!=M_PROPERTY_OK
)
1935 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1936 mp_input_set_section("teletext");
1938 mp_input_set_section("tv");
1939 return M_PROPERTY_OK
;
1942 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1945 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1948 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1949 return M_PROPERTY_UNAVAILABLE
;
1951 case M_PROPERTY_STEP_UP
:
1952 case M_PROPERTY_STEP_DOWN
:
1953 //This should be handled separately
1954 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1955 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1958 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1964 #endif /* CONFIG_TV_TELETEXT */
1968 /// All properties available in MPlayer.
1969 /** \ingroup Properties
1971 static const m_option_t mp_properties
[] = {
1973 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1974 M_OPT_RANGE
, 0, 3, NULL
},
1975 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1976 M_OPT_MIN
, -1, 0, NULL
},
1977 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1978 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1979 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1981 { "path", mp_property_path
, CONF_TYPE_STRING
,
1983 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1985 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1986 M_OPT_MIN
, 0, 0, NULL
},
1987 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1988 M_OPT_MIN
, 0, 0, NULL
},
1989 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1990 M_OPT_MIN
, 0, 0, NULL
},
1991 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1992 M_OPT_MIN
, 0, 0, NULL
},
1993 { "length", mp_property_length
, CONF_TYPE_TIME
,
1994 M_OPT_MIN
, 0, 0, NULL
},
1995 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1996 M_OPT_RANGE
, 0, 100, NULL
},
1997 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1998 M_OPT_MIN
, 0, 0, NULL
},
1999 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2000 M_OPT_MIN
, 0, 0, NULL
},
2001 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2003 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2004 CONF_RANGE
, -2, 10, NULL
},
2005 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2007 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2008 M_OPT_RANGE
, 0, 1, NULL
},
2011 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2012 M_OPT_RANGE
, 0, 100, NULL
},
2013 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2014 M_OPT_RANGE
, 0, 1, NULL
},
2015 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2016 M_OPT_RANGE
, -100, 100, NULL
},
2017 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2019 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2021 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2023 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2025 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2027 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2028 CONF_RANGE
, -2, 65535, NULL
},
2029 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2030 M_OPT_RANGE
, -1, 1, NULL
},
2033 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2034 M_OPT_RANGE
, 0, 1, NULL
},
2035 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2036 M_OPT_RANGE
, 0, 1, NULL
},
2037 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2038 M_OPT_RANGE
, 0, 1, NULL
},
2039 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2040 M_OPT_RANGE
, 0, 1, NULL
},
2041 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2042 M_OPT_RANGE
, 0, 1, NULL
},
2043 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2044 M_OPT_RANGE
, 0, 2, NULL
},
2045 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2046 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2047 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2048 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2049 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2050 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2051 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2052 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2053 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2054 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2055 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2056 M_OPT_RANGE
, 0, 1, NULL
},
2057 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2058 M_OPT_RANGE
, 0, 1, NULL
},
2059 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2061 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2063 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2065 { "width", mp_property_width
, CONF_TYPE_INT
,
2067 { "height", mp_property_height
, CONF_TYPE_INT
,
2069 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2071 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2073 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2074 CONF_RANGE
, -2, 65535, NULL
},
2075 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2076 CONF_RANGE
, -1, 65535, NULL
},
2079 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2080 M_OPT_MIN
, -1, 0, NULL
},
2081 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2082 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2083 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2084 M_OPT_MIN
, -1, 0, NULL
},
2085 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2086 M_OPT_MIN
, -1, 0, NULL
},
2087 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2088 M_OPT_MIN
, -1, 0, NULL
},
2089 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2091 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2092 M_OPT_RANGE
, 0, 100, NULL
},
2093 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2094 M_OPT_RANGE
, 0, 2, NULL
},
2095 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2096 M_OPT_RANGE
, 0, 1, NULL
},
2097 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2098 M_OPT_RANGE
, 0, 1, NULL
},
2099 #ifdef CONFIG_FREETYPE
2100 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2101 M_OPT_RANGE
, 0, 100, NULL
},
2104 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2105 M_OPT_RANGE
, 0, 1, NULL
},
2109 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2110 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2111 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2112 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2113 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2114 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2115 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2116 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2119 #ifdef CONFIG_TV_TELETEXT
2120 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2121 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2122 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2123 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2124 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2125 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2126 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2127 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2128 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2129 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2132 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2136 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2138 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2141 char* mp_property_print(const char *name
, void* ctx
)
2144 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2149 char *property_expand_string(MPContext
* mpctx
, char *str
)
2151 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2154 void property_print_help(void)
2156 m_properties_print_help_list(mp_properties
);
2165 * \defgroup Command2Property Command to property bridge
2167 * It is used to handle most commands that just set a property
2168 * and optionally display something on the OSD.
2169 * Two kinds of commands are handled: adjust or toggle.
2171 * Adjust commands take 1 or 2 parameters: <value> <abs>
2172 * If <abs> is non-zero the property is set to the given value
2173 * otherwise it is adjusted.
2175 * Toggle commands take 0 or 1 parameters. With no parameter
2176 * or a value less than the property minimum it just steps the
2177 * property to its next value. Otherwise it sets it to the given
2183 /// List of the commands that can be handled by setting a property.
2189 /// set/adjust or toggle command
2191 /// progressbar type
2193 /// osd msg id if it must be shared
2195 /// osd msg template
2196 const char *osd_msg
;
2197 } set_prop_cmd
[] = {
2199 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2200 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2201 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2203 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2204 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2205 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2206 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2207 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2209 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2210 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2211 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2212 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2213 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2214 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2215 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2216 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2217 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2218 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2219 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2220 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2222 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2223 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2224 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2225 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2226 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2227 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2228 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2229 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2230 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2231 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2232 #ifdef CONFIG_FREETYPE
2233 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2236 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2239 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2240 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2241 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2242 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2244 { NULL
, 0, 0, 0, -1, NULL
}
2248 /// Handle commands that set a property.
2249 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2255 // look for the command
2256 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2257 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2259 if (!(pname
= set_prop_cmd
[i
].name
))
2262 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2266 if (set_prop_cmd
[i
].toggle
) {
2268 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2269 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2271 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2272 } else if (cmd
->args
[1].v
.i
) //set
2273 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2275 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2280 if (set_prop_cmd
[i
].osd_progbar
) {
2281 if (prop
->type
== CONF_TYPE_INT
) {
2282 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2283 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2284 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2285 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2287 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2288 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2289 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2291 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2292 "Property use an unsupported type.\n");
2296 if (set_prop_cmd
[i
].osd_msg
) {
2297 char *val
= mp_property_print(pname
, mpctx
);
2299 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2300 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2301 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2308 #ifdef CONFIG_DVDNAV
2309 static const struct {
2311 const mp_command_type cmd
;
2312 } mp_dvdnav_bindings
[] = {
2313 { "up", MP_CMD_DVDNAV_UP
},
2314 { "down", MP_CMD_DVDNAV_DOWN
},
2315 { "left", MP_CMD_DVDNAV_LEFT
},
2316 { "right", MP_CMD_DVDNAV_RIGHT
},
2317 { "menu", MP_CMD_DVDNAV_MENU
},
2318 { "select", MP_CMD_DVDNAV_SELECT
},
2319 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2320 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2323 * keep old dvdnav sub-command options for a while in order not to
2324 * break slave-mode API too suddenly.
2326 { "1", MP_CMD_DVDNAV_UP
},
2327 { "2", MP_CMD_DVDNAV_DOWN
},
2328 { "3", MP_CMD_DVDNAV_LEFT
},
2329 { "4", MP_CMD_DVDNAV_RIGHT
},
2330 { "5", MP_CMD_DVDNAV_MENU
},
2331 { "6", MP_CMD_DVDNAV_SELECT
},
2332 { "7", MP_CMD_DVDNAV_PREVMENU
},
2333 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2338 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2340 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2341 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2343 if (!set_property_command(mpctx
, cmd
))
2349 mpctx
->osd_show_percentage
= sh_video
->fps
;
2350 v
= cmd
->args
[0].v
.f
;
2351 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2352 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2353 abs_seek_pos
= SEEK_ABSOLUTE
;
2355 mpctx
->osd_function
=
2356 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2358 } else if (abs
) { /* Absolute seek by percentage */
2359 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2361 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2362 rel_seek_secs
= v
/ 100.0;
2365 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2371 case MP_CMD_SET_PROPERTY
:{
2372 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2373 cmd
->args
[1].v
.s
, mpctx
);
2374 if (r
== M_PROPERTY_UNKNOWN
)
2375 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2376 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2378 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2379 "Failed to set property '%s' to '%s'.\n",
2380 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2384 case MP_CMD_STEP_PROPERTY
:{
2389 if (cmd
->args
[1].v
.f
) {
2391 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2392 M_PROPERTY_GET_TYPE
,
2393 &prop
, mpctx
)) <= 0)
2395 if(prop
->type
== CONF_TYPE_INT
||
2396 prop
->type
== CONF_TYPE_FLAG
)
2397 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2398 else if(prop
->type
== CONF_TYPE_FLOAT
)
2399 arg
= &cmd
->args
[1].v
.f
;
2400 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2401 prop
->type
== CONF_TYPE_TIME
)
2402 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2403 else if(prop
->type
== CONF_TYPE_POSITION
)
2404 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2406 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2407 "Ignoring step size stepping property '%s'.\n",
2410 r
= mp_property_do(cmd
->args
[0].v
.s
,
2411 cmd
->args
[2].v
.i
< 0 ?
2412 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2415 if (r
== M_PROPERTY_UNKNOWN
)
2416 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2417 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2419 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2420 "Failed to increment property '%s' by %f.\n",
2421 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2425 case MP_CMD_GET_PROPERTY
:{
2427 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2428 &tmp
, mpctx
) <= 0) {
2429 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2430 "Failed to get value of property '%s'.\n",
2434 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2435 cmd
->args
[0].v
.s
, tmp
);
2440 case MP_CMD_EDL_MARK
:
2442 float v
= sh_video
? sh_video
->pts
:
2443 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2446 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2447 mpctx
->begin_skip
= v
;
2448 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2450 if (mpctx
->begin_skip
> v
)
2451 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2453 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2454 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2456 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2461 case MP_CMD_SWITCH_RATIO
:
2464 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2465 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2467 movie_aspect
= cmd
->args
[0].v
.f
;
2468 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2471 case MP_CMD_SPEED_INCR
:{
2472 float v
= cmd
->args
[0].v
.f
;
2473 playback_speed
+= v
;
2474 build_afilter_chain(sh_audio
, &ao_data
);
2475 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2479 case MP_CMD_SPEED_MULT
:{
2480 float v
= cmd
->args
[0].v
.f
;
2481 playback_speed
*= v
;
2482 build_afilter_chain(sh_audio
, &ao_data
);
2483 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2487 case MP_CMD_SPEED_SET
:{
2488 float v
= cmd
->args
[0].v
.f
;
2490 build_afilter_chain(sh_audio
, &ao_data
);
2491 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2495 case MP_CMD_FRAME_STEP
:
2501 case MP_CMD_FILE_FILTER
:
2502 file_filter
= cmd
->args
[0].v
.i
;
2506 exit_player_with_rc(EXIT_QUIT
,
2507 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2509 case MP_CMD_PLAY_TREE_STEP
:{
2510 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2511 int force
= cmd
->args
[1].v
.i
;
2517 for (i
= 0; i
< n
; i
++)
2520 for (i
= 0; i
< -1 * n
; i
++)
2525 if (!force
&& mpctx
->playtree_iter
) {
2526 play_tree_iter_t
*i
=
2527 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2528 if (play_tree_iter_step(i
, n
, 0) ==
2529 PLAY_TREE_ITER_ENTRY
)
2531 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2532 play_tree_iter_free(i
);
2534 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2536 mpctx
->play_tree_step
= n
;
2542 case MP_CMD_PLAY_TREE_UP_STEP
:{
2543 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2544 int force
= cmd
->args
[1].v
.i
;
2546 if (!force
&& mpctx
->playtree_iter
) {
2547 play_tree_iter_t
*i
=
2548 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2549 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2550 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2551 play_tree_iter_free(i
);
2553 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2558 case MP_CMD_PLAY_ALT_SRC_STEP
:
2559 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2560 int v
= cmd
->args
[0].v
.i
;
2562 && mpctx
->playtree_iter
->file
<
2563 mpctx
->playtree_iter
->num_files
)
2564 mpctx
->eof
= PT_NEXT_SRC
;
2565 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2566 mpctx
->eof
= PT_PREV_SRC
;
2571 case MP_CMD_SUB_STEP
:
2573 int movement
= cmd
->args
[0].v
.i
;
2574 step_sub(subdata
, sh_video
->pts
, movement
);
2578 ass_step_sub(ass_track
,
2580 sub_delay
) * 1000 + .5, movement
) / 1000.;
2582 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2583 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2587 case MP_CMD_SUB_LOG
:
2592 int v
= cmd
->args
[0].v
.i
;
2594 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2595 if (osd_level
> max
)
2598 osd_level
= (osd_level
+ 1) % (max
+ 1);
2600 osd_level
= v
> max
? max
: v
;
2601 /* Show OSD state when disabled, but not when an explicit
2602 argument is given to the OSD command, i.e. in slave mode. */
2603 if (v
== -1 && osd_level
<= 1)
2604 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2606 osd_level
? MSGTR_OSDenabled
:
2609 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2613 case MP_CMD_OSD_SHOW_TEXT
:
2614 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2616 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2617 "%-.63s", cmd
->args
[0].v
.s
);
2620 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2621 char *txt
= m_properties_expand_string(mp_properties
,
2624 /* if no argument supplied take default osd_duration, else <arg> ms. */
2626 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2628 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2635 case MP_CMD_LOADFILE
:{
2636 play_tree_t
*e
= play_tree_new();
2637 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2639 if (cmd
->args
[1].v
.i
) // append
2640 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2642 // Go back to the starting point.
2643 while (play_tree_iter_up_step
2644 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2646 play_tree_free_list(mpctx
->playtree
->child
, 1);
2647 play_tree_set_child(mpctx
->playtree
, e
);
2648 pt_iter_goto_head(mpctx
->playtree_iter
);
2649 mpctx
->eof
= PT_NEXT_SRC
;
2655 case MP_CMD_LOADLIST
:{
2656 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2658 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2659 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2661 if (cmd
->args
[1].v
.i
) // append
2662 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2664 // Go back to the starting point.
2665 while (play_tree_iter_up_step
2666 (mpctx
->playtree_iter
, 0, 1)
2667 != PLAY_TREE_ITER_END
)
2669 play_tree_free_list(mpctx
->playtree
->child
, 1);
2670 play_tree_set_child(mpctx
->playtree
, e
);
2671 pt_iter_goto_head(mpctx
->playtree_iter
);
2672 mpctx
->eof
= PT_NEXT_SRC
;
2680 // Go back to the starting point.
2681 while (play_tree_iter_up_step
2682 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2684 mpctx
->eof
= PT_STOP
;
2689 case MP_CMD_RADIO_STEP_CHANNEL
:
2690 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2691 int v
= cmd
->args
[0].v
.i
;
2693 radio_step_channel(mpctx
->demuxer
->stream
,
2694 RADIO_CHANNEL_HIGHER
);
2696 radio_step_channel(mpctx
->demuxer
->stream
,
2697 RADIO_CHANNEL_LOWER
);
2698 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2699 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2701 radio_get_channel_name(mpctx
->demuxer
->stream
));
2706 case MP_CMD_RADIO_SET_CHANNEL
:
2707 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2708 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2709 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2710 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2712 radio_get_channel_name(mpctx
->demuxer
->stream
));
2717 case MP_CMD_RADIO_SET_FREQ
:
2718 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2719 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2722 case MP_CMD_RADIO_STEP_FREQ
:
2723 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2724 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2729 case MP_CMD_TV_START_SCAN
:
2730 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2731 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2733 case MP_CMD_TV_SET_FREQ
:
2734 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2735 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2736 cmd
->args
[0].v
.f
* 16.0);
2738 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2739 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2740 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2741 pvr_get_current_channelname (mpctx
->stream
),
2742 pvr_get_current_stationname (mpctx
->stream
));
2744 #endif /* CONFIG_PVR */
2747 case MP_CMD_TV_STEP_FREQ
:
2748 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2749 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2750 cmd
->args
[0].v
.f
* 16.0);
2752 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2753 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2754 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2755 pvr_get_current_channelname (mpctx
->stream
),
2756 pvr_get_current_frequency (mpctx
->stream
));
2758 #endif /* CONFIG_PVR */
2761 case MP_CMD_TV_SET_NORM
:
2762 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2763 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2767 case MP_CMD_TV_STEP_CHANNEL
:{
2768 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2769 int v
= cmd
->args
[0].v
.i
;
2771 tv_step_channel((tvi_handle_t
*) (mpctx
->
2775 tv_step_channel((tvi_handle_t
*) (mpctx
->
2779 if (tv_channel_list
) {
2780 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2781 MSGTR_OSDChannel
, tv_channel_current
->name
);
2782 //vo_osd_changed(OSDTYPE_SUBTITLE);
2786 else if (mpctx
->stream
&&
2787 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2788 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2789 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2790 pvr_get_current_channelname (mpctx
->stream
),
2791 pvr_get_current_stationname (mpctx
->stream
));
2793 #endif /* CONFIG_PVR */
2796 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2798 int v
= cmd
->args
[0].v
.i
;
2800 mpctx
->last_dvb_step
= v
;
2802 dir
= DVB_CHANNEL_HIGHER
;
2804 dir
= DVB_CHANNEL_LOWER
;
2807 if (dvb_step_channel(mpctx
->stream
, dir
))
2808 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2810 #endif /* CONFIG_DVBIN */
2813 case MP_CMD_TV_SET_CHANNEL
:
2814 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2815 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2817 if (tv_channel_list
) {
2818 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2819 MSGTR_OSDChannel
, tv_channel_current
->name
);
2820 //vo_osd_changed(OSDTYPE_SUBTITLE);
2824 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2825 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2826 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2827 pvr_get_current_channelname (mpctx
->stream
),
2828 pvr_get_current_stationname (mpctx
->stream
));
2830 #endif /* CONFIG_PVR */
2834 case MP_CMD_DVB_SET_CHANNEL
:
2835 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2836 mpctx
->last_dvb_step
= 1;
2839 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2840 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2843 #endif /* CONFIG_DVBIN */
2845 case MP_CMD_TV_LAST_CHANNEL
:
2846 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2847 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2848 if (tv_channel_list
) {
2849 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2850 MSGTR_OSDChannel
, tv_channel_current
->name
);
2851 //vo_osd_changed(OSDTYPE_SUBTITLE);
2855 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2856 pvr_set_lastchannel (mpctx
->stream
);
2857 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2858 pvr_get_current_channelname (mpctx
->stream
),
2859 pvr_get_current_stationname (mpctx
->stream
));
2861 #endif /* CONFIG_PVR */
2864 case MP_CMD_TV_STEP_NORM
:
2865 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2866 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2869 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2870 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2871 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2873 #ifdef CONFIG_TV_TELETEXT
2874 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2876 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2877 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2878 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2881 case MP_CMD_TV_TELETEXT_GO_LINK
:
2883 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2884 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2885 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2888 #endif /* CONFIG_TV_TELETEXT */
2889 #endif /* CONFIG_TV */
2891 case MP_CMD_SUB_LOAD
:
2893 int n
= mpctx
->set_of_sub_size
;
2894 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2895 if (n
!= mpctx
->set_of_sub_size
) {
2896 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2897 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2898 mpctx
->global_sub_size
;
2899 ++mpctx
->global_sub_size
;
2904 case MP_CMD_SUB_REMOVE
:
2906 int v
= cmd
->args
[0].v
.i
;
2909 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2910 subd
= mpctx
->set_of_subtitles
[v
];
2911 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2912 MSGTR_RemovedSubtitleFile
, v
+ 1,
2913 filename_recode(subd
->filename
));
2915 mpctx
->set_of_subtitles
[v
] = NULL
;
2917 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2918 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2919 mpctx
->set_of_sub_size
= 0;
2920 if (mpctx
->set_of_sub_pos
>= 0) {
2921 mpctx
->global_sub_pos
= -2;
2923 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2925 } else if (v
< mpctx
->set_of_sub_size
) {
2926 subd
= mpctx
->set_of_subtitles
[v
];
2927 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2928 MSGTR_RemovedSubtitleFile
, v
+ 1,
2929 filename_recode(subd
->filename
));
2931 if (mpctx
->set_of_sub_pos
== v
) {
2932 mpctx
->global_sub_pos
= -2;
2934 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2935 } else if (mpctx
->set_of_sub_pos
> v
) {
2936 --mpctx
->set_of_sub_pos
;
2937 --mpctx
->global_sub_pos
;
2939 while (++v
< mpctx
->set_of_sub_size
)
2940 mpctx
->set_of_subtitles
[v
- 1] =
2941 mpctx
->set_of_subtitles
[v
];
2942 --mpctx
->set_of_sub_size
;
2943 --mpctx
->global_sub_size
;
2944 if (mpctx
->set_of_sub_size
<= 0)
2945 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2946 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2951 case MP_CMD_GET_SUB_VISIBILITY
:
2953 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2954 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2958 case MP_CMD_SCREENSHOT
:
2959 if (vo_config_count
) {
2960 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2962 ((vf_instance_t
*) sh_video
->vfilter
)->
2963 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2965 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2969 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
;