From 0a54f5e741e395ffb14a1305529c70e817679596 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Sep 2012 05:29:38 +0200 Subject: commands: remove legacy slave mode get commands These have been replaced by properties. Also remove some other slave- mode specific get commands that can be replaced by property uses. The get_metadata() function didn't actually contain anything useful, and just replicated code from other parts of mplayer. --- command.c | 127 ---------------------------------------------------------- input/input.c | 19 --------- input/input.h | 19 --------- metadata.h | 55 ------------------------- mplayer.c | 125 --------------------------------------------------------- screenshot.c | 4 +- 6 files changed, 1 insertion(+), 348 deletions(-) delete mode 100644 metadata.h diff --git a/command.c b/command.c index 1cffedfd13..e4bc5e73ff 100644 --- a/command.c +++ b/command.c @@ -39,7 +39,6 @@ #include "m_option.h" #include "m_property.h" #include "m_config.h" -#include "metadata.h" #include "libmpcodecs/vf.h" #include "libmpcodecs/vd.h" #include "mp_osd.h" @@ -2676,136 +2675,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) } break; - case MP_CMD_GET_SUB_VISIBILITY: - if (sh_video) { - mp_msg(MSGT_GLOBAL, MSGL_INFO, - "ANS_SUB_VISIBILITY=%d\n", opts->sub_visibility); - } - break; - case MP_CMD_SCREENSHOT: screenshot_request(mpctx, cmd->args[0].v.i, cmd->args[1].v.i); break; - case MP_CMD_GET_TIME_LENGTH: - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2f\n", - get_time_length(mpctx)); - break; - - case MP_CMD_GET_FILENAME: { - char *inf = get_metadata(mpctx, META_NAME); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_FILENAME='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_VIDEO_CODEC: { - char *inf = get_metadata(mpctx, META_VIDEO_CODEC); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_VIDEO_BITRATE: { - char *inf = get_metadata(mpctx, META_VIDEO_BITRATE); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_VIDEO_RESOLUTION: { - char *inf = get_metadata(mpctx, META_VIDEO_RESOLUTION); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_RESOLUTION='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_AUDIO_CODEC: { - char *inf = get_metadata(mpctx, META_AUDIO_CODEC); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_AUDIO_BITRATE: { - char *inf = get_metadata(mpctx, META_AUDIO_BITRATE); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_AUDIO_SAMPLES: { - char *inf = get_metadata(mpctx, META_AUDIO_SAMPLES); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_TITLE: { - char *inf = get_metadata(mpctx, META_INFO_TITLE); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TITLE='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_ARTIST: { - char *inf = get_metadata(mpctx, META_INFO_ARTIST); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_ALBUM: { - char *inf = get_metadata(mpctx, META_INFO_ALBUM); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_YEAR: { - char *inf = get_metadata(mpctx, META_INFO_YEAR); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_YEAR='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_COMMENT: { - char *inf = get_metadata(mpctx, META_INFO_COMMENT); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_TRACK: { - char *inf = get_metadata(mpctx, META_INFO_TRACK); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TRACK='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_META_GENRE: { - char *inf = get_metadata(mpctx, META_INFO_GENRE); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_GENRE='%s'\n", inf); - talloc_free(inf); - break; - } - - case MP_CMD_GET_VO_FULLSCREEN: - if (mpctx->video_out && mpctx->video_out->config_ok) - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs); - break; - - case MP_CMD_GET_PERCENT_POS: - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n", - get_percent_pos(mpctx)); - break; - - case MP_CMD_GET_TIME_POS: { - float pos = get_current_time(mpctx); - mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos); - break; - } - case MP_CMD_RUN: #ifndef __MINGW32__ if (!fork()) { diff --git a/input/input.c b/input/input.c index 7f9021e35b..38e89d4577 100644 --- a/input/input.c +++ b/input/input.c @@ -138,23 +138,6 @@ static const mp_cmd_t mp_cmds[] = { #ifdef CONFIG_ASS { MP_CMD_ASS_USE_MARGINS, "ass_use_margins", { OARG_INT(-1) } }, #endif - { MP_CMD_GET_PERCENT_POS, "get_percent_pos", }, - { MP_CMD_GET_TIME_POS, "get_time_pos", }, - { MP_CMD_GET_TIME_LENGTH, "get_time_length", }, - { MP_CMD_GET_FILENAME, "get_file_name", }, - { MP_CMD_GET_VIDEO_CODEC, "get_video_codec", }, - { MP_CMD_GET_VIDEO_BITRATE, "get_video_bitrate", }, - { MP_CMD_GET_VIDEO_RESOLUTION, "get_video_resolution", }, - { MP_CMD_GET_AUDIO_CODEC, "get_audio_codec", }, - { MP_CMD_GET_AUDIO_BITRATE, "get_audio_bitrate", }, - { MP_CMD_GET_AUDIO_SAMPLES, "get_audio_samples", }, - { MP_CMD_GET_META_TITLE, "get_meta_title", }, - { MP_CMD_GET_META_ARTIST, "get_meta_artist", }, - { MP_CMD_GET_META_ALBUM, "get_meta_album", }, - { MP_CMD_GET_META_YEAR, "get_meta_year", }, - { MP_CMD_GET_META_COMMENT, "get_meta_comment", }, - { MP_CMD_GET_META_TRACK, "get_meta_track", }, - { MP_CMD_GET_META_GENRE, "get_meta_genre", }, { MP_CMD_SWITCH_AUDIO, "switch_audio", { OARG_INT(-1) } }, { MP_CMD_SWITCH_ANGLE, "switch_angle", { OARG_INT(-1) } }, { MP_CMD_SWITCH_TITLE, "switch_title", { OARG_INT(-1) } }, @@ -190,8 +173,6 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_PLAYLIST_CLEAR, "playlist_clear", }, { MP_CMD_RUN, "run", { ARG_STRING } }, - { MP_CMD_GET_VO_FULLSCREEN, "get_vo_fullscreen", }, - { MP_CMD_GET_SUB_VISIBILITY, "get_sub_visibility", }, { MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } }, { MP_CMD_SET_PROPERTY, "set_property", { ARG_STRING, ARG_STRING } }, { MP_CMD_SET_PROPERTY_OSD, "set_property_osd", { ARG_STRING, ARG_STRING } }, diff --git a/input/input.h b/input/input.h index ddd9016203..8672728598 100644 --- a/input/input.h +++ b/input/input.h @@ -53,8 +53,6 @@ enum mp_command_type { MP_CMD_GAMMA, MP_CMD_SUB_VISIBILITY, MP_CMD_VOBSUB_LANG, // deprecated: combined with SUB_SELECT - MP_CMD_GET_TIME_LENGTH, - MP_CMD_GET_PERCENT_POS, MP_CMD_SUB_STEP, MP_CMD_TV_SET_CHANNEL, MP_CMD_EDL_MARK, @@ -67,8 +65,6 @@ enum mp_command_type { MP_CMD_TV_SET_CONTRAST, MP_CMD_TV_SET_HUE, MP_CMD_TV_SET_SATURATION, - MP_CMD_GET_VO_FULLSCREEN, - MP_CMD_GET_SUB_VISIBILITY, MP_CMD_SUB_FORCED_ONLY, MP_CMD_VO_ONTOP, MP_CMD_SUB_SELECT, @@ -81,7 +77,6 @@ enum mp_command_type { MP_CMD_SPEED_SET, MP_CMD_RUN, MP_CMD_SWITCH_AUDIO, - MP_CMD_GET_TIME_POS, MP_CMD_SUB_LOAD, MP_CMD_KEYDOWN_EVENTS, MP_CMD_VO_BORDER, @@ -91,20 +86,6 @@ enum mp_command_type { MP_CMD_OSD_SHOW_PROPERTY_TEXT, MP_CMD_OSD_SHOW_PROGRESSION, MP_CMD_SEEK_CHAPTER, - MP_CMD_GET_FILENAME, - MP_CMD_GET_VIDEO_CODEC, - MP_CMD_GET_VIDEO_BITRATE, - MP_CMD_GET_VIDEO_RESOLUTION, - MP_CMD_GET_AUDIO_CODEC, - MP_CMD_GET_AUDIO_BITRATE, - MP_CMD_GET_AUDIO_SAMPLES, - MP_CMD_GET_META_TITLE, - MP_CMD_GET_META_ARTIST, - MP_CMD_GET_META_ALBUM, - MP_CMD_GET_META_YEAR, - MP_CMD_GET_META_COMMENT, - MP_CMD_GET_META_TRACK, - MP_CMD_GET_META_GENRE, MP_CMD_RADIO_STEP_CHANNEL, MP_CMD_RADIO_SET_CHANNEL, MP_CMD_RADIO_SET_FREQ, diff --git a/metadata.h b/metadata.h deleted file mode 100644 index 06c3822d81..0000000000 --- a/metadata.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * set of helper routines for stream metadata and properties retrieval - * - * Copyright (C) 2006 Benjamin Zores - * - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_METADATA_H -#define MPLAYER_METADATA_H - -typedef enum metadata_s metadata_t; -enum metadata_s { - /* common info */ - META_NAME = 0, - - /* video stream properties */ - META_VIDEO_CODEC, - META_VIDEO_BITRATE, - META_VIDEO_RESOLUTION, - - /* audio stream properties */ - META_AUDIO_CODEC, - META_AUDIO_BITRATE, - META_AUDIO_SAMPLES, - - /* ID3 tags and other stream infos */ - META_INFO_TITLE, - META_INFO_ARTIST, - META_INFO_ALBUM, - META_INFO_YEAR, - META_INFO_COMMENT, - META_INFO_TRACK, - META_INFO_GENRE -}; - -struct MPContext; - -char *get_metadata(struct MPContext *mpctx, metadata_t type); - -#endif /* MPLAYER_METADATA_H */ diff --git a/mplayer.c b/mplayer.c index 7fa37641fc..d0abca3112 100644 --- a/mplayer.c +++ b/mplayer.c @@ -247,8 +247,6 @@ int use_filedir_conf; #include "mpcommon.h" #include "command.h" -#include "metadata.h" - static void reset_subtitles(struct MPContext *mpctx); static void reinit_subs(struct MPContext *mpctx); @@ -260,129 +258,6 @@ static float get_relative_time(struct MPContext *mpctx) return delta * 0.000001; } -static int is_valid_metadata_type(struct MPContext *mpctx, metadata_t type) -{ - switch (type) { - /* check for valid video stream */ - case META_VIDEO_CODEC: - case META_VIDEO_BITRATE: - case META_VIDEO_RESOLUTION: - if (!mpctx->sh_video) - return 0; - break; - - /* check for valid audio stream */ - case META_AUDIO_CODEC: - case META_AUDIO_BITRATE: - case META_AUDIO_SAMPLES: - if (!mpctx->sh_audio) - return 0; - break; - - /* check for valid demuxer */ - case META_INFO_TITLE: - case META_INFO_ARTIST: - case META_INFO_ALBUM: - case META_INFO_YEAR: - case META_INFO_COMMENT: - case META_INFO_TRACK: - case META_INFO_GENRE: - if (!mpctx->master_demuxer) - return 0; - break; - - default: - break; - } - - return 1; -} - -static char *get_demuxer_info(struct MPContext *mpctx, char *tag) -{ - char **info = mpctx->master_demuxer->info; - int n; - - if (!info || !tag) - return talloc_strdup(NULL, ""); - - for (n = 0; info[2 * n] != NULL; n++) - if (!strcasecmp(info[2 * n], tag)) - break; - - return talloc_strdup(NULL, info[2 * n + 1] ? info[2 * n + 1] : ""); -} - -char *get_metadata(struct MPContext *mpctx, metadata_t type) -{ - sh_audio_t * const sh_audio = mpctx->sh_audio; - sh_video_t * const sh_video = mpctx->sh_video; - - if (!is_valid_metadata_type(mpctx, type)) - return NULL; - - switch (type) { - case META_NAME: - return talloc_strdup(NULL, mp_basename(mpctx->filename)); - case META_VIDEO_CODEC: - if (sh_video->format == 0x10000001) - return talloc_strdup(NULL, "mpeg1"); - else if (sh_video->format == 0x10000002) - return talloc_strdup(NULL, "mpeg2"); - else if (sh_video->format == 0x10000004) - return talloc_strdup(NULL, "mpeg4"); - else if (sh_video->format == 0x10000005) - return talloc_strdup(NULL, "h264"); - else if (sh_video->format >= 0x20202020) - return talloc_asprintf(NULL, "%.4s", (char *) &sh_video->format); - else - return talloc_asprintf(NULL, "0x%08X", sh_video->format); - case META_VIDEO_BITRATE: - return talloc_asprintf(NULL, "%d kbps", - (int) (sh_video->i_bps * 8 / 1024)); - case META_VIDEO_RESOLUTION: - return talloc_asprintf(NULL, "%d x %d", sh_video->disp_w, - sh_video->disp_h); - case META_AUDIO_CODEC: - if (sh_audio->codec && sh_audio->codec->name) - return talloc_strdup(NULL, sh_audio->codec->name); - return talloc_strdup(NULL, ""); - case META_AUDIO_BITRATE: - return talloc_asprintf(NULL, "%d kbps", - (int) (sh_audio->i_bps * 8 / 1000)); - case META_AUDIO_SAMPLES: - return talloc_asprintf(NULL, "%d Hz, %d ch.", sh_audio->samplerate, - sh_audio->channels); - - /* check for valid demuxer */ - case META_INFO_TITLE: - return get_demuxer_info(mpctx, "Title"); - - case META_INFO_ARTIST: - return get_demuxer_info(mpctx, "Artist"); - - case META_INFO_ALBUM: - return get_demuxer_info(mpctx, "Album"); - - case META_INFO_YEAR: - return get_demuxer_info(mpctx, "Year"); - - case META_INFO_COMMENT: - return get_demuxer_info(mpctx, "Comment"); - - case META_INFO_TRACK: - return get_demuxer_info(mpctx, "Track"); - - case META_INFO_GENRE: - return get_demuxer_info(mpctx, "Genre"); - - default: - break; - } - - return talloc_strdup(NULL, ""); -} - static void print_stream(struct MPContext *mpctx, struct track *t, int id) { struct sh_stream *s = t->stream; diff --git a/screenshot.c b/screenshot.c index 79356ed9a2..a6313d01da 100644 --- a/screenshot.c +++ b/screenshot.c @@ -30,7 +30,6 @@ #include "m_property.h" #include "bstr.h" #include "mp_msg.h" -#include "metadata.h" #include "path.h" #include "libmpcodecs/mp_image.h" #include "libmpcodecs/dec_video.h" @@ -154,14 +153,13 @@ static char *create_fname(struct MPContext *mpctx, char *template, } case 'f': case 'F': { - char *video_file = get_metadata(mpctx, META_NAME); + char *video_file = mp_basename(mpctx->filename); if (video_file) { char *name = video_file; if (fmt == 'F') name = stripext(res, video_file); append_filename(&res, name); } - talloc_free(video_file); break; } case 'p': -- cgit v1.2.3