1 /*
2 * Copyright (C) 2022 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 "payload_data/object_event_data.h"
16 #include "media_log.h"
17 #include "media_mtp_utils.h"
18 #include "mtp_packet_tools.h"
19 using namespace std;
20 
21 namespace OHOS {
22 namespace Media {
ObjectEventData(shared_ptr<MtpOperationContext> & context)23 ObjectEventData::ObjectEventData(shared_ptr<MtpOperationContext> &context) : PayloadData(context)
24 {
25 }
26 
ObjectEventData()27 ObjectEventData::ObjectEventData()
28 {
29 }
30 
~ObjectEventData()31 ObjectEventData::~ObjectEventData()
32 {
33 }
34 
Parser(const vector<uint8_t> & buffer,int32_t readSize)35 int ObjectEventData::Parser(const vector<uint8_t> &buffer, int32_t readSize)
36 {
37     return MTP_SUCCESS;
38 }
39 
Maker(vector<uint8_t> & outBuffer)40 int ObjectEventData::Maker(vector<uint8_t> &outBuffer)
41 {
42     MtpPacketTool::PutUInt32(outBuffer, payload_);
43     return MTP_SUCCESS;
44 }
45 
CalculateSize()46 uint32_t ObjectEventData::CalculateSize()
47 {
48     std::vector<uint8_t> tmpVar;
49     int res = Maker(tmpVar);
50     if (res != MTP_SUCCESS) {
51         return res;
52     }
53 
54     return tmpVar.size();
55 }
56 
SetPayload(const int32_t payload)57 void ObjectEventData::SetPayload(const int32_t payload)
58 {
59     payload_ = payload;
60 }
61 } // namespace Media
62 } // namespace OHOS