1 /* 2 * Copyright (c) 2021-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 HISTREAMER_PLUGIN_COMMON_TAGS_H 17 #define HISTREAMER_PLUGIN_COMMON_TAGS_H 18 19 #include <map> // NOLINT 20 #include <string> 21 #include <vector> // NOLINT 22 #include "plugin/common/any.h" // NOLINT 23 24 namespace OHOS { 25 namespace Media { 26 namespace Plugin { 27 enum struct TagSection : uint8_t { 28 REGULAR = 1, 29 MEDIA = 2, 30 AUDIO_UNIVERSAL = 3, 31 AUDIO_SPECIFIC = 4, 32 VIDEO_UNIVERSAL = 5, 33 VIDEO_SPECIFIC = 6, 34 USER_SPECIFIC = 7, 35 MAX_SECTION = 64 36 }; 37 38 enum struct AudioFormat : uint8_t { 39 MPEG = 1, 40 AAC, 41 }; 42 43 enum struct VideoFormat : uint8_t { 44 UNKNOWN = 0, 45 H264 = 1, 46 MPEG4 = 2, 47 }; 48 49 enum class MediaType : uint32_t { 50 UNKNOWN = 0, ///< Usually treated as DATA 51 AUDIO, 52 VIDEO, 53 SUBTITLE, 54 ATTACHMENT, ///< Opaque data information usually sparse 55 DATA ///< Opaque data information usually continuous 56 }; 57 58 #define MAKE_AUDIO_SPECIFIC_START(format) (SECTION_AUDIO_SPECIFIC_START | (static_cast<uint8_t>(format) << 8U)) 59 60 #define MAKE_VIDEO_SPECIFIC_START(format) (SECTION_VIDEO_SPECIFIC_START | (static_cast<uint8_t>(format) << 8U)) 61 62 /** 63 * @brief Tag is a key-value pair used to settings or transfer information. 64 * 65 * The "key" member:An uint32_t index, defined as an enumerated type. 66 * Tag Index consisting of the following fragments: 67 * - reserved field 68 * - vendor extensions 69 * - section (regular, audio, video ...) 70 * - addition index 71 * 72 * layout: 73 * +----------+---------+--------+----------------+ 74 * | reserved | section | vendor | addition index | 75 * +----------+---------+--------+----------------+ 76 * bit: 31 ... 22 21 ... 16 15 14 ............ 0 77 * 78 * The "value" member: Different tag have different value types, 79 * which is defined in the plug-in interface. 80 * 81 * @since 1.0 82 * @version 1.0 83 */ 84 enum struct Tag : uint32_t { 85 INVALID = 0, 86 SECTION_REGULAR_START = static_cast<uint8_t>(TagSection::REGULAR) << 16U, // regular tag 87 SECTION_MEDIA_START = static_cast<uint8_t>(TagSection::MEDIA) << 16U, // media tag 88 SECTION_AUDIO_UNIVERSAL_START = static_cast<uint8_t>(TagSection::AUDIO_UNIVERSAL) << 16U, // audio universal tag 89 SECTION_AUDIO_SPECIFIC_START = static_cast<uint8_t>(TagSection::AUDIO_SPECIFIC) << 16U, // audio specific tag 90 SECTION_VIDEO_UNIVERSAL_START = static_cast<uint8_t>(TagSection::VIDEO_UNIVERSAL) << 16U, // video universal tag 91 SECTION_VIDEO_SPECIFIC_START = static_cast<uint8_t>(TagSection::VIDEO_SPECIFIC) << 16U, // video specific tag 92 SECTION_USER_SPECIFIC_START = static_cast<uint8_t>(TagSection::USER_SPECIFIC) << 16U, // user specific tag 93 94 /* -------------------- regular tag -------------------- */ 95 MIME = SECTION_REGULAR_START + 1, ///< std::string 96 TRACK_ID, ///< uint32_t, track id 97 REQUIRED_OUT_BUFFER_CNT, ///< uint32_t, required buffer count of plugin; read only tag 98 REQUIRED_OUT_BUFFER_SIZE, ///< uint32_t, required buffer size of plugin; read only tag 99 BUFFER_ALLOCATOR, ///< Allocator, allocator to alloc buffers 100 BUFFERING_SIZE, ///< uint32_t, download buffer size 101 WATERLINE_HIGH, ///< uint32_t, high waterline 102 WATERLINE_LOW, ///< uint32_t, low waterline 103 SRC_INPUT_TYPE, ///< @see SrcInputType 104 BITS_PER_CODED_SAMPLE, ///< uint32_t, bits per coded sample 105 APP_TOKEN_ID, ///< uint32_t, app token id 106 APP_FULL_TOKEN_ID, ///< uint64_t, app full token id 107 APP_UID, ///< int32_t, app uid 108 APP_PID, ///< int32_t, app pid 109 AUDIO_RENDER_INFO, ///< AudioRenderInfo, audio render info 110 AUDIO_INTERRUPT_MODE, ///< AudioInterruptMode, audio interrupt mode 111 VIDEO_SCALE_TYPE, ///< VideoScaleType, video scale type 112 INPUT_MEMORY_TYPE, ///< @see MemoryType 113 OUTPUT_MEMORY_TYPE, ///< @see MemoryType 114 115 /* -------------------- media tag -------------------- */ 116 MEDIA_TITLE = SECTION_MEDIA_START + 1, ///< string 117 MEDIA_ARTIST, ///< std::string, artist 118 MEDIA_LYRICIST, ///< std::string, lyricist 119 MEDIA_ALBUM, ///< std::string, album 120 MEDIA_ALBUM_ARTIST, ///< std::string, album artist 121 MEDIA_DATE, ///< std::string, media date, format:YYYY-MM-DD 122 MEDIA_COMMENT, ///< std::string, comment 123 MEDIA_GENRE, ///< std::string, genre 124 MEDIA_COPYRIGHT, ///< std::string, copyright 125 MEDIA_LANGUAGE, ///< std::string, language 126 MEDIA_DESCRIPTION, ///< std::string, description 127 MEDIA_LYRICS, ///< std::string, cyrics 128 MEDIA_DURATION, ///< int64_t, duration based on {@link HST_TIME_BASE} 129 MEDIA_FILE_SIZE, ///< uint64_t, file size 130 MEDIA_BITRATE, ///< int64_t, bite rate 131 MEDIA_FILE_URI, ///< std::string, file uri 132 MEDIA_CODEC_CONFIG, ///< std::vector<uint8_t>, codec config. e.g. AudioSpecificConfig for mp4 133 MEDIA_POSITION, ///< uint64_t : The byte position within media stream/file 134 MEDIA_START_TIME, ///< int64_t: The start time of one track 135 MEDIA_SEEKABLE, ///< enum Seekable: Seekable status of the media 136 MEDIA_PLAYBACK_SPEED, ///< double, playback speed 137 MEDIA_TYPE, ///< enum MediaType: Auido Video Subtitle... 138 139 /* -------------------- audio universal tag -------------------- */ 140 AUDIO_CHANNELS = SECTION_AUDIO_UNIVERSAL_START + 1, ///< uint32_t, stream channel num 141 AUDIO_CHANNEL_LAYOUT, ///< @see AudioChannelLayout, stream channel layout 142 AUDIO_SAMPLE_RATE, ///< uint32_t, sample rate 143 AUDIO_SAMPLE_FORMAT, ///< @see AudioSampleFormat 144 AUDIO_SAMPLE_PER_FRAME, ///< uint32_t, sample per frame 145 AUDIO_OUTPUT_CHANNELS, ///< uint32_t, sink output channel num 146 AUDIO_OUTPUT_CHANNEL_LAYOUT, ///< @see AudioChannelLayout, sink output channel layout 147 148 /* -------------------- audio specific tag -------------------- */ 149 AUDIO_SPECIFIC_MPEG_START = MAKE_AUDIO_SPECIFIC_START(AudioFormat::MPEG), 150 AUDIO_MPEG_VERSION, ///< uint32_t, mpeg version 151 AUDIO_MPEG_LAYER, ///< uint32_t, mpeg layer 152 153 AUDIO_SPECIFIC_AAC_START = MAKE_AUDIO_SPECIFIC_START(AudioFormat::AAC), 154 AUDIO_AAC_PROFILE, ///< @see AudioAacProfile 155 AUDIO_AAC_LEVEL, ///< uint32_t, acc level 156 AUDIO_AAC_STREAM_FORMAT, ///< @see AudioAacStreamFormat 157 158 /* -------------------- video universal tag -------------------- */ 159 VIDEO_WIDTH = SECTION_VIDEO_UNIVERSAL_START + 1, ///< uint32_t, video width 160 VIDEO_HEIGHT, ///< uint32_t, video height 161 VIDEO_PIXEL_FORMAT, ///< @see VideoPixelFormat 162 VIDEO_FRAME_RATE, ///< uint32_t, video frame rate 163 VIDEO_SURFACE, ///< @see class Surface 164 VIDEO_MAX_SURFACE_NUM, ///< uint32_t, max video surface num 165 VIDEO_CAPTURE_RATE, ///< double, video capture rate 166 VIDEO_BIT_STREAM_FORMAT, ///< @see VideoBitStreamFormat 167 168 /* -------------------- video specific tag -------------------- */ 169 VIDEO_SPECIFIC_H264_START = MAKE_VIDEO_SPECIFIC_START(VideoFormat::H264), 170 VIDEO_H264_PROFILE, ///< @see VideoH264Profile 171 VIDEO_H264_LEVEL, ///< uint32_t, h264 level 172 173 /* -------------------- user specific tag -------------------- */ 174 USER_FRAME_NUMBER = SECTION_USER_SPECIFIC_START + 1, ///< uint32_t : The user frame number 175 USER_FRAME_PTS, ///< int64_t : The user frame pts 176 USER_TIME_SYNC_RESULT, ///< std::string : The time sync result 177 USER_AV_SYNC_GROUP_INFO, ///< std::string : The av sync group info 178 USER_SHARED_MEMORY_FD, ///< std::string : The shared memory fd 179 USER_PUSH_DATA_TIME, ///< int64_t : The user push data time 180 181 /* -------------------- subtitle universal tag ----------------*/ 182 SUBTITLE_TEXT, ///< std::string : The text of subtitle 183 SUBTITLE_PTS, 184 SUBTITLE_DURATION, 185 }; 186 /** 187 * @enum Media protocol type. 188 * 189 * @since 1.0 190 * @version 1.0 191 */ 192 enum struct ProtocolType : uint32_t { 193 UNKNOWN, ///< Unknown protocol 194 FILE, ///< File protocol, uri prefix: "file://" 195 FD, ///< File descriptor protocol, uri prefix: "fd://" 196 STREAM, ///< Stream protocol, uri prefix: "stream://" 197 HTTP, ///< Http protocol, uri prefix: "http://" 198 HTTPS, ///< Https protocol, uri prefix: "https://" 199 HLS, ///< Http live streaming protocol, uri prefix: "https://" or "https://" or "file://", suffix: ".m3u8" 200 DASH, ///< Dynamic adaptive streaming over Http protocol, uri prefix: "https://" or "https://", suffix: ".mpd" 201 RTSP, ///< Real time streaming protocol, uri prefix: "rtsp://" 202 RTP, ///< Real-time transport protocol, uri prefix: "rtp://" 203 RTMP, ///< RTMP protocol, uri prefix: "rtmp://" 204 FTP, ///< FTP protocol, uri prefix: "ftp://" 205 UDP, ///< User datagram protocol, uri prefix: "udp://" 206 }; 207 208 using ValueType = Any; 209 210 /** 211 * The tag content is stored in key-value format. 212 */ 213 using CodecConfig = std::vector<uint8_t>; 214 } // namespace Plugin 215 } // namespace Media 216 } // namespace OHOS 217 #endif // HISTREAMER_PLUGIN_COMMON_TAGS_H 218