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 "playbin2_ctrler.h"
17 #include "media_errors.h"
18 #include "media_log.h"
19
20 namespace {
21 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "PlayBin2Ctrler"};
22 }
23
24 namespace OHOS {
25 namespace Media {
Create(PlayBinKind kind,const PlayBinCreateParam & createParam)26 std::shared_ptr<IPlayBinCtrler> IPlayBinCtrler::Create(
27 PlayBinKind kind, const PlayBinCreateParam &createParam)
28 {
29 if (kind != PlayBinKind::PLAYBIN2) {
30 return nullptr;
31 }
32
33 auto inst = std::make_shared<PlayBin2Ctrler>(createParam);
34 int32_t ret = inst->Init();
35 if (ret != MSERR_OK) {
36 MEDIA_LOGE("create playbin2ctrler failed");
37 return nullptr;
38 }
39
40 return inst;
41 }
42
~PlayBin2Ctrler()43 PlayBin2Ctrler::~PlayBin2Ctrler()
44 {
45 MEDIA_LOGD("enter dtor");
46 }
47
OnInit()48 int32_t PlayBin2Ctrler::OnInit()
49 {
50 playbin_ = reinterpret_cast<GstPipeline *>(gst_element_factory_make("playbin", "playbin"));
51 if (playbin_ == nullptr) {
52 MEDIA_LOGE("create playbin failed");
53 return MSERR_UNKNOWN;
54 }
55
56 return MSERR_OK;
57 }
58 } // namespace Media
59 } // namespace OHOS