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/send_object_data.h"
16 #include "media_log.h"
17 #include "media_mtp_utils.h"
18 #include "mtp_packet_tools.h"
19 #include "mtp_storage_manager.h"
20 using namespace std;
21 namespace OHOS {
22 namespace Media {
SendObjectData(std::shared_ptr<MtpOperationContext> & context)23 SendObjectData::SendObjectData(std::shared_ptr<MtpOperationContext> &context)
24     : PayloadData(context)
25 {
26 }
27 
~SendObjectData()28 SendObjectData::~SendObjectData()
29 {
30 }
31 
Parser(const std::vector<uint8_t> & buffer,int32_t readSize)32 int SendObjectData::Parser(const std::vector<uint8_t> &buffer, int32_t readSize)
33 {
34     if ((context_ == nullptr) || (!MtpStorageManager::GetInstance()->HasStorage())) {
35         MEDIA_ERR_LOG("SendObjectData::parser null or storage");
36         return MTP_INVALID_OBJECTHANDLE_CODE;
37     }
38     return MTP_SUCCESS;
39 }
40 
Maker(std::vector<uint8_t> & outBuffer)41 int SendObjectData::Maker(std::vector<uint8_t> &outBuffer)
42 {
43     return MTP_SUCCESS;
44 }
45 
CalculateSize()46 uint32_t SendObjectData::CalculateSize()
47 {
48     std::vector<uint8_t> tmpVar;
49     int res = Maker(tmpVar);
50     if (res != MTP_SUCCESS) {
51         return res;
52     }
53     return tmpVar.size();
54 }
55 } // namespace Media
56 } // namespace OHOS