1 /*
2 * Copyright (C) 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 #define MLOG_TAG "MediaConvertFormatVo"
17
18 #include "convert_format_vo.h"
19
20 #include <sstream>
21
22 #include "media_log.h"
23
24 namespace OHOS::Media {
25 using namespace std;
Unmarshalling(MessageParcel & parcel)26 bool ConvertFormatReqBody::Unmarshalling(MessageParcel &parcel)
27 {
28 bool status = parcel.ReadInt32(this->fileId);
29 CHECK_AND_RETURN_RET_LOG(status, status, "read fileId failed");
30 status = parcel.ReadString(this->title);
31 CHECK_AND_RETURN_RET_LOG(status, status, "read title failed");
32 status = parcel.ReadString(this->extension);
33 CHECK_AND_RETURN_RET_LOG(status, status, "read extension failed");
34 return true;
35 }
36
Marshalling(MessageParcel & parcel) const37 bool ConvertFormatReqBody::Marshalling(MessageParcel &parcel) const
38 {
39 bool status = parcel.WriteInt32(this->fileId);
40 CHECK_AND_RETURN_RET_LOG(status, status, "write fileId failed");
41 status = parcel.WriteString(this->title);
42 CHECK_AND_RETURN_RET_LOG(status, status, "write title failed");
43 status = parcel.WriteString(this->extension);
44 CHECK_AND_RETURN_RET_LOG(status, status, "write extension failed");
45 return true;
46 }
47
ToString() const48 string ConvertFormatReqBody::ToString() const
49 {
50 std::stringstream ss;
51 ss << "{"
52 << "\"fileId\": \"" << std::to_string(this->fileId) << "\", "
53 << "\"title\": \"" << this->title << "\", "
54 << "\"extension\": \"" << this->extension << "\""
55 << "}";
56 return ss.str();
57 }
58 } // namespace OHOS::Media