• 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 I_CODEC_SERVICE_H
17 #define I_CODEC_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 #include "meta/meta.h"
26 #include "buffer/avbuffer.h"
27 #include "buffer/avbuffer_queue.h"
28 #include "buffer/avbuffer_queue_consumer.h"
29 #include "buffer/avbuffer_queue_define.h"
30 #include "buffer/avbuffer_queue_producer.h"
31 #include "foundation/multimedia/drm_framework/services/drm_service/ipc/i_keysession_service.h"
32 
33 namespace OHOS {
34 namespace MediaAVCodec {
35 class ICodecService {
36 public:
37     virtual ~ICodecService() = default;
38 
39     virtual int32_t Init(AVCodecType type, bool isMimeType,
40         const std::string &name, API_VERSION apiVersion = API_VERSION::API_VERSION_10) = 0;
41     virtual int32_t Configure(const Format &format) = 0;
42     virtual int32_t Start() = 0;
43     virtual int32_t Stop() = 0;
44     virtual int32_t Flush() = 0;
45     virtual int32_t Reset() = 0;
46     virtual int32_t Release() = 0;
47     virtual int32_t NotifyEos() = 0;
48     virtual sptr<Surface> CreateInputSurface() = 0;
49     virtual int32_t SetOutputSurface(sptr<Surface> surface) = 0;
50     virtual int32_t QueueInputBuffer(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) = 0;
51     virtual int32_t QueueInputBuffer(uint32_t index) = 0;
52     virtual int32_t GetOutputFormat(Format &format) = 0;
53     virtual int32_t ReleaseOutputBuffer(uint32_t index, bool render = false) = 0;
54     virtual int32_t SetParameter(const Format &format) = 0;
55     virtual int32_t SetCallback(const std::shared_ptr<AVCodecCallback> &callback) = 0;
56     virtual int32_t SetCallback(const std::shared_ptr<MediaCodecCallback> &callback) = 0;
57     virtual int32_t GetInputFormat(Format &format) = 0;
SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> & keySession,const bool svpFlag)58     virtual int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession,
59         const bool svpFlag)
60     {
61         (void)keySession;
62         (void)svpFlag;
63         return AVCODEC_ERROR_EXTEND_START;
64     }
65 
66     /* API11 audio codec interface */
CreateCodecByName(const std::string & name)67     virtual int32_t CreateCodecByName(const std::string &name)
68     {
69         (void)name;
70         return AVCODEC_ERROR_EXTEND_START;
71     }
72 
Configure(const std::shared_ptr<Media::Meta> & meta)73     virtual int32_t Configure(const std::shared_ptr<Media::Meta> &meta)
74     {
75         (void)meta;
76         return AVCODEC_ERROR_EXTEND_START;
77     }
SetParameter(const std::shared_ptr<Media::Meta> & parameter)78     virtual int32_t SetParameter(const std::shared_ptr<Media::Meta> &parameter)
79     {
80         (void)parameter;
81         return AVCODEC_ERROR_EXTEND_START;
82     }
GetOutputFormat(std::shared_ptr<Media::Meta> & parameter)83     virtual int32_t GetOutputFormat(std::shared_ptr<Media::Meta> &parameter)
84     {
85         (void)parameter;
86         return AVCODEC_ERROR_EXTEND_START;
87     }
88 
SetOutputBufferQueue(const sptr<Media::AVBufferQueueProducer> & bufferQueueProducer)89     virtual int32_t SetOutputBufferQueue(const sptr<Media::AVBufferQueueProducer> &bufferQueueProducer)
90     {
91         (void)bufferQueueProducer;
92         return AVCODEC_ERROR_EXTEND_START;
93     }
Prepare()94     virtual int32_t Prepare()
95     {
96         return AVCODEC_ERROR_EXTEND_START;
97     }
GetInputBufferQueue()98     virtual sptr<Media::AVBufferQueueProducer> GetInputBufferQueue()
99     {
100         return nullptr;
101     }
ProcessInputBuffer()102     virtual void ProcessInputBuffer()
103     {
104         return;
105     }
GetStatus()106     virtual bool GetStatus()
107     {
108         return false;
109     }
110 };
111 } // namespace MediaAVCodec
112 } // namespace OHOS
113 #endif // I_CODEC_SERVICE_H