1 /*
2 * Copyright (C) 2024 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 "media_log.h"
17 #include "composite_engine/composite_engine.h"
18 #include "composite_engine/impl/video_composite_engine.h"
19
20 namespace OHOS {
21 namespace Media {
22
23 namespace {
24 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_VIDEOEDITOR, "VideoComposite"};
25 }
26
27 static std::atomic_uint64_t g_compositeEngineId{ 1 };
CreateCompositeEngine(const std::shared_ptr<IDataCenter> & dc)28 std::shared_ptr<ICompositeEngine> ICompositeEngine::CreateCompositeEngine(const std::shared_ptr<IDataCenter>& dc)
29 {
30 if (dc == nullptr) {
31 MEDIA_LOGE("create video composite engine failed, dataCenter is nullptr.");
32 return nullptr;
33 }
34 auto engine = std::make_shared<VideoCompositeEngine>(g_compositeEngineId.fetch_add(1));
35 auto err = engine ->Init(dc);
36 if (err != VEFError::ERR_OK) {
37 MEDIA_LOGE("init composite engine[id = %{public}" PRIu64 "] failed, err: %{public}d.", engine->GetId(), err);
38 return nullptr;
39 }
40 return engine;
41 }
42
43 } // namespace Media
44 } // namespace OHOS
45