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_AVCAST_CONTROLLER_H 17 #define OHOS_AVCAST_CONTROLLER_H 18 19 #include <bitset> 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "media_info_holder.h" 25 #include "avsession_info.h" 26 #include "key_event.h" 27 #include "i_avcast_controller_proxy.h" 28 #include "avcast_control_command.h" 29 30 /** 31 * @brief Session controller instance. 32 * @since 9 33 */ 34 namespace OHOS::AVSession { 35 class AVCastController { 36 public: 37 /** 38 * Send commands to its corresponding session through the controller. 39 * 40 * @param cmd Commands and parameters related to the session {@link AVControlCommand}. 41 * @return int32_t Return whether sending succeeded. 42 * @since 9 43 */ 44 virtual int32_t SendControlCommand(const AVCastControlCommand& cmd) = 0; 45 46 virtual int32_t Start(const AVQueueItem& avQueueItem) = 0; 47 48 virtual int32_t Prepare(const AVQueueItem& avQueueItem) = 0; 49 /** 50 * @brief Listen for AVController Callback event. 51 * 52 * @param callback Listen for AVController Callback event{@link AVControllerCallback}. 53 * @return Returns whether the return is successful. 54 * @since 9 55 */ 56 virtual int32_t RegisterCallback(const std::shared_ptr<AVCastControllerCallback>& callback) = 0; 57 58 virtual int32_t GetDuration(int32_t& duration) = 0; 59 60 virtual int32_t GetCastAVPlaybackState(AVPlaybackState& avPlaybackState) = 0; 61 62 virtual int32_t GetCurrentItem(AVQueueItem& currentItem) = 0; 63 64 virtual int32_t GetValidCommands(std::vector<int32_t>& cmds) = 0; 65 66 virtual int32_t SetDisplaySurface(std::string& surfaceId) = 0; 67 68 virtual int32_t SetCastPlaybackFilter(const AVPlaybackState::PlaybackStateMaskType& filter) = 0; 69 70 virtual int32_t ProcessMediaKeyResponse(const std::string& assetId, const std::vector<uint8_t>& response) = 0; 71 72 virtual int32_t AddAvailableCommand(const int32_t cmd) = 0; 73 74 virtual int32_t RemoveAvailableCommand(const int32_t cmd) = 0; 75 76 virtual int32_t Destroy() = 0; 77 78 /** 79 * @brief Deconstruct AVSessionController. 80 * @since 9 81 */ 82 virtual ~AVCastController() = default; 83 }; 84 } // namespace OHOS::AVSession 85 #endif // OHOS_AVCAST_CONTROLLER_H 86