• 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 #include "avcodec_ability_singleton.h"
17 #include "avcodec_xml_parser.h"
18 #include "codec_plugins_capability.h"
19 #include "media_log.h"
20 #include "media_errors.h"
21 
22 namespace {
23     constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "AVCodecAbilitySingleton"};
24 }
25 
26 namespace OHOS {
27 namespace Media {
GetInstance()28 AVCodecAbilitySingleton& AVCodecAbilitySingleton::GetInstance()
29 {
30     static AVCodecAbilitySingleton instance;
31     return instance;
32 }
33 
AVCodecAbilitySingleton()34 AVCodecAbilitySingleton::AVCodecAbilitySingleton()
35 {
36     MEDIA_LOGD("0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
37 }
38 
~AVCodecAbilitySingleton()39 AVCodecAbilitySingleton::~AVCodecAbilitySingleton()
40 {
41     MEDIA_LOGD("0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
42 }
43 
ParseCodecXml()44 bool AVCodecAbilitySingleton::ParseCodecXml()
45 {
46     AVCodecXmlParser xmlParser;
47     bool ret = xmlParser.LoadConfiguration();
48     if (!ret) {
49         this->isParsered_ = false;
50         MEDIA_LOGE("AVCodecList LoadConfiguration failed");
51         return false;
52     }
53     ret = xmlParser.Parse();
54     if (!ret) {
55         isParsered_ = false;
56         MEDIA_LOGE("AVCodecList Parse failed.");
57         return false;
58     }
59     std::vector<CapabilityData> data = xmlParser.GetCapabilityDataArray();
60     capabilityDataArray_.insert(capabilityDataArray_.end(), data.begin(), data.end());
61     isParsered_ = true;
62     return true;
63 }
64 
ParseHardwareCapability()65 bool AVCodecAbilitySingleton::ParseHardwareCapability()
66 {
67     MEDIA_LOGD("ParseHardwareCapability start");
68     std::vector<CapabilityData> data = CodecPluginsCapability::GetInstance().GetCodecPluginsCapability();
69     capabilityDataArray_.insert(capabilityDataArray_.end(), data.begin(), data.end());
70     MEDIA_LOGD("ParseHardwareCapability end");
71     return true;
72 }
73 
IsParsered()74 bool AVCodecAbilitySingleton::IsParsered()
75 {
76     return this->isParsered_;
77 }
78 } // namespace Media
79 } // namespace OHOS
80