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 #include "avqueue_info.h"
17 #include "avsession_log.h"
18 
19 namespace OHOS::AVSession {
Marshalling(Parcel & parcel) const20 bool AVQueueInfo::Marshalling(Parcel& parcel) const
21 {
22     return parcel.WriteString(bundleName_) &&
23         parcel.WriteString(avQueueName_) &&
24         parcel.WriteString(avQueueId_) &&
25         parcel.WriteString(avQueueImageUri_) &&
26         parcel.WriteParcelable(avQueueImage_.get());
27 }
28 
Unmarshalling(Parcel & data)29 bool AVQueueInfo::Unmarshalling(Parcel& data)
30 {
31     if (!data.ReadString(bundleName_) ||
32         !data.ReadString(avQueueName_) ||
33         !data.ReadString(avQueueId_) ||
34         !data.ReadString(avQueueImageUri_)) {
35         SLOGE("read AVQueueInfo failed");
36         return false;
37     }
38     avQueueImage_ = std::shared_ptr<AVSessionPixelMap>(data.ReadParcelable<AVSessionPixelMap>());
39     if (avQueueImage_ == nullptr) {
40         SLOGE("read AVQueueInfo PixelMap failed");
41         return false;
42     }
43     return true;
44 }
45 
SetBundleName(const std::string & bundleName)46 void AVQueueInfo::SetBundleName(const std::string& bundleName)
47 {
48     bundleName_ = bundleName;
49 }
50 
GetBundleName() const51 std::string AVQueueInfo::GetBundleName() const
52 {
53     return bundleName_;
54 }
55 
SetAVQueueName(const std::string & avQueueName)56 void AVQueueInfo::SetAVQueueName(const std::string& avQueueName)
57 {
58     avQueueName_ = avQueueName;
59 }
60 
GetAVQueueName() const61 std::string AVQueueInfo::GetAVQueueName() const
62 {
63     return avQueueName_;
64 }
65 
SetAVQueueId(const std::string & avQueueId)66 void AVQueueInfo::SetAVQueueId(const std::string& avQueueId)
67 {
68     avQueueId_ = avQueueId;
69 }
70 
GetAVQueueId() const71 std::string AVQueueInfo::GetAVQueueId() const
72 {
73     return avQueueId_;
74 }
75 
SetAVQueueImage(const std::shared_ptr<AVSessionPixelMap> & avQueueImage)76 void AVQueueInfo::SetAVQueueImage(const std::shared_ptr<AVSessionPixelMap>& avQueueImage)
77 {
78     avQueueImage_ = avQueueImage;
79 }
80 
GetAVQueueImage() const81 std::shared_ptr<AVSessionPixelMap> AVQueueInfo::GetAVQueueImage() const
82 {
83     return avQueueImage_;
84 }
85 
SetAVQueueLength(const int32_t avQueueLength)86 void AVQueueInfo::SetAVQueueLength(const int32_t avQueueLength)
87 {
88     avQueueLength_ = avQueueLength;
89 }
90 
GetAVQueueLength() const91 int32_t AVQueueInfo::GetAVQueueLength() const
92 {
93     return avQueueLength_;
94 }
95 
SetAVQueueImageUri(const std::string & avQueueImageUri)96 void AVQueueInfo::SetAVQueueImageUri(const std::string& avQueueImageUri)
97 {
98     avQueueImageUri_ = avQueueImageUri;
99 }
100 
GetAVQueueImageUri() const101 std::string AVQueueInfo::GetAVQueueImageUri() const
102 {
103     return avQueueImageUri_;
104 }
105 } // namespace OHOS::AVSession