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 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDDeinterlace
,
1024 deinterlace
? MSGTR_Enabled
: MSGTR_Disabled
);
1025 return M_PROPERTY_OK
;
1027 return M_PROPERTY_NOT_IMPLEMENTED
;
1031 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1035 if (!mpctx
->video_out
1036 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1037 return M_PROPERTY_UNAVAILABLE
;
1040 case M_PROPERTY_SET
:
1042 return M_PROPERTY_ERROR
;
1043 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1044 vo_panscan
= *(float *) arg
;
1045 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1046 return M_PROPERTY_OK
;
1047 case M_PROPERTY_STEP_UP
:
1048 case M_PROPERTY_STEP_DOWN
:
1049 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1050 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1053 else if (vo_panscan
< 0)
1055 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1056 return M_PROPERTY_OK
;
1058 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1062 /// Helper to set vo flags.
1063 /** \ingroup PropertyImplHelper
1065 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1066 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1069 if (!mpctx
->video_out
)
1070 return M_PROPERTY_UNAVAILABLE
;
1073 case M_PROPERTY_SET
:
1075 return M_PROPERTY_ERROR
;
1076 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1077 if (*vo_var
== !!*(int *) arg
)
1078 return M_PROPERTY_OK
;
1079 case M_PROPERTY_STEP_UP
:
1080 case M_PROPERTY_STEP_DOWN
:
1081 if (vo_config_count
)
1082 mpctx
->video_out
->control(vo_ctrl
, 0);
1083 return M_PROPERTY_OK
;
1085 return m_property_flag(prop
, action
, arg
, vo_var
);
1089 /// Window always on top (RW)
1090 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1093 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1097 /// Display in the root window (RW)
1098 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1101 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1102 &vo_rootwin
, mpctx
);
1105 /// Show window borders (RW)
1106 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1109 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1113 /// Framedropping state (RW)
1114 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1115 void *arg
, MPContext
* mpctx
)
1118 if (!mpctx
->sh_video
)
1119 return M_PROPERTY_UNAVAILABLE
;
1122 case M_PROPERTY_PRINT
:
1124 return M_PROPERTY_ERROR
;
1125 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1126 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1128 return M_PROPERTY_OK
;
1130 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1134 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1135 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1138 int *gamma
= prop
->priv
, r
, val
;
1140 if (!mpctx
->sh_video
)
1141 return M_PROPERTY_UNAVAILABLE
;
1143 if (gamma
[0] == 1000) {
1145 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1149 case M_PROPERTY_SET
:
1151 return M_PROPERTY_ERROR
;
1152 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1153 *gamma
= *(int *) arg
;
1154 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1158 case M_PROPERTY_GET
:
1159 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1161 return M_PROPERTY_ERROR
;
1163 return M_PROPERTY_OK
;
1166 case M_PROPERTY_STEP_UP
:
1167 case M_PROPERTY_STEP_DOWN
:
1168 *gamma
+= (arg
? *(int *) arg
: 1) *
1169 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1170 M_PROPERTY_CLAMP(prop
, *gamma
);
1171 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1176 return M_PROPERTY_NOT_IMPLEMENTED
;
1180 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1181 int l
= strlen(prop
->name
);
1182 char tv_prop
[3 + l
+ 1];
1183 sprintf(tv_prop
, "tv_%s", prop
->name
);
1184 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1188 return M_PROPERTY_UNAVAILABLE
;
1192 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1195 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1198 /// Video codec tag (RO)
1199 static int mp_property_video_format(m_option_t
* prop
, int action
,
1200 void *arg
, MPContext
* mpctx
)
1203 if (!mpctx
->sh_video
)
1204 return M_PROPERTY_UNAVAILABLE
;
1206 case M_PROPERTY_PRINT
:
1208 return M_PROPERTY_ERROR
;
1209 switch(mpctx
->sh_video
->format
) {
1211 meta
= strdup ("mpeg1"); break;
1213 meta
= strdup ("mpeg2"); break;
1215 meta
= strdup ("mpeg4"); break;
1217 meta
= strdup ("h264"); break;
1219 if(mpctx
->sh_video
->format
>= 0x20202020) {
1221 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1224 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1227 *(char**)arg
= meta
;
1228 return M_PROPERTY_OK
;
1230 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1233 /// Video codec name (RO)
1234 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1235 void *arg
, MPContext
* mpctx
)
1237 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1238 return M_PROPERTY_UNAVAILABLE
;
1239 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1243 /// Video bitrate (RO)
1244 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1245 void *arg
, MPContext
* mpctx
)
1247 if (!mpctx
->sh_video
)
1248 return M_PROPERTY_UNAVAILABLE
;
1249 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1252 /// Video display width (RO)
1253 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1256 if (!mpctx
->sh_video
)
1257 return M_PROPERTY_UNAVAILABLE
;
1258 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1261 /// Video display height (RO)
1262 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1265 if (!mpctx
->sh_video
)
1266 return M_PROPERTY_UNAVAILABLE
;
1267 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1271 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1274 if (!mpctx
->sh_video
)
1275 return M_PROPERTY_UNAVAILABLE
;
1276 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1279 /// Video aspect (RO)
1280 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1283 if (!mpctx
->sh_video
)
1284 return M_PROPERTY_UNAVAILABLE
;
1285 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1290 /// \defgroup SubProprties Subtitles properties
1291 /// \ingroup Properties
1294 /// Text subtitle position (RW)
1295 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1298 if (!mpctx
->sh_video
)
1299 return M_PROPERTY_UNAVAILABLE
;
1302 case M_PROPERTY_SET
:
1304 return M_PROPERTY_ERROR
;
1305 case M_PROPERTY_STEP_UP
:
1306 case M_PROPERTY_STEP_DOWN
:
1307 vo_osd_changed(OSDTYPE_SUBTITLE
);
1309 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1313 /// Selected subtitles (RW)
1314 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1317 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1318 const int global_sub_size
= mpctx
->global_sub_size
;
1319 int source
= -1, reset_spu
= 0;
1323 if (global_sub_size
<= 0)
1324 return M_PROPERTY_UNAVAILABLE
;
1327 case M_PROPERTY_GET
:
1329 return M_PROPERTY_ERROR
;
1330 *(int *) arg
= mpctx
->global_sub_pos
;
1331 return M_PROPERTY_OK
;
1332 case M_PROPERTY_PRINT
:
1334 return M_PROPERTY_ERROR
;
1335 *(char **) arg
= malloc(64);
1336 (*(char **) arg
)[63] = 0;
1339 sub_name
= subdata
->filename
;
1341 if (ass_track
&& ass_track
->name
)
1342 sub_name
= ass_track
->name
;
1347 if ((tmp2
= strrchr(tmp
, '/')))
1350 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1351 mpctx
->set_of_sub_pos
+ 1,
1352 strlen(tmp
) < 20 ? "" : "...",
1353 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1354 return M_PROPERTY_OK
;
1356 #ifdef CONFIG_DVDNAV
1357 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1358 if (vo_spudec
&& dvdsub_id
>= 0) {
1359 unsigned char lang
[3];
1360 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1361 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1362 return M_PROPERTY_OK
;
1368 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1369 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1370 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1371 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1372 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1373 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1374 if (!lang
) lang
= MSGTR_Unknown
;
1375 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1376 return M_PROPERTY_OK
;
1379 if (vo_vobsub
&& vobsub_id
>= 0) {
1380 const char *language
= MSGTR_Unknown
;
1381 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1382 snprintf(*(char **) arg
, 63, "(%d) %s",
1383 vobsub_id
, language
? language
: MSGTR_Unknown
);
1384 return M_PROPERTY_OK
;
1386 #ifdef CONFIG_DVDREAD
1387 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1388 && dvdsub_id
>= 0) {
1390 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1391 lang
[0] = code
>> 8;
1394 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1395 return M_PROPERTY_OK
;
1398 if (dvdsub_id
>= 0) {
1399 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1400 return M_PROPERTY_OK
;
1402 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1403 return M_PROPERTY_OK
;
1405 case M_PROPERTY_SET
:
1407 return M_PROPERTY_ERROR
;
1408 if (*(int *) arg
< -1)
1410 else if (*(int *) arg
>= global_sub_size
)
1411 *(int *) arg
= global_sub_size
- 1;
1412 mpctx
->global_sub_pos
= *(int *) arg
;
1414 case M_PROPERTY_STEP_UP
:
1415 mpctx
->global_sub_pos
+= 2;
1416 mpctx
->global_sub_pos
=
1417 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1419 case M_PROPERTY_STEP_DOWN
:
1420 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1421 mpctx
->global_sub_pos
=
1422 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1425 return M_PROPERTY_NOT_IMPLEMENTED
;
1428 if (mpctx
->global_sub_pos
>= 0)
1429 source
= sub_source(mpctx
);
1431 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1432 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1434 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1435 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1436 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1437 mpctx
->global_sub_pos
, source
);
1439 mpctx
->set_of_sub_pos
= -1;
1453 if (source
== SUB_SOURCE_VOBSUB
) {
1454 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1455 } else if (source
== SUB_SOURCE_SUBS
) {
1456 mpctx
->set_of_sub_pos
=
1457 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1459 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1460 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1464 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1465 vo_osd_changed(OSDTYPE_SUBTITLE
);
1467 } else if (source
== SUB_SOURCE_DEMUX
) {
1469 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1470 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1472 // default: assume 1:1 mapping of sid and stream id
1473 d_sub
->id
= dvdsub_id
;
1474 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1475 ds_free_packs(d_sub
);
1476 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1477 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1478 if (sh
&& sh
->sid
== dvdsub_id
) {
1484 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1485 sh_sub_t
*sh
= d_sub
->sh
;
1486 if (sh
->type
== 'v')
1489 else if (ass_enabled
)
1490 ass_track
= sh
->ass_track
;
1498 #ifdef CONFIG_DVDREAD
1500 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1501 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1502 && dvdsub_id
< 0 && reset_spu
) {
1507 if (mpctx
->sh_audio
)
1508 pts
= mpctx
->sh_audio
->pts
;
1509 if (mpctx
->sh_video
)
1510 pts
= mpctx
->sh_video
->pts
;
1511 update_subtitles(mpctx
->sh_video
, pts
, d_sub
, 1);
1513 return M_PROPERTY_OK
;
1516 /// Selected sub source (RW)
1517 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1521 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1522 return M_PROPERTY_UNAVAILABLE
;
1525 case M_PROPERTY_GET
:
1527 return M_PROPERTY_ERROR
;
1528 *(int *) arg
= sub_source(mpctx
);
1529 return M_PROPERTY_OK
;
1530 case M_PROPERTY_PRINT
:
1532 return M_PROPERTY_ERROR
;
1533 *(char **) arg
= malloc(64);
1534 (*(char **) arg
)[63] = 0;
1535 switch (sub_source(mpctx
))
1537 case SUB_SOURCE_SUBS
:
1538 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1540 case SUB_SOURCE_VOBSUB
:
1541 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1543 case SUB_SOURCE_DEMUX
:
1544 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1547 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1549 return M_PROPERTY_OK
;
1550 case M_PROPERTY_SET
:
1552 return M_PROPERTY_ERROR
;
1553 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1554 if (*(int *) arg
< 0)
1555 mpctx
->global_sub_pos
= -1;
1556 else if (*(int *) arg
!= sub_source(mpctx
)) {
1557 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1558 return M_PROPERTY_UNAVAILABLE
;
1559 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1562 case M_PROPERTY_STEP_UP
:
1563 case M_PROPERTY_STEP_DOWN
: {
1564 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1565 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1566 int step
= (step_all
> 0) ? 1 : -1;
1567 int cur_source
= sub_source(mpctx
);
1568 source
= cur_source
;
1571 if (source
>= SUB_SOURCES
)
1573 else if (source
< -1)
1574 source
= SUB_SOURCES
- 1;
1575 if (source
== cur_source
|| source
== -1 ||
1576 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1579 if (source
== cur_source
)
1580 return M_PROPERTY_OK
;
1582 mpctx
->global_sub_pos
= -1;
1584 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1588 return M_PROPERTY_NOT_IMPLEMENTED
;
1590 --mpctx
->global_sub_pos
;
1591 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1594 /// Selected subtitles from specific source (RW)
1595 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1598 int source
, is_cur_source
, offset
;
1599 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1600 return M_PROPERTY_UNAVAILABLE
;
1602 if (!strcmp(prop
->name
, "sub_file"))
1603 source
= SUB_SOURCE_SUBS
;
1604 else if (!strcmp(prop
->name
, "sub_vob"))
1605 source
= SUB_SOURCE_VOBSUB
;
1606 else if (!strcmp(prop
->name
, "sub_demux"))
1607 source
= SUB_SOURCE_DEMUX
;
1609 return M_PROPERTY_ERROR
;
1611 offset
= mpctx
->global_sub_indices
[source
];
1612 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1613 return M_PROPERTY_UNAVAILABLE
;
1615 is_cur_source
= sub_source(mpctx
) == source
;
1617 case M_PROPERTY_GET
:
1619 return M_PROPERTY_ERROR
;
1620 if (is_cur_source
) {
1621 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1622 if (source
== SUB_SOURCE_VOBSUB
)
1623 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1627 return M_PROPERTY_OK
;
1628 case M_PROPERTY_PRINT
:
1630 return M_PROPERTY_ERROR
;
1632 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1633 *(char **) arg
= malloc(64);
1634 (*(char **) arg
)[63] = 0;
1635 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1636 return M_PROPERTY_OK
;
1637 case M_PROPERTY_SET
:
1639 return M_PROPERTY_ERROR
;
1640 if (*(int *) arg
>= 0) {
1641 int index
= *(int *)arg
;
1642 if (source
== SUB_SOURCE_VOBSUB
)
1643 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1644 mpctx
->global_sub_pos
= offset
+ index
;
1645 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1646 || sub_source(mpctx
) != source
) {
1647 mpctx
->global_sub_pos
= -1;
1652 mpctx
->global_sub_pos
= -1;
1654 case M_PROPERTY_STEP_UP
:
1655 case M_PROPERTY_STEP_DOWN
: {
1656 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1657 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1658 int step
= (step_all
> 0) ? 1 : -1;
1659 int max_sub_pos_for_source
= -1;
1661 mpctx
->global_sub_pos
= -1;
1663 if (mpctx
->global_sub_pos
== -1) {
1665 mpctx
->global_sub_pos
= offset
;
1666 else if (max_sub_pos_for_source
== -1) {
1667 // Find max pos for specific source
1668 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1669 while (mpctx
->global_sub_pos
>= 0
1670 && sub_source(mpctx
) != source
)
1671 --mpctx
->global_sub_pos
;
1674 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1677 mpctx
->global_sub_pos
+= step
;
1678 if (mpctx
->global_sub_pos
< offset
||
1679 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1680 sub_source(mpctx
) != source
)
1681 mpctx
->global_sub_pos
= -1;
1688 return M_PROPERTY_NOT_IMPLEMENTED
;
1690 --mpctx
->global_sub_pos
;
1691 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1694 /// Subtitle delay (RW)
1695 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1698 if (!mpctx
->sh_video
)
1699 return M_PROPERTY_UNAVAILABLE
;
1700 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1703 /// Alignment of text subtitles (RW)
1704 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1705 void *arg
, MPContext
* mpctx
)
1707 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1709 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1710 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1711 return M_PROPERTY_UNAVAILABLE
;
1714 case M_PROPERTY_PRINT
:
1716 return M_PROPERTY_ERROR
;
1717 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1718 *(char **) arg
= strdup(name
[sub_alignment
]);
1719 return M_PROPERTY_OK
;
1720 case M_PROPERTY_SET
:
1722 return M_PROPERTY_ERROR
;
1723 case M_PROPERTY_STEP_UP
:
1724 case M_PROPERTY_STEP_DOWN
:
1725 vo_osd_changed(OSDTYPE_SUBTITLE
);
1727 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1731 /// Subtitle visibility (RW)
1732 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1733 void *arg
, MPContext
* mpctx
)
1735 if (!mpctx
->sh_video
)
1736 return M_PROPERTY_UNAVAILABLE
;
1739 case M_PROPERTY_SET
:
1741 return M_PROPERTY_ERROR
;
1742 case M_PROPERTY_STEP_UP
:
1743 case M_PROPERTY_STEP_DOWN
:
1744 vo_osd_changed(OSDTYPE_SUBTITLE
);
1746 vo_osd_changed(OSDTYPE_SPU
);
1748 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1753 /// Use margins for libass subtitles (RW)
1754 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1755 void *arg
, MPContext
* mpctx
)
1757 if (!mpctx
->sh_video
)
1758 return M_PROPERTY_UNAVAILABLE
;
1761 case M_PROPERTY_SET
:
1763 return M_PROPERTY_ERROR
;
1764 case M_PROPERTY_STEP_UP
:
1765 case M_PROPERTY_STEP_DOWN
:
1766 ass_force_reload
= 1;
1768 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1773 /// Show only forced subtitles (RW)
1774 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1775 void *arg
, MPContext
* mpctx
)
1778 return M_PROPERTY_UNAVAILABLE
;
1781 case M_PROPERTY_SET
:
1783 return M_PROPERTY_ERROR
;
1784 case M_PROPERTY_STEP_UP
:
1785 case M_PROPERTY_STEP_DOWN
:
1786 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1787 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1788 return M_PROPERTY_OK
;
1790 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1795 #ifdef CONFIG_FREETYPE
1796 /// Subtitle scale (RW)
1797 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1802 case M_PROPERTY_SET
:
1804 return M_PROPERTY_ERROR
;
1805 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1808 ass_font_scale
= *(float *) arg
;
1809 ass_force_reload
= 1;
1812 text_font_scale_factor
= *(float *) arg
;
1813 force_load_font
= 1;
1814 return M_PROPERTY_OK
;
1815 case M_PROPERTY_STEP_UP
:
1816 case M_PROPERTY_STEP_DOWN
:
1819 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1820 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1821 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1822 ass_force_reload
= 1;
1825 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1826 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1827 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1828 force_load_font
= 1;
1829 return M_PROPERTY_OK
;
1833 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1836 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1843 /// \defgroup TVProperties TV properties
1844 /// \ingroup Properties
1849 /// TV color settings (RW)
1850 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1854 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1855 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1856 return M_PROPERTY_UNAVAILABLE
;
1859 case M_PROPERTY_SET
:
1861 return M_PROPERTY_ERROR
;
1862 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1863 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1864 case M_PROPERTY_GET
:
1865 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1866 case M_PROPERTY_STEP_UP
:
1867 case M_PROPERTY_STEP_DOWN
:
1868 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1870 return M_PROPERTY_ERROR
;
1871 val
+= (arg
? *(int *) arg
: 1) *
1872 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1873 M_PROPERTY_CLAMP(prop
, val
);
1874 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1876 return M_PROPERTY_ERROR
;
1878 return M_PROPERTY_NOT_IMPLEMENTED
;
1883 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1887 int base_ioctl
=(int)prop
->priv
;
1889 for teletext's GET,SET,STEP ioctls this is not 0
1893 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1894 return M_PROPERTY_UNAVAILABLE
;
1896 return M_PROPERTY_ERROR
;
1899 case M_PROPERTY_GET
:
1901 return M_PROPERTY_ERROR
;
1902 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1904 case M_PROPERTY_SET
:
1906 return M_PROPERTY_ERROR
;
1907 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1908 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1910 case M_PROPERTY_STEP_UP
:
1911 case M_PROPERTY_STEP_DOWN
:
1912 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1913 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1914 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
1917 return M_PROPERTY_NOT_IMPLEMENTED
;
1920 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1923 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1929 //with tvh==NULL will fail too
1930 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1931 if(result
!=M_PROPERTY_OK
)
1934 if(teletext_control(mpctx
->demuxer
->teletext
,
1935 (int)prop
->priv
, &val
)==VBI_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
,
1947 if (!mpctx
->demuxer
->teletext
)
1948 return M_PROPERTY_UNAVAILABLE
;
1950 case M_PROPERTY_STEP_UP
:
1951 case M_PROPERTY_STEP_DOWN
:
1952 //This should be handled separately
1953 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1954 result
=teletext_control(mpctx
->demuxer
->teletext
,
1955 TV_VBI_CONTROL_STEP_PAGE
, &val
);
1958 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1965 /// All properties available in MPlayer.
1966 /** \ingroup Properties
1968 static const m_option_t mp_properties
[] = {
1970 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1971 M_OPT_RANGE
, 0, 3, NULL
},
1972 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1973 M_OPT_MIN
, -1, 0, NULL
},
1974 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1975 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1976 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1978 { "path", mp_property_path
, CONF_TYPE_STRING
,
1980 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1982 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1983 M_OPT_MIN
, 0, 0, NULL
},
1984 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1985 M_OPT_MIN
, 0, 0, NULL
},
1986 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1987 M_OPT_MIN
, 0, 0, NULL
},
1988 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1989 M_OPT_MIN
, 0, 0, NULL
},
1990 { "length", mp_property_length
, CONF_TYPE_TIME
,
1991 M_OPT_MIN
, 0, 0, NULL
},
1992 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1993 M_OPT_RANGE
, 0, 100, NULL
},
1994 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1995 M_OPT_MIN
, 0, 0, NULL
},
1996 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1997 M_OPT_MIN
, 0, 0, NULL
},
1998 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2000 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2001 CONF_RANGE
, -2, 10, NULL
},
2002 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2004 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2005 M_OPT_RANGE
, 0, 1, NULL
},
2008 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2009 M_OPT_RANGE
, 0, 100, NULL
},
2010 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2011 M_OPT_RANGE
, 0, 1, NULL
},
2012 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2013 M_OPT_RANGE
, -100, 100, NULL
},
2014 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2016 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2018 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2020 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2022 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2024 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2025 CONF_RANGE
, -2, 65535, NULL
},
2026 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2027 M_OPT_RANGE
, -1, 1, NULL
},
2030 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2031 M_OPT_RANGE
, 0, 1, NULL
},
2032 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2033 M_OPT_RANGE
, 0, 1, NULL
},
2034 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2035 M_OPT_RANGE
, 0, 1, NULL
},
2036 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2037 M_OPT_RANGE
, 0, 1, NULL
},
2038 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2039 M_OPT_RANGE
, 0, 1, NULL
},
2040 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2041 M_OPT_RANGE
, 0, 2, NULL
},
2042 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2043 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2044 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2045 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2046 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2047 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2048 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2049 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2050 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2051 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2052 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2053 M_OPT_RANGE
, 0, 1, NULL
},
2054 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2055 M_OPT_RANGE
, 0, 1, NULL
},
2056 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2058 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2060 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2062 { "width", mp_property_width
, CONF_TYPE_INT
,
2064 { "height", mp_property_height
, CONF_TYPE_INT
,
2066 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2068 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2070 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2071 CONF_RANGE
, -2, 65535, NULL
},
2072 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2073 CONF_RANGE
, -1, 65535, NULL
},
2076 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2077 M_OPT_MIN
, -1, 0, NULL
},
2078 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2080 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2081 M_OPT_MIN
, -1, 0, NULL
},
2082 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2083 M_OPT_MIN
, -1, 0, NULL
},
2084 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2085 M_OPT_MIN
, -1, 0, NULL
},
2086 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2088 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2089 M_OPT_RANGE
, 0, 100, NULL
},
2090 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2091 M_OPT_RANGE
, 0, 2, NULL
},
2092 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2093 M_OPT_RANGE
, 0, 1, NULL
},
2094 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2095 M_OPT_RANGE
, 0, 1, NULL
},
2096 #ifdef CONFIG_FREETYPE
2097 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2098 M_OPT_RANGE
, 0, 100, NULL
},
2101 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2102 M_OPT_RANGE
, 0, 1, NULL
},
2106 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2107 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2108 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2109 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2110 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2111 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2112 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2115 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2116 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2117 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2118 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2119 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2120 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2121 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2122 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2123 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2124 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2125 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2129 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2131 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2134 char* mp_property_print(const char *name
, void* ctx
)
2137 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2142 char *property_expand_string(MPContext
* mpctx
, char *str
)
2144 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2147 void property_print_help(void)
2149 m_properties_print_help_list(mp_properties
);
2158 * \defgroup Command2Property Command to property bridge
2160 * It is used to handle most commands that just set a property
2161 * and optionally display something on the OSD.
2162 * Two kinds of commands are handled: adjust or toggle.
2164 * Adjust commands take 1 or 2 parameters: <value> <abs>
2165 * If <abs> is non-zero the property is set to the given value
2166 * otherwise it is adjusted.
2168 * Toggle commands take 0 or 1 parameters. With no parameter
2169 * or a value less than the property minimum it just steps the
2170 * property to its next value. Otherwise it sets it to the given
2176 /// List of the commands that can be handled by setting a property.
2182 /// set/adjust or toggle command
2184 /// progressbar type
2186 /// osd msg id if it must be shared
2188 /// osd msg template
2189 const char *osd_msg
;
2190 } set_prop_cmd
[] = {
2192 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2193 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2194 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2196 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2197 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2198 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2199 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2200 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2202 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2203 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2204 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2205 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2206 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2207 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2208 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2209 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2210 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2211 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2212 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2213 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2215 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2216 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2217 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2218 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2219 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2220 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2221 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2222 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2223 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2224 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2225 #ifdef CONFIG_FREETYPE
2226 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2229 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2232 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2233 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2234 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2235 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2237 { NULL
, 0, 0, 0, -1, NULL
}
2241 /// Handle commands that set a property.
2242 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2248 // look for the command
2249 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2250 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2252 if (!(pname
= set_prop_cmd
[i
].name
))
2255 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2259 if (set_prop_cmd
[i
].toggle
) {
2261 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2262 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2264 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2265 } else if (cmd
->args
[1].v
.i
) //set
2266 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2268 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2273 if (set_prop_cmd
[i
].osd_progbar
) {
2274 if (prop
->type
== CONF_TYPE_INT
) {
2275 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2276 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2277 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2278 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2280 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2281 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2282 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2284 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2285 "Property use an unsupported type.\n");
2289 if (set_prop_cmd
[i
].osd_msg
) {
2290 char *val
= mp_property_print(pname
, mpctx
);
2292 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2293 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2294 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2301 #ifdef CONFIG_DVDNAV
2302 static const struct {
2304 const mp_command_type cmd
;
2305 } mp_dvdnav_bindings
[] = {
2306 { "up", MP_CMD_DVDNAV_UP
},
2307 { "down", MP_CMD_DVDNAV_DOWN
},
2308 { "left", MP_CMD_DVDNAV_LEFT
},
2309 { "right", MP_CMD_DVDNAV_RIGHT
},
2310 { "menu", MP_CMD_DVDNAV_MENU
},
2311 { "select", MP_CMD_DVDNAV_SELECT
},
2312 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2313 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2316 * keep old dvdnav sub-command options for a while in order not to
2317 * break slave-mode API too suddenly.
2319 { "1", MP_CMD_DVDNAV_UP
},
2320 { "2", MP_CMD_DVDNAV_DOWN
},
2321 { "3", MP_CMD_DVDNAV_LEFT
},
2322 { "4", MP_CMD_DVDNAV_RIGHT
},
2323 { "5", MP_CMD_DVDNAV_MENU
},
2324 { "6", MP_CMD_DVDNAV_SELECT
},
2325 { "7", MP_CMD_DVDNAV_PREVMENU
},
2326 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2331 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2333 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2334 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2336 if (!set_property_command(mpctx
, cmd
))
2342 mpctx
->osd_show_percentage
= sh_video
->fps
;
2343 v
= cmd
->args
[0].v
.f
;
2344 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2345 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2346 abs_seek_pos
= SEEK_ABSOLUTE
;
2348 mpctx
->osd_function
=
2349 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2351 } else if (abs
) { /* Absolute seek by percentage */
2352 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2354 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2355 rel_seek_secs
= v
/ 100.0;
2358 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2364 case MP_CMD_SET_PROPERTY
:{
2365 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2366 cmd
->args
[1].v
.s
, mpctx
);
2367 if (r
== M_PROPERTY_UNKNOWN
)
2368 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2369 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2371 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2372 "Failed to set property '%s' to '%s'.\n",
2373 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2377 case MP_CMD_STEP_PROPERTY
:{
2382 if (cmd
->args
[1].v
.f
) {
2384 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2385 M_PROPERTY_GET_TYPE
,
2386 &prop
, mpctx
)) <= 0)
2388 if(prop
->type
== CONF_TYPE_INT
||
2389 prop
->type
== CONF_TYPE_FLAG
)
2390 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2391 else if(prop
->type
== CONF_TYPE_FLOAT
)
2392 arg
= &cmd
->args
[1].v
.f
;
2393 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2394 prop
->type
== CONF_TYPE_TIME
)
2395 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2396 else if(prop
->type
== CONF_TYPE_POSITION
)
2397 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2399 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2400 "Ignoring step size stepping property '%s'.\n",
2403 r
= mp_property_do(cmd
->args
[0].v
.s
,
2404 cmd
->args
[2].v
.i
< 0 ?
2405 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2408 if (r
== M_PROPERTY_UNKNOWN
)
2409 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2410 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2412 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2413 "Failed to increment property '%s' by %f.\n",
2414 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2418 case MP_CMD_GET_PROPERTY
:{
2420 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2421 &tmp
, mpctx
) <= 0) {
2422 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2423 "Failed to get value of property '%s'.\n",
2427 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2428 cmd
->args
[0].v
.s
, tmp
);
2433 case MP_CMD_EDL_MARK
:
2435 float v
= sh_video
? sh_video
->pts
:
2436 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2439 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2440 mpctx
->begin_skip
= v
;
2441 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2443 if (mpctx
->begin_skip
> v
)
2444 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2446 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2447 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2449 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2454 case MP_CMD_SWITCH_RATIO
:
2457 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2458 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2460 movie_aspect
= cmd
->args
[0].v
.f
;
2461 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2464 case MP_CMD_SPEED_INCR
:{
2465 float v
= cmd
->args
[0].v
.f
;
2466 playback_speed
+= v
;
2467 build_afilter_chain(sh_audio
, &ao_data
);
2468 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2472 case MP_CMD_SPEED_MULT
:{
2473 float v
= cmd
->args
[0].v
.f
;
2474 playback_speed
*= v
;
2475 build_afilter_chain(sh_audio
, &ao_data
);
2476 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2480 case MP_CMD_SPEED_SET
:{
2481 float v
= cmd
->args
[0].v
.f
;
2483 build_afilter_chain(sh_audio
, &ao_data
);
2484 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2488 case MP_CMD_FRAME_STEP
:
2494 case MP_CMD_FILE_FILTER
:
2495 file_filter
= cmd
->args
[0].v
.i
;
2499 exit_player_with_rc(EXIT_QUIT
,
2500 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2502 case MP_CMD_PLAY_TREE_STEP
:{
2503 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2504 int force
= cmd
->args
[1].v
.i
;
2510 for (i
= 0; i
< n
; i
++)
2513 for (i
= 0; i
< -1 * n
; i
++)
2518 if (!force
&& mpctx
->playtree_iter
) {
2519 play_tree_iter_t
*i
=
2520 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2521 if (play_tree_iter_step(i
, n
, 0) ==
2522 PLAY_TREE_ITER_ENTRY
)
2524 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2525 play_tree_iter_free(i
);
2527 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2529 mpctx
->play_tree_step
= n
;
2535 case MP_CMD_PLAY_TREE_UP_STEP
:{
2536 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2537 int force
= cmd
->args
[1].v
.i
;
2539 if (!force
&& mpctx
->playtree_iter
) {
2540 play_tree_iter_t
*i
=
2541 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2542 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2543 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2544 play_tree_iter_free(i
);
2546 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2551 case MP_CMD_PLAY_ALT_SRC_STEP
:
2552 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2553 int v
= cmd
->args
[0].v
.i
;
2555 && mpctx
->playtree_iter
->file
<
2556 mpctx
->playtree_iter
->num_files
)
2557 mpctx
->eof
= PT_NEXT_SRC
;
2558 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2559 mpctx
->eof
= PT_PREV_SRC
;
2564 case MP_CMD_SUB_STEP
:
2566 int movement
= cmd
->args
[0].v
.i
;
2567 step_sub(subdata
, sh_video
->pts
, movement
);
2571 ass_step_sub(ass_track
,
2573 sub_delay
) * 1000 + .5, movement
) / 1000.;
2575 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2576 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2580 case MP_CMD_SUB_LOG
:
2585 int v
= cmd
->args
[0].v
.i
;
2587 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2588 if (osd_level
> max
)
2591 osd_level
= (osd_level
+ 1) % (max
+ 1);
2593 osd_level
= v
> max
? max
: v
;
2594 /* Show OSD state when disabled, but not when an explicit
2595 argument is given to the OSD command, i.e. in slave mode. */
2596 if (v
== -1 && osd_level
<= 1)
2597 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2599 osd_level
? MSGTR_OSDenabled
:
2602 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2606 case MP_CMD_OSD_SHOW_TEXT
:
2607 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2609 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2610 "%-.63s", cmd
->args
[0].v
.s
);
2613 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2614 char *txt
= m_properties_expand_string(mp_properties
,
2617 /* if no argument supplied take default osd_duration, else <arg> ms. */
2619 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2621 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2628 case MP_CMD_LOADFILE
:{
2629 play_tree_t
*e
= play_tree_new();
2630 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2632 if (cmd
->args
[1].v
.i
) // append
2633 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2635 // Go back to the starting point.
2636 while (play_tree_iter_up_step
2637 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2639 play_tree_free_list(mpctx
->playtree
->child
, 1);
2640 play_tree_set_child(mpctx
->playtree
, e
);
2641 pt_iter_goto_head(mpctx
->playtree_iter
);
2642 mpctx
->eof
= PT_NEXT_SRC
;
2648 case MP_CMD_LOADLIST
:{
2649 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2651 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2652 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2654 if (cmd
->args
[1].v
.i
) // append
2655 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2657 // Go back to the starting point.
2658 while (play_tree_iter_up_step
2659 (mpctx
->playtree_iter
, 0, 1)
2660 != PLAY_TREE_ITER_END
)
2662 play_tree_free_list(mpctx
->playtree
->child
, 1);
2663 play_tree_set_child(mpctx
->playtree
, e
);
2664 pt_iter_goto_head(mpctx
->playtree_iter
);
2665 mpctx
->eof
= PT_NEXT_SRC
;
2673 // Go back to the starting point.
2674 while (play_tree_iter_up_step
2675 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2677 mpctx
->eof
= PT_STOP
;
2682 case MP_CMD_RADIO_STEP_CHANNEL
:
2683 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2684 int v
= cmd
->args
[0].v
.i
;
2686 radio_step_channel(mpctx
->demuxer
->stream
,
2687 RADIO_CHANNEL_HIGHER
);
2689 radio_step_channel(mpctx
->demuxer
->stream
,
2690 RADIO_CHANNEL_LOWER
);
2691 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2692 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2694 radio_get_channel_name(mpctx
->demuxer
->stream
));
2699 case MP_CMD_RADIO_SET_CHANNEL
:
2700 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2701 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2702 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2703 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2705 radio_get_channel_name(mpctx
->demuxer
->stream
));
2710 case MP_CMD_RADIO_SET_FREQ
:
2711 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2712 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2715 case MP_CMD_RADIO_STEP_FREQ
:
2716 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2717 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2722 case MP_CMD_TV_START_SCAN
:
2723 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2724 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2726 case MP_CMD_TV_SET_FREQ
:
2727 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2728 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2729 cmd
->args
[0].v
.f
* 16.0);
2731 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2732 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2733 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2734 pvr_get_current_channelname (mpctx
->stream
),
2735 pvr_get_current_stationname (mpctx
->stream
));
2737 #endif /* CONFIG_PVR */
2740 case MP_CMD_TV_STEP_FREQ
:
2741 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2742 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2743 cmd
->args
[0].v
.f
* 16.0);
2745 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2746 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2747 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2748 pvr_get_current_channelname (mpctx
->stream
),
2749 pvr_get_current_frequency (mpctx
->stream
));
2751 #endif /* CONFIG_PVR */
2754 case MP_CMD_TV_SET_NORM
:
2755 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2756 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2760 case MP_CMD_TV_STEP_CHANNEL
:{
2761 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2762 int v
= cmd
->args
[0].v
.i
;
2764 tv_step_channel((tvi_handle_t
*) (mpctx
->
2768 tv_step_channel((tvi_handle_t
*) (mpctx
->
2772 if (tv_channel_list
) {
2773 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2774 MSGTR_OSDChannel
, tv_channel_current
->name
);
2775 //vo_osd_changed(OSDTYPE_SUBTITLE);
2779 else if (mpctx
->stream
&&
2780 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2781 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2782 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2783 pvr_get_current_channelname (mpctx
->stream
),
2784 pvr_get_current_stationname (mpctx
->stream
));
2786 #endif /* CONFIG_PVR */
2789 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2791 int v
= cmd
->args
[0].v
.i
;
2793 mpctx
->last_dvb_step
= v
;
2795 dir
= DVB_CHANNEL_HIGHER
;
2797 dir
= DVB_CHANNEL_LOWER
;
2800 if (dvb_step_channel(mpctx
->stream
, dir
))
2801 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2803 #endif /* CONFIG_DVBIN */
2806 case MP_CMD_TV_SET_CHANNEL
:
2807 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2808 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2810 if (tv_channel_list
) {
2811 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2812 MSGTR_OSDChannel
, tv_channel_current
->name
);
2813 //vo_osd_changed(OSDTYPE_SUBTITLE);
2817 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2818 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2819 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2820 pvr_get_current_channelname (mpctx
->stream
),
2821 pvr_get_current_stationname (mpctx
->stream
));
2823 #endif /* CONFIG_PVR */
2827 case MP_CMD_DVB_SET_CHANNEL
:
2828 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2829 mpctx
->last_dvb_step
= 1;
2832 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2833 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2836 #endif /* CONFIG_DVBIN */
2838 case MP_CMD_TV_LAST_CHANNEL
:
2839 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2840 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2841 if (tv_channel_list
) {
2842 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2843 MSGTR_OSDChannel
, tv_channel_current
->name
);
2844 //vo_osd_changed(OSDTYPE_SUBTITLE);
2848 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2849 pvr_set_lastchannel (mpctx
->stream
);
2850 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2851 pvr_get_current_channelname (mpctx
->stream
),
2852 pvr_get_current_stationname (mpctx
->stream
));
2854 #endif /* CONFIG_PVR */
2857 case MP_CMD_TV_STEP_NORM
:
2858 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2859 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2862 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2863 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2864 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2866 #endif /* CONFIG_TV */
2867 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2869 if (mpctx
->demuxer
->teletext
)
2870 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
2871 &(cmd
->args
[0].v
.s
));
2874 case MP_CMD_TV_TELETEXT_GO_LINK
:
2876 if (mpctx
->demuxer
->teletext
)
2877 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
2878 &(cmd
->args
[0].v
.i
));
2882 case MP_CMD_SUB_LOAD
:
2884 int n
= mpctx
->set_of_sub_size
;
2885 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2886 if (n
!= mpctx
->set_of_sub_size
) {
2887 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2888 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2889 mpctx
->global_sub_size
;
2890 ++mpctx
->global_sub_size
;
2895 case MP_CMD_SUB_REMOVE
:
2897 int v
= cmd
->args
[0].v
.i
;
2900 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2901 subd
= mpctx
->set_of_subtitles
[v
];
2902 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2903 MSGTR_RemovedSubtitleFile
, v
+ 1,
2904 filename_recode(subd
->filename
));
2906 mpctx
->set_of_subtitles
[v
] = NULL
;
2908 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2909 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2910 mpctx
->set_of_sub_size
= 0;
2911 if (mpctx
->set_of_sub_pos
>= 0) {
2912 mpctx
->global_sub_pos
= -2;
2914 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2916 } else if (v
< mpctx
->set_of_sub_size
) {
2917 subd
= mpctx
->set_of_subtitles
[v
];
2918 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2919 MSGTR_RemovedSubtitleFile
, v
+ 1,
2920 filename_recode(subd
->filename
));
2922 if (mpctx
->set_of_sub_pos
== v
) {
2923 mpctx
->global_sub_pos
= -2;
2925 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2926 } else if (mpctx
->set_of_sub_pos
> v
) {
2927 --mpctx
->set_of_sub_pos
;
2928 --mpctx
->global_sub_pos
;
2930 while (++v
< mpctx
->set_of_sub_size
)
2931 mpctx
->set_of_subtitles
[v
- 1] =
2932 mpctx
->set_of_subtitles
[v
];
2933 --mpctx
->set_of_sub_size
;
2934 --mpctx
->global_sub_size
;
2935 if (mpctx
->set_of_sub_size
<= 0)
2936 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2937 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2942 case MP_CMD_GET_SUB_VISIBILITY
:
2944 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2945 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2949 case MP_CMD_SCREENSHOT
:
2950 if (vo_config_count
) {
2951 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2953 ((vf_instance_t
*) sh_video
->vfilter
)->
2954 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2956 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2960 case MP_CMD_VF_CHANGE_RECTANGLE
:
2963 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2966 case MP_CMD_GET_TIME_LENGTH
:{
2967 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2968 demuxer_get_time_length(mpctx
->demuxer
));
2972 case MP_CMD_GET_FILENAME
:{
2973 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2974 get_metadata(META_NAME
));
2978 case MP_CMD_GET_VIDEO_CODEC
:{
2979 char *inf
= get_metadata(META_VIDEO_CODEC
);
2982 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2987 case MP_CMD_GET_VIDEO_BITRATE
:{
2988 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2991 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2996 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2997 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
3000 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3001 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3006 case MP_CMD_GET_AUDIO_CODEC
:{
3007 char *inf
= get_metadata(META_AUDIO_CODEC
);
3010 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3015 case MP_CMD_GET_AUDIO_BITRATE
:{
3016 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3019 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3024 case MP_CMD_GET_AUDIO_SAMPLES
:{
3025 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3028 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3033 case MP_CMD_GET_META_TITLE
:{
3034 char *inf
= get_metadata(META_INFO_TITLE
);
3037 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3042 case MP_CMD_GET_META_ARTIST
:{
3043 char *inf
= get_metadata(META_INFO_ARTIST
);
3046 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3051 case MP_CMD_GET_META_ALBUM
:{
3052 char *inf
= get_metadata(META_INFO_ALBUM
);
3055 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3060 case MP_CMD_GET_META_YEAR
:{
3061 char *inf
= get_metadata(META_INFO_YEAR
);
3064 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3069 case MP_CMD_GET_META_COMMENT
:{
3070 char *inf
= get_metadata(META_INFO_COMMENT
);
3073 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3078 case MP_CMD_GET_META_TRACK
:{
3079 char *inf
= get_metadata(META_INFO_TRACK
);
3082 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3087 case MP_CMD_GET_META_GENRE
:{
3088 char *inf
= get_metadata(META_INFO_GENRE
);
3091 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3096 case MP_CMD_GET_VO_FULLSCREEN
:
3097 if (mpctx
->video_out
&& vo_config_count
)
3098 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3101 case MP_CMD_GET_PERCENT_POS
:
3102 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3103 demuxer_get_percent_pos(mpctx
->demuxer
));
3106 case MP_CMD_GET_TIME_POS
:{
3109 pos
= sh_video
->pts
;
3110 else if (sh_audio
&& mpctx
->audio_out
)
3112 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3114 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3121 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3127 case MP_CMD_KEYDOWN_EVENTS
:
3128 mplayer_put_key(cmd
->args
[0].v
.i
);
3131 case MP_CMD_SET_MOUSE_POS
:{
3132 int pointer_x
, pointer_y
;
3134 pointer_x
= cmd
->args
[0].v
.i
;
3135 pointer_y
= cmd
->args
[1].v
.i
;
3136 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3137 #ifdef CONFIG_DVDNAV
3138 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3139 && dx
> 0.0 && dy
> 0.0) {
3141 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3142 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3143 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3144 pointer_x
, pointer_y
, &button
);
3145 if (osd_level
> 1 && button
> 0)
3146 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3147 "Selected button number %d", button
);
3151 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3152 menu_update_mouse_pos(dx
, dy
);
3157 #ifdef CONFIG_DVDNAV
3158 case MP_CMD_DVDNAV
:{
3161 mp_command_type command
= 0;
3162 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3165 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3166 if (cmd
->args
[0].v
.s
&&
3167 !strcasecmp (cmd
->args
[0].v
.s
,
3168 mp_dvdnav_bindings
[i
].name
))
3169 command
= mp_dvdnav_bindings
[i
].cmd
;
3171 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3172 if (osd_level
> 1 && button
> 0)
3173 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3174 "Selected button number %d", button
);
3178 case MP_CMD_SWITCH_TITLE
:
3179 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3180 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3187 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3188 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3191 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3192 "Received unknown cmd %s\n", cmd
->name
);
3195 switch (cmd
->pausing
) {
3196 case 1: // "pausing"
3197 mpctx
->osd_function
= OSD_PAUSE
;
3199 case 3: // "pausing_toggle"
3200 mpctx
->was_paused
= !mpctx
->was_paused
;
3201 if (mpctx
->was_paused
)
3202 mpctx
->osd_function
= OSD_PAUSE
;
3203 else if (mpctx
->osd_function
== OSD_PAUSE
)
3204 mpctx
->osd_function
= OSD_PLAY
;
3206 case 2: // "pausing_keep"
3207 if (mpctx
->was_paused
)
3208 mpctx
->osd_function
= OSD_PAUSE
;