/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file bluetooth_avrcp_ct.h * * @brief Declares the class of the AVRCP controller framework, including attributes and methods. * * @since 6 */ #ifndef BLUETOOTH_AVRCP_CT_H #define BLUETOOTH_AVRCP_CT_H #include #include "bluetooth_def.h" #include "bluetooth_types.h" #include "bluetooth_remote_device.h" #include "bluetooth_no_destructor.h" namespace OHOS { namespace Bluetooth { /** * @brief This class provides the attribute of the result of the actions. * * @since 6 */ class AvrcpCtResponse { public: /** * @brief This struct declares the attributes of the button. * * @since 6 */ class Button { public: explicit Button(uint8_t code) : code_(code) {}; ~Button() {}; uint8_t code_; // The value of the button. private: Button() = delete; }; /** * @brief This struct declares a set of capabilities supported by TG. * * @since 6 */ class Capabilities { public: explicit Capabilities(std::vector companies) : companies_(companies) {}; explicit Capabilities(std::vector events) : events_(events) {}; ~Capabilities() { events_.clear(); companies_.clear(); } std::vector companies_; std::vector events_; private: Capabilities() = delete; }; /** * @brief This struct declares a set of attributes of the player application setting. * * @since 6 */ class PlayerSettingAttributes { public: explicit PlayerSettingAttributes(std::vector attributes) : attributes_(attributes) {}; ~PlayerSettingAttributes() { attributes_.clear(); }; std::vector attributes_; // The attribute of the player application setting. private: PlayerSettingAttributes() = delete; }; /** * @brief This struct declares a set of attributes of the player application setting values. * * @since 6 */ class PlayerSettingValues { public: PlayerSettingValues(uint8_t attribute, const std::vector &values) : attribute_(attribute), values_(values) {}; ~PlayerSettingValues() { values_.clear(); }; uint8_t attribute_; // The attribute of the player application setting. std::vector values_; // The values of the specified attribute of the player application setting. private: PlayerSettingValues() = delete; }; /** * @brief This struct declares a set of attributes of the current player application setting value. * * @since 6 */ class PlayerSettingCurrentValue { public: PlayerSettingCurrentValue(const std::vector &attributes, const std::vector &values) : attributes_(attributes), values_(values) {}; ~PlayerSettingCurrentValue() { attributes_.clear(); values_.clear(); }; std::vector attributes_; // The attribute of the player application settings. std::vector values_; // The value of the specified attribute of the player application settings. private: PlayerSettingCurrentValue() = delete; }; /** * @brief This struct declares a set of attributes of the player application getting attribtue text. * * @since 6 */ class PlayerGettingText { public: PlayerGettingText(const std::vector &attributes, const std::vector &attrStr) : attributes_(attributes), attrStr_(attrStr) {}; ~PlayerGettingText() { attributes_.clear(); attrStr_.clear(); }; std::vector attributes_; // The attribute of the player application settings. std::vector attrStr_; // The values associated witch the attribute. private: PlayerGettingText() = delete; }; /** * @brief This struct declares a set of element attribute. * * @since 6 */ class ElementAttributes { public: ElementAttributes(const std::vector &attributes, const std::vector &values) : attributes_(attributes), values_(values) {}; ~ElementAttributes() { attributes_.clear(); values_.clear(); }; std::vector attributes_; // The attribute of the player application settings. std::vector values_; // The value of the specified attribute of the player application settings. private: ElementAttributes() = delete; }; /** * @brief This struct declares the attributes of the player status. * * @since 6 */ class PlayStatus { public: PlayStatus(uint32_t songLength, uint32_t songPosition, uint8_t playStatus) : songLength_(songLength), songPosition_(songPosition), playStatus_(playStatus) {}; ~PlayStatus() {}; uint32_t songLength_; // The total length of the playing song in milliseconds. uint32_t songPosition_; // The current position of the playing in milliseconds elapsed. uint8_t playStatus_; // The current status of playing. Refer to AvrcPlayStatus. private: PlayStatus() = delete; }; /** * @brief This struct declares the attributes of the media item. * * @since 6 */ class MediaItems { public: struct MediaItem { // The value of the "Folder Type" and the "Media Type". Refer to AvrcMediaFolderType and // AvrcMediaElementType. uint8_t type_ {AVRC_MEDIA_ELEMENT_TYPE_RESERVED}; // The value of the "Is Playable". Refer to AvrcMediaFolderPlayable. uint8_t playable_ {AVRC_MEDIA_FOLDER_PLAYABLE_RESERVED}; uint64_t uid_ {0xFFFFFFFFFFFFFFFF}; // The value of the "Displayable Name". std::string name_; // The list of the "Attribute ID". Refer to AvrcMediaAttribute. std::vector attributes_; // The list of the "Attribute Value". std::vector values_; }; MediaItems(uint16_t uidCounter, const std::vector &mediaItems) : uidCounter_(uidCounter), mediaItems_(mediaItems) {}; ~MediaItems() {}; uint16_t uidCounter_ {0xFFFF}; std::vector mediaItems_; private: MediaItems() = delete; }; /** * @brief This struct declares the the media player list. * * @since 6 */ class MediaPlayers { public: struct MediaPlayer { /// The value of the "Folder Type" and the "Media Type". Refer to AvrcMediaFolderType and /// AvrcMediaElementType. uint8_t itemType_ {AVRC_MEDIA_ELEMENT_TYPE_RESERVED}; /// The value of the "Is Playable". Refer to AvrcMediaFolderPlayable. uint16_t playerId_ {AVRC_MEDIA_FOLDER_PLAYABLE_RESERVED}; ///< The value of the "Major Player Type". Refer to AvrcMediaMajorPlayerType. uint8_t majorType_ = 0x00; ///< The value of the "Player Sub Type". Refer to AvrcMediaPlayerSubType. uint32_t subType_ = 0x00; ///< The value of the "Play Status". Refer to AvrcPlayStatus. uint8_t playStatus_ = 0x00; ///< The value of the "Feature Bit Mask". std::vector features_; ///< The value of the "Displayable Name". std::string name_ = "\0"; }; MediaPlayers(uint16_t uidCounter, const std::vector &mediaPlayers) : uidCounter_(uidCounter), mediaPlayers_(mediaPlayers) {}; ~MediaPlayers() {}; uint16_t uidCounter_ {0xFFFF}; std::vector mediaPlayers_; private: MediaPlayers() = delete; }; /** * @brief This struct declares the attributes of the media item attribute. * * @since 6 */ class ItemAttributes { public: struct ItemAttribute { uint32_t attribute_; std::string value_; }; explicit ItemAttributes(const std::vector &itemAttrs) : itemAttrs_(itemAttrs) {}; ~ItemAttributes() {}; std::vector itemAttrs_; private: ItemAttributes() = delete; }; /** * @brief This struct declares a set of attributes of the player application setting values. * * @since 6 */ class TotalNumberOfItems { public: TotalNumberOfItems(uint16_t uidCounter, uint32_t numOfItems) : uidCounter_(uidCounter), numOfItems_(numOfItems) {}; ~TotalNumberOfItems() {}; uint16_t uidCounter_; // The value of the uid counter. uint32_t numOfItems_; // The number of items in the directory. private: TotalNumberOfItems() = delete; }; /** * @brief This struct declares a set of attributes of the player application setting values. * * @since 6 */ class AbsoluteVolume { public: explicit AbsoluteVolume(uint8_t volume) : volume_(volume) {}; ~AbsoluteVolume() {}; uint8_t volume_; // The percentage of the absolute volume.Refer to AvrcAbsoluteVolume. private: AbsoluteVolume() = delete; }; /** * @brief This struct declares a set of attributes of the notifications. * * @since 6 */ class Notification { public: Notification(uint8_t playStatus, uint8_t volume) : playStatus_(playStatus), volume_(volume) {}; explicit Notification(uint64_t uid) : uid_(uid) {}; explicit Notification(uint32_t playbackPos) : playbackPos_(playbackPos) {}; Notification(const std::vector &attributes, const std::vector &values) : attributes_(attributes), values_(values) {}; Notification(uint16_t playerId, uint16_t uidCounter) : playerId_(playerId), uidCounter_(uidCounter) {}; explicit Notification(uint16_t uidCounter) : uidCounter_(uidCounter) {}; ~Notification() {}; uint8_t playStatus_ {AVRC_PLAY_STATUS_ERROR}; // The value of the "PlayStatus". uint64_t uid_ {0xFFFFFFFFFFFFFFFF}; // The value of the "Identifier". uint32_t playbackPos_ {0x00000000}; // The value of the "Playback position". std::vector attributes_; // The value of the "PlayerApplicationSettingAttributeID". std::vector values_; // The value of the "PlayerApplicationSettingValueID". uint16_t playerId_ {0xFFFF}; // The value of the "Player Id". uint16_t uidCounter_ {0xFFFF}; // The value of the "UID Counter". uint8_t volume_ {AVRC_ABSOLUTE_VOLUME_INVALID}; // The value of the "Absolute Volume". private: Notification() = delete; }; AvrcpCtResponse(uint8_t type, int resp); ~AvrcpCtResponse(); uint8_t type_; // The type of the action. int resp_; // The result of the called action. // The unique pointer to the AvrcpCtResponse::Button class. std::unique_ptr