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 "mtp_test.h" 16 #include "media_log.h" 17 18 using namespace std; 19 namespace OHOS { 20 namespace Media { 21 std::shared_ptr<MtpTest> MtpTest::mtpTestInstance_{nullptr}; 22 std::mutex MtpTest::instanceLock_; MtpTest(void)23MtpTest::MtpTest(void) {} 24 GetInstance()25shared_ptr<MtpTest> MtpTest::GetInstance() 26 { 27 if (mtpTestInstance_ == nullptr) { 28 std::lock_guard<std::mutex> lockGuard(instanceLock_); 29 mtpTestInstance_ = make_shared<MtpTest>(); 30 } 31 32 return mtpTestInstance_; 33 } 34 setOutBuffer(std::vector<uint8_t> testData)35void MtpTest::setOutBuffer(std::vector<uint8_t> testData) 36 { 37 MEDIA_INFO_LOG("MtpTest::setOutBuffer IN"); 38 std::vector<uint8_t>().swap(testData_); 39 testData_.insert(testData_.end(), testData.begin(), testData.end()); 40 MEDIA_INFO_LOG("MtpTest::setOutBuffer OUT"); 41 } 42 getOutBuffer(std::vector<uint8_t> & outBuffer)43void MtpTest::getOutBuffer(std::vector<uint8_t> &outBuffer) 44 { 45 MEDIA_INFO_LOG("MtpTest::getOutBuffer IN"); 46 outBuffer.insert(outBuffer.end(), testData_.begin(), testData_.end()); 47 MEDIA_INFO_LOG("MtpTest::getOutBuffer OUT"); 48 } 49 } // namespace Media 50 } // namespace OHOS