• 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 #include "avcodec_service_proxy.h"
16 #include "avcodec_errors.h"
17 #include "avcodec_log.h"
18 
19 
20 namespace {
21 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_FRAMEWORK, "AVCodecServiceProxy"};
22 }
23 
24 namespace OHOS {
25 namespace MediaAVCodec {
AVCodecServiceProxy(const sptr<IRemoteObject> & impl)26 AVCodecServiceProxy::AVCodecServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IStandardAVCodecService>(impl)
27 {
28     AVCODEC_LOGD("0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
29 }
30 
~AVCodecServiceProxy()31 AVCodecServiceProxy::~AVCodecServiceProxy()
32 {
33     AVCODEC_LOGD("0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
34 }
35 
GetSubSystemAbility(IStandardAVCodecService::AVCodecSystemAbility subSystemId,const sptr<IRemoteObject> & listener,sptr<IRemoteObject> & object)36 int32_t AVCodecServiceProxy::GetSubSystemAbility(IStandardAVCodecService::AVCodecSystemAbility subSystemId,
37                                                  const sptr<IRemoteObject> &listener, sptr<IRemoteObject> &object)
38 {
39     CHECK_AND_RETURN_RET_LOG(listener != nullptr, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "listener is nullptr");
40 
41     MessageParcel data;
42     MessageParcel reply;
43     MessageOption option;
44 
45     bool ret = data.WriteInterfaceToken(AVCodecServiceProxy::GetDescriptor());
46     CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "Failed to write descriptor");
47 
48     (void)data.WriteInt32(static_cast<int32_t>(subSystemId));
49     (void)data.WriteRemoteObject(listener);
50     int error =
51         Remote()->SendRequest(static_cast<uint32_t>(AVCodecServiceInterfaceCode::GET_SUBSYSTEM), data, reply, option);
52     CHECK_AND_RETURN_RET_LOG(error == 0, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED,
53         "Create av_codec proxy failed, error: %{public}d", error);
54 
55     object = reply.ReadRemoteObject();
56     CHECK_AND_RETURN_RET_LOG(object != nullptr, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "Remote object is nullptr");
57     return reply.ReadInt32();
58 }
59 } // namespace MediaAVCodec
60 } // namespace OHOS
61