1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GST_META_PARSER_H 17 #define GST_META_PARSER_H 18 19 #include <gst/gst.h> 20 #include <unordered_map> 21 #include <string> 22 #include "format.h" 23 24 namespace OHOS { 25 namespace Media { 26 // meta key, sorted by alphabetical order. 27 inline constexpr std::string_view INNER_META_KEY_ALBUM = "album"; 28 inline constexpr std::string_view INNER_META_KEY_ALBUM_ARTIST = "albumartist"; 29 inline constexpr std::string_view INNER_META_KEY_ARTIST = "artist"; 30 inline constexpr std::string_view INNER_META_KEY_AUTHOR = "author"; 31 inline constexpr std::string_view INNER_META_KEY_BITRATE = "bitrate"; 32 inline constexpr std::string_view INNER_META_KEY_CHANNEL_COUNT = "channel-count"; 33 inline constexpr std::string_view INNER_META_KEY_COMPOSER = "composer"; 34 inline constexpr std::string_view INNER_META_KEY_DURATION = "duration"; 35 inline constexpr std::string_view INNER_META_KEY_FRAMERATE = "frame-rate"; 36 inline constexpr std::string_view INNER_META_KEY_GENRE = "genre"; 37 inline constexpr std::string_view INNER_META_KEY_VIDEO_HEIGHT = "height"; 38 inline constexpr std::string_view INNER_META_KEY_IMAGE = "image"; 39 inline constexpr std::string_view INNER_META_KEY_MIME_TYPE = "mime"; 40 inline constexpr std::string_view INNER_META_KEY_SAMPLE_RATE = "samplerate"; 41 inline constexpr std::string_view INNER_META_KEY_TITLE = "title"; 42 inline constexpr std::string_view INNER_META_KEY_TRACK_TYPE = "track-type"; 43 inline constexpr std::string_view INNER_META_KEY_VIDEO_WIDTH = "width"; 44 45 // video codec mime 46 inline constexpr std::string_view VIDEO_MIMETYPE_AVC = "video/avc"; 47 inline constexpr std::string_view VIDEO_MIMETYPE_MPEG4 = "video/mp4v-es"; 48 49 // audio codec mime 50 inline constexpr std::string_view AUDIO_MIMETYPE_AAC = "audio/mp4a-latm"; 51 inline constexpr std::string_view AUDIO_MIMETYPE_MPEG = "audio/mpeg"; 52 53 // container mime 54 inline constexpr std::string_view FILE_MIMETYPE_VIDEO_MP4 = "video/mp4"; 55 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_MP4 = "audio/mp4"; 56 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_AAC = "audio/aac-adts"; 57 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_OGG = "audio/ogg"; 58 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_FLAC = "audio/flac"; 59 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_WAV = "audio/wav"; 60 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_MP3 = "audio/mpeg"; 61 62 // parse meta from GstTagList, GstCaps 63 class GstMetaParser { 64 public: 65 static void ParseTagList(const GstTagList &tagList, Format &metadata); 66 static void ParseStreamCaps(const GstCaps &caps, Format &metadata); 67 static void ParseFileMimeType(const GstCaps &caps, Format &metadata); 68 69 private: 70 GstMetaParser() = default; 71 ~GstMetaParser() = default; 72 }; 73 } // namespace Media 74 } // namespace OHOS 75 #endif // GST_META_PARSER_H