22478
|
1 #include <inttypes.h>
|
|
2 #include <stdlib.h>
|
|
3 #include "config.h"
|
|
4
|
|
5 #include <unistd.h>
|
|
6
|
|
7 #include "help_mp.h"
|
|
8
|
|
9 #include "m_option.h"
|
|
10 #include "m_property.h"
|
|
11
|
|
12 #include "libvo/video_out.h"
|
|
13
|
|
14 #include "libvo/sub.h"
|
|
15
|
|
16 #include "libao2/audio_out.h"
|
|
17
|
|
18 #include "spudec.h"
|
|
19 #include "vobsub.h"
|
|
20
|
|
21 #ifdef HAVE_NEW_GUI
|
|
22 #include "Gui/interface.h"
|
|
23 #endif
|
|
24
|
|
25 #include "input/input.h"
|
|
26
|
|
27 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
|
|
28
|
|
29 #ifdef USE_TV
|
|
30 #include "stream/tv.h"
|
|
31 #endif
|
|
32 #ifdef USE_RADIO
|
|
33 #include "stream/stream_radio.h"
|
|
34 #endif
|
|
35
|
|
36 #ifdef HAS_DVBIN_SUPPORT
|
|
37 #include "stream/dvbin.h"
|
|
38 #endif
|
|
39 #include "playtree.h"
|
|
40
|
|
41 #include "stream/stream.h"
|
|
42 #include "libmpdemux/demuxer.h"
|
|
43 #include "libmpdemux/stheader.h"
|
|
44 #include "libmpdemux/matroska.h"
|
|
45
|
|
46 #ifdef USE_DVDREAD
|
|
47 #include "stream/stream_dvd.h"
|
|
48 #endif
|
|
49
|
|
50 #ifdef USE_DVDNAV
|
|
51 #include "stream/stream_dvdnav.h"
|
|
52 #endif
|
|
53
|
|
54 #include "libmpcodecs/dec_video.h"
|
|
55 #include "libmpcodecs/mp_image.h"
|
|
56 #include "libmpcodecs/vf.h"
|
|
57 #include "libmpcodecs/vd.h"
|
|
58 #ifdef USE_ASS
|
|
59 #include "libass/ass.h"
|
|
60 #include "libass/ass_mp.h"
|
|
61 #endif
|
|
62 #include "mpcommon.h"
|
|
63 #include "metadata.h"
|
|
64 #include "mixer.h"
|
|
65
|
|
66 #include "mplayer.h"
|
|
67
|
|
68 #include "mp_core.h"
|
|
69
|
|
70 static int sub_source(MPContext * mpctx)
|
|
71 {
|
|
72 int source = -1;
|
|
73 int top = -1;
|
|
74 int i;
|
|
75 for (i = 0; i < SUB_SOURCES; i++) {
|
|
76 int j = mpctx->global_sub_indices[i];
|
|
77 if ((j >= 0) && (j > top) && (mpctx->global_sub_pos >= j)) {
|
|
78 source = i;
|
|
79 top = j;
|
|
80 }
|
|
81 }
|
|
82 return source;
|
|
83 }
|
|
84
|
|
85 /**
|
|
86 * \brief Log the currently displayed subtitle to a file
|
|
87 *
|
|
88 * Logs the current or last displayed subtitle together with filename
|
|
89 * and time information to ~/.mplayer/subtitle_log
|
|
90 *
|
|
91 * Intended purpose is to allow convenient marking of bogus subtitles
|
|
92 * which need to be fixed while watching the movie.
|
|
93 */
|
|
94
|
|
95 static void log_sub(void){
|
|
96 char *fname;
|
|
97 FILE *f;
|
|
98 int i;
|
|
99
|
|
100 if (subdata == NULL || vo_sub_last == NULL) return;
|
|
101 fname = get_path("subtitle_log");
|
|
102 f = fopen(fname, "a");
|
|
103 if (!f) return;
|
|
104 fprintf(f, "----------------------------------------------------------\n");
|
|
105 if (subdata->sub_uses_time) {
|
|
106 fprintf(f, "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", filename,
|
|
107 vo_sub_last->start/360000, (vo_sub_last->start/6000)%60,
|
|
108 (vo_sub_last->start/100)%60, vo_sub_last->start%100,
|
|
109 vo_sub_last->end/360000, (vo_sub_last->end/6000)%60,
|
|
110 (vo_sub_last->end/100)%60, vo_sub_last->end%100);
|
|
111 } else {
|
|
112 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start, vo_sub_last->end);
|
|
113 }
|
|
114 for (i = 0; i < vo_sub_last->lines; i++) {
|
|
115 fprintf(f, "%s\n", vo_sub_last->text[i]);
|
|
116 }
|
|
117 fclose(f);
|
|
118 }
|
|
119
|
|
120
|
|
121 /// \defgroup Properties
|
|
122 ///@{
|
|
123
|
|
124 /// \defgroup GeneralProperties General properties
|
|
125 /// \ingroup Properties
|
|
126 ///@{
|
|
127
|
|
128 /// OSD level (RW)
|
|
129 static int mp_property_osdlevel(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
130 return m_property_choice(prop,action,arg,&osd_level);
|
|
131 }
|
|
132
|
|
133 /// Playback speed (RW)
|
|
134 static int mp_property_playback_speed(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
135 switch(action) {
|
|
136 case M_PROPERTY_SET:
|
|
137 if(!arg) return M_PROPERTY_ERROR;
|
|
138 M_PROPERTY_CLAMP(prop,*(float*)arg);
|
|
139 playback_speed = *(float*)arg;
|
|
140 build_afilter_chain(mpctx->sh_audio, &ao_data);
|
|
141 return M_PROPERTY_OK;
|
|
142 case M_PROPERTY_STEP_UP:
|
|
143 case M_PROPERTY_STEP_DOWN:
|
|
144 playback_speed += (arg ? *(float*)arg : 0.1) *
|
|
145 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
|
|
146 M_PROPERTY_CLAMP(prop,playback_speed);
|
|
147 build_afilter_chain(mpctx->sh_audio, &ao_data);
|
|
148 return M_PROPERTY_OK;
|
|
149 }
|
|
150 return m_property_float_range(prop,action,arg,&playback_speed);
|
|
151 }
|
|
152
|
|
153 /// filename with path (RO)
|
|
154 static int mp_property_path(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
155 return m_property_string_ro(prop,action,arg,filename);
|
|
156 }
|
|
157
|
|
158 /// filename without path (RO)
|
|
159 static int mp_property_filename(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
160 char* f;
|
|
161 if(!filename) return M_PROPERTY_UNAVAILABLE;
|
|
162 if(((f = strrchr(filename,'/')) || (f = strrchr(filename,'\\'))) && f[1])
|
|
163 f++;
|
|
164 else
|
|
165 f = filename;
|
|
166 return m_property_string_ro(prop,action,arg,f);
|
|
167 }
|
|
168
|
|
169 /// Demuxer name (RO)
|
|
170 static int mp_property_demuxer(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
171 if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE;
|
|
172 return m_property_string_ro(prop, action, arg, (char *) mpctx->demuxer->desc->name);
|
|
173 }
|
|
174
|
|
175 /// Position in the stream (RW)
|
|
176 static int mp_property_stream_pos(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
177 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
|
|
178 if (!arg) return M_PROPERTY_ERROR;
|
|
179 switch (action) {
|
|
180 case M_PROPERTY_GET:
|
|
181 *(off_t *) arg = stream_tell(mpctx->demuxer->stream);
|
|
182 return M_PROPERTY_OK;
|
|
183 case M_PROPERTY_SET:
|
|
184 M_PROPERTY_CLAMP(prop,*(off_t*)arg);
|
|
185 stream_seek(mpctx->demuxer->stream, *(off_t *) arg);
|
|
186 return M_PROPERTY_OK;
|
|
187 }
|
|
188 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
189 }
|
|
190
|
|
191 /// Stream start offset (RO)
|
|
192 static int mp_property_stream_start(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
193 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
|
|
194 switch (action) {
|
|
195 case M_PROPERTY_GET:
|
|
196 *(off_t *) arg = mpctx->demuxer->stream->start_pos;
|
|
197 return M_PROPERTY_OK;
|
|
198 }
|
|
199 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
200 }
|
|
201
|
|
202 /// Stream end offset (RO)
|
|
203 static int mp_property_stream_end(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
204 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
|
|
205 switch (action) {
|
|
206 case M_PROPERTY_GET:
|
|
207 *(off_t *) arg = mpctx->demuxer->stream->end_pos;
|
|
208 return M_PROPERTY_OK;
|
|
209 }
|
|
210 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
211 }
|
|
212
|
|
213 /// Stream length (RO)
|
|
214 static int mp_property_stream_length(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
215 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
|
|
216 switch (action) {
|
|
217 case M_PROPERTY_GET:
|
|
218 *(off_t *) arg = mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos;
|
|
219 return M_PROPERTY_OK;
|
|
220 }
|
|
221 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
222 }
|
|
223
|
|
224 /// Media length in seconds (RO)
|
|
225 static int mp_property_length(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
226 double len;
|
|
227
|
|
228 if (!mpctx->demuxer ||
|
|
229 !(int) (len = demuxer_get_time_length(mpctx->demuxer)))
|
|
230 return M_PROPERTY_UNAVAILABLE;
|
|
231
|
|
232 switch(action) {
|
|
233 case M_PROPERTY_PRINT:
|
|
234 if(!arg) return M_PROPERTY_ERROR;
|
|
235 else {
|
|
236 int h, m, s = len;
|
|
237 h = s/3600;
|
|
238 s -= h*3600;
|
|
239 m = s/60;
|
|
240 s -= m*60;
|
|
241 *(char**)arg = malloc(20);
|
|
242 if(h > 0) sprintf(*(char**)arg,"%d:%02d:%02d",h,m,s);
|
|
243 else if(m > 0) sprintf(*(char**)arg,"%d:%02d",m,s);
|
|
244 else sprintf(*(char**)arg,"%d",s);
|
|
245 return M_PROPERTY_OK;
|
|
246 }
|
|
247 break;
|
|
248 }
|
|
249 return m_property_double_ro(prop,action,arg,len);
|
|
250 }
|
|
251
|
|
252 ///@}
|
|
253
|
|
254 /// \defgroup AudioProperties Audio properties
|
|
255 /// \ingroup Properties
|
|
256 ///@{
|
|
257
|
|
258 /// Volume (RW)
|
|
259 static int mp_property_volume(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
260
|
|
261 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
262
|
|
263 switch(action) {
|
|
264 case M_PROPERTY_GET:
|
|
265 if(!arg) return M_PROPERTY_ERROR;
|
|
266 mixer_getbothvolume(&mpctx->mixer, arg);
|
|
267 return M_PROPERTY_OK;
|
|
268 case M_PROPERTY_PRINT:{
|
|
269 float vol;
|
|
270 if(!arg) return M_PROPERTY_ERROR;
|
|
271 mixer_getbothvolume(&mpctx->mixer, &vol);
|
|
272 return m_property_float_range(prop,action,arg,&vol);
|
|
273 }
|
|
274 case M_PROPERTY_STEP_UP:
|
|
275 case M_PROPERTY_STEP_DOWN:
|
|
276 case M_PROPERTY_SET:
|
|
277 break;
|
|
278 default:
|
|
279 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
280 }
|
|
281
|
|
282 if (mpctx->edl_muted) return M_PROPERTY_DISABLED;
|
|
283 mpctx->user_muted = 0;
|
|
284
|
|
285 switch(action) {
|
|
286 case M_PROPERTY_SET:
|
|
287 if(!arg) return M_PROPERTY_ERROR;
|
|
288 M_PROPERTY_CLAMP(prop,*(float*)arg);
|
|
289 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg);
|
|
290 return M_PROPERTY_OK;
|
|
291 case M_PROPERTY_STEP_UP:
|
|
292 if(arg && *(float*)arg <= 0)
|
|
293 mixer_decvolume(&mpctx->mixer);
|
|
294 else
|
|
295 mixer_incvolume(&mpctx->mixer);
|
|
296 return M_PROPERTY_OK;
|
|
297 case M_PROPERTY_STEP_DOWN:
|
|
298 if(arg && *(float*)arg <= 0)
|
|
299 mixer_incvolume(&mpctx->mixer);
|
|
300 else
|
|
301 mixer_decvolume(&mpctx->mixer);
|
|
302 return M_PROPERTY_OK;
|
|
303 }
|
|
304 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
305 }
|
|
306
|
|
307 /// Mute (RW)
|
|
308 static int mp_property_mute(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
309
|
|
310 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
311
|
|
312 switch(action) {
|
|
313 case M_PROPERTY_SET:
|
|
314 if (mpctx->edl_muted) return M_PROPERTY_DISABLED;
|
|
315 if(!arg) return M_PROPERTY_ERROR;
|
|
316 if ((!!*(int *) arg) != mpctx->mixer.muted)
|
|
317 mixer_mute(&mpctx->mixer);
|
|
318 mpctx->user_muted = mpctx->mixer.muted;
|
|
319 return M_PROPERTY_OK;
|
|
320 case M_PROPERTY_STEP_UP:
|
|
321 case M_PROPERTY_STEP_DOWN:
|
|
322 if (mpctx->edl_muted) return M_PROPERTY_DISABLED;
|
|
323 mixer_mute(&mpctx->mixer);
|
|
324 mpctx->user_muted = mpctx->mixer.muted;
|
|
325 return M_PROPERTY_OK;
|
|
326 case M_PROPERTY_PRINT:
|
|
327 if(!arg) return M_PROPERTY_ERROR;
|
|
328 if (mpctx->edl_muted) {
|
|
329 *(char**)arg = strdup(MSGTR_EnabledEdl);
|
|
330 return M_PROPERTY_OK;
|
|
331 }
|
|
332 default:
|
|
333 return m_property_flag(prop, action, arg, &mpctx->mixer.muted);
|
|
334
|
|
335 }
|
|
336 }
|
|
337
|
|
338 /// Audio delay (RW)
|
|
339 static int mp_property_audio_delay(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
340 if (!(mpctx->sh_audio && mpctx->sh_video)) return M_PROPERTY_UNAVAILABLE;
|
|
341 switch(action) {
|
|
342 case M_PROPERTY_SET:
|
|
343 case M_PROPERTY_STEP_UP:
|
|
344 case M_PROPERTY_STEP_DOWN:
|
|
345 if(!arg) return M_PROPERTY_ERROR;
|
|
346 else {
|
|
347 float delay = audio_delay;
|
|
348 m_property_delay(prop,action,arg,&audio_delay);
|
|
349 if (mpctx->sh_audio) mpctx->sh_audio->delay -= audio_delay - delay;
|
|
350 }
|
|
351 return M_PROPERTY_OK;
|
|
352 default:
|
|
353 return m_property_delay(prop,action,arg,&audio_delay);
|
|
354 }
|
|
355 }
|
|
356
|
|
357 /// Audio codec tag (RO)
|
|
358 static int mp_property_audio_format(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
359 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
360 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format);
|
|
361 }
|
|
362
|
|
363 /// Audio bitrate (RO)
|
|
364 static int mp_property_audio_bitrate(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
365 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
366 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->i_bps);
|
|
367 }
|
|
368
|
|
369 /// Samplerate (RO)
|
|
370 static int mp_property_samplerate(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
371 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
372 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate);
|
|
373 }
|
|
374
|
|
375 /// Number of channels (RO)
|
|
376 static int mp_property_channels(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
377 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
378 switch(action) {
|
|
379 case M_PROPERTY_PRINT:
|
|
380 if(!arg) return M_PROPERTY_ERROR;
|
|
381 switch (mpctx->sh_audio->channels) {
|
|
382 case 1: *(char**)arg = strdup("mono"); break;
|
|
383 case 2: *(char**)arg = strdup("stereo"); break;
|
|
384 default:
|
|
385 *(char**)arg = malloc(32);
|
|
386 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels);
|
|
387 }
|
|
388 return M_PROPERTY_OK;
|
|
389 }
|
|
390 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels);
|
|
391 }
|
|
392
|
|
393 /// Selected audio id (RW)
|
|
394 static int mp_property_audio(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
395 int current_id = -1, tmp;
|
|
396
|
|
397 switch(action) {
|
|
398 case M_PROPERTY_GET:
|
|
399 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
400 if(!arg) return M_PROPERTY_ERROR;
|
|
401 *(int*)arg = audio_id;
|
|
402 return M_PROPERTY_OK;
|
|
403 case M_PROPERTY_PRINT:
|
|
404 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
|
|
405 if(!arg) return M_PROPERTY_ERROR;
|
|
406
|
|
407 if (audio_id < 0)
|
|
408 *(char**)arg = strdup(MSGTR_Disabled);
|
|
409 else {
|
|
410 char lang[40] = MSGTR_Unknown;
|
|
411 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
|
|
412 demux_mkv_get_audio_lang(mpctx->demuxer, audio_id, lang, 9);
|
|
413 #ifdef USE_DVDREAD
|
|
414 else if (mpctx->stream->type == STREAMTYPE_DVD) {
|
|
415 int code = dvd_lang_from_aid(mpctx->stream, audio_id);
|
|
416 if (code) {
|
|
417 lang[0] = code >> 8;
|
|
418 lang[1] = code;
|
|
419 lang[2] = 0;
|
|
420 }
|
|
421 }
|
|
422 #endif
|
|
423
|
|
424 #ifdef USE_DVDNAV
|
|
425 else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
|
|
426 dvdnav_lang_from_aid(mpctx->stream, audio_id, lang);
|
|
427 #endif
|
|
428 *(char**)arg = malloc(64);
|
|
429 snprintf(*(char**)arg, 64, "(%d) %s", audio_id, lang);
|
|
430 }
|
|
431 return M_PROPERTY_OK;
|
|
432
|
|
433 case M_PROPERTY_STEP_UP:
|
|
434 case M_PROPERTY_SET:
|
|
435 if(action==M_PROPERTY_SET && arg)
|
|
436 tmp = *((int*)arg);
|
|
437 else
|
|
438 tmp = -1;
|
|
439 current_id = mpctx->demuxer->audio->id;
|
|
440 audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
|
|
441 if (audio_id == -2 || (audio_id > -1 && mpctx->demuxer->audio->id != current_id && current_id != -2))
|
|
442 uninit_player(INITED_AO | INITED_ACODEC);
|
|
443 if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
|
|
444 sh_audio_t *sh2;
|
|
445 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
|
|
446 if(sh2) {
|
|
447 sh2->ds = mpctx->demuxer->audio;
|
|
448 mpctx->sh_audio = sh2;
|
|
449 reinit_audio_chain();
|
|
450 }
|
|
451 }
|
|
452 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
|
|
453 return M_PROPERTY_OK;
|
|
454 default:
|
|
455 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
456 }
|
|
457
|
|
458 }
|
|
459
|
|
460 /// Selected video id (RW)
|
|
461 static int mp_property_video(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
462 int current_id = -1, tmp;
|
|
463
|
|
464 switch(action) {
|
|
465 case M_PROPERTY_GET:
|
|
466 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
467 if(!arg) return M_PROPERTY_ERROR;
|
|
468 *(int*)arg = video_id;
|
|
469 return M_PROPERTY_OK;
|
|
470 case M_PROPERTY_PRINT:
|
|
471 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
472 if(!arg) return M_PROPERTY_ERROR;
|
|
473
|
|
474 if (video_id < 0)
|
|
475 *(char**)arg = strdup(MSGTR_Disabled);
|
|
476 else {
|
|
477 char lang[40] = MSGTR_Unknown;
|
|
478 *(char**)arg = malloc(64);
|
|
479 snprintf(*(char**)arg, 64, "(%d) %s", video_id, lang);
|
|
480 }
|
|
481 return M_PROPERTY_OK;
|
|
482
|
|
483 case M_PROPERTY_STEP_UP:
|
|
484 case M_PROPERTY_SET:
|
|
485 current_id = mpctx->demuxer->video->id;
|
|
486 if(action==M_PROPERTY_SET && arg)
|
|
487 tmp = *((int*)arg);
|
|
488 else
|
|
489 tmp = -1;
|
|
490 video_id = demuxer_switch_video(mpctx->demuxer, tmp);
|
|
491 if (video_id == -2 || (video_id > -1 && mpctx->demuxer->video->id != current_id && current_id != -2))
|
|
492 uninit_player(INITED_VCODEC | (fixed_vo && video_id != -2 ? 0 : INITED_VO));
|
|
493 if (video_id > -1 && mpctx->demuxer->video->id != current_id) {
|
|
494 sh_video_t *sh2;
|
|
495 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
|
|
496 if(sh2) {
|
|
497 sh2->ds = mpctx->demuxer->video;
|
|
498 mpctx->sh_video = sh2;
|
|
499 reinit_video_chain();
|
|
500 }
|
|
501 }
|
|
502 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id);
|
|
503 return M_PROPERTY_OK;
|
|
504
|
|
505 default:
|
|
506 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
507 }
|
|
508 }
|
|
509
|
|
510 static int mp_property_program(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
511 demux_program_t prog;
|
|
512
|
|
513 switch(action) {
|
|
514 case M_PROPERTY_STEP_UP:
|
|
515 case M_PROPERTY_SET:
|
|
516 if(action==M_PROPERTY_SET && arg)
|
|
517 prog.progid = *((int*)arg);
|
|
518 else
|
|
519 prog.progid = -1;
|
|
520 if (demux_control(mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) == DEMUXER_CTRL_NOTIMPL)
|
|
521 return M_PROPERTY_ERROR;
|
|
522
|
|
523 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx);
|
|
524 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx);
|
|
525 return M_PROPERTY_OK;
|
|
526
|
|
527 default:
|
|
528 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
529 }
|
|
530 }
|
|
531
|
|
532 ///@}
|
|
533
|
|
534 /// \defgroup VideoProperties Video properties
|
|
535 /// \ingroup Properties
|
|
536 ///@{
|
|
537
|
|
538 /// Fullscreen state (RW)
|
|
539 static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
540
|
|
541 if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE;
|
|
542
|
|
543 switch(action) {
|
|
544 case M_PROPERTY_SET:
|
|
545 if(!arg) return M_PROPERTY_ERROR;
|
|
546 M_PROPERTY_CLAMP(prop,*(int*)arg);
|
|
547 if(vo_fs == !!*(int*)arg) return M_PROPERTY_OK;
|
|
548 case M_PROPERTY_STEP_UP:
|
|
549 case M_PROPERTY_STEP_DOWN:
|
|
550 #ifdef HAVE_NEW_GUI
|
|
551 if(use_gui) guiGetEvent(guiIEvent,(char*)MP_CMD_GUI_FULLSCREEN);
|
|
552 else
|
|
553 #endif
|
|
554 if (vo_config_count) mpctx->video_out->control(VOCTRL_FULLSCREEN, 0);
|
|
555 return M_PROPERTY_OK;
|
|
556 default:
|
|
557 return m_property_flag(prop,action,arg,&vo_fs);
|
|
558 }
|
|
559 }
|
|
560
|
|
561 static int mp_property_deinterlace(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
562 int deinterlace;
|
|
563 vf_instance_t *vf;
|
|
564 if (!mpctx->sh_video || !mpctx->sh_video->vfilter) return M_PROPERTY_UNAVAILABLE;
|
|
565 vf = mpctx->sh_video->vfilter;
|
|
566 switch(action) {
|
|
567 case M_PROPERTY_GET:
|
|
568 if(!arg) return M_PROPERTY_ERROR;
|
|
569 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg);
|
|
570 return M_PROPERTY_OK;
|
|
571 case M_PROPERTY_SET:
|
|
572 if(!arg) return M_PROPERTY_ERROR;
|
|
573 M_PROPERTY_CLAMP(prop,*(int*)arg);
|
|
574 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg);
|
|
575 return M_PROPERTY_OK;
|
|
576 case M_PROPERTY_STEP_UP:
|
|
577 case M_PROPERTY_STEP_DOWN:
|
|
578 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace);
|
|
579 deinterlace = !deinterlace;
|
|
580 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace);
|
|
581 return M_PROPERTY_OK;
|
|
582 }
|
|
583 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
584 }
|
|
585
|
|
586 /// Panscan (RW)
|
|
587 static int mp_property_panscan(m_option_t * prop, int action, void *arg, MPContext * mpctx)
|
|
588 {
|
|
589
|
|
590 if (!mpctx->video_out || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
|
|
591 return M_PROPERTY_UNAVAILABLE;
|
|
592
|
|
593 switch(action) {
|
|
594 case M_PROPERTY_SET:
|
|
595 if(!arg) return M_PROPERTY_ERROR;
|
|
596 M_PROPERTY_CLAMP(prop,*(float*)arg);
|
|
597 vo_panscan = *(float*)arg;
|
|
598 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
|
|
599 return M_PROPERTY_OK;
|
|
600 case M_PROPERTY_STEP_UP:
|
|
601 case M_PROPERTY_STEP_DOWN:
|
|
602 vo_panscan += (arg ? *(float*)arg : 0.1) *
|
|
603 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
|
|
604 if(vo_panscan > 1) vo_panscan = 1;
|
|
605 else if(vo_panscan < 0) vo_panscan = 0;
|
|
606 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
|
|
607 return M_PROPERTY_OK;
|
|
608 default:
|
|
609 return m_property_float_range(prop,action,arg,&vo_panscan);
|
|
610 }
|
|
611 }
|
|
612
|
|
613 /// Helper to set vo flags.
|
|
614 /** \ingroup PropertyImplHelper
|
|
615 */
|
|
616 static int mp_property_vo_flag(m_option_t* prop,int action,void* arg,
|
|
617 int vo_ctrl, int *vo_var, MPContext * mpctx) {
|
|
618
|
|
619 if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE;
|
|
620
|
|
621 switch(action) {
|
|
622 case M_PROPERTY_SET:
|
|
623 if(!arg) return M_PROPERTY_ERROR;
|
|
624 M_PROPERTY_CLAMP(prop,*(int*)arg);
|
|
625 if(*vo_var == !!*(int*)arg) return M_PROPERTY_OK;
|
|
626 case M_PROPERTY_STEP_UP:
|
|
627 case M_PROPERTY_STEP_DOWN:
|
|
628 if (vo_config_count) mpctx->video_out->control(vo_ctrl, 0);
|
|
629 return M_PROPERTY_OK;
|
|
630 default:
|
|
631 return m_property_flag(prop,action,arg,vo_var);
|
|
632 }
|
|
633 }
|
|
634
|
|
635 /// Window always on top (RW)
|
|
636 static int mp_property_ontop(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
637 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop, mpctx);
|
|
638 }
|
|
639
|
|
640 /// Display in the root window (RW)
|
|
641 static int mp_property_rootwin(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
642 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN, &vo_rootwin, mpctx);
|
|
643 }
|
|
644
|
|
645 /// Show window borders (RW)
|
|
646 static int mp_property_border(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
647 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, &vo_border, mpctx);
|
|
648 }
|
|
649
|
|
650 /// Framedropping state (RW)
|
|
651 static int mp_property_framedropping(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
652
|
|
653 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
654
|
|
655 switch(action) {
|
|
656 case M_PROPERTY_PRINT:
|
|
657 if(!arg) return M_PROPERTY_ERROR;
|
|
658 *(char**)arg = strdup(frame_dropping == 1 ? MSGTR_Enabled :
|
|
659 (frame_dropping == 2 ? MSGTR_HardFrameDrop : MSGTR_Disabled));
|
|
660 return M_PROPERTY_OK;
|
|
661 default:
|
|
662 return m_property_choice(prop,action,arg,&frame_dropping);
|
|
663 }
|
|
664 }
|
|
665
|
|
666 /// Color settings, try to use vf/vo then fall back on TV. (RW)
|
|
667 static int mp_property_gamma(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
668 int* gamma = prop->priv, r;
|
|
669
|
|
670 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
671
|
|
672 if(gamma[0] == 1000) {
|
|
673 gamma[0] = 0;
|
|
674 get_video_colors(mpctx->sh_video, prop->name, gamma);
|
|
675 }
|
|
676
|
|
677 switch(action) {
|
|
678 case M_PROPERTY_SET:
|
|
679 if(!arg) return M_PROPERTY_ERROR;
|
|
680 M_PROPERTY_CLAMP(prop,*(int*)arg);
|
|
681 *gamma = *(int*)arg;
|
|
682 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
|
|
683 if(r <= 0) break;
|
|
684 return r;
|
|
685 case M_PROPERTY_GET:
|
|
686 if(!arg) return M_PROPERTY_ERROR;
|
|
687 r = get_video_colors(mpctx->sh_video, prop->name, arg);
|
|
688 if(r <= 0) break;
|
|
689 return r;
|
|
690 case M_PROPERTY_STEP_UP:
|
|
691 case M_PROPERTY_STEP_DOWN:
|
|
692 *gamma += (arg ? *(int*)arg : 1) *
|
|
693 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
|
|
694 M_PROPERTY_CLAMP(prop,*gamma);
|
|
695 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
|
|
696 if(r <= 0) break;
|
|
697 return r;
|
|
698 default:
|
|
699 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
700 }
|
|
701
|
|
702 #ifdef USE_TV
|
|
703 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) {
|
|
704 int l = strlen(prop->name);
|
|
705 char tv_prop[3+l+1];
|
|
706 sprintf(tv_prop,"tv_%s",prop->name);
|
|
707 return mp_property_do(tv_prop, action, arg, mpctx);
|
|
708 }
|
|
709 #endif
|
|
710
|
|
711 return M_PROPERTY_UNAVAILABLE;
|
|
712 }
|
|
713
|
|
714 /// VSync (RW)
|
|
715 static int mp_property_vsync(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
716 return m_property_flag(prop,action,arg,&vo_vsync);
|
|
717 }
|
|
718
|
|
719 /// Video codec tag (RO)
|
|
720 static int mp_property_video_format(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
721 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
722 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format);
|
|
723 }
|
|
724
|
|
725 /// Video bitrate (RO)
|
|
726 static int mp_property_video_bitrate(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
727 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
728 return m_property_int_ro(prop, action, arg, mpctx->sh_video->i_bps);
|
|
729 }
|
|
730
|
|
731 /// Video display width (RO)
|
|
732 static int mp_property_width(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
733 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
734 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w);
|
|
735 }
|
|
736
|
|
737 /// Video display height (RO)
|
|
738 static int mp_property_height(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
739 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
740 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h);
|
|
741 }
|
|
742
|
|
743 /// Video fps (RO)
|
|
744 static int mp_property_fps(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
745 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
746 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps);
|
|
747 }
|
|
748
|
|
749 /// Video aspect (RO)
|
|
750 static int mp_property_aspect(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
751 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
752 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect);
|
|
753 }
|
|
754
|
|
755 ///@}
|
|
756
|
|
757 /// \defgroup SubProprties Subtitles properties
|
|
758 /// \ingroup Properties
|
|
759 ///@{
|
|
760
|
|
761 /// Text subtitle position (RW)
|
|
762 static int mp_property_sub_pos(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
763 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
764
|
|
765 switch(action) {
|
|
766 case M_PROPERTY_SET:
|
|
767 if(!arg) return M_PROPERTY_ERROR;
|
|
768 case M_PROPERTY_STEP_UP:
|
|
769 case M_PROPERTY_STEP_DOWN:
|
|
770 vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
771 default:
|
|
772 return m_property_int_range(prop,action,arg,&sub_pos);
|
|
773 }
|
|
774 }
|
|
775
|
|
776 /// Selected subtitles (RW)
|
|
777 static int mp_property_sub(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
778 demux_stream_t *const d_sub = mpctx->d_sub;
|
|
779 const int global_sub_size = mpctx->global_sub_size;
|
|
780 int source = -1, reset_spu = 0;
|
|
781 char* sub_name;
|
|
782
|
|
783 if(global_sub_size <= 0) return M_PROPERTY_UNAVAILABLE;
|
|
784
|
|
785 switch(action) {
|
|
786 case M_PROPERTY_GET:
|
|
787 if(!arg) return M_PROPERTY_ERROR;
|
|
788 *(int *) arg = mpctx->global_sub_pos;
|
|
789 return M_PROPERTY_OK;
|
|
790 case M_PROPERTY_PRINT:
|
|
791 if(!arg) return M_PROPERTY_ERROR;
|
|
792 *(char**)arg = malloc(64);
|
|
793 (*(char**)arg)[63] = 0;
|
|
794 sub_name = 0;
|
|
795 if(subdata)
|
|
796 sub_name = subdata->filename;
|
|
797 #ifdef USE_ASS
|
|
798 if (ass_track && ass_track->name)
|
|
799 sub_name = ass_track->name;
|
|
800 #endif
|
|
801 if(sub_name) {
|
|
802 char *tmp,*tmp2;
|
|
803 tmp = sub_name;
|
|
804 if ((tmp2 = strrchr(tmp, '/')))
|
|
805 tmp = tmp2+1;
|
|
806
|
|
807 snprintf(*(char**)arg, 63, "(%d) %s%s",
|
|
808 mpctx->set_of_sub_pos + 1,
|
|
809 strlen(tmp) < 20 ? "" : "...",
|
|
810 strlen(tmp) < 20 ? tmp : tmp+strlen(tmp)-19);
|
|
811 return M_PROPERTY_OK;
|
|
812 }
|
|
813 #ifdef USE_DVDNAV
|
|
814 if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
|
|
815 if(vo_spudec && dvdsub_id >= 0) {
|
|
816 unsigned char lang[3];
|
|
817 if (dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) {
|
|
818 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, lang);
|
|
819 return M_PROPERTY_OK;
|
|
820 }
|
|
821 }
|
|
822 }
|
|
823 #endif
|
|
824
|
|
825 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA && dvdsub_id >= 0) {
|
|
826 char lang[40] = MSGTR_Unknown;
|
|
827 demux_mkv_get_sub_lang(mpctx->demuxer, dvdsub_id, lang, 9);
|
|
828 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, lang);
|
|
829 return M_PROPERTY_OK;
|
|
830 }
|
|
831 #ifdef HAVE_OGGVORBIS
|
|
832 if (mpctx->demuxer->type == DEMUXER_TYPE_OGG && d_sub && dvdsub_id >= 0) {
|
|
833 char *lang = demux_ogg_sub_lang(mpctx->demuxer, dvdsub_id);
|
|
834 if (!lang) lang = MSGTR_Unknown;
|
|
835 snprintf(*(char**)arg, 63, "(%d) %s",
|
|
836 dvdsub_id, lang);
|
|
837 return M_PROPERTY_OK;
|
|
838 }
|
|
839 #endif
|
|
840 if (vo_vobsub && vobsub_id >= 0) {
|
|
841 const char *language = MSGTR_Unknown;
|
|
842 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
|
|
843 snprintf(*(char**)arg, 63, "(%d) %s",
|
|
844 vobsub_id, language ? language : MSGTR_Unknown);
|
|
845 return M_PROPERTY_OK;
|
|
846 }
|
|
847 #ifdef USE_DVDREAD
|
|
848 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD && dvdsub_id >= 0) {
|
|
849 char lang[3];
|
|
850 int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id);
|
|
851 lang[0] = code >> 8;
|
|
852 lang[1] = code;
|
|
853 lang[2] = 0;
|
|
854 snprintf(*(char**)arg, 63, "(%d) %s",
|
|
855 dvdsub_id, lang);
|
|
856 return M_PROPERTY_OK;
|
|
857 }
|
|
858 #endif
|
|
859 if (dvdsub_id >= 0) {
|
|
860 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
|
|
861 return M_PROPERTY_OK;
|
|
862 }
|
|
863 snprintf(*(char**)arg, 63, MSGTR_Disabled);
|
|
864 return M_PROPERTY_OK;
|
|
865
|
|
866 case M_PROPERTY_SET:
|
|
867 if(!arg) return M_PROPERTY_ERROR;
|
|
868 if(*(int*)arg < -1) *(int*)arg = -1;
|
|
869 else if(*(int*)arg >= global_sub_size) *(int*)arg = global_sub_size-1;
|
|
870 mpctx->global_sub_pos = *(int *) arg;
|
|
871 break;
|
|
872 case M_PROPERTY_STEP_UP:
|
|
873 mpctx->global_sub_pos += 2;
|
|
874 mpctx->global_sub_pos = (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
|
|
875 break;
|
|
876 case M_PROPERTY_STEP_DOWN:
|
|
877 mpctx->global_sub_pos += global_sub_size + 1;
|
|
878 mpctx->global_sub_pos = (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
|
|
879 break;
|
|
880 default:
|
|
881 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
882 }
|
|
883
|
|
884 if (mpctx->global_sub_pos >= 0)
|
|
885 source = sub_source(mpctx);
|
|
886
|
|
887 mp_msg(MSGT_CPLAYER, MSGL_DBG3,
|
|
888 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
|
|
889 global_sub_size,
|
|
890 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB],
|
|
891 mpctx->global_sub_indices[SUB_SOURCE_SUBS],
|
|
892 mpctx->global_sub_indices[SUB_SOURCE_DEMUX],
|
|
893 mpctx->global_sub_pos, source);
|
|
894
|
|
895 mpctx->set_of_sub_pos = -1;
|
|
896 subdata = NULL;
|
|
897 vo_sub_last = vo_sub = NULL;
|
|
898
|
|
899 vobsub_id = -1;
|
|
900 dvdsub_id = -1;
|
|
901 if (d_sub) {
|
|
902 if (d_sub->id > -2) reset_spu = 1;
|
|
903 d_sub->id = -2;
|
|
904 }
|
|
905 #ifdef USE_ASS
|
|
906 ass_track = 0;
|
|
907 #endif
|
|
908
|
|
909 if (source == SUB_SOURCE_VOBSUB) {
|
|
910 vobsub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_VOBSUB];
|
|
911 } else if (source == SUB_SOURCE_SUBS) {
|
|
912 mpctx->set_of_sub_pos = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS];
|
|
913 #ifdef USE_ASS
|
|
914 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos])
|
|
915 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos];
|
|
916 else
|
|
917 #endif
|
|
918 {
|
|
919 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos];
|
|
920 vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
921 }
|
|
922 } else if (source == SUB_SOURCE_DEMUX) {
|
|
923 dvdsub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX];
|
|
924 if (d_sub) {
|
|
925 #ifdef USE_DVDREAD
|
|
926 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD) {
|
|
927 d_sub->id = dvdsub_id;
|
|
928 }
|
|
929 #endif
|
|
930
|
|
931 #ifdef USE_DVDNAV
|
|
932 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVDNAV) {
|
|
933 d_sub->id = dvdsub_id;
|
|
934 }
|
|
935 #endif
|
|
936 if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_DVDNAV) {
|
|
937 int i = 0;
|
|
938 for (d_sub->id = 0; d_sub->id < MAX_S_STREAMS; d_sub->id++) {
|
|
939 if (mpctx->demuxer->s_streams[d_sub->id]) {
|
|
940 if (i == dvdsub_id) break;
|
|
941 i++;
|
|
942 }
|
|
943 }
|
|
944 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
|
|
945 }
|
|
946 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA) {
|
|
947 d_sub->id = demux_mkv_change_subs(mpctx->demuxer, dvdsub_id);
|
|
948 }
|
|
949 if (d_sub->sh && d_sub->id >= 0) {
|
|
950 sh_sub_t *sh = d_sub->sh;
|
|
951 if (sh->type == 'v')
|
|
952 init_vo_spudec();
|
|
953 #ifdef USE_ASS
|
|
954 else if (ass_enabled && sh->type == 'a')
|
|
955 ass_track = sh->ass_track;
|
|
956 #endif
|
|
957 }
|
|
958 }
|
|
959 }
|
|
960 #ifdef USE_DVDREAD
|
|
961 if (vo_spudec && (mpctx->stream->type == STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV) && dvdsub_id < 0 && reset_spu) {
|
|
962 dvdsub_id = -2;
|
|
963 d_sub->id = dvdsub_id;
|
|
964 }
|
|
965 #endif
|
|
966 update_subtitles(mpctx->sh_video, d_sub, 1);
|
|
967
|
|
968 return M_PROPERTY_OK;
|
|
969 }
|
|
970
|
|
971 /// Subtitle delay (RW)
|
|
972 static int mp_property_sub_delay(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
973 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
974 return m_property_delay(prop,action,arg,&sub_delay);
|
|
975 }
|
|
976
|
|
977 /// Alignment of text subtitles (RW)
|
|
978 static int mp_property_sub_alignment(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
979 char* name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom };
|
|
980
|
|
981 if (!mpctx->sh_video || mpctx->global_sub_pos < 0 || sub_source(mpctx) != SUB_SOURCE_SUBS)
|
|
982 return M_PROPERTY_UNAVAILABLE;
|
|
983
|
|
984 switch(action) {
|
|
985 case M_PROPERTY_PRINT:
|
|
986 if(!arg) return M_PROPERTY_ERROR;
|
|
987 M_PROPERTY_CLAMP(prop,sub_alignment);
|
|
988 *(char**)arg = strdup(name[sub_alignment]);
|
|
989 return M_PROPERTY_OK;
|
|
990 case M_PROPERTY_SET:
|
|
991 if(!arg) return M_PROPERTY_ERROR;
|
|
992 case M_PROPERTY_STEP_UP:
|
|
993 case M_PROPERTY_STEP_DOWN:
|
|
994 vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
995 default:
|
|
996 return m_property_choice(prop,action,arg,&sub_alignment);
|
|
997 }
|
|
998 }
|
|
999
|
|
1000 /// Subtitle visibility (RW)
|
|
1001 static int mp_property_sub_visibility(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
1002 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
|
|
1003
|
|
1004 switch(action) {
|
|
1005 case M_PROPERTY_SET:
|
|
1006 if(!arg) return M_PROPERTY_ERROR;
|
|
1007 case M_PROPERTY_STEP_UP:
|
|
1008 case M_PROPERTY_STEP_DOWN:
|
|
1009 vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
1010 if(vo_spudec) vo_osd_changed(OSDTYPE_SPU);
|
|
1011 default:
|
|
1012 return m_property_flag(prop,action,arg,&sub_visibility);
|
|
1013 }
|
|
1014 }
|
|
1015
|
|
1016 /// Show only forced subtitles (RW)
|
|
1017 static int mp_property_sub_forced_only(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
1018 if(!vo_spudec) return M_PROPERTY_UNAVAILABLE;
|
|
1019
|
|
1020 switch(action) {
|
|
1021 case M_PROPERTY_SET:
|
|
1022 if(!arg) return M_PROPERTY_ERROR;
|
|
1023 case M_PROPERTY_STEP_UP:
|
|
1024 case M_PROPERTY_STEP_DOWN:
|
|
1025 m_property_flag(prop,action,arg,&forced_subs_only);
|
|
1026 spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
|
|
1027 return M_PROPERTY_OK;
|
|
1028 default:
|
|
1029 return m_property_flag(prop,action,arg,&forced_subs_only);
|
|
1030 }
|
|
1031
|
|
1032 }
|
|
1033
|
|
1034 ///@}
|
|
1035
|
|
1036 /// \defgroup TVProperties TV properties
|
|
1037 /// \ingroup Properties
|
|
1038 ///@{
|
|
1039
|
|
1040 #ifdef USE_TV
|
|
1041
|
|
1042 /// TV color settings (RW)
|
|
1043 static int mp_property_tv_color(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
|
|
1044 int r,val;
|
|
1045 tvi_handle_t *tvh = mpctx->demuxer->priv;
|
|
1046 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) return M_PROPERTY_UNAVAILABLE;
|
|
1047
|
|
1048 switch(action) {
|
|
1049 case M_PROPERTY_SET:
|
|
1050 if(!arg) return M_PROPERTY_ERROR;
|
|
1051 M_PROPERTY_CLAMP(prop,*(int*)arg);
|
|
1052 return tv_set_color_options(tvh,(int)prop->priv,*(int*)arg);
|
|
1053 case M_PROPERTY_GET:
|
|
1054 return tv_get_color_options(tvh,(int)prop->priv,arg);
|
|
1055 case M_PROPERTY_STEP_UP:
|
|
1056 case M_PROPERTY_STEP_DOWN:
|
|
1057 if((r = tv_get_color_options(tvh,(int)prop->priv,&val)) >= 0) {
|
|
1058 if(!r) return M_PROPERTY_ERROR;
|
|
1059 val += (arg ? *(int*)arg : 1) *
|
|
1060 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
|
|
1061 M_PROPERTY_CLAMP(prop,val);
|
|
1062 return tv_set_color_options(tvh,(int)prop->priv,val);
|
|
1063 }
|
|
1064 return M_PROPERTY_ERROR;
|
|
1065 }
|
|
1066 return M_PROPERTY_NOT_IMPLEMENTED;
|
|
1067 }
|
|
1068
|
|
1069 #endif
|
|
1070
|
|
1071 ///@}
|
|
1072
|
|
1073 /// All properties available in MPlayer.
|
|
1074 /** \ingroup Properties
|
|
1075 */
|
|
1076 static m_option_t mp_properties[] = {
|
|
1077 // General
|
|
1078 { "osdlevel", mp_property_osdlevel, CONF_TYPE_INT,
|
|
1079 M_OPT_RANGE, 0, 3, NULL },
|
|
1080 { "speed", mp_property_playback_speed, CONF_TYPE_FLOAT,
|
|
1081 M_OPT_RANGE, 0.01, 100.0, NULL },
|
|
1082 { "filename", mp_property_filename, CONF_TYPE_STRING,
|
|
1083 0, 0, 0, NULL },
|
|
1084 { "path", mp_property_path, CONF_TYPE_STRING,
|
|
1085 0, 0, 0, NULL },
|
|
1086 { "demuxer", mp_property_demuxer, CONF_TYPE_STRING,
|
|
1087 0, 0, 0, NULL },
|
|
1088 { "stream_pos", mp_property_stream_pos, CONF_TYPE_POSITION,
|
|
1089 M_OPT_MIN, 0, 0, NULL },
|
|
1090 { "stream_start", mp_property_stream_start, CONF_TYPE_POSITION,
|
|
1091 M_OPT_MIN, 0, 0, NULL },
|
|
1092 { "stream_end", mp_property_stream_end, CONF_TYPE_POSITION,
|
|
1093 M_OPT_MIN, 0, 0, NULL },
|
|
1094 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION,
|
|
1095 M_OPT_MIN, 0, 0, NULL },
|
|
1096 { "length", mp_property_length, CONF_TYPE_DOUBLE,
|
|
1097 0, 0, 0, NULL },
|
|
1098
|
|
1099 // Audio
|
|
1100 { "volume", mp_property_volume, CONF_TYPE_FLOAT,
|
|
1101 M_OPT_RANGE, 0, 100, NULL },
|
|
1102 { "mute", mp_property_mute, CONF_TYPE_FLAG,
|
|
1103 M_OPT_RANGE, 0, 1, NULL },
|
|
1104 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT,
|
|
1105 M_OPT_RANGE, -100, 100, NULL },
|
|
1106 { "audio_format", mp_property_audio_format, CONF_TYPE_INT,
|
|
1107 0, 0, 0, NULL },
|
|
1108 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT,
|
|
1109 0, 0, 0, NULL },
|
|
1110 { "samplerate", mp_property_samplerate, CONF_TYPE_INT,
|
|
1111 0, 0, 0, NULL },
|
|
1112 { "channels", mp_property_channels, CONF_TYPE_INT,
|
|
1113 0, 0, 0, NULL },
|
|
1114 { "switch_audio", mp_property_audio, CONF_TYPE_INT,
|
|
1115 CONF_RANGE, -2, MAX_A_STREAMS-1, NULL },
|
|
1116
|
|
1117 // Video
|
|
1118 { "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG,
|
|
1119 M_OPT_RANGE, 0, 1, NULL },
|
|
1120 { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG,
|
|
1121 M_OPT_RANGE, 0, 1, NULL },
|
|
1122 { "ontop", mp_property_ontop, CONF_TYPE_FLAG,
|
|
1123 M_OPT_RANGE, 0, 1, NULL },
|
|
1124 { "rootwin", mp_property_rootwin, CONF_TYPE_FLAG,
|
|
1125 M_OPT_RANGE, 0, 1, NULL },
|
|
1126 { "border", mp_property_border, CONF_TYPE_FLAG,
|
|
1127 M_OPT_RANGE, 0, 1, NULL },
|
|
1128 { "framedropping", mp_property_framedropping, CONF_TYPE_INT,
|
|
1129 M_OPT_RANGE, 0, 2, NULL },
|
|
1130 { "gamma", mp_property_gamma, CONF_TYPE_INT,
|
|
1131 M_OPT_RANGE, -100, 100, &vo_gamma_gamma },
|
|
1132 { "brightness", mp_property_gamma, CONF_TYPE_INT,
|
|
1133 M_OPT_RANGE, -100, 100, &vo_gamma_brightness },
|
|
1134 { "contrast", mp_property_gamma, CONF_TYPE_INT,
|
|
1135 M_OPT_RANGE, -100, 100, &vo_gamma_contrast },
|
|
1136 { "saturation", mp_property_gamma, CONF_TYPE_INT,
|
|
1137 M_OPT_RANGE, -100, 100, &vo_gamma_saturation },
|
|
1138 { "hue", mp_property_gamma, CONF_TYPE_INT,
|
|
1139 M_OPT_RANGE, -100, 100, &vo_gamma_hue },
|
|
1140 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT,
|
|
1141 M_OPT_RANGE, 0, 1, NULL },
|
|
1142 { "vsync", mp_property_vsync, CONF_TYPE_FLAG,
|
|
1143 M_OPT_RANGE, 0, 1, NULL },
|
|
1144 { "video_format", mp_property_video_format, CONF_TYPE_INT,
|
|
1145 0, 0, 0, NULL },
|
|
1146 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT,
|
|
1147 0, 0, 0, NULL },
|
|
1148 { "width", mp_property_width, CONF_TYPE_INT,
|
|
1149 0, 0, 0, NULL },
|
|
1150 { "height", mp_property_height, CONF_TYPE_INT,
|
|
1151 0, 0, 0, NULL },
|
|
1152 { "fps", mp_property_fps, CONF_TYPE_FLOAT,
|
|
1153 0, 0, 0, NULL },
|
|
1154 { "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
|
|
1155 0, 0, 0, NULL },
|
|
1156 { "switch_video", mp_property_video, CONF_TYPE_INT,
|
|
1157 CONF_RANGE, -2, MAX_V_STREAMS-1, NULL },
|
|
1158 { "switch_program", mp_property_program, CONF_TYPE_INT,
|
|
1159 CONF_RANGE, -1, 65535, NULL },
|
|
1160
|
|
1161 // Subs
|
|
1162 { "sub", mp_property_sub, CONF_TYPE_INT,
|
|
1163 M_OPT_MIN, -1, 0, NULL },
|
|
1164 { "sub_delay", mp_property_sub_delay, CONF_TYPE_FLOAT,
|
|
1165 0, 0, 0, NULL },
|
|
1166 { "sub_pos", mp_property_sub_pos, CONF_TYPE_INT,
|
|
1167 M_OPT_RANGE, 0, 100, NULL },
|
|
1168 { "sub_alignment", mp_property_sub_alignment, CONF_TYPE_INT,
|
|
1169 M_OPT_RANGE, 0, 2, NULL },
|
|
1170 { "sub_visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
|
|
1171 M_OPT_RANGE, 0, 1, NULL },
|
|
1172 { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG,
|
|
1173 M_OPT_RANGE, 0, 1, NULL },
|
|
1174
|
|
1175 #ifdef USE_TV
|
|
1176 { "tv_brightness", mp_property_tv_color, CONF_TYPE_INT,
|
|
1177 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_BRIGHTNESS },
|
|
1178 { "tv_contrast", mp_property_tv_color, CONF_TYPE_INT,
|
|
1179 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_CONTRAST },
|
|
1180 { "tv_saturation", mp_property_tv_color, CONF_TYPE_INT,
|
|
1181 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_SATURATION },
|
|
1182 { "tv_hue", mp_property_tv_color, CONF_TYPE_INT,
|
|
1183 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_HUE },
|
|
1184 #endif
|
|
1185
|
|
1186 { NULL, NULL, NULL, 0, 0, 0, NULL }
|
|
1187 };
|
|
1188
|
|
1189 m_option_t* mp_property_find(const char* name) {
|
|
1190 return m_option_list_find(mp_properties,name);
|
|
1191 }
|
|
1192
|
|
1193 int mp_property_do(const char *name, int action, void *val, void *ctx) {
|
|
1194 m_option_t* p = mp_property_find(name);
|
|
1195 if(!p) return M_PROPERTY_UNAVAILABLE;
|
|
1196 return m_property_do(p, action, val, ctx);
|
|
1197 }
|
|
1198
|
|
1199 char *property_expand_string(MPContext * mpctx, char *str) {
|
|
1200 return m_properties_expand_string(mp_properties, str, mpctx);
|
|
1201 }
|
|
1202
|
|
1203 void property_print_help(void) {
|
|
1204 m_properties_print_help_list(mp_properties);
|
|
1205 }
|
|
1206
|
|
1207
|
|
1208 ///@}
|
|
1209 // Properties group
|
|
1210
|
|
1211
|
|
1212 /**
|
|
1213 * \defgroup Command2Property Command to property bridge
|
|
1214 *
|
|
1215 * It is used to handle most commands that just set a property
|
|
1216 * and optionally display something on the OSD.
|
|
1217 * Two kinds of commands are handled: adjust or toggle.
|
|
1218 *
|
|
1219 * Adjust commands take 1 or 2 parameters: <value> <abs>
|
|
1220 * If <abs> is non-zero the property is set to the given value
|
|
1221 * otherwise it is adjusted.
|
|
1222 *
|
|
1223 * Toggle commands take 0 or 1 parameters. With no parameter
|
|
1224 * or a value less than the property minimum it just steps the
|
|
1225 * property to its next value. Otherwise it sets it to the given
|
|
1226 * value.
|
|
1227 *
|
|
1228 *@{
|
|
1229 */
|
|
1230
|
|
1231 /// List of the commands that can be handled by setting a property.
|
|
1232 static struct {
|
|
1233 /// property name
|
|
1234 const char* name;
|
|
1235 /// cmd id
|
|
1236 int cmd;
|
|
1237 /// set/adjust or toggle command
|
|
1238 int toggle;
|
|
1239 /// progressbar type
|
|
1240 int osd_progbar;
|
|
1241 /// osd msg id if it must be shared
|
|
1242 int osd_id;
|
|
1243 /// osd msg template
|
|
1244 const char* osd_msg;
|
|
1245 } set_prop_cmd[] = {
|
|
1246 // audio
|
|
1247 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
|
|
1248 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
|
|
1249 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus },
|
|
1250 { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio },
|
|
1251 // video
|
|
1252 { "fullscreen", MP_CMD_VO_FULLSCREEN, 1, 0, -1, NULL },
|
|
1253 { "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, MSGTR_Panscan },
|
|
1254 { "ontop", MP_CMD_VO_ONTOP, 1, 0, -1, MSGTR_OnTopStatus },
|
|
1255 { "rootwin", MP_CMD_VO_ROOTWIN, 1, 0, -1, MSGTR_RootwinStatus },
|
|
1256 { "border", MP_CMD_VO_BORDER, 1, 0, -1, MSGTR_BorderStatus },
|
|
1257 { "framedropping", MP_CMD_FRAMEDROPPING, 1, 0, -1, MSGTR_FramedroppingStatus },
|
|
1258 { "gamma", MP_CMD_GAMMA, 0, OSD_BRIGHTNESS, -1, MSGTR_Gamma },
|
|
1259 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
|
|
1260 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
|
|
1261 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
|
|
1262 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
|
|
1263 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus },
|
|
1264 // subs
|
|
1265 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus },
|
|
1266 { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus },
|
|
1267 { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus },
|
|
1268 { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus },
|
|
1269 { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus },
|
|
1270 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, MSGTR_SubForcedOnlyStatus },
|
|
1271 #ifdef USE_TV
|
|
1272 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
|
|
1273 { "tv_hue", MP_CMD_TV_SET_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
|
|
1274 { "tv_saturation", MP_CMD_TV_SET_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
|
|
1275 { "tv_contrast", MP_CMD_TV_SET_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
|
|
1276 #endif
|
|
1277 { NULL, 0, 0, 0, -1, NULL }
|
|
1278 };
|
|
1279
|
|
1280
|
|
1281 /// Handle commands that set a property.
|
|
1282 static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd) {
|
|
1283 int i,r;
|
|
1284 m_option_t* prop;
|
|
1285
|
|
1286 // look for the command
|
|
1287 for(i = 0 ; set_prop_cmd[i].name ; i++)
|
|
1288 if(set_prop_cmd[i].cmd == cmd->id) break;
|
|
1289 if(!set_prop_cmd[i].name) return 0;
|
|
1290
|
|
1291 // get the property
|
|
1292 prop = mp_property_find(set_prop_cmd[i].name);
|
|
1293 if(!prop) return 0;
|
|
1294
|
|
1295 // toggle command
|
|
1296 if(set_prop_cmd[i].toggle) {
|
|
1297 // set to value
|
|
1298 if(cmd->nargs > 0 && cmd->args[0].v.i >= prop->min)
|
|
1299 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx);
|
|
1300 else
|
|
1301 r = m_property_do(prop, M_PROPERTY_STEP_UP, NULL, mpctx);
|
|
1302 } else if(cmd->args[1].v.i) //set
|
|
1303 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v, mpctx);
|
|
1304 else // adjust
|
|
1305 r = m_property_do(prop, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx);
|
|
1306
|
|
1307 if(r <= 0) return 1;
|
|
1308
|
|
1309 if(set_prop_cmd[i].osd_progbar) {
|
|
1310 if(prop->type == CONF_TYPE_INT) {
|
|
1311 if (m_property_do(prop, M_PROPERTY_GET, &r, mpctx) > 0)
|
|
1312 set_osd_bar(set_prop_cmd[i].osd_progbar,
|
|
1313 set_prop_cmd[i].osd_msg,
|
|
1314 prop->min,prop->max,r);
|
|
1315 } else if(prop->type == CONF_TYPE_FLOAT) {
|
|
1316 float f;
|
|
1317 if (m_property_do(prop, M_PROPERTY_GET, &f, mpctx) > 0)
|
|
1318 set_osd_bar(set_prop_cmd[i].osd_progbar,set_prop_cmd[i].osd_msg,
|
|
1319 prop->min,prop->max,f);
|
|
1320 } else
|
|
1321 mp_msg(MSGT_CPLAYER,MSGL_ERR, "Property use an unsupported type.\n");
|
|
1322 return 1;
|
|
1323 }
|
|
1324
|
|
1325 if(set_prop_cmd[i].osd_msg) {
|
|
1326 char *val = m_property_print(prop, mpctx);
|
|
1327 if(val) {
|
|
1328 set_osd_msg(set_prop_cmd[i].osd_id >= 0 ? set_prop_cmd[i].osd_id :
|
|
1329 OSD_MSG_PROPERTY+i,1,osd_duration,
|
|
1330 set_prop_cmd[i].osd_msg,val);
|
|
1331 free(val);
|
|
1332 }
|
|
1333 }
|
|
1334 return 1;
|
|
1335 }
|
|
1336
|
|
1337 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) {
|
|
1338 //remove the borders, if any, and rescale to the range [0,1],[0,1]
|
|
1339 if(vo_fs) { //we are in full-screen mode
|
|
1340 if(vo_screenwidth > vo_dwidth) //there are borders along the x axis
|
|
1341 ix -= (vo_screenwidth - vo_dwidth) / 2;
|
|
1342 if(vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
|
|
1343 iy -= (vo_screenheight - vo_dheight) / 2;
|
|
1344
|
|
1345 if(ix < 0 || ix > vo_dwidth) {*dx = *dy = -1.0; return; } //we are on one of the borders
|
|
1346 if(iy < 0 || iy > vo_dheight) {*dx = *dy = -1.0; return; } //we are on one of the borders
|
|
1347 }
|
|
1348
|
|
1349 *dx = (double) ix / (double) vo_dwidth;
|
|
1350 *dy = (double) iy / (double) vo_dheight;
|
|
1351
|
|
1352 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
|
|
1353 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, vo_dheight, vo_fs);
|
|
1354 }
|
|
1355
|
|
1356 int run_command(MPContext * mpctx, mp_cmd_t * cmd)
|
|
1357 {
|
|
1358 sh_audio_t * const sh_audio = mpctx->sh_audio;
|
|
1359 sh_video_t * const sh_video = mpctx->sh_video;
|
|
1360 int brk_cmd = 0;
|
|
1361 if (!set_property_command(mpctx, cmd))
|
|
1362 switch(cmd->id) {
|
|
1363 case MP_CMD_SEEK : {
|
|
1364 float v;
|
|
1365 int abs;
|
|
1366 if(sh_video)
|
|
1367 mpctx->osd_show_percentage = sh_video->fps;
|
|
1368 v = cmd->args[0].v.f;
|
|
1369 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
|
|
1370 if(abs==2) { /* Absolute seek to a specific timestamp in seconds */
|
|
1371 abs_seek_pos = 1;
|
|
1372 if(sh_video)
|
|
1373 mpctx->osd_function = (v > sh_video->pts) ? OSD_FFW : OSD_REW;
|
|
1374 rel_seek_secs = v;
|
|
1375 }
|
|
1376 else if(abs) { /* Absolute seek by percentage */
|
|
1377 abs_seek_pos = 3;
|
|
1378 if(sh_video)
|
|
1379 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly
|
|
1380 rel_seek_secs = v/100.0;
|
|
1381 }
|
|
1382 else {
|
|
1383 rel_seek_secs+= v;
|
|
1384 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW;
|
|
1385 }
|
|
1386 brk_cmd = 1;
|
|
1387 } break;
|
|
1388 case MP_CMD_SET_PROPERTY: {
|
|
1389 m_option_t* prop = mp_property_find(cmd->args[0].v.s);
|
|
1390 if(!prop) mp_msg(MSGT_CPLAYER,MSGL_WARN,"Unknown property: '%s'\n",cmd->args[0].v.s);
|
|
1391 else if (m_property_parse(prop, cmd->args[1].v.s, mpctx) <= 0)
|
|
1392 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to set property '%s' to '%s'.\n",
|
|
1393 cmd->args[0].v.s,cmd->args[1].v.s);
|
|
1394
|
|
1395 } break;
|
|
1396 case MP_CMD_STEP_PROPERTY: {
|
|
1397 m_option_t* prop = mp_property_find(cmd->args[0].v.s);
|
|
1398 float arg = cmd->args[1].v.f;
|
|
1399 if(!prop) mp_msg(MSGT_CPLAYER,MSGL_WARN, "Unknown property: '%s'\n",cmd->args[0].v.s);
|
|
1400 else if (m_property_do(prop, M_PROPERTY_STEP_UP, arg ? &arg : NULL, mpctx) <= 0)
|
|
1401 mp_msg(MSGT_CPLAYER,MSGL_WARN, "Failed to increment property '%s' by %f.\n",cmd->args[0].v.s, arg);
|
|
1402 } break;
|
|
1403
|
|
1404 case MP_CMD_GET_PROPERTY: {
|
|
1405 m_option_t* prop;
|
|
1406 void* val;
|
|
1407 char* tmp;
|
|
1408 prop = mp_property_find(cmd->args[0].v.s);
|
|
1409 if(!prop) {
|
|
1410 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Unknown property: '%s'\n",cmd->args[0].v.s);
|
|
1411 break;
|
|
1412 }
|
|
1413 /* Use m_option_print directly to get easily parseable values. */
|
|
1414 val = calloc(1,prop->type->size);
|
|
1415 if (m_property_do(prop, M_PROPERTY_GET, val, mpctx) <= 0) {
|
|
1416 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to get value of property '%s'.\n",
|
|
1417 cmd->args[0].v.s);
|
|
1418 break;
|
|
1419 }
|
|
1420 tmp = m_option_print(prop, val);
|
|
1421 if(!tmp || tmp == (char*)-1) {
|
|
1422 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to print value of property '%s'.\n",
|
|
1423 cmd->args[0].v.s);
|
|
1424 break;
|
|
1425 }
|
|
1426 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_%s=%s\n",cmd->args[0].v.s,tmp);
|
|
1427 free(tmp);
|
|
1428 } break;
|
|
1429 case MP_CMD_EDL_MARK:
|
|
1430 if( edl_fd ) {
|
|
1431 float v = sh_video ? sh_video->pts :
|
|
1432 playing_audio_pts(sh_audio, mpctx->d_audio, mpctx->audio_out);
|
|
1433
|
|
1434 if (mpctx->begin_skip == MP_NOPTS_VALUE)
|
|
1435 {
|
|
1436 mpctx->begin_skip = v;
|
|
1437 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip);
|
|
1438 }else{
|
|
1439 if (mpctx->begin_skip > v)
|
|
1440 {
|
|
1441 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop);
|
|
1442 }else{
|
|
1443 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0);
|
|
1444 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip);
|
|
1445 }
|
|
1446 mpctx->begin_skip = MP_NOPTS_VALUE;
|
|
1447 }
|
|
1448 }
|
|
1449 break;
|
|
1450 case MP_CMD_SWITCH_RATIO : {
|
|
1451 if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
|
|
1452 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
|
|
1453 else
|
|
1454 movie_aspect = cmd->args[0].v.f;
|
|
1455 mpcodecs_config_vo (sh_video, sh_video->disp_w, sh_video->disp_h, 0);
|
|
1456 } break;
|
|
1457 case MP_CMD_SPEED_INCR : {
|
|
1458 float v = cmd->args[0].v.f;
|
|
1459 playback_speed += v;
|
|
1460 build_afilter_chain(sh_audio, &ao_data);
|
|
1461 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
|
|
1462 } break;
|
|
1463 case MP_CMD_SPEED_MULT : {
|
|
1464 float v = cmd->args[0].v.f;
|
|
1465 playback_speed *= v;
|
|
1466 build_afilter_chain(sh_audio, &ao_data);
|
|
1467 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
|
|
1468 } break;
|
|
1469 case MP_CMD_SPEED_SET : {
|
|
1470 float v = cmd->args[0].v.f;
|
|
1471 playback_speed = v;
|
|
1472 build_afilter_chain(sh_audio, &ao_data);
|
|
1473 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
|
|
1474 } break;
|
|
1475 case MP_CMD_FRAME_STEP :
|
|
1476 case MP_CMD_PAUSE : {
|
|
1477 cmd->pausing = 1;
|
|
1478 brk_cmd = 1;
|
|
1479 } break;
|
|
1480 case MP_CMD_FILE_FILTER : {
|
|
1481 file_filter = cmd->args[0].v.i;
|
|
1482 break;
|
|
1483 }
|
|
1484 case MP_CMD_QUIT : {
|
|
1485 exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
|
|
1486 }
|
|
1487 case MP_CMD_PLAY_TREE_STEP : {
|
|
1488 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i;
|
|
1489 int force = cmd->args[1].v.i;
|
|
1490
|
|
1491 #ifdef HAVE_NEW_GUI
|
|
1492 if (use_gui) {
|
|
1493 int i=0;
|
|
1494 if (n>0)
|
|
1495 for (i=0;i<n;i++)
|
|
1496 mplNext();
|
|
1497 else
|
|
1498 for (i=0;i<-1*n;i++)
|
|
1499 mplPrev();
|
|
1500 } else
|
|
1501 #endif
|
|
1502 {
|
|
1503 if (!force && mpctx->playtree_iter) {
|
|
1504 play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter);
|
|
1505
|
|
1506 if(play_tree_iter_step(i,n,0) == PLAY_TREE_ITER_ENTRY)
|
|
1507 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
|
|
1508 play_tree_iter_free(i);
|
|
1509 } else
|
|
1510 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
|
|
1511 if (mpctx->eof)
|
|
1512 mpctx->play_tree_step = n;
|
|
1513 brk_cmd = 1;
|
|
1514 }
|
|
1515 } break;
|
|
1516 case MP_CMD_PLAY_TREE_UP_STEP : {
|
|
1517 int n = cmd->args[0].v.i > 0 ? 1 : -1;
|
|
1518 int force = cmd->args[1].v.i;
|
|
1519
|
|
1520 if (!force && mpctx->playtree_iter) {
|
|
1521 play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter);
|
|
1522 if(play_tree_iter_up_step(i,n,0) == PLAY_TREE_ITER_ENTRY)
|
|
1523 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
|
|
1524 play_tree_iter_free(i);
|
|
1525 } else
|
|
1526 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
|
|
1527 brk_cmd = 1;
|
|
1528 } break;
|
|
1529 case MP_CMD_PLAY_ALT_SRC_STEP : {
|
|
1530 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) {
|
|
1531 int v = cmd->args[0].v.i;
|
|
1532 if (v > 0 && mpctx->playtree_iter->file < mpctx->playtree_iter->num_files)
|
|
1533 mpctx->eof = PT_NEXT_SRC;
|
|
1534 else if (v < 0 && mpctx->playtree_iter->file > 1)
|
|
1535 mpctx->eof = PT_PREV_SRC;
|
|
1536 }
|
|
1537 brk_cmd = 1;
|
|
1538 } break;
|
|
1539 case MP_CMD_SUB_STEP : {
|
|
1540 if (sh_video) {
|
|
1541 int movement = cmd->args[0].v.i;
|
|
1542 step_sub(subdata, sh_video->pts, movement);
|
|
1543 #ifdef USE_ASS
|
|
1544 if (ass_track)
|
|
1545 sub_delay += ass_step_sub(ass_track, (sh_video->pts + sub_delay) * 1000 + .5, movement) / 1000.;
|
|
1546 #endif
|
|
1547 set_osd_msg(OSD_MSG_SUB_DELAY,1,osd_duration,
|
|
1548 MSGTR_OSDSubDelay, ROUND(sub_delay*1000));
|
|
1549 }
|
|
1550 } break;
|
|
1551 case MP_CMD_SUB_LOG : {
|
|
1552 log_sub();
|
|
1553 } break;
|
|
1554 case MP_CMD_OSD : {
|
|
1555 int v = cmd->args[0].v.i;
|
|
1556 int max = (term_osd && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
|
|
1557 if(osd_level > max) osd_level = max;
|
|
1558 if(v < 0)
|
|
1559 osd_level=(osd_level+1)%(max+1);
|
|
1560 else
|
|
1561 osd_level= v > max ? max : v;
|
|
1562 /* Show OSD state when disabled, but not when an explicit
|
|
1563 argument is given to the OSD command, i.e. in slave mode. */
|
|
1564 if (v == -1 && osd_level <= 1)
|
|
1565 set_osd_msg(OSD_MSG_OSD_STATUS,0,osd_duration,
|
|
1566 MSGTR_OSDosd, osd_level ? MSGTR_OSDenabled : MSGTR_OSDdisabled);
|
|
1567 else
|
|
1568 rm_osd_msg(OSD_MSG_OSD_STATUS);
|
|
1569 } break;
|
|
1570 case MP_CMD_OSD_SHOW_TEXT : {
|
|
1571 set_osd_msg(OSD_MSG_TEXT,cmd->args[2].v.i,
|
|
1572 (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
|
|
1573 "%-.63s",cmd->args[0].v.s);
|
|
1574 } break;
|
|
1575 case MP_CMD_OSD_SHOW_PROPERTY_TEXT : {
|
|
1576 char *txt = m_properties_expand_string(mp_properties,cmd->args[0].v.s,mpctx);
|
|
1577 /* if no argument supplied take default osd_duration, else <arg> ms. */
|
|
1578 if(txt) {
|
|
1579 set_osd_msg(OSD_MSG_TEXT,cmd->args[2].v.i,
|
|
1580 (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
|
|
1581 "%-.63s",txt);
|
|
1582 free(txt);
|
|
1583 }
|
|
1584 } break;
|
|
1585 case MP_CMD_LOADFILE : {
|
|
1586 play_tree_t* e = play_tree_new();
|
|
1587 play_tree_add_file(e,cmd->args[0].v.s);
|
|
1588
|
|
1589 if (cmd->args[1].v.i) // append
|
|
1590 play_tree_append_entry(mpctx->playtree, e);
|
|
1591 else {
|
|
1592 // Go back to the starting point.
|
|
1593 while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
|
|
1594 /* NOP */;
|
|
1595 play_tree_free_list(mpctx->playtree->child, 1);
|
|
1596 play_tree_set_child(mpctx->playtree, e);
|
|
1597 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
|
|
1598 mpctx->eof = PT_NEXT_SRC;
|
|
1599 }
|
|
1600 brk_cmd = 1;
|
|
1601 } break;
|
|
1602 case MP_CMD_LOADLIST : {
|
|
1603 play_tree_t* e = parse_playlist_file(cmd->args[0].v.s);
|
|
1604 if(!e)
|
|
1605 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_PlaylistLoadUnable,cmd->args[0].v.s);
|
|
1606 else {
|
|
1607 if (cmd->args[1].v.i) // append
|
|
1608 play_tree_append_entry(mpctx->playtree, e);
|
|
1609 else {
|
|
1610 // Go back to the starting point.
|
|
1611 while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
|
|
1612 /* NOP */;
|
|
1613 play_tree_free_list(mpctx->playtree->child, 1);
|
|
1614 play_tree_set_child(mpctx->playtree, e);
|
|
1615 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
|
|
1616 mpctx->eof = PT_NEXT_SRC;
|
|
1617 }
|
|
1618 }
|
|
1619 brk_cmd = 1;
|
|
1620 } break;
|
|
1621 #ifdef USE_RADIO
|
|
1622 case MP_CMD_RADIO_STEP_CHANNEL : {
|
|
1623 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
|
|
1624 int v = cmd->args[0].v.i;
|
|
1625 if(v > 0)
|
|
1626 radio_step_channel(mpctx->demuxer->stream, RADIO_CHANNEL_HIGHER);
|
|
1627 else
|
|
1628 radio_step_channel(mpctx->demuxer->stream, RADIO_CHANNEL_LOWER);
|
|
1629 if (radio_get_channel_name(mpctx->demuxer->stream)) {
|
|
1630 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
|
|
1631 MSGTR_OSDChannel, radio_get_channel_name(mpctx->demuxer->stream));
|
|
1632 }
|
|
1633 }
|
|
1634 } break;
|
|
1635 case MP_CMD_RADIO_SET_CHANNEL : {
|
|
1636 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
|
|
1637 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s);
|
|
1638 if (radio_get_channel_name(mpctx->demuxer->stream)) {
|
|
1639 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
|
|
1640 MSGTR_OSDChannel, radio_get_channel_name(mpctx->demuxer->stream));
|
|
1641 }
|
|
1642 }
|
|
1643 } break;
|
|
1644 case MP_CMD_RADIO_SET_FREQ : {
|
|
1645 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
|
|
1646 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
|
|
1647 } break;
|
|
1648 case MP_CMD_RADIO_STEP_FREQ :
|
|
1649 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
|
|
1650 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
|
|
1651 }
|
|
1652 break;
|
|
1653 #endif
|
|
1654 #ifdef USE_TV
|
|
1655 case MP_CMD_TV_SET_FREQ : {
|
|
1656 if (mpctx->file_format == DEMUXER_TYPE_TV)
|
|
1657 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.f * 16.0);
|
|
1658 } break;
|
|
1659 case MP_CMD_TV_SET_NORM : {
|
|
1660 if (mpctx->file_format == DEMUXER_TYPE_TV)
|
|
1661 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.s);
|
|
1662 } break;
|
|
1663 case MP_CMD_TV_STEP_CHANNEL : {
|
|
1664 if (mpctx->file_format == DEMUXER_TYPE_TV) {
|
|
1665 int v = cmd->args[0].v.i;
|
|
1666 if(v > 0){
|
|
1667 tv_step_channel((tvi_handle_t *) (mpctx->demuxer->priv), TV_CHANNEL_HIGHER);
|
|
1668 } else {
|
|
1669 tv_step_channel((tvi_handle_t *) (mpctx->demuxer->priv), TV_CHANNEL_LOWER);
|
|
1670 }
|
|
1671 if (tv_channel_list) {
|
|
1672 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
|
|
1673 MSGTR_OSDChannel, tv_channel_current->name);
|
|
1674 //vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
1675 }
|
|
1676 }
|
|
1677 }
|
|
1678 #ifdef HAS_DVBIN_SUPPORT
|
|
1679 if ((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv)
|
|
1680 {
|
|
1681 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
|
|
1682 if(priv->is_on)
|
|
1683 {
|
|
1684 int dir;
|
|
1685 int v = cmd->args[0].v.i;
|
|
1686
|
|
1687 mpctx->last_dvb_step = v;
|
|
1688 if(v > 0)
|
|
1689 dir = DVB_CHANNEL_HIGHER;
|
|
1690 else
|
|
1691 dir = DVB_CHANNEL_LOWER;
|
|
1692
|
|
1693
|
|
1694 if(dvb_step_channel(priv, dir))
|
|
1695 mpctx->eof = mpctx->dvbin_reopen = 1;
|
|
1696 }
|
|
1697 }
|
|
1698 #endif /* HAS_DVBIN_SUPPORT */
|
|
1699 break;
|
|
1700 case MP_CMD_TV_SET_CHANNEL : {
|
|
1701 if (mpctx->file_format == DEMUXER_TYPE_TV) {
|
|
1702 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.s);
|
|
1703 if (tv_channel_list) {
|
|
1704 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
|
|
1705 MSGTR_OSDChannel, tv_channel_current->name);
|
|
1706 //vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
1707 }
|
|
1708 }
|
|
1709 } break;
|
|
1710 #ifdef HAS_DVBIN_SUPPORT
|
|
1711 case MP_CMD_DVB_SET_CHANNEL:
|
|
1712 {
|
|
1713 if ((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv)
|
|
1714 {
|
|
1715 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
|
|
1716 if(priv->is_on)
|
|
1717 {
|
|
1718 if(priv->list->current <= cmd->args[0].v.i)
|
|
1719 mpctx->last_dvb_step = 1;
|
|
1720 else
|
|
1721 mpctx->last_dvb_step = -1;
|
|
1722
|
|
1723 if(dvb_set_channel(priv, cmd->args[1].v.i, cmd->args[0].v.i))
|
|
1724 mpctx->eof = mpctx->dvbin_reopen = 1;
|
|
1725 }
|
|
1726 }
|
|
1727 }
|
|
1728 break;
|
|
1729 #endif /* HAS_DVBIN_SUPPORT */
|
|
1730 case MP_CMD_TV_LAST_CHANNEL : {
|
|
1731 if (mpctx->file_format == DEMUXER_TYPE_TV) {
|
|
1732 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
|
|
1733 if (tv_channel_list) {
|
|
1734 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
|
|
1735 MSGTR_OSDChannel, tv_channel_current->name);
|
|
1736 //vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
1737 }
|
|
1738 }
|
|
1739 } break;
|
|
1740 case MP_CMD_TV_STEP_NORM : {
|
|
1741 if (mpctx->file_format == DEMUXER_TYPE_TV)
|
|
1742 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv));
|
|
1743 } break;
|
|
1744 case MP_CMD_TV_STEP_CHANNEL_LIST : {
|
|
1745 if (mpctx->file_format == DEMUXER_TYPE_TV)
|
|
1746 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
|
|
1747 } break;
|
|
1748 #endif /* USE_TV */
|
|
1749 case MP_CMD_SUB_LOAD:
|
|
1750 {
|
|
1751 if (sh_video) {
|
|
1752 int n = mpctx->set_of_sub_size;
|
|
1753 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0);
|
|
1754 if (n != mpctx->set_of_sub_size) {
|
|
1755 if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0)
|
|
1756 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = mpctx->global_sub_size;
|
|
1757 ++mpctx->global_sub_size;
|
|
1758 }
|
|
1759 }
|
|
1760 } break;
|
|
1761 case MP_CMD_SUB_REMOVE:
|
|
1762 {
|
|
1763 if (sh_video) {
|
|
1764 int v = cmd->args[0].v.i;
|
|
1765 sub_data *subd;
|
|
1766 if (v < 0) {
|
|
1767 for (v = 0; v < mpctx->set_of_sub_size; ++v) {
|
|
1768 subd = mpctx->set_of_subtitles[v];
|
|
1769 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
|
|
1770 filename_recode(subd->filename));
|
|
1771 sub_free(subd);
|
|
1772 mpctx->set_of_subtitles[v] = NULL;
|
|
1773 }
|
|
1774 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
|
|
1775 mpctx->global_sub_size -= mpctx->set_of_sub_size;
|
|
1776 mpctx->set_of_sub_size = 0;
|
|
1777 if (mpctx->set_of_sub_pos >= 0) {
|
|
1778 mpctx->global_sub_pos = -2;
|
|
1779 vo_sub_last = vo_sub = NULL;
|
|
1780 vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
1781 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
|
|
1782 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
|
|
1783 }
|
|
1784 }
|
|
1785 else if (v < mpctx->set_of_sub_size) {
|
|
1786 subd = mpctx->set_of_subtitles[v];
|
|
1787 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
|
|
1788 filename_recode(subd->filename));
|
|
1789 sub_free(subd);
|
|
1790 if (mpctx->set_of_sub_pos == v) {
|
|
1791 mpctx->global_sub_pos = -2;
|
|
1792 vo_sub_last = vo_sub = NULL;
|
|
1793 vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
1794 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
|
|
1795 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
|
|
1796 }
|
|
1797 else if (mpctx->set_of_sub_pos > v) {
|
|
1798 --mpctx->set_of_sub_pos;
|
|
1799 --mpctx->global_sub_pos;
|
|
1800 }
|
|
1801 while (++v < mpctx->set_of_sub_size)
|
|
1802 mpctx->set_of_subtitles[v - 1] = mpctx->set_of_subtitles[v];
|
|
1803 --mpctx->set_of_sub_size;
|
|
1804 --mpctx->global_sub_size;
|
|
1805 if (mpctx->set_of_sub_size <= 0)
|
|
1806 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
|
|
1807 mpctx->set_of_subtitles[mpctx->set_of_sub_size] = NULL;
|
|
1808 }
|
|
1809 }
|
|
1810 } break;
|
|
1811 case MP_CMD_GET_SUB_VISIBILITY:
|
|
1812 {
|
|
1813 if (sh_video) {
|
|
1814 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_SUB_VISIBILITY=%d\n", sub_visibility);
|
|
1815 }
|
|
1816 } break;
|
|
1817 case MP_CMD_SCREENSHOT :
|
|
1818 if(vo_config_count){
|
|
1819 mp_msg(MSGT_CPLAYER,MSGL_INFO,"sending VFCTRL_SCREENSHOT!\n");
|
|
1820 if(CONTROL_OK!=((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SCREENSHOT, &cmd->args[0].v.i))
|
|
1821 mpctx->video_out->control(VOCTRL_SCREENSHOT, NULL);
|
|
1822 }
|
|
1823 break;
|
|
1824 case MP_CMD_VF_CHANGE_RECTANGLE:
|
|
1825 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i);
|
|
1826 break;
|
|
1827
|
|
1828 case MP_CMD_GET_TIME_LENGTH : {
|
|
1829 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2lf\n", demuxer_get_time_length(mpctx->demuxer));
|
|
1830 } break;
|
|
1831
|
|
1832 case MP_CMD_GET_FILENAME : {
|
|
1833 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_FILENAME='%s'\n", get_metadata (META_NAME));
|
|
1834 } break;
|
|
1835
|
|
1836 case MP_CMD_GET_VIDEO_CODEC : {
|
|
1837 char *inf = get_metadata (META_VIDEO_CODEC);
|
|
1838 if (!inf) inf = strdup ("");
|
|
1839 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf);
|
|
1840 free (inf);
|
|
1841 } break;
|
|
1842
|
|
1843 case MP_CMD_GET_VIDEO_BITRATE : {
|
|
1844 char *inf = get_metadata (META_VIDEO_BITRATE);
|
|
1845 if (!inf) inf = strdup ("");
|
|
1846 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf);
|
|
1847 free (inf);
|
|
1848 } break;
|
|
1849
|
|
1850 case MP_CMD_GET_VIDEO_RESOLUTION : {
|
|
1851 char *inf = get_metadata (META_VIDEO_RESOLUTION);
|
|
1852 if (!inf) inf = strdup ("");
|
|
1853 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_RESOLUTION='%s'\n", inf);
|
|
1854 free (inf);
|
|
1855 } break;
|
|
1856
|
|
1857 case MP_CMD_GET_AUDIO_CODEC : {
|
|
1858 char *inf = get_metadata (META_AUDIO_CODEC);
|
|
1859 if (!inf) inf = strdup ("");
|
|
1860 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf);
|
|
1861 free (inf);
|
|
1862 } break;
|
|
1863
|
|
1864 case MP_CMD_GET_AUDIO_BITRATE : {
|
|
1865 char *inf = get_metadata (META_AUDIO_BITRATE);
|
|
1866 if (!inf) inf = strdup ("");
|
|
1867 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf);
|
|
1868 free (inf);
|
|
1869 } break;
|
|
1870
|
|
1871 case MP_CMD_GET_AUDIO_SAMPLES : {
|
|
1872 char *inf = get_metadata (META_AUDIO_SAMPLES);
|
|
1873 if (!inf) inf = strdup ("");
|
|
1874 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf);
|
|
1875 free (inf);
|
|
1876 } break;
|
|
1877
|
|
1878 case MP_CMD_GET_META_TITLE : {
|
|
1879 char *inf = get_metadata (META_INFO_TITLE);
|
|
1880 if (!inf) inf = strdup ("");
|
|
1881 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_TITLE='%s'\n", inf);
|
|
1882 free (inf);
|
|
1883 } break;
|
|
1884
|
|
1885 case MP_CMD_GET_META_ARTIST : {
|
|
1886 char *inf = get_metadata (META_INFO_ARTIST);
|
|
1887 if (!inf) inf = strdup ("");
|
|
1888 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf);
|
|
1889 free (inf);
|
|
1890 } break;
|
|
1891
|
|
1892 case MP_CMD_GET_META_ALBUM : {
|
|
1893 char *inf = get_metadata (META_INFO_ALBUM);
|
|
1894 if (!inf) inf = strdup ("");
|
|
1895 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf);
|
|
1896 free (inf);
|
|
1897 } break;
|
|
1898
|
|
1899 case MP_CMD_GET_META_YEAR : {
|
|
1900 char *inf = get_metadata (META_INFO_YEAR);
|
|
1901 if (!inf) inf = strdup ("");
|
|
1902 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_YEAR='%s'\n", inf);
|
|
1903 free (inf);
|
|
1904 } break;
|
|
1905
|
|
1906 case MP_CMD_GET_META_COMMENT : {
|
|
1907 char *inf = get_metadata (META_INFO_COMMENT);
|
|
1908 if (!inf) inf = strdup ("");
|
|
1909 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf);
|
|
1910 free (inf);
|
|
1911 } break;
|
|
1912
|
|
1913 case MP_CMD_GET_META_TRACK : {
|
|
1914 char *inf = get_metadata (META_INFO_TRACK);
|
|
1915 if (!inf) inf = strdup ("");
|
|
1916 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_TRACK='%s'\n", inf);
|
|
1917 free (inf);
|
|
1918 } break;
|
|
1919
|
|
1920 case MP_CMD_GET_META_GENRE : {
|
|
1921 char *inf = get_metadata (META_INFO_GENRE);
|
|
1922 if (!inf) inf = strdup ("");
|
|
1923 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_GENRE='%s'\n", inf);
|
|
1924 free (inf);
|
|
1925 } break;
|
|
1926
|
|
1927 case MP_CMD_GET_VO_FULLSCREEN : {
|
|
1928 if (mpctx->video_out && vo_config_count)
|
|
1929 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs);
|
|
1930 } break;
|
|
1931
|
|
1932 case MP_CMD_GET_PERCENT_POS : {
|
|
1933 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n", demuxer_get_percent_pos(mpctx->demuxer));
|
|
1934 } break;
|
|
1935 case MP_CMD_GET_TIME_POS : {
|
|
1936 float pos = 0;
|
|
1937 if (sh_video)
|
|
1938 pos = sh_video->pts;
|
|
1939 else
|
|
1940 if (sh_audio && mpctx->audio_out)
|
|
1941 pos = playing_audio_pts(sh_audio, mpctx->d_audio, mpctx->audio_out);
|
|
1942 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
|
|
1943 } break;
|
|
1944 case MP_CMD_RUN : {
|
|
1945 #ifndef __MINGW32__
|
|
1946 if(!fork()) {
|
|
1947 execl("/bin/sh","sh","-c",cmd->args[0].v.s,NULL);
|
|
1948 exit(0);
|
|
1949 }
|
|
1950 #endif
|
|
1951 } break;
|
|
1952 case MP_CMD_KEYDOWN_EVENTS : {
|
|
1953 mplayer_put_key(cmd->args[0].v.i);
|
|
1954 } break;
|
|
1955 case MP_CMD_SEEK_CHAPTER : {
|
|
1956 int seek = cmd->args[0].v.i;
|
|
1957 int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
|
|
1958 int chap;
|
|
1959 float next_pts = 0;
|
|
1960 int num_chapters;
|
|
1961 char *chapter_name;
|
|
1962
|
|
1963 rel_seek_secs = 0;
|
|
1964 abs_seek_pos = 0;
|
|
1965 chap = demuxer_seek_chapter(mpctx->demuxer, seek, abs, &next_pts, &num_chapters, &chapter_name);
|
|
1966 if(chap != -1) {
|
|
1967 if(next_pts > -1.0) {
|
|
1968 abs_seek_pos = 1;
|
|
1969 rel_seek_secs = next_pts;
|
|
1970 }
|
|
1971 if(chapter_name) {
|
|
1972 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter,
|
|
1973 chap+1, chapter_name);
|
|
1974 free(chapter_name);
|
|
1975 }
|
|
1976 } else {
|
|
1977 if (seek > 0)
|
|
1978 rel_seek_secs = 1000000000.;
|
|
1979 else
|
|
1980 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter, 0, MSGTR_Unknown);
|
|
1981 }
|
|
1982 break;
|
|
1983 } break;
|
|
1984 case MP_CMD_SET_MOUSE_POS: {
|
|
1985 int button = -1, pointer_x, pointer_y;
|
|
1986 double dx, dy;
|
|
1987 pointer_x = cmd->args[0].v.i;
|
|
1988 pointer_y = cmd->args[1].v.i;
|
|
1989 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
|
|
1990 #ifdef USE_DVDNAV
|
|
1991 if (mpctx->stream->type == STREAMTYPE_DVDNAV && dx > 0.0 && dy > 0.0) {
|
|
1992 pointer_x = (int) (dx * (double) sh_video->disp_w);
|
|
1993 pointer_y = (int) (dy * (double) sh_video->disp_h);
|
|
1994 mp_dvdnav_update_mouse_pos(mpctx->stream, pointer_x, pointer_y, &button);
|
|
1995 if(button>0) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Selected button number %d", button);
|
|
1996 }
|
|
1997 #endif
|
|
1998 break;
|
|
1999 }
|
|
2000 #ifdef USE_DVDNAV
|
|
2001 case MP_CMD_DVDNAV: {
|
|
2002 int button = -1;
|
|
2003 if (mpctx->stream->type != STREAMTYPE_DVDNAV) break;
|
|
2004
|
|
2005 if (mp_dvdnav_handle_input (mpctx->stream, cmd->args[0].v.i, &button)) {
|
|
2006 uninit_player(INITED_ALL-(INITED_STREAM|INITED_INPUT|(fixed_vo ? INITED_VO : 0)));
|
|
2007 brk_cmd = 2;
|
|
2008 } else if(button>0) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Selected button number %d", button);
|
|
2009 break;
|
|
2010 }
|
|
2011 #endif
|
|
2012 default : {
|
|
2013 #ifdef HAVE_NEW_GUI
|
|
2014 if ( ( use_gui )&&( cmd->id > MP_CMD_GUI_EVENTS ) ) guiGetEvent( guiIEvent,(char *)cmd->id );
|
|
2015 else
|
|
2016 #endif
|
|
2017 mp_msg(MSGT_CPLAYER, MSGL_V, "Received unknown cmd %s\n",cmd->name);
|
|
2018 }
|
|
2019 }
|
|
2020 switch (cmd->pausing) {
|
|
2021 case 1: // "pausing"
|
|
2022 mpctx->osd_function = OSD_PAUSE;
|
|
2023 break;
|
|
2024 case 3: // "pausing_toggle"
|
|
2025 mpctx->was_paused = !mpctx->was_paused;
|
|
2026 // fall through
|
|
2027 case 2: // "pausing_keep"
|
|
2028 if (mpctx->was_paused) mpctx->osd_function = OSD_PAUSE;
|
|
2029 }
|
|
2030 return brk_cmd;
|
|
2031 }
|