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 "avsession_errors.h" 27 #include "key_event.h" 28 #include "i_avcast_controller_proxy.h" 29 #include "avcast_control_command.h" 30 31 /** 32 * @brief Session controller instance. 33 * @since 9 34 */ 35 namespace OHOS::AVSession { 36 class AVCastController { 37 public: 38 /** 39 * Send commands to its corresponding session through the controller. 40 * 41 * @param cmd Commands and parameters related to the session {@link AVControlCommand}. 42 * @return int32_t Return whether sending succeeded. 43 * @since 9 44 */ 45 virtual int32_t SendControlCommand(const AVCastControlCommand& cmd) = 0; 46 SendCustomData(const AAFwk::WantParams & data)47 virtual int32_t SendCustomData(const AAFwk::WantParams& data) { return AVSESSION_SUCCESS; }; 48 49 virtual int32_t Start(const AVQueueItem& avQueueItem) = 0; 50 51 virtual int32_t Prepare(const AVQueueItem& avQueueItem) = 0; 52 /** 53 * @brief Listen for AVController Callback event. 54 * 55 * @param callback Listen for AVController Callback event{@link AVControllerCallback}. 56 * @return Returns whether the return is successful. 57 * @since 9 58 */ 59 virtual int32_t RegisterCallback(const std::shared_ptr<AVCastControllerCallback>& callback) = 0; 60 61 virtual int32_t GetDuration(int32_t& duration) = 0; 62 63 virtual int32_t GetCastAVPlaybackState(AVPlaybackState& avPlaybackState) = 0; 64 65 virtual int32_t GetSupportedDecoders(std::vector<std::string>& decoderTypes) = 0; 66 67 virtual int32_t GetRecommendedResolutionLevel(std::string& decoderType, ResolutionLevel& resolutionLevel) = 0; 68 69 virtual int32_t GetSupportedHdrCapabilities(std::vector<HDRFormat>& hdrFormats) = 0; 70 71 virtual int32_t GetSupportedPlaySpeeds(std::vector<float>& playSpeeds) = 0; 72 73 virtual int32_t GetCurrentItem(AVQueueItem& currentItem) = 0; 74 75 virtual int32_t GetValidCommands(std::vector<int32_t>& cmds) = 0; 76 77 virtual int32_t SetDisplaySurface(std::string& surfaceId) = 0; 78 79 virtual int32_t SetCastPlaybackFilter(const AVPlaybackState::PlaybackStateMaskType& filter) = 0; 80 81 virtual int32_t ProcessMediaKeyResponse(const std::string& assetId, const std::vector<uint8_t>& response) = 0; 82 83 virtual int32_t AddAvailableCommand(const int32_t cmd) = 0; 84 85 virtual int32_t RemoveAvailableCommand(const int32_t cmd) = 0; 86 87 virtual int32_t Destroy() = 0; 88 89 /** 90 * @brief Deconstruct AVSessionController. 91 * @since 9 92 */ 93 virtual ~AVCastController() = default; 94 }; 95 } // namespace OHOS::AVSession 96 #endif // OHOS_AVCAST_CONTROLLER_H 97