1 /* 2 * Copyright (C) 2023 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 #ifndef AVBUFFER_MOCK_H 17 #define AVBUFFER_MOCK_H 18 19 #include <string> 20 #include "avcodec_common.h" 21 #include "avformat_mock.h" 22 #include "native_avbuffer.h" 23 #include "nocopyable.h" 24 #include "surface.h" 25 26 using AVBuffer = OHOS::Media::AVBuffer; 27 using Status = OHOS::Media::Status; 28 using MemoryFlag = OHOS::Media::MemoryFlag; 29 using MemoryType = OHOS::Media::MemoryType; 30 using AVAllocatorFactory = OHOS::Media::AVAllocatorFactory; 31 using AVAllocator = OHOS::Media::AVAllocator; 32 namespace OHOS { 33 namespace MediaAVCodec { 34 class AVBufferMock : public NoCopyable { 35 public: 36 virtual ~AVBufferMock() = default; 37 virtual uint8_t *GetAddr() = 0; 38 virtual int32_t GetCapacity() = 0; 39 virtual int32_t GetBufferAttr(OH_AVCodecBufferAttr &attr) = 0; 40 virtual int32_t SetBufferAttr(const OH_AVCodecBufferAttr &attr) = 0; 41 virtual std::shared_ptr<FormatMock> GetParameter() = 0; 42 virtual int32_t SetParameter(const std::shared_ptr<FormatMock> &format) = 0; 43 virtual sptr<SurfaceBuffer> GetNativeBuffer() = 0; 44 virtual int32_t Destroy() = 0; 45 }; 46 47 class __attribute__((visibility("default"))) AVBufferMockFactory { 48 public: 49 static std::shared_ptr<AVBufferMock> CreateAVBuffer(const int32_t &capacity); 50 static std::shared_ptr<AVBufferMock> CreateAVBuffer(std::shared_ptr<AVBuffer> buffer); 51 private: 52 AVBufferMockFactory() = delete; 53 ~AVBufferMockFactory() = delete; 54 }; 55 } // namespace MediaAVCodec 56 } // namespace OHOS 57 #endif // AVBUFFER_MOCK_H