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 #define HST_LOG_TAG "CodecFilterFactory"
17 
18 #include "pipeline/filters/codec/codec_filter_factory.h"
19 #include "pipeline/filters/codec/async_mode.h"
20 #include "pipeline/filters/codec/audio_decoder/audio_decoder_filter.h"
21 #include "pipeline/filters/codec/audio_encoder/audio_encoder_filter.h"
22 #include "pipeline/filters/codec/codec_filter_base.h"
23 #include "pipeline/filters/codec/video_decoder/video_decoder_filter.h"
24 #include "pipeline/filters/codec/sync_mode.h"
25 
26 namespace OHOS {
27 namespace Media {
28 namespace Pipeline {
CreateCodecFilter(const std::string & name,FilterCodecMode type)29 std::shared_ptr<CodecFilterBase> CreateCodecFilter(const std::string& name, FilterCodecMode type)
30 {
31     switch (type) {
32         case FilterCodecMode::AUDIO_SYNC_DECODER:
33             return std::make_shared<AudioDecoderFilter>(name, std::make_shared<SyncMode>("audioDec"));
34         case FilterCodecMode::AUDIO_ASYNC_DECODER:
35             return std::make_shared<AudioDecoderFilter>(name, std::make_shared<AsyncMode>("audioDec"));
36 #ifdef VIDEO_SUPPORT
37         case FilterCodecMode::VIDEO_SYNC_DECODER:
38             return std::make_shared<VideoDecoderFilter>(name, std::make_shared<SyncMode>("videoDec"));
39         case FilterCodecMode::VIDEO_ASYNC_DECODER:
40             return std::make_shared<VideoDecoderFilter>(name, std::make_shared<AsyncMode>("videoDec"));
41 #endif
42         default:
43             return nullptr;
44     }
45 }
46 } // Pipeline
47 } // Media
48 } // OHOS
49 
50