• 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 HCODEC_TESTER_CAPI_H
17 #define HCODEC_TESTER_CAPI_H
18 
19 #include "tester_common.h"
20 #include "native_avcodec_base.h"
21 
22 namespace OHOS::MediaAVCodec {
23 struct TesterCapi : TesterCommon {
TesterCapiTesterCapi24     explicit TesterCapi(const CommandOpt& opt) : TesterCommon(opt) {}
25 
26 protected:
27     bool Create() override;
28     bool SetCallback() override;
29     bool GetInputFormat() override;
30     bool GetOutputFormat() override;
31     bool Start() override;
32     bool Stop() override;
33     bool Release() override;
34     bool Flush() override;
35     void ClearAllBuffer() override;
36     std::optional<uint32_t> GetInputIndex(Span& span) override;
37     bool QueueInput(uint32_t idx, OH_AVCodecBufferAttr attr) override;
38     std::optional<uint32_t> GetOutputIndex() override;
39     bool ReturnOutput(uint32_t idx) override;
40 
41     bool ConfigureEncoder() override;
42     bool CreateInputSurface() override;
43     bool NotifyEos() override;
44     bool RequestIDR() override;
45     std::optional<uint32_t> GetInputStride() override;
46 
47     bool SetOutputSurface(sptr<Surface>& surface) override;
48     bool ConfigureDecoder() override;
49 
50     static void OnError(OH_AVCodec *codec, int32_t errorCode, void *userData);
51     static void OnStreamChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData);
52     static void OnNeedInputData(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData);
53     static void OnNewOutputData(
54         OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData);
55 
56     OH_AVCodec *codec_ = nullptr;
57     std::list<std::pair<uint32_t, OH_AVMemory*>> inputList_;
58     std::list<std::tuple<uint32_t, OH_AVMemory*, OH_AVCodecBufferAttr>> outputList_;
59 
60     std::shared_ptr<OH_AVFormat> inputFmt_;
61 };
62 }
63 #endif