• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DATE_TIME = "datetime";
35 inline constexpr std::string_view INNER_META_KEY_DURATION = "duration";
36 inline constexpr std::string_view INNER_META_KEY_FRAMERATE = "frame-rate";
37 inline constexpr std::string_view INNER_META_KEY_GENRE = "genre";
38 inline constexpr std::string_view INNER_META_KEY_VIDEO_HEIGHT = "height";
39 inline constexpr std::string_view INNER_META_KEY_IMAGE = "image";
40 inline constexpr std::string_view INNER_META_KEY_LANGUAGE = "language";
41 inline constexpr std::string_view INNER_META_KEY_VIDEO_ORIENTATION = "image-orientation";
42 inline constexpr std::string_view INNER_META_KEY_MIME_TYPE = "mime";
43 inline constexpr std::string_view INNER_META_KEY_SAMPLE_RATE = "samplerate";
44 inline constexpr std::string_view INNER_META_KEY_TITLE = "title";
45 inline constexpr std::string_view INNER_META_KEY_TRACK_INDEX = "track-index";
46 inline constexpr std::string_view INNER_META_KEY_TRACK_TYPE = "track-type";
47 inline constexpr std::string_view INNER_META_KEY_VIDEO_WIDTH = "width";
48 
49 // video codec mime
50 inline constexpr std::string_view VIDEO_MIMETYPE_AVC = "video/avc";
51 inline constexpr std::string_view VIDEO_MIMETYPE_MPEG4 = "video/mp4v-es";
52 
53 // audio codec mime
54 inline constexpr std::string_view AUDIO_MIMETYPE_AAC = "audio/mp4a-latm";
55 inline constexpr std::string_view AUDIO_MIMETYPE_MPEG = "audio/mpeg";
56 
57 // container mime
58 inline constexpr std::string_view FILE_MIMETYPE_VIDEO_MP4 = "video/mp4";
59 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_MP4 = "audio/mp4";
60 inline constexpr std::string_view FILE_MIMETYPE_VIDEO_MKV = "video/x-matroska";
61 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_MKV = "audio/x-matroska";
62 inline constexpr std::string_view FILE_MIMETYPE_VIDEO_MPEGTS = "video/mp2ts";
63 inline constexpr std::string_view FILE_MIMETYPE_VIDEO_WEBM = "video/webm";
64 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_WEBM = "audio/webm";
65 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_AAC = "audio/aac-adts";
66 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_OGG = "audio/ogg";
67 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_FLAC = "audio/flac";
68 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_WAV = "audio/wav";
69 inline constexpr std::string_view FILE_MIMETYPE_AUDIO_MP3 = "audio/mpeg";
70 
71 // parse meta from GstTagList, GstCaps
72 class GstMetaParser {
73 public:
74     static void ParseTagList(const GstTagList &tagList, Format &metadata);
75     static void ParseStreamCaps(const GstCaps &caps, Format &metadata);
76     static void ParseFileMimeType(const GstCaps &caps, Format &metadata);
77 
78 private:
79     GstMetaParser() = default;
80     ~GstMetaParser() = default;
81 };
82 } // namespace Media
83 } // namespace OHOS
84 #endif // GST_META_PARSER_H