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_TYPES_H 17 #define HISTREAMER_PLUGIN_TYPES_H 18 19 #include <cstdint> // NOLINT: using int32_t in this file 20 21 namespace OHOS { 22 namespace Media { 23 namespace Plugin { 24 /** 25 * @enum Plugin running state. 26 * 27 * @since 1.0 28 * @version 1.0 29 */ 30 enum struct State : int32_t { 31 CREATED = 0, ///< Indicates the status of the plugin when it is constructed. 32 ///< The plug-in will not be restored in the entire life cycle. 33 INITIALIZED = 1, ///< Plugin global resource initialization completion status. 34 PREPARED = 2, ///< Status of parameters required for plugin running. 35 RUNNING = 3, ///< The system enters the running state after call start(). 36 PAUSED = 4, ///< Plugin temporarily stops processing data. This state is optional. 37 DESTROYED = -1, ///< Plugin destruction state. In this state, all resources are released. 38 INVALID = -2, ///< An error occurs in any state and the plugin enters the invalid state. 39 }; 40 41 /** 42 * @enum Enumerates types of Seek Mode. 43 * 44 * @brief Seek modes, Options that SeekTo() behaviour. 45 * 46 * @since 1.0 47 * @version 1.0 48 */ 49 enum struct SeekMode : uint32_t { 50 SEEK_NEXT_SYNC = 0, ///> sync to keyframes after the time point. 51 SEEK_PREVIOUS_SYNC, ///> sync to keyframes before the time point. 52 SEEK_CLOSEST_SYNC, ///> sync to closest keyframes. 53 SEEK_CLOSEST, ///> seek to frames closest the time point. 54 }; 55 56 /** 57 * @enum Seekable Status. 58 * 59 * @since 1.0 60 * @version 1.0 61 */ 62 enum class Seekable : int32_t { 63 INVALID = -1, 64 UNSEEKABLE = 0, 65 SEEKABLE = 1 66 }; 67 68 enum struct CodecMode { 69 HARDWARE, ///< HARDWARE CODEC 70 SOFTWARE, ///< SOFTWARE CODEC 71 }; 72 /** 73 * @enum Api Return Status. 74 * 75 * @since 1.0 76 * @version 1.0 77 */ 78 enum struct Status : int32_t { 79 END_OF_STREAM = 1, ///< Read source when end of stream 80 OK = 0, ///< The execution result is correct. 81 NO_ERROR = OK, ///< Same as Status::OK 82 ERROR_UNKNOWN = -1, ///< An unknown error occurred. 83 ERROR_PLUGIN_ALREADY_EXISTS = -2, ///< The plugin already exists, usually occurs when in plugin registered. 84 ERROR_INCOMPATIBLE_VERSION = 85 -3, ///< Incompatible version, may occur during plugin registration or function calling. 86 ERROR_NO_MEMORY = -4, ///< The system memory is insufficient. 87 ERROR_WRONG_STATE = -5, ///< The function is called in an invalid state. 88 ERROR_UNIMPLEMENTED = -6, ///< This method or interface is not implemented. 89 ERROR_INVALID_PARAMETER = -7, ///< The plugin does not support this parameter. 90 ERROR_INVALID_DATA = -8, ///< The value is not in the valid range. 91 ERROR_MISMATCHED_TYPE = -9, ///< Mismatched data type 92 ERROR_TIMED_OUT = -10, ///< Operation timeout. 93 ERROR_UNSUPPORTED_FORMAT = -11, ///< The plugin not support this format/name. 94 ERROR_NOT_ENOUGH_DATA = -12, ///< Not enough data when read from source. 95 ERROR_NOT_EXISTED = -13, ///< Source is not existed. 96 ERROR_AGAIN = -14, ///< Operation is not available right now, should try again later. 97 ERROR_PERMISSION_DENIED = -15, ///< Permission denied. 98 ERROR_NULL_POINTER = -16, ///< Null pointer. 99 ERROR_INVALID_OPERATION = -17, ///< Invalid operation. 100 ERROR_CLIENT = -18, ///< Http client error 101 ERROR_SERVER = -19, ///< Http server error 102 ERROR_DELAY_READY = -20, ///< Delay ready event 103 }; 104 105 /** 106 * @enum Plugin Type. 107 * 108 * @since 1.0 109 * @version 1.0 110 */ 111 enum struct PluginType : int32_t { 112 INVALID_TYPE = -1, ///< Invalid plugin 113 SOURCE = 1, ///< reference SourcePlugin 114 DEMUXER, ///< reference DemuxerPlugin 115 AUDIO_DECODER, ///< reference CodecPlugin 116 AUDIO_ENCODER, ///< reference CodecPlugin 117 VIDEO_DECODER, ///< reference CodecPlugin 118 VIDEO_ENCODER, ///< reference CodecPlugin 119 AUDIO_SINK, ///< reference AudioSinkPlugin 120 VIDEO_SINK, ///< reference VideoSinkPlugin 121 MUXER, ///< reference MuxerPlugin 122 OUTPUT_SINK, ///< reference OutputSinkPlugin 123 GENERIC_PLUGIN, ///< generic plugin can be used to represent any user extended plugin 124 }; 125 126 /* 127 * @brief Audio RenderInfo, default ContentType::CONTENT_TYPE_UNKNOWN(0) and StreamUsage::STREAM_USAGE_UNKNOWN(0) 128 * combined into AudioStreamType::STREAM_MUSIC. 129 */ 130 struct AudioRenderInfo { 131 int32_t contentType {0}; 132 int32_t streamUsage {0}; 133 int32_t rendererFlags {0}; 134 }; 135 136 enum class AudioInterruptMode { 137 SHARE_MODE, 138 INDEPENDENT_MODE 139 }; 140 141 enum class VideoScaleType { 142 VIDEO_SCALE_TYPE_FIT, 143 VIDEO_SCALE_TYPE_FIT_CROP, 144 }; 145 } // namespace Plugin 146 } // namespace Media 147 } // namespace OHOS 148 #endif // HISTREAMER_PLUGIN_TYPES_H 149