• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SRC_BASE_H
17 #define SRC_BASE_H
18 
19 #include <cstdint>
20 #include <gst/gst.h>
21 #include "avcodec_common.h"
22 #include "avsharedmemory.h"
23 #include "codec_common.h"
24 #include "format.h"
25 #include "i_avcodec_engine.h"
26 #include "media_errors.h"
27 #include "surface.h"
28 
29 namespace OHOS {
30 namespace Media {
31 enum SrcType : int32_t {
32     SRC_TYPE_BYTEBUFFER = 0,
33     SRC_TYPE_SURFACE,
34 };
35 
36 class SrcBase {
37 public:
38     virtual ~SrcBase() = default;
39 
40     virtual int32_t Init() = 0;
41     virtual int32_t Configure(const std::shared_ptr<ProcessorConfig> &config) = 0;
42 
CreateInputSurface(const std::shared_ptr<ProcessorConfig> & inputConfig)43     virtual sptr<Surface> CreateInputSurface(const std::shared_ptr<ProcessorConfig> &inputConfig)
44     {
45         (void)inputConfig;
46         return nullptr;
47     }
48 
Start()49     virtual int32_t Start()
50     {
51         return MSERR_OK;
52     }
53 
Stop()54     virtual int32_t Stop()
55     {
56         return MSERR_OK;
57     }
58 
Flush()59     virtual int32_t Flush()
60     {
61         return MSERR_OK;
62     }
63 
NotifyEos()64     virtual int32_t NotifyEos()
65     {
66         return MSERR_INVALID_OPERATION;
67     }
68 
Needflush()69     virtual bool Needflush()
70     {
71         return true;
72     }
73 
GetElement()74     virtual const GstElement *GetElement()
75     {
76         return src_;
77     }
78 
GetInputBuffer(uint32_t index)79     virtual std::shared_ptr<AVSharedMemory> GetInputBuffer(uint32_t index)
80     {
81         (void)index;
82         return nullptr;
83     }
84 
QueueInputBuffer(uint32_t index,AVCodecBufferInfo info,AVCodecBufferFlag flag)85     virtual int32_t QueueInputBuffer(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag)
86     {
87         (void)index;
88         (void)info;
89         (void)flag;
90         return MSERR_INVALID_OPERATION;
91     }
92 
SetParameter(const Format & format)93     virtual int32_t SetParameter(const Format &format)
94     {
95         (void)format;
96         return MSERR_OK;
97     }
98 
SetCallback(const std::weak_ptr<IAVCodecEngineObs> & obs)99     virtual int32_t SetCallback(const std::weak_ptr<IAVCodecEngineObs> &obs)
100     {
101         (void)obs;
102         return MSERR_OK;
103     }
104 
105 protected:
106     GstElement *src_ = nullptr;
107 };
108 } // namespace Media
109 } // namespace OHOS
110 #endif // SRC_BASE_H