• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 COMMON_MOCK_H
17 #define COMMON_MOCK_H
18 
19 #include <string>
20 #include "avformat_mock.h"
21 #include "native_avcodec_base.h"
22 #include "nocopyable.h"
23 #include "surface.h"
24 
25 namespace OHOS {
26 namespace MediaAVCodec {
27 class SurfaceMock : public NoCopyable {
28 public:
29     virtual ~SurfaceMock() = default;
30 };
31 
32 class AVMemoryMock : public NoCopyable {
33 public:
34     virtual ~AVMemoryMock() = default;
35     virtual uint8_t *GetAddr() const = 0;
36     virtual int32_t GetSize() const = 0;
37     virtual uint32_t GetFlags() const = 0;
38 };
39 
40 class AVCodecCallbackMock : public NoCopyable {
41 public:
42     virtual ~AVCodecCallbackMock() = default;
43     virtual void OnError(int32_t errorCode) = 0;
44     virtual void OnStreamChanged(std::shared_ptr<FormatMock> format) = 0;
45     virtual void OnNeedInputData(uint32_t index, std::shared_ptr<AVMemoryMock> data) = 0;
46     virtual void OnNewOutputData(uint32_t index, std::shared_ptr<AVMemoryMock> data, OH_AVCodecBufferAttr attr) = 0;
47 };
48 
49 class __attribute__((visibility("default"))) SurfaceMockFactory {
50 public:
51     static std::shared_ptr<SurfaceMock> CreateSurface();
52     static std::shared_ptr<SurfaceMock> CreateSurface(sptr<Surface> &surface);
53 
54 private:
55     SurfaceMockFactory() = delete;
56     ~SurfaceMockFactory() = delete;
57 };
58 } // namespace MediaAVCodec
59 } // namespace OHOS
60 #endif // COMMON_MOCK_H