• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_AVCAST_CONTROL_COMMAND_H
17 #define OHOS_AVCAST_CONTROL_COMMAND_H
18 
19 #include <cinttypes>
20 #include <functional>
21 #include <string>
22 #include <variant>
23 
24 #include "parcel.h"
25 
26 namespace OHOS::AVSession {
27 class AVCastControlCommand : public Parcelable {
28 public:
29     enum {
30         CAST_CONTROL_CMD_INVALID = -1,
31         CAST_CONTROL_CMD_PLAY = 0,
32         CAST_CONTROL_CMD_PAUSE = 1,
33         CAST_CONTROL_CMD_STOP = 2,
34         CAST_CONTROL_CMD_PLAY_NEXT = 3,
35         CAST_CONTROL_CMD_PLAY_PREVIOUS = 4,
36         CAST_CONTROL_CMD_FAST_FORWARD = 5,
37         CAST_CONTROL_CMD_REWIND = 6,
38         CAST_CONTROL_CMD_SEEK = 7,
39         CAST_CONTROL_CMD_SET_VOLUME = 8,
40         CAST_CONTROL_CMD_SET_SPEED = 9,
41         CAST_CONTROL_CMD_SET_LOOP_MODE = 10,
42         CAST_CONTROL_CMD_TOGGLE_FAVORITE = 11,
43         CAST_CONTROL_CMD_TOGGLE_MUTE = 12,
44         CAST_CONTROL_CMD_MAX = 13,
45     };
46 
47     AVCastControlCommand();
48     ~AVCastControlCommand() override;
49 
50     static AVCastControlCommand* Unmarshalling(Parcel& data);
51     bool Marshalling(Parcel& parcel) const override;
52 
53     bool IsValid() const;
54 
55     int32_t SetCommand(int32_t cmd);
56     int32_t GetCommand() const;
57 
58     int32_t SetForwardTime(int32_t forwardTime);
59     int32_t GetForwardTime(int32_t& forwardTime) const;
60 
61     int32_t SetRewindTime(int32_t rewindTime);
62     int32_t GetRewindTime(int32_t& rewindTime) const;
63 
64     int32_t SetSeekTime(int32_t seekTime);
65     int32_t GetSeekTime(int32_t& seekTime) const;
66 
67     int32_t SetVolume(int32_t volume);
68     int32_t GetVolume(int32_t& volume) const;
69 
70     int32_t SetSpeed(int32_t speed);
71     int32_t GetSpeed(int32_t& speed) const;
72 
73     int32_t SetLoopMode(int32_t loopMode);
74     int32_t GetLoopMode(int32_t& loopMode) const;
75 
76     const static inline std::vector<int32_t> localCapability {
77         CAST_CONTROL_CMD_PLAY,
78         CAST_CONTROL_CMD_PAUSE,
79         CAST_CONTROL_CMD_STOP,
80         CAST_CONTROL_CMD_PLAY_NEXT,
81         CAST_CONTROL_CMD_PLAY_PREVIOUS,
82         CAST_CONTROL_CMD_FAST_FORWARD,
83         CAST_CONTROL_CMD_REWIND,
84         CAST_CONTROL_CMD_SEEK,
85         CAST_CONTROL_CMD_SET_VOLUME,
86         CAST_CONTROL_CMD_SET_SPEED,
87         CAST_CONTROL_CMD_SET_LOOP_MODE,
88         CAST_CONTROL_CMD_TOGGLE_FAVORITE,
89         CAST_CONTROL_CMD_TOGGLE_MUTE,
90     };
91 
92 private:
93     int32_t cmd_ = CAST_CONTROL_CMD_INVALID;
94     std::variant<int32_t, double, int64_t, bool> param_;
95 };
96 }
97 #endif // OHOS_AVCAST_CONTROL_COMMAND_H
98