• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_AVSESSION_STUB_H
17 #define OHOS_AVSESSION_STUB_H
18 
19 #include "iav_session.h"
20 #include "iremote_stub.h"
21 #include "want_agent.h"
22 #include "want_params.h"
23 #include "avsession_log.h"
24 #include "avsession_errors.h"
25 
26 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
27 #include "avcast_controller.h"
28 #endif
29 
30 namespace OHOS::AVSession {
31 class AVSessionStub : public IRemoteStub<IAVSession> {
32 public:
33     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
34 
RegisterCallback(const std::shared_ptr<AVSessionCallback> & callback)35     int32_t RegisterCallback(const std::shared_ptr<AVSessionCallback>& callback) override
36     {
37         return ERR_NONE;
38     }
39 
GetController()40     std::shared_ptr<AVSessionController> GetController() override
41     {
42         return nullptr;
43     }
44 
45 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
GetAVCastController()46     std::shared_ptr<AVCastController> GetAVCastController() override
47     {
48         return nullptr;
49     }
50 #endif
51 
52 private:
53     int32_t HandleGetSessionId(MessageParcel& data, MessageParcel& reply);
54 
55     int32_t HandleGetSessionType(MessageParcel& data, MessageParcel& reply);
56 
57     int32_t HandleSetAVCallMetaData(MessageParcel& data, MessageParcel& reply);
58 
59     int32_t HandleSetAVCallState(MessageParcel& data, MessageParcel& reply);
60 
61     int32_t HandleGetAVMetaData(MessageParcel& data, MessageParcel& reply);
62 
63     int32_t HandleSetAVMetaData(MessageParcel& data, MessageParcel& reply);
64 
65     int32_t HandleGetAVPlaybackState(MessageParcel& data, MessageParcel& reply);
66 
67     int32_t HandleSetAVPlaybackState(MessageParcel& data, MessageParcel& reply);
68 
69     int32_t HandleSetLaunchAbility(MessageParcel& data, MessageParcel& reply);
70 
71     int32_t HandleGetExtras(MessageParcel& data, MessageParcel& reply);
72 
73     int32_t HandleSetExtras(MessageParcel& data, MessageParcel& reply);
74 
75     int32_t HandleGetController(MessageParcel& data, MessageParcel& reply);
76 
77 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
78     int32_t HandleGetAVCastController(MessageParcel& data, MessageParcel& reply);
79 
80     int32_t HandleReleaseCast(MessageParcel& data, MessageParcel& reply);
81 #endif
82 
83     int32_t HandleRegisterCallbackInner(MessageParcel& data, MessageParcel& reply);
84 
85     int32_t HandleActivate(MessageParcel& data, MessageParcel& reply);
86 
87     int32_t HandleDeactivate(MessageParcel& data, MessageParcel& reply);
88 
89     int32_t HandleIsActive(MessageParcel& data, MessageParcel& reply);
90 
91     int32_t HandleDestroy(MessageParcel& data, MessageParcel& reply);
92 
93     int32_t HandleAddSupportCommand(MessageParcel& data, MessageParcel& reply);
94 
95     int32_t HandleDeleteSupportCommand(MessageParcel& data, MessageParcel& reply);
96 
97     int32_t HandleSetSessionEvent(MessageParcel& data, MessageParcel& reply);
98 
99     int32_t HandleGetAVQueueItems(MessageParcel& data, MessageParcel& reply);
100 
101     int32_t HandleSetAVQueueItems(MessageParcel& data, MessageParcel& reply);
102 
103     int32_t HandleGetAVQueueTitle(MessageParcel& data, MessageParcel& reply);
104 
105     int32_t HandleSetAVQueueTitle(MessageParcel& data, MessageParcel& reply);
106 
107     static bool CheckInterfaceToken(MessageParcel& data);
108 
109     using HandlerFunc = int32_t(AVSessionStub::*)(MessageParcel&, MessageParcel&);
110     static inline HandlerFunc handlers[] = {
111         &AVSessionStub::HandleGetSessionId,
112         &AVSessionStub::HandleGetSessionType,
113         &AVSessionStub::HandleGetAVMetaData,
114         &AVSessionStub::HandleSetAVMetaData,
115         &AVSessionStub::HandleGetAVPlaybackState,
116         &AVSessionStub::HandleSetAVPlaybackState,
117         &AVSessionStub::HandleGetAVQueueItems,
118         &AVSessionStub::HandleSetAVQueueItems,
119         &AVSessionStub::HandleGetAVQueueTitle,
120         &AVSessionStub::HandleSetAVQueueTitle,
121         &AVSessionStub::HandleGetExtras,
122         &AVSessionStub::HandleSetExtras,
123         &AVSessionStub::HandleSetLaunchAbility,
124         &AVSessionStub::HandleGetController,
125 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
126         &AVSessionStub::HandleGetAVCastController,
127 #endif
128         &AVSessionStub::HandleRegisterCallbackInner,
129         &AVSessionStub::HandleActivate,
130         &AVSessionStub::HandleDeactivate,
131         &AVSessionStub::HandleIsActive,
132         &AVSessionStub::HandleDestroy,
133         &AVSessionStub::HandleAddSupportCommand,
134         &AVSessionStub::HandleDeleteSupportCommand,
135         &AVSessionStub::HandleSetSessionEvent,
136 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
137         &AVSessionStub::HandleReleaseCast,
138 #endif
139         &AVSessionStub::HandleSetAVCallMetaData,
140         &AVSessionStub::HandleSetAVCallState,
141     };
142 
143     int32_t MAX_IMAGE_SIZE = 10 * 1024 * 1024;
144 };
145 }
146 #endif // OHOS_AVSESSION_STUB_H
147