• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 /**
17  * @file bluetooth_avrcp_ct.h
18  *
19  * @brief Declares the class of the AVRCP controller framework, including attributes and methods.
20  *
21  * @since 6
22  */
23 
24 #ifndef BLUETOOTH_AVRCP_CT_H
25 #define BLUETOOTH_AVRCP_CT_H
26 
27 #include <vector>
28 
29 #include "bluetooth_def.h"
30 #include "bluetooth_types.h"
31 #include "bluetooth_remote_device.h"
32 
33 namespace OHOS {
34 namespace Bluetooth {
35 /**
36  * @brief This class provides the attribute of the result of the actions.
37  *
38  * @since 6
39  */
40 class AvrcpCtResponse {
41 public:
42     /**
43      * @brief This struct declares the attributes of the button.
44      *
45      * @since 6
46      */
47     class Button {
48     public:
Button(uint8_t code)49         explicit Button(uint8_t code) : code_(code)
50         {};
~Button()51         ~Button()
52         {};
53         uint8_t code_;  // The value of the button.
54 
55     private:
56         Button() = delete;
57     };
58 
59     /**
60      * @brief This struct declares a set of capabilities supported by TG.
61      *
62      * @since 6
63      */
64     class Capabilities {
65     public:
Capabilities(std::vector<uint32_t> companies)66         explicit Capabilities(std::vector<uint32_t> companies) : companies_(companies)
67         {};
Capabilities(std::vector<uint8_t> events)68         explicit Capabilities(std::vector<uint8_t> events) : events_(events)
69         {};
~Capabilities()70         ~Capabilities()
71         {
72             events_.clear();
73             companies_.clear();
74         }
75         std::vector<uint32_t> companies_;
76         std::vector<uint8_t> events_;
77 
78     private:
79         Capabilities() = delete;
80     };
81 
82     /**
83      * @brief This struct declares a set of attributes of the player application setting.
84      *
85      * @since 6
86      */
87     class PlayerSettingAttributes {
88     public:
PlayerSettingAttributes(std::vector<uint8_t> attributes)89         explicit PlayerSettingAttributes(std::vector<uint8_t> attributes) : attributes_(attributes)
90         {};
~PlayerSettingAttributes()91         ~PlayerSettingAttributes()
92         {
93             attributes_.clear();
94         };
95         std::vector<uint8_t> attributes_;  // The attribute of the player application setting.
96 
97     private:
98         PlayerSettingAttributes() = delete;
99     };
100 
101     /**
102      * @brief This struct declares a set of attributes of the player application setting values.
103      *
104      * @since 6
105      */
106     class PlayerSettingValues {
107     public:
PlayerSettingValues(uint8_t attribute,const std::vector<uint8_t> & values)108         PlayerSettingValues(uint8_t attribute, const std::vector<uint8_t> &values)
109             : attribute_(attribute), values_(values)
110             {};
~PlayerSettingValues()111         ~PlayerSettingValues()
112         {
113             values_.clear();
114         };
115         uint8_t attribute_;            // The attribute of the player application setting.
116         std::vector<uint8_t> values_;  // The values of the specified attribute of the player application setting.
117 
118     private:
119         PlayerSettingValues() = delete;
120     };
121 
122     /**
123      * @brief This struct declares a set of attributes of the current player application setting value.
124      *
125      * @since 6
126      */
127     class PlayerSettingCurrentValue {
128     public:
PlayerSettingCurrentValue(const std::vector<uint8_t> & attributes,const std::vector<uint8_t> & values)129         PlayerSettingCurrentValue(const std::vector<uint8_t> &attributes, const std::vector<uint8_t> &values)
130             : attributes_(attributes), values_(values)
131             {};
~PlayerSettingCurrentValue()132         ~PlayerSettingCurrentValue()
133         {
134             attributes_.clear();
135             values_.clear();
136         };
137         std::vector<uint8_t> attributes_;  // The attribute of the player application settings.
138         std::vector<uint8_t> values_;      // The value of the specified attribute of the player application settings.
139 
140     private:
141         PlayerSettingCurrentValue() = delete;
142     };
143 
144     /**
145      * @brief This struct declares a set of attributes of the player application getting attribtue text.
146      *
147      * @since 6
148      */
149     class PlayerGettingText {
150     public:
PlayerGettingText(const std::vector<uint8_t> & attributes,const std::vector<std::string> & attrStr)151         PlayerGettingText(const std::vector<uint8_t> &attributes, const std::vector<std::string> &attrStr)
152             : attributes_(attributes), attrStr_(attrStr)
153             {};
~PlayerGettingText()154         ~PlayerGettingText()
155         {
156             attributes_.clear();
157             attrStr_.clear();
158         };
159         std::vector<uint8_t> attributes_;   // The attribute of the player application settings.
160         std::vector<std::string> attrStr_;  // The values associated witch the attribute.
161 
162     private:
163         PlayerGettingText() = delete;
164     };
165 
166     /**
167      * @brief This struct declares a set of element attribute.
168      *
169      * @since 6
170      */
171     class ElementAttributes {
172     public:
ElementAttributes(const std::vector<uint32_t> & attributes,const std::vector<std::string> & values)173         ElementAttributes(const std::vector<uint32_t> &attributes, const std::vector<std::string> &values)
174             : attributes_(attributes), values_(values)
175             {};
~ElementAttributes()176         ~ElementAttributes()
177         {
178             attributes_.clear();
179             values_.clear();
180         };
181         std::vector<uint32_t> attributes_;  // The attribute of the player application settings.
182         std::vector<std::string> values_;   // The value of the specified attribute of the player application settings.
183 
184     private:
185         ElementAttributes() = delete;
186     };
187 
188     /**
189      * @brief This struct declares the attributes of the player status.
190      *
191      * @since 6
192      */
193     class PlayStatus {
194     public:
PlayStatus(uint32_t songLength,uint32_t songPosition,uint8_t playStatus)195         PlayStatus(uint32_t songLength, uint32_t songPosition, uint8_t playStatus)
196             : songLength_(songLength), songPosition_(songPosition), playStatus_(playStatus)
197             {};
~PlayStatus()198         ~PlayStatus()
199         {};
200         uint32_t songLength_;    // The total length of the playing song in milliseconds.
201         uint32_t songPosition_;  // The current position of the playing in milliseconds elapsed.
202         uint8_t playStatus_;     // The current status of playing. Refer to <b>AvrcPlayStatus</b>.
203 
204     private:
205         PlayStatus() = delete;
206     };
207 
208     /**
209      * @brief This struct declares the attributes of the media item.
210      *
211      * @since 6
212 
213      */
214     class MediaItems {
215     public:
216         struct MediaItem {
217             // The value of the "Folder Type" and the "Media Type". Refer to <b>AvrcMediaFolderType</b> and
218             // <b>AvrcMediaElementType</b>.
219             uint8_t type_ {AVRC_MEDIA_ELEMENT_TYPE_RESERVED};
220             // The value of the "Is Playable". Refer to <b>AvrcMediaFolderPlayable</b>.
221             uint8_t playable_ {AVRC_MEDIA_FOLDER_PLAYABLE_RESERVED};
222             uint64_t uid_ {0xFFFFFFFFFFFFFFFF};
223             // The value of the "Displayable Name".
224             std::string name_;
225             // The list of the "Attribute ID".  Refer to <b>AvrcMediaAttribute</b>.
226             std::vector<uint32_t> attributes_;
227             // The list of the "Attribute Value".
228             std::vector<std::string> values_;
229         };
MediaItems(uint16_t uidCounter,const std::vector<MediaItem> & mediaItems)230         MediaItems(uint16_t uidCounter, const std::vector<MediaItem> &mediaItems)
231             : uidCounter_(uidCounter), mediaItems_(mediaItems)
232             {};
~MediaItems()233         ~MediaItems()
234         {};
235 
236         uint16_t uidCounter_ {0xFFFF};
237         std::vector<MediaItem> mediaItems_;
238 
239     private:
240         MediaItems() = delete;
241     };
242 
243         /**
244      * @brief This struct declares the the media player list.
245      *
246      * @since 6
247      */
248     class MediaPlayers {
249     public:
250         struct MediaPlayer {
251             /// The value of the "Folder Type" and the "Media Type". Refer to <b>AvrcMediaFolderType</b> and
252             /// <b>AvrcMediaElementType</b>.
253             uint8_t itemType_ {AVRC_MEDIA_ELEMENT_TYPE_RESERVED};
254             /// The value of the "Is Playable". Refer to <b>AvrcMediaFolderPlayable</b>.
255             uint16_t playerId_ {AVRC_MEDIA_FOLDER_PLAYABLE_RESERVED};
256             ///< The value of the "Major Player Type". Refer to <b>AvrcMediaMajorPlayerType</b>.
257             uint8_t majorType_ = 0x00;
258             ///< The value of the "Player Sub Type". Refer to <b>AvrcMediaPlayerSubType</b>.
259             uint32_t subType_ = 0x00;
260             ///< The value of the "Play Status". Refer to <b>AvrcPlayStatus</b>.
261             uint8_t playStatus_ = 0x00;
262             ///< The value of the "Feature Bit Mask".
263             std::vector<uint8_t> features_;
264             ///< The value of the "Displayable Name".
265             std::string name_ = "\0";
266         };
MediaPlayers(uint16_t uidCounter,const std::vector<MediaPlayer> & mediaPlayers)267         MediaPlayers(uint16_t uidCounter, const std::vector<MediaPlayer> &mediaPlayers)
268             : uidCounter_(uidCounter), mediaPlayers_(mediaPlayers)
269             {};
~MediaPlayers()270         ~MediaPlayers()
271         {};
272 
273         uint16_t uidCounter_ {0xFFFF};
274         std::vector<MediaPlayer> mediaPlayers_;
275 
276     private:
277         MediaPlayers() = delete;
278     };
279 
280     /**
281      * @brief This struct declares the attributes of the media item attribute.
282      *
283      * @since 6
284      */
285     class ItemAttributes {
286     public:
287         struct ItemAttribute {
288             uint32_t attribute_;
289             std::string value_;
290         };
ItemAttributes(const std::vector<ItemAttribute> & itemAttrs)291         explicit ItemAttributes(const std::vector<ItemAttribute> &itemAttrs) : itemAttrs_(itemAttrs)
292         {};
~ItemAttributes()293         ~ItemAttributes()
294         {};
295         std::vector<ItemAttribute> itemAttrs_;
296 
297     private:
298         ItemAttributes() = delete;
299     };
300 
301     /**
302      * @brief This struct declares a set of attributes of the player application setting values.
303      *
304      * @since 6
305      */
306     class TotalNumberOfItems {
307     public:
TotalNumberOfItems(uint16_t uidCounter,uint32_t numOfItems)308         TotalNumberOfItems(uint16_t uidCounter, uint32_t numOfItems)
309             : uidCounter_(uidCounter), numOfItems_(numOfItems)
310             {};
~TotalNumberOfItems()311         ~TotalNumberOfItems()
312         {};
313         uint16_t uidCounter_;  // The value of the uid counter.
314         uint32_t numOfItems_;  // The number of items in the directory.
315 
316     private:
317         TotalNumberOfItems() = delete;
318     };
319 
320     /**
321      * @brief This struct declares a set of attributes of the player application setting values.
322      *
323      * @since 6
324      */
325     class AbsoluteVolume {
326     public:
AbsoluteVolume(uint8_t volume)327         explicit AbsoluteVolume(uint8_t volume) : volume_(volume)
328         {};
~AbsoluteVolume()329         ~AbsoluteVolume()
330         {};
331         uint8_t volume_;  // The percentage of the absolute volume.Refer to <b> AvrcAbsoluteVolume</ b>.
332 
333     private:
334         AbsoluteVolume() = delete;
335     };
336 
337     /**
338      * @brief This struct declares a set of attributes of the notifications.
339      *
340      * @since 6
341      */
342     class Notification {
343     public:
Notification(uint8_t playStatus,uint8_t volume)344         Notification(uint8_t playStatus, uint8_t volume) : playStatus_(playStatus), volume_(volume)
345         {};
Notification(uint64_t uid)346         explicit Notification(uint64_t uid) : uid_(uid)
347         {};
Notification(uint32_t playbackPos)348         explicit Notification(uint32_t playbackPos) : playbackPos_(playbackPos)
349         {};
Notification(const std::vector<uint8_t> & attributes,const std::vector<uint8_t> & values)350         Notification(const std::vector<uint8_t> &attributes, const std::vector<uint8_t> &values)
351             : attributes_(attributes), values_(values)
352             {};
Notification(uint16_t playerId,uint16_t uidCounter)353         Notification(uint16_t playerId, uint16_t uidCounter) : playerId_(playerId), uidCounter_(uidCounter)
354         {};
Notification(uint16_t uidCounter)355         explicit Notification(uint16_t uidCounter) : uidCounter_(uidCounter)
356         {};
~Notification()357         ~Notification()
358         {};
359         uint8_t playStatus_ {AVRC_PLAY_STATUS_ERROR};    // The value of the "PlayStatus".
360         uint64_t uid_ {0xFFFFFFFFFFFFFFFF};              // The value of the "Identifier".
361         uint32_t playbackPos_ {0x00000000};              // The value of the "Playback position".
362         std::vector<uint8_t> attributes_;             // The value of the "PlayerApplicationSettingAttributeID".
363         std::vector<uint8_t> values_;                 // The value of the "PlayerApplicationSettingValueID".
364         uint16_t playerId_ {0xFFFF};                     // The value of the "Player Id".
365         uint16_t uidCounter_ {0xFFFF};                   // The value of the "UID Counter".
366         uint8_t volume_ {AVRC_ABSOLUTE_VOLUME_INVALID};  // The value of the "Absolute Volume".
367     private:
368         Notification() = delete;
369     };
370 
371     AvrcpCtResponse(uint8_t type, int resp);
372     ~AvrcpCtResponse();
373 
374     uint8_t type_;  // The type of the action.
375     int resp_;      // The result of the called action.
376     // The unique pointer to the <b>AvrcpCtResponse::Button</b> class.
377     std::unique_ptr<Button> button_ {nullptr};
378     // The unique pointer to the <b>AvrcpCtResponse::GetCapabilities</b> class.
379     std::unique_ptr<Capabilities> capabilities_ {nullptr};
380     // The unique pointer to the <b>AvrcpCtResponse::PlayerSettingAttributes</b> class.
381     std::unique_ptr<PlayerSettingAttributes> playerAttrs_ {nullptr};
382     // The unique pointer to the <b>AvrcpCtResponse::PlayerSettingValues</b> class.
383     std::unique_ptr<PlayerSettingValues> playerVals_ {nullptr};
384     // The unique pointer to the <b>AvrcpCtResponse::PlayerSettingCurrentValue</b> class.
385     std::unique_ptr<PlayerSettingCurrentValue> playerCurVal_ {nullptr};
386     // The unique pointer to the <b>AvrcpCtResponse::PlayerGettingAttribtueText</b> class.
387     std::unique_ptr<PlayerGettingText> playerText_ {nullptr};
388     // The unique pointer to the <b>AvrcpCtResponse::GetElementAttributes</b> class.
389     std::unique_ptr<ElementAttributes> eleSts_ {nullptr};
390     // The unique pointer to the <b>AvrcpCtResponse::PlayStatus</b> class.
391     std::unique_ptr<PlayStatus> playSts_ {nullptr};
392     // The unique pointer to the <b>AvrcpCtResponse::MediaItem</b> class.
393     std::unique_ptr<MediaItems> mediaItems_ {nullptr};
394     ///< The unique pointer to the <b>AvrcpCtResponse::MediaPlayer</b> class.
395     std::unique_ptr<MediaPlayers> mediaPlayers_ {nullptr};
396     ///< The unique pointer to the <b>AvrcpCtResponse::ItemAttributes</b> class.
397     std::unique_ptr<ItemAttributes> itemAttrs_ {nullptr};
398     // The unique pointer to the <b>AvrcpCtResponse::TotalNumberOfItems</b> class.
399     std::unique_ptr<TotalNumberOfItems> totalItems_ {nullptr};
400     // The unique pointer to the <b>AvrcpCtResponse::AbsoluteVolume</b> class.
401     std::unique_ptr<AbsoluteVolume> absVolume_ {nullptr};
402     // The unique pointer to the <b>AvrcpCtResponse::Notification</b> class.
403     std::unique_ptr<Notification> notify_ {nullptr};
404 
405 private:
406     AvrcpCtResponse() = delete;
407 };
408 
409 /**
410  * @brief This class provides a set of methods for operating the AVRCP controller.
411  *
412  * @since 6
413  */
414 class BLUETOOTH_API AvrcpController {
415 public:
416     /**
417      * @brief This abstract class declares a set of methods for observing the <b>AvrcpController::IObserver</b> class.
418      *
419      * @since 6
420      */
421     class IObserver {
422     public:
423         /**
424          * @brief A constructor used to create an <b>AvrcpController::IObserver</b> instance.
425          *
426          * @since 6
427          */
428         IObserver() = default;
429 
430         /**
431          * @brief A destructor used to delete the <b>AvrcpController::IObserver</b> instance.
432          *
433          * @since 6
434          */
435         virtual ~IObserver() = default;
436 
437         /**
438          * @brief Observes the state of the connection.
439          *
440          * @param[in] device The bluetooth device.
441          * @param[in] state  The connection state. Refer to <b>BTConnectState</b>.
442          *
443          * @since 6
444          */
445         virtual void OnConnectionStateChanged(const BluetoothRemoteDevice &device, int state) = 0;
446 
447         /**
448          * @brief Observes the status of the other actions.
449          *
450          * @param[in] device The bluetooth device.
451          * @param[in] resp   The result of the called action.
452          *
453          * @since 6
454          */
455         virtual void OnActionCompleted(const BluetoothRemoteDevice &device, const AvrcpCtResponse &resp) = 0;
456     };
457 
458     /**
459      * @brief Gets the static instance of the <b>AvrcpController</b> class.
460      *
461      * @return The static instance.
462      *
463      * @since 6
464      */
465     static AvrcpController *GetProfile(void);
466 
467     /******************************************************************
468      * REGISTER / UNREGISTER OBSERVER                                 *
469      ******************************************************************/
470 
471     /**
472      * @brief Registers the observer.
473      *
474      * @param[in] observer The pointer to the <b>AvrcpController::IObserver</b>.
475      * @since 6
476      */
477     void RegisterObserver(AvrcpController::IObserver *observer);
478 
479     /**
480      * @brief Unregisters the observer.
481      *
482      * @param[in] observer The pointer to the <b>AvrcpController::IObserver</b>.
483      * @since 6
484      */
485     void UnregisterObserver(AvrcpController::IObserver *observer);
486 
487     /******************************************************************
488      * CONNECTION                                                     *
489      ******************************************************************/
490 
491     /**
492      * @brief Gets the connected devices.
493      *
494      * @return The list of the instance of the <b>BluetoothRemoteDevice</b> class.
495      *
496      * @since 6
497      */
498     std::vector<BluetoothRemoteDevice> GetConnectedDevices(void);
499 
500     /**
501      * @brief Gets the devices of the specified states.
502      *
503      * @param[in] states The connection states. Refer to <b>BTConnectState</b>.
504      * @return The list of the instance of the <b>BluetoothRemoteDevice</b> class.
505      *
506      * @since 6
507      */
508     std::vector<BluetoothRemoteDevice> GetDevicesByStates(const std::vector<int> &states);
509 
510     /**
511      * @brief Gets the connection state of the specified bluetooth device.
512      *
513      * @param[in] device The bluetooth device.
514      * @return The connection state. Refer to <b>BTConnectState</b>.
515      *
516      * @since 6
517      */
518     int GetDeviceState(const BluetoothRemoteDevice &device);
519 
520     /**
521      * @brief Connects to the AVRCP TG service.
522      *
523      * @param[in] device The bluetooth device.
524      * @return The result of the method execution.
525      * @retval true  command send success.
526      * @retval false command seend failed.
527      *
528      * @since 6
529      */
530     bool Connect(const BluetoothRemoteDevice &device);
531 
532     /**
533      * @brief Disconnects from the AVRCP TG service.
534      *
535      * @param[in] device The bluetooth device.
536      * @return The result of the method execution.
537      * @retval true  command send success.
538      * @retval false command seend failed.
539      *
540      * @since 6
541      */
542     bool Disconnect(const BluetoothRemoteDevice &device);
543 
544     /******************************************************************
545      * BUTTON OPERATION                                               *
546      ******************************************************************/
547 
548     /**
549      * @brief Presses the button.
550      *
551      * @param[in] device The bluetooth device.
552      * @param[in] button The value of the key operation. Refer to <b>AvrcKeyOperation</b>
553      * @return The result of the method execution.
554      * @retval RET_NO_ERROR   Execute success.
555      * @retval RET_NO_SUPPORT Not support.
556      * @retval RET_BAD_PARAM  Bad parameters.
557      * @retval RET_BAD_STATUS Execute failure.
558      *
559      * @since 6
560      */
561     int PressButton(const BluetoothRemoteDevice &device, uint8_t button);
562 
563     /**
564      * @brief Releases the button.
565      *
566      * @param[in] device The bluetooth device.
567      * @param[in] button The value of the key operation. Refer to <b>AvrcKeyOperation</b>
568      * @return The result of the method execution.
569      * @retval RET_NO_ERROR   Execute success.
570      * @retval RET_NO_SUPPORT Not support.
571      * @retval RET_BAD_PARAM  Bad parameters.
572      * @retval RET_BAD_STATUS Execute failure.
573      *
574      * @since 6
575      */
576     int ReleaseButton(const BluetoothRemoteDevice &device, uint8_t button);
577 
578     /******************************************************************
579      * UNIT INFO / SUB UNIT INFO                                      *
580      ******************************************************************/
581 
582     // TEMP
583     /**
584      * @brief Gets the unit information.
585      *
586      * @param[in] device The bluetooth device.
587      * @return The result of the method execution.
588      * @retval RET_NO_ERROR   Execute success.
589      * @retval RET_NO_SUPPORT Not support.
590      * @retval RET_BAD_STATUS Execute failure.
591      *
592      * @since 6
593      */
594     int GetUnitInfo(const BluetoothRemoteDevice &device);
595 
596     // TEMP
597     /**
598      * @brief Gets the sub unit information.
599      *
600      * @param[in] device The bluetooth device.
601      * @return The result of the method execution.
602      * @retval RET_NO_ERROR   Execute success.
603      * @retval RET_NO_SUPPORT Not Support.
604      * @retval RET_BAD_STATUS Execute failure.
605      *
606      * @since 6
607      */
608     int GetSubUnitInfo(const BluetoothRemoteDevice &device);
609 
610     /******************************************************************
611      * Media Player Selection                                         *
612      ******************************************************************/
613 
614     // TEMP
615     /**
616      * @brief Informs which media player wishes to control.
617      *
618      * @param[in] device   The bluetooth device.
619      * @param[in] playerId The unique media player id.
620      * @return The result of the method execution.
621      * @retval RET_NO_ERROR   Execute success.
622      * @retval RET_NO_SUPPORT Not Support.
623      * @retval RET_BAD_STATUS Execute failure.
624      *
625      * @since 6
626      */
627     int SetAddressedPlayer(const BluetoothRemoteDevice &device, uint16_t playerId);
628 
629     /**
630      * @brief Informs to which player browsing commands should be routed.
631      *
632      * @param[in] device   The bluetooth device.
633      * @param[in] playerId The unique media player id.
634      * @return The result of the method execution.
635      * @retval RET_NO_ERROR   Execute success.
636      * @retval RET_NO_SUPPORT Not Support.
637      * @retval RET_BAD_STATUS Execute failure.
638      *
639      * @since 6
640      */
641     int SetBrowsedPlayer(const BluetoothRemoteDevice &device, uint16_t playerId);
642 
643     /******************************************************************
644      * Capabilities                                                   *
645      ******************************************************************/
646 
647     /**
648      * @brief Get the supported companies by remote device.
649      *
650      * @details This is sent by CT to get the capabilities of the peer device.
651      * @param[in] rawAddr      The address of the bluetooth device.
652      * @return The result of the method execution.
653      * @retval RET_NO_ERROR   Execute success.
654      * @retval RET_NO_SUPPORT Not Support.
655      * @retval RET_BAD_STATUS Execute failure.
656      *
657      * @since 6
658      */
659     int GetSupportedCompanies(const BluetoothRemoteDevice &device);
660 
661     /**
662      * @brief Get the supported events by remote device.
663      *
664      * @details This is sent by CT to get the capabilities of the peer device.
665      * @param[in] rawAddr      The address of the bluetooth device.
666      * @return The result of the method execution.
667      * @retval RET_NO_ERROR   Execute success.
668      * @retval RET_NO_SUPPORT Not Support.
669      * @retval RET_BAD_STATUS Execute failure.
670      *
671      * @since 6
672      */
673     int GetSupportedEvents(const BluetoothRemoteDevice &device);
674     /******************************************************************
675      * PLAYER APPLICATION SETTINGS                                    *
676      ******************************************************************/
677 
678     /**
679      * @brief Gets the attribute of the player application.
680      *
681      * @param[in] device The bluetooth device.
682      * @return The result of the method execution.
683      * @retval RET_NO_ERROR   Execute success.
684      * @retval RET_NO_SUPPORT Not support.
685      * @retval RET_BAD_PARAM  Bad parameters.
686      * @retval RET_BAD_STATUS Execute failure.
687      *
688      * @since 6
689      */
690     int GetPlayerAppSettingAttributes(const BluetoothRemoteDevice &device);
691 
692     /**
693      * @brief Gets the values of the specified attribute of the player application.
694      *
695      * @param[in] device    The bluetooth device.
696      * @param[in] attribute The attribute of the player application setting. Refer to <b>AvrcPlayerAttribute</b>.
697      * @return The result of the method execution.
698      * @retval RET_NO_ERROR   Execute success.
699      * @retval RET_NO_SUPPORT Not support.
700      * @retval RET_BAD_PARAM  Bad parameters.
701      * @retval RET_BAD_STATUS Execute failure.
702      *
703      * @since 6
704      */
705     int GetPlayerAppSettingValues(const BluetoothRemoteDevice &device, uint8_t attribute);
706 
707     /**
708      * @brief Gets the current set values on the target for the provided player application setting attributes list.
709      *
710      * @param[in] device     The bluetooth device.
711      * @param[in] attributes The attribute of the player application settings. Refer to <b>AvrcPlayerAttribute</b>.
712      * @return The result of the method execution.
713      * @retval RET_NO_ERROR   Execute success.
714      * @retval RET_NO_SUPPORT Not Support.
715      * @retval RET_BAD_STATUS Execute failure.
716      *
717      * @since 6
718      */
719     int GetPlayerAppSettingCurrentValue(const BluetoothRemoteDevice &device, const std::vector<uint8_t> &attributes);
720 
721     /**
722      * @brief Sets the player application setting list of player application setting values on the target device for the
723      * corresponding defined list of AvrcPlayerAttribute.
724      *
725      * @param[in] device     The bluetooth device.
726      * @param[in] attributes The attribute of the player application settings. Refer to <b>AvrcPlayerAttribute</b>.
727      * @param[in] values     The value of the player application setting attribute.
728      * @return The result of the method execution.
729      * @retval RET_NO_ERROR   Execute success.
730      * @retval RET_NO_SUPPORT Not Support.
731      * @retval RET_BAD_STATUS Execute failure.
732      *
733      * @since 6
734      */
735     int SetPlayerAppSettingCurrentValue(const BluetoothRemoteDevice &device, const std::vector<uint8_t> &attributes,
736         const std::vector<uint8_t> &values);
737 
738     /**
739      * @brief  provide supported player application setting attribute displayable text.
740      *
741      * @details Switch to the thread of the AVRCP CT service in this method.
742      * @param[in] rawAddr    The address of the bluetooth device.
743      * @param[in] attributes The attribute of the player application settings.
744      * @return The result of the method execution.
745      * @retval RET_NO_ERROR   Execute success.
746      * @retval RET_NO_SUPPORT Not Support.
747      * @retval RET_BAD_STATUS Execute failure.
748      *
749      * @since 6
750      */
751     int GetPlayerApplicationSettingAttributeText(
752         const BluetoothRemoteDevice &device, const std::vector<uint8_t> &attributes);
753 
754     /**
755      * @brief  request the target device to provide target supported player application setting value displayable text.
756      *
757      * @details Switch to the thread of the AVRCP CT service in this method.
758      * @param[in] rawAddr     The address of the bluetooth device.
759      * @param[in] attributeId Player application setting attribute ID.
760      * @param[in] values      Player application setting value ID.
761      * @return The result of the method execution.
762      * @retval RET_NO_ERROR   Execute success.
763      * @retval RET_NO_SUPPORT Not Support.
764      * @retval RET_BAD_STATUS Execute failure.
765      *
766      * @since 6
767      */
768     int GetPlayerApplicationSettingValueText(
769         const BluetoothRemoteDevice &device, uint8_t attributeId, const std::vector<uint8_t> &values);
770 
771     /******************************************************************
772      * MEDIA INFORMATION PDUS                                         *
773      ******************************************************************/
774 
775     /**
776      * @brief Requests the TG to provide the attributes of the element specified in the parameter.
777      *
778      * @details Switch to the thread of the AVRCP CT service in this function.
779      * @param[in] device     The bluetooth device.
780      * @param[in] attributes Specifies the attribute ID for the attributes to be retrieved
781      *            @c RET_NO_ERROR   : The action is successful.
782      *            @c RET_NO_SUPPORT : The action is not supported.
783      *            @c RET_BAD_STATUS : The action is failed.
784      */
785 
786     int GetElementAttributes(const BluetoothRemoteDevice &device, const std::vector<uint32_t> &attributes);
787 
788     /******************************************************************
789      * PLAY                                                           *
790      ******************************************************************/
791 
792     /**
793      * @brief Gets the play status.
794      *
795      * @param[in] device The bluetooth device.
796      * @return The result of the method execution.
797      * @retval RET_NO_ERROR   Execute success.
798      * @retval RET_NO_SUPPORT Not Support.
799      * @retval RET_BAD_STATUS Execute failure.
800      *
801      * @since 6
802      */
803     int GetPlayStatus(const BluetoothRemoteDevice &device);
804 
805     /**
806      * @brief Starts playing an item indicated by the UID.
807      *
808      * @param[in] device     The bluetooth device.
809      * @param[in] scope      The scope in which media content navigation may take place. Refer to <b>AvrcMediaScope</b>.
810      * @param[in] uid        The unique ID of media item.
811      * @param[in] uidCounter The UID counter shall be incremented every time the TG makes an update.
812      * @return The result of the method execution.
813      * @retval RET_NO_ERROR   Execute success.
814      * @retval RET_NO_SUPPORT Not Support.
815      * @retval RET_BAD_STATUS Execute failure.
816      *
817      * @since 6
818      */
819     int PlayItem(const BluetoothRemoteDevice &device, uint64_t uid, uint16_t uidCounter);
820 
821     // TEMP
822     /**
823      * @brief Adds an item indicated by the UID to the Now Playing queue.
824      *
825      * @param[in] device     The bluetooth device.
826      * @param[in] scope      The scope in which media content navigation may take place. Refer to <b>AvrcMediaScope</b>.
827      * @param[in] uid        The UID of the media element item or folder item.
828      * @param[in] uidCounter The UID Counter.
829      * @return The result of the method execution.
830      * @retval RET_NO_ERROR   Execute success.
831      * @retval RET_NO_SUPPORT Not support.
832      * @retval RET_BAD_STATUS Execute failure.
833      *
834      * @since 6
835      */
836     int AddToNowPlaying(const BluetoothRemoteDevice &device, uint64_t uid, uint16_t uidCounter);
837 
838     /******************************************************************
839      * CONTINUING RESPONSE / ABORT CONTINUING RESPONSE                *
840      ******************************************************************/
841 
842     /**
843      * @brief Requests continuing response.
844      *
845      * @param[in] device  The bluetooth device.
846      * @param[in] pduId   The PDU ID which wants to request.
847      * @return The result of the method execution.
848      * @retval RET_NO_ERROR   Execute success.
849      * @retval RET_NO_SUPPORT Not Support.
850      * @retval RET_BAD_STATUS Execute failure.
851      */
852     int RequestContinuingResponse(const BluetoothRemoteDevice &device, uint8_t pduId);
853 
854     /**
855      * @brief Aborts continuing response.
856      *
857      * @param[in] device  The bluetooth device.
858      * @param[in] pduId   The PDU ID which wants to abort.
859      * @return The result of the method execution.
860      * @retval RET_NO_ERROR   Execute success.
861      * @retval RET_NO_SUPPORT Not Support.
862      * @retval RET_BAD_STATUS Execute failure.
863      *
864      * @since 6.0
865      */
866     int AbortContinuingResponse(const BluetoothRemoteDevice &device, uint8_t pduId);
867 
868     /******************************************************************
869      * OPERATE THE VIRTUAL FILE SYSTEM                                *
870      ******************************************************************/
871 
872     /**
873      * @brief Navigates one level up or down in the virtual file system.
874      *
875      * @param[in] device     The bluetooth device.
876      * @param[in] uidCounter The value of the uid counter.
877      * @param[in] direction  The flag of the navigation. Refer to <b>bluetooth::AvrcFolderDirection</b>.
878      * @param[in] folderUid  The UID of the folder to navigate to. This may be retrieved via a GetFolderItems command.
879      * If the navigation command is Folder Up this field is reserved.
880      * @return The result of the method execution.
881      * @retval RET_NO_ERROR   Execute success.
882      * @retval RET_NO_SUPPORT Not support.
883      * @retval RET_BAD_PARAM  Bad parameters.
884      * @retval RET_BAD_STATUS Execute failure.
885      *
886      * @since 6
887      */
888     int ChangePath(const BluetoothRemoteDevice &device, uint16_t uidCounter, uint16_t direction, uint64_t folderUid);
889 
890     /**
891      * @brief Retrieves a listing of the contents of a folder.
892      *
893      * @param[in] device     The bluetooth device.
894      * @param[in] startItem  The offset within the listing of the item, which should be the first returned item. The
895      * first element in the listing is at offset 0.
896      * @param[in] endItem    The offset within the listing of the item which should be the final returned item. If this
897      * is set to a value beyond what is available, the TG shall return items from the provided Start Item index to the
898      * index of the final item. If the End Item index is smaller than the Start Item index, the TG shall return an
899      * error. If CT requests too many items, TG can respond with a sub-set of the requested items.
900      * @param[in] attributes The list of media attributes.
901      * @return The result of the method execution.
902      * @retval RET_NO_ERROR   Execute success.
903      * @retval RET_NO_SUPPORT Not support.
904      * @retval RET_BAD_STATUS Execute failure.
905      *
906      * @since 6
907      */
908     int GetFolderItems(const BluetoothRemoteDevice &device, uint32_t startItem, uint32_t endItem,
909         const std::vector<uint32_t> &attributes);
910 
911         /**
912      * @brief Retrieves a listing of the contents of a folder.
913      *
914      * @param[in] device     The bluetooth device.
915      * @param[in] startItem  The offset within the listing of the item, which should be the first returned item. The
916      * first element in the listing is at offset 0.
917      * @param[in] endItem    The offset within the listing of the item which should be the final returned item. If this
918      * is set to a value beyond what is available, the TG shall return items from the provided Start Item index to the
919      * index of the final item. If the End Item index is smaller than the Start Item index, the TG shall return an
920      * error. If CT requests too many items, TG can respond with a sub-set of the requested items.
921      * @return The result of the method execution.
922      * @retval RET_NO_ERROR   Execute success.
923      * @retval RET_NO_SUPPORT Not support.
924      * @retval RET_BAD_STATUS Execute failure.
925      *
926      * @since 6
927      */
928     int GetMeidaPlayerList(const BluetoothRemoteDevice &device, uint32_t startItem, uint32_t endItem);
929 
930     /**
931      * @brief Retrieves the metadata attributes for a particular media element item or folder item.
932      *
933      * @param[in] device     The bluetooth device.
934      * @param[in] uid        The UID of the media element item or folder item.
935      * @param[in] uidCounter The UID Counter.
936      * @param[in] attributes The list of media attributes.
937      * @return The result of the method execution.
938      * @retval RET_NO_ERROR   Execute success.
939      * @retval RET_NO_SUPPORT Not support.
940      * @retval RET_BAD_STATUS Execute failure.
941      *
942      * @since 6
943      */
944     int GetItemAttributes(const BluetoothRemoteDevice &device, uint64_t uid, uint16_t uidCounter,
945         const std::vector<uint32_t> &attributes);
946 
947     /**
948      * @brief Gets the number of items in the now playing scope.
949      *
950      * @param[in] device The bluetooth device.
951      * @return The result of the method execution.
952      * @retval RET_NO_ERROR   Execute success.
953      * @retval RET_NO_SUPPORT Not support.
954      * @retval RET_BAD_STATUS Execute failure.
955      *
956      * @since 6
957      */
958     int GetTotalNumberOfItems(const BluetoothRemoteDevice &device);
959 
960     /******************************************************************
961      * ABSOLUTE VOLUME                                                *
962      ******************************************************************/
963 
964     /**
965      * @brief Sets an absolute volume to be used by the rendering device.
966      *
967      * @param[in] device The bluetooth device.
968      * @param[in] volume The percentage of the absolute volume. Refer to <b>AvrcAbsoluteVolume</b>.
969      * @return The result of the method execution.
970      * @retval RET_NO_ERROR   Execute success.
971      * @retval RET_NO_SUPPORT Not support.
972      * @retval RET_BAD_STATUS Execute failure.
973      *
974      * @since 6
975      */
976     int SetAbsoluteVolume(const BluetoothRemoteDevice &device, uint8_t volume);
977 
978     /******************************************************************
979      * NOTIFICATION                                                   *
980      ******************************************************************/
981 
982     /**
983      * @brief Enables for receiving notifications asynchronously based on specific events occurring.
984      *
985      * @details Switch to the thread of the AVRCP CT service in this method.
986      * @param[in] rawAddr  The address of the bluetooth device.
987      * @param[in] events   The event for which the requires notification. Refer to <b>AvrcEventId</b>.
988      * @param[in] interval The specifies the time interval (in seconds) at which the change in playback position will be
989      * notified.
990      * @return The result of the method execution.
991      * @retval RET_NO_ERROR   Execute success.
992      * @retval RET_NO_SUPPORT Not support.
993      * @retval RET_BAD_STATUS Execute failure.
994      *
995      * @since 6
996      */
997     int EnableNotification(const BluetoothRemoteDevice &device, const std::vector<uint8_t> &events,
998         uint32_t interval = AVRC_PLAYBACK_INTERVAL_1_SEC);
999 
1000     /**
1001      * @brief Disables for receiving notifications asynchronously based on specific events occurring.
1002      *
1003      * @details Switch to the thread of the AVRCP CT service in this method.
1004      * @param[in] rawAddr The address of the bluetooth device.
1005      * @param[in] events  The event for which the requires notification. Refer to <b>AvrcEventId</b>.
1006      * @return The result of the method execution.
1007      * @retval RET_NO_ERROR   Execute success.
1008      * @retval RET_NO_SUPPORT Not support.
1009      * @retval RET_BAD_STATUS Execute failure.
1010      *
1011      * @since 6
1012      */
1013     int DisableNotification(const BluetoothRemoteDevice &device, const std::vector<uint8_t> &events);
1014 
1015     /**
1016      * @brief The external process calls the A2dpsrc profile interface before the Bluetooth process starts. At this
1017      * time, it needs to monitor the start of the Bluetooth process, and then call this interface to initialize the
1018      * A2dpsrc proflie.
1019      */
1020     void Init();
1021 
1022 private:
1023     /**
1024      * @brief A constructor used to create an <b>AvrcpController</b> instance.
1025      *
1026      * @since 6
1027      */
1028     AvrcpController();
1029 
1030     /**
1031      * @brief A destructor used to delete the <b>AvrcpController</b> instance.
1032      *
1033      * @since 6
1034      */
1035     virtual ~AvrcpController();
1036 
1037     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(AvrcpController);
1038     BLUETOOTH_DECLARE_IMPL();
1039 };
1040 }  // namespace Bluetooth
1041 }  // namespace OHOS
1042 #endif  // !BLUETOOTH_AVRCP_CT_H
1043