1 /*
2  * Copyright (c) 2022-2022 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 HISTREAMER_PIPELINE_VIDEO_ASYNC_DECODER_FILTER_H
17 #define HISTREAMER_PIPELINE_VIDEO_ASYNC_DECODER_FILTER_H
18 
19 #ifdef VIDEO_SUPPORT
20 
21 #include "pipeline/filters/codec/codec_filter_base.h"
22 
23 namespace OHOS {
24 namespace Media {
25 namespace Pipeline {
26 class VideoDecoderFilter : public CodecFilterBase {
27 public:
28     explicit VideoDecoderFilter(const std::string& name, std::shared_ptr<CodecMode> codecMode);
29     ~VideoDecoderFilter() override;
30 
31     ErrorCode Prepare() override;
32 
33     ErrorCode Start() override;
34 
35     ErrorCode Stop() override;
36 
37     void FlushStart() override;
38 
39     void FlushEnd() override;
40 
41     bool Negotiate(const std::string& inPort,
42                    const std::shared_ptr<const Plugin::Capability>& upstreamCap,
43                    Plugin::Capability& negotiatedCap,
44                    const Plugin::Meta& upstreamParams,
45                    Plugin::Meta& downstreamParams) override;
46 
47     bool Configure(const std::string& inPort, const std::shared_ptr<const Plugin::Meta>& upstreamMeta,
48                    Plugin::Meta& upstreamParams, Plugin::Meta& downstreamParams) override;
49 
50     void OnInputBufferDone(const std::shared_ptr<Plugin::Buffer>& input) override;
51 
52     void OnOutputBufferDone(const std::shared_ptr<Plugin::Buffer>& output) override;
53 
54 private:
55     uint32_t GetOutBufferPoolSize() override;
56 
57     std::shared_ptr<Allocator> GetAllocator() override;
58 
59     Plugin::Meta GetNegotiateParams(const Plugin::Meta& upstreamParams) override;
60 
61     uint32_t CalculateBufferSize(const std::shared_ptr<const Plugin::Meta>& meta) override;
62 
63     void UpdateParams(const std::shared_ptr<const Plugin::Meta>& upMeta, std::shared_ptr<Plugin::Meta>& meta) override;
64 };
65 }
66 }
67 }
68 #endif // VIDEO_SUPPORT
69 #endif // HISTREAMER_PIPELINE_VIDEO_ASYNC_DECODER_FILTER_H