• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 #include "audio_policy_interface.h"
17 #include "audio_service_log.h"
18 #include "audio_system_manager.h"
19 
20 namespace OHOS {
21 namespace AudioStandard {
AudioRendererFilter()22 AudioRendererFilter::AudioRendererFilter()
23 {}
24 
~AudioRendererFilter()25 AudioRendererFilter::~AudioRendererFilter()
26 {}
27 
Marshalling(Parcel & parcel) const28 bool AudioRendererFilter::Marshalling(Parcel &parcel) const
29 {
30     return parcel.WriteInt32(uid) &&
31         parcel.WriteInt32(static_cast<int32_t>(rendererInfo.contentType)) &&
32         parcel.WriteInt32(static_cast<int32_t>(rendererInfo.streamUsage)) &&
33         parcel.WriteInt32(static_cast<int32_t>(streamType)) &&
34         parcel.WriteInt32(rendererInfo.rendererFlags) &&
35         parcel.WriteInt32(streamId);
36 }
37 
Unmarshalling(Parcel & parcel)38 AudioRendererFilter *AudioRendererFilter::Unmarshalling(Parcel &parcel)
39 {
40     auto info = new(std::nothrow) AudioRendererFilter();
41     if (info == nullptr) {
42         return nullptr;
43     }
44     info->uid = parcel.ReadInt32();
45     info->rendererInfo.contentType = static_cast<ContentType>(parcel.ReadInt32());
46     info->rendererInfo.streamUsage = static_cast<StreamUsage>(parcel.ReadInt32());
47     info->streamType = static_cast<AudioStreamType>(parcel.ReadInt32());
48     info->rendererInfo.rendererFlags = parcel.ReadInt32();
49     info->streamId = parcel.ReadInt32();
50     return info;
51 }
52 
AudioCapturerFilter()53 AudioCapturerFilter::AudioCapturerFilter()
54 {}
55 
~AudioCapturerFilter()56 AudioCapturerFilter::~AudioCapturerFilter()
57 {}
58 
Marshalling(Parcel & parcel) const59 bool AudioCapturerFilter::Marshalling(Parcel &parcel) const
60 {
61     return parcel.WriteInt32(uid) &&
62         parcel.WriteInt32(static_cast<int32_t>(capturerInfo.sourceType)) &&
63         parcel.WriteInt32(capturerInfo.capturerFlags);
64 }
65 
Unmarshalling(Parcel & in)66 AudioCapturerFilter *AudioCapturerFilter::Unmarshalling(Parcel &in)
67 {
68     auto audioCapturerFilter = new(std::nothrow) AudioCapturerFilter();
69     CHECK_AND_RETURN_RET(audioCapturerFilter != nullptr, nullptr);
70 
71     audioCapturerFilter->uid = in.ReadInt32();
72     audioCapturerFilter->capturerInfo.sourceType = static_cast<SourceType>(in.ReadInt32());
73     audioCapturerFilter->capturerInfo.capturerFlags = in.ReadInt32();
74 
75     return audioCapturerFilter;
76 }
77 } // namespace AudioStandard
78 } // namespace OHOS
79