• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_
16 #define FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_
17 #include <memory>
18 #include <vector>
19 #include "mtp_driver.h"
20 #include "mtp_operation_context.h"
21 #include "mtp_operation_utils.h"
22 #include "mtp_packet.h"
23 #include "payload_data.h"
24 namespace OHOS {
25 namespace Media {
26 
27 class MtpOperation {
28 public:
29     MtpOperation();
30     ~MtpOperation() = default;
31     int32_t Execute();
32     void Stop();
33 
34 private:
35     void Init();
36     void ResetOperation();
37     uint16_t GetPayloadData(std::shared_ptr<MtpOperationContext> &context,
38         std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode);
39     uint16_t GetPayloadDataSub(std::shared_ptr<MtpOperationContext> &context,
40         std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode);
41     uint16_t GetPayloadDataMore(std::shared_ptr<MtpOperationContext> &context,
42         std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode);
43     void ReceiveRequestPacket(int &errorCode);
44     void SendObjectData(int &errorCode);
45     void RecevieObjectData(int &errorCode);
46     void SendMakeResponsePacket(int &errorCode);
47     void ReceiveI2Rdata(int &errorCode);
48     void SendR2Idata(int &errorCode);
49     void AddStorage(std::shared_ptr<Storage> &storage);
50     void RemoveStorage(std::shared_ptr<Storage> &storage);
51     void DealRequest(uint16_t operationCode, int &errorCode);
52 
53 private:
54     std::shared_ptr<MtpOperationContext> mtpContextPtr_;
55     std::shared_ptr<MtpPacket> requestPacketPtr_;
56     std::shared_ptr<MtpPacket> dataPacketPtr_;
57     std::shared_ptr<MtpPacket> responsePacketPtr_;
58     std::shared_ptr<MtpOperationUtils> operationUtils_;
59     std::shared_ptr<MtpDriver> mtpDriver_;
60     std::shared_ptr<PayloadData> dataPayloadData_;
61     uint16_t responseCode_;
62 };
63 } // namespace Media
64 } // namespace OHOS
65 #endif  // FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_
66