• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #define HST_LOG_TAG "HstEngineFactory"
17 
18 #include "hst_engine_factory.h"
19 #include <memory>
20 #include "foundation/log.h"
21 #include "parameter.h"
22 #include "scene/player/standard/hiplayer_impl.h"
23 #include "scene/recorder/standard/hirecorder_impl.h"
24 
25 namespace OHOS {
26 namespace Media {
Score(Scene scene,const std::string & uri)27 int32_t HstEngineFactory::Score(Scene scene, const std::string& uri)
28 {
29     MEDIA_LOG_I("Score in");
30     if (scene == Scene::SCENE_PLAYBACK || scene == Scene::SCENE_RECORDER) {
31         char useHistreamer[10] = {0}; // 10 for system parameter usage
32         auto res = GetParameter("debug.media_service.histreamer", "0", useHistreamer,
33             sizeof(useHistreamer));
34         if (res == 1 && useHistreamer[0] == '1') {
35             MEDIA_LOG_I("enable histreamer");
36             return MAX_SCORE;
37         }
38     }
39     return MIN_SCORE;
40 }
41 
CreatePlayerEngine()42 std::unique_ptr<IPlayerEngine> HstEngineFactory::CreatePlayerEngine()
43 {
44     MEDIA_LOG_I("CreatePlayerEngine enter.");
45     auto player = std::unique_ptr<HiPlayerImpl>(new (std::nothrow) HiPlayerImpl());
46     if (player && player->Init() == ErrorCode::SUCCESS) {
47         return player;
48     }
49     return nullptr;
50 }
51 
CreateRecorderEngine()52 std::unique_ptr<IRecorderEngine> HstEngineFactory::CreateRecorderEngine()
53 {
54     MEDIA_LOG_I("CreateRecorderEngine enter.");
55 #ifdef RECORDER_SUPPORT
56     auto recorder = std::unique_ptr<Record::HiRecorderImpl>(new (std::nothrow) Record::HiRecorderImpl());
57     if (recorder && recorder->Init() == ErrorCode::SUCCESS) {
58         return recorder;
59     }
60 #endif
61     return nullptr;
62 }
63 
CreateAVMetadataHelperEngine()64 std::unique_ptr<IAVMetadataHelperEngine> HstEngineFactory::CreateAVMetadataHelperEngine()
65 {
66     MEDIA_LOG_W("CreateAVMetadataHelperEngine not supported now, return nullptr.");
67     return nullptr;
68 }
69 
CreateAVCodecEngine()70 std::unique_ptr<IAVCodecEngine> HstEngineFactory::CreateAVCodecEngine()
71 {
72     MEDIA_LOG_W("CreateAVCodecEngine not supported now, return nullptr.");
73     return nullptr;
74 }
75 
CreateAVCodecListEngine()76 std::unique_ptr<IAVCodecListEngine> HstEngineFactory::CreateAVCodecListEngine()
77 {
78     MEDIA_LOG_W("CreateAVCodecListEngine not supported now, return nullptr.");
79     return nullptr;
80 }
81 }  // namespace Media
82 }  // namespace OHOS
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87 
88 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
89 #define HST_EXPORT __declspec(dllexport)
90 #else
91 #if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
92 #define HST_EXPORT __attribute__((visibility("default")))
93 #else
94 #define HST_EXPORT
95 #endif
96 #endif
97 
CreateEngineFactory()98 HST_EXPORT OHOS::Media::IEngineFactory* CreateEngineFactory()
99 {
100     return new (std::nothrow) OHOS::Media::HstEngineFactory();
101 }
102 #undef HST_EXPORT
103 #ifdef __cplusplus
104 }
105 #endif