mirror of
https://github.com/openharmony/multimedia_camera_standard.git
synced 2026-07-01 20:44:17 -04:00
code review fixes
Signed-off-by: Veeresh Kadasani <veeresh.kadasani@huawei.com>
This commit is contained in:
@@ -13,24 +13,24 @@
|
||||
limitations under the License.
|
||||
|
||||
Notes:
|
||||
This is project config file for OpenHarmony OSS Audit Tool, if you have any questions or concerns, please email chenyaxun.
|
||||
This is project config file for OpenHarmony OSS Audit Tool.
|
||||
-->
|
||||
<!-- OAT(OSS Audit Tool) configuration guide:
|
||||
basedir: Root dir, the basedir + project path is the real source file location.
|
||||
<!-- OSS Audit Tool (OAT) configuration guide:
|
||||
basedir: Root directory. the basedir + project path is the real source file location.
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
1.If the project does not have "LICENSE" in root dir, please define all the license files in this project in. OAT will check license files according to this rule.
|
||||
|
||||
tasklist(only for batch mode):
|
||||
1. task: Define oat check thread, each task will start a new thread.
|
||||
2. task name: Only an name, no practical effect.
|
||||
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
|
||||
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
|
||||
5. task project: Projects to be checked, the path field define the source root dir of the project.
|
||||
tasklist(for batch mode only):
|
||||
1. task: OAT check check task. Each task will start a new thread.
|
||||
2. task name: Name of the OAT check task.
|
||||
3. task policy: Default policy for projects under this task. This field is mandatory and the specified policy must defined in policylist.
|
||||
4. task filter: Default filefilter for projects under this task. This field is mandatory and the specified filefilter must defined in filefilterlist.
|
||||
5. task project: Projects to be checked. The source root dir of the project is defined by the path field.
|
||||
|
||||
|
||||
policyList:
|
||||
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
1. policy: All policyitems will be merged to default rules in OAT.xml. The policy name doesn't affect OAT check process.
|
||||
2. policyitem: The fields type, name, path, desc are mandatory, and the fields rule, group, filefilter are optional. The default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
@@ -40,13 +40,13 @@ policyList:
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
|
||||
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
4. policyitem name: This field is used to define the license, copyright, "*" means to match all, the "!" prefix means a failure to match this value. For example, "!GPL" means a failure to use GPL license.
|
||||
5. policyitem path: This field is used to define the source file scope to apply this policyitem. The "!" prefix means to exclude the files. For example, "!./lib/." means to exclude the files in lib dir while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means that the result will be passed if any policyitem in this group is passed.
|
||||
7. policyitem filefilter: This field is used to bind file filters, which defines filter rules.
|
||||
8. filefilter: This field is used to define filter rules. Wherein, filename is used to filter file names and filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
Note: If the text contains special characters, please escape them according to the following rules:
|
||||
" == >
|
||||
& == >
|
||||
' == >
|
||||
|
||||
@@ -130,7 +130,7 @@ Steps to capture a photo:
|
||||
int32_t photoHeight = 960;
|
||||
photoSurface->SetDefaultWidthAndHeight(photoWidth, photoHeight);
|
||||
photoSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(OHOS_CAMERA_FORMAT_JPEG));
|
||||
sptr<CaptureSurfaceListener> capturelistener = new CaptureSurfaceListener();
|
||||
sptr<CaptureSurfaceListener> capturelistener = new(std::nothrow) CaptureSurfaceListener();
|
||||
capturelistener->mode_ = MODE_PHOTO;
|
||||
capturelistener->surface_ = photoSurface;
|
||||
photoSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)capturelistener);
|
||||
@@ -429,7 +429,7 @@ Below steps demonstrate how to switch between the camera devices. Initially a vi
|
||||
int32_t photoHeight = 960;
|
||||
photoSurface->SetDefaultWidthAndHeight(photoWidth, photoHeight);
|
||||
photoSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(OHOS_CAMERA_FORMAT_JPEG));
|
||||
sptr<CaptureSurfaceListener> capturelistener = new CaptureSurfaceListener();
|
||||
sptr<CaptureSurfaceListener> capturelistener = new(std::nothrow) CaptureSurfaceListener();
|
||||
capturelistener->mode_ = MODE_PHOTO;
|
||||
capturelistener->surface_ = photoSurface;
|
||||
photoSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)capturelistener);
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@
|
||||
int32_t photoHeight = 960;
|
||||
photoSurface->SetDefaultWidthAndHeight(photoWidth, photoHeight);
|
||||
photoSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(OHOS_CAMERA_FORMAT_JPEG));
|
||||
sptr<CaptureSurfaceListener> capturelistener = new CaptureSurfaceListener();
|
||||
sptr<CaptureSurfaceListener> capturelistener = new(std::nothrow) CaptureSurfaceListener();
|
||||
capturelistener->mode_ = MODE_PHOTO;
|
||||
capturelistener->surface_ = photoSurface;
|
||||
photoSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)capturelistener);
|
||||
@@ -428,7 +428,7 @@
|
||||
int32_t photoHeight = 960;
|
||||
photoSurface->SetDefaultWidthAndHeight(photoWidth, photoHeight);
|
||||
photoSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(OHOS_CAMERA_FORMAT_JPEG));
|
||||
sptr<CaptureSurfaceListener> capturelistener = new CaptureSurfaceListener();
|
||||
sptr<CaptureSurfaceListener> capturelistener = new(std::nothrow) CaptureSurfaceListener();
|
||||
capturelistener->mode_ = MODE_PHOTO;
|
||||
capturelistener->surface_ = photoSurface;
|
||||
photoSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)capturelistener);
|
||||
|
||||
@@ -1653,6 +1653,9 @@ napi_value CameraInputNapi::Release(napi_env env, napi_callback_info info)
|
||||
CommonCompleteCallback, static_cast<void*>(asyncContext.get()), &asyncContext->work);
|
||||
if (status != napi_ok) {
|
||||
MEDIA_ERR_LOG("Failed to create napi_create_async_work for CameraInputNapi::Release");
|
||||
if (asyncContext->callbackRef != nullptr) {
|
||||
napi_delete_reference(env, asyncContext->callbackRef);
|
||||
}
|
||||
napi_get_undefined(env, &result);
|
||||
} else {
|
||||
napi_queue_async_work(env, asyncContext->work);
|
||||
|
||||
@@ -420,6 +420,9 @@ napi_value CameraManagerNapi::On(napi_env env, napi_callback_info info)
|
||||
obj->cameraManager_->SetCallback(callback);
|
||||
} else {
|
||||
MEDIA_ERR_LOG("Incorrect callback event type provided for camera manager!");
|
||||
if (callbackRef != nullptr) {
|
||||
napi_delete_reference(env, callbackRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +155,9 @@ void PhotoOutputCallback::UpdateJSCallback(std::string propName, const CallbackI
|
||||
napi_create_int32(env_, jsErrorCodeUnknown, &propValue);
|
||||
napi_set_named_property(env_, result[PARAM1], "code", propValue);
|
||||
napi_get_reference_value(env_, errorCallbackRef_, &callback);
|
||||
if (errorCallbackRef_ != nullptr) {
|
||||
napi_delete_reference(env_, errorCallbackRef_);
|
||||
}
|
||||
}
|
||||
|
||||
napi_call_function(env_, nullptr, callback, ARGS_TWO, result, &retVal);
|
||||
|
||||
@@ -121,6 +121,9 @@ void PreviewOutputCallback::UpdateJSCallback(std::string propName, const int32_t
|
||||
napi_create_int32(env_, jsErrorCodeUnknown, &propValue);
|
||||
napi_set_named_property(env_, result[PARAM1], "code", propValue);
|
||||
napi_get_reference_value(env_, errorCallbackRef_, &callback); // should errorcode be valued as -1
|
||||
if (errorCallbackRef_ != nullptr) {
|
||||
napi_delete_reference(env_, errorCallbackRef_);
|
||||
}
|
||||
}
|
||||
|
||||
napi_call_function(env_, nullptr, callback, ARGS_TWO, result, &retVal);
|
||||
|
||||
@@ -121,6 +121,9 @@ void VideoCallbackListener::UpdateJSCallback(std::string propName, const int32_t
|
||||
napi_create_int32(env_, jsErrorCodeUnknown, &propValue);
|
||||
napi_set_named_property(env_, result[PARAM1], "code", propValue);
|
||||
napi_get_reference_value(env_, errorCallbackRef_, &callback); // should errorcode be valued as -1
|
||||
if (errorCallbackRef_ != nullptr) {
|
||||
napi_delete_reference(env_, errorCallbackRef_);
|
||||
}
|
||||
}
|
||||
|
||||
napi_call_function(env_, nullptr, callback, ARGS_TWO, result, &retVal);
|
||||
|
||||
@@ -811,6 +811,9 @@ napi_value CameraSessionNapi::On(napi_env env, napi_callback_info info)
|
||||
obj->cameraSession_->SetCallback(callback);
|
||||
} else {
|
||||
MEDIA_ERR_LOG("Failed to Register Callback: event type is empty!");
|
||||
if (callbackRef != nullptr) {
|
||||
napi_delete_reference(env, callbackRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace CameraStandard {
|
||||
namespace {
|
||||
constexpr int32_t DEFAULT_ITEMS = 10;
|
||||
constexpr int32_t DEFAULT_DATA_LENGTH = 100;
|
||||
constexpr uint32_t UNIT_LENGTH = 3;
|
||||
}
|
||||
|
||||
class CameraDeviceServiceCallback : public HCameraDeviceCallbackStub {
|
||||
public:
|
||||
sptr<CameraInput> camInput_ = nullptr;
|
||||
@@ -88,8 +94,8 @@ const std::unordered_map<camera_af_state_t, FocusCallback::FocusState> CameraInp
|
||||
CameraInput::CameraInput(sptr<ICameraDeviceService> &deviceObj,
|
||||
sptr<CameraInfo> &cameraObj) : cameraObj_(cameraObj), deviceObj_(deviceObj)
|
||||
{
|
||||
CameraDeviceSvcCallback_ = new CameraDeviceServiceCallback(this);
|
||||
if (!CameraDeviceSvcCallback_) {
|
||||
CameraDeviceSvcCallback_ = new(std::nothrow) CameraDeviceServiceCallback(this);
|
||||
if (CameraDeviceSvcCallback_ == nullptr) {
|
||||
MEDIA_ERR_LOG("CameraInput::CameraInput CameraDeviceServiceCallback alloc failed");
|
||||
return;
|
||||
}
|
||||
@@ -107,9 +113,7 @@ void CameraInput::Release()
|
||||
void CameraInput::LockForControl()
|
||||
{
|
||||
changeMetaMutex_.lock();
|
||||
int32_t items = 10;
|
||||
int32_t dataLength = 100;
|
||||
changedMetadata_ = std::make_shared<CameraMetadata>(items, dataLength);
|
||||
changedMetadata_ = std::make_shared<CameraMetadata>(DEFAULT_ITEMS, DEFAULT_DATA_LENGTH);
|
||||
}
|
||||
|
||||
int32_t CameraInput::UpdateSetting(std::shared_ptr<CameraMetadata> changedMetadata)
|
||||
@@ -175,7 +179,6 @@ void CameraInput::getVector(DataPtr data, size_t count, Vec &vect, VecType dataT
|
||||
|
||||
std::vector<camera_format_t> CameraInput::GetSupportedPhotoFormats()
|
||||
{
|
||||
uint32_t unitLen = 3;
|
||||
camera_format_t format;
|
||||
std::set<camera_format_t> formats;
|
||||
std::shared_ptr<CameraMetadata> metadata = cameraObj_->GetMetadata();
|
||||
@@ -185,11 +188,11 @@ std::vector<camera_format_t> CameraInput::GetSupportedPhotoFormats()
|
||||
MEDIA_ERR_LOG("Failed to get stream configuration with return code %{public}d", ret);
|
||||
return {};
|
||||
}
|
||||
if (item.count % unitLen != 0) {
|
||||
if (item.count % UNIT_LENGTH != 0) {
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}d", item.count);
|
||||
return {};
|
||||
}
|
||||
for (uint32_t index = 0; index < item.count; index += unitLen) {
|
||||
for (uint32_t index = 0; index < item.count; index += UNIT_LENGTH) {
|
||||
format = static_cast<camera_format_t>(item.data.i32[index]);
|
||||
if (format == OHOS_CAMERA_FORMAT_JPEG) {
|
||||
formats.insert(format);
|
||||
@@ -200,7 +203,6 @@ std::vector<camera_format_t> CameraInput::GetSupportedPhotoFormats()
|
||||
|
||||
std::vector<camera_format_t> CameraInput::GetSupportedVideoFormats()
|
||||
{
|
||||
uint32_t unitLen = 3;
|
||||
camera_format_t format;
|
||||
std::set<camera_format_t> formats;
|
||||
std::shared_ptr<CameraMetadata> metadata = cameraObj_->GetMetadata();
|
||||
@@ -210,11 +212,11 @@ std::vector<camera_format_t> CameraInput::GetSupportedVideoFormats()
|
||||
MEDIA_ERR_LOG("Failed to get stream configuration with return code %{public}d", ret);
|
||||
return {};
|
||||
}
|
||||
if (item.count % unitLen != 0) {
|
||||
if (item.count % UNIT_LENGTH != 0) {
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}d", item.count);
|
||||
return {};
|
||||
}
|
||||
for (uint32_t index = 0; index < item.count; index += unitLen) {
|
||||
for (uint32_t index = 0; index < item.count; index += UNIT_LENGTH) {
|
||||
format = static_cast<camera_format_t>(item.data.i32[index]);
|
||||
if (format != OHOS_CAMERA_FORMAT_JPEG) {
|
||||
formats.insert(format);
|
||||
@@ -225,7 +227,6 @@ std::vector<camera_format_t> CameraInput::GetSupportedVideoFormats()
|
||||
|
||||
std::vector<camera_format_t> CameraInput::GetSupportedPreviewFormats()
|
||||
{
|
||||
uint32_t unitLen = 3;
|
||||
camera_format_t format;
|
||||
std::set<camera_format_t> formats;
|
||||
std::shared_ptr<CameraMetadata> metadata = cameraObj_->GetMetadata();
|
||||
@@ -235,11 +236,11 @@ std::vector<camera_format_t> CameraInput::GetSupportedPreviewFormats()
|
||||
MEDIA_ERR_LOG("Failed to get stream configuration with return code %{public}d", ret);
|
||||
return {};
|
||||
}
|
||||
if (item.count % unitLen != 0) {
|
||||
if (item.count % UNIT_LENGTH != 0) {
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}d", item.count);
|
||||
return {};
|
||||
}
|
||||
for (uint32_t index = 0; index < item.count; index += unitLen) {
|
||||
for (uint32_t index = 0; index < item.count; index += UNIT_LENGTH) {
|
||||
format = static_cast<camera_format_t>(item.data.i32[index]);
|
||||
if (format != OHOS_CAMERA_FORMAT_JPEG) {
|
||||
formats.insert(format);
|
||||
@@ -250,7 +251,6 @@ std::vector<camera_format_t> CameraInput::GetSupportedPreviewFormats()
|
||||
|
||||
std::vector<CameraPicSize> CameraInput::getSupportedSizes(camera_format_t format)
|
||||
{
|
||||
uint32_t unitLen = 3;
|
||||
uint32_t widthOffset = 1;
|
||||
uint32_t heightOffset = 2;
|
||||
camera_metadata_item_t item;
|
||||
@@ -260,12 +260,12 @@ std::vector<CameraPicSize> CameraInput::getSupportedSizes(camera_format_t format
|
||||
MEDIA_ERR_LOG("Failed to get stream configuration with return code %{public}d", ret);
|
||||
return {};
|
||||
}
|
||||
if (item.count % unitLen != 0) {
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}d", item.count);
|
||||
if (item.count % UNIT_LENGTH != 0) {
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}u", item.count);
|
||||
return {};
|
||||
}
|
||||
int32_t count = 0;
|
||||
for (uint32_t index_ = 0; index_ < item.count; index_ += unitLen) {
|
||||
for (uint32_t index_ = 0; index_ < item.count; index_ += UNIT_LENGTH) {
|
||||
if (item.data.i32[index_] == format) {
|
||||
count++;
|
||||
}
|
||||
@@ -277,7 +277,7 @@ std::vector<CameraPicSize> CameraInput::getSupportedSizes(camera_format_t format
|
||||
|
||||
std::vector<CameraPicSize> sizes(count);
|
||||
CameraPicSize *size = &sizes[0];
|
||||
for (uint32_t index = 0; index < item.count; index += unitLen) {
|
||||
for (uint32_t index = 0; index < item.count; index += UNIT_LENGTH) {
|
||||
if (item.data.i32[index] == format) {
|
||||
size->width = static_cast<uint32_t>(item.data.i32[index + widthOffset]);
|
||||
size->height = static_cast<uint32_t>(item.data.i32[index + heightOffset]);
|
||||
@@ -494,7 +494,7 @@ int32_t CameraInput::SetCropRegion(float zoomRatio)
|
||||
return ret;
|
||||
}
|
||||
if (item.count != arrayCount) {
|
||||
MEDIA_ERR_LOG("CameraInput::SetCropRegion Invalid sensor active array size count: %{public}d", item.count);
|
||||
MEDIA_ERR_LOG("CameraInput::SetCropRegion Invalid sensor active array size count: %{public}u", item.count);
|
||||
return CAM_META_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,8 +139,8 @@ sptr<CaptureSession> CameraManager::CreateCaptureSession()
|
||||
}
|
||||
retCode = serviceProxy_->CreateCaptureSession(captureSession);
|
||||
if (retCode == CAMERA_OK && captureSession != nullptr) {
|
||||
result = new CaptureSession(captureSession);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) CaptureSession(captureSession);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new CaptureSession");
|
||||
}
|
||||
} else {
|
||||
@@ -162,8 +162,8 @@ sptr<PhotoOutput> CameraManager::CreatePhotoOutput(sptr<Surface> &surface)
|
||||
std::string format = surface->GetUserData(surfaceFormat);
|
||||
retCode = serviceProxy_->CreatePhotoOutput(surface->GetProducer(), std::stoi(format), streamCapture);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new PhotoOutput(streamCapture);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) PhotoOutput(streamCapture);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new PhotoOutput ");
|
||||
}
|
||||
} else {
|
||||
@@ -184,8 +184,8 @@ sptr<PhotoOutput> CameraManager::CreatePhotoOutput(const sptr<OHOS::IBufferProdu
|
||||
}
|
||||
retCode = serviceProxy_->CreatePhotoOutput(producer, format, streamCapture);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new PhotoOutput(streamCapture);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) PhotoOutput(streamCapture);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new PhotoOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -207,8 +207,8 @@ sptr<PreviewOutput> CameraManager::CreatePreviewOutput(sptr<Surface> surface)
|
||||
std::string format = surface->GetUserData(surfaceFormat);
|
||||
retCode = serviceProxy_->CreatePreviewOutput(surface->GetProducer(), std::stoi(format), streamRepeat);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new PreviewOutput(streamRepeat);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) PreviewOutput(streamRepeat);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new PreviewOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -229,8 +229,8 @@ sptr<PreviewOutput> CameraManager::CreatePreviewOutput(const sptr<OHOS::IBufferP
|
||||
}
|
||||
retCode = serviceProxy_->CreatePreviewOutput(producer, format, streamRepeat);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new PreviewOutput(streamRepeat);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) PreviewOutput(streamRepeat);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new PreviewOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -253,8 +253,8 @@ sptr<PreviewOutput> CameraManager::CreateCustomPreviewOutput(sptr<Surface> surfa
|
||||
retCode = serviceProxy_->CreateCustomPreviewOutput(surface->GetProducer(), std::stoi(format), width, height,
|
||||
streamRepeat);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new PreviewOutput(streamRepeat);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) PreviewOutput(streamRepeat);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new PreviewOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -276,8 +276,8 @@ sptr<PreviewOutput> CameraManager::CreateCustomPreviewOutput(const sptr<OHOS::IB
|
||||
}
|
||||
retCode = serviceProxy_->CreateCustomPreviewOutput(producer, format, width, height, streamRepeat);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new PreviewOutput(streamRepeat);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) PreviewOutput(streamRepeat);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new PreviewOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -299,8 +299,8 @@ sptr<VideoOutput> CameraManager::CreateVideoOutput(sptr<Surface> &surface)
|
||||
std::string format = surface->GetUserData(surfaceFormat);
|
||||
retCode = serviceProxy_->CreateVideoOutput(surface->GetProducer(), std::stoi(format), streamRepeat);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new VideoOutput(streamRepeat);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) VideoOutput(streamRepeat);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new VideoOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -321,8 +321,8 @@ sptr<VideoOutput> CameraManager::CreateVideoOutput(const sptr<OHOS::IBufferProdu
|
||||
}
|
||||
retCode = serviceProxy_->CreateVideoOutput(producer, format, streamRepeat);
|
||||
if (retCode == CAMERA_OK) {
|
||||
result = new VideoOutput(streamRepeat);
|
||||
if (!result) {
|
||||
result = new(std::nothrow) VideoOutput(streamRepeat);
|
||||
if (result == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to new VideoOutput");
|
||||
}
|
||||
} else {
|
||||
@@ -351,7 +351,7 @@ void CameraManager::Init()
|
||||
MEDIA_ERR_LOG("CameraManager::init serviceProxy_ is null.");
|
||||
return;
|
||||
} else {
|
||||
cameraSvcCallback_ = new CameraStatusServiceCallback(this);
|
||||
cameraSvcCallback_ = new(std::nothrow) CameraStatusServiceCallback(this);
|
||||
if (cameraSvcCallback_) {
|
||||
SetCameraServiceCallback(cameraSvcCallback_);
|
||||
} else {
|
||||
@@ -431,7 +431,7 @@ sptr<CameraManager> &CameraManager::GetInstance()
|
||||
{
|
||||
if (CameraManager::cameraManager_ == nullptr) {
|
||||
MEDIA_INFO_LOG("Initializing camera manager for first time!");
|
||||
CameraManager::cameraManager_ = new CameraManager();
|
||||
CameraManager::cameraManager_ = new(std::nothrow) CameraManager();
|
||||
if (CameraManager::cameraManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("CameraManager::GetInstance failed to new CameraManager");
|
||||
}
|
||||
@@ -457,7 +457,7 @@ std::vector<sptr<CameraInfo>> CameraManager::GetCameras()
|
||||
retCode = serviceProxy_->GetCameras(cameraIds, cameraAbilityList);
|
||||
if (retCode == CAMERA_OK) {
|
||||
for (auto& it : cameraIds) {
|
||||
cameraObj = new CameraInfo(it, cameraAbilityList[index++]);
|
||||
cameraObj = new(std::nothrow) CameraInfo(it, cameraAbilityList[index++]);
|
||||
if (cameraObj == nullptr) {
|
||||
MEDIA_ERR_LOG("CameraManager::GetCameras new CameraInfo failed for id={public}%s", it.c_str());
|
||||
continue;
|
||||
@@ -478,7 +478,7 @@ sptr<CameraInput> CameraManager::CreateCameraInput(sptr<CameraInfo> &camera)
|
||||
if (camera != nullptr) {
|
||||
deviceObj = CreateCameraDevice(camera->GetID());
|
||||
if (deviceObj != nullptr) {
|
||||
cameraInput = new CameraInput(deviceObj, camera);
|
||||
cameraInput = new(std::nothrow) CameraInput(deviceObj, camera);
|
||||
if (cameraInput == nullptr) {
|
||||
MEDIA_ERR_LOG("failed to new CameraInput Returning null in CreateCameraInput");
|
||||
return cameraInput;
|
||||
|
||||
@@ -20,8 +20,13 @@
|
||||
#include "media_log.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
namespace CameraStandard {
|
||||
namespace {
|
||||
constexpr uint8_t QUALITY_NORMAL = 90;
|
||||
constexpr uint8_t QUALITY_LOW = 50;
|
||||
}
|
||||
PhotoCaptureSetting::PhotoCaptureSetting()
|
||||
{
|
||||
int32_t items = 10;
|
||||
@@ -31,8 +36,6 @@ PhotoCaptureSetting::PhotoCaptureSetting()
|
||||
|
||||
PhotoCaptureSetting::QualityLevel PhotoCaptureSetting::GetQuality()
|
||||
{
|
||||
uint8_t normalQuality = 90;
|
||||
uint8_t lowQuality = 50;
|
||||
QualityLevel quality = LOW_QUALITY;
|
||||
camera_metadata_item_t item;
|
||||
|
||||
@@ -40,9 +43,9 @@ PhotoCaptureSetting::QualityLevel PhotoCaptureSetting::GetQuality()
|
||||
if (ret != CAM_META_SUCCESS) {
|
||||
return NORMAL_QUALITY;
|
||||
}
|
||||
if (item.data.u8[0] > normalQuality) {
|
||||
if (item.data.u8[0] > QUALITY_NORMAL) {
|
||||
quality = HIGH_QUALITY;
|
||||
} else if (item.data.u8[0] > lowQuality) {
|
||||
} else if (item.data.u8[0] > QUALITY_LOW) {
|
||||
quality = NORMAL_QUALITY;
|
||||
}
|
||||
return quality;
|
||||
@@ -229,8 +232,8 @@ void PhotoOutput::SetCallback(std::shared_ptr<PhotoCallback> callback)
|
||||
appCallback_ = callback;
|
||||
if (appCallback_ != nullptr) {
|
||||
if (cameraSvcCallback_ == nullptr) {
|
||||
cameraSvcCallback_ = new HStreamCaptureCallbackImpl(this);
|
||||
if (!cameraSvcCallback_) {
|
||||
cameraSvcCallback_ = new(std::nothrow) HStreamCaptureCallbackImpl(this);
|
||||
if (cameraSvcCallback_ == nullptr) {
|
||||
MEDIA_ERR_LOG("PhotoOutput::SetCallback new HStreamCaptureCallbackImpl Failed to register callback");
|
||||
appCallback_ = nullptr;
|
||||
return;
|
||||
|
||||
@@ -85,8 +85,8 @@ void PreviewOutput::SetCallback(std::shared_ptr<PreviewCallback> callback)
|
||||
appCallback_ = callback;
|
||||
if (appCallback_ != nullptr) {
|
||||
if (svcCallback_ == nullptr) {
|
||||
svcCallback_ = new HStreamRepeatCallbackImpl(this);
|
||||
if (!svcCallback_) {
|
||||
svcCallback_ = new(std::nothrow) HStreamRepeatCallbackImpl(this);
|
||||
if (svcCallback_ == nullptr) {
|
||||
MEDIA_ERR_LOG("PreviewOutput::SetCallback: new HStreamRepeatCallbackImpl Failed to register callback");
|
||||
appCallback_ = nullptr;
|
||||
return;
|
||||
|
||||
@@ -76,8 +76,8 @@ void VideoOutput::SetCallback(std::shared_ptr<VideoCallback> callback)
|
||||
appCallback_ = callback;
|
||||
if (appCallback_ != nullptr) {
|
||||
if (svcCallback_ == nullptr) {
|
||||
svcCallback_ = new HStreamRepeatCallbackImpl(this);
|
||||
if (!svcCallback_) {
|
||||
svcCallback_ = new(std::nothrow) HStreamRepeatCallbackImpl(this);
|
||||
if (svcCallback_ == nullptr) {
|
||||
MEDIA_ERR_LOG("VideoOutput::SetCallback: new HStreamRepeatCallbackImpl Failed to register callback");
|
||||
appCallback_ = nullptr;
|
||||
return;
|
||||
@@ -104,6 +104,7 @@ float VideoOutput::GetFps()
|
||||
|
||||
int32_t VideoOutput::SetFps(float fps)
|
||||
{
|
||||
(void)fps;
|
||||
return CAMERA_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ void CaptureSession::SetCallback(std::shared_ptr<SessionCallback> callback)
|
||||
appCallback_ = callback;
|
||||
if (appCallback_ != nullptr) {
|
||||
if (captureSessionCallback_ == nullptr) {
|
||||
captureSessionCallback_ = new CaptureSessionCallback(this);
|
||||
captureSessionCallback_ = new(std::nothrow) CaptureSessionCallback(this);
|
||||
}
|
||||
errorCode = captureSession_->SetCallback(captureSessionCallback_);
|
||||
if (errorCode != CAMERA_OK) {
|
||||
|
||||
@@ -13,14 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "camera_framework_moduletest.h"
|
||||
#include <cinttypes>
|
||||
|
||||
#include "input/camera_input.h"
|
||||
#include "input/camera_manager.h"
|
||||
#include "media_log.h"
|
||||
#include "surface.h"
|
||||
#include "test_common.h"
|
||||
#include "camera_framework_moduletest.h"
|
||||
|
||||
#include "ipc_skeleton.h"
|
||||
#include "access_token.h"
|
||||
@@ -245,7 +244,7 @@ sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePhotoOutput(int32_t width,
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer();
|
||||
surface->SetDefaultWidthAndHeight(width, height);
|
||||
surface->SetUserData(CameraManager::surfaceFormat, std::to_string(photoFormat_));
|
||||
sptr<SurfaceListener> listener = new SurfaceListener("Test_Capture", SurfaceType::PHOTO, fd, surface);
|
||||
sptr<SurfaceListener> listener = new(std::nothrow) SurfaceListener("Test_Capture", SurfaceType::PHOTO, fd, surface);
|
||||
surface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)listener);
|
||||
sptr<CaptureOutput> photoOutput = manager_->CreatePhotoOutput(surface);
|
||||
return photoOutput;
|
||||
@@ -264,7 +263,8 @@ sptr<CaptureOutput> CameraFrameworkModuleTest::CreatePreviewOutput(bool customPr
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer();
|
||||
surface->SetDefaultWidthAndHeight(width, height);
|
||||
surface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewFormat_));
|
||||
sptr<SurfaceListener> listener = new SurfaceListener("Test_Preview", SurfaceType::PREVIEW, fd, surface);
|
||||
sptr<SurfaceListener> listener = new(std::nothrow) SurfaceListener("Test_Preview", SurfaceType::PREVIEW,
|
||||
fd, surface);
|
||||
surface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)listener);
|
||||
sptr<CaptureOutput> previewOutput = nullptr;
|
||||
if (customPreview) {
|
||||
@@ -286,7 +286,8 @@ sptr<CaptureOutput> CameraFrameworkModuleTest::CreateVideoOutput(int32_t width,
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer();
|
||||
surface->SetDefaultWidthAndHeight(width, height);
|
||||
surface->SetUserData(CameraManager::surfaceFormat, std::to_string(videoFormat_));
|
||||
sptr<SurfaceListener> listener = new SurfaceListener("Test_Video", SurfaceType::VIDEO, g_videoFd, surface);
|
||||
sptr<SurfaceListener> listener = new(std::nothrow) SurfaceListener("Test_Video", SurfaceType::VIDEO,
|
||||
g_videoFd, surface);
|
||||
surface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)listener);
|
||||
sptr<CaptureOutput> videoOutput = manager_->CreateVideoOutput(surface);
|
||||
return videoOutput;
|
||||
@@ -777,6 +778,8 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_003, TestSize.Le
|
||||
intResult = session_->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
sleep(WAIT_TIME_AFTER_START);
|
||||
|
||||
intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
@@ -786,6 +789,8 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_003, TestSize.Le
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
|
||||
|
||||
sleep(WAIT_TIME_BEFORE_STOP);
|
||||
session_->Stop();
|
||||
}
|
||||
|
||||
@@ -1077,7 +1082,7 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_018, TestSize.Le
|
||||
|
||||
sptr<CaptureInput> input1 = nullptr;
|
||||
intResult = session_->AddInput(input1);
|
||||
EXPECT_EQ(intResult, 0);
|
||||
EXPECT_NE(intResult, 0);
|
||||
|
||||
session_->Stop();
|
||||
}
|
||||
@@ -1097,7 +1102,7 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_019, TestSize.Le
|
||||
|
||||
sptr<CaptureOutput> previewOutput = nullptr;
|
||||
intResult = session_->AddOutput(previewOutput);
|
||||
EXPECT_EQ(intResult, 0);
|
||||
EXPECT_NE(intResult, 0);
|
||||
|
||||
session_->Stop();
|
||||
}
|
||||
@@ -1265,7 +1270,7 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_024, TestSize.Le
|
||||
#ifdef PRODUCT_M40
|
||||
EXPECT_EQ(intResult, 0);
|
||||
#else
|
||||
EXPECT_EQ(intResult, 0);
|
||||
EXPECT_NE(intResult, 0);
|
||||
#endif
|
||||
|
||||
sleep(WAIT_TIME_AFTER_START);
|
||||
@@ -1452,6 +1457,8 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_027, TestSize.Le
|
||||
intResult = session_->Stop();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
sleep(WAIT_TIME_AFTER_START);
|
||||
|
||||
intResult = session_->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
@@ -1494,6 +1501,8 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_028, TestSize.Le
|
||||
intResult = session_->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
sleep(WAIT_TIME_AFTER_START);
|
||||
|
||||
intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
@@ -1502,6 +1511,8 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_028, TestSize.Le
|
||||
intResult = ((sptr<VideoOutput> &)videoOutput)->Stop();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
sleep(WAIT_TIME_AFTER_START);
|
||||
|
||||
intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
@@ -1512,6 +1523,7 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_028, TestSize.Le
|
||||
|
||||
TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
|
||||
|
||||
sleep(WAIT_TIME_BEFORE_STOP);
|
||||
session_->Stop();
|
||||
}
|
||||
|
||||
@@ -1721,6 +1733,8 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_032, TestSize.Le
|
||||
intResult = session_->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
sleep(WAIT_TIME_AFTER_START);
|
||||
|
||||
intResult = ((sptr<VideoOutput> &)videoOutput)->Start();
|
||||
EXPECT_EQ(intResult, 0);
|
||||
|
||||
@@ -1731,6 +1745,7 @@ HWTEST_F(CameraFrameworkModuleTest, camera_framework_moduletest_032, TestSize.Le
|
||||
|
||||
TestUtils::SaveVideoFile(nullptr, 0, VideoSaveMode::CLOSE, g_videoFd);
|
||||
|
||||
sleep(WAIT_TIME_BEFORE_STOP);
|
||||
session_->Stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
sptr<CaptureOutput> CameraFrameworkUnitTest::CreatePhotoOutput(int32_t width, int32_t height)
|
||||
{
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer();
|
||||
if (!surface) {
|
||||
if (surface == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
surface->SetDefaultWidthAndHeight(width, height);
|
||||
@@ -179,7 +179,7 @@ sptr<CaptureOutput> CameraFrameworkUnitTest::CreatePhotoOutput(int32_t width, in
|
||||
sptr<CaptureOutput> CameraFrameworkUnitTest::CreatePreviewOutput(int32_t width, int32_t height)
|
||||
{
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer();
|
||||
if (!surface) {
|
||||
if (surface == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
surface->SetDefaultWidthAndHeight(width, height);
|
||||
@@ -190,7 +190,7 @@ sptr<CaptureOutput> CameraFrameworkUnitTest::CreatePreviewOutput(int32_t width,
|
||||
sptr<CaptureOutput> CameraFrameworkUnitTest::CreateVideoOutput(int32_t width, int32_t height)
|
||||
{
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsConsumer();
|
||||
if (!surface) {
|
||||
if (surface == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
surface->SetDefaultWidthAndHeight(width, height);
|
||||
|
||||
@@ -123,8 +123,8 @@ bool CameraMetadata::updateEntry(uint32_t tag, const void *data, size_t dataCoun
|
||||
METADATA_ERR_LOG("Failed to update tag tagname = %{public}s : not present", (name ? name : "<unknown>"));
|
||||
return false;
|
||||
}
|
||||
METADATA_INFO_LOG("updateEntry Metadata pointer: %{public}p, item id: %{public}d, name: %{public}s, "
|
||||
"dataCount: %{public}zu", metadata_, tag, name ? name : "<unknown>", dataCount);
|
||||
METADATA_INFO_LOG("updateEntry item id: %{public}d, name: %{public}s, "
|
||||
"dataCount: %{public}zu", tag, name ? name : "<unknown>", dataCount);
|
||||
ret = UpdateCameraMetadataItemByIndex(metadata_, item.index, data, dataCount, nullptr);
|
||||
if (ret) {
|
||||
const char *name_ = GetCameraMetadataItemName(tag);
|
||||
|
||||
@@ -605,6 +605,10 @@ uint32_t GetCameraMetadataItemCapacity(const common_metadata_header_t *metadataH
|
||||
|
||||
uint32_t GetCameraMetadataDataSize(const common_metadata_header_t *metadataHeader)
|
||||
{
|
||||
if (metadataHeader == nullptr) {
|
||||
METADATA_ERR_LOG("GetCameraMetadataDataSize::metadataHeader is null");
|
||||
return 0;
|
||||
}
|
||||
return metadataHeader->data_capacity;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,60 @@ public:
|
||||
CameraInfo() = default;
|
||||
CameraInfo(std::string cameraID, std::shared_ptr<CameraMetadata> metadata);
|
||||
~CameraInfo();
|
||||
/**
|
||||
* @brief Get the camera Id.
|
||||
*
|
||||
* @return Returns the camera Id.
|
||||
*/
|
||||
std::string GetID();
|
||||
|
||||
/**
|
||||
* @brief Get the metadata corresponding to current camera object.
|
||||
*
|
||||
* @return Returns the metadata corresponding to current object.
|
||||
*/
|
||||
std::shared_ptr<CameraMetadata> GetMetadata();
|
||||
|
||||
/**
|
||||
* @brief Set the metadata to current camera object.
|
||||
*
|
||||
* @param Metadat to set.
|
||||
*/
|
||||
void SetMetadata(std::shared_ptr<CameraMetadata> metadata);
|
||||
|
||||
/**
|
||||
* @brief Get the position of the camera.
|
||||
*
|
||||
* @return Returns the position of the camera.
|
||||
*/
|
||||
camera_position_enum_t GetPosition();
|
||||
|
||||
/**
|
||||
* @brief Get the Camera type of the camera.
|
||||
*
|
||||
* @return Returns the Camera type of the camera.
|
||||
*/
|
||||
camera_type_enum_t GetCameraType();
|
||||
|
||||
/**
|
||||
* @brief Get the Camera connection type.
|
||||
*
|
||||
* @return Returns the Camera type of the camera.
|
||||
*/
|
||||
camera_connection_type_t GetConnectionType();
|
||||
|
||||
/**
|
||||
* @brief Check if mirror mode supported.
|
||||
*
|
||||
* @return Returns True is supported.
|
||||
*/
|
||||
bool IsMirrorSupported();
|
||||
|
||||
/**
|
||||
* @brief Get the supported Zoom Ratio range.
|
||||
*
|
||||
* @return Returns vector<float> of supported Zoom ratio range.
|
||||
*/
|
||||
std::vector<float> GetZoomRatioRange();
|
||||
|
||||
private:
|
||||
|
||||
@@ -67,30 +67,184 @@ public:
|
||||
~CameraInput() {}
|
||||
void LockForControl();
|
||||
int32_t UnlockForControl();
|
||||
|
||||
/**
|
||||
* @brief Get the supported format for photo.
|
||||
*
|
||||
* @return Returns vector of camera_format_t supported format for photo.
|
||||
*/
|
||||
std::vector<camera_format_t> GetSupportedPhotoFormats();
|
||||
|
||||
/**
|
||||
* @brief Get the supported format for video.
|
||||
*
|
||||
* @return Returns vector of camera_format_t supported format for video.
|
||||
*/
|
||||
std::vector<camera_format_t> GetSupportedVideoFormats();
|
||||
|
||||
/**
|
||||
* @brief Get the supported format for preview.
|
||||
*
|
||||
* @return Returns vector of camera_format_t supported format for preview.
|
||||
*/
|
||||
std::vector<camera_format_t> GetSupportedPreviewFormats();
|
||||
|
||||
/**
|
||||
* @brief Get the supported sizes for given format.
|
||||
*
|
||||
* @param camera_format_t for which you want to get supported sizes.
|
||||
* @return Returns vector of CameraPicSize supported sizes.
|
||||
*/
|
||||
std::vector<CameraPicSize> getSupportedSizes(camera_format_t format);
|
||||
|
||||
/**
|
||||
* @brief Get the supported exposure modes.
|
||||
*
|
||||
* @return Returns vector of camera_ae_mode_t supported exposure modes.
|
||||
*/
|
||||
std::vector<camera_ae_mode_t> GetSupportedExposureModes();
|
||||
|
||||
/**
|
||||
* @brief Set exposure mode.
|
||||
*
|
||||
* @param camera_ae_mode_t exposure mode to be set.
|
||||
*/
|
||||
void SetExposureMode(camera_ae_mode_t exposureMode);
|
||||
|
||||
/**
|
||||
* @brief Get the current exposure mode.
|
||||
*
|
||||
* @return Returns current exposure mode.
|
||||
*/
|
||||
camera_ae_mode_t GetExposureMode();
|
||||
|
||||
/**
|
||||
* @brief Set the exposure callback.
|
||||
* which will be called when there is exposure state change.
|
||||
*
|
||||
* @param The ExposureCallback pointer.
|
||||
*/
|
||||
void SetExposureCallback(std::shared_ptr<ExposureCallback> exposureCallback);
|
||||
|
||||
/**
|
||||
* @brief Get the supported Focus modes.
|
||||
*
|
||||
* @return Returns vector of camera_af_mode_t supported exposure modes.
|
||||
*/
|
||||
std::vector<camera_af_mode_t> GetSupportedFocusModes();
|
||||
|
||||
/**
|
||||
* @brief Set the focus callback.
|
||||
* which will be called when there is focus state change.
|
||||
*
|
||||
* @param The ExposureCallback pointer.
|
||||
*/
|
||||
void SetFocusCallback(std::shared_ptr<FocusCallback> focusCallback);
|
||||
|
||||
/**
|
||||
* @brief Set exposure mode.
|
||||
*
|
||||
* @param camera_ae_mode_t exposure mode to be set.
|
||||
*/
|
||||
void SetFocusMode(camera_af_mode_t focusMode);
|
||||
|
||||
/**
|
||||
* @brief Get the current focus mode.
|
||||
*
|
||||
* @return Returns current focus mode.
|
||||
*/
|
||||
camera_af_mode_t GetFocusMode();
|
||||
|
||||
/**
|
||||
* @brief Get the supported Zoom Ratio range.
|
||||
*
|
||||
* @return Returns vector<float> of supported Zoom ratio range.
|
||||
*/
|
||||
std::vector<float> GetSupportedZoomRatioRange();
|
||||
|
||||
/**
|
||||
* @brief Get the current Zoom Ratio.
|
||||
*
|
||||
* @return Returns current Zoom Ratio.
|
||||
*/
|
||||
float GetZoomRatio();
|
||||
|
||||
/**
|
||||
* @brief Set Zoom ratio.
|
||||
*
|
||||
* @param Zoom ratio to be set.
|
||||
*/
|
||||
void SetZoomRatio(float zoomRatio);
|
||||
|
||||
/**
|
||||
* @brief Get the supported Focus modes.
|
||||
*
|
||||
* @return Returns vector of camera_af_mode_t supported exposure modes.
|
||||
*/
|
||||
std::vector<camera_flash_mode_enum_t> GetSupportedFlashModes();
|
||||
|
||||
/**
|
||||
* @brief Get the current flash mode.
|
||||
*
|
||||
* @return Returns current flash mode.
|
||||
*/
|
||||
camera_flash_mode_enum_t GetFlashMode();
|
||||
|
||||
/**
|
||||
* @brief Set flash mode.
|
||||
*
|
||||
* @param camera_flash_mode_enum_t flash mode to be set.
|
||||
*/
|
||||
void SetFlashMode(camera_flash_mode_enum_t flashMode);
|
||||
|
||||
/**
|
||||
* @brief Set the error callback.
|
||||
* which will be called when error occurs.
|
||||
*
|
||||
* @param The ErrorCallback pointer.
|
||||
*/
|
||||
void SetErrorCallback(std::shared_ptr<ErrorCallback> errorCallback);
|
||||
|
||||
/**
|
||||
* @brief Release camera input.
|
||||
*/
|
||||
void Release() override;
|
||||
|
||||
/**
|
||||
* @brief Get Camera Device.
|
||||
*
|
||||
* @return Returns Camera Device pointer.
|
||||
*/
|
||||
sptr<ICameraDeviceService> GetCameraDevice();
|
||||
|
||||
/**
|
||||
* @brief Get ErrorCallback pointer.
|
||||
*
|
||||
* @return Returns ErrorCallback pointer.
|
||||
*/
|
||||
std::shared_ptr<ErrorCallback> GetErrorCallback();
|
||||
|
||||
/**
|
||||
* @brief This function is called when there is focus state change
|
||||
* and process the focus state callback.
|
||||
*
|
||||
* @param result metadata got from callback from service layer.
|
||||
*/
|
||||
void ProcessAutoFocusUpdates(const std::shared_ptr<CameraMetadata> &result);
|
||||
|
||||
/**
|
||||
* @brief Get current Camera Settings.
|
||||
*
|
||||
* @return Returns string encoded metadata setting.
|
||||
*/
|
||||
std::string GetCameraSettings();
|
||||
|
||||
/**
|
||||
* @brief set the camera metadata setting.
|
||||
*
|
||||
* @param string encoded camera metadata setting.
|
||||
* @return Returns 0 if success or appropriate error code if failed.
|
||||
*/
|
||||
int32_t SetCameraSettings(std::string setting);
|
||||
|
||||
private:
|
||||
|
||||
@@ -59,21 +59,130 @@ public:
|
||||
|
||||
class CameraManager : public RefBase {
|
||||
public:
|
||||
/**
|
||||
* @brief Get camera manager instance.
|
||||
*
|
||||
* @return Returns pointer to camera manager instance.
|
||||
*/
|
||||
static sptr<CameraManager> &GetInstance();
|
||||
|
||||
/**
|
||||
* @brief Get all available cameras.
|
||||
*
|
||||
* @return Returns vector of cameraInfo of available camera.
|
||||
*/
|
||||
std::vector<sptr<CameraInfo>> GetCameras();
|
||||
|
||||
/**
|
||||
* @brief Create camera input instance.
|
||||
*
|
||||
* @param The cameraInfo for which input has to be created.
|
||||
* @return Returns pointer to camera input instance.
|
||||
*/
|
||||
sptr<CameraInput> CreateCameraInput(sptr<CameraInfo> &camera);
|
||||
|
||||
/**
|
||||
* @brief Create capture session.
|
||||
*
|
||||
* @return Returns pointer to capture session.
|
||||
*/
|
||||
sptr<CaptureSession> CreateCaptureSession();
|
||||
|
||||
/**
|
||||
* @brief Create photo output instance using surface.
|
||||
*
|
||||
* @param The surface to be used for photo output.
|
||||
* @return Returns pointer to photo output instance.
|
||||
*/
|
||||
sptr<PhotoOutput> CreatePhotoOutput(sptr<Surface> &surface);
|
||||
|
||||
/**
|
||||
* @brief Create photo output instance using IBufferProducer.
|
||||
*
|
||||
* @param The IBufferProducer to be used for photo output.
|
||||
* @param The format to be used for photo capture.
|
||||
* @return Returns pointer to photo output instance.
|
||||
*/
|
||||
sptr<PhotoOutput> CreatePhotoOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format);
|
||||
|
||||
/**
|
||||
* @brief Create video output instance using surface.
|
||||
*
|
||||
* @param The surface to be used for video output.
|
||||
* @return Returns pointer to video output instance.
|
||||
*/
|
||||
sptr<VideoOutput> CreateVideoOutput(sptr<Surface> &surface);
|
||||
|
||||
/**
|
||||
* @brief Create video output instance using IBufferProducer.
|
||||
*
|
||||
* @param The IBufferProducer to be used for video output.
|
||||
* @param The format to be used for video capture.
|
||||
* @return Returns pointer to video output instance.
|
||||
*/
|
||||
sptr<VideoOutput> CreateVideoOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format);
|
||||
|
||||
/**
|
||||
* @brief Create preview output instance using surface.
|
||||
*
|
||||
* @param The surface to be used for preview.
|
||||
* @return Returns pointer to preview output instance.
|
||||
*/
|
||||
sptr<PreviewOutput> CreatePreviewOutput(sptr<Surface> surface);
|
||||
|
||||
/**
|
||||
* @brief Create preview output instance using IBufferProducer.
|
||||
*
|
||||
* @param The IBufferProducer to be used for preview output.
|
||||
* @param The format to be used for preview.
|
||||
* @return Returns pointer to video preview instance.
|
||||
*/
|
||||
sptr<PreviewOutput> CreatePreviewOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format);
|
||||
|
||||
/**
|
||||
* @brief Create preview output instance using surface
|
||||
* with custom width and height.
|
||||
*
|
||||
* @param The surface to be used for preview.
|
||||
* @param preview width.
|
||||
* @param preview height.
|
||||
* @return Returns pointer to preview output instance.
|
||||
*/
|
||||
sptr<PreviewOutput> CreateCustomPreviewOutput(sptr<Surface> surface, int32_t width, int32_t height);
|
||||
|
||||
/**
|
||||
* @brief Create preview output instance using IBufferProducer
|
||||
* with custom width and height.
|
||||
*
|
||||
* @param The IBufferProducer to be used for preview output.
|
||||
* @param The format to be used for preview.
|
||||
* @param preview width.
|
||||
* @param preview height.
|
||||
* @return Returns pointer to preview output instance.
|
||||
*/
|
||||
sptr<PreviewOutput> CreateCustomPreviewOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
|
||||
int32_t width, int32_t height);
|
||||
|
||||
/**
|
||||
* @brief Set camera manager callback.
|
||||
*
|
||||
* @param CameraManagerCallback pointer.
|
||||
*/
|
||||
void SetCallback(std::shared_ptr<CameraManagerCallback> callback);
|
||||
|
||||
/**
|
||||
* @brief Get the application callback.
|
||||
*
|
||||
* @return CameraManagerCallback pointer is set by application.
|
||||
*/
|
||||
std::shared_ptr<CameraManagerCallback> GetApplicationCallback();
|
||||
|
||||
/**
|
||||
* @brief Get cameraInfo of specific camera id.
|
||||
*
|
||||
* @param std::string camera id.
|
||||
* @return Returns pointer to cameraInfo of given Id if found else return nullptr.
|
||||
*/
|
||||
sptr<CameraInfo> GetCameraInfo(std::string cameraId);
|
||||
|
||||
static const std::string surfaceFormat;
|
||||
|
||||
@@ -23,8 +23,12 @@ namespace CameraStandard {
|
||||
class CaptureInput : public RefBase {
|
||||
public:
|
||||
virtual ~CaptureInput() {}
|
||||
|
||||
/**
|
||||
* @brief Release camera input.
|
||||
*/
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
} // namespace CameraStandard
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_CAMERA_CAPTURE_INPUT_H
|
||||
#endif // OHOS_CAMERA_CAPTURE_INPUT_H
|
||||
|
||||
@@ -29,6 +29,10 @@ class CaptureOutput : public RefBase {
|
||||
public:
|
||||
explicit CaptureOutput(CAPTURE_OUTPUT_TYPE type);
|
||||
virtual ~CaptureOutput() {}
|
||||
|
||||
/**
|
||||
* @brief Releases the instance of CaptureOutput.
|
||||
*/
|
||||
virtual void Release() = 0;
|
||||
CAPTURE_OUTPUT_TYPE GetType();
|
||||
|
||||
|
||||
@@ -27,9 +27,36 @@ class PhotoCallback {
|
||||
public:
|
||||
PhotoCallback() = default;
|
||||
virtual ~PhotoCallback() = default;
|
||||
|
||||
/**
|
||||
* @brief Called when camera capture started.
|
||||
*
|
||||
* @param captureID Obtain the constant capture id for the photo capture callback.
|
||||
*/
|
||||
virtual void OnCaptureStarted(const int32_t captureID) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when camera capture ended.
|
||||
*
|
||||
* @param captureID Obtain the constant capture id for the photo capture callback.
|
||||
* @param frameCount Obtain the constant number of frames for the photo capture callback.
|
||||
*/
|
||||
virtual void OnCaptureEnded(const int32_t captureID, const int32_t frameCount) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when camera capture ended.
|
||||
*
|
||||
* @param captureId Obtain the constant capture id for the photo capture callback.
|
||||
* @param timestamp Represents timestamp information for the photo capture callback
|
||||
*/
|
||||
virtual void OnFrameShutter(const int32_t captureId, const uint64_t timestamp) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when error occured during camera capture.
|
||||
*
|
||||
* @param captureId Indicates the pointer in which captureId will be requested.
|
||||
* @param errorCode Indicates a {@link ErrorCode} which will give information for photo capture callback error
|
||||
*/
|
||||
virtual void OnCaptureError(const int32_t captureId, const int32_t errorCode) const = 0;
|
||||
};
|
||||
class PhotoCaptureSetting {
|
||||
@@ -47,13 +74,62 @@ public:
|
||||
};
|
||||
PhotoCaptureSetting();
|
||||
virtual ~PhotoCaptureSetting() = default;
|
||||
|
||||
/**
|
||||
* @brief Get the quality level for the photo capture settings.
|
||||
*
|
||||
* @return Returns the quality level.
|
||||
*/
|
||||
QualityLevel GetQuality();
|
||||
|
||||
/**
|
||||
* @brief Set the quality level for the photo capture settings.
|
||||
*
|
||||
* @param qualityLevel to be set.
|
||||
*/
|
||||
void SetQuality(QualityLevel qualityLevel);
|
||||
|
||||
/**
|
||||
* @brief Get rotation information for the photo capture settings.
|
||||
*
|
||||
* @return Returns the RotationConfig.
|
||||
*/
|
||||
RotationConfig GetRotation();
|
||||
|
||||
/**
|
||||
* @brief Set the Rotation for the photo capture settings.
|
||||
*
|
||||
* @param rotationvalue to be set.
|
||||
*/
|
||||
void SetRotation(RotationConfig rotationvalue);
|
||||
|
||||
/**
|
||||
* @brief Set the GPS Location for the photo capture settings.
|
||||
*
|
||||
* @param latitude value to be set.
|
||||
* @param longitude value to be set.
|
||||
*/
|
||||
void SetGpsLocation(double latitude, double longitude);
|
||||
|
||||
/**
|
||||
* @brief To check the photo capture is mirrored or not.
|
||||
*
|
||||
* @return Returns true/false if the photo capture is mirrored/not-mirrored respectively.
|
||||
*/
|
||||
bool IsMirrored();
|
||||
|
||||
/**
|
||||
* @brief Set the mirror option for the photo capture.
|
||||
*
|
||||
* @param boolean true/false to set/unset mirror respectively.
|
||||
*/
|
||||
void SetMirror(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Get the photo capture settings metadata information.
|
||||
*
|
||||
* @return Returns the pointer where CameraMetadata information is present.
|
||||
*/
|
||||
std::shared_ptr<CameraMetadata> GetCaptureMetadataSetting();
|
||||
|
||||
private:
|
||||
@@ -63,12 +139,48 @@ private:
|
||||
class PhotoOutput : public CaptureOutput {
|
||||
public:
|
||||
explicit PhotoOutput(sptr<IStreamCapture> &streamCapture);
|
||||
/**
|
||||
* @brief Get capture stream information.
|
||||
*
|
||||
* @return Returns the pointer where IStreamCapture is present.
|
||||
*/
|
||||
sptr<IStreamCapture> GetStreamCapture();
|
||||
|
||||
/**
|
||||
* @brief Set the photo callback.
|
||||
*
|
||||
* @param callback Requested for the pointer where photo callback is present.
|
||||
*/
|
||||
void SetCallback(std::shared_ptr<PhotoCallback> callback);
|
||||
|
||||
/**
|
||||
* @brief Photo capture request using photocapturesettings.
|
||||
*
|
||||
* @param photoCaptureSettings Requested for the photoCaptureSettings object which has metadata
|
||||
* information such as: Rotation, Location, Mirror & Quality.
|
||||
*/
|
||||
int32_t Capture(std::shared_ptr<PhotoCaptureSetting> photoCaptureSettings);
|
||||
|
||||
/**
|
||||
* @brief Initiate for the photo capture.
|
||||
*/
|
||||
int32_t Capture();
|
||||
|
||||
/**
|
||||
* @brief cancelling the photo capture. Applicable only for burst/ continuous capture.
|
||||
*/
|
||||
int32_t CancelCapture();
|
||||
|
||||
/**
|
||||
* @brief Releases the instance of PhotoOutput.
|
||||
*/
|
||||
void Release() override;
|
||||
|
||||
/**
|
||||
* @brief Get the application callback information.
|
||||
*
|
||||
* @return Returns the pointer to PhotoCallback.
|
||||
*/
|
||||
std::shared_ptr<PhotoCallback> GetApplicationCallback();
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,17 +26,55 @@ class PreviewCallback {
|
||||
public:
|
||||
PreviewCallback() = default;
|
||||
virtual ~PreviewCallback() = default;
|
||||
|
||||
/**
|
||||
* @brief Called when preview frame is started rendering.
|
||||
*/
|
||||
virtual void OnFrameStarted() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when preview frame is ended.
|
||||
*
|
||||
* @param frameCount Indicates number of frames captured.
|
||||
*/
|
||||
virtual void OnFrameEnded(const int32_t frameCount) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when error occured during preview rendering.
|
||||
*
|
||||
* @param errorCode Indicates a {@link ErrorCode} which will give information for preview callback error.
|
||||
*/
|
||||
virtual void OnError(const int32_t errorCode) const = 0;
|
||||
};
|
||||
|
||||
class PreviewOutput : public CaptureOutput {
|
||||
public:
|
||||
explicit PreviewOutput(sptr<IStreamRepeat> &streamRepeat);
|
||||
|
||||
/**
|
||||
* @brief Set the preview callback for the preview output.
|
||||
*
|
||||
* @param PreviewCallback to be triggered.
|
||||
*/
|
||||
void SetCallback(std::shared_ptr<PreviewCallback> callback);
|
||||
|
||||
/**
|
||||
* @brief Releases a instance of the preview output.
|
||||
*/
|
||||
void Release() override;
|
||||
|
||||
/**
|
||||
* @brief Get repeat stream for the preview output.
|
||||
*
|
||||
* @return Returns the pointer to IStreamRepeat.
|
||||
*/
|
||||
sptr<IStreamRepeat> GetStreamRepeat();
|
||||
|
||||
/**
|
||||
* @brief Get the application callback information.
|
||||
*
|
||||
* @return Returns the pointer application callback.
|
||||
*/
|
||||
std::shared_ptr<PreviewCallback> GetApplicationCallback();
|
||||
|
||||
private:
|
||||
|
||||
@@ -28,24 +28,96 @@ class VideoCallback {
|
||||
public:
|
||||
VideoCallback() = default;
|
||||
virtual ~VideoCallback() = default;
|
||||
|
||||
/**
|
||||
* @brief Called when video frame is started rendering.
|
||||
*/
|
||||
virtual void OnFrameStarted() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when video frame is ended.
|
||||
*
|
||||
* @param frameCount Indicates number of frames captured.
|
||||
*/
|
||||
virtual void OnFrameEnded(const int32_t frameCount) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Called when error occured during video rendering.
|
||||
*
|
||||
* @param errorCode Indicates a {@link ErrorCode} which will give information for video callback error.
|
||||
*/
|
||||
virtual void OnError(const int32_t errorCode) const = 0;
|
||||
};
|
||||
|
||||
class VideoOutput : public CaptureOutput {
|
||||
public:
|
||||
explicit VideoOutput(sptr<IStreamRepeat> &streamRepeat);
|
||||
|
||||
/**
|
||||
* @brief Releases a instance of the VideoOutput.
|
||||
*/
|
||||
void Release() override;
|
||||
|
||||
/**
|
||||
* @brief Get repeated stream for the video output.
|
||||
*
|
||||
* @return Returns the pointer to IStreamRepeat.
|
||||
*/
|
||||
sptr<IStreamRepeat> GetStreamRepeat();
|
||||
|
||||
/**
|
||||
* @brief Set the video callback for the video output.
|
||||
*
|
||||
* @param VideoCallback pointer to be triggered.
|
||||
*/
|
||||
void SetCallback(std::shared_ptr<VideoCallback> callback);
|
||||
|
||||
/**
|
||||
* @brief Get supported Fps for the video output.
|
||||
*
|
||||
* @return Returns the vector<float> of Fps values for the video output.
|
||||
*/
|
||||
std::vector<float> GetSupportedFps();
|
||||
|
||||
/**
|
||||
* @brief Get current Fps value.
|
||||
*
|
||||
* @return Returns a float current Fps for the video output.
|
||||
*/
|
||||
float GetFps();
|
||||
|
||||
/**
|
||||
* @brief Set Fps value for the video output.
|
||||
*
|
||||
* @param video frame rate to be set.
|
||||
*/
|
||||
int32_t SetFps(float fps);
|
||||
|
||||
/**
|
||||
* @brief Start the video capture.
|
||||
*/
|
||||
int32_t Start();
|
||||
|
||||
/**
|
||||
* @brief Stop the video capture.
|
||||
*/
|
||||
int32_t Stop();
|
||||
|
||||
/**
|
||||
* @brief Pause the video capture.
|
||||
*/
|
||||
int32_t Pause();
|
||||
|
||||
/**
|
||||
* @brief Resume the paused video capture.
|
||||
*/
|
||||
int32_t Resume();
|
||||
|
||||
/**
|
||||
* @brief Get the application callback information.
|
||||
*
|
||||
* @return VideoCallback pointer set by application.
|
||||
*/
|
||||
std::shared_ptr<VideoCallback> GetApplicationCallback();
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,6 +29,11 @@ class SessionCallback {
|
||||
public:
|
||||
SessionCallback() = default;
|
||||
virtual ~SessionCallback() = default;
|
||||
/**
|
||||
* @brief Called when error occured during capture session callback.
|
||||
*
|
||||
* @param errorCode Indicates a {@link ErrorCode} which will give information for capture session callback error.
|
||||
*/
|
||||
virtual void OnError(int32_t errorCode) = 0;
|
||||
};
|
||||
|
||||
@@ -36,16 +41,72 @@ class CaptureSession : public RefBase {
|
||||
public:
|
||||
explicit CaptureSession(sptr<ICaptureSession> &captureSession);
|
||||
~CaptureSession() {}
|
||||
|
||||
/**
|
||||
* @brief Begin the capture session config.
|
||||
*/
|
||||
int32_t BeginConfig();
|
||||
|
||||
/**
|
||||
* @brief Commit the capture session config.
|
||||
*/
|
||||
int32_t CommitConfig();
|
||||
|
||||
/**
|
||||
* @brief Add CaptureInput for the capture session.
|
||||
*
|
||||
* @param CaptureInput to be added to session.
|
||||
*/
|
||||
int32_t AddInput(sptr<CaptureInput> &input);
|
||||
|
||||
/**
|
||||
* @brief Add CaptureOutput for the capture session.
|
||||
*
|
||||
* @param CaptureOutput to be added to session.
|
||||
*/
|
||||
int32_t AddOutput(sptr<CaptureOutput> &output);
|
||||
|
||||
/**
|
||||
* @brief Remove CaptureInput for the capture session.
|
||||
*
|
||||
* @param CaptureInput to be removed from session.
|
||||
*/
|
||||
int32_t RemoveInput(sptr<CaptureInput> &input);
|
||||
|
||||
/**
|
||||
* @brief Remove CaptureOutput for the capture session.
|
||||
*
|
||||
* @param CaptureOutput to be removed from session.
|
||||
*/
|
||||
int32_t RemoveOutput(sptr<CaptureOutput> &output);
|
||||
|
||||
/**
|
||||
* @brief Starts session and preview.
|
||||
*/
|
||||
int32_t Start();
|
||||
|
||||
/**
|
||||
* @brief Stop session and preview..
|
||||
*/
|
||||
int32_t Stop();
|
||||
|
||||
/**
|
||||
* @brief Set the session callback for the capture session.
|
||||
*
|
||||
* @param SessionCallback pointer to be triggered.
|
||||
*/
|
||||
void SetCallback(std::shared_ptr<SessionCallback> callback);
|
||||
|
||||
/**
|
||||
* @brief Get the application callback information.
|
||||
*
|
||||
* @return Returns the pointer to SessionCallback set by application.
|
||||
*/
|
||||
std::shared_ptr<SessionCallback> GetApplicationCallback();
|
||||
|
||||
/**
|
||||
* @brief Releases CaptureSession instance.
|
||||
*/
|
||||
void Release();
|
||||
|
||||
private:
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "input/camera_input.h"
|
||||
#include "input/camera_manager.h"
|
||||
#include "media_log.h"
|
||||
@@ -90,7 +89,7 @@ int main(int argc, char **argv)
|
||||
int32_t photoCaptureCount = 1;
|
||||
bool isResolutionConfigured = false;
|
||||
|
||||
MEDIA_DEBUG_LOG("Camera new sample begin.");
|
||||
MEDIA_DEBUG_LOG("Camera new(std::nothrow) sample begin.");
|
||||
// Update sizes if enough number of valid arguments are passed
|
||||
if (argc == validArgCount) {
|
||||
// Validate arguments
|
||||
@@ -244,7 +243,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
photoSurface->SetDefaultWidthAndHeight(photoWidth, photoHeight);
|
||||
photoSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(photoFormat));
|
||||
sptr<SurfaceListener> captureListener = new SurfaceListener("Photo", SurfaceType::PHOTO, photoFd, photoSurface);
|
||||
sptr<SurfaceListener> captureListener = new(std::nothrow) SurfaceListener("Photo", SurfaceType::PHOTO,
|
||||
photoFd, photoSurface);
|
||||
photoSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)captureListener);
|
||||
sptr<CaptureOutput> photoOutput = camManagerObj->CreatePhotoOutput(photoSurface);
|
||||
if (photoOutput == nullptr) {
|
||||
@@ -273,7 +273,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
previewSurface->SetDefaultWidthAndHeight(previewWidth, previewHeight);
|
||||
previewSurface->SetUserData(CameraManager::surfaceFormat, std::to_string(previewFormat));
|
||||
sptr<SurfaceListener> listener = new SurfaceListener("Preview", SurfaceType::PREVIEW, previewFd, previewSurface);
|
||||
sptr<SurfaceListener> listener = new(std::nothrow) SurfaceListener("Preview", SurfaceType::PREVIEW,
|
||||
previewFd, previewSurface);
|
||||
previewSurface->RegisterConsumerListener((sptr<IBufferConsumerListener> &)listener);
|
||||
sptr<CaptureOutput> previewOutput = camManagerObj->CreateCustomPreviewOutput(previewSurface,
|
||||
previewWidth, previewHeight);
|
||||
|
||||
@@ -254,7 +254,7 @@ int32_t CameraCaptureVideo::TakePhoto()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!photoOutput_) {
|
||||
if (photoOutput_ == nullptr) {
|
||||
MEDIA_ERR_LOG("photoOutput_ is null");
|
||||
(void)OHOS::Security::AccessToken::AccessTokenKit::DeleteToken(
|
||||
tokenIdEx.tokenIdExStruct.tokenID);
|
||||
@@ -276,7 +276,7 @@ int32_t CameraCaptureVideo::RecordVideo()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!videoOutput_) {
|
||||
if (videoOutput_ == nullptr) {
|
||||
MEDIA_ERR_LOG("videoOutput_ is null");
|
||||
(void)OHOS::Security::AccessToken::AccessTokenKit::DeleteToken(
|
||||
tokenIdEx.tokenIdExStruct.tokenID);
|
||||
@@ -457,7 +457,7 @@ int32_t CameraCaptureVideo::InitCameraInput()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!cameraManager_) {
|
||||
if (cameraManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("cameraManager_ is null");
|
||||
return result;
|
||||
}
|
||||
@@ -489,20 +489,21 @@ int32_t CameraCaptureVideo::InitPreviewOutput()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!cameraManager_) {
|
||||
if (cameraManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("cameraManager_ is null");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (previewOutput_ == nullptr) {
|
||||
previewSurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
if (!previewSurface_) {
|
||||
if (previewSurface_ == nullptr) {
|
||||
MEDIA_ERR_LOG("previewSurface_ is null");
|
||||
return result;
|
||||
}
|
||||
previewSurface_->SetDefaultWidthAndHeight(previewWidth_, previewHeight_);
|
||||
previewSurface_->SetUserData(CameraManager::surfaceFormat, std::to_string(previewFormat_));
|
||||
previewSurfaceListener_ = new SurfaceListener(testName_, SurfaceType::PREVIEW, fd_, previewSurface_);
|
||||
previewSurfaceListener_ = new(std::nothrow) SurfaceListener(testName_, SurfaceType::PREVIEW,
|
||||
fd_, previewSurface_);
|
||||
previewSurface_->RegisterConsumerListener((sptr<IBufferConsumerListener> &)previewSurfaceListener_);
|
||||
previewOutput_ = cameraManager_->CreatePreviewOutput(previewSurface_);
|
||||
if (previewOutput_ == nullptr) {
|
||||
@@ -520,22 +521,22 @@ int32_t CameraCaptureVideo::InitSecondPreviewOutput()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!cameraManager_) {
|
||||
if (cameraManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("cameraManager_ is null");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (secondPreviewOutput_ == nullptr) {
|
||||
secondPreviewSurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
if (!secondPreviewSurface_) {
|
||||
if (secondPreviewSurface_ == nullptr) {
|
||||
MEDIA_ERR_LOG("secondPreviewSurface_ is null");
|
||||
return result;
|
||||
}
|
||||
secondPreviewSurface_->SetDefaultWidthAndHeight(previewWidth_, previewHeight_);
|
||||
secondPreviewSurface_->SetUserData(CameraManager::surfaceFormat, std::to_string(previewFormat_));
|
||||
secondPreviewSurfaceListener_ = new SurfaceListener(testName_,
|
||||
secondPreviewSurfaceListener_ = new(std::nothrow) SurfaceListener(testName_,
|
||||
SurfaceType::SECOND_PREVIEW, fd_, secondPreviewSurface_);
|
||||
if (!secondPreviewSurfaceListener_) {
|
||||
if (secondPreviewSurfaceListener_ == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to create new SurfaceListener");
|
||||
return result;
|
||||
}
|
||||
@@ -558,21 +559,21 @@ int32_t CameraCaptureVideo::InitPhotoOutput()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!cameraManager_) {
|
||||
if (cameraManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("cameraManager_ is null");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (photoOutput_ == nullptr) {
|
||||
photoSurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
if (!photoSurface_) {
|
||||
if (photoSurface_ == nullptr) {
|
||||
MEDIA_ERR_LOG("photoSurface_ is null");
|
||||
return result;
|
||||
}
|
||||
photoSurface_->SetDefaultWidthAndHeight(photoWidth_, photoHeight_);
|
||||
photoSurface_->SetUserData(CameraManager::surfaceFormat, std::to_string(photoFormat_));
|
||||
photoSurfaceListener_ = new SurfaceListener(testName_, SurfaceType::PHOTO, fd_, photoSurface_);
|
||||
if (!photoSurfaceListener_) {
|
||||
photoSurfaceListener_ = new(std::nothrow) SurfaceListener(testName_, SurfaceType::PHOTO, fd_, photoSurface_);
|
||||
if (photoSurfaceListener_ == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to create new SurfaceListener");
|
||||
return result;
|
||||
}
|
||||
@@ -593,21 +594,21 @@ int32_t CameraCaptureVideo::InitVideoOutput()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!cameraManager_) {
|
||||
if (cameraManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("cameraManager_ is null");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (videoOutput_ == nullptr) {
|
||||
videoSurface_ = Surface::CreateSurfaceAsConsumer();
|
||||
if (!videoSurface_) {
|
||||
if (videoSurface_ == nullptr) {
|
||||
MEDIA_ERR_LOG("videoSurface_ is null");
|
||||
return result;
|
||||
}
|
||||
videoSurface_->SetDefaultWidthAndHeight(videoWidth_, videoHeight_);
|
||||
videoSurface_->SetUserData(CameraManager::surfaceFormat, std::to_string(videoFormat_));
|
||||
videoSurfaceListener_ = new SurfaceListener(testName_, SurfaceType::VIDEO, fd_, videoSurface_);
|
||||
if (!videoSurfaceListener_) {
|
||||
videoSurfaceListener_ = new(std::nothrow) SurfaceListener(testName_, SurfaceType::VIDEO, fd_, videoSurface_);
|
||||
if (videoSurfaceListener_ == nullptr) {
|
||||
MEDIA_ERR_LOG("Failed to create new SurfaceListener");
|
||||
return result;
|
||||
}
|
||||
@@ -628,7 +629,7 @@ int32_t CameraCaptureVideo::AddOutputbyState()
|
||||
{
|
||||
int32_t result = -1;
|
||||
|
||||
if (!captureSession_) {
|
||||
if (captureSession_ == nullptr) {
|
||||
MEDIA_ERR_LOG("captureSession_ is null");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "input/camera_input.h"
|
||||
#include "input/camera_manager.h"
|
||||
#include "media_errors.h"
|
||||
|
||||
@@ -238,7 +238,7 @@ void SurfaceListener::OnBufferAvailable()
|
||||
MEDIA_DEBUG_LOG("SurfaceListener::OnBufferAvailable(), testName_: %{public}s, surfaceType_: %{public}d",
|
||||
testName_, surfaceType_);
|
||||
OHOS::sptr<OHOS::SurfaceBuffer> buffer = nullptr;
|
||||
if (!surface_) {
|
||||
if (surface_ == nullptr) {
|
||||
MEDIA_ERR_LOG("OnBufferAvailable:surface_ is null");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ struct CallbackInfo {
|
||||
|
||||
class PhotoOutputCallback : public PhotoCallback {
|
||||
public:
|
||||
PhotoOutputCallback(napi_env env);
|
||||
explicit PhotoOutputCallback(napi_env env);
|
||||
~PhotoOutputCallback() = default;
|
||||
|
||||
void OnCaptureStarted(const int32_t captureID) const override;
|
||||
|
||||
@@ -46,7 +46,7 @@ static const char CAMERA_PREVIEW_OUTPUT_NAPI_CLASS_NAME[] = "PreviewOutput";
|
||||
|
||||
class PreviewOutputCallback : public PreviewCallback {
|
||||
public:
|
||||
PreviewOutputCallback(napi_env env);
|
||||
explicit PreviewOutputCallback(napi_env env);
|
||||
~PreviewOutputCallback() = default;
|
||||
|
||||
void OnFrameStarted() const override;
|
||||
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
|
||||
class VideoCallbackListener : public VideoCallback {
|
||||
public:
|
||||
VideoCallbackListener(napi_env env);
|
||||
explicit VideoCallbackListener(napi_env env);
|
||||
~VideoCallbackListener() = default;
|
||||
|
||||
void OnFrameStarted() const override;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
|
||||
@@ -56,9 +56,8 @@ int HCameraDeviceCallbackStub::HandleDeviceOnError(MessageParcel& data)
|
||||
int HCameraDeviceCallbackStub::HandleDeviceOnResult(MessageParcel& data)
|
||||
{
|
||||
std::shared_ptr<CameraStandard::CameraMetadata> metadata = nullptr;
|
||||
uint64_t timestamp = 0;
|
||||
uint64_t timestamp = timestamp = data.ReadUint64();
|
||||
|
||||
timestamp = data.ReadUint64();
|
||||
MetadataUtils::DecodeCameraMetadata(data, metadata);
|
||||
return OnResult(timestamp, metadata);
|
||||
}
|
||||
|
||||
@@ -42,9 +42,7 @@ int HCaptureSessionCallbackStub::OnRemoteRequest(
|
||||
|
||||
int HCaptureSessionCallbackStub::HandleSessionOnError(MessageParcel& data)
|
||||
{
|
||||
int32_t errorCode = 0;
|
||||
|
||||
errorCode = data.ReadInt32();
|
||||
int32_t errorCode = data.ReadInt32();
|
||||
return OnError(errorCode);
|
||||
}
|
||||
} // namespace CameraStandard
|
||||
|
||||
@@ -97,7 +97,7 @@ bool IsValidSize(std::shared_ptr<CameraMetadata> cameraAbility, int32_t format,
|
||||
#ifndef PRODUCT_M40
|
||||
return true;
|
||||
#endif
|
||||
uint32_t unitLen = 3;
|
||||
constexpr uint32_t unitLen = 3;
|
||||
camera_metadata_item_t item;
|
||||
int ret = FindCameraMetadataItem(cameraAbility->get(), OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, &item);
|
||||
if (ret != CAM_META_SUCCESS) {
|
||||
@@ -105,7 +105,7 @@ bool IsValidSize(std::shared_ptr<CameraMetadata> cameraAbility, int32_t format,
|
||||
return false;
|
||||
}
|
||||
if (item.count % unitLen != 0) {
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}d", item.count);
|
||||
MEDIA_ERR_LOG("Invalid stream configuration count: %{public}u", item.count);
|
||||
return false;
|
||||
}
|
||||
for (uint32_t index = 0; index < item.count; index += 3) {
|
||||
|
||||
@@ -134,7 +134,7 @@ int32_t HCameraHostManager::CameraHostInfo::GetCameraAbility(std::string& camera
|
||||
ability = deviceInfo->ability;
|
||||
} else {
|
||||
std::lock_guard<std::mutex> lock(deviceInfo->mutex);
|
||||
if (!cameraHostProxy_) {
|
||||
if (cameraHostProxy_ == nullptr) {
|
||||
MEDIA_ERR_LOG("CameraHostInfo::GetCameraAbility cameraHostProxy_ is null");
|
||||
return CAMERA_UNKNOWN_ERROR;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ int32_t HCameraHostManager::CameraHostInfo::OpenCamera(std::string& cameraId,
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(deviceInfo->mutex);
|
||||
if (!cameraHostProxy_) {
|
||||
if (cameraHostProxy_ == nullptr) {
|
||||
MEDIA_ERR_LOG("CameraHostInfo::OpenCamera cameraHostProxy_ is null");
|
||||
return CAMERA_UNKNOWN_ERROR;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ int32_t HCameraHostManager::CameraHostInfo::OpenCamera(std::string& cameraId,
|
||||
int32_t HCameraHostManager::CameraHostInfo::SetFlashlight(const std::string& cameraId, bool isEnable)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!cameraHostProxy_) {
|
||||
if (cameraHostProxy_ == nullptr) {
|
||||
MEDIA_ERR_LOG("CameraHostInfo::SetFlashlight cameraHostProxy_ is null");
|
||||
return CAMERA_UNKNOWN_ERROR;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ int32_t HCameraHostManager::GetCameraAbility(std::string &cameraId,
|
||||
std::shared_ptr<CameraMetadata> &ability)
|
||||
{
|
||||
auto cameraHostInfo = FindCameraHostInfo(cameraId);
|
||||
if (!cameraHostInfo) {
|
||||
if (cameraHostInfo == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraHostManager::OpenCameraDevice failed with invalid device info.");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
@@ -390,7 +390,7 @@ int32_t HCameraHostManager::OpenCameraDevice(std::string &cameraId,
|
||||
sptr<Camera::ICameraDevice> &pDevice)
|
||||
{
|
||||
auto cameraHostInfo = FindCameraHostInfo(cameraId);
|
||||
if (!cameraHostInfo) {
|
||||
if (cameraHostInfo == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraHostManager::OpenCameraDevice failed with invalid device info");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ int32_t HCameraHostManager::OpenCameraDevice(std::string &cameraId,
|
||||
int32_t HCameraHostManager::SetFlashlight(const std::string& cameraId, bool isEnable)
|
||||
{
|
||||
auto cameraHostInfo = FindCameraHostInfo(cameraId);
|
||||
if (!cameraHostInfo) {
|
||||
if (cameraHostInfo == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraHostManager::OpenCameraDevice failed with invalid device info");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
@@ -437,7 +437,8 @@ void HCameraHostManager::AddCameraHost(const std::string& svcName)
|
||||
MEDIA_INFO_LOG("HCameraHostManager::AddCameraHost camera host %{public}s already exists", svcName.c_str());
|
||||
return;
|
||||
}
|
||||
sptr<HCameraHostManager::CameraHostInfo> cameraHost = new HCameraHostManager::CameraHostInfo(this, svcName);
|
||||
sptr<HCameraHostManager::CameraHostInfo> cameraHost = new(std::nothrow) HCameraHostManager::CameraHostInfo
|
||||
(this, svcName);
|
||||
if (!cameraHost->Init()) {
|
||||
MEDIA_ERR_LOG("HCameraHostManager::AddCameraHost failed due to init failure");
|
||||
return;
|
||||
|
||||
@@ -44,9 +44,9 @@ HCameraService::~HCameraService()
|
||||
|
||||
void HCameraService::OnStart()
|
||||
{
|
||||
if (!cameraHostManager_) {
|
||||
cameraHostManager_ = new HCameraHostManager(this);
|
||||
if (!cameraHostManager_) {
|
||||
if (cameraHostManager_ == nullptr) {
|
||||
cameraHostManager_ = new(std::nothrow) HCameraHostManager(this);
|
||||
if (cameraHostManager_ == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService OnStart failed to create HCameraHostManager obj");
|
||||
return;
|
||||
}
|
||||
@@ -127,13 +127,13 @@ int32_t HCameraService::CreateCameraDevice(std::string cameraId, sptr<ICameraDev
|
||||
}
|
||||
|
||||
if (cameraDeviceCallback_ == nullptr) {
|
||||
cameraDeviceCallback_ = new CameraDeviceCallback();
|
||||
if (!cameraDeviceCallback_) {
|
||||
cameraDeviceCallback_ = new(std::nothrow) CameraDeviceCallback();
|
||||
if (cameraDeviceCallback_ == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreateCameraDevice CameraDeviceCallback allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
}
|
||||
}
|
||||
cameraDevice = new HCameraDevice(cameraHostManager_, cameraDeviceCallback_, cameraId);
|
||||
cameraDevice = new(std::nothrow) HCameraDevice(cameraHostManager_, cameraDeviceCallback_, cameraId);
|
||||
if (cameraDevice == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreateCameraDevice HCameraDevice allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
@@ -147,14 +147,14 @@ int32_t HCameraService::CreateCaptureSession(sptr<ICaptureSession> &session)
|
||||
{
|
||||
sptr<HCaptureSession> captureSession;
|
||||
if (streamOperatorCallback_ == nullptr) {
|
||||
streamOperatorCallback_ = new StreamOperatorCallback();
|
||||
streamOperatorCallback_ = new(std::nothrow) StreamOperatorCallback();
|
||||
if (streamOperatorCallback_ == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreateCaptureSession streamOperatorCallback_ allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
captureSession = new HCaptureSession(cameraHostManager_, streamOperatorCallback_);
|
||||
captureSession = new(std::nothrow) HCaptureSession(cameraHostManager_, streamOperatorCallback_);
|
||||
if (captureSession == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreateCaptureSession HCaptureSession allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
@@ -170,7 +170,7 @@ int32_t HCameraService::CreatePhotoOutput(const sptr<OHOS::IBufferProducer> &pro
|
||||
MEDIA_ERR_LOG("HCameraService::CreatePhotoOutput producer is null");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
sptr<HStreamCapture> streamCapture = new HStreamCapture(producer, format);
|
||||
sptr<HStreamCapture> streamCapture = new(std::nothrow) HStreamCapture(producer, format);
|
||||
if (streamCapture == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreatePhotoOutput HStreamCapture allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
@@ -188,7 +188,7 @@ int32_t HCameraService::CreatePreviewOutput(const sptr<OHOS::IBufferProducer> &p
|
||||
MEDIA_ERR_LOG("HCameraService::CreatePreviewOutput producer is null");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
streamRepeatPreview = new HStreamRepeat(producer, format);
|
||||
streamRepeatPreview = new(std::nothrow) HStreamRepeat(producer, format);
|
||||
if (streamRepeatPreview == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreatePreviewOutput HStreamRepeat allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
@@ -206,7 +206,7 @@ int32_t HCameraService::CreateCustomPreviewOutput(const sptr<OHOS::IBufferProduc
|
||||
MEDIA_ERR_LOG("HCameraService::CreateCustomPreviewOutput producer is null or invalid custom size is set");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
streamRepeatPreview = new HStreamRepeat(producer, format, width, height);
|
||||
streamRepeatPreview = new(std::nothrow) HStreamRepeat(producer, format, width, height);
|
||||
if (streamRepeatPreview == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreateCustomPreviewOutput HStreamRepeat allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
@@ -224,7 +224,7 @@ int32_t HCameraService::CreateVideoOutput(const sptr<OHOS::IBufferProducer> &pro
|
||||
MEDIA_ERR_LOG("HCameraService::CreateVideoOutput producer is null");
|
||||
return CAMERA_INVALID_ARG;
|
||||
}
|
||||
streamRepeatVideo = new HStreamRepeat(producer, format, true);
|
||||
streamRepeatVideo = new(std::nothrow) HStreamRepeat(producer, format, true);
|
||||
if (streamRepeatVideo == nullptr) {
|
||||
MEDIA_ERR_LOG("HCameraService::CreateVideoOutput HStreamRepeat allocation failed");
|
||||
return CAMERA_ALLOC_ERROR;
|
||||
@@ -311,7 +311,7 @@ void HCameraService::CameraDumpStreaminfo(common_metadata_header_t *metadataEntr
|
||||
{
|
||||
camera_metadata_item_t item;
|
||||
int ret;
|
||||
uint32_t unitLen = 3;
|
||||
constexpr uint32_t unitLen = 3;
|
||||
uint32_t widthOffset = 1;
|
||||
uint32_t heightOffset = 2;
|
||||
dumpString += " ### Camera Available stream configuration List: \n";
|
||||
|
||||
@@ -511,7 +511,7 @@ int32_t HCaptureSession::HandleCaptureOuputsConfig(sptr<HCameraDevice> &device)
|
||||
streamId = streamId_;
|
||||
for (auto item = tempStreamCaptures_.begin(); item != tempStreamCaptures_.end(); ++item) {
|
||||
curStreamCapture = *item;
|
||||
if (!curStreamCapture) {
|
||||
if (curStreamCapture == nullptr) {
|
||||
MEDIA_ERR_LOG("HCaptureSession::HandleCaptureOuputsConfig() curStreamCapture is null");
|
||||
return CAMERA_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void HStreamRepeat::SetStreamInfo(std::shared_ptr<Camera::StreamInfo> streamInfo
|
||||
#endif
|
||||
}
|
||||
MEDIA_INFO_LOG("HStreamRepeat::SetStreamInfo pixelFormat is %{public}d", pixelFormat);
|
||||
if (!streamInfo) {
|
||||
if (streamInfo == nullptr) {
|
||||
MEDIA_ERR_LOG("HStreamRepeat::SetStreamInfo null");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user