1 /*
2  * Copyright (C) 2021 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 I_AVCODEC_SERVICE_H
17 #define I_AVCODEC_SERVICE_H
18 
19 #include <string>
20 #include "avcodec_common.h"
21 #include "avcodec_info.h"
22 #include "buffer/avsharedmemory.h"
23 #include "refbase.h"
24 #include "surface.h"
25 
26 namespace OHOS {
27 namespace Media {
28 class IAVCodecService {
29 public:
30     virtual ~IAVCodecService() = default;
31 
32     virtual int32_t InitParameter(AVCodecType type, bool isMimeType, const std::string &name) = 0;
33     virtual int32_t Configure(const Format &format) = 0;
34     virtual int32_t Prepare() = 0;
35     virtual int32_t Start() = 0;
36     virtual int32_t Stop() = 0;
37     virtual int32_t Flush() = 0;
38     virtual int32_t Reset() = 0;
39     virtual int32_t Release() = 0;
40     virtual int32_t NotifyEos() = 0;
41     virtual sptr<Surface> CreateInputSurface() = 0;
42     virtual int32_t SetOutputSurface(sptr<Surface> surface) = 0;
43     virtual std::shared_ptr<AVSharedMemory> GetInputBuffer(uint32_t index) = 0;
44     virtual int32_t QueueInputBuffer(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) = 0;
45     virtual std::shared_ptr<AVSharedMemory> GetOutputBuffer(uint32_t index) = 0;
46     virtual int32_t GetOutputFormat(Format &format) = 0;
47     virtual int32_t ReleaseOutputBuffer(uint32_t index, bool render = false) = 0;
48     virtual int32_t SetParameter(const Format &format) = 0;
49     virtual int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) = 0;
50 };
51 } // namespace Media
52 } // namespace OHOS
53 #endif // I_AVCODEC_SERVICE_H