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"
31 #include "stream/tv.h"
32 #include "stream/stream_radio.h"
33 #include "stream/pvr.h"
35 #include "stream/dvbin.h"
38 #include "stream/stream_dvd.h"
40 #include "stream/stream_dvdnav.h"
41 #include "libass/ass.h"
42 #include "libass/ass_mp.h"
44 #include "libmenu/menu.h"
45 #include "gui/interface.h"
49 #include "libavutil/avstring.h"
51 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
55 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
57 //remove the borders, if any, and rescale to the range [0,1],[0,1]
58 if (vo_fs
) { //we are in full-screen mode
59 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
60 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
61 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
62 iy
-= (vo_screenheight
- vo_dheight
) / 2;
64 if (ix
< 0 || ix
> vo_dwidth
) {
67 } //we are on one of the borders
68 if (iy
< 0 || iy
> vo_dheight
) {
71 } //we are on one of the borders
74 *dx
= (double) ix
/ (double) vo_dwidth
;
75 *dy
= (double) iy
/ (double) vo_dheight
;
77 mp_msg(MSGT_CPLAYER
, MSGL_V
,
78 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
79 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
83 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
88 for (i
= 0; i
< SUB_SOURCES
; i
++) {
89 int j
= mpctx
->global_sub_indices
[i
];
90 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
98 static int sub_source(MPContext
* mpctx
)
100 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
104 * \brief Log the currently displayed subtitle to a file
106 * Logs the current or last displayed subtitle together with filename
107 * and time information to ~/.mplayer/subtitle_log
109 * Intended purpose is to allow convenient marking of bogus subtitles
110 * which need to be fixed while watching the movie.
113 static void log_sub(void)
119 if (subdata
== NULL
|| vo_sub_last
== NULL
)
121 fname
= get_path("subtitle_log");
122 f
= fopen(fname
, "a");
125 fprintf(f
, "----------------------------------------------------------\n");
126 if (subdata
->sub_uses_time
) {
128 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
129 filename
, vo_sub_last
->start
/ 360000,
130 (vo_sub_last
->start
/ 6000) % 60,
131 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
132 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
133 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
135 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
138 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
139 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
145 /// \defgroup Properties
148 /// \defgroup GeneralProperties General properties
149 /// \ingroup Properties
153 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
156 return m_property_choice(prop
, action
, arg
, &osd_level
);
160 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
164 case M_PROPERTY_PRINT
:
165 if (!arg
) return M_PROPERTY_ERROR
;
166 if (mpctx
->loop_times
< 0)
167 *(char**)arg
= strdup("off");
168 else if (mpctx
->loop_times
== 0)
169 *(char**)arg
= strdup("inf");
172 return M_PROPERTY_OK
;
174 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
177 /// Playback speed (RW)
178 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
179 void *arg
, MPContext
* mpctx
)
184 return M_PROPERTY_ERROR
;
185 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
186 playback_speed
= *(float *) arg
;
187 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
188 return M_PROPERTY_OK
;
189 case M_PROPERTY_STEP_UP
:
190 case M_PROPERTY_STEP_DOWN
:
191 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
192 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
193 M_PROPERTY_CLAMP(prop
, playback_speed
);
194 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
195 return M_PROPERTY_OK
;
197 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
200 /// filename with path (RO)
201 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
204 return m_property_string_ro(prop
, action
, arg
, filename
);
207 /// filename without path (RO)
208 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
213 return M_PROPERTY_UNAVAILABLE
;
214 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
218 return m_property_string_ro(prop
, action
, arg
, f
);
221 /// Demuxer name (RO)
222 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
226 return M_PROPERTY_UNAVAILABLE
;
227 return m_property_string_ro(prop
, action
, arg
,
228 (char *) mpctx
->demuxer
->desc
->name
);
231 /// Position in the stream (RW)
232 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
235 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
236 return M_PROPERTY_UNAVAILABLE
;
238 return M_PROPERTY_ERROR
;
241 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
242 return M_PROPERTY_OK
;
244 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
245 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
246 return M_PROPERTY_OK
;
248 return M_PROPERTY_NOT_IMPLEMENTED
;
251 /// Stream start offset (RO)
252 static int mp_property_stream_start(m_option_t
* prop
, int action
,
253 void *arg
, MPContext
* mpctx
)
255 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
256 return M_PROPERTY_UNAVAILABLE
;
259 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
260 return M_PROPERTY_OK
;
262 return M_PROPERTY_NOT_IMPLEMENTED
;
265 /// Stream end offset (RO)
266 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
269 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
270 return M_PROPERTY_UNAVAILABLE
;
273 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
274 return M_PROPERTY_OK
;
276 return M_PROPERTY_NOT_IMPLEMENTED
;
279 /// Stream length (RO)
280 static int mp_property_stream_length(m_option_t
* prop
, int action
,
281 void *arg
, MPContext
* mpctx
)
283 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
284 return M_PROPERTY_UNAVAILABLE
;
288 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
289 return M_PROPERTY_OK
;
291 return M_PROPERTY_NOT_IMPLEMENTED
;
294 /// Media length in seconds (RO)
295 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
300 if (!mpctx
->demuxer
||
301 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
302 return M_PROPERTY_UNAVAILABLE
;
304 return m_property_time_ro(prop
, action
, arg
, len
);
307 /// Current position in percent (RW)
308 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
309 void *arg
, MPContext
* mpctx
) {
313 return M_PROPERTY_UNAVAILABLE
;
317 if(!arg
) return M_PROPERTY_ERROR
;
318 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
321 case M_PROPERTY_STEP_UP
:
322 case M_PROPERTY_STEP_DOWN
:
323 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
324 pos
+= (arg
? *(int*)arg
: 10) *
325 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
326 M_PROPERTY_CLAMP(prop
, pos
);
329 return m_property_int_ro(prop
, action
, arg
,
330 demuxer_get_percent_pos(mpctx
->demuxer
));
333 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
334 rel_seek_secs
= pos
/ 100.0;
335 return M_PROPERTY_OK
;
338 /// Current position in seconds (RW)
339 static int mp_property_time_pos(m_option_t
* prop
, int action
,
340 void *arg
, MPContext
* mpctx
) {
341 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
342 return M_PROPERTY_UNAVAILABLE
;
346 if(!arg
) return M_PROPERTY_ERROR
;
347 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
348 abs_seek_pos
= SEEK_ABSOLUTE
;
349 rel_seek_secs
= *(double*)arg
;
350 return M_PROPERTY_OK
;
351 case M_PROPERTY_STEP_UP
:
352 case M_PROPERTY_STEP_DOWN
:
353 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
354 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
355 return M_PROPERTY_OK
;
357 return m_property_time_ro(prop
, action
, arg
,
358 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
359 playing_audio_pts(mpctx
->sh_audio
,
364 /// Current chapter (RW)
365 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
372 char *chapter_name
= NULL
;
375 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
377 return M_PROPERTY_UNAVAILABLE
;
382 return M_PROPERTY_ERROR
;
383 *(int *) arg
= chapter
;
384 return M_PROPERTY_OK
;
385 case M_PROPERTY_PRINT
: {
387 return M_PROPERTY_ERROR
;
388 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
390 return M_PROPERTY_UNAVAILABLE
;
391 *(char **) arg
= chapter_name
;
392 return M_PROPERTY_OK
;
396 return M_PROPERTY_ERROR
;
397 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
398 step_all
= *(int *)arg
- chapter
;
401 case M_PROPERTY_STEP_UP
:
402 case M_PROPERTY_STEP_DOWN
: {
403 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
404 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
411 return M_PROPERTY_NOT_IMPLEMENTED
;
415 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
416 &next_pts
, &chapter_num
, &chapter_name
);
418 if (next_pts
> -1.0) {
419 abs_seek_pos
= SEEK_ABSOLUTE
;
420 rel_seek_secs
= next_pts
;
423 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
424 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
426 else if (step_all
> 0)
427 rel_seek_secs
= 1000000000.;
429 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
430 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
433 return M_PROPERTY_OK
;
436 /// Number of chapters in file
437 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
441 return M_PROPERTY_UNAVAILABLE
;
442 if (mpctx
->demuxer
->num_chapters
== 0)
443 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
444 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
447 /// Current dvd angle (RW)
448 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
453 char *angle_name
= NULL
;
456 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
458 return M_PROPERTY_UNAVAILABLE
;
459 angles
= demuxer_angles_count(mpctx
->demuxer
);
461 return M_PROPERTY_UNAVAILABLE
;
466 return M_PROPERTY_ERROR
;
467 *(int *) arg
= angle
;
468 return M_PROPERTY_OK
;
469 case M_PROPERTY_PRINT
: {
471 return M_PROPERTY_ERROR
;
472 angle_name
= calloc(1, 64);
474 return M_PROPERTY_UNAVAILABLE
;
475 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
476 *(char **) arg
= angle_name
;
477 return M_PROPERTY_OK
;
481 return M_PROPERTY_ERROR
;
483 M_PROPERTY_CLAMP(prop
, angle
);
485 case M_PROPERTY_STEP_UP
:
486 case M_PROPERTY_STEP_DOWN
: {
492 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
494 if (angle
< 1) //cycle
499 return M_PROPERTY_NOT_IMPLEMENTED
;
501 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
502 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
503 MSGTR_OSDAngle
, angle
, angles
);
506 return M_PROPERTY_OK
;
509 /// Demuxer meta data
510 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
512 m_property_action_t
* ka
;
514 static m_option_t key_type
=
515 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
517 return M_PROPERTY_UNAVAILABLE
;
521 if(!arg
) return M_PROPERTY_ERROR
;
522 *(char***)arg
= mpctx
->demuxer
->info
;
523 return M_PROPERTY_OK
;
524 case M_PROPERTY_KEY_ACTION
:
525 if(!arg
) return M_PROPERTY_ERROR
;
527 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
528 return M_PROPERTY_UNKNOWN
;
531 if(!ka
->arg
) return M_PROPERTY_ERROR
;
532 *(char**)ka
->arg
= meta
;
533 return M_PROPERTY_OK
;
534 case M_PROPERTY_GET_TYPE
:
535 if(!ka
->arg
) return M_PROPERTY_ERROR
;
536 *(m_option_t
**)ka
->arg
= &key_type
;
537 return M_PROPERTY_OK
;
540 return M_PROPERTY_NOT_IMPLEMENTED
;
543 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
546 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
552 /// \defgroup AudioProperties Audio properties
553 /// \ingroup Properties
557 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
561 if (!mpctx
->sh_audio
)
562 return M_PROPERTY_UNAVAILABLE
;
567 return M_PROPERTY_ERROR
;
568 mixer_getbothvolume(&mpctx
->mixer
, arg
);
569 return M_PROPERTY_OK
;
570 case M_PROPERTY_PRINT
:{
573 return M_PROPERTY_ERROR
;
574 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
575 return m_property_float_range(prop
, action
, arg
, &vol
);
577 case M_PROPERTY_STEP_UP
:
578 case M_PROPERTY_STEP_DOWN
:
582 return M_PROPERTY_NOT_IMPLEMENTED
;
585 if (mpctx
->edl_muted
)
586 return M_PROPERTY_DISABLED
;
587 mpctx
->user_muted
= 0;
592 return M_PROPERTY_ERROR
;
593 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
594 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
595 return M_PROPERTY_OK
;
596 case M_PROPERTY_STEP_UP
:
597 if (arg
&& *(float *) arg
<= 0)
598 mixer_decvolume(&mpctx
->mixer
);
600 mixer_incvolume(&mpctx
->mixer
);
601 return M_PROPERTY_OK
;
602 case M_PROPERTY_STEP_DOWN
:
603 if (arg
&& *(float *) arg
<= 0)
604 mixer_incvolume(&mpctx
->mixer
);
606 mixer_decvolume(&mpctx
->mixer
);
607 return M_PROPERTY_OK
;
609 return M_PROPERTY_NOT_IMPLEMENTED
;
613 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
617 if (!mpctx
->sh_audio
)
618 return M_PROPERTY_UNAVAILABLE
;
622 if (mpctx
->edl_muted
)
623 return M_PROPERTY_DISABLED
;
625 return M_PROPERTY_ERROR
;
626 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
627 mixer_mute(&mpctx
->mixer
);
628 mpctx
->user_muted
= mpctx
->mixer
.muted
;
629 return M_PROPERTY_OK
;
630 case M_PROPERTY_STEP_UP
:
631 case M_PROPERTY_STEP_DOWN
:
632 if (mpctx
->edl_muted
)
633 return M_PROPERTY_DISABLED
;
634 mixer_mute(&mpctx
->mixer
);
635 mpctx
->user_muted
= mpctx
->mixer
.muted
;
636 return M_PROPERTY_OK
;
637 case M_PROPERTY_PRINT
:
639 return M_PROPERTY_ERROR
;
640 if (mpctx
->edl_muted
) {
641 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
642 return M_PROPERTY_OK
;
645 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
651 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
652 void *arg
, MPContext
* mpctx
)
654 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
655 return M_PROPERTY_UNAVAILABLE
;
658 case M_PROPERTY_STEP_UP
:
659 case M_PROPERTY_STEP_DOWN
: {
661 float delay
= audio_delay
;
662 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
663 if (ret
!= M_PROPERTY_OK
)
666 mpctx
->delay
-= audio_delay
- delay
;
668 return M_PROPERTY_OK
;
670 return m_property_delay(prop
, action
, arg
, &audio_delay
);
674 /// Audio codec tag (RO)
675 static int mp_property_audio_format(m_option_t
* prop
, int action
,
676 void *arg
, MPContext
* mpctx
)
678 if (!mpctx
->sh_audio
)
679 return M_PROPERTY_UNAVAILABLE
;
680 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
683 /// Audio codec name (RO)
684 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
685 void *arg
, MPContext
* mpctx
)
687 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
688 return M_PROPERTY_UNAVAILABLE
;
689 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
692 /// Audio bitrate (RO)
693 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
694 void *arg
, MPContext
* mpctx
)
696 if (!mpctx
->sh_audio
)
697 return M_PROPERTY_UNAVAILABLE
;
698 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
702 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
705 if (!mpctx
->sh_audio
)
706 return M_PROPERTY_UNAVAILABLE
;
708 case M_PROPERTY_PRINT
:
709 if(!arg
) return M_PROPERTY_ERROR
;
710 *(char**)arg
= malloc(16);
711 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
712 return M_PROPERTY_OK
;
714 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
717 /// Number of channels (RO)
718 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
721 if (!mpctx
->sh_audio
)
722 return M_PROPERTY_UNAVAILABLE
;
724 case M_PROPERTY_PRINT
:
726 return M_PROPERTY_ERROR
;
727 switch (mpctx
->sh_audio
->channels
) {
729 *(char **) arg
= strdup("mono");
732 *(char **) arg
= strdup("stereo");
735 *(char **) arg
= malloc(32);
736 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
738 return M_PROPERTY_OK
;
740 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
744 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
749 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
750 return M_PROPERTY_UNAVAILABLE
;
755 return M_PROPERTY_ERROR
;
756 mixer_getbalance(&mpctx
->mixer
, arg
);
757 return M_PROPERTY_OK
;
758 case M_PROPERTY_PRINT
: {
761 return M_PROPERTY_ERROR
;
762 mixer_getbalance(&mpctx
->mixer
, &bal
);
764 *str
= strdup("center");
765 else if (bal
== -1.f
)
766 *str
= strdup("left only");
768 *str
= strdup("right only");
770 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
771 *str
= malloc(sizeof("left xxx%, right xxx%"));
772 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
774 return M_PROPERTY_OK
;
776 case M_PROPERTY_STEP_UP
:
777 case M_PROPERTY_STEP_DOWN
:
778 mixer_getbalance(&mpctx
->mixer
, &bal
);
779 bal
+= (arg
? *(float*)arg
: .1f
) *
780 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
781 M_PROPERTY_CLAMP(prop
, bal
);
782 mixer_setbalance(&mpctx
->mixer
, bal
);
783 return M_PROPERTY_OK
;
786 return M_PROPERTY_ERROR
;
787 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
788 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
789 return M_PROPERTY_OK
;
791 return M_PROPERTY_NOT_IMPLEMENTED
;
794 /// Selected audio id (RW)
795 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
798 int current_id
= -1, tmp
;
802 if (!mpctx
->sh_audio
)
803 return M_PROPERTY_UNAVAILABLE
;
805 return M_PROPERTY_ERROR
;
806 *(int *) arg
= audio_id
;
807 return M_PROPERTY_OK
;
808 case M_PROPERTY_PRINT
:
809 if (!mpctx
->sh_audio
)
810 return M_PROPERTY_UNAVAILABLE
;
812 return M_PROPERTY_ERROR
;
815 *(char **) arg
= strdup(MSGTR_Disabled
);
817 char lang
[40] = MSGTR_Unknown
;
818 sh_audio_t
* sh
= mpctx
->sh_audio
;
820 av_strlcpy(lang
, sh
->lang
, 40);
821 #ifdef CONFIG_DVDREAD
822 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
823 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
833 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
834 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
836 *(char **) arg
= malloc(64);
837 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
839 return M_PROPERTY_OK
;
841 case M_PROPERTY_STEP_UP
:
844 return M_PROPERTY_UNAVAILABLE
;
845 if (action
== M_PROPERTY_SET
&& arg
)
846 tmp
= *((int *) arg
);
849 current_id
= mpctx
->demuxer
->audio
->id
;
850 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
853 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
854 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
855 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
857 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
859 sh2
->ds
= mpctx
->demuxer
->audio
;
860 mpctx
->sh_audio
= sh2
;
861 reinit_audio_chain();
864 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
865 return M_PROPERTY_OK
;
867 return M_PROPERTY_NOT_IMPLEMENTED
;
872 /// Selected video id (RW)
873 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
876 int current_id
= -1, tmp
;
880 if (!mpctx
->sh_video
)
881 return M_PROPERTY_UNAVAILABLE
;
883 return M_PROPERTY_ERROR
;
884 *(int *) arg
= video_id
;
885 return M_PROPERTY_OK
;
886 case M_PROPERTY_PRINT
:
887 if (!mpctx
->sh_video
)
888 return M_PROPERTY_UNAVAILABLE
;
890 return M_PROPERTY_ERROR
;
893 *(char **) arg
= strdup(MSGTR_Disabled
);
895 char lang
[40] = MSGTR_Unknown
;
896 *(char **) arg
= malloc(64);
897 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
899 return M_PROPERTY_OK
;
901 case M_PROPERTY_STEP_UP
:
903 current_id
= mpctx
->demuxer
->video
->id
;
904 if (action
== M_PROPERTY_SET
&& arg
)
905 tmp
= *((int *) arg
);
908 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
910 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
911 && current_id
!= -2))
912 uninit_player(INITIALIZED_VCODEC
|
913 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
914 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
916 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
918 sh2
->ds
= mpctx
->demuxer
->video
;
919 mpctx
->sh_video
= sh2
;
920 reinit_video_chain();
923 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
924 return M_PROPERTY_OK
;
927 return M_PROPERTY_NOT_IMPLEMENTED
;
931 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
934 demux_program_t prog
;
937 case M_PROPERTY_STEP_UP
:
939 if (action
== M_PROPERTY_SET
&& arg
)
940 prog
.progid
= *((int *) arg
);
944 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
945 &prog
) == DEMUXER_CTRL_NOTIMPL
)
946 return M_PROPERTY_ERROR
;
948 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
949 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
950 return M_PROPERTY_OK
;
953 return M_PROPERTY_NOT_IMPLEMENTED
;
959 /// \defgroup VideoProperties Video properties
960 /// \ingroup Properties
963 /// Fullscreen state (RW)
964 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
968 if (!mpctx
->video_out
)
969 return M_PROPERTY_UNAVAILABLE
;
974 return M_PROPERTY_ERROR
;
975 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
976 if (vo_fs
== !!*(int *) arg
)
977 return M_PROPERTY_OK
;
978 case M_PROPERTY_STEP_UP
:
979 case M_PROPERTY_STEP_DOWN
:
982 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
986 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
987 return M_PROPERTY_OK
;
989 return m_property_flag(prop
, action
, arg
, &vo_fs
);
993 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
994 void *arg
, MPContext
* mpctx
)
998 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
999 return M_PROPERTY_UNAVAILABLE
;
1000 vf
= mpctx
->sh_video
->vfilter
;
1002 case M_PROPERTY_GET
:
1004 return M_PROPERTY_ERROR
;
1005 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1006 return M_PROPERTY_OK
;
1007 case M_PROPERTY_SET
:
1009 return M_PROPERTY_ERROR
;
1010 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1011 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1012 return M_PROPERTY_OK
;
1013 case M_PROPERTY_STEP_UP
:
1014 case M_PROPERTY_STEP_DOWN
:
1015 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1016 deinterlace
= !deinterlace
;
1017 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1018 return M_PROPERTY_OK
;
1020 return M_PROPERTY_NOT_IMPLEMENTED
;
1024 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1028 if (!mpctx
->video_out
1029 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1030 return M_PROPERTY_UNAVAILABLE
;
1033 case M_PROPERTY_SET
:
1035 return M_PROPERTY_ERROR
;
1036 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1037 vo_panscan
= *(float *) arg
;
1038 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1039 return M_PROPERTY_OK
;
1040 case M_PROPERTY_STEP_UP
:
1041 case M_PROPERTY_STEP_DOWN
:
1042 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1043 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1046 else if (vo_panscan
< 0)
1048 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1049 return M_PROPERTY_OK
;
1051 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1055 /// Helper to set vo flags.
1056 /** \ingroup PropertyImplHelper
1058 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1059 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1062 if (!mpctx
->video_out
)
1063 return M_PROPERTY_UNAVAILABLE
;
1066 case M_PROPERTY_SET
:
1068 return M_PROPERTY_ERROR
;
1069 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1070 if (*vo_var
== !!*(int *) arg
)
1071 return M_PROPERTY_OK
;
1072 case M_PROPERTY_STEP_UP
:
1073 case M_PROPERTY_STEP_DOWN
:
1074 if (vo_config_count
)
1075 mpctx
->video_out
->control(vo_ctrl
, 0);
1076 return M_PROPERTY_OK
;
1078 return m_property_flag(prop
, action
, arg
, vo_var
);
1082 /// Window always on top (RW)
1083 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1086 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1090 /// Display in the root window (RW)
1091 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1094 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1095 &vo_rootwin
, mpctx
);
1098 /// Show window borders (RW)
1099 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1102 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1106 /// Framedropping state (RW)
1107 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1108 void *arg
, MPContext
* mpctx
)
1111 if (!mpctx
->sh_video
)
1112 return M_PROPERTY_UNAVAILABLE
;
1115 case M_PROPERTY_PRINT
:
1117 return M_PROPERTY_ERROR
;
1118 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1119 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1121 return M_PROPERTY_OK
;
1123 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1127 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1128 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1131 int *gamma
= prop
->priv
, r
, val
;
1133 if (!mpctx
->sh_video
)
1134 return M_PROPERTY_UNAVAILABLE
;
1136 if (gamma
[0] == 1000) {
1138 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1142 case M_PROPERTY_SET
:
1144 return M_PROPERTY_ERROR
;
1145 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1146 *gamma
= *(int *) arg
;
1147 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1151 case M_PROPERTY_GET
:
1152 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1154 return M_PROPERTY_ERROR
;
1156 return M_PROPERTY_OK
;
1159 case M_PROPERTY_STEP_UP
:
1160 case M_PROPERTY_STEP_DOWN
:
1161 *gamma
+= (arg
? *(int *) arg
: 1) *
1162 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1163 M_PROPERTY_CLAMP(prop
, *gamma
);
1164 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1169 return M_PROPERTY_NOT_IMPLEMENTED
;
1173 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1174 int l
= strlen(prop
->name
);
1175 char tv_prop
[3 + l
+ 1];
1176 sprintf(tv_prop
, "tv_%s", prop
->name
);
1177 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1181 return M_PROPERTY_UNAVAILABLE
;
1185 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1188 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1191 /// Video codec tag (RO)
1192 static int mp_property_video_format(m_option_t
* prop
, int action
,
1193 void *arg
, MPContext
* mpctx
)
1196 if (!mpctx
->sh_video
)
1197 return M_PROPERTY_UNAVAILABLE
;
1199 case M_PROPERTY_PRINT
:
1201 return M_PROPERTY_ERROR
;
1202 switch(mpctx
->sh_video
->format
) {
1204 meta
= strdup ("mpeg1"); break;
1206 meta
= strdup ("mpeg2"); break;
1208 meta
= strdup ("mpeg4"); break;
1210 meta
= strdup ("h264"); break;
1212 if(mpctx
->sh_video
->format
>= 0x20202020) {
1214 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1217 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1220 *(char**)arg
= meta
;
1221 return M_PROPERTY_OK
;
1223 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1226 /// Video codec name (RO)
1227 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1228 void *arg
, MPContext
* mpctx
)
1230 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1231 return M_PROPERTY_UNAVAILABLE
;
1232 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1236 /// Video bitrate (RO)
1237 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1238 void *arg
, MPContext
* mpctx
)
1240 if (!mpctx
->sh_video
)
1241 return M_PROPERTY_UNAVAILABLE
;
1242 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1245 /// Video display width (RO)
1246 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1249 if (!mpctx
->sh_video
)
1250 return M_PROPERTY_UNAVAILABLE
;
1251 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1254 /// Video display height (RO)
1255 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1258 if (!mpctx
->sh_video
)
1259 return M_PROPERTY_UNAVAILABLE
;
1260 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1264 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1267 if (!mpctx
->sh_video
)
1268 return M_PROPERTY_UNAVAILABLE
;
1269 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1272 /// Video aspect (RO)
1273 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1276 if (!mpctx
->sh_video
)
1277 return M_PROPERTY_UNAVAILABLE
;
1278 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1283 /// \defgroup SubProprties Subtitles properties
1284 /// \ingroup Properties
1287 /// Text subtitle position (RW)
1288 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1291 if (!mpctx
->sh_video
)
1292 return M_PROPERTY_UNAVAILABLE
;
1295 case M_PROPERTY_SET
:
1297 return M_PROPERTY_ERROR
;
1298 case M_PROPERTY_STEP_UP
:
1299 case M_PROPERTY_STEP_DOWN
:
1300 vo_osd_changed(OSDTYPE_SUBTITLE
);
1302 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1306 /// Selected subtitles (RW)
1307 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1310 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1311 const int global_sub_size
= mpctx
->global_sub_size
;
1312 int source
= -1, reset_spu
= 0;
1315 if (global_sub_size
<= 0)
1316 return M_PROPERTY_UNAVAILABLE
;
1319 case M_PROPERTY_GET
:
1321 return M_PROPERTY_ERROR
;
1322 *(int *) arg
= mpctx
->global_sub_pos
;
1323 return M_PROPERTY_OK
;
1324 case M_PROPERTY_PRINT
:
1326 return M_PROPERTY_ERROR
;
1327 *(char **) arg
= malloc(64);
1328 (*(char **) arg
)[63] = 0;
1331 sub_name
= subdata
->filename
;
1333 if (ass_track
&& ass_track
->name
)
1334 sub_name
= ass_track
->name
;
1339 if ((tmp2
= strrchr(tmp
, '/')))
1342 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1343 mpctx
->set_of_sub_pos
+ 1,
1344 strlen(tmp
) < 20 ? "" : "...",
1345 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1346 return M_PROPERTY_OK
;
1348 #ifdef CONFIG_DVDNAV
1349 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1350 if (vo_spudec
&& dvdsub_id
>= 0) {
1351 unsigned char lang
[3];
1352 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1353 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1354 return M_PROPERTY_OK
;
1360 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1361 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1362 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1363 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1364 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1365 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1366 if (!lang
) lang
= MSGTR_Unknown
;
1367 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1368 return M_PROPERTY_OK
;
1371 if (vo_vobsub
&& vobsub_id
>= 0) {
1372 const char *language
= MSGTR_Unknown
;
1373 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1374 snprintf(*(char **) arg
, 63, "(%d) %s",
1375 vobsub_id
, language
? language
: MSGTR_Unknown
);
1376 return M_PROPERTY_OK
;
1378 #ifdef CONFIG_DVDREAD
1379 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1380 && dvdsub_id
>= 0) {
1382 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1383 lang
[0] = code
>> 8;
1386 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1387 return M_PROPERTY_OK
;
1390 if (dvdsub_id
>= 0) {
1391 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1392 return M_PROPERTY_OK
;
1394 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1395 return M_PROPERTY_OK
;
1397 case M_PROPERTY_SET
:
1399 return M_PROPERTY_ERROR
;
1400 if (*(int *) arg
< -1)
1402 else if (*(int *) arg
>= global_sub_size
)
1403 *(int *) arg
= global_sub_size
- 1;
1404 mpctx
->global_sub_pos
= *(int *) arg
;
1406 case M_PROPERTY_STEP_UP
:
1407 mpctx
->global_sub_pos
+= 2;
1408 mpctx
->global_sub_pos
=
1409 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1411 case M_PROPERTY_STEP_DOWN
:
1412 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1413 mpctx
->global_sub_pos
=
1414 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1417 return M_PROPERTY_NOT_IMPLEMENTED
;
1420 if (mpctx
->global_sub_pos
>= 0)
1421 source
= sub_source(mpctx
);
1423 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1424 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1426 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1427 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1428 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1429 mpctx
->global_sub_pos
, source
);
1431 mpctx
->set_of_sub_pos
= -1;
1445 if (source
== SUB_SOURCE_VOBSUB
) {
1446 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1447 } else if (source
== SUB_SOURCE_SUBS
) {
1448 mpctx
->set_of_sub_pos
=
1449 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1451 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1452 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1456 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1457 vo_osd_changed(OSDTYPE_SUBTITLE
);
1459 } else if (source
== SUB_SOURCE_DEMUX
) {
1461 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1462 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1464 // default: assume 1:1 mapping of sid and stream id
1465 d_sub
->id
= dvdsub_id
;
1466 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1467 ds_free_packs(d_sub
);
1468 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1469 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1470 if (sh
&& sh
->sid
== dvdsub_id
) {
1476 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1477 sh_sub_t
*sh
= d_sub
->sh
;
1478 if (sh
->type
== 'v')
1481 else if (ass_enabled
)
1482 ass_track
= sh
->ass_track
;
1490 #ifdef CONFIG_DVDREAD
1492 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1493 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1494 && dvdsub_id
< 0 && reset_spu
) {
1496 d_sub
->id
= dvdsub_id
;
1499 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1501 return M_PROPERTY_OK
;
1504 /// Selected sub source (RW)
1505 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1509 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1510 return M_PROPERTY_UNAVAILABLE
;
1513 case M_PROPERTY_GET
:
1515 return M_PROPERTY_ERROR
;
1516 *(int *) arg
= sub_source(mpctx
);
1517 return M_PROPERTY_OK
;
1518 case M_PROPERTY_PRINT
:
1520 return M_PROPERTY_ERROR
;
1521 *(char **) arg
= malloc(64);
1522 (*(char **) arg
)[63] = 0;
1523 switch (sub_source(mpctx
))
1525 case SUB_SOURCE_SUBS
:
1526 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1528 case SUB_SOURCE_VOBSUB
:
1529 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1531 case SUB_SOURCE_DEMUX
:
1532 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1535 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1537 return M_PROPERTY_OK
;
1538 case M_PROPERTY_SET
:
1540 return M_PROPERTY_ERROR
;
1541 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1542 if (*(int *) arg
< 0)
1543 mpctx
->global_sub_pos
= -1;
1544 else if (*(int *) arg
!= sub_source(mpctx
)) {
1545 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1546 return M_PROPERTY_UNAVAILABLE
;
1547 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1550 case M_PROPERTY_STEP_UP
:
1551 case M_PROPERTY_STEP_DOWN
: {
1552 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1553 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1554 int step
= (step_all
> 0) ? 1 : -1;
1555 int cur_source
= sub_source(mpctx
);
1556 source
= cur_source
;
1559 if (source
>= SUB_SOURCES
)
1561 else if (source
< -1)
1562 source
= SUB_SOURCES
- 1;
1563 if (source
== cur_source
|| source
== -1 ||
1564 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1567 if (source
== cur_source
)
1568 return M_PROPERTY_OK
;
1570 mpctx
->global_sub_pos
= -1;
1572 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1576 return M_PROPERTY_NOT_IMPLEMENTED
;
1578 --mpctx
->global_sub_pos
;
1579 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1582 /// Selected subtitles from specific source (RW)
1583 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1586 int source
, is_cur_source
, offset
;
1587 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1588 return M_PROPERTY_UNAVAILABLE
;
1590 if (!strcmp(prop
->name
, "sub_file"))
1591 source
= SUB_SOURCE_SUBS
;
1592 else if (!strcmp(prop
->name
, "sub_vob"))
1593 source
= SUB_SOURCE_VOBSUB
;
1594 else if (!strcmp(prop
->name
, "sub_demux"))
1595 source
= SUB_SOURCE_DEMUX
;
1597 return M_PROPERTY_ERROR
;
1599 offset
= mpctx
->global_sub_indices
[source
];
1600 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1601 return M_PROPERTY_UNAVAILABLE
;
1603 is_cur_source
= sub_source(mpctx
) == source
;
1605 case M_PROPERTY_GET
:
1607 return M_PROPERTY_ERROR
;
1608 if (is_cur_source
) {
1609 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1610 if (source
== SUB_SOURCE_VOBSUB
)
1611 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1615 return M_PROPERTY_OK
;
1616 case M_PROPERTY_PRINT
:
1618 return M_PROPERTY_ERROR
;
1620 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1621 *(char **) arg
= malloc(64);
1622 (*(char **) arg
)[63] = 0;
1623 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1624 return M_PROPERTY_OK
;
1625 case M_PROPERTY_SET
:
1627 return M_PROPERTY_ERROR
;
1628 if (*(int *) arg
>= 0) {
1629 int index
= *(int *)arg
;
1630 if (source
== SUB_SOURCE_VOBSUB
)
1631 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1632 mpctx
->global_sub_pos
= offset
+ index
;
1633 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1634 || sub_source(mpctx
) != source
) {
1635 mpctx
->global_sub_pos
= -1;
1640 mpctx
->global_sub_pos
= -1;
1642 case M_PROPERTY_STEP_UP
:
1643 case M_PROPERTY_STEP_DOWN
: {
1644 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1645 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1646 int step
= (step_all
> 0) ? 1 : -1;
1647 int max_sub_pos_for_source
= -1;
1649 mpctx
->global_sub_pos
= -1;
1651 if (mpctx
->global_sub_pos
== -1) {
1653 mpctx
->global_sub_pos
= offset
;
1654 else if (max_sub_pos_for_source
== -1) {
1655 // Find max pos for specific source
1656 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1657 while (mpctx
->global_sub_pos
>= 0
1658 && sub_source(mpctx
) != source
)
1659 --mpctx
->global_sub_pos
;
1662 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1665 mpctx
->global_sub_pos
+= step
;
1666 if (mpctx
->global_sub_pos
< offset
||
1667 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1668 sub_source(mpctx
) != source
)
1669 mpctx
->global_sub_pos
= -1;
1676 return M_PROPERTY_NOT_IMPLEMENTED
;
1678 --mpctx
->global_sub_pos
;
1679 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1682 /// Subtitle delay (RW)
1683 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1686 if (!mpctx
->sh_video
)
1687 return M_PROPERTY_UNAVAILABLE
;
1688 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1691 /// Alignment of text subtitles (RW)
1692 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1693 void *arg
, MPContext
* mpctx
)
1695 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1697 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1698 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1699 return M_PROPERTY_UNAVAILABLE
;
1702 case M_PROPERTY_PRINT
:
1704 return M_PROPERTY_ERROR
;
1705 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1706 *(char **) arg
= strdup(name
[sub_alignment
]);
1707 return M_PROPERTY_OK
;
1708 case M_PROPERTY_SET
:
1710 return M_PROPERTY_ERROR
;
1711 case M_PROPERTY_STEP_UP
:
1712 case M_PROPERTY_STEP_DOWN
:
1713 vo_osd_changed(OSDTYPE_SUBTITLE
);
1715 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1719 /// Subtitle visibility (RW)
1720 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1721 void *arg
, MPContext
* mpctx
)
1723 if (!mpctx
->sh_video
)
1724 return M_PROPERTY_UNAVAILABLE
;
1727 case M_PROPERTY_SET
:
1729 return M_PROPERTY_ERROR
;
1730 case M_PROPERTY_STEP_UP
:
1731 case M_PROPERTY_STEP_DOWN
:
1732 vo_osd_changed(OSDTYPE_SUBTITLE
);
1734 vo_osd_changed(OSDTYPE_SPU
);
1736 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1741 /// Use margins for libass subtitles (RW)
1742 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1743 void *arg
, MPContext
* mpctx
)
1745 if (!mpctx
->sh_video
)
1746 return M_PROPERTY_UNAVAILABLE
;
1749 case M_PROPERTY_SET
:
1751 return M_PROPERTY_ERROR
;
1752 case M_PROPERTY_STEP_UP
:
1753 case M_PROPERTY_STEP_DOWN
:
1754 ass_force_reload
= 1;
1756 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1761 /// Show only forced subtitles (RW)
1762 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1763 void *arg
, MPContext
* mpctx
)
1766 return M_PROPERTY_UNAVAILABLE
;
1769 case M_PROPERTY_SET
:
1771 return M_PROPERTY_ERROR
;
1772 case M_PROPERTY_STEP_UP
:
1773 case M_PROPERTY_STEP_DOWN
:
1774 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1775 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1776 return M_PROPERTY_OK
;
1778 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1783 #ifdef CONFIG_FREETYPE
1784 /// Subtitle scale (RW)
1785 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1790 case M_PROPERTY_SET
:
1792 return M_PROPERTY_ERROR
;
1793 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1796 ass_font_scale
= *(float *) arg
;
1797 ass_force_reload
= 1;
1800 text_font_scale_factor
= *(float *) arg
;
1801 force_load_font
= 1;
1802 return M_PROPERTY_OK
;
1803 case M_PROPERTY_STEP_UP
:
1804 case M_PROPERTY_STEP_DOWN
:
1807 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1808 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1809 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1810 ass_force_reload
= 1;
1813 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1814 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1815 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1816 force_load_font
= 1;
1817 return M_PROPERTY_OK
;
1821 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1824 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1831 /// \defgroup TVProperties TV properties
1832 /// \ingroup Properties
1837 /// TV color settings (RW)
1838 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1842 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1843 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1844 return M_PROPERTY_UNAVAILABLE
;
1847 case M_PROPERTY_SET
:
1849 return M_PROPERTY_ERROR
;
1850 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1851 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1852 case M_PROPERTY_GET
:
1853 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1854 case M_PROPERTY_STEP_UP
:
1855 case M_PROPERTY_STEP_DOWN
:
1856 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1858 return M_PROPERTY_ERROR
;
1859 val
+= (arg
? *(int *) arg
: 1) *
1860 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1861 M_PROPERTY_CLAMP(prop
, val
);
1862 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1864 return M_PROPERTY_ERROR
;
1866 return M_PROPERTY_NOT_IMPLEMENTED
;
1871 #ifdef CONFIG_TV_TELETEXT
1872 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1876 int base_ioctl
=(int)prop
->priv
;
1878 for teletext's GET,SET,STEP ioctls this is not 0
1882 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1883 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1884 return M_PROPERTY_UNAVAILABLE
;
1886 return M_PROPERTY_ERROR
;
1889 case M_PROPERTY_GET
:
1891 return M_PROPERTY_ERROR
;
1892 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1894 case M_PROPERTY_SET
:
1896 return M_PROPERTY_ERROR
;
1897 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1898 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1900 case M_PROPERTY_STEP_UP
:
1901 case M_PROPERTY_STEP_DOWN
:
1902 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1903 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1904 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1907 return M_PROPERTY_NOT_IMPLEMENTED
;
1910 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1913 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1916 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1920 //with tvh==NULL will fail too
1921 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1922 if(result
!=M_PROPERTY_OK
)
1925 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1926 mp_input_set_section("teletext");
1928 mp_input_set_section("tv");
1929 return M_PROPERTY_OK
;
1932 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1935 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1938 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1939 return M_PROPERTY_UNAVAILABLE
;
1941 case M_PROPERTY_STEP_UP
:
1942 case M_PROPERTY_STEP_DOWN
:
1943 //This should be handled separately
1944 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1945 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1948 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1954 #endif /* CONFIG_TV_TELETEXT */
1958 /// All properties available in MPlayer.
1959 /** \ingroup Properties
1961 static const m_option_t mp_properties
[] = {
1963 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1964 M_OPT_RANGE
, 0, 3, NULL
},
1965 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1966 M_OPT_MIN
, -1, 0, NULL
},
1967 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1968 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1969 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1971 { "path", mp_property_path
, CONF_TYPE_STRING
,
1973 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1975 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1976 M_OPT_MIN
, 0, 0, NULL
},
1977 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1978 M_OPT_MIN
, 0, 0, NULL
},
1979 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1980 M_OPT_MIN
, 0, 0, NULL
},
1981 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1982 M_OPT_MIN
, 0, 0, NULL
},
1983 { "length", mp_property_length
, CONF_TYPE_TIME
,
1984 M_OPT_MIN
, 0, 0, NULL
},
1985 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1986 M_OPT_RANGE
, 0, 100, NULL
},
1987 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1988 M_OPT_MIN
, 0, 0, NULL
},
1989 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1990 M_OPT_MIN
, 0, 0, NULL
},
1991 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
1993 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1994 CONF_RANGE
, -2, 10, NULL
},
1995 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1997 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
1998 M_OPT_RANGE
, 0, 1, NULL
},
2001 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2002 M_OPT_RANGE
, 0, 100, NULL
},
2003 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2004 M_OPT_RANGE
, 0, 1, NULL
},
2005 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2006 M_OPT_RANGE
, -100, 100, NULL
},
2007 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2009 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2011 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2013 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2015 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2017 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2018 CONF_RANGE
, -2, 65535, NULL
},
2019 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2020 M_OPT_RANGE
, -1, 1, NULL
},
2023 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2024 M_OPT_RANGE
, 0, 1, NULL
},
2025 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2026 M_OPT_RANGE
, 0, 1, NULL
},
2027 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2028 M_OPT_RANGE
, 0, 1, NULL
},
2029 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2030 M_OPT_RANGE
, 0, 1, NULL
},
2031 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2032 M_OPT_RANGE
, 0, 1, NULL
},
2033 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2034 M_OPT_RANGE
, 0, 2, NULL
},
2035 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2036 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2037 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2038 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2039 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2040 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2041 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2042 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2043 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2044 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2045 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2046 M_OPT_RANGE
, 0, 1, NULL
},
2047 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2048 M_OPT_RANGE
, 0, 1, NULL
},
2049 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2051 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2053 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2055 { "width", mp_property_width
, CONF_TYPE_INT
,
2057 { "height", mp_property_height
, CONF_TYPE_INT
,
2059 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2061 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2063 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2064 CONF_RANGE
, -2, 65535, NULL
},
2065 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2066 CONF_RANGE
, -1, 65535, NULL
},
2069 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2070 M_OPT_MIN
, -1, 0, NULL
},
2071 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2072 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2073 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2074 M_OPT_MIN
, -1, 0, NULL
},
2075 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2076 M_OPT_MIN
, -1, 0, NULL
},
2077 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2078 M_OPT_MIN
, -1, 0, NULL
},
2079 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2081 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2082 M_OPT_RANGE
, 0, 100, NULL
},
2083 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2084 M_OPT_RANGE
, 0, 2, NULL
},
2085 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2086 M_OPT_RANGE
, 0, 1, NULL
},
2087 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2088 M_OPT_RANGE
, 0, 1, NULL
},
2089 #ifdef CONFIG_FREETYPE
2090 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2091 M_OPT_RANGE
, 0, 100, NULL
},
2094 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2095 M_OPT_RANGE
, 0, 1, NULL
},
2099 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2100 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2101 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2102 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2103 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2104 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2105 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2106 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2109 #ifdef CONFIG_TV_TELETEXT
2110 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2111 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2112 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2114 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2115 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2116 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2117 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2118 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2119 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2122 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2126 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2128 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2131 char* mp_property_print(const char *name
, void* ctx
)
2134 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2139 char *property_expand_string(MPContext
* mpctx
, char *str
)
2141 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2144 void property_print_help(void)
2146 m_properties_print_help_list(mp_properties
);
2155 * \defgroup Command2Property Command to property bridge
2157 * It is used to handle most commands that just set a property
2158 * and optionally display something on the OSD.
2159 * Two kinds of commands are handled: adjust or toggle.
2161 * Adjust commands take 1 or 2 parameters: <value> <abs>
2162 * If <abs> is non-zero the property is set to the given value
2163 * otherwise it is adjusted.
2165 * Toggle commands take 0 or 1 parameters. With no parameter
2166 * or a value less than the property minimum it just steps the
2167 * property to its next value. Otherwise it sets it to the given
2173 /// List of the commands that can be handled by setting a property.
2179 /// set/adjust or toggle command
2181 /// progressbar type
2183 /// osd msg id if it must be shared
2185 /// osd msg template
2186 const char *osd_msg
;
2187 } set_prop_cmd
[] = {
2189 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2190 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2191 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2193 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2194 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2195 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2196 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2197 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2199 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2200 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2201 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2202 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2203 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2204 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2205 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2206 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2207 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2208 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2209 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2210 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2212 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2213 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2214 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2215 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2216 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2217 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2218 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2219 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2220 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2221 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2222 #ifdef CONFIG_FREETYPE
2223 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2226 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2229 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2230 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2231 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2232 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2234 { NULL
, 0, 0, 0, -1, NULL
}
2238 /// Handle commands that set a property.
2239 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2245 // look for the command
2246 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2247 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2249 if (!(pname
= set_prop_cmd
[i
].name
))
2252 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2256 if (set_prop_cmd
[i
].toggle
) {
2258 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2259 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2261 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2262 } else if (cmd
->args
[1].v
.i
) //set
2263 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2265 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2270 if (set_prop_cmd
[i
].osd_progbar
) {
2271 if (prop
->type
== CONF_TYPE_INT
) {
2272 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2273 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2274 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2275 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2277 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2278 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2279 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2281 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2282 "Property use an unsupported type.\n");
2286 if (set_prop_cmd
[i
].osd_msg
) {
2287 char *val
= mp_property_print(pname
, mpctx
);
2289 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2290 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2291 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2298 #ifdef CONFIG_DVDNAV
2299 static const struct {
2301 const mp_command_type cmd
;
2302 } mp_dvdnav_bindings
[] = {
2303 { "up", MP_CMD_DVDNAV_UP
},
2304 { "down", MP_CMD_DVDNAV_DOWN
},
2305 { "left", MP_CMD_DVDNAV_LEFT
},
2306 { "right", MP_CMD_DVDNAV_RIGHT
},
2307 { "menu", MP_CMD_DVDNAV_MENU
},
2308 { "select", MP_CMD_DVDNAV_SELECT
},
2309 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2310 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2313 * keep old dvdnav sub-command options for a while in order not to
2314 * break slave-mode API too suddenly.
2316 { "1", MP_CMD_DVDNAV_UP
},
2317 { "2", MP_CMD_DVDNAV_DOWN
},
2318 { "3", MP_CMD_DVDNAV_LEFT
},
2319 { "4", MP_CMD_DVDNAV_RIGHT
},
2320 { "5", MP_CMD_DVDNAV_MENU
},
2321 { "6", MP_CMD_DVDNAV_SELECT
},
2322 { "7", MP_CMD_DVDNAV_PREVMENU
},
2323 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2328 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2330 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2331 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2333 if (!set_property_command(mpctx
, cmd
))
2339 mpctx
->osd_show_percentage
= sh_video
->fps
;
2340 v
= cmd
->args
[0].v
.f
;
2341 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2342 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2343 abs_seek_pos
= SEEK_ABSOLUTE
;
2345 mpctx
->osd_function
=
2346 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2348 } else if (abs
) { /* Absolute seek by percentage */
2349 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2351 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2352 rel_seek_secs
= v
/ 100.0;
2355 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2361 case MP_CMD_SET_PROPERTY
:{
2362 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2363 cmd
->args
[1].v
.s
, mpctx
);
2364 if (r
== M_PROPERTY_UNKNOWN
)
2365 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2366 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2368 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2369 "Failed to set property '%s' to '%s'.\n",
2370 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2374 case MP_CMD_STEP_PROPERTY
:{
2379 if (cmd
->args
[1].v
.f
) {
2381 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2382 M_PROPERTY_GET_TYPE
,
2383 &prop
, mpctx
)) <= 0)
2385 if(prop
->type
== CONF_TYPE_INT
||
2386 prop
->type
== CONF_TYPE_FLAG
)
2387 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2388 else if(prop
->type
== CONF_TYPE_FLOAT
)
2389 arg
= &cmd
->args
[1].v
.f
;
2390 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2391 prop
->type
== CONF_TYPE_TIME
)
2392 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2393 else if(prop
->type
== CONF_TYPE_POSITION
)
2394 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2396 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2397 "Ignoring step size stepping property '%s'.\n",
2400 r
= mp_property_do(cmd
->args
[0].v
.s
,
2401 cmd
->args
[2].v
.i
< 0 ?
2402 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2405 if (r
== M_PROPERTY_UNKNOWN
)
2406 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2407 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2409 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2410 "Failed to increment property '%s' by %f.\n",
2411 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2415 case MP_CMD_GET_PROPERTY
:{
2417 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2418 &tmp
, mpctx
) <= 0) {
2419 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2420 "Failed to get value of property '%s'.\n",
2424 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2425 cmd
->args
[0].v
.s
, tmp
);
2430 case MP_CMD_EDL_MARK
:
2432 float v
= sh_video
? sh_video
->pts
:
2433 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2436 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2437 mpctx
->begin_skip
= v
;
2438 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2440 if (mpctx
->begin_skip
> v
)
2441 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2443 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2444 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2446 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2451 case MP_CMD_SWITCH_RATIO
:
2454 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2455 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2457 movie_aspect
= cmd
->args
[0].v
.f
;
2458 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2461 case MP_CMD_SPEED_INCR
:{
2462 float v
= cmd
->args
[0].v
.f
;
2463 playback_speed
+= v
;
2464 build_afilter_chain(sh_audio
, &ao_data
);
2465 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2469 case MP_CMD_SPEED_MULT
:{
2470 float v
= cmd
->args
[0].v
.f
;
2471 playback_speed
*= v
;
2472 build_afilter_chain(sh_audio
, &ao_data
);
2473 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2477 case MP_CMD_SPEED_SET
:{
2478 float v
= cmd
->args
[0].v
.f
;
2480 build_afilter_chain(sh_audio
, &ao_data
);
2481 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2485 case MP_CMD_FRAME_STEP
:
2491 case MP_CMD_FILE_FILTER
:
2492 file_filter
= cmd
->args
[0].v
.i
;
2496 exit_player_with_rc(EXIT_QUIT
,
2497 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2499 case MP_CMD_PLAY_TREE_STEP
:{
2500 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2501 int force
= cmd
->args
[1].v
.i
;
2507 for (i
= 0; i
< n
; i
++)
2510 for (i
= 0; i
< -1 * n
; i
++)
2515 if (!force
&& mpctx
->playtree_iter
) {
2516 play_tree_iter_t
*i
=
2517 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2518 if (play_tree_iter_step(i
, n
, 0) ==
2519 PLAY_TREE_ITER_ENTRY
)
2521 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2522 play_tree_iter_free(i
);
2524 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2526 mpctx
->play_tree_step
= n
;
2532 case MP_CMD_PLAY_TREE_UP_STEP
:{
2533 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2534 int force
= cmd
->args
[1].v
.i
;
2536 if (!force
&& mpctx
->playtree_iter
) {
2537 play_tree_iter_t
*i
=
2538 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2539 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2540 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2541 play_tree_iter_free(i
);
2543 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2548 case MP_CMD_PLAY_ALT_SRC_STEP
:
2549 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2550 int v
= cmd
->args
[0].v
.i
;
2552 && mpctx
->playtree_iter
->file
<
2553 mpctx
->playtree_iter
->num_files
)
2554 mpctx
->eof
= PT_NEXT_SRC
;
2555 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2556 mpctx
->eof
= PT_PREV_SRC
;
2561 case MP_CMD_SUB_STEP
:
2563 int movement
= cmd
->args
[0].v
.i
;
2564 step_sub(subdata
, sh_video
->pts
, movement
);
2568 ass_step_sub(ass_track
,
2570 sub_delay
) * 1000 + .5, movement
) / 1000.;
2572 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2573 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2577 case MP_CMD_SUB_LOG
:
2582 int v
= cmd
->args
[0].v
.i
;
2584 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2585 if (osd_level
> max
)
2588 osd_level
= (osd_level
+ 1) % (max
+ 1);
2590 osd_level
= v
> max
? max
: v
;
2591 /* Show OSD state when disabled, but not when an explicit
2592 argument is given to the OSD command, i.e. in slave mode. */
2593 if (v
== -1 && osd_level
<= 1)
2594 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2596 osd_level
? MSGTR_OSDenabled
:
2599 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2603 case MP_CMD_OSD_SHOW_TEXT
:
2604 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2606 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2607 "%-.63s", cmd
->args
[0].v
.s
);
2610 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2611 char *txt
= m_properties_expand_string(mp_properties
,
2614 /* if no argument supplied take default osd_duration, else <arg> ms. */
2616 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2618 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2625 case MP_CMD_LOADFILE
:{
2626 play_tree_t
*e
= play_tree_new();
2627 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2629 if (cmd
->args
[1].v
.i
) // append
2630 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2632 // Go back to the starting point.
2633 while (play_tree_iter_up_step
2634 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2636 play_tree_free_list(mpctx
->playtree
->child
, 1);
2637 play_tree_set_child(mpctx
->playtree
, e
);
2638 pt_iter_goto_head(mpctx
->playtree_iter
);
2639 mpctx
->eof
= PT_NEXT_SRC
;
2645 case MP_CMD_LOADLIST
:{
2646 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2648 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2649 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2651 if (cmd
->args
[1].v
.i
) // append
2652 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2654 // Go back to the starting point.
2655 while (play_tree_iter_up_step
2656 (mpctx
->playtree_iter
, 0, 1)
2657 != PLAY_TREE_ITER_END
)
2659 play_tree_free_list(mpctx
->playtree
->child
, 1);
2660 play_tree_set_child(mpctx
->playtree
, e
);
2661 pt_iter_goto_head(mpctx
->playtree_iter
);
2662 mpctx
->eof
= PT_NEXT_SRC
;
2670 // Go back to the starting point.
2671 while (play_tree_iter_up_step
2672 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2674 mpctx
->eof
= PT_STOP
;
2679 case MP_CMD_RADIO_STEP_CHANNEL
:
2680 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2681 int v
= cmd
->args
[0].v
.i
;
2683 radio_step_channel(mpctx
->demuxer
->stream
,
2684 RADIO_CHANNEL_HIGHER
);
2686 radio_step_channel(mpctx
->demuxer
->stream
,
2687 RADIO_CHANNEL_LOWER
);
2688 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2689 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2691 radio_get_channel_name(mpctx
->demuxer
->stream
));
2696 case MP_CMD_RADIO_SET_CHANNEL
:
2697 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2698 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2699 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2700 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2702 radio_get_channel_name(mpctx
->demuxer
->stream
));
2707 case MP_CMD_RADIO_SET_FREQ
:
2708 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2709 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2712 case MP_CMD_RADIO_STEP_FREQ
:
2713 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2714 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2719 case MP_CMD_TV_START_SCAN
:
2720 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2721 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2723 case MP_CMD_TV_SET_FREQ
:
2724 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2725 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2726 cmd
->args
[0].v
.f
* 16.0);
2728 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2729 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2730 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2731 pvr_get_current_channelname (mpctx
->stream
),
2732 pvr_get_current_stationname (mpctx
->stream
));
2734 #endif /* CONFIG_PVR */
2737 case MP_CMD_TV_STEP_FREQ
:
2738 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2739 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2740 cmd
->args
[0].v
.f
* 16.0);
2742 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2743 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2744 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2745 pvr_get_current_channelname (mpctx
->stream
),
2746 pvr_get_current_frequency (mpctx
->stream
));
2748 #endif /* CONFIG_PVR */
2751 case MP_CMD_TV_SET_NORM
:
2752 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2753 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2757 case MP_CMD_TV_STEP_CHANNEL
:{
2758 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2759 int v
= cmd
->args
[0].v
.i
;
2761 tv_step_channel((tvi_handle_t
*) (mpctx
->
2765 tv_step_channel((tvi_handle_t
*) (mpctx
->
2769 if (tv_channel_list
) {
2770 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2771 MSGTR_OSDChannel
, tv_channel_current
->name
);
2772 //vo_osd_changed(OSDTYPE_SUBTITLE);
2776 else if (mpctx
->stream
&&
2777 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2778 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2779 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2780 pvr_get_current_channelname (mpctx
->stream
),
2781 pvr_get_current_stationname (mpctx
->stream
));
2783 #endif /* CONFIG_PVR */
2786 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2788 int v
= cmd
->args
[0].v
.i
;
2790 mpctx
->last_dvb_step
= v
;
2792 dir
= DVB_CHANNEL_HIGHER
;
2794 dir
= DVB_CHANNEL_LOWER
;
2797 if (dvb_step_channel(mpctx
->stream
, dir
))
2798 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2800 #endif /* CONFIG_DVBIN */
2803 case MP_CMD_TV_SET_CHANNEL
:
2804 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2805 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2807 if (tv_channel_list
) {
2808 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2809 MSGTR_OSDChannel
, tv_channel_current
->name
);
2810 //vo_osd_changed(OSDTYPE_SUBTITLE);
2814 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2815 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2816 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2817 pvr_get_current_channelname (mpctx
->stream
),
2818 pvr_get_current_stationname (mpctx
->stream
));
2820 #endif /* CONFIG_PVR */
2824 case MP_CMD_DVB_SET_CHANNEL
:
2825 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2826 mpctx
->last_dvb_step
= 1;
2829 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2830 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2833 #endif /* CONFIG_DVBIN */
2835 case MP_CMD_TV_LAST_CHANNEL
:
2836 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2837 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2838 if (tv_channel_list
) {
2839 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2840 MSGTR_OSDChannel
, tv_channel_current
->name
);
2841 //vo_osd_changed(OSDTYPE_SUBTITLE);
2845 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2846 pvr_set_lastchannel (mpctx
->stream
);
2847 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2848 pvr_get_current_channelname (mpctx
->stream
),
2849 pvr_get_current_stationname (mpctx
->stream
));
2851 #endif /* CONFIG_PVR */
2854 case MP_CMD_TV_STEP_NORM
:
2855 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2856 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2859 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2860 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2861 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2863 #ifdef CONFIG_TV_TELETEXT
2864 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2866 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2867 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2868 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2871 case MP_CMD_TV_TELETEXT_GO_LINK
:
2873 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2874 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2875 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2878 #endif /* CONFIG_TV_TELETEXT */
2879 #endif /* CONFIG_TV */
2881 case MP_CMD_SUB_LOAD
:
2883 int n
= mpctx
->set_of_sub_size
;
2884 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2885 if (n
!= mpctx
->set_of_sub_size
) {
2886 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2887 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2888 mpctx
->global_sub_size
;
2889 ++mpctx
->global_sub_size
;
2894 case MP_CMD_SUB_REMOVE
:
2896 int v
= cmd
->args
[0].v
.i
;
2899 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2900 subd
= mpctx
->set_of_subtitles
[v
];
2901 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2902 MSGTR_RemovedSubtitleFile
, v
+ 1,
2903 filename_recode(subd
->filename
));
2905 mpctx
->set_of_subtitles
[v
] = NULL
;
2907 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2908 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2909 mpctx
->set_of_sub_size
= 0;
2910 if (mpctx
->set_of_sub_pos
>= 0) {
2911 mpctx
->global_sub_pos
= -2;
2913 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2915 } else if (v
< mpctx
->set_of_sub_size
) {
2916 subd
= mpctx
->set_of_subtitles
[v
];
2917 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2918 MSGTR_RemovedSubtitleFile
, v
+ 1,
2919 filename_recode(subd
->filename
));
2921 if (mpctx
->set_of_sub_pos
== v
) {
2922 mpctx
->global_sub_pos
= -2;
2924 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2925 } else if (mpctx
->set_of_sub_pos
> v
) {
2926 --mpctx
->set_of_sub_pos
;
2927 --mpctx
->global_sub_pos
;
2929 while (++v
< mpctx
->set_of_sub_size
)
2930 mpctx
->set_of_subtitles
[v
- 1] =
2931 mpctx
->set_of_subtitles
[v
];
2932 --mpctx
->set_of_sub_size
;
2933 --mpctx
->global_sub_size
;
2934 if (mpctx
->set_of_sub_size
<= 0)
2935 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2936 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2941 case MP_CMD_GET_SUB_VISIBILITY
:
2943 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2944 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2948 case MP_CMD_SCREENSHOT
:
2949 if (vo_config_count
) {
2950 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2952 ((vf_instance_t
*) sh_video
->vfilter
)->
2953 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2955 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2959 case MP_CMD_VF_CHANGE_RECTANGLE
:
2962 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2965 case MP_CMD_GET_TIME_LENGTH
:{
2966 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2967 demuxer_get_time_length(mpctx
->demuxer
));
2971 case MP_CMD_GET_FILENAME
:{
2972 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2973 get_metadata(META_NAME
));
2977 case MP_CMD_GET_VIDEO_CODEC
:{
2978 char *inf
= get_metadata(META_VIDEO_CODEC
);
2981 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2986 case MP_CMD_GET_VIDEO_BITRATE
:{
2987 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2990 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2995 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2996 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2999 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3000 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3005 case MP_CMD_GET_AUDIO_CODEC
:{
3006 char *inf
= get_metadata(META_AUDIO_CODEC
);
3009 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3014 case MP_CMD_GET_AUDIO_BITRATE
:{
3015 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3018 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3023 case MP_CMD_GET_AUDIO_SAMPLES
:{
3024 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3027 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3032 case MP_CMD_GET_META_TITLE
:{
3033 char *inf
= get_metadata(META_INFO_TITLE
);
3036 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3041 case MP_CMD_GET_META_ARTIST
:{
3042 char *inf
= get_metadata(META_INFO_ARTIST
);
3045 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3050 case MP_CMD_GET_META_ALBUM
:{
3051 char *inf
= get_metadata(META_INFO_ALBUM
);
3054 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3059 case MP_CMD_GET_META_YEAR
:{
3060 char *inf
= get_metadata(META_INFO_YEAR
);
3063 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3068 case MP_CMD_GET_META_COMMENT
:{
3069 char *inf
= get_metadata(META_INFO_COMMENT
);
3072 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3077 case MP_CMD_GET_META_TRACK
:{
3078 char *inf
= get_metadata(META_INFO_TRACK
);
3081 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3086 case MP_CMD_GET_META_GENRE
:{
3087 char *inf
= get_metadata(META_INFO_GENRE
);
3090 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3095 case MP_CMD_GET_VO_FULLSCREEN
:
3096 if (mpctx
->video_out
&& vo_config_count
)
3097 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3100 case MP_CMD_GET_PERCENT_POS
:
3101 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3102 demuxer_get_percent_pos(mpctx
->demuxer
));
3105 case MP_CMD_GET_TIME_POS
:{
3108 pos
= sh_video
->pts
;
3109 else if (sh_audio
&& mpctx
->audio_out
)
3111 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3113 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3120 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3126 case MP_CMD_KEYDOWN_EVENTS
:
3127 mplayer_put_key(cmd
->args
[0].v
.i
);
3130 case MP_CMD_SET_MOUSE_POS
:{
3131 int pointer_x
, pointer_y
;
3133 pointer_x
= cmd
->args
[0].v
.i
;
3134 pointer_y
= cmd
->args
[1].v
.i
;
3135 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3136 #ifdef CONFIG_DVDNAV
3137 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3138 && dx
> 0.0 && dy
> 0.0) {
3140 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3141 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3142 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3143 pointer_x
, pointer_y
, &button
);
3144 if (osd_level
> 1 && button
> 0)
3145 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3146 "Selected button number %d", button
);
3150 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3151 menu_update_mouse_pos(dx
, dy
);
3156 #ifdef CONFIG_DVDNAV
3157 case MP_CMD_DVDNAV
:{
3160 mp_command_type command
= 0;
3161 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3164 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3165 if (cmd
->args
[0].v
.s
&&
3166 !strcasecmp (cmd
->args
[0].v
.s
,
3167 mp_dvdnav_bindings
[i
].name
))
3168 command
= mp_dvdnav_bindings
[i
].cmd
;
3170 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3171 if (osd_level
> 1 && button
> 0)
3172 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3173 "Selected button number %d", button
);
3177 case MP_CMD_SWITCH_TITLE
:
3178 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3179 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3186 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3187 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3190 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3191 "Received unknown cmd %s\n", cmd
->name
);
3194 switch (cmd
->pausing
) {
3195 case 1: // "pausing"
3196 mpctx
->osd_function
= OSD_PAUSE
;
3198 case 3: // "pausing_toggle"
3199 mpctx
->was_paused
= !mpctx
->was_paused
;
3200 if (mpctx
->was_paused
)
3201 mpctx
->osd_function
= OSD_PAUSE
;
3202 else if (mpctx
->osd_function
== OSD_PAUSE
)
3203 mpctx
->osd_function
= OSD_PLAY
;
3205 case 2: // "pausing_keep"
3206 if (mpctx
->was_paused
)
3207 mpctx
->osd_function
= OSD_PAUSE
;