diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md
deleted file mode 100755
index f09d98d..0000000
--- a/.gitee/ISSUE_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,13 +0,0 @@
-### 该问题是怎么引起的?
-
-
-
-### 重现步骤
-
-
-
-### 报错信息
-
-
-
-
diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
deleted file mode 100755
index 33948fd..0000000
--- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,15 +0,0 @@
-### 相关的Issue
-
-
-### 原因(目的、解决的问题等)
-
-
-### 描述(做了什么,变更了什么)
-
-
-### 测试用例(新增、改动、可能影响的功能)
-
-
-
-
-
diff --git a/BUILD.gn b/BUILD.gn
deleted file mode 100755
index 509c1e5..0000000
--- a/BUILD.gn
+++ /dev/null
@@ -1,45 +0,0 @@
-import("//build/lite/config/component/lite_component.gni")
-
-shared_library("camera") {
- sources = [
- "camera_ability.cpp",
- "camera_config.cpp",
- "camera_device.cpp",
- "camera_impl.cpp",
- "camera_kit.cpp",
- "camera_manager.cpp",
- "camera_service.cpp",
- "event_handler.cpp",
- "frame_config.cpp",
- ]
- cflags = ["-fPIC"]
- cflags += ["-Wall"]
- cflags_cc = cflags
- include_dirs = [
- "//base/security/interfaces/kits/iam_lite",
- "//foundation/multimedia/hals/camera_lite",
- "//drivers/hdf/lite/hdi/codec/include"
- ]
-
- ldflags = ["-lstdc++"]
- ldflags += ["-lcodec"]
- ldflags += ["-lhdi_media"]
- ldflags += ["-L$ohos_root_path/$root_out_dir"]
- public_configs = [":camera_external_library_config"]
- deps = [
- "//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared",
- "//base/security/services/iam_lite/pms_client:pms_client",
- "//third_party/bounds_checking_function:libsec_shared",
- "$ohos_vendor_adapter_dir/../../hardware:hardware_media_sdk",
- "$ohos_vendor_adapter_dir/../../middleware:middleware_source_sdk",
- "$ohos_vendor_adapter_dir/hals/multimedia:hdi_media",
- ]
- public_deps = [
- "//foundation/graphic/lite/frameworks/surface:surface",
- ]
-}
-
-config("camera_external_library_config") {
- include_dirs = ["//foundation/multimedia/interfaces/kits/camera_lite"]
- include_dirs += ["//foundation/multimedia/utils/lite/include"]
-}
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d15cfde
--- /dev/null
+++ b/README.md
@@ -0,0 +1,49 @@
+# CAMERA\_LITE
+
+- [Introduction](#section11660541593)
+- [Directory Structure](#section56984451495)
+- [Usage](#section1648194512427)
+- [Constraints](#section161941989596)
+- [Repositories Involved](#section105062051111614)
+
+## Introduction
+
+This repository provides the camera capability.
+
+**Figure 1** Position of this repository \(in the dotted blue box\) in the multimedia subsystem
+-in-the-multimedia-subsystem.png "position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem")
+
+## Directory Structure
+
+```
+/foundation/multimedia/camera_lite
+├── frameworks # Framework code
+└── interfaces # APIs
+ └── kits # External APIs
+```
+
+## Usage
+
+Build a single repository in the root directory.
+
+```
+# Select the development board.
+hb set
+# Build this repository.
+hb build camera_lite
+```
+
+## Constraints
+
+C++ 11 or later
+
+## Repositories Involved
+
+/hmf/multimedia/audio\_lite
+
+/hmf/multimedia/media\_lite
+
+/hmf/multimedia/utils\_lite
+
+/hmf/multimedia/service\_lite
+
diff --git a/README_zh.md b/README_zh.md
new file mode 100644
index 0000000..a247a4f
--- /dev/null
+++ b/README_zh.md
@@ -0,0 +1,49 @@
+# 媒体子系统CAMERA\_LITE组件
+
+- [简介](#section11660541593)
+- [目录](#section56984451495)
+- [使用说明](#section1648194512427)
+- [约束](#section161941989596)
+- [相关仓](#section105062051111614)
+
+## 简介
+
+Camera\_Lite组件提供相机能力的支持。
+
+**图 1** 媒体子系统架构(蓝色虚线框是camera\_lite)
+.png "媒体子系统架构(蓝色虚线框是camera_lite)")
+
+## 目录
+
+```
+/foundation/multimedia/camera_lite
+├── frameworks # 框架代码
+└── interfaces # 接口
+ └── kits # 对外接口
+```
+
+## 使用说明
+
+单仓的编译构建,在根目录下进行整仓的构建和编译
+
+```
+# 开发板选择
+hb set
+# 单仓构建和编译
+hb build camera_lite
+```
+
+## 约束
+
+C++11版本或以上
+
+## 相关仓
+
+/hmf/multimedia/audio\_lite
+
+/hmf/multimedia/media\_lite
+
+/hmf/multimedia/utils\_lite
+
+/hmf/multimedia/service\_lite
+
diff --git a/figures/position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem.png b/figures/position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem.png
new file mode 100644
index 0000000..68f86ae
Binary files /dev/null and b/figures/position-of-this-repository-(in-the-dotted-blue-box)-in-the-multimedia-subsystem.png differ
diff --git a/figures/媒体子系统架构(蓝色虚线框是camera_lite).png b/figures/媒体子系统架构(蓝色虚线框是camera_lite).png
new file mode 100644
index 0000000..e7b66db
Binary files /dev/null and b/figures/媒体子系统架构(蓝色虚线框是camera_lite).png differ
diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn
new file mode 100644
index 0000000..9e44287
--- /dev/null
+++ b/frameworks/BUILD.gn
@@ -0,0 +1,43 @@
+import("//build/lite/config/component/lite_component.gni")
+
+shared_library("camera_lite") {
+ sources = [
+ "camera_ability.cpp",
+ "camera_config.cpp",
+ "camera_device.cpp",
+ "camera_impl.cpp",
+ "camera_kit.cpp",
+ "camera_manager.cpp",
+ "camera_service.cpp",
+ "event_handler.cpp",
+ "frame_config.cpp",
+ ]
+ cflags = [ "-fPIC" ]
+ cflags += [ "-Wall" ]
+ cflags_cc = cflags
+ include_dirs = [
+ "//base/security/permission/interfaces/kits/permission_lite",
+ "//drivers/peripheral/codec/interfaces/include",
+ "//foundation/multimedia/utils/lite/hals",
+ ]
+
+ ldflags = [ "-lstdc++" ]
+ ldflags += [ "-lcodec" ]
+ ldflags += [ "-lhdi_media" ]
+ ldflags += [ "-L$ohos_root_path/$root_out_dir" ]
+ public_configs = [ ":camera_external_library_config" ]
+ deps = [
+ "$ohos_vendor_adapter_dir:hardware_media_sdk",
+ "$ohos_vendor_adapter_dir/../modules/middleware:middleware_source_sdk",
+ "$ohos_vendor_adapter_dir/multimedia:libhdi_media",
+ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
+ "//base/security/permission/services/permission_lite/pms_client:pms_client",
+ "//third_party/bounds_checking_function:libsec_shared",
+ ]
+ public_deps = [ "//foundation/graphic/surface:lite_surface" ]
+}
+
+config("camera_external_library_config") {
+ include_dirs = [ "//foundation/multimedia/camera_lite/interfaces/kits" ]
+ include_dirs += [ "//foundation/multimedia/utils/lite/include" ]
+}
diff --git a/camera_ability.cpp b/frameworks/camera_ability.cpp
similarity index 93%
rename from camera_ability.cpp
rename to frameworks/camera_ability.cpp
index c911d8d..72d2296 100755
--- a/camera_ability.cpp
+++ b/frameworks/camera_ability.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
diff --git a/camera_config.cpp b/frameworks/camera_config.cpp
similarity index 94%
rename from camera_config.cpp
rename to frameworks/camera_config.cpp
index d1dfd7e..a205597 100755
--- a/camera_config.cpp
+++ b/frameworks/camera_config.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
diff --git a/camera_device.cpp b/frameworks/camera_device.cpp
similarity index 87%
rename from camera_device.cpp
rename to frameworks/camera_device.cpp
index 18f222b..f0a1263 100755
--- a/camera_device.cpp
+++ b/frameworks/camera_device.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -15,15 +15,15 @@
#include "camera_device.h"
-#include
-#include
-
#include "codec_interface.h"
#include "hal_display.h"
#include "media_log.h"
#include "meta_data.h"
#include "securec.h"
+#include
+#include
+
using namespace OHOS;
using namespace OHOS::Media;
using namespace std;
@@ -33,10 +33,24 @@ const int32_t KEY_TIME_US = 2; // "timeUs"
namespace OHOS {
namespace Media {
-inline PicSize Convert2CodecSize(CameraPicSize size)
+inline PicSize Convert2CodecSize(int32_t width, int32_t height)
{
- return (PicSize)size;
+ struct SizeMap {
+ PicSize res_;
+ int32_t width_;
+ int32_t height_;
+ };
+ static SizeMap sizeMap[] = {{Resolution_CIF, 352, 288}, {Resolution_360P, 640, 360},
+ {Resolution_D1_PAL, 720, 576}, {Resolution_D1_NTSC, 720, 480},
+ {Resolution_720P, 1280, 720}, {Resolution_1080P, 1920, 1080}};
+ for (uint32_t i = 0; i < sizeof(sizeMap) / sizeof(SizeMap); i++) {
+ if (sizeMap[i].width_ == width && sizeMap[i].height_ == height) {
+ return sizeMap[i].res_;
+ }
+ }
+ return Resolution_INVALID;
}
+
static int32_t SetVencSource(CODEC_HANDLETYPE codecHdl, uint32_t deviceId)
{
Param param = {.key = KEY_DEVICE_ID, .val = (void *)&deviceId, .size = sizeof(uint32_t)};
@@ -86,7 +100,7 @@ static int32_t
param[paramIndex].size = sizeof(Profile);
paramIndex++;
- PicSize picSize = Convert2CodecSize(attr->size);
+ PicSize picSize = Convert2CodecSize(attr->width, attr->height);
MEDIA_DEBUG_LOG("picSize=%d", picSize);
param[paramIndex].key = KEY_VIDEO_PIC_SIZE;
param[paramIndex].val = &picSize;
@@ -115,7 +129,8 @@ static int32_t
return HAL_MEDIA_OK;
}
-static int32_t CameraCreateJpegEnc(uint32_t srcDev, HalVideoProcessorAttr *attr, CODEC_HANDLETYPE *codecHdl)
+static int32_t
+ CameraCreateJpegEnc(FrameConfig &fc, uint32_t srcDev, HalVideoProcessorAttr *attr, CODEC_HANDLETYPE *codecHdl)
{
const char *videoEncName = "codec.jpeg.hardware.encoder";
const uint32_t maxParamNum = 5;
@@ -134,7 +149,7 @@ static int32_t CameraCreateJpegEnc(uint32_t srcDev, HalVideoProcessorAttr *attr,
param[paramIndex].size = sizeof(AvCodecMime);
paramIndex++;
- PicSize picSize = Convert2CodecSize(attr->size);
+ PicSize picSize = Convert2CodecSize(attr->width, attr->height);
param[paramIndex].key = KEY_VIDEO_PIC_SIZE;
param[paramIndex].val = &picSize;
param[paramIndex].size = sizeof(PicSize);
@@ -145,6 +160,21 @@ static int32_t CameraCreateJpegEnc(uint32_t srcDev, HalVideoProcessorAttr *attr,
return HAL_MEDIA_ERR;
}
+ int32_t qfactor = -1;
+ fc.GetParameter(PARAM_KEY_IMAGE_ENCODE_QFACTOR, qfactor);
+ if (qfactor != -1) {
+ MEDIA_DEBUG_LOG("qfactor=%d", qfactor);
+ Param jpegParam = {
+ .key = KEY_IMAGE_Q_FACTOR,
+ .val = &qfactor,
+ .size = sizeof(qfactor)
+ };
+ ret = CodecSetParameter(*codecHdl, &jpegParam, 1);
+ if (ret != 0) {
+ MEDIA_ERR_LOG("CodecSetParameter set jpeg qfactor failed.(ret=%u)", ret);
+ }
+ }
+
ret = SetVencSource(*codecHdl, srcDev);
if (ret != 0) {
MEDIA_ERR_LOG("Set video encoder source failed.");
@@ -172,9 +202,8 @@ static int32_t CopyCodecOutput(void *dst, uint32_t *size, OutputInfo *buffer)
static int32_t FindAvailProcessorIdx(Surface &surface, vector &attrs)
{
- CameraPicSize picSize = HalConvert2StandardSize(surface.GetWidth(), surface.GetHeight());
for (uint32_t i = 0; i < attrs.size(); i++) {
- if (attrs[i].size == picSize) {
+ if (attrs[i].width == surface.GetWidth() && attrs[i].height == surface.GetHeight()) {
return i;
}
}
@@ -412,7 +441,7 @@ int32_t CaptureAssistant::SetFrameConfig(FrameConfig &fc,
return MEDIA_ERR;
}
uint32_t deviceId = HalGetProcessorDeviceId(hdls[idx]);
- int32_t ret = CameraCreateJpegEnc(deviceId, &attrs[idx], &vencHdl_);
+ int32_t ret = CameraCreateJpegEnc(fc, deviceId, &attrs[idx], &vencHdl_);
if (ret != HAL_MEDIA_OK) {
MEDIA_ERR_LOG("Create capture venc failed.");
return MEDIA_ERR;
@@ -504,7 +533,8 @@ int32_t CameraDevice::Initialize(CameraAbility &ability)
for (int i = 0; i < size; i++) {
prcessorAttrs_.emplace_back(attrs[i]);
prcessorHdls_.emplace_back(hdls[i]);
- range.emplace_back(attrs[i].size);
+ CameraPicSize tmpSize = {.width = attrs[i].width, .height = attrs[i].height};
+ range.emplace_back(tmpSize);
}
ability.SetParameterRange(PARAM_KEY_SIZE, range);
diff --git a/camera_device.h b/frameworks/camera_device.h
similarity index 93%
rename from camera_device.h
rename to frameworks/camera_device.h
index a64f84b..cfd8bb5 100755
--- a/camera_device.h
+++ b/frameworks/camera_device.h
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/camera_impl.cpp b/frameworks/camera_impl.cpp
similarity index 94%
rename from camera_impl.cpp
rename to frameworks/camera_impl.cpp
index 0d3a953..42971ce 100755
--- a/camera_impl.cpp
+++ b/frameworks/camera_impl.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/camera_impl.h b/frameworks/camera_impl.h
similarity index 91%
rename from camera_impl.h
rename to frameworks/camera_impl.h
index b5f66c7..9654898 100755
--- a/camera_impl.h
+++ b/frameworks/camera_impl.h
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/camera_kit.cpp b/frameworks/camera_kit.cpp
similarity index 88%
rename from camera_kit.cpp
rename to frameworks/camera_kit.cpp
index 02306b5..250ac2b 100755
--- a/camera_kit.cpp
+++ b/frameworks/camera_kit.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,7 +29,7 @@ CameraKit::~CameraKit() {}
CameraKit *CameraKit::GetInstance()
{
- if (CheckPermission(0, "ohos.permission.CAMERA") != GRANTED) {
+ if (CheckSelfPermission("ohos.permission.CAMERA") != GRANTED) {
MEDIA_WARNING_LOG("Process can not access camera.");
return nullptr;
}
diff --git a/camera_manager.cpp b/frameworks/camera_manager.cpp
similarity index 94%
rename from camera_manager.cpp
rename to frameworks/camera_manager.cpp
index c0c5e82..f046d95 100755
--- a/camera_manager.cpp
+++ b/frameworks/camera_manager.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -127,6 +127,7 @@ public:
auto p = cameraMapCache_.find(cameraId);
if (p == cameraMapCache_.end()) {
handler.Post([&callback, &cameraId] { callback.OnCreateFailed(cameraId, MEDIA_ERR); });
+ return;
}
p->second->RegistCb(callback, handler);
cameraService_->CreateCamera(cameraId);
@@ -155,4 +156,4 @@ CameraManager *CameraManager::GetInstance()
return &cameraManagerImpl;
}
} // namespace Media
-} // namespace OHOS
\ No newline at end of file
+} // namespace OHOS
diff --git a/camera_manager.h b/frameworks/camera_manager.h
similarity index 90%
rename from camera_manager.h
rename to frameworks/camera_manager.h
index 223203c..df49f44 100755
--- a/camera_manager.h
+++ b/frameworks/camera_manager.h
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/camera_service.cpp b/frameworks/camera_service.cpp
similarity index 92%
rename from camera_service.cpp
rename to frameworks/camera_service.cpp
index ba72ffc..eeb8d68 100755
--- a/camera_service.cpp
+++ b/frameworks/camera_service.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/camera_service.h b/frameworks/camera_service.h
similarity index 89%
rename from camera_service.h
rename to frameworks/camera_service.h
index 85c5700..a57fac7 100755
--- a/camera_service.h
+++ b/frameworks/camera_service.h
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/camera_service_callback.h b/frameworks/camera_service_callback.h
similarity index 89%
rename from camera_service_callback.h
rename to frameworks/camera_service_callback.h
index e42b4ad..b8ada0c 100755
--- a/camera_service_callback.h
+++ b/frameworks/camera_service_callback.h
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/event_handler.cpp b/frameworks/event_handler.cpp
similarity index 91%
rename from event_handler.cpp
rename to frameworks/event_handler.cpp
index 0eeb6a2..8483132 100755
--- a/event_handler.cpp
+++ b/frameworks/event_handler.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright(c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http ://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/frame_config.cpp b/frameworks/frame_config.cpp
similarity index 68%
rename from frame_config.cpp
rename to frameworks/frame_config.cpp
index a56c2d9..cf17675 100755
--- a/frame_config.cpp
+++ b/frameworks/frame_config.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -39,6 +39,23 @@ void FrameConfig::RemoveSurface(Surface &surface)
surfaceList_.remove(&surface);
}
+void *FrameConfig::GetValue(uint32_t key)
+{
+ auto p = keyMap_.find(key);
+ return (p == keyMap_.end()) ? nullptr : (&p->second);
+}
+
+void FrameConfig::SetValue(uint32_t key, const void *value)
+{
+ switch (key) {
+ case PARAM_KEY_IMAGE_ENCODE_QFACTOR:
+ keyMap_[key] = *(static_cast(value));
+ break;
+ default:
+ break;
+ }
+}
+
FrameConfig::FrameConfig(int32_t type) : type_(type) {}
} // namespace Media
} // namespace OHOS
\ No newline at end of file
diff --git a/interfaces/kits/camera.h b/interfaces/kits/camera.h
new file mode 100755
index 0000000..a18db1f
--- /dev/null
+++ b/interfaces/kits/camera.h
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup MultiMedia_Camera
+ * @{
+ *
+ * @brief Defines the Camera class for camera-related operations.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+/**
+ * @file camera.h
+ *
+ * @brief Declares functions in the Camera class to implement camera
+ * operations.
+ *
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+#ifndef OHOS_CAMERA_H
+#define OHOS_CAMERA_H
+
+#include
+#include
+
+#include "camera_config.h"
+#include "frame_config.h"
+
+namespace OHOS {
+namespace Media {
+/**
+ *
+ * @brief Provides functions in the Camera class to implement camera operations.
+ * operations.
+ *
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+class Camera {
+public:
+ /**
+ * @brief A destructor used to delete the Camera instance.
+ *
+ */
+ virtual ~Camera() = default;
+
+ /**
+ * @brief Obtains the camera ID.
+ *
+ * @return Returns the camera ID if obtained; returns the "Error" string if
+ * the camera fails to be created.
+ */
+ virtual std::string GetCameraId()
+ {
+ return std::string();
+ }
+
+ /**
+ * @brief Obtains the camera configuration.
+ * You can use the obtained CameraConfig object to configure the
+ * camera.
+ * @return Returns the pointer to the CameraConfig object if obtained;
+ * returns NULL otherwise.
+ */
+ virtual const CameraConfig *GetCameraConfig() const
+ {
+ return nullptr;
+ }
+
+ /**
+ * @brief Obtains the frame configuration.
+ *
+ * @param type Indicates the type of the frame configuration.
+ * @return Returns the pointer to the FrameConfig object if obtained;
+ * returns NULL otherwise.
+ */
+ virtual FrameConfig *GetFrameConfig(int32_t type)
+ {
+ return nullptr;
+ }
+
+ /**
+ * @brief Configures the camera using the CameraConfig object.
+ *
+ * @param config Indicates the pointer to the CameraConfig object.
+ */
+ virtual void Configure(CameraConfig &config) {}
+
+ /**
+ * @brief Triggers looping-frame capture.
+ *
+ * @param fc Indicates the frame configuration.
+ * @return Returns true if the looping-frame capture is successfully
+ * started; returns false otherwise.
+ */
+ virtual int32_t TriggerLoopingCapture(FrameConfig &frameConfig)
+ {
+ return -1;
+ }
+
+ /**
+ * @brief Stops looping-frame capture.
+ *
+ * @return Returns true if the looping-frame capture is successfully
+ * stopped; returns false otherwise.
+ */
+ virtual void StopLoopingCapture() {}
+
+ /**
+ * @brief Starts single-frame capture. The frame parameters are set through
+ * the FrameConfig object, and the captured image data is stored in the
+ * surface of the FrameConfig object.
+ *
+ * @param fc Indicates the frame configuration.
+ * @return Returns true if the single-frame capture is successfully
+ * started and the data is stored; returns false otherwise.
+ */
+ virtual int32_t TriggerSingleCapture(FrameConfig &frameConfig)
+ {
+ return -1;
+ }
+
+ /**
+ * @brief Releases the Camera object and associated resources.
+ *
+ */
+ virtual void Release() {}
+
+protected:
+ /**
+ * @brief A constructor used to create a Camera instance.
+ *
+ */
+ Camera() = default;
+};
+} // namespace Media
+} // namespace OHOS
+#endif // OHOS_CAMERA_H
diff --git a/interfaces/kits/camera_ability.h b/interfaces/kits/camera_ability.h
new file mode 100755
index 0000000..f64226e
--- /dev/null
+++ b/interfaces/kits/camera_ability.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup MultiMedia_CameraAbility
+ * @{
+ *
+ * @brief Defines the camera capability set for applications to achieve and access the capabilities.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+/**
+ * @file camera_ability.h
+ *
+ * @brief Declares functions of the CameraAbility class.
+ *
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+#ifndef OHOS_CAMERA_ABILITY_H
+#define OHOS_CAMERA_ABILITY_H
+
+#include "media_log.h"
+#include "meta_data.h"
+
+#include
+#include
+#include