comparison command.c @ 23394:d4e8613ddc95

Make all the info available via the metadata API available via properties.
author albeu
date Tue, 29 May 2007 22:14:41 +0000
parents a5e55cb59bbc
children 8412921b363c
comparison
equal deleted inserted replaced
23393:a5e55cb59bbc 23394:d4e8613ddc95
6 #include "config.h" 6 #include "config.h"
7 #include "input/input.h" 7 #include "input/input.h"
8 #include "stream/stream.h" 8 #include "stream/stream.h"
9 #include "libmpdemux/demuxer.h" 9 #include "libmpdemux/demuxer.h"
10 #include "libmpdemux/stheader.h" 10 #include "libmpdemux/stheader.h"
11 #include "codec-cfg.h"
11 #include "mplayer.h" 12 #include "mplayer.h"
12 #include "libvo/sub.h" 13 #include "libvo/sub.h"
13 #include "m_option.h" 14 #include "m_option.h"
14 #include "m_property.h" 15 #include "m_property.h"
15 #include "help_mp.h" 16 #include "help_mp.h"
304 break; 305 break;
305 } 306 }
306 return m_property_double_ro(prop, action, arg, len); 307 return m_property_double_ro(prop, action, arg, len);
307 } 308 }
308 309
310 /// Demuxer meta data
311 static int mp_property_metadata(m_option_t * prop, int action, void *arg,
312 MPContext * mpctx) {
313 m_property_action_t* ka;
314 char* meta;
315 static m_option_t key_type =
316 { "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL };
317 if (!mpctx->demuxer)
318 return M_PROPERTY_UNAVAILABLE;
319
320 switch(action) {
321 case M_PROPERTY_GET:
322 if(!arg) return M_PROPERTY_ERROR;
323 *(char***)arg = mpctx->demuxer->info;
324 return M_PROPERTY_OK;
325 case M_PROPERTY_KEY_ACTION:
326 if(!arg) return M_PROPERTY_ERROR;
327 ka = arg;
328 if(!(meta = demux_info_get(mpctx->demuxer,ka->key)))
329 return M_PROPERTY_UNKNOWN;
330 switch(ka->action) {
331 case M_PROPERTY_GET:
332 if(!ka->arg) return M_PROPERTY_ERROR;
333 *(char**)ka->arg = meta;
334 return M_PROPERTY_OK;
335 case M_PROPERTY_GET_TYPE:
336 if(!ka->arg) return M_PROPERTY_ERROR;
337 *(m_option_t**)ka->arg = &key_type;
338 return M_PROPERTY_OK;
339 }
340 }
341 return M_PROPERTY_NOT_IMPLEMENTED;
342 }
343
344
309 ///@} 345 ///@}
310 346
311 /// \defgroup AudioProperties Audio properties 347 /// \defgroup AudioProperties Audio properties
312 /// \ingroup Properties 348 /// \ingroup Properties
313 ///@{ 349 ///@{
437 if (!mpctx->sh_audio) 473 if (!mpctx->sh_audio)
438 return M_PROPERTY_UNAVAILABLE; 474 return M_PROPERTY_UNAVAILABLE;
439 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format); 475 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format);
440 } 476 }
441 477
478 /// Audio codec name (RO)
479 static int mp_property_audio_codec(m_option_t * prop, int action,
480 void *arg, MPContext * mpctx)
481 {
482 if (!mpctx->sh_audio || !mpctx->sh_audio->codec)
483 return M_PROPERTY_UNAVAILABLE;
484 return m_property_string_ro(prop, action, arg, mpctx->sh_audio->codec->name);
485 }
486
442 /// Audio bitrate (RO) 487 /// Audio bitrate (RO)
443 static int mp_property_audio_bitrate(m_option_t * prop, int action, 488 static int mp_property_audio_bitrate(m_option_t * prop, int action,
444 void *arg, MPContext * mpctx) 489 void *arg, MPContext * mpctx)
445 { 490 {
446 if (!mpctx->sh_audio) 491 if (!mpctx->sh_audio)
447 return M_PROPERTY_UNAVAILABLE; 492 return M_PROPERTY_UNAVAILABLE;
448 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->i_bps); 493 return m_property_bitrate(prop, action, arg, mpctx->sh_audio->i_bps);
449 } 494 }
450 495
451 /// Samplerate (RO) 496 /// Samplerate (RO)
452 static int mp_property_samplerate(m_option_t * prop, int action, void *arg, 497 static int mp_property_samplerate(m_option_t * prop, int action, void *arg,
453 MPContext * mpctx) 498 MPContext * mpctx)
878 923
879 /// Video codec tag (RO) 924 /// Video codec tag (RO)
880 static int mp_property_video_format(m_option_t * prop, int action, 925 static int mp_property_video_format(m_option_t * prop, int action,
881 void *arg, MPContext * mpctx) 926 void *arg, MPContext * mpctx)
882 { 927 {
928 char* meta;
883 if (!mpctx->sh_video) 929 if (!mpctx->sh_video)
884 return M_PROPERTY_UNAVAILABLE; 930 return M_PROPERTY_UNAVAILABLE;
931 switch(action) {
932 case M_PROPERTY_PRINT:
933 if (!arg)
934 return M_PROPERTY_ERROR;
935 switch(mpctx->sh_video->format) {
936 case 0x10000001:
937 meta = strdup ("mpeg1"); break;
938 case 0x10000002:
939 meta = strdup ("mpeg2"); break;
940 case 0x10000004:
941 meta = strdup ("mpeg4"); break;
942 case 0x10000005:
943 meta = strdup ("h264"); break;
944 default:
945 if(mpctx->sh_video->format >= 0x20202020) {
946 meta = malloc(5);
947 sprintf (meta, "%.4s", (char *) &mpctx->sh_video->format);
948 } else {
949 meta = malloc(20);
950 sprintf (meta, "0x%08X", mpctx->sh_video->format);
951 }
952 }
953 *(char**)arg = meta;
954 return M_PROPERTY_OK;
955 }
885 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format); 956 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format);
886 } 957 }
958
959 /// Video codec name (RO)
960 static int mp_property_video_codec(m_option_t * prop, int action,
961 void *arg, MPContext * mpctx)
962 {
963 if (!mpctx->sh_video || !mpctx->sh_video->codec)
964 return M_PROPERTY_UNAVAILABLE;
965 return m_property_string_ro(prop, action, arg, mpctx->sh_video->codec->name);
966 }
967
887 968
888 /// Video bitrate (RO) 969 /// Video bitrate (RO)
889 static int mp_property_video_bitrate(m_option_t * prop, int action, 970 static int mp_property_video_bitrate(m_option_t * prop, int action,
890 void *arg, MPContext * mpctx) 971 void *arg, MPContext * mpctx)
891 { 972 {
892 if (!mpctx->sh_video) 973 if (!mpctx->sh_video)
893 return M_PROPERTY_UNAVAILABLE; 974 return M_PROPERTY_UNAVAILABLE;
894 return m_property_int_ro(prop, action, arg, mpctx->sh_video->i_bps); 975 return m_property_bitrate(prop, action, arg, mpctx->sh_video->i_bps);
895 } 976 }
896 977
897 /// Video display width (RO) 978 /// Video display width (RO)
898 static int mp_property_width(m_option_t * prop, int action, void *arg, 979 static int mp_property_width(m_option_t * prop, int action, void *arg,
899 MPContext * mpctx) 980 MPContext * mpctx)
1316 M_OPT_MIN, 0, 0, NULL }, 1397 M_OPT_MIN, 0, 0, NULL },
1317 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION, 1398 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION,
1318 M_OPT_MIN, 0, 0, NULL }, 1399 M_OPT_MIN, 0, 0, NULL },
1319 { "length", mp_property_length, CONF_TYPE_DOUBLE, 1400 { "length", mp_property_length, CONF_TYPE_DOUBLE,
1320 0, 0, 0, NULL }, 1401 0, 0, 0, NULL },
1402 { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST,
1403 0, 0, 0, NULL },
1321 1404
1322 // Audio 1405 // Audio
1323 { "volume", mp_property_volume, CONF_TYPE_FLOAT, 1406 { "volume", mp_property_volume, CONF_TYPE_FLOAT,
1324 M_OPT_RANGE, 0, 100, NULL }, 1407 M_OPT_RANGE, 0, 100, NULL },
1325 { "mute", mp_property_mute, CONF_TYPE_FLAG, 1408 { "mute", mp_property_mute, CONF_TYPE_FLAG,
1326 M_OPT_RANGE, 0, 1, NULL }, 1409 M_OPT_RANGE, 0, 1, NULL },
1327 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT, 1410 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT,
1328 M_OPT_RANGE, -100, 100, NULL }, 1411 M_OPT_RANGE, -100, 100, NULL },
1329 { "audio_format", mp_property_audio_format, CONF_TYPE_INT, 1412 { "audio_format", mp_property_audio_format, CONF_TYPE_INT,
1413 0, 0, 0, NULL },
1414 { "audio_codec", mp_property_audio_codec, CONF_TYPE_STRING,
1330 0, 0, 0, NULL }, 1415 0, 0, 0, NULL },
1331 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT, 1416 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT,
1332 0, 0, 0, NULL }, 1417 0, 0, 0, NULL },
1333 { "samplerate", mp_property_samplerate, CONF_TYPE_INT, 1418 { "samplerate", mp_property_samplerate, CONF_TYPE_INT,
1334 0, 0, 0, NULL }, 1419 0, 0, 0, NULL },
1363 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT, 1448 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT,
1364 M_OPT_RANGE, 0, 1, NULL }, 1449 M_OPT_RANGE, 0, 1, NULL },
1365 { "vsync", mp_property_vsync, CONF_TYPE_FLAG, 1450 { "vsync", mp_property_vsync, CONF_TYPE_FLAG,
1366 M_OPT_RANGE, 0, 1, NULL }, 1451 M_OPT_RANGE, 0, 1, NULL },
1367 { "video_format", mp_property_video_format, CONF_TYPE_INT, 1452 { "video_format", mp_property_video_format, CONF_TYPE_INT,
1453 0, 0, 0, NULL },
1454 { "video_codec", mp_property_video_codec, CONF_TYPE_STRING,
1368 0, 0, 0, NULL }, 1455 0, 0, 0, NULL },
1369 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT, 1456 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT,
1370 0, 0, 0, NULL }, 1457 0, 0, 0, NULL },
1371 { "width", mp_property_width, CONF_TYPE_INT, 1458 { "width", mp_property_width, CONF_TYPE_INT,
1372 0, 0, 0, NULL }, 1459 0, 0, 0, NULL },