6 #include "input/input.h"
7 #include "stream/stream.h"
8 #include "libmpdemux/demuxer.h"
9 #include "libmpdemux/stheader.h"
11 #include "libvo/sub.h"
13 #include "m_property.h"
16 #include "libmpcodecs/mp_image.h"
17 #include "libmpcodecs/vf.h"
18 #include "libmpcodecs/vd.h"
19 #include "libvo/video_out.h"
21 #include "libao2/audio_out.h"
24 #include "libmpdemux/matroska.h"
25 #include "libmpcodecs/dec_video.h"
29 #include "stream/tv.h"
32 #include "stream/stream_radio.h"
34 #ifdef HAS_DVBIN_SUPPORT
35 #include "stream/dvbin.h"
38 #include "stream/stream_dvd.h"
41 #include "stream/stream_dvdnav.h"
44 #include "libass/ass.h"
45 #include "libass/ass_mp.h"
48 #include "Gui/interface.h"
53 #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(MPContext
* mpctx
)
88 for (i
= 0; i
< SUB_SOURCES
; i
++) {
89 int j
= mpctx
->global_sub_indices
[i
];
90 if ((j
>= 0) && (j
> top
) && (mpctx
->global_sub_pos
>= j
)) {
99 * \brief Log the currently displayed subtitle to a file
101 * Logs the current or last displayed subtitle together with filename
102 * and time information to ~/.mplayer/subtitle_log
104 * Intended purpose is to allow convenient marking of bogus subtitles
105 * which need to be fixed while watching the movie.
108 static void log_sub(void)
114 if (subdata
== NULL
|| vo_sub_last
== NULL
)
116 fname
= get_path("subtitle_log");
117 f
= fopen(fname
, "a");
120 fprintf(f
, "----------------------------------------------------------\n");
121 if (subdata
->sub_uses_time
) {
123 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
124 filename
, vo_sub_last
->start
/ 360000,
125 (vo_sub_last
->start
/ 6000) % 60,
126 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
127 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
128 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
130 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
133 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
134 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
140 /// \defgroup Properties
143 /// \defgroup GeneralProperties General properties
144 /// \ingroup Properties
148 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
151 return m_property_choice(prop
, action
, arg
, &osd_level
);
154 /// Playback speed (RW)
155 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
156 void *arg
, MPContext
* mpctx
)
161 return M_PROPERTY_ERROR
;
162 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
163 playback_speed
= *(float *) arg
;
164 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
165 return M_PROPERTY_OK
;
166 case M_PROPERTY_STEP_UP
:
167 case M_PROPERTY_STEP_DOWN
:
168 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
169 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
170 M_PROPERTY_CLAMP(prop
, playback_speed
);
171 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
172 return M_PROPERTY_OK
;
174 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
177 /// filename with path (RO)
178 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
181 return m_property_string_ro(prop
, action
, arg
, filename
);
184 /// filename without path (RO)
185 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
190 return M_PROPERTY_UNAVAILABLE
;
191 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
195 return m_property_string_ro(prop
, action
, arg
, f
);
198 /// Demuxer name (RO)
199 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
203 return M_PROPERTY_UNAVAILABLE
;
204 return m_property_string_ro(prop
, action
, arg
,
205 (char *) mpctx
->demuxer
->desc
->name
);
208 /// Position in the stream (RW)
209 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
212 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
213 return M_PROPERTY_UNAVAILABLE
;
215 return M_PROPERTY_ERROR
;
218 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
219 return M_PROPERTY_OK
;
221 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
222 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
223 return M_PROPERTY_OK
;
225 return M_PROPERTY_NOT_IMPLEMENTED
;
228 /// Stream start offset (RO)
229 static int mp_property_stream_start(m_option_t
* prop
, int action
,
230 void *arg
, MPContext
* mpctx
)
232 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
233 return M_PROPERTY_UNAVAILABLE
;
236 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
237 return M_PROPERTY_OK
;
239 return M_PROPERTY_NOT_IMPLEMENTED
;
242 /// Stream end offset (RO)
243 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
246 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
247 return M_PROPERTY_UNAVAILABLE
;
250 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
251 return M_PROPERTY_OK
;
253 return M_PROPERTY_NOT_IMPLEMENTED
;
256 /// Stream length (RO)
257 static int mp_property_stream_length(m_option_t
* prop
, int action
,
258 void *arg
, MPContext
* mpctx
)
260 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
261 return M_PROPERTY_UNAVAILABLE
;
265 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
266 return M_PROPERTY_OK
;
268 return M_PROPERTY_NOT_IMPLEMENTED
;
271 /// Media length in seconds (RO)
272 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
277 if (!mpctx
->demuxer
||
278 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
279 return M_PROPERTY_UNAVAILABLE
;
282 case M_PROPERTY_PRINT
:
284 return M_PROPERTY_ERROR
;
291 *(char **) arg
= malloc(20);
293 sprintf(*(char **) arg
, "%d:%02d:%02d", h
, m
, s
);
295 sprintf(*(char **) arg
, "%d:%02d", m
, s
);
297 sprintf(*(char **) arg
, "%d", s
);
298 return M_PROPERTY_OK
;
302 return m_property_double_ro(prop
, action
, arg
, len
);
307 /// \defgroup AudioProperties Audio properties
308 /// \ingroup Properties
312 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
316 if (!mpctx
->sh_audio
)
317 return M_PROPERTY_UNAVAILABLE
;
322 return M_PROPERTY_ERROR
;
323 mixer_getbothvolume(&mpctx
->mixer
, arg
);
324 return M_PROPERTY_OK
;
325 case M_PROPERTY_PRINT
:{
328 return M_PROPERTY_ERROR
;
329 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
330 return m_property_float_range(prop
, action
, arg
, &vol
);
332 case M_PROPERTY_STEP_UP
:
333 case M_PROPERTY_STEP_DOWN
:
337 return M_PROPERTY_NOT_IMPLEMENTED
;
340 if (mpctx
->edl_muted
)
341 return M_PROPERTY_DISABLED
;
342 mpctx
->user_muted
= 0;
347 return M_PROPERTY_ERROR
;
348 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
349 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
350 return M_PROPERTY_OK
;
351 case M_PROPERTY_STEP_UP
:
352 if (arg
&& *(float *) arg
<= 0)
353 mixer_decvolume(&mpctx
->mixer
);
355 mixer_incvolume(&mpctx
->mixer
);
356 return M_PROPERTY_OK
;
357 case M_PROPERTY_STEP_DOWN
:
358 if (arg
&& *(float *) arg
<= 0)
359 mixer_incvolume(&mpctx
->mixer
);
361 mixer_decvolume(&mpctx
->mixer
);
362 return M_PROPERTY_OK
;
364 return M_PROPERTY_NOT_IMPLEMENTED
;
368 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
372 if (!mpctx
->sh_audio
)
373 return M_PROPERTY_UNAVAILABLE
;
377 if (mpctx
->edl_muted
)
378 return M_PROPERTY_DISABLED
;
380 return M_PROPERTY_ERROR
;
381 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
382 mixer_mute(&mpctx
->mixer
);
383 mpctx
->user_muted
= mpctx
->mixer
.muted
;
384 return M_PROPERTY_OK
;
385 case M_PROPERTY_STEP_UP
:
386 case M_PROPERTY_STEP_DOWN
:
387 if (mpctx
->edl_muted
)
388 return M_PROPERTY_DISABLED
;
389 mixer_mute(&mpctx
->mixer
);
390 mpctx
->user_muted
= mpctx
->mixer
.muted
;
391 return M_PROPERTY_OK
;
392 case M_PROPERTY_PRINT
:
394 return M_PROPERTY_ERROR
;
395 if (mpctx
->edl_muted
) {
396 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
397 return M_PROPERTY_OK
;
400 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
406 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
407 void *arg
, MPContext
* mpctx
)
409 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
410 return M_PROPERTY_UNAVAILABLE
;
413 case M_PROPERTY_STEP_UP
:
414 case M_PROPERTY_STEP_DOWN
:
416 return M_PROPERTY_ERROR
;
418 float delay
= audio_delay
;
419 m_property_delay(prop
, action
, arg
, &audio_delay
);
421 mpctx
->sh_audio
->delay
-= audio_delay
- delay
;
423 return M_PROPERTY_OK
;
425 return m_property_delay(prop
, action
, arg
, &audio_delay
);
429 /// Audio codec tag (RO)
430 static int mp_property_audio_format(m_option_t
* prop
, int action
,
431 void *arg
, MPContext
* mpctx
)
433 if (!mpctx
->sh_audio
)
434 return M_PROPERTY_UNAVAILABLE
;
435 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
438 /// Audio bitrate (RO)
439 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
440 void *arg
, MPContext
* mpctx
)
442 if (!mpctx
->sh_audio
)
443 return M_PROPERTY_UNAVAILABLE
;
444 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
448 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
451 if (!mpctx
->sh_audio
)
452 return M_PROPERTY_UNAVAILABLE
;
453 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
456 /// Number of channels (RO)
457 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
460 if (!mpctx
->sh_audio
)
461 return M_PROPERTY_UNAVAILABLE
;
463 case M_PROPERTY_PRINT
:
465 return M_PROPERTY_ERROR
;
466 switch (mpctx
->sh_audio
->channels
) {
468 *(char **) arg
= strdup("mono");
471 *(char **) arg
= strdup("stereo");
474 *(char **) arg
= malloc(32);
475 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
477 return M_PROPERTY_OK
;
479 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
482 /// Selected audio id (RW)
483 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
486 int current_id
= -1, tmp
;
490 if (!mpctx
->sh_audio
)
491 return M_PROPERTY_UNAVAILABLE
;
493 return M_PROPERTY_ERROR
;
494 *(int *) arg
= audio_id
;
495 return M_PROPERTY_OK
;
496 case M_PROPERTY_PRINT
:
497 if (!mpctx
->sh_audio
)
498 return M_PROPERTY_UNAVAILABLE
;
500 return M_PROPERTY_ERROR
;
503 *(char **) arg
= strdup(MSGTR_Disabled
);
505 char lang
[40] = MSGTR_Unknown
;
506 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
507 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
509 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
510 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
520 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
521 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
523 *(char **) arg
= malloc(64);
524 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
526 return M_PROPERTY_OK
;
528 case M_PROPERTY_STEP_UP
:
530 if (action
== M_PROPERTY_SET
&& arg
)
531 tmp
= *((int *) arg
);
534 current_id
= mpctx
->demuxer
->audio
->id
;
535 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
538 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
539 uninit_player(INITED_AO
| INITED_ACODEC
);
540 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
542 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
544 sh2
->ds
= mpctx
->demuxer
->audio
;
545 mpctx
->sh_audio
= sh2
;
546 reinit_audio_chain();
549 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
550 return M_PROPERTY_OK
;
552 return M_PROPERTY_NOT_IMPLEMENTED
;
557 /// Selected video id (RW)
558 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
561 int current_id
= -1, tmp
;
565 if (!mpctx
->sh_video
)
566 return M_PROPERTY_UNAVAILABLE
;
568 return M_PROPERTY_ERROR
;
569 *(int *) arg
= video_id
;
570 return M_PROPERTY_OK
;
571 case M_PROPERTY_PRINT
:
572 if (!mpctx
->sh_video
)
573 return M_PROPERTY_UNAVAILABLE
;
575 return M_PROPERTY_ERROR
;
578 *(char **) arg
= strdup(MSGTR_Disabled
);
580 char lang
[40] = MSGTR_Unknown
;
581 *(char **) arg
= malloc(64);
582 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
584 return M_PROPERTY_OK
;
586 case M_PROPERTY_STEP_UP
:
588 current_id
= mpctx
->demuxer
->video
->id
;
589 if (action
== M_PROPERTY_SET
&& arg
)
590 tmp
= *((int *) arg
);
593 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
595 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
596 && current_id
!= -2))
597 uninit_player(INITED_VCODEC
|
598 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
599 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
601 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
603 sh2
->ds
= mpctx
->demuxer
->video
;
604 mpctx
->sh_video
= sh2
;
605 reinit_video_chain();
608 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
609 return M_PROPERTY_OK
;
612 return M_PROPERTY_NOT_IMPLEMENTED
;
616 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
619 demux_program_t prog
;
622 case M_PROPERTY_STEP_UP
:
624 if (action
== M_PROPERTY_SET
&& arg
)
625 prog
.progid
= *((int *) arg
);
629 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
630 &prog
) == DEMUXER_CTRL_NOTIMPL
)
631 return M_PROPERTY_ERROR
;
633 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
634 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
635 return M_PROPERTY_OK
;
638 return M_PROPERTY_NOT_IMPLEMENTED
;
644 /// \defgroup VideoProperties Video properties
645 /// \ingroup Properties
648 /// Fullscreen state (RW)
649 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
653 if (!mpctx
->video_out
)
654 return M_PROPERTY_UNAVAILABLE
;
659 return M_PROPERTY_ERROR
;
660 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
661 if (vo_fs
== !!*(int *) arg
)
662 return M_PROPERTY_OK
;
663 case M_PROPERTY_STEP_UP
:
664 case M_PROPERTY_STEP_DOWN
:
667 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
671 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
672 return M_PROPERTY_OK
;
674 return m_property_flag(prop
, action
, arg
, &vo_fs
);
678 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
679 void *arg
, MPContext
* mpctx
)
683 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
684 return M_PROPERTY_UNAVAILABLE
;
685 vf
= mpctx
->sh_video
->vfilter
;
689 return M_PROPERTY_ERROR
;
690 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
691 return M_PROPERTY_OK
;
694 return M_PROPERTY_ERROR
;
695 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
696 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
697 return M_PROPERTY_OK
;
698 case M_PROPERTY_STEP_UP
:
699 case M_PROPERTY_STEP_DOWN
:
700 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
701 deinterlace
= !deinterlace
;
702 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
703 return M_PROPERTY_OK
;
705 return M_PROPERTY_NOT_IMPLEMENTED
;
709 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
713 if (!mpctx
->video_out
714 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
715 return M_PROPERTY_UNAVAILABLE
;
720 return M_PROPERTY_ERROR
;
721 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
722 vo_panscan
= *(float *) arg
;
723 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
724 return M_PROPERTY_OK
;
725 case M_PROPERTY_STEP_UP
:
726 case M_PROPERTY_STEP_DOWN
:
727 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
728 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
731 else if (vo_panscan
< 0)
733 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
734 return M_PROPERTY_OK
;
736 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
740 /// Helper to set vo flags.
741 /** \ingroup PropertyImplHelper
743 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
744 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
747 if (!mpctx
->video_out
)
748 return M_PROPERTY_UNAVAILABLE
;
753 return M_PROPERTY_ERROR
;
754 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
755 if (*vo_var
== !!*(int *) arg
)
756 return M_PROPERTY_OK
;
757 case M_PROPERTY_STEP_UP
:
758 case M_PROPERTY_STEP_DOWN
:
760 mpctx
->video_out
->control(vo_ctrl
, 0);
761 return M_PROPERTY_OK
;
763 return m_property_flag(prop
, action
, arg
, vo_var
);
767 /// Window always on top (RW)
768 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
771 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
775 /// Display in the root window (RW)
776 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
779 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
783 /// Show window borders (RW)
784 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
787 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
791 /// Framedropping state (RW)
792 static int mp_property_framedropping(m_option_t
* prop
, int action
,
793 void *arg
, MPContext
* mpctx
)
796 if (!mpctx
->sh_video
)
797 return M_PROPERTY_UNAVAILABLE
;
800 case M_PROPERTY_PRINT
:
802 return M_PROPERTY_ERROR
;
803 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
804 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
806 return M_PROPERTY_OK
;
808 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
812 /// Color settings, try to use vf/vo then fall back on TV. (RW)
813 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
816 int *gamma
= prop
->priv
, r
;
818 if (!mpctx
->sh_video
)
819 return M_PROPERTY_UNAVAILABLE
;
821 if (gamma
[0] == 1000) {
823 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
829 return M_PROPERTY_ERROR
;
830 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
831 *gamma
= *(int *) arg
;
832 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
838 return M_PROPERTY_ERROR
;
839 r
= get_video_colors(mpctx
->sh_video
, prop
->name
, arg
);
843 case M_PROPERTY_STEP_UP
:
844 case M_PROPERTY_STEP_DOWN
:
845 *gamma
+= (arg
? *(int *) arg
: 1) *
846 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
847 M_PROPERTY_CLAMP(prop
, *gamma
);
848 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
853 return M_PROPERTY_NOT_IMPLEMENTED
;
857 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
858 int l
= strlen(prop
->name
);
859 char tv_prop
[3 + l
+ 1];
860 sprintf(tv_prop
, "tv_%s", prop
->name
);
861 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
865 return M_PROPERTY_UNAVAILABLE
;
869 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
872 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
875 /// Video codec tag (RO)
876 static int mp_property_video_format(m_option_t
* prop
, int action
,
877 void *arg
, MPContext
* mpctx
)
879 if (!mpctx
->sh_video
)
880 return M_PROPERTY_UNAVAILABLE
;
881 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
884 /// Video bitrate (RO)
885 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
886 void *arg
, MPContext
* mpctx
)
888 if (!mpctx
->sh_video
)
889 return M_PROPERTY_UNAVAILABLE
;
890 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
893 /// Video display width (RO)
894 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
897 if (!mpctx
->sh_video
)
898 return M_PROPERTY_UNAVAILABLE
;
899 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
902 /// Video display height (RO)
903 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
906 if (!mpctx
->sh_video
)
907 return M_PROPERTY_UNAVAILABLE
;
908 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
912 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
915 if (!mpctx
->sh_video
)
916 return M_PROPERTY_UNAVAILABLE
;
917 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
920 /// Video aspect (RO)
921 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
924 if (!mpctx
->sh_video
)
925 return M_PROPERTY_UNAVAILABLE
;
926 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
931 /// \defgroup SubProprties Subtitles properties
932 /// \ingroup Properties
935 /// Text subtitle position (RW)
936 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
939 if (!mpctx
->sh_video
)
940 return M_PROPERTY_UNAVAILABLE
;
945 return M_PROPERTY_ERROR
;
946 case M_PROPERTY_STEP_UP
:
947 case M_PROPERTY_STEP_DOWN
:
948 vo_osd_changed(OSDTYPE_SUBTITLE
);
950 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
954 /// Selected subtitles (RW)
955 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
958 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
959 const int global_sub_size
= mpctx
->global_sub_size
;
960 int source
= -1, reset_spu
= 0;
963 if (global_sub_size
<= 0)
964 return M_PROPERTY_UNAVAILABLE
;
969 return M_PROPERTY_ERROR
;
970 *(int *) arg
= mpctx
->global_sub_pos
;
971 return M_PROPERTY_OK
;
972 case M_PROPERTY_PRINT
:
974 return M_PROPERTY_ERROR
;
975 *(char **) arg
= malloc(64);
976 (*(char **) arg
)[63] = 0;
979 sub_name
= subdata
->filename
;
981 if (ass_track
&& ass_track
->name
)
982 sub_name
= ass_track
->name
;
987 if ((tmp2
= strrchr(tmp
, '/')))
990 snprintf(*(char **) arg
, 63, "(%d) %s%s",
991 mpctx
->set_of_sub_pos
+ 1,
992 strlen(tmp
) < 20 ? "" : "...",
993 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
994 return M_PROPERTY_OK
;
997 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
998 if (vo_spudec
&& dvdsub_id
>= 0) {
999 unsigned char lang
[3];
1000 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1001 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1002 return M_PROPERTY_OK
;
1008 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1009 char lang
[40] = MSGTR_Unknown
;
1010 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1011 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1012 return M_PROPERTY_OK
;
1014 #ifdef HAVE_OGGVORBIS
1015 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1016 char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1018 lang
= MSGTR_Unknown
;
1019 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1020 return M_PROPERTY_OK
;
1023 if (vo_vobsub
&& vobsub_id
>= 0) {
1024 const char *language
= MSGTR_Unknown
;
1025 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1026 snprintf(*(char **) arg
, 63, "(%d) %s",
1027 vobsub_id
, language
? language
: MSGTR_Unknown
);
1028 return M_PROPERTY_OK
;
1031 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1032 && dvdsub_id
>= 0) {
1034 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1035 lang
[0] = code
>> 8;
1038 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1039 return M_PROPERTY_OK
;
1042 if (dvdsub_id
>= 0) {
1043 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1044 return M_PROPERTY_OK
;
1046 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1047 return M_PROPERTY_OK
;
1049 case M_PROPERTY_SET
:
1051 return M_PROPERTY_ERROR
;
1052 if (*(int *) arg
< -1)
1054 else if (*(int *) arg
>= global_sub_size
)
1055 *(int *) arg
= global_sub_size
- 1;
1056 mpctx
->global_sub_pos
= *(int *) arg
;
1058 case M_PROPERTY_STEP_UP
:
1059 mpctx
->global_sub_pos
+= 2;
1060 mpctx
->global_sub_pos
=
1061 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1063 case M_PROPERTY_STEP_DOWN
:
1064 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1065 mpctx
->global_sub_pos
=
1066 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1069 return M_PROPERTY_NOT_IMPLEMENTED
;
1072 if (mpctx
->global_sub_pos
>= 0)
1073 source
= sub_source(mpctx
);
1075 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1076 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1078 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1079 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1080 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1081 mpctx
->global_sub_pos
, source
);
1083 mpctx
->set_of_sub_pos
= -1;
1085 vo_sub_last
= vo_sub
= NULL
;
1098 if (source
== SUB_SOURCE_VOBSUB
) {
1100 mpctx
->global_sub_pos
-
1101 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
];
1102 } else if (source
== SUB_SOURCE_SUBS
) {
1103 mpctx
->set_of_sub_pos
=
1104 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1106 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1107 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1111 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1112 vo_osd_changed(OSDTYPE_SUBTITLE
);
1114 } else if (source
== SUB_SOURCE_DEMUX
) {
1116 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1119 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
) {
1120 d_sub
->id
= dvdsub_id
;
1125 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1126 d_sub
->id
= dvdsub_id
;
1129 if (mpctx
->stream
->type
!= STREAMTYPE_DVD
1130 && mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
) {
1132 for (d_sub
->id
= 0; d_sub
->id
< MAX_S_STREAMS
; d_sub
->id
++) {
1133 if (mpctx
->demuxer
->s_streams
[d_sub
->id
]) {
1139 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1141 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
1142 d_sub
->id
= demux_mkv_change_subs(mpctx
->demuxer
, dvdsub_id
);
1143 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1144 sh_sub_t
*sh
= d_sub
->sh
;
1145 if (sh
->type
== 'v')
1148 else if (ass_enabled
&& sh
->type
== 'a')
1149 ass_track
= sh
->ass_track
;
1156 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1157 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1158 && dvdsub_id
< 0 && reset_spu
) {
1160 d_sub
->id
= dvdsub_id
;
1163 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1165 return M_PROPERTY_OK
;
1168 /// Subtitle delay (RW)
1169 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1172 if (!mpctx
->sh_video
)
1173 return M_PROPERTY_UNAVAILABLE
;
1174 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1177 /// Alignment of text subtitles (RW)
1178 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1179 void *arg
, MPContext
* mpctx
)
1181 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1183 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1184 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1185 return M_PROPERTY_UNAVAILABLE
;
1188 case M_PROPERTY_PRINT
:
1190 return M_PROPERTY_ERROR
;
1191 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1192 *(char **) arg
= strdup(name
[sub_alignment
]);
1193 return M_PROPERTY_OK
;
1194 case M_PROPERTY_SET
:
1196 return M_PROPERTY_ERROR
;
1197 case M_PROPERTY_STEP_UP
:
1198 case M_PROPERTY_STEP_DOWN
:
1199 vo_osd_changed(OSDTYPE_SUBTITLE
);
1201 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1205 /// Subtitle visibility (RW)
1206 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1207 void *arg
, MPContext
* mpctx
)
1209 if (!mpctx
->sh_video
)
1210 return M_PROPERTY_UNAVAILABLE
;
1213 case M_PROPERTY_SET
:
1215 return M_PROPERTY_ERROR
;
1216 case M_PROPERTY_STEP_UP
:
1217 case M_PROPERTY_STEP_DOWN
:
1218 vo_osd_changed(OSDTYPE_SUBTITLE
);
1220 vo_osd_changed(OSDTYPE_SPU
);
1222 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1226 /// Show only forced subtitles (RW)
1227 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1228 void *arg
, MPContext
* mpctx
)
1231 return M_PROPERTY_UNAVAILABLE
;
1234 case M_PROPERTY_SET
:
1236 return M_PROPERTY_ERROR
;
1237 case M_PROPERTY_STEP_UP
:
1238 case M_PROPERTY_STEP_DOWN
:
1239 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1240 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1241 return M_PROPERTY_OK
;
1243 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1250 /// \defgroup TVProperties TV properties
1251 /// \ingroup Properties
1256 /// TV color settings (RW)
1257 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1261 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1262 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1263 return M_PROPERTY_UNAVAILABLE
;
1266 case M_PROPERTY_SET
:
1268 return M_PROPERTY_ERROR
;
1269 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1270 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1271 case M_PROPERTY_GET
:
1272 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1273 case M_PROPERTY_STEP_UP
:
1274 case M_PROPERTY_STEP_DOWN
:
1275 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1277 return M_PROPERTY_ERROR
;
1278 val
+= (arg
? *(int *) arg
: 1) *
1279 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1280 M_PROPERTY_CLAMP(prop
, val
);
1281 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1283 return M_PROPERTY_ERROR
;
1285 return M_PROPERTY_NOT_IMPLEMENTED
;
1292 /// All properties available in MPlayer.
1293 /** \ingroup Properties
1295 static m_option_t mp_properties
[] = {
1297 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1298 M_OPT_RANGE
, 0, 3, NULL
},
1299 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1300 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1301 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1303 { "path", mp_property_path
, CONF_TYPE_STRING
,
1305 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1307 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1308 M_OPT_MIN
, 0, 0, NULL
},
1309 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1310 M_OPT_MIN
, 0, 0, NULL
},
1311 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1312 M_OPT_MIN
, 0, 0, NULL
},
1313 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1314 M_OPT_MIN
, 0, 0, NULL
},
1315 { "length", mp_property_length
, CONF_TYPE_DOUBLE
,
1319 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1320 M_OPT_RANGE
, 0, 100, NULL
},
1321 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1322 M_OPT_RANGE
, 0, 1, NULL
},
1323 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1324 M_OPT_RANGE
, -100, 100, NULL
},
1325 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1327 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1329 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1331 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1333 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1334 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1337 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1338 M_OPT_RANGE
, 0, 1, NULL
},
1339 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1340 M_OPT_RANGE
, 0, 1, NULL
},
1341 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1342 M_OPT_RANGE
, 0, 1, NULL
},
1343 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1344 M_OPT_RANGE
, 0, 1, NULL
},
1345 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1346 M_OPT_RANGE
, 0, 1, NULL
},
1347 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1348 M_OPT_RANGE
, 0, 2, NULL
},
1349 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1350 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1351 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1352 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1353 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1354 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1355 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
1356 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
1357 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
1358 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
1359 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
1360 M_OPT_RANGE
, 0, 1, NULL
},
1361 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
1362 M_OPT_RANGE
, 0, 1, NULL
},
1363 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
1365 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
1367 { "width", mp_property_width
, CONF_TYPE_INT
,
1369 { "height", mp_property_height
, CONF_TYPE_INT
,
1371 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
1373 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
1375 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
1376 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
1377 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
1378 CONF_RANGE
, -1, 65535, NULL
},
1381 { "sub", mp_property_sub
, CONF_TYPE_INT
,
1382 M_OPT_MIN
, -1, 0, NULL
},
1383 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
1385 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
1386 M_OPT_RANGE
, 0, 100, NULL
},
1387 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
1388 M_OPT_RANGE
, 0, 2, NULL
},
1389 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
1390 M_OPT_RANGE
, 0, 1, NULL
},
1391 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
1392 M_OPT_RANGE
, 0, 1, NULL
},
1395 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
1396 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
1397 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
1398 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
1399 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
1400 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
1401 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
1402 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
1405 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
1409 m_option_t
*mp_property_find(const char *name
)
1411 return m_option_list_find(mp_properties
, name
);
1414 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
1416 m_option_t
*p
= mp_property_find(name
);
1418 return M_PROPERTY_UNAVAILABLE
;
1419 return m_property_do(p
, action
, val
, ctx
);
1422 char *property_expand_string(MPContext
* mpctx
, char *str
)
1424 return m_properties_expand_string(mp_properties
, str
, mpctx
);
1427 void property_print_help(void)
1429 m_properties_print_help_list(mp_properties
);
1438 * \defgroup Command2Property Command to property bridge
1440 * It is used to handle most commands that just set a property
1441 * and optionally display something on the OSD.
1442 * Two kinds of commands are handled: adjust or toggle.
1444 * Adjust commands take 1 or 2 parameters: <value> <abs>
1445 * If <abs> is non-zero the property is set to the given value
1446 * otherwise it is adjusted.
1448 * Toggle commands take 0 or 1 parameters. With no parameter
1449 * or a value less than the property minimum it just steps the
1450 * property to its next value. Otherwise it sets it to the given
1456 /// List of the commands that can be handled by setting a property.
1462 /// set/adjust or toggle command
1464 /// progressbar type
1466 /// osd msg id if it must be shared
1468 /// osd msg template
1469 const char *osd_msg
;
1470 } set_prop_cmd
[] = {
1472 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
1473 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
1474 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
1475 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
1477 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
1478 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
1479 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
1480 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
1481 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
1482 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
1483 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
1484 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1485 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1486 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1487 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1488 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
1490 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
1491 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
1492 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
1493 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
1494 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
1495 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
1497 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
1498 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
1499 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
1500 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
1502 { NULL
, 0, 0, 0, -1, NULL
}
1506 /// Handle commands that set a property.
1507 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1512 // look for the command
1513 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
1514 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
1516 if (!set_prop_cmd
[i
].name
)
1520 prop
= mp_property_find(set_prop_cmd
[i
].name
);
1525 if (set_prop_cmd
[i
].toggle
) {
1527 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
1528 r
= m_property_do(prop
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
1530 r
= m_property_do(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1531 } else if (cmd
->args
[1].v
.i
) //set
1532 r
= m_property_do(prop
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
1534 r
= m_property_do(prop
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
1539 if (set_prop_cmd
[i
].osd_progbar
) {
1540 if (prop
->type
== CONF_TYPE_INT
) {
1541 if (m_property_do(prop
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
1542 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1543 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
1544 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
1546 if (m_property_do(prop
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
1547 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
1548 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
1550 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
1551 "Property use an unsupported type.\n");
1555 if (set_prop_cmd
[i
].osd_msg
) {
1556 char *val
= m_property_print(prop
, mpctx
);
1558 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
1559 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
1560 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
1568 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
1570 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
1571 sh_video_t
* const sh_video
= mpctx
->sh_video
;
1573 if (!set_property_command(mpctx
, cmd
))
1579 mpctx
->osd_show_percentage
= sh_video
->fps
;
1580 v
= cmd
->args
[0].v
.f
;
1581 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
1582 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
1585 mpctx
->osd_function
=
1586 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
1588 } else if (abs
) { /* Absolute seek by percentage */
1591 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
1592 rel_seek_secs
= v
/ 100.0;
1595 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
1601 case MP_CMD_SET_PROPERTY
:{
1602 m_option_t
*prop
= mp_property_find(cmd
->args
[0].v
.s
);
1604 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1605 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1606 else if (m_property_parse(prop
, cmd
->args
[1].v
.s
, mpctx
) <= 0)
1607 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1608 "Failed to set property '%s' to '%s'.\n",
1609 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
1613 case MP_CMD_STEP_PROPERTY
:{
1614 m_option_t
*prop
= mp_property_find(cmd
->args
[0].v
.s
);
1615 float arg
= cmd
->args
[1].v
.f
;
1617 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1618 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1619 else if (m_property_do
1620 (prop
, M_PROPERTY_STEP_UP
,
1621 arg
? &arg
: NULL
, mpctx
) <= 0)
1622 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1623 "Failed to increment property '%s' by %f.\n",
1624 cmd
->args
[0].v
.s
, arg
);
1628 case MP_CMD_GET_PROPERTY
:{
1632 prop
= mp_property_find(cmd
->args
[0].v
.s
);
1634 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1635 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
1638 /* Use m_option_print directly to get easily parseable values. */
1639 val
= calloc(1, prop
->type
->size
);
1640 if (m_property_do(prop
, M_PROPERTY_GET
, val
, mpctx
) <= 0) {
1641 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1642 "Failed to get value of property '%s'.\n",
1646 tmp
= m_option_print(prop
, val
);
1647 if (!tmp
|| tmp
== (char *) -1) {
1648 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
1649 "Failed to print value of property '%s'.\n",
1653 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
1654 cmd
->args
[0].v
.s
, tmp
);
1659 case MP_CMD_EDL_MARK
:
1661 float v
= sh_video
? sh_video
->pts
:
1662 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
1665 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
1666 mpctx
->begin_skip
= v
;
1667 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
1669 if (mpctx
->begin_skip
> v
)
1670 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
1672 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
1673 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
1675 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
1680 case MP_CMD_SWITCH_RATIO
:
1681 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
1682 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
1684 movie_aspect
= cmd
->args
[0].v
.f
;
1685 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
1688 case MP_CMD_SPEED_INCR
:{
1689 float v
= cmd
->args
[0].v
.f
;
1690 playback_speed
+= v
;
1691 build_afilter_chain(sh_audio
, &ao_data
);
1692 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
1696 case MP_CMD_SPEED_MULT
:{
1697 float v
= cmd
->args
[0].v
.f
;
1698 playback_speed
*= v
;
1699 build_afilter_chain(sh_audio
, &ao_data
);
1700 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
1704 case MP_CMD_SPEED_SET
:{
1705 float v
= cmd
->args
[0].v
.f
;
1707 build_afilter_chain(sh_audio
, &ao_data
);
1708 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
1712 case MP_CMD_FRAME_STEP
:
1718 case MP_CMD_FILE_FILTER
:
1719 file_filter
= cmd
->args
[0].v
.i
;
1723 exit_player_with_rc(MSGTR_Exit_quit
,
1724 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
1726 case MP_CMD_PLAY_TREE_STEP
:{
1727 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
1728 int force
= cmd
->args
[1].v
.i
;
1734 for (i
= 0; i
< n
; i
++)
1737 for (i
= 0; i
< -1 * n
; i
++)
1742 if (!force
&& mpctx
->playtree_iter
) {
1743 play_tree_iter_t
*i
=
1744 play_tree_iter_new_copy(mpctx
->playtree_iter
);
1745 if (play_tree_iter_step(i
, n
, 0) ==
1746 PLAY_TREE_ITER_ENTRY
)
1748 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
1749 play_tree_iter_free(i
);
1751 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
1753 mpctx
->play_tree_step
= n
;
1759 case MP_CMD_PLAY_TREE_UP_STEP
:{
1760 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
1761 int force
= cmd
->args
[1].v
.i
;
1763 if (!force
&& mpctx
->playtree_iter
) {
1764 play_tree_iter_t
*i
=
1765 play_tree_iter_new_copy(mpctx
->playtree_iter
);
1766 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
1767 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
1768 play_tree_iter_free(i
);
1770 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
1775 case MP_CMD_PLAY_ALT_SRC_STEP
:
1776 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
1777 int v
= cmd
->args
[0].v
.i
;
1779 && mpctx
->playtree_iter
->file
<
1780 mpctx
->playtree_iter
->num_files
)
1781 mpctx
->eof
= PT_NEXT_SRC
;
1782 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
1783 mpctx
->eof
= PT_PREV_SRC
;
1788 case MP_CMD_SUB_STEP
:
1790 int movement
= cmd
->args
[0].v
.i
;
1791 step_sub(subdata
, sh_video
->pts
, movement
);
1795 ass_step_sub(ass_track
,
1797 sub_delay
) * 1000 + .5, movement
) / 1000.;
1799 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
1800 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
1804 case MP_CMD_SUB_LOG
:
1809 int v
= cmd
->args
[0].v
.i
;
1811 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
1812 if (osd_level
> max
)
1815 osd_level
= (osd_level
+ 1) % (max
+ 1);
1817 osd_level
= v
> max
? max
: v
;
1818 /* Show OSD state when disabled, but not when an explicit
1819 argument is given to the OSD command, i.e. in slave mode. */
1820 if (v
== -1 && osd_level
<= 1)
1821 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
1823 osd_level
? MSGTR_OSDenabled
:
1826 rm_osd_msg(OSD_MSG_OSD_STATUS
);
1830 case MP_CMD_OSD_SHOW_TEXT
:
1831 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
1833 0 ? osd_duration
: cmd
->args
[1].v
.i
),
1834 "%-.63s", cmd
->args
[0].v
.s
);
1837 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
1838 char *txt
= m_properties_expand_string(mp_properties
,
1841 /* if no argument supplied take default osd_duration, else <arg> ms. */
1843 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
1845 0 ? osd_duration
: cmd
->args
[1].v
.i
),
1852 case MP_CMD_LOADFILE
:{
1853 play_tree_t
*e
= play_tree_new();
1854 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
1856 if (cmd
->args
[1].v
.i
) // append
1857 play_tree_append_entry(mpctx
->playtree
, e
);
1859 // Go back to the starting point.
1860 while (play_tree_iter_up_step
1861 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
1863 play_tree_free_list(mpctx
->playtree
->child
, 1);
1864 play_tree_set_child(mpctx
->playtree
, e
);
1865 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
1866 mpctx
->eof
= PT_NEXT_SRC
;
1872 case MP_CMD_LOADLIST
:{
1873 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
1875 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
1876 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
1878 if (cmd
->args
[1].v
.i
) // append
1879 play_tree_append_entry(mpctx
->playtree
, e
);
1881 // Go back to the starting point.
1882 while (play_tree_iter_up_step
1883 (mpctx
->playtree_iter
, 0, 1)
1884 != PLAY_TREE_ITER_END
)
1886 play_tree_free_list(mpctx
->playtree
->child
, 1);
1887 play_tree_set_child(mpctx
->playtree
, e
);
1888 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
1889 mpctx
->eof
= PT_NEXT_SRC
;
1897 case MP_CMD_RADIO_STEP_CHANNEL
:
1898 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
1899 int v
= cmd
->args
[0].v
.i
;
1901 radio_step_channel(mpctx
->demuxer
->stream
,
1902 RADIO_CHANNEL_HIGHER
);
1904 radio_step_channel(mpctx
->demuxer
->stream
,
1905 RADIO_CHANNEL_LOWER
);
1906 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
1907 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
1909 radio_get_channel_name(mpctx
->demuxer
->stream
));
1914 case MP_CMD_RADIO_SET_CHANNEL
:
1915 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
1916 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
1917 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
1918 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
1920 radio_get_channel_name(mpctx
->demuxer
->stream
));
1925 case MP_CMD_RADIO_SET_FREQ
:
1926 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
1927 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
1930 case MP_CMD_RADIO_STEP_FREQ
:
1931 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
1932 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
1937 case MP_CMD_TV_SET_FREQ
:
1938 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
1939 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
1940 cmd
->args
[0].v
.f
* 16.0);
1943 case MP_CMD_TV_SET_NORM
:
1944 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
1945 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
1949 case MP_CMD_TV_STEP_CHANNEL
:{
1950 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
1951 int v
= cmd
->args
[0].v
.i
;
1953 tv_step_channel((tvi_handle_t
*) (mpctx
->
1957 tv_step_channel((tvi_handle_t
*) (mpctx
->
1961 if (tv_channel_list
) {
1962 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
1963 MSGTR_OSDChannel
, tv_channel_current
->name
);
1964 //vo_osd_changed(OSDTYPE_SUBTITLE);
1968 #ifdef HAS_DVBIN_SUPPORT
1969 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
1970 && mpctx
->stream
->priv
) {
1971 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
1974 int v
= cmd
->args
[0].v
.i
;
1976 mpctx
->last_dvb_step
= v
;
1978 dir
= DVB_CHANNEL_HIGHER
;
1980 dir
= DVB_CHANNEL_LOWER
;
1983 if (dvb_step_channel(priv
, dir
))
1984 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
1987 #endif /* HAS_DVBIN_SUPPORT */
1990 case MP_CMD_TV_SET_CHANNEL
:
1991 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
1992 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
1994 if (tv_channel_list
) {
1995 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
1996 MSGTR_OSDChannel
, tv_channel_current
->name
);
1997 //vo_osd_changed(OSDTYPE_SUBTITLE);
2002 #ifdef HAS_DVBIN_SUPPORT
2003 case MP_CMD_DVB_SET_CHANNEL
:
2004 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2005 && mpctx
->stream
->priv
) {
2006 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2008 if (priv
->list
->current
<= cmd
->args
[0].v
.i
)
2009 mpctx
->last_dvb_step
= 1;
2011 mpctx
->last_dvb_step
= -1;
2014 (priv
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2015 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2019 #endif /* HAS_DVBIN_SUPPORT */
2021 case MP_CMD_TV_LAST_CHANNEL
:
2022 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2023 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2024 if (tv_channel_list
) {
2025 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2026 MSGTR_OSDChannel
, tv_channel_current
->name
);
2027 //vo_osd_changed(OSDTYPE_SUBTITLE);
2032 case MP_CMD_TV_STEP_NORM
:
2033 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2034 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2037 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2038 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2039 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2043 case MP_CMD_SUB_LOAD
:
2045 int n
= mpctx
->set_of_sub_size
;
2046 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2047 if (n
!= mpctx
->set_of_sub_size
) {
2048 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2049 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2050 mpctx
->global_sub_size
;
2051 ++mpctx
->global_sub_size
;
2056 case MP_CMD_SUB_REMOVE
:
2058 int v
= cmd
->args
[0].v
.i
;
2061 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2062 subd
= mpctx
->set_of_subtitles
[v
];
2063 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2064 MSGTR_RemovedSubtitleFile
, v
+ 1,
2065 filename_recode(subd
->filename
));
2067 mpctx
->set_of_subtitles
[v
] = NULL
;
2069 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2070 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2071 mpctx
->set_of_sub_size
= 0;
2072 if (mpctx
->set_of_sub_pos
>= 0) {
2073 mpctx
->global_sub_pos
= -2;
2074 vo_sub_last
= vo_sub
= NULL
;
2075 vo_osd_changed(OSDTYPE_SUBTITLE
);
2076 vo_update_osd(sh_video
->disp_w
, sh_video
->disp_h
);
2077 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2079 } else if (v
< mpctx
->set_of_sub_size
) {
2080 subd
= mpctx
->set_of_subtitles
[v
];
2081 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2082 MSGTR_RemovedSubtitleFile
, v
+ 1,
2083 filename_recode(subd
->filename
));
2085 if (mpctx
->set_of_sub_pos
== v
) {
2086 mpctx
->global_sub_pos
= -2;
2087 vo_sub_last
= vo_sub
= NULL
;
2088 vo_osd_changed(OSDTYPE_SUBTITLE
);
2089 vo_update_osd(sh_video
->disp_w
, sh_video
->disp_h
);
2090 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2091 } else if (mpctx
->set_of_sub_pos
> v
) {
2092 --mpctx
->set_of_sub_pos
;
2093 --mpctx
->global_sub_pos
;
2095 while (++v
< mpctx
->set_of_sub_size
)
2096 mpctx
->set_of_subtitles
[v
- 1] =
2097 mpctx
->set_of_subtitles
[v
];
2098 --mpctx
->set_of_sub_size
;
2099 --mpctx
->global_sub_size
;
2100 if (mpctx
->set_of_sub_size
<= 0)
2101 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2102 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2107 case MP_CMD_GET_SUB_VISIBILITY
:
2109 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2110 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2114 case MP_CMD_SCREENSHOT
:
2115 if (vo_config_count
) {
2116 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2118 ((vf_instance_t
*) sh_video
->vfilter
)->
2119 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2121 mpctx
->video_out
->control(VOCTRL_SCREENSHOT
, NULL
);
2125 case MP_CMD_VF_CHANGE_RECTANGLE
:
2126 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2129 case MP_CMD_GET_TIME_LENGTH
:{
2130 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2131 demuxer_get_time_length(mpctx
->demuxer
));
2135 case MP_CMD_GET_FILENAME
:{
2136 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2137 get_metadata(META_NAME
));
2141 case MP_CMD_GET_VIDEO_CODEC
:{
2142 char *inf
= get_metadata(META_VIDEO_CODEC
);
2145 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2150 case MP_CMD_GET_VIDEO_BITRATE
:{
2151 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2154 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2159 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2160 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2163 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2164 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2169 case MP_CMD_GET_AUDIO_CODEC
:{
2170 char *inf
= get_metadata(META_AUDIO_CODEC
);
2173 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2178 case MP_CMD_GET_AUDIO_BITRATE
:{
2179 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2182 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2187 case MP_CMD_GET_AUDIO_SAMPLES
:{
2188 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2191 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2196 case MP_CMD_GET_META_TITLE
:{
2197 char *inf
= get_metadata(META_INFO_TITLE
);
2200 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2205 case MP_CMD_GET_META_ARTIST
:{
2206 char *inf
= get_metadata(META_INFO_ARTIST
);
2209 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2214 case MP_CMD_GET_META_ALBUM
:{
2215 char *inf
= get_metadata(META_INFO_ALBUM
);
2218 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2223 case MP_CMD_GET_META_YEAR
:{
2224 char *inf
= get_metadata(META_INFO_YEAR
);
2227 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2232 case MP_CMD_GET_META_COMMENT
:{
2233 char *inf
= get_metadata(META_INFO_COMMENT
);
2236 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2241 case MP_CMD_GET_META_TRACK
:{
2242 char *inf
= get_metadata(META_INFO_TRACK
);
2245 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2250 case MP_CMD_GET_META_GENRE
:{
2251 char *inf
= get_metadata(META_INFO_GENRE
);
2254 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
2259 case MP_CMD_GET_VO_FULLSCREEN
:
2260 if (mpctx
->video_out
&& vo_config_count
)
2261 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
2264 case MP_CMD_GET_PERCENT_POS
:
2265 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
2266 demuxer_get_percent_pos(mpctx
->demuxer
));
2269 case MP_CMD_GET_TIME_POS
:{
2272 pos
= sh_video
->pts
;
2273 else if (sh_audio
&& mpctx
->audio_out
)
2275 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2277 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
2284 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
2290 case MP_CMD_KEYDOWN_EVENTS
:
2291 mplayer_put_key(cmd
->args
[0].v
.i
);
2294 case MP_CMD_SEEK_CHAPTER
:{
2295 int seek
= cmd
->args
[0].v
.i
;
2296 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2305 demuxer_seek_chapter(mpctx
->demuxer
, seek
, abs
,
2306 &next_pts
, &num_chapters
,
2309 if (next_pts
> -1.0) {
2311 rel_seek_secs
= next_pts
;
2314 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2315 MSGTR_OSDChapter
, chap
+ 1, chapter_name
);
2320 rel_seek_secs
= 1000000000.;
2322 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2323 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
2329 case MP_CMD_SET_MOUSE_POS
:{
2330 int button
= -1, pointer_x
, pointer_y
;
2332 pointer_x
= cmd
->args
[0].v
.i
;
2333 pointer_y
= cmd
->args
[1].v
.i
;
2334 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
2336 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
2337 && dx
> 0.0 && dy
> 0.0) {
2338 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
2339 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
2340 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
2341 pointer_x
, pointer_y
, &button
);
2343 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2344 "Selected button number %d", button
);
2351 case MP_CMD_DVDNAV
:{
2353 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
2356 if (mp_dvdnav_handle_input
2357 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
2358 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
2359 (fixed_vo
? INITED_VO
: 0)));
2361 } else if (button
> 0)
2362 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2363 "Selected button number %d", button
);
2370 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
2371 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
2374 mp_msg(MSGT_CPLAYER
, MSGL_V
,
2375 "Received unknown cmd %s\n", cmd
->name
);
2378 switch (cmd
->pausing
) {
2379 case 1: // "pausing"
2380 mpctx
->osd_function
= OSD_PAUSE
;
2382 case 3: // "pausing_toggle"
2383 mpctx
->was_paused
= !mpctx
->was_paused
;
2385 case 2: // "pausing_keep"
2386 if (mpctx
->was_paused
)
2387 mpctx
->osd_function
= OSD_PAUSE
;