From 8b42796fcef6e242b2d9233dc28eceb1c1f1718e Mon Sep 17 00:00:00 2001 From: FileStream Date: Sat, 14 Sep 2024 07:46:01 +0000 Subject: [PATCH] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5=20?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=B0=B4=E5=8D=B0=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: FileStream --- frameworks/js/avrecorder/avrecorder_napi.cpp | 337 +----------------- frameworks/js/avrecorder/avrecorder_napi.h | 45 +-- .../js/recorder/video_recorder_napi.cpp | 4 +- frameworks/native/recorder/recorder_impl.cpp | 13 +- frameworks/native/recorder/recorder_impl.h | 3 +- interfaces/inner_api/native/recorder.h | 23 +- .../histreamer/recorder/hirecorder_impl.cpp | 29 -- .../histreamer/recorder/hirecorder_impl.h | 6 +- services/include/i_recorder_service.h | 11 - .../services/engine_intf/i_recorder_engine.h | 8 - .../recorder/client/recorder_client.cpp | 18 - .../recorder/client/recorder_client.h | 2 - .../ipc/i_standard_recorder_service.h | 4 - .../recorder/ipc/recorder_service_proxy.cpp | 35 -- .../recorder/ipc/recorder_service_proxy.h | 2 - .../recorder/ipc/recorder_service_stub.cpp | 33 -- .../recorder/ipc/recorder_service_stub.h | 4 - .../recorder/server/recorder_server.cpp | 32 -- .../recorder/server/recorder_server.h | 2 - 19 files changed, 27 insertions(+), 584 deletions(-) diff --git a/frameworks/js/avrecorder/avrecorder_napi.cpp b/frameworks/js/avrecorder/avrecorder_napi.cpp index 95f1c4890..01996345d 100644 --- a/frameworks/js/avrecorder/avrecorder_napi.cpp +++ b/frameworks/js/avrecorder/avrecorder_napi.cpp @@ -86,8 +86,6 @@ napi_value AVRecorderNapi::Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("getCurrentAudioCapturerInfo", JsGetCurrentAudioCapturerInfo), DECLARE_NAPI_FUNCTION("getAudioCapturerMaxAmplitude", JsGetAudioCapturerMaxAmplitude), DECLARE_NAPI_FUNCTION("getAvailableEncoder", JsGetAvailableEncoder), - DECLARE_NAPI_FUNCTION("setWatermark", JsSetWatermark), - DECLARE_NAPI_FUNCTION("isWatermarkSupported", JsIsWatermarkSupported), DECLARE_NAPI_GETTER("state", JsGetState), }; @@ -332,57 +330,6 @@ napi_value AVRecorderNapi::JsSetOrientationHint(napi_env env, napi_callback_info return result; } -napi_value AVRecorderNapi::JsSetWatermark(napi_env env, napi_callback_info info) -{ - MediaTrace trace("AVRecorder::JsSetWatermark"); - const std::string &opt = AVRecordergOpt::SET_WATERMARK; - MEDIA_LOGI("Js %{public}s Start", opt.c_str()); - - const int32_t maxParam = 2; // pixelMap + WatermarkConfig - size_t argCount = maxParam; - napi_value args[maxParam] = { nullptr }; - - napi_value result = nullptr; - napi_get_undefined(env, &result); - - auto asyncCtx = std::make_unique(env); - CHECK_AND_RETURN_RET_LOG(asyncCtx != nullptr, result, "failed to get AsyncContext"); - asyncCtx->napi = AVRecorderNapi::GetJsInstanceAndArgs(env, info, argCount, args); - CHECK_AND_RETURN_RET_LOG(asyncCtx->napi != nullptr, result, "failed to GetJsInstanceAndArgs"); - CHECK_AND_RETURN_RET_LOG(asyncCtx->napi->taskQue_ != nullptr, result, "taskQue is nullptr!"); - - asyncCtx->deferred = CommonNapi::CreatePromise(env, nullptr, result); - - if (asyncCtx->napi->CheckStateMachine(opt) == MSERR_OK) { - if (asyncCtx->napi->GetWatermarkParameter(asyncCtx, env, args) == MSERR_OK) { - asyncCtx->task_ = AVRecorderNapi::SetWatermarkTask(asyncCtx); - (void)asyncCtx->napi->taskQue_->EnqueueTask(asyncCtx->task_); - } - } else { - asyncCtx->AVRecorderSignError(MSERR_INVALID_OPERATION, opt, ""); - } - - napi_value resource = nullptr; - napi_create_string_utf8(env, opt.c_str(), NAPI_AUTO_LENGTH, &resource); - NAPI_CALL(env, napi_create_async_work(env, nullptr, resource, [](napi_env env, void* data) { - AVRecorderAsyncContext* asyncCtx = reinterpret_cast(data); - CHECK_AND_RETURN_LOG(asyncCtx != nullptr, "asyncCtx is nullptr!"); - - if (asyncCtx->task_) { - auto result = asyncCtx->task_->GetResult(); - if (result.Value().first != MSERR_EXT_API9_OK) { - asyncCtx->SignError(result.Value().first, result.Value().second); - } - } - MEDIA_LOGI("The js thread of setWatermark finishes execution and returns"); - }, MediaAsyncContext::CompleteCallback, static_cast(asyncCtx.get()), &asyncCtx->work)); - NAPI_CALL(env, napi_queue_async_work_with_qos(env, asyncCtx->work, napi_qos_user_initiated)); - asyncCtx.release(); - - MEDIA_LOGI("Js %{public}s End", opt.c_str()); - return result; -} - std::shared_ptr> AVRecorderNapi::GetPrepareTask(std::unique_ptr &asyncCtx) { return std::make_shared>([napi = asyncCtx->napi, config = asyncCtx->config_]() { @@ -797,7 +744,7 @@ napi_value AVRecorderNapi::JsGetAudioCapturerMaxAmplitude(napi_env env, napi_ca { MediaTrace trace("AVRecorder::JsGetAudioCapturerMaxAmplitude"); const std::string &opt = AVRecordergOpt::GET_MAX_AMPLITUDE; - MEDIA_LOGI("Js %{public}s Start", opt.c_str()); + MEDIA_LOGD("Js %{public}s Start", opt.c_str()); napi_value result = nullptr; napi_get_undefined(env, &result); size_t argCount = 1; @@ -840,7 +787,7 @@ napi_value AVRecorderNapi::JsGetAudioCapturerMaxAmplitude(napi_env env, napi_ca NAPI_CALL(env, napi_queue_async_work_with_qos(env, asyncCtx->work, napi_qos_user_initiated)); asyncCtx.release(); - MEDIA_LOGI("Js %{public}s End", opt.c_str()); + MEDIA_LOGD("Js %{public}s End", opt.c_str()); return result; } @@ -1003,7 +950,7 @@ napi_value AVRecorderNapi::JsGetState(napi_env env, napi_callback_info info) auto napiCb = std::static_pointer_cast(recorderNapi->recorderCb_); CHECK_AND_RETURN_RET_LOG(napiCb != nullptr, result, "napiCb is nullptr!"); std::string curState = napiCb->GetState(); - MEDIA_LOGI("GetState success, State: %{public}s", curState.c_str()); + MEDIA_LOGD("GetState success, State: %{public}s", curState.c_str()); napi_value jsResult = nullptr; napi_status status = napi_create_string_utf8(env, curState.c_str(), NAPI_AUTO_LENGTH, &jsResult); @@ -1011,58 +958,6 @@ napi_value AVRecorderNapi::JsGetState(napi_env env, napi_callback_info info) return jsResult; } -napi_value AVRecorderNapi::JsIsWatermarkSupported(napi_env env, napi_callback_info info) -{ - MediaTrace trace("AVRecorderNapi::JsIsWatermarkSupported"); - const std::string &opt = AVRecordergOpt::IS_WATERMARK_SUPPORTED; - MEDIA_LOGI("Js %{public}s Start", opt.c_str()); - napi_value result = nullptr; - napi_get_undefined(env, &result); - - size_t argCount = 1; - napi_value args[1] = { nullptr }; - - auto asyncCtx = std::make_unique(env); - CHECK_AND_RETURN_RET_LOG(asyncCtx != nullptr, result, "failed to get AsyncContext"); - asyncCtx->napi = AVRecorderNapi::GetJsInstanceAndArgs(env, info, argCount, args); - CHECK_AND_RETURN_RET_LOG(asyncCtx->napi != nullptr, result, "failed to GetJsInstanceAndArgs"); - CHECK_AND_RETURN_RET_LOG(asyncCtx->napi->taskQue_ != nullptr, result, "taskQue is nullptr!"); - - asyncCtx->deferred = CommonNapi::CreatePromise(env, nullptr, result); - - if (asyncCtx->napi->CheckStateMachine(opt) == MSERR_OK) { - asyncCtx->task_ = AVRecorderNapi::IsWatermarkSupportedTask(asyncCtx); - (void)asyncCtx->napi->taskQue_->EnqueueTask(asyncCtx->task_); - asyncCtx->opt_ = opt; - } else { - asyncCtx->AVRecorderSignError(MSERR_INVALID_OPERATION, opt, ""); - } - - napi_value resource = nullptr; - napi_create_string_utf8(env, opt.c_str(), NAPI_AUTO_LENGTH, &resource); - NAPI_CALL(env, napi_create_async_work(env, nullptr, resource, [](napi_env env, void* data) { - AVRecorderAsyncContext* asyncCtx = reinterpret_cast(data); - CHECK_AND_RETURN_LOG(asyncCtx != nullptr, "asyncCtx is nullptr!"); - if (asyncCtx->task_) { - auto result = asyncCtx->task_->GetResult(); - if (result.Value().first != MSERR_EXT_API9_OK) { - asyncCtx->SignError(result.Value().first, result.Value().second); - } - - if ((result.Value().first == MSERR_EXT_API9_OK) && - (asyncCtx->opt_ == AVRecordergOpt::IS_WATERMARK_SUPPORTED)) { - asyncCtx->JsResult = std::make_unique(asyncCtx->isWatermarkSupported_); - } - } - MEDIA_LOGI("The js thread of prepare finishes execution and returns"); - }, MediaAsyncContext::CompleteCallback, static_cast(asyncCtx.get()), &asyncCtx->work)); - NAPI_CALL(env, napi_queue_async_work_with_qos(env, asyncCtx->work, napi_qos_user_initiated)); - asyncCtx.release(); - - MEDIA_LOGI("Js %{public}s End", opt.c_str()); - return result; -} - AVRecorderNapi *AVRecorderNapi::GetJsInstanceAndArgs( napi_env env, napi_callback_info info, size_t &argCount, napi_value *args) { @@ -1209,7 +1104,7 @@ std::shared_ptr> AVRecorderNapi::GetMaxAmplitudeTask( { return std::make_shared>([napi = asyncCtx->napi, &maxAmplitude = asyncCtx->maxAmplitude_]() { const std::string &option = AVRecordergOpt::GET_MAX_AMPLITUDE; - MEDIA_LOGI("%{public}s Start", option.c_str()); + MEDIA_LOGD("%{public}s Start", option.c_str()); CHECK_AND_RETURN_RET(napi != nullptr, GetRetInfo(MSERR_INVALID_OPERATION, option, "")); @@ -1224,7 +1119,7 @@ std::shared_ptr> AVRecorderNapi::GetMaxAmplitudeTask( CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(MSERR_INVALID_VAL, "GetMaxAmplitudeTask", ""), "get GetMaxAmplitudeTask failed"); - MEDIA_LOGI("%{public}s End", option.c_str()); + MEDIA_LOGD("%{public}s End", option.c_str()); return RetInfo(MSERR_EXT_API9_OK, ""); }); } @@ -1254,64 +1149,6 @@ std::shared_ptr> AVRecorderNapi::GetEncoderInfoTask( }); } -std::shared_ptr> AVRecorderNapi::IsWatermarkSupportedTask( - const std::unique_ptr &asyncCtx) -{ - return std::make_shared>([napi = asyncCtx->napi, - &isWatermarkSupported = asyncCtx->isWatermarkSupported_]() { - const std::string &option = AVRecordergOpt::IS_WATERMARK_SUPPORTED; - MEDIA_LOGI("%{public}s Start", option.c_str()); - - CHECK_AND_RETURN_RET(napi != nullptr, - GetRetInfo(MSERR_INVALID_OPERATION, option, "")); - - CHECK_AND_RETURN_RET(napi->CheckStateMachine(option) == MSERR_OK, - GetRetInfo(MSERR_INVALID_OPERATION, option, "")); - - CHECK_AND_RETURN_RET(napi->CheckRepeatOperation(option) == MSERR_OK, - RetInfo(MSERR_EXT_API9_OK, "")); - - int32_t ret = napi->IsWatermarkSupported(isWatermarkSupported); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(MSERR_INVALID_VAL, "IsWatermarkSupportedTask", ""), - "IsWatermarkSupportedTask failed"); - - MEDIA_LOGI("%{public}s End", option.c_str()); - return RetInfo(MSERR_EXT_API9_OK, ""); - }); -} - -std::shared_ptr> AVRecorderNapi::SetWatermarkTask( - const std::unique_ptr &asyncCtx) -{ - return std::make_shared>([napi = asyncCtx->napi, &pixelMap = asyncCtx->pixelMap_, - &watermarkConfig = asyncCtx->watermarkConfig_]() { - const std::string &option = AVRecordergOpt::SET_WATERMARK; - MEDIA_LOGI("%{public}s Start", option.c_str()); - - CHECK_AND_RETURN_RET(napi != nullptr, - GetRetInfo(MSERR_INVALID_OPERATION, option, "")); - - CHECK_AND_RETURN_RET(napi->CheckStateMachine(option) == MSERR_OK, - GetRetInfo(MSERR_INVALID_OPERATION, option, "")); - - CHECK_AND_RETURN_RET(napi->CheckRepeatOperation(option) == MSERR_OK, - RetInfo(MSERR_EXT_API9_OK, "")); - bool isWatermarkSupported = false; - int32_t ret = napi->IsWatermarkSupported(isWatermarkSupported); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(MSERR_UNKNOWN, "SetWatermarkTask", ""), - "IsWatermarkSupported fail"); - CHECK_AND_RETURN_RET_LOG(isWatermarkSupported, GetRetInfo(MSERR_UNSUPPORT_WATER_MARK, "SetWatermarkTask", ""), - "capability not supported"); - - ret = napi->SetWatermark(pixelMap, watermarkConfig); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(ret, "SetWatermarkTask", ""), - "SetWatermarkTask failed"); - - MEDIA_LOGI("%{public}s End", option.c_str()); - return RetInfo(MSERR_EXT_API9_OK, ""); - }); -} - RetInfo AVRecorderNapi::GetInputSurface() { CHECK_AND_RETURN_RET_LOG(withVideo_, GetRetInfo(MSERR_INVALID_OPERATION, "GetInputSurface", "", @@ -1347,16 +1184,18 @@ std::shared_ptr> AVRecorderNapi::GetInputMetaSurface( CHECK_AND_RETURN_RET_LOG(napi->metaSourceIDMap_.find(type) != napi->metaSourceIDMap_.end(), GetRetInfo(MSERR_INVALID_OPERATION, "GetInputMetaSurface", "no meta source type"), "failed to find meta type"); - MEDIA_LOGI("The meta source type is %{public}d", static_cast(type)); - napi->metaSurface_ = napi->recorder_->GetMetaSurface(napi->metaSourceIDMap_.at(type)); - CHECK_AND_RETURN_RET_LOG(napi->metaSurface_ != nullptr, - GetRetInfo(MSERR_INVALID_OPERATION, "GetInputMetaSurface", ""), "failed to GetInputMetaSurface"); - - SurfaceError error = - SurfaceUtils::GetInstance()->Add(napi->metaSurface_->GetUniqueId(), napi->metaSurface_); - CHECK_AND_RETURN_RET_LOG(error == SURFACE_ERROR_OK, - GetRetInfo(MSERR_INVALID_OPERATION, "GetInputMetaSurface", "add surface failed"), - "failed to AddSurface"); + if (napi->metaSurface_ == nullptr) { + MEDIA_LOGI("The meta source type is %{public}d", static_cast(type)); + napi->metaSurface_ = napi->recorder_->GetMetaSurface(napi->metaSourceIDMap_.at(type)); + CHECK_AND_RETURN_RET_LOG(napi->metaSurface_ != nullptr, + GetRetInfo(MSERR_INVALID_OPERATION, "GetInputMetaSurface", ""), "failed to GetInputMetaSurface"); + + SurfaceError error = + SurfaceUtils::GetInstance()->Add(napi->metaSurface_->GetUniqueId(), napi->metaSurface_); + CHECK_AND_RETURN_RET_LOG(error == SURFACE_ERROR_OK, + GetRetInfo(MSERR_INVALID_OPERATION, "GetInputMetaSurface", "add surface failed"), + "failed to AddSurface"); + } auto surfaceId = std::to_string(napi->metaSurface_->GetUniqueId()); MEDIA_LOGI("surfaceId:%{public}s", surfaceId.c_str()); @@ -1475,102 +1314,6 @@ int32_t AVRecorderNapi::GetEncoderInfo(std::vector &encod return ret; } -int32_t AVRecorderNapi::IsWatermarkSupported(bool &isWatermarkSupported) -{ - return recorder_->IsWatermarkSupported(isWatermarkSupported); -} - -int32_t AVRecorderNapi::SetWatermark(std::shared_ptr &pixelMap, - std::shared_ptr &watermarkConfig) -{ -#ifndef CROSS_PLATFORM - MEDIA_LOGD("pixelMap Width %{public}d, height %{public}d, pixelformat %{public}d, RowStride %{public}d", - pixelMap->GetWidth(), pixelMap->GetHeight(), pixelMap->GetPixelFormat(), pixelMap->GetRowStride()); - CHECK_AND_RETURN_RET_LOG(pixelMap->GetPixelFormat() == PixelFormat::RGBA_8888, MSERR_INVALID_VAL, - "Invalid pixel format"); - std::shared_ptr avBufferConfig = std::make_shared(); - int32_t ret = ConfigAVBufferMeta(pixelMap, watermarkConfig, avBufferConfig); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, MSERR_INVALID_VAL, "ConfigAVBufferMeta is failed"); - sptr surfaceBuffer = SurfaceBuffer::Create(); - BufferRequestConfig bufferConfig = { - .width = pixelMap->GetWidth(), - .height = pixelMap->GetHeight(), - .strideAlignment = 0x8, - .format = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888, - .usage = BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA, - .timeout = 0, - }; - surfaceBuffer->Alloc(bufferConfig); - - MEDIA_LOGD("surface size %{public}d, surface stride %{public}d", - surfaceBuffer->GetSize(), surfaceBuffer->GetStride()); - - for (int i = 0; i < pixelMap->GetHeight(); i++) { - ret = memcpy_s(static_cast(surfaceBuffer->GetVirAddr()) + i * surfaceBuffer->GetStride(), - pixelMap->GetRowStride(), pixelMap->GetPixels() + i * pixelMap->GetRowStride(), pixelMap->GetRowStride()); - CHECK_AND_RETURN_RET_LOG(ret == 0, MSERR_INVALID_VAL, "memcpy failed"); - } - std::shared_ptr waterMarkBuffer = AVBuffer::CreateAVBuffer(surfaceBuffer); - CHECK_AND_RETURN_RET_LOG(waterMarkBuffer != nullptr, MSERR_NO_MEMORY, "surfaceBuffer is nullptr"); - waterMarkBuffer->meta_ = avBufferConfig; - return recorder_->SetWatermark(waterMarkBuffer); -#endif - return MSERR_OK; -} - -int32_t AVRecorderNapi::ConfigAVBufferMeta(std::shared_ptr &pixelMap, - std::shared_ptr &watermarkConfig, std::shared_ptr &meta) -{ - int32_t top = watermarkConfig->top; - int32_t left = watermarkConfig->left; - int32_t watermarkWidth = pixelMap->GetWidth(); - int32_t watermarkHeight = pixelMap->GetHeight(); - meta->Set(true); - switch (rotation_) { - case VIDEO_ROTATION_0: - meta->Set(left); - meta->Set(top); - meta->Set(watermarkWidth); - meta->Set(watermarkHeight); - break; - case VIDEO_ROTATION_90: - MEDIA_LOGI("rotation %{public}d", VIDEO_ROTATION_90); - CHECK_AND_RETURN_RET_LOG(videoFrameHeight_ - left - watermarkWidth >= 0, - MSERR_INVALID_VAL, "invalid watermark"); - pixelMap->rotate(VIDEO_ROTATION_270); - meta->Set(top); - meta->Set(videoFrameHeight_ - left - watermarkWidth); - meta->Set(watermarkHeight); - meta->Set(watermarkWidth); - break; - case VIDEO_ROTATION_180: - MEDIA_LOGI("rotation %{public}d", VIDEO_ROTATION_180); - CHECK_AND_RETURN_RET_LOG(videoFrameWidth_-left-watermarkWidth >= 0, - MSERR_INVALID_VAL, "invalid watermark"); - CHECK_AND_RETURN_RET_LOG(videoFrameHeight_-top-watermarkHeight >= 0, - MSERR_INVALID_VAL, "invalid watermark"); - pixelMap->rotate(VIDEO_ROTATION_180); - meta->Set(videoFrameWidth_-left-watermarkWidth); - meta->Set(videoFrameHeight_-top-watermarkHeight); - meta->Set(watermarkWidth); - meta->Set(watermarkHeight); - break; - case VIDEO_ROTATION_270: - MEDIA_LOGI("rotation %{public}d", VIDEO_ROTATION_270); - CHECK_AND_RETURN_RET_LOG(videoFrameHeight_ - left - watermarkWidth >= 0, - MSERR_INVALID_VAL, "invalid watermark"); - pixelMap->rotate(VIDEO_ROTATION_90); - meta->Set(videoFrameWidth_ - top - watermarkHeight); - meta->Set(left); - meta->Set(watermarkHeight); - meta->Set(watermarkWidth); - break; - default: - break; - } - return MSERR_OK; -} - int32_t AVRecorderNapi::CheckStateMachine(const std::string &opt) { auto napiCb = std::static_pointer_cast(recorderCb_); @@ -1753,10 +1496,8 @@ int32_t AVRecorderNapi::GetVideoProfile(std::unique_ptr (asyncCtx->AVRecorderSignError(ret, "GetvideoBitrate", "videoBitrate"), ret)); CHECK_AND_RETURN_RET(CommonNapi::GetPropertyInt32(env, item, "videoFrameWidth", profile.videoFrameWidth), (asyncCtx->AVRecorderSignError(ret, "GetvideoFrameWidth", "videoFrameWidth"), ret)); - videoFrameWidth_ = profile.videoFrameWidth; CHECK_AND_RETURN_RET(CommonNapi::GetPropertyInt32(env, item, "videoFrameHeight", profile.videoFrameHeight), (asyncCtx->AVRecorderSignError(ret, "GetvideoFrameHeight", "videoFrameHeight"), ret)); - videoFrameHeight_ = profile.videoFrameHeight; CHECK_AND_RETURN_RET(CommonNapi::GetPropertyInt32(env, item, "videoFrameRate", profile.videoFrameRate), (asyncCtx->AVRecorderSignError(ret, "GetvideoFrameRate", "videoFrameRate"), ret)); if (CommonNapi::GetPropertyBool(env, item, "isHdr", profile.isHdr)) { @@ -1865,7 +1606,6 @@ int32_t AVRecorderNapi::GetConfig(std::unique_ptr &async config->rotation == VIDEO_ROTATION_180 || config->rotation == VIDEO_ROTATION_270), (asyncCtx->AVRecorderSignError(MSERR_PARAMETER_VERIFICATION_FAILED, "getrotation", "rotation", "rotation angle must be 0, 90, 180 or 270!"), MSERR_PARAMETER_VERIFICATION_FAILED)); - rotation_ = config->rotation; if (CommonNapi::CheckhasNamedProperty(env, args, "location")) { CHECK_AND_RETURN_RET(GetLocation(asyncCtx, env, args), (asyncCtx->AVRecorderSignError(MSERR_INCORRECT_PARAMETER_TYPE, "GetLocation", "Location", @@ -1900,7 +1640,6 @@ int32_t AVRecorderNapi::GetRotation(std::unique_ptr &asy config->rotation == VIDEO_ROTATION_180 || config->rotation == VIDEO_ROTATION_270), (asyncCtx->AVRecorderSignError(MSERR_INVALID_VAL, "getrotation", "rotation"), MSERR_INVALID_VAL)); MEDIA_LOGI("GetRecordRotation success %{public}d", config->rotation); - rotation_ = config->rotation; return MSERR_OK; } @@ -1912,7 +1651,6 @@ int32_t AVRecorderNapi::GetRotation(std::unique_ptr &asy CHECK_AND_RETURN_RET((config->rotation == VIDEO_ROTATION_0 || config->rotation == VIDEO_ROTATION_90 || config->rotation == VIDEO_ROTATION_180 || config->rotation == VIDEO_ROTATION_270), (asyncCtx->AVRecorderSignError(MSERR_INVALID_VAL, "getrotation", "rotation"), MSERR_INVALID_VAL)); - rotation_ = config->rotation; return MSERR_OK; } @@ -1973,7 +1711,6 @@ int32_t AVRecorderNapi::GetAVMetaData(std::unique_ptr &a std::string strRotation = CommonNapi::GetPropertyString(env, metadata, "videoOrientation"); if (strRotation == "0" || strRotation == "90" || strRotation == "180" || strRotation == "270") { asyncCtx->config_->rotation = std::stoi(strRotation); - rotation_ = asyncCtx->config_->rotation; MEDIA_LOGI("rotation: %{public}d", asyncCtx->config_->rotation); } else if (strRotation != "") { asyncCtx->AVRecorderSignError(MSERR_INVALID_VAL, "not support rotation", "videoOrientation"); @@ -1988,46 +1725,6 @@ int32_t AVRecorderNapi::GetAVMetaData(std::unique_ptr &a return MSERR_OK; } -int32_t AVRecorderNapi::GetWatermarkParameter(std::unique_ptr &asyncCtx, - napi_env env, napi_value *args) -{ - int32_t ret = GetWatermark(asyncCtx, env, args[0]); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "failed to GetWatermark"); - ret = GetWatermarkConfig(asyncCtx, env, args[1]); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "failed to GetWatermarkConfig"); - return MSERR_OK; -} - -int32_t AVRecorderNapi::GetWatermark(std::unique_ptr &asyncCtx, - napi_env env, napi_value args) -{ - CHECK_AND_RETURN_RET(CommonNapi::CheckValueType(env, args, napi_object), - (asyncCtx->AVRecorderSignError(MSERR_INVALID_VAL, "GetPixelMap", "PixelMap"), MSERR_INVALID_VAL)); - asyncCtx->pixelMap_ = Media::PixelMapNapi::GetPixelMap(env, args); - CHECK_AND_RETURN_RET(asyncCtx->pixelMap_ != nullptr, - (asyncCtx->AVRecorderSignError(MSERR_INVALID_VAL, "GetPixelMap", "PixelMap"), MSERR_INVALID_VAL)); - return MSERR_OK; -} - -int32_t AVRecorderNapi::GetWatermarkConfig(std::unique_ptr &asyncCtx, - napi_env env, napi_value args) -{ - CHECK_AND_RETURN_RET(CommonNapi::CheckValueType(env, args, napi_object), - (asyncCtx->AVRecorderSignError(MSERR_INVALID_VAL, "GetWatermarkConfig", "WatermarkConfig"), MSERR_INVALID_VAL)); - asyncCtx->watermarkConfig_ = std::make_shared(); - - bool ret = CommonNapi::GetPropertyInt32(env, args, "top", asyncCtx->watermarkConfig_->top); - CHECK_AND_RETURN_RET(ret && asyncCtx->watermarkConfig_->top >= 0, - (asyncCtx->AVRecorderSignError(MSERR_PARAMETER_VERIFICATION_FAILED, "GetWatermarkConfig", "top", - "config top cannot be null or less than zero"), MSERR_PARAMETER_VERIFICATION_FAILED)); - - ret = CommonNapi::GetPropertyInt32(env, args, "left", asyncCtx->watermarkConfig_->left); - CHECK_AND_RETURN_RET(ret && asyncCtx->watermarkConfig_->left >= 0, - (asyncCtx->AVRecorderSignError(MSERR_PARAMETER_VERIFICATION_FAILED, "GetWatermarkConfig", "left", - "config left cannot be null or less than zero"), MSERR_PARAMETER_VERIFICATION_FAILED)); - return MSERR_OK; -} - bool AVRecorderNapi::GetLocation(std::unique_ptr &asyncCtx, napi_env env, napi_value args) { napi_value geoLocation = nullptr; diff --git a/frameworks/js/avrecorder/avrecorder_napi.h b/frameworks/js/avrecorder/avrecorder_napi.h index 0ccede315..2ea51b1b6 100644 --- a/frameworks/js/avrecorder/avrecorder_napi.h +++ b/frameworks/js/avrecorder/avrecorder_napi.h @@ -24,8 +24,6 @@ #include "common_napi.h" #include "task_queue.h" #include "recorder_profiles.h" -#include "pixel_map_napi.h" -#include "buffer/avbuffer.h" namespace OHOS { namespace Media { @@ -57,8 +55,6 @@ const std::string GET_AV_RECORDER_CONFIG = "GetAVRecorderConfig"; const std::string GET_CURRENT_AUDIO_CAPTURER_INFO = "GetCurrentAudioCapturerInfo"; const std::string GET_MAX_AMPLITUDE = "GetMaxAmplitude"; const std::string GET_ENCODER_INFO = "GetEncoderInfo"; -const std::string IS_WATERMARK_SUPPORTED = "IsWatermarkSupported"; -const std::string SET_WATERMARK = "SetWatermark"; } constexpr int32_t AVRECORDER_DEFAULT_AUDIO_BIT_RATE = 48000; @@ -88,9 +84,7 @@ const std::map> stateCtrlList = { AVRecordergOpt::GET_CURRENT_AUDIO_CAPTURER_INFO, AVRecordergOpt::GET_MAX_AMPLITUDE, AVRecordergOpt::GET_ENCODER_INFO, - AVRecordergOpt::GET_AV_RECORDER_CONFIG, - AVRecordergOpt::IS_WATERMARK_SUPPORTED, - AVRecordergOpt::SET_WATERMARK + AVRecordergOpt::GET_AV_RECORDER_CONFIG }}, {AVRecorderState::STATE_STARTED, { AVRecordergOpt::START, @@ -102,8 +96,7 @@ const std::map> stateCtrlList = { AVRecordergOpt::GET_CURRENT_AUDIO_CAPTURER_INFO, AVRecordergOpt::GET_MAX_AMPLITUDE, AVRecordergOpt::GET_ENCODER_INFO, - AVRecordergOpt::GET_AV_RECORDER_CONFIG, - AVRecordergOpt::IS_WATERMARK_SUPPORTED + AVRecordergOpt::GET_AV_RECORDER_CONFIG }}, {AVRecorderState::STATE_PAUSED, { AVRecordergOpt::PAUSE, @@ -114,8 +107,7 @@ const std::map> stateCtrlList = { AVRecordergOpt::GET_CURRENT_AUDIO_CAPTURER_INFO, AVRecordergOpt::GET_MAX_AMPLITUDE, AVRecordergOpt::GET_ENCODER_INFO, - AVRecordergOpt::GET_AV_RECORDER_CONFIG, - AVRecordergOpt::IS_WATERMARK_SUPPORTED + AVRecordergOpt::GET_AV_RECORDER_CONFIG }}, {AVRecorderState::STATE_STOPPED, { AVRecordergOpt::STOP, @@ -180,11 +172,6 @@ struct AVRecorderConfig { bool withLocation = false; }; -struct WatermarkConfig { - int32_t top = -1; // offset of the watermark to the top line of pixel - int32_t left = -1; // offset of the watermark to the left line if pixel -}; - using RetInfo = std::pair; class AVRecorderNapi { @@ -211,10 +198,6 @@ private: * setOrientationHint(config: AVRecorderConfig): Promise; */ static napi_value JsSetOrientationHint(napi_env env, napi_callback_info info); - /** - * setWatermark(watermark: image.PixelMap, config: WatermarkConfig): promise; - */ - static napi_value JsSetWatermark(napi_env env, napi_callback_info info); /** * getInputSurface(callback: AsyncCallback): void * getInputSurface(): Promise @@ -304,10 +287,6 @@ private: * getAvailableEncoder(): Promise>; */ static napi_value JsGetAvailableEncoder(napi_env env, napi_callback_info info); - /** - * isWatermarkSupported(): promise; - */ - static napi_value JsIsWatermarkSupported(napi_env env, napi_callback_info info); static AVRecorderNapi* GetJsInstanceAndArgs(napi_env env, napi_callback_info info, size_t &argCount, napi_value *args); @@ -330,10 +309,6 @@ private: const std::unique_ptr &asyncCtx); static std::shared_ptr> GetEncoderInfoTask( const std::unique_ptr &asyncCtx); - static std::shared_ptr> IsWatermarkSupportedTask( - const std::unique_ptr &asyncCtx); - static std::shared_ptr> SetWatermarkTask( - const std::unique_ptr &asyncCtx); static int32_t GetAudioCodecFormat(const std::string &mime, AudioCodecFormat &codecFormat); static int32_t GetVideoCodecFormat(const std::string &mime, VideoCodecFormat &codecFormat); static int32_t GetOutputFormat(const std::string &extension, OutputFormatType &type); @@ -363,8 +338,6 @@ private: int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo); int32_t GetMaxAmplitude(int32_t &maxAmplitude); int32_t GetEncoderInfo(std::vector &encoderInfo); - int32_t IsWatermarkSupported(bool &isWatermarkSupported); - int32_t SetWatermark(std::shared_ptr &pixelMap, std::shared_ptr &watermarkConfig); void ErrorCallback(int32_t errCode, const std::string &operate, const std::string &add = ""); void StateCallback(const std::string &state); @@ -386,18 +359,12 @@ private: int32_t GetRotation(std::unique_ptr &asyncCtx, napi_env env, napi_value args); int32_t GetMetaType(std::unique_ptr &asyncCtx, napi_env env, napi_value args); int32_t GetAVMetaData(std::unique_ptr &asyncCtx, napi_env env, napi_value args); - int32_t GetWatermarkParameter(std::unique_ptr &asyncCtx, napi_env env, napi_value *args); - int32_t GetWatermark(std::unique_ptr &asyncCtx, napi_env env, napi_value args); - int32_t GetWatermarkConfig(std::unique_ptr &asyncCtx, napi_env env, napi_value args); - bool GetLocation(std::unique_ptr &asyncCtx, napi_env env, napi_value args); int32_t GetSourceIdAndQuality(std::unique_ptr &asyncCtx, napi_env env, napi_value sourceIdArgs, napi_value qualityArgs, const std::string &opt); RetInfo SetProfile(std::shared_ptr config); RetInfo Configure(std::shared_ptr config); RetInfo ConfigureUrl(std::shared_ptr config); - int32_t ConfigAVBufferMeta(std::shared_ptr &pixelMap, std::shared_ptr &watermarkConfig, - std::shared_ptr &meta); static thread_local napi_ref constructor_; napi_env env_ = nullptr; @@ -418,9 +385,6 @@ private: int32_t sourceId_ = -1; int32_t qualityLevel_ = -1; bool hasConfiged_ = false; - int32_t videoFrameWidth_ = -1; // Required for watermarking. Synchronize the modification if any. - int32_t videoFrameHeight_ = -1; // Required for watermarking. Synchronize the modification if any. - int32_t rotation_ = 0; // Required for watermarking. Synchronize the modification if any. }; struct AVRecorderAsyncContext : public MediaAsyncContext { @@ -439,9 +403,6 @@ struct AVRecorderAsyncContext : public MediaAsyncContext { int32_t maxAmplitude_ = 0; std::vector encoderInfo_; MetaSourceType metaType_ = MetaSourceType::VIDEO_META_SOURCE_INVALID; - std::shared_ptr pixelMap_ = nullptr; - std::shared_ptr watermarkConfig_ = nullptr; - bool isWatermarkSupported_ = false; }; class MediaJsResultExtensionMethod { diff --git a/frameworks/js/recorder/video_recorder_napi.cpp b/frameworks/js/recorder/video_recorder_napi.cpp index 3bac87351..3ca355e53 100644 --- a/frameworks/js/recorder/video_recorder_napi.cpp +++ b/frameworks/js/recorder/video_recorder_napi.cpp @@ -311,7 +311,7 @@ napi_value VideoRecorderNapi::GetInputSurface(napi_env env, napi_callback_info i napi_value VideoRecorderNapi::Start(napi_env env, napi_callback_info info) { - MEDIA_LOGD("VideoRecorderNapi::Start In"); + MEDIA_LOGD("Start In"); napi_value result = nullptr; napi_get_undefined(env, &result); @@ -409,7 +409,7 @@ napi_value VideoRecorderNapi::Pause(napi_env env, napi_callback_info info) napi_value VideoRecorderNapi::Resume(napi_env env, napi_callback_info info) { - MEDIA_LOGD("VideoRecorderNapi::Resume In"); + MEDIA_LOGD("Resume In"); napi_value result = nullptr; napi_get_undefined(env, &result); diff --git a/frameworks/native/recorder/recorder_impl.cpp b/frameworks/native/recorder/recorder_impl.cpp index 1cbbe595a..c9f4a6f29 100644 --- a/frameworks/native/recorder/recorder_impl.cpp +++ b/frameworks/native/recorder/recorder_impl.cpp @@ -382,16 +382,5 @@ int32_t RecorderImpl::GetMaxAmplitude() return recorderService_->GetMaxAmplitude(); } -int32_t RecorderImpl::IsWatermarkSupported(bool &isWatermarkSupported) -{ - CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist.."); - return recorderService_->IsWatermarkSupported(isWatermarkSupported); -} - -int32_t RecorderImpl::SetWatermark(std::shared_ptr &waterMarkBuffer) -{ - CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist.."); - return recorderService_->SetWatermark(waterMarkBuffer); -} } // namespace Media -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/native/recorder/recorder_impl.h b/frameworks/native/recorder/recorder_impl.h index 22131cb2a..f6cc8ffd2 100644 --- a/frameworks/native/recorder/recorder_impl.h +++ b/frameworks/native/recorder/recorder_impl.h @@ -73,8 +73,7 @@ public: int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; int32_t GetAvailableEncoder(std::vector &encoderInfo) override; int32_t GetMaxAmplitude() override; - int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; - int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) override; + private: std::shared_ptr recorderService_ = nullptr; sptr surface_ = nullptr; diff --git a/interfaces/inner_api/native/recorder.h b/interfaces/inner_api/native/recorder.h index 37abe0c46..f2aa513ea 100644 --- a/interfaces/inner_api/native/recorder.h +++ b/interfaces/inner_api/native/recorder.h @@ -23,7 +23,6 @@ #include #include "meta/format.h" #include "meta/meta.h" -#include "buffer/avbuffer.h" #include "surface.h" #include "av_common.h" #include "codec_capability.h" @@ -33,7 +32,7 @@ namespace OHOS { namespace Media { using ConfigMap = std::map; constexpr size_t DEVICE_INFO_SIZE_LIMIT = 30; // 30 from audioCapture - + enum FileGenerationMode : int32_t { APP_CREATE = 0, AUTO_CREATE_CAMERA_SCENE = 1, @@ -808,7 +807,7 @@ public: * @version 1.0 */ virtual int32_t SetFileGenerationMode(FileGenerationMode mode) = 0; - + /** * Unsupported App Usage. * @brief Sets the FD of the next output file. @@ -992,24 +991,6 @@ public: virtual int32_t GetAvailableEncoder(std::vector &encoderInfo) = 0; virtual int32_t GetMaxAmplitude() = 0; - /** - * @brief Check if the avrecorder has watermark capability. - * - * @param isWatermarkSupported isWatermarkSupported true or false. - * @return Returns {@link MSERR_OK} If the query succeeds; returns an error code otherwise. - * @since 1.0 - * @version 1.0 - */ - virtual int32_t IsWatermarkSupported(bool &isWatermarkSupported) = 0; - /** - * @brief Set watermarkBuffer to avrecorder. - * - * @param waterMarkBuffer watermark image and config - * @return Returns {@link MSERR_OK} If the SetWatermark succeeds; returns an error code otherwise. - * @since 1.0 - * @version 1.0 - */ - virtual int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) = 0; }; class __attribute__((visibility("default"))) RecorderFactory { diff --git a/services/engine/histreamer/recorder/hirecorder_impl.cpp b/services/engine/histreamer/recorder/hirecorder_impl.cpp index 3cdfd10bf..192afcd44 100644 --- a/services/engine/histreamer/recorder/hirecorder_impl.cpp +++ b/services/engine/histreamer/recorder/hirecorder_impl.cpp @@ -444,8 +444,6 @@ int32_t HiRecorderImpl::Stop(bool isDrainAll) audioSourceId_ = 0; videoSourceId_ = 0; muxerFilter_ = nullptr; - isWatermarkSupported_ = false; - codecMimeType_ = ""; if (audioCaptureFilter_) { pipeline_->RemoveHeadFilter(audioCaptureFilter_); } @@ -740,16 +738,13 @@ void HiRecorderImpl::ConfigureVideoEncoderFormat(const RecorderParam &recParam) videoEncFormat_->Set(Plugins::MimeType::VIDEO_AVC); videoEncFormat_->Set(Plugins::VideoH264Profile::BASELINE); videoEncFormat_->Set(32); // 32: LEVEL 3.2 - codecMimeType_ = MediaAVCodec::CodecMimeType::VIDEO_AVC; break; case OHOS::Media::VideoCodecFormat::MPEG4: videoEncFormat_->Set(Plugins::MimeType::VIDEO_MPEG4); - codecMimeType_ = MediaAVCodec::CodecMimeType::VIDEO_MPEG4; break; case OHOS::Media::VideoCodecFormat::H265: MEDIA_LOG_I("ConfigureVideo H265 enter"); videoEncFormat_->Set(Plugins::MimeType::VIDEO_HEVC); - codecMimeType_ = MediaAVCodec::CodecMimeType::VIDEO_HEVC; break; default: break; @@ -950,29 +945,5 @@ void HiRecorderImpl::SetCallingInfo(const std::string &bundleName, uint64_t inst bundleName_ = bundleName; instanceId_ = instanceId; } - -int32_t HiRecorderImpl::IsWatermarkSupported(bool &isWatermarkSupported) -{ - MEDIA_LOG_D("IsWatermarkSupported enter, codecMimeType:" PUBLIC_LOG_S, codecMimeType_.c_str()); - if (isWatermarkSupported_) { - isWatermarkSupported = isWatermarkSupported_; - return (int32_t)Status::OK; - } - FALSE_RETURN_V_MSG_E(codecMimeType_ != "", static_cast(Status::ERROR_INVALID_OPERATION), - "codecMimeType is nullptr, cannot get isWatermarkSupported"); - if (!codecCapabilityAdapter_) { - codecCapabilityAdapter_ = std::make_shared(); - } - codecCapabilityAdapter_->Init(); - Status ret = codecCapabilityAdapter_->IsWatermarkSupported(codecMimeType_, isWatermarkSupported); - return static_cast(ret); -} - -int32_t HiRecorderImpl::SetWatermark(std::shared_ptr &waterMarkBuffer) -{ - FALSE_RETURN_V_MSG_E(videoEncoderFilter_ != nullptr, static_cast(Status::ERROR_NULL_POINTER), - "videoEncoderFilter is nullptr, cannot set watermark"); - return static_cast(videoEncoderFilter_->SetWatermark(waterMarkBuffer)); -} } // namespace MEDIA } // namespace OHOS diff --git a/services/engine/histreamer/recorder/hirecorder_impl.h b/services/engine/histreamer/recorder/hirecorder_impl.h index 05e267009..2b2dee47f 100644 --- a/services/engine/histreamer/recorder/hirecorder_impl.h +++ b/services/engine/histreamer/recorder/hirecorder_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -80,8 +80,6 @@ public: int32_t GetAvailableEncoder(std::vector &encoderInfo); int32_t GetMaxAmplitude(); void SetCallingInfo(const std::string &bundleName, uint64_t instanceId); - int32_t IsWatermarkSupported(bool &isWatermarkSupported); - int32_t SetWatermark(std::shared_ptr &waterMarkBuffer); private: void ConfigureAudioCapture(); @@ -140,7 +138,6 @@ private: bool videoSourceIsYuv_ = false; bool videoSourceIsRGBA_ = false; - bool isWatermarkSupported_ = false; Mutex stateMutex_ {}; ConditionVariable cond_ {}; @@ -153,7 +150,6 @@ private: BUFFER_USAGE_MEM_DMA | BUFFER_USAGE_VIDEO_ENCODER; std::string recorderId_; std::string bundleName_; - std::string codecMimeType_ = ""; uint64_t instanceId_ = 0; }; } // namespace MEDIA diff --git a/services/include/i_recorder_service.h b/services/include/i_recorder_service.h index 52db5bfc0..0bf251d4a 100644 --- a/services/include/i_recorder_service.h +++ b/services/include/i_recorder_service.h @@ -594,17 +594,6 @@ public: * in {@link media_errors.h} otherwise. */ virtual int32_t SetGenre(std::string &genre) = 0; - - /** - * @brief Check if the avrecorder has watermark capability. - * - * @param isWatermarkSupported - * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined - * in {@link media_errors.h} otherwise. - */ - virtual int32_t IsWatermarkSupported(bool &isWatermarkSupported) = 0; - - virtual int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) = 0; }; } // namespace Media } // namespace OHOS diff --git a/services/services/engine_intf/i_recorder_engine.h b/services/services/engine_intf/i_recorder_engine.h index c3d4f97c5..8b468750e 100644 --- a/services/services/engine_intf/i_recorder_engine.h +++ b/services/services/engine_intf/i_recorder_engine.h @@ -213,14 +213,6 @@ public: * Set App calling info for recording. */ virtual void SetCallingInfo(const std::string &bundleName, uint64_t instanceId) = 0; - /** - * check if the avrecorder has watermark capability. - */ - virtual int32_t IsWatermarkSupported(bool &isWatermarkSupported) = 0; - /** - * Set watermark config - */ - virtual int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) = 0; }; } // namespace Media } // namespace OHOS diff --git a/services/services/recorder/client/recorder_client.cpp b/services/services/recorder/client/recorder_client.cpp index 682194c26..abec2accc 100644 --- a/services/services/recorder/client/recorder_client.cpp +++ b/services/services/recorder/client/recorder_client.cpp @@ -510,23 +510,5 @@ int32_t RecorderClient::GetMaxAmplitude() MEDIA_LOGD("GetMaxAmplitude"); return recorderProxy_->GetMaxAmplitude(); } - -int32_t RecorderClient::IsWatermarkSupported(bool &isWatermarkSupported) -{ - std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(recorderProxy_ != nullptr, MSERR_NO_MEMORY, "recorder service does not exist."); - - MEDIA_LOGD("IsWatermarkSupported"); - return recorderProxy_->IsWatermarkSupported(isWatermarkSupported); -} - -int32_t RecorderClient::SetWatermark(std::shared_ptr &waterMarkBuffer) -{ - std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(recorderProxy_ != nullptr, MSERR_NO_MEMORY, "recorder service does not exist."); - - MEDIA_LOGD("SetWatermark"); - return recorderProxy_->SetWatermark(waterMarkBuffer); -} } // namespace Media } // namespace OHOS diff --git a/services/services/recorder/client/recorder_client.h b/services/services/recorder/client/recorder_client.h index de5a9b8ca..042c0c7d3 100644 --- a/services/services/recorder/client/recorder_client.h +++ b/services/services/recorder/client/recorder_client.h @@ -76,8 +76,6 @@ public: int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; int32_t GetAvailableEncoder(std::vector &encoderInfo) override; int32_t GetMaxAmplitude() override; - int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; - int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) override; // RecorderClient void MediaServerDied(); diff --git a/services/services/recorder/ipc/i_standard_recorder_service.h b/services/services/recorder/ipc/i_standard_recorder_service.h index a0bc7c5b4..9852f7728 100644 --- a/services/services/recorder/ipc/i_standard_recorder_service.h +++ b/services/services/recorder/ipc/i_standard_recorder_service.h @@ -92,8 +92,6 @@ public: virtual int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) = 0; virtual int32_t GetAvailableEncoder(std::vector &encoderInfo) = 0; virtual int32_t GetMaxAmplitude() = 0; - virtual int32_t IsWatermarkSupported(bool &isWatermarkSupported) = 0; - virtual int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) = 0; /** * IPC code ID */ @@ -138,8 +136,6 @@ public: GET_AUDIO_CAPTURER_CHANGE_INFO, GET_AVAILABLE_ENCODER, GET_MAX_AMPLITUDE, - IS_WATERMARK_SUPPORTED, - SET_WATERMARK, SET_META_CONFIGS, SET_META_SOURCE, SET_META_MIME_TYPE, diff --git a/services/services/recorder/ipc/recorder_service_proxy.cpp b/services/services/recorder/ipc/recorder_service_proxy.cpp index 34e47d49c..66861fa21 100644 --- a/services/services/recorder/ipc/recorder_service_proxy.cpp +++ b/services/services/recorder/ipc/recorder_service_proxy.cpp @@ -861,40 +861,5 @@ int32_t RecorderServiceProxy::GetMaxAmplitude() MEDIA_LOGI("GetMaxAmplitude amplitude result: %d", amplitude); return amplitude; } - -int32_t RecorderServiceProxy::IsWatermarkSupported(bool &isWatermarkSupported) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool token = data.WriteInterfaceToken(RecorderServiceProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, MSERR_INVALID_OPERATION, "Failed to write descriptor!"); - - int error = Remote()->SendRequest(IS_WATERMARK_SUPPORTED, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, - "IsWatermarkSupported failed, error: %{public}d", error); - isWatermarkSupported = reply.ReadBool(); - return reply.ReadInt32(); -} - -int32_t RecorderServiceProxy::SetWatermark(std::shared_ptr &waterMarkBuffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - bool token = data.WriteInterfaceToken(RecorderServiceProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, MSERR_INVALID_OPERATION, "Failed to write descriptor!"); - - CHECK_AND_RETURN_RET_LOG(waterMarkBuffer->WriteToMessageParcel(data), - MSERR_INVALID_OPERATION, "Failed to write waterMarkBuffer!"); - - int error = Remote()->SendRequest(SET_WATERMARK, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, - "SetWatermark failed, error: %{public}d", error); - - return reply.ReadInt32(); -} } // namespace Media } // namespace OHOS diff --git a/services/services/recorder/ipc/recorder_service_proxy.h b/services/services/recorder/ipc/recorder_service_proxy.h index 0b7a9fb86..f52e747ee 100644 --- a/services/services/recorder/ipc/recorder_service_proxy.h +++ b/services/services/recorder/ipc/recorder_service_proxy.h @@ -72,8 +72,6 @@ public: int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; int32_t GetAvailableEncoder(std::vector &encoderInfo) override; int32_t GetMaxAmplitude() override; - int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; - int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) override; private: static inline BrokerDelegator delegator_; }; diff --git a/services/services/recorder/ipc/recorder_service_stub.cpp b/services/services/recorder/ipc/recorder_service_stub.cpp index 244476545..eb3548a42 100644 --- a/services/services/recorder/ipc/recorder_service_stub.cpp +++ b/services/services/recorder/ipc/recorder_service_stub.cpp @@ -142,10 +142,6 @@ void RecorderServiceStub::FillRecFuncPart2() [this](MessageParcel &data, MessageParcel &reply) { return GetAvailableEncoder(data, reply); }; recFuncs_[GET_MAX_AMPLITUDE] = [this](MessageParcel &data, MessageParcel &reply) { return GetMaxAmplitude(data, reply); }; - recFuncs_[IS_WATERMARK_SUPPORTED] = - [this](MessageParcel &data, MessageParcel &reply) { return IsWatermarkSupported(data, reply); }; - recFuncs_[SET_WATERMARK] = - [this](MessageParcel &data, MessageParcel &reply) { return SetWatermark(data, reply); }; recFuncs_[SET_META_CONFIGS] = [this](MessageParcel &data, MessageParcel &reply) { return SetMetaConfigs(data, reply); }; recFuncs_[SET_META_SOURCE] = @@ -495,18 +491,6 @@ int32_t RecorderServiceStub::GetMaxAmplitude() return recorderServer_->GetMaxAmplitude(); } -int32_t RecorderServiceStub::IsWatermarkSupported(bool &isWatermarkSupported) -{ - CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); - return recorderServer_->IsWatermarkSupported(isWatermarkSupported); -} - -int32_t RecorderServiceStub::SetWatermark(std::shared_ptr &waterMarkBuffer) -{ - CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); - return recorderServer_->SetWatermark(waterMarkBuffer); -} - int32_t RecorderServiceStub::DoIpcAbnormality() { MEDIA_LOGI("Enter DoIpcAbnormality."); @@ -919,22 +903,5 @@ int32_t RecorderServiceStub::GetMaxAmplitude(MessageParcel &data, MessageParcel return MSERR_OK; } - -int32_t RecorderServiceStub::IsWatermarkSupported(MessageParcel &data, MessageParcel &reply) -{ - (void)data; - bool isWatermarkSupported = false; - int32_t ret = IsWatermarkSupported(isWatermarkSupported); - CHECK_AND_RETURN_RET_LOG(reply.WriteBool(isWatermarkSupported), MSERR_INVALID_OPERATION, "reply write failed"); - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(ret), MSERR_INVALID_OPERATION, "reply write failed"); - return MSERR_OK; -} -int32_t RecorderServiceStub::SetWatermark(MessageParcel &data, MessageParcel &reply) -{ - std::shared_ptr buffer = AVBuffer::CreateAVBuffer(); - CHECK_AND_RETURN_RET_LOG(buffer->ReadFromMessageParcel(data), MSERR_INVALID_OPERATION, "read buffer failed"); - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(SetWatermark(buffer)), MSERR_INVALID_OPERATION, "reply write failed"); - return MSERR_OK; -} } // namespace Media } // namespace OHOS diff --git a/services/services/recorder/ipc/recorder_service_stub.h b/services/services/recorder/ipc/recorder_service_stub.h index 08f9b9959..c232ca517 100644 --- a/services/services/recorder/ipc/recorder_service_stub.h +++ b/services/services/recorder/ipc/recorder_service_stub.h @@ -78,8 +78,6 @@ public: int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; int32_t GetAvailableEncoder(std::vector &encoderInfo) override; int32_t GetMaxAmplitude() override; - int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; - int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) override; // MonitorServerObject override int32_t DoIpcAbnormality() override; int32_t DoIpcRecovery(bool fromMonitor) override; @@ -129,8 +127,6 @@ private: int32_t GetCurrentCapturerChangeInfo(MessageParcel &data, MessageParcel &reply); int32_t GetAvailableEncoder(MessageParcel &data, MessageParcel &reply); int32_t GetMaxAmplitude(MessageParcel &data, MessageParcel &reply); - int32_t IsWatermarkSupported(MessageParcel &data, MessageParcel &reply); - int32_t SetWatermark(MessageParcel &data, MessageParcel &reply); int32_t CheckPermission(); void FillRecFuncPart1(); void FillRecFuncPart2(); diff --git a/services/services/recorder/server/recorder_server.cpp b/services/services/recorder/server/recorder_server.cpp index 0ca9decf7..7a8d0daea 100644 --- a/services/services/recorder/server/recorder_server.cpp +++ b/services/services/recorder/server/recorder_server.cpp @@ -1104,38 +1104,6 @@ int32_t RecorderServer::GetMaxAmplitude() return result.Value(); } -int32_t RecorderServer::IsWatermarkSupported(bool &isWatermarkSupported) -{ - MEDIA_LOGI("IsWatermarkSupported in"); - std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); - auto task = std::make_shared>([&, this] { - return recorderEngine_->IsWatermarkSupported(isWatermarkSupported); - }); - int32_t ret = taskQue_.EnqueueTask(task); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); - - auto result = task->GetResult(); - return result.Value(); -} - -int32_t RecorderServer::SetWatermark(std::shared_ptr &waterMarkBuffer) -{ - MEDIA_LOGI("SetWatermark in"); - std::lock_guard lock(mutex_); - MediaTrace trace("RecorderServer::SetWatermark"); - CHECK_STATUS_FAILED_AND_LOGE_RET(status_ != REC_PREPARED, MSERR_INVALID_OPERATION); - CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); - auto task = std::make_shared>([&, this] { - return recorderEngine_->SetWatermark(waterMarkBuffer); - }); - int32_t ret = taskQue_.EnqueueTask(task); - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); - - auto result = task->GetResult(); - return result.Value(); -} - void RecorderServer::SetMetaDataReport() { std::shared_ptr meta = std::make_shared(); diff --git a/services/services/recorder/server/recorder_server.h b/services/services/recorder/server/recorder_server.h index e4ea965f4..ecb04abf5 100644 --- a/services/services/recorder/server/recorder_server.h +++ b/services/services/recorder/server/recorder_server.h @@ -116,8 +116,6 @@ public: int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; int32_t GetAvailableEncoder(std::vector &encoderInfo) override; int32_t GetMaxAmplitude() override; - int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; - int32_t SetWatermark(std::shared_ptr &waterMarkBuffer) override; // IRecorderEngineObs override void OnError(ErrorType errorType, int32_t errorCode) override; -- Gitee