1 /* 2 * Copyright (c) 2023 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 OHOS_I_AV_SENDER_ENGINE_H 17 #define OHOS_I_AV_SENDER_ENGINE_H 18 19 #include <memory> 20 #include <string> 21 22 #include "av_trans_buffer.h" 23 #include "av_trans_errno.h" 24 #include "av_trans_message.h" 25 #include "av_trans_types.h" 26 #include "i_av_sender_engine_callback.h" 27 28 namespace OHOS { 29 namespace DistributedHardware { 30 /** 31 * @brief AV sender engine interface. 32 * 33 * AV sender engine is loaded and running on the source device. 34 * It supports the management and control the histreamer pipeline, as well as processing of video and audio data. 35 * 36 * @since 1.0 37 * @version 1.0 38 */ 39 class IAVSenderEngine { 40 public: 41 /** 42 * @brief Destructor. 43 * @return No return value. 44 */ 45 virtual ~IAVSenderEngine() = default; 46 47 /** 48 * @brief Initialize the av sender engine. 49 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 50 */ 51 virtual int32_t Initialize() = 0; 52 53 /** 54 * @brief Release the av sender engine. 55 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 56 */ 57 virtual int32_t Release() = 0; 58 59 /** 60 * @brief Start the pipeline and plugins in the sender engine. 61 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 62 */ 63 virtual int32_t Start() = 0; 64 65 /** 66 * @brief Stop the pipeline and plugins in the sender engine. 67 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 68 */ 69 virtual int32_t Stop() = 0; 70 71 /** 72 * @brief Push video or audio data to the sender engine. 73 * @param buffer video or audio buffer data. 74 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 75 */ 76 virtual int32_t PushData(const std::shared_ptr<AVTransBuffer> &buffer) = 0; 77 78 /** 79 * @brief Set parameter to the sender engine. 80 * @param tag parameter key. 81 * @param value parameter value. 82 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 83 */ 84 virtual int32_t SetParameter(AVTransTag tag, const std::string &value) = 0; 85 86 /** 87 * @brief Send message to the sender engine or the sink device. 88 * @param message message content. 89 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 90 */ 91 virtual int32_t SendMessage(const std::shared_ptr<AVTransMessage> &message) = 0; 92 93 /** 94 * @brief Create control channel for the sender engine. 95 * @param dstDevIds ids of the target devices. 96 * @param attribution channel attributes. 97 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 98 */ 99 virtual int32_t CreateControlChannel(const std::vector<std::string> &dstDevIds, 100 const ChannelAttribute &attribution) = 0; 101 102 /** 103 * @brief Register interface callback to the sender engine. 104 * @param callback interface callback. 105 * @return Returns DH_AVT_SUCCESS(0) if successful, otherwise returns other error code. 106 */ 107 virtual int32_t RegisterSenderCallback(const std::shared_ptr<IAVSenderEngineCallback> &callback) = 0; 108 /** 109 * @brief Send dump signal to the receiver engine. 110 * @return Returns BOOL(0) 111 */ 112 virtual bool StartDumpMediaData() = 0; 113 /** 114 * @brief Send dump stop signal to the receiver engine. 115 * @return Returns BOOL(0) 116 */ 117 virtual bool StopDumpMediaData() = 0; 118 /** 119 * @brief Send redump signal to the receiver engine. 120 * @return Returns BOOL(0) 121 */ 122 virtual bool ReStartDumpMediaData() = 0; 123 }; 124 } // DistributedHardware 125 } // OHOS 126 #endif // OHOS_I_AV_SENDER_ENGINE_H