• 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 MEDIA_AVCODEC_CODEC_KEY_H
17 #define MEDIA_AVCODEC_CODEC_KEY_H
18 #include <string_view>
19 #include <string>
20 #include <unordered_set>
21 
22 namespace OHOS {
23 namespace MediaAVCodec {
24 class AVCodecCodecName {
25 public:
26     static constexpr std::string_view AUDIO_DECODER_MP3_NAME = "OH.Media.Codec.Decoder.Audio.Mpeg";
27     static constexpr std::string_view AUDIO_DECODER_AAC_NAME = "OH.Media.Codec.Decoder.Audio.AAC";
28     static constexpr std::string_view AUDIO_DECODER_OPUS_NAME = "OH.Media.Codec.Decoder.Audio.Opus";
29     static constexpr std::string_view AUDIO_DECODER_API9_AAC_NAME = "avdec_aac";
30     static constexpr std::string_view AUDIO_DECODER_VORBIS_NAME = "OH.Media.Codec.Decoder.Audio.Vorbis";
31     static constexpr std::string_view AUDIO_DECODER_FLAC_NAME = "OH.Media.Codec.Decoder.Audio.Flac";
32     static constexpr std::string_view AUDIO_DECODER_AMRNB_NAME = "OH.Media.Codec.Decoder.Audio.Amrnb";
33     static constexpr std::string_view AUDIO_DECODER_AMRWB_NAME = "OH.Media.Codec.Decoder.Audio.Amrwb";
34     static constexpr std::string_view AUDIO_DECODER_VIVID_NAME = "OH.Media.Codec.Decoder.Audio.Vivid";
35     static constexpr std::string_view AUDIO_DECODER_G711MU_NAME = "OH.Media.Codec.Decoder.Audio.G711mu";
36     static constexpr std::string_view AUDIO_DECODER_G711A_NAME = "OH.Media.Codec.Decoder.Audio.G711a";
37     static constexpr std::string_view AUDIO_DECODER_APE_NAME = "OH.Media.Codec.Decoder.Audio.Ape";
38     static constexpr std::string_view AUDIO_DECODER_L2HC_NAME = "OH.Media.Codec.Decoder.Audio.L2HC";
39     static constexpr std::string_view AUDIO_DECODER_LBVC_NAME = "OH.Media.Codec.Decoder.Audio.LBVC";
40     static constexpr std::string_view AUDIO_DECODER_COOK_NAME = "OH.Media.Codec.Decoder.Audio.COOK";
41     static constexpr std::string_view AUDIO_DECODER_AC3_NAME = "OH.Media.Codec.Decoder.Audio.AC3";
42     static constexpr std::string_view AUDIO_DECODER_RAW_NAME = "OH.Media.Codec.Decoder.Audio.Raw";
43 
44     static constexpr std::string_view AUDIO_ENCODER_FLAC_NAME = "OH.Media.Codec.Encoder.Audio.Flac";
45     static constexpr std::string_view AUDIO_ENCODER_OPUS_NAME = "OH.Media.Codec.Encoder.Audio.Opus";
46     static constexpr std::string_view AUDIO_ENCODER_G711MU_NAME = "OH.Media.Codec.Encoder.Audio.G711mu";
47     static constexpr std::string_view AUDIO_ENCODER_AAC_NAME = "OH.Media.Codec.Encoder.Audio.AAC";
48     static constexpr std::string_view AUDIO_ENCODER_VENDOR_AAC_NAME = "OH.Media.Codec.Encoder.Audio.Vendor.AAC";
49     static constexpr std::string_view AUDIO_ENCODER_L2HC_NAME = "OH.Media.Codec.Encoder.Audio.L2HC";
50     static constexpr std::string_view AUDIO_ENCODER_LBVC_NAME = "OH.Media.Codec.Encoder.Audio.LBVC";
51     static constexpr std::string_view AUDIO_ENCODER_AMRNB_NAME = "OH.Media.Codec.Encoder.Audio.Amrnb";
52     static constexpr std::string_view AUDIO_ENCODER_AMRWB_NAME = "OH.Media.Codec.Encoder.Audio.Amrwb";
53     static constexpr std::string_view AUDIO_ENCODER_API9_AAC_NAME = "avenc_aac";
54     static constexpr std::string_view AUDIO_ENCODER_MP3_NAME = "OH.Media.Codec.Encoder.Audio.Mp3";
55 
56     static constexpr std::string_view VIDEO_ENCODER_AVC_NAME = "OH.Media.Codec.Encoder.Video.AVC";
57     static constexpr std::string_view VIDEO_DECODER_AVC_NAME = "OH.Media.Codec.Decoder.Video.AVC";
58     static constexpr std::string_view VIDEO_DECODER_HEVC_NAME = "OH.Media.Codec.Decoder.Video.HEVC";
59     static constexpr std::string_view VIDEO_DECODER_MPEG2_NAME = "OH.Media.Codec.Decoder.Video.MPEG2";
60     static constexpr std::string_view VIDEO_DECODER_MPEG4_NAME = "OH.Media.Codec.Decoder.Video.MPEG4";
61     static constexpr std::string_view VIDEO_DECODER_H263_NAME = "OH.Media.Codec.Decoder.Video.H263";
62     static constexpr std::string_view VIDEO_DECODER_VVC_NAME = "OH.Media.Codec.Decoder.Video.VVC";
63     static constexpr std::string_view VIDEO_DECODER_RV30_NAME = "OH.Media.Codec.Decoder.Video.Rv30";
64     static constexpr std::string_view VIDEO_DECODER_RV40_NAME = "OH.Media.Codec.Decoder.Video.Rv40";
65 
GetAudioCodecOuterSupportTable()66     static const std::unordered_set<std::string_view> &GetAudioCodecOuterSupportTable()
67     {
68         static const std::unordered_set<std::string_view> OUTER_SUPPORT_TABLE = {
69             AUDIO_DECODER_AAC_NAME,
70             AUDIO_ENCODER_AAC_NAME,
71             AUDIO_DECODER_FLAC_NAME,
72             AUDIO_ENCODER_FLAC_NAME,
73             AUDIO_DECODER_VORBIS_NAME,
74             AUDIO_DECODER_AMRNB_NAME,
75             AUDIO_DECODER_MP3_NAME,
76             AUDIO_ENCODER_MP3_NAME,
77             AUDIO_DECODER_AMRWB_NAME,
78             AUDIO_DECODER_G711MU_NAME,
79             AUDIO_ENCODER_G711MU_NAME,
80             AUDIO_DECODER_G711A_NAME,
81             AUDIO_DECODER_APE_NAME,
82             AUDIO_DECODER_RAW_NAME,
83 #ifdef AV_CODEC_AUDIO_VIVID_CAPACITY
84             AUDIO_ENCODER_VENDOR_AAC_NAME,
85             AUDIO_DECODER_OPUS_NAME,
86             AUDIO_ENCODER_OPUS_NAME,
87             AUDIO_DECODER_VIVID_NAME,
88             AUDIO_ENCODER_AMRNB_NAME,
89             AUDIO_ENCODER_AMRWB_NAME
90 #endif
91         };
92         return OUTER_SUPPORT_TABLE;
93     }
94 
CheckAudioCodecNameSupportOuter(const std::string & name)95     static bool CheckAudioCodecNameSupportOuter(const std::string &name)
96     {
97         return GetAudioCodecOuterSupportTable().count(name);
98     }
99 
100 private:
101     AVCodecCodecName() = delete;
102     ~AVCodecCodecName() = delete;
103 };
104 } // namespace MediaAVCodec
105 } // namespace OHOS
106 #endif // MEDIA_AVCODEC_CODEC_KEY_H
107