• 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 #include "../include/player_factory.h"
17 
18 #include "histreamer/hiplayer.h"
19 #include "media_log.h"
20 #include "parameter.h"
21 #include "player_impl.h"
22 
23 namespace OHOS {
24 namespace Media {
CreatePlayer(PlayerId playerId)25 std::shared_ptr<PlayerInterface> PlayerFactory::CreatePlayer(PlayerId playerId)
26 {
27     std::shared_ptr<PlayerInterface> player = nullptr;
28     switch (playerId) {
29         case PlayerId::HISTREAMER:
30             player = CreateHiPlayer();
31             break;
32         case PlayerId::PLAYER_LITE:
33         default:
34             player = std::shared_ptr<PlayerInterface>(new (std::nothrow) PlayerImpl());
35             break;
36     }
37     return player;
38 }
39 
CreatePlayer()40 std::shared_ptr<PlayerInterface> PlayerFactory::CreatePlayer()
41 {
42     MEDIA_INFO_LOG("create player");
43     char useHistreamer [10] = {0}; // 10 for system parameter usage
44     auto res = GetParameter("debug.media_service.histreamer", "0", useHistreamer,
45         10); // 10 for system parameter usage
46     if (res == 1 && useHistreamer[0] == '1') {
47         MEDIA_INFO_LOG("enable histreamer");
48         return CreateHiPlayer();
49     } else {
50         MEDIA_INFO_LOG("enable liteplayer");
51         return std::shared_ptr<PlayerInterface>(new (std::nothrow) PlayerImpl());
52     }
53 }
54 } // namespace Media
55 } // namespace OHOS