• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 #include "codec_factory.h"
17 #include "audio_aac_codec.h"
18 #include "audio_g711_codec.h"
19 #include "sharing_log.h"
20 
21 namespace OHOS {
22 namespace Sharing {
CreateAudioEncoder(CodecId format)23 std::shared_ptr<AudioEncoder> CodecFactory::CreateAudioEncoder(CodecId format)
24 {
25     SHARING_LOGD("trace.");
26     std::shared_ptr<AudioEncoder> encoder;
27 
28     switch (format) {
29         case CODEC_G711A:
30             break;
31         case CODEC_G711U:
32             break;
33         default:
34             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
35             break;
36     }
37 
38     return encoder;
39 }
40 
CreateAudioDecoder(CodecId format)41 std::shared_ptr<AudioDecoder> CodecFactory::CreateAudioDecoder(CodecId format)
42 {
43     SHARING_LOGD("trace.");
44     std::shared_ptr<AudioDecoder> decoder;
45     switch (format) {
46         case CODEC_G711A:
47             decoder.reset(new AudioG711Decoder(G711_TYPE::G711_ALAW));
48             break;
49         case CODEC_G711U:
50             decoder.reset(new AudioG711Decoder(G711_TYPE::G711_ULAW));
51             break;
52         case CODEC_AAC:
53             decoder.reset(new AudioAACDecoder());
54             break;
55         default:
56             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
57             break;
58     }
59 
60     return decoder;
61 }
62 
CreateVideoEncoder(CodecId format)63 std::shared_ptr<VideoEncoder> CodecFactory::CreateVideoEncoder(CodecId format)
64 {
65     SHARING_LOGD("trace.");
66     std::shared_ptr<VideoEncoder> encoder;
67     switch (format) {
68         case CODEC_AAC:
69             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
70             break;
71         case CODEC_G711U:
72             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
73             break;
74         default:
75             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
76             break;
77     }
78 
79     return encoder;
80 }
81 
CreateVideoDecoder(CodecId format)82 std::shared_ptr<VideoDecoder> CodecFactory::CreateVideoDecoder(CodecId format)
83 {
84     SHARING_LOGD("trace.");
85     std::shared_ptr<VideoDecoder> decoder;
86     switch (format) {
87         case CODEC_AAC:
88             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
89             break;
90         case CODEC_G711U:
91             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
92             break;
93         default:
94             SHARING_LOGE("unsupported codec format %{public}d.", (int32_t)format);
95             break;
96     }
97 
98     return decoder;
99 }
100 } // namespace Sharing
101 } // namespace OHOS
102