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