已合并
【录制框架】AVRecorder补充NDK接口 #7524
刘祥创建于 3月9日
【录制框架】AVRecorder补充NDK接口 #7524
已合并
共 31 个文件变更+395-40
| @@ -698,7 +698,7 @@ int32_t CjAVRecorder::GetAudioCapturerMaxAmplitude(int32_t *errCode) | |||
| 698 | return retMaxAmplitude; | 698 | return retMaxAmplitude; |
| 699 | } | 699 | } |
| 700 | if (CheckStateMachine(opt) == MSERR_OK) { | 700 | if (CheckStateMachine(opt) == MSERR_OK) { |
| 701 | - retMaxAmplitude = recorder_->GetMaxAmplitude(); | 701 | + *errCode = recorder_->GetMaxAmplitude(retMaxAmplitude); |
| 702 | } else { | 702 | } else { |
| 703 | ret = GetRetInfo(MSERR_INVALID_OPERATION, "GetAudioCapturerMaxAmplitude", "", "CheckStateMachine failed"); | 703 | ret = GetRetInfo(MSERR_INVALID_OPERATION, "GetAudioCapturerMaxAmplitude", "", "CheckStateMachine failed"); |
| 704 | *errCode = ret.first; | 704 | *errCode = ret.first; |
| @@ -92,6 +92,7 @@ napi_value AVRecorderNapi::Init(napi_env env, napi_value exports) | |||
| 92 | DECLARE_NAPI_FUNCTION("getAvailableEncoder", JsGetAvailableEncoder), | 92 | DECLARE_NAPI_FUNCTION("getAvailableEncoder", JsGetAvailableEncoder), |
| 93 | DECLARE_NAPI_FUNCTION("setWatermark", JsSetWatermark), | 93 | DECLARE_NAPI_FUNCTION("setWatermark", JsSetWatermark), |
| 94 | DECLARE_NAPI_FUNCTION("setMetadata", JsSetMetadata), | 94 | DECLARE_NAPI_FUNCTION("setMetadata", JsSetMetadata), |
| 95 | + DECLARE_NAPI_FUNCTION("setCustomInfo", JsSetCustomInfo), | ||
| 95 | DECLARE_NAPI_FUNCTION("isWatermarkSupported", JsIsWatermarkSupported), | 96 | DECLARE_NAPI_FUNCTION("isWatermarkSupported", JsIsWatermarkSupported), |
| 96 | DECLARE_NAPI_FUNCTION("setWillMuteWhenInterrupted", JsSetWillMuteWhenInterrupted), | 97 | DECLARE_NAPI_FUNCTION("setWillMuteWhenInterrupted", JsSetWillMuteWhenInterrupted), |
| 97 | 98 | ||
| @@ -446,6 +447,62 @@ napi_value AVRecorderNapi::JsSetMetadata(napi_env env, napi_callback_info info) | |||
| 446 | return result; | 447 | return result; |
| 447 | } | 448 | } |
| 448 | 449 | ||
| 450 | +napi_value AVRecorderNapi::JsSetCustomInfo(napi_env env, napi_callback_info info) | ||
| 451 | +{ | ||
| 452 | + MediaTrace trace("AVRecorder::JsSetCustomInfo"); | ||
| 453 | + const std::string &opt = AVRecordergOpt::SET_CUSTOM_INFO; | ||
| 454 | + MEDIA_LOGI("Js %{public}s Start", opt.c_str()); | ||
| 455 | + | ||
| 456 | + const int32_t maxParam = 1; // customInfo: Record<string, string> | ||
| 457 | + size_t argCount = maxParam; | ||
| 458 | + napi_value args[maxParam] = { nullptr }; | ||
| 459 | + | ||
| 460 | + napi_value result = nullptr; | ||
| 461 | + napi_get_undefined(env, &result); | ||
| 462 | + | ||
| 463 | + auto asyncCtx = std::make_unique<AVRecorderAsyncContext>(env); | ||
| 464 | + CHECK_AND_RETURN_RET_LOG(asyncCtx != nullptr, result, "failed to get AsyncContext"); | ||
| 465 | + AVRecorderNapi *jsRecorder = AVRecorderNapi::GetJsInstanceAndArgs(env, info, argCount, args); | ||
| 466 | + CHECK_AND_RETURN_RET_LOG(jsRecorder != nullptr, result, "failed to GetJsInstanceAndArgs"); | ||
| 467 | + CHECK_AND_RETURN_RET_LOG(jsRecorder->taskQue_ != nullptr, result, "taskQue is nullptr!"); | ||
| 468 | + | ||
| 469 | + if (jsRecorder->CheckStateMachine(opt) == MSERR_OK) { | ||
| 470 | + std::map<std::string, std::string> recordMeta; | ||
| 471 | + CommonNapi::GetPropertyMap(env, args[0], recordMeta); | ||
| 472 | + CHECK_AND_RETURN_RET_LOG(recordMeta.size() != 0, result, "recordMeta has no data"); | ||
| 473 | + | ||
| 474 | + asyncCtx->task_ = std::make_shared<TaskHandler<RetInfo>>([jsRecorder, recordMeta]() { | ||
| 475 | + int32_t ret = jsRecorder->SetCustomInfo(recordMeta); | ||
| 476 | + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(ret, "SetCustomInfoTask", ""), | ||
| 477 | + "SetCustomInfoTask failed"); | ||
| 478 | + return RetInfo(MSERR_EXT_API9_OK, ""); | ||
| 479 | + }); | ||
| 480 | + (void)jsRecorder->taskQue_->EnqueueTask(asyncCtx->task_); | ||
| 481 | + } else { | ||
| 482 | + asyncCtx->AVRecorderSignError(MSERR_INVALID_STATE, opt, ""); | ||
| 483 | + } | ||
| 484 | + | ||
| 485 | + napi_value resource = nullptr; | ||
| 486 | + napi_create_string_utf8(env, opt.c_str(), NAPI_AUTO_LENGTH, &resource); | ||
| 487 | + NAPI_CALL(env, napi_create_async_work(env, nullptr, resource, [](napi_env env, void* data) { | ||
| 488 | + AVRecorderAsyncContext* asyncCtx = reinterpret_cast<AVRecorderAsyncContext *>(data); | ||
| 489 | + CHECK_AND_RETURN_LOG(asyncCtx != nullptr, "asyncCtx is nullptr!"); | ||
| 490 | + | ||
| 491 | + if (asyncCtx->task_) { | ||
| 492 | + auto result = asyncCtx->task_->GetResult(); | ||
| 493 | + if (result.Value().first != MSERR_EXT_API9_OK) { | ||
| 494 | + asyncCtx->SignError(result.Value().first, result.Value().second); | ||
| 495 | + } | ||
| 496 | + } | ||
| 497 | + MEDIA_LOGI("The js thread of %{public}s finishes execution and returns", opt.c_str()); | ||
| 498 | + }, MediaAsyncContext::CompleteCallback, static_cast<void *>(asyncCtx.get()), &asyncCtx->work)); | ||
| 499 | + NAPI_CALL(env, napi_queue_async_work_with_qos(env, asyncCtx->work, napi_qos_user_initiated)); | ||
| 500 | + asyncCtx.release(); | ||
| 501 | + | ||
| 502 | + MEDIA_LOGI("Js %{public}s End", opt.c_str()); | ||
| 503 | + return result; | ||
| 504 | +} | ||
| 505 | + | ||
| 449 | std::shared_ptr<TaskHandler<RetInfo>> AVRecorderNapi::GetPrepareTask(std::unique_ptr<AVRecorderAsyncContext> &asyncCtx) | 506 | std::shared_ptr<TaskHandler<RetInfo>> AVRecorderNapi::GetPrepareTask(std::unique_ptr<AVRecorderAsyncContext> &asyncCtx) |
| 450 | { | 507 | { |
| 451 | return std::make_shared<TaskHandler<RetInfo>>([napi = asyncCtx->napi, config = asyncCtx->config_]() { | 508 | return std::make_shared<TaskHandler<RetInfo>>([napi = asyncCtx->napi, config = asyncCtx->config_]() { |
| @@ -1609,8 +1666,7 @@ int32_t AVRecorderNapi::GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &ch | |||
| 1609 | 1666 | ||
| 1610 | int32_t AVRecorderNapi::GetMaxAmplitude(int32_t &maxAmplitude) | 1667 | int32_t AVRecorderNapi::GetMaxAmplitude(int32_t &maxAmplitude) |
| 1611 | { | 1668 | { |
| 1612 | - maxAmplitude = recorder_->GetMaxAmplitude(); | 1669 | + return recorder_->GetMaxAmplitude(maxAmplitude); |
| 1613 | - return MSERR_OK; | ||
| 1614 | } | 1670 | } |
| 1615 | 1671 | ||
| 1616 | int32_t AVRecorderNapi::GetEncoderInfo(std::vector<EncoderCapabilityData> &encoderInfo) | 1672 | int32_t AVRecorderNapi::GetEncoderInfo(std::vector<EncoderCapabilityData> &encoderInfo) |
| @@ -1678,6 +1734,16 @@ int32_t AVRecorderNapi::SetMetadata(const std::map<std::string, std::string> &re | |||
| 1678 | return recorder_->SetUserMeta(userMeta); | 1734 | return recorder_->SetUserMeta(userMeta); |
| 1679 | } | 1735 | } |
| 1680 | 1736 | ||
| 1737 | +int32_t AVRecorderNapi::SetCustomInfo(const std::map<std::string, std::string> &recordMeta) | ||
| 1738 | +{ | ||
| 1739 | + std::shared_ptr<Meta> userMeta = std::make_shared<Meta>(); | ||
| 1740 | + for (auto &meta : recordMeta) { | ||
| 1741 | + MEDIA_LOGI("recordMeta tag: %{public}s, value: %{public}s", meta.first.c_str(), meta.second.c_str()); | ||
| 1742 | + userMeta->SetData(meta.first, meta.second); | ||
| 1743 | + } | ||
| 1744 | + return recorder_->SetCustomInfo(userMeta); | ||
| 1745 | +} | ||
| 1746 | + | ||
| 1681 | int32_t AVRecorderNapi::ConfigAVBufferMeta(std::shared_ptr<PixelMap> &pixelMap, | 1747 | int32_t AVRecorderNapi::ConfigAVBufferMeta(std::shared_ptr<PixelMap> &pixelMap, |
| 1682 | std::shared_ptr<WatermarkConfig> &watermarkConfig, std::shared_ptr<Meta> &meta) | 1748 | std::shared_ptr<WatermarkConfig> &watermarkConfig, std::shared_ptr<Meta> &meta) |
| 1683 | { | 1749 | { |
| @@ -60,6 +60,7 @@ const std::string GET_ENCODER_INFO = "GetEncoderInfo"; | |||
| 60 | const std::string IS_WATERMARK_SUPPORTED = "IsWatermarkSupported"; | 60 | const std::string IS_WATERMARK_SUPPORTED = "IsWatermarkSupported"; |
| 61 | const std::string SET_WATERMARK = "SetWatermark"; | 61 | const std::string SET_WATERMARK = "SetWatermark"; |
| 62 | const std::string SET_METADATA = "SetMetadata"; | 62 | const std::string SET_METADATA = "SetMetadata"; |
| 63 | +const std::string SET_CUSTOM_INFO = "SetCustomInfo"; | ||
| 63 | const std::string SET_WILL_MUTE_WHEN_INTERRUPTED = "SetWillMuteWhenInterrupted"; | 64 | const std::string SET_WILL_MUTE_WHEN_INTERRUPTED = "SetWillMuteWhenInterrupted"; |
| 64 | } | 65 | } |
| 65 | 66 | ||
| @@ -94,7 +95,8 @@ const std::map<std::string, std::vector<std::string>> stateCtrlList = { | |||
| 94 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, | 95 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, |
| 95 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, | 96 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, |
| 96 | AVRecordergOpt::SET_WATERMARK, | 97 | AVRecordergOpt::SET_WATERMARK, |
| 97 | - AVRecordergOpt::SET_METADATA | 98 | + AVRecordergOpt::SET_METADATA, |
| 99 | + AVRecordergOpt::SET_CUSTOM_INFO, | ||
| 98 | }}, | 100 | }}, |
| 99 | {AVRecorderState::STATE_STARTED, { | 101 | {AVRecorderState::STATE_STARTED, { |
| 100 | AVRecordergOpt::START, | 102 | AVRecordergOpt::START, |
| @@ -108,7 +110,8 @@ const std::map<std::string, std::vector<std::string>> stateCtrlList = { | |||
| 108 | AVRecordergOpt::GET_ENCODER_INFO, | 110 | AVRecordergOpt::GET_ENCODER_INFO, |
| 109 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, | 111 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, |
| 110 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, | 112 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, |
| 111 | - AVRecordergOpt::SET_METADATA | 113 | + AVRecordergOpt::SET_METADATA, |
| 114 | + AVRecordergOpt::SET_CUSTOM_INFO, | ||
| 112 | }}, | 115 | }}, |
| 113 | {AVRecorderState::STATE_PAUSED, { | 116 | {AVRecorderState::STATE_PAUSED, { |
| 114 | AVRecordergOpt::PAUSE, | 117 | AVRecordergOpt::PAUSE, |
| @@ -121,7 +124,8 @@ const std::map<std::string, std::vector<std::string>> stateCtrlList = { | |||
| 121 | AVRecordergOpt::GET_ENCODER_INFO, | 124 | AVRecordergOpt::GET_ENCODER_INFO, |
| 122 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, | 125 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, |
| 123 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, | 126 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, |
| 124 | - AVRecordergOpt::SET_METADATA | 127 | + AVRecordergOpt::SET_METADATA, |
| 128 | + AVRecordergOpt::SET_CUSTOM_INFO, | ||
| 125 | }}, | 129 | }}, |
| 126 | {AVRecorderState::STATE_STOPPED, { | 130 | {AVRecorderState::STATE_STOPPED, { |
| 127 | AVRecordergOpt::STOP, | 131 | AVRecordergOpt::STOP, |
| @@ -229,6 +233,10 @@ private: | |||
| 229 | * setMetadata(metadata: Record<string, string>): void; | 233 | * setMetadata(metadata: Record<string, string>): void; |
| 230 | */ | 234 | */ |
| 231 | static napi_value JsSetMetadata(napi_env env, napi_callback_info info); | 235 | static napi_value JsSetMetadata(napi_env env, napi_callback_info info); |
| 236 | + /** | ||
| 237 | + * setCustomInfo(customInfo: Record<string, string>): void; | ||
| 238 | + */ | ||
| 239 | + static napi_value JsSetCustomInfo(napi_env env, napi_callback_info info); | ||
| 232 | /** | 240 | /** |
| 233 | * getInputSurface(callback: AsyncCallback<string>): void | 241 | * getInputSurface(callback: AsyncCallback<string>): void |
| 234 | * getInputSurface(): Promise<string> | 242 | * getInputSurface(): Promise<string> |
| @@ -386,6 +394,7 @@ private: | |||
| 386 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); | 394 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); |
| 387 | int32_t SetWatermark(std::shared_ptr<PixelMap> &pixelMap, std::shared_ptr<WatermarkConfig> &watermarkConfig); | 395 | int32_t SetWatermark(std::shared_ptr<PixelMap> &pixelMap, std::shared_ptr<WatermarkConfig> &watermarkConfig); |
| 388 | int32_t SetMetadata(const std::map<std::string, std::string> &recordMeta); | 396 | int32_t SetMetadata(const std::map<std::string, std::string> &recordMeta); |
| 397 | + int32_t SetCustomInfo(const std::map<std::string, std::string> &recordMeta); | ||
| 389 | 398 | ||
| 390 | void ErrorCallback(int32_t errCode, const std::string &operate, const std::string &add = ""); | 399 | void ErrorCallback(int32_t errCode, const std::string &operate, const std::string &add = ""); |
| 391 | void StateCallback(const std::string &state); | 400 | void StateCallback(const std::string &state); |
| @@ -597,6 +597,48 @@ OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig(OH_AVRecorder *recorder, OH_AVRec | |||
| 597 | return AV_ERR_OK; | 597 | return AV_ERR_OK; |
| 598 | } | 598 | } |
| 599 | 599 | ||
| 600 | +OH_AVErrCode OH_AVRecorder_GetAudioCapturerMaxAmplitude(OH_AVRecorder *recorder, int32_t *amplitude) | ||
| 601 | +{ | ||
| 602 | + MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_GetAudioCapturerMaxAmplitude in."); | ||
| 603 | + CHECK_AND_RETURN_RET_LOG(recorder != nullptr, AV_ERR_INVALID_VAL, "input recorder is nullptr!"); | ||
| 604 | + | ||
| 605 | + struct RecorderObject *recorderObj = reinterpret_cast<RecorderObject *>(recorder); | ||
| 606 | + CHECK_AND_RETURN_RET_LOG(recorderObj != nullptr, AV_ERR_INVALID_VAL, "recorderObj is nullptr"); | ||
| 607 | + CHECK_AND_RETURN_RET_LOG(recorderObj->recorder_ != nullptr, AV_ERR_INVALID_VAL, "recorder_ is null"); | ||
| 608 | + | ||
| 609 | + int32_t ret = recorderObj->recorder_->GetMaxAmplitude(*amplitude); | ||
| 610 | + | ||
| 611 | + CHECK_AND_RETURN_RET_LOG(ret != MSERR_INVALID_STATE, AV_ERR_INVALID_STATE, "Invalid state"); | ||
| 612 | + CHECK_AND_RETURN_RET_LOG(ret != MSERR_NO_MEMORY, AV_ERR_NO_MEMORY, "No memory"); | ||
| 613 | + CHECK_AND_RETURN_RET_LOG(ret != MSERR_INVALID_VAL, AV_ERR_INVALID_VAL, "Invalid value"); | ||
| 614 | + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_UNKNOWN, "GetAudioCapturerMaxAmplitude failed!"); | ||
| 615 | + | ||
| 616 | + MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_GetAudioCapturerMaxAmplitude out."); | ||
| 617 | + return AV_ERR_OK; | ||
| 618 | +} | ||
| 619 | + | ||
| 620 | +OH_AVErrCode OH_AVRecorder_SetCustomInfo(OH_AVRecorder *recorder, OH_AVFormat *customInfo) | ||
| 621 | +{ | ||
| 622 | + MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_SetCustomInfo in."); | ||
| 623 | + CHECK_AND_RETURN_RET_LOG(recorder != nullptr, AV_ERR_INVALID_VAL, "input recorder is nullptr!"); | ||
| 624 | + CHECK_AND_RETURN_RET_LOG(customInfo != nullptr, AV_ERR_INVALID_VAL, "input customInfo is nullptr!"); | ||
| 625 | + | ||
| 626 | + struct RecorderObject *recorderObj = reinterpret_cast<RecorderObject *>(recorder); | ||
| 627 | + CHECK_AND_RETURN_RET_LOG(recorderObj != nullptr, AV_ERR_INVALID_VAL, "recorderObj is nullptr"); | ||
| 628 | + CHECK_AND_RETURN_RET_LOG(recorderObj->recorder_ != nullptr, AV_ERR_INVALID_VAL, "recorder_ is null"); | ||
| 629 | + | ||
| 630 | + std::shared_ptr<Meta> meta = customInfo->format_.GetMeta(); | ||
| 631 | + int32_t ret = recorderObj->recorder_->SetCustomInfo(meta); | ||
| 632 | + | ||
| 633 | + CHECK_AND_RETURN_RET_LOG(ret != MSERR_INVALID_STATE, AV_ERR_INVALID_STATE, "Invalid state"); | ||
| 634 | + CHECK_AND_RETURN_RET_LOG(ret != MSERR_NO_MEMORY, AV_ERR_NO_MEMORY, "No memory"); | ||
| 635 | + CHECK_AND_RETURN_RET_LOG(ret != MSERR_INVALID_VAL, AV_ERR_INVALID_VAL, "Invalid value"); | ||
| 636 | + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_UNKNOWN, "SetCustomInfo failed!"); | ||
| 637 | + | ||
| 638 | + MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_SetCustomInfo out."); | ||
| 639 | + return AV_ERR_OK; | ||
| 640 | +} | ||
| 641 | + | ||
| 600 | OH_AVErrCode OH_AVRecorder_GetInputSurface(OH_AVRecorder *recorder, OHNativeWindow **window) | 642 | OH_AVErrCode OH_AVRecorder_GetInputSurface(OH_AVRecorder *recorder, OHNativeWindow **window) |
| 601 | { | 643 | { |
| 602 | MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_GetInputSurface in."); | 644 | MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_GetInputSurface in."); |
| @@ -414,10 +414,10 @@ int32_t RecorderImpl::GetAvailableEncoder(std::vector<EncoderCapabilityData> &en | |||
| 414 | return recorderService_->GetAvailableEncoder(encoderInfo); | 414 | return recorderService_->GetAvailableEncoder(encoderInfo); |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | -int32_t RecorderImpl::GetMaxAmplitude() | 417 | +int32_t RecorderImpl::GetMaxAmplitude(int32_t &litude) |
| 418 | { | 418 | { |
| 419 | CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); | 419 | CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); |
| 420 | - return recorderService_->GetMaxAmplitude(); | 420 | + return recorderService_->GetMaxAmplitude(amplitude); |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | int32_t RecorderImpl::IsWatermarkSupported(bool &isWatermarkSupported) | 423 | int32_t RecorderImpl::IsWatermarkSupported(bool &isWatermarkSupported) |
| @@ -438,6 +438,12 @@ int32_t RecorderImpl::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 438 | return recorderService_->SetUserMeta(userMeta); | 438 | return recorderService_->SetUserMeta(userMeta); |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | +int32_t RecorderImpl::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 442 | +{ | ||
| 443 | + CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); | ||
| 444 | + return recorderService_->SetCustomInfo(customInfo); | ||
| 445 | +} | ||
| 446 | + | ||
| 441 | int32_t RecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 447 | int32_t RecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 442 | { | 448 | { |
| 443 | CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); | 449 | CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); |
| @@ -75,10 +75,11 @@ public: | |||
| 75 | int32_t GetLocation(Location &location) override; | 75 | int32_t GetLocation(Location &location) override; |
| 76 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; | 76 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; |
| 77 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; | 77 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; |
| 78 | - int32_t GetMaxAmplitude() override; | 78 | + int32_t GetMaxAmplitude(int32_t &litude) override; |
| 79 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; | 79 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; |
| 80 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; | 80 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; |
| 81 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; | 81 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; |
| 82 | + int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) override; | ||
| 82 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 83 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 83 | private: | 84 | private: |
| 84 | std::shared_ptr<IRecorderService> recorderService_ = nullptr; | 85 | std::shared_ptr<IRecorderService> recorderService_ = nullptr; |
| @@ -1592,8 +1592,7 @@ std::shared_ptr<TaskHandler<RetInfo>> AVRecorderImpl::GetMaxAmplitudeTask( | |||
| 1592 | 1592 | ||
| 1593 | int32_t AVRecorderImpl::GetMaxAmplitude(int32_t &maxAmplitude) | 1593 | int32_t AVRecorderImpl::GetMaxAmplitude(int32_t &maxAmplitude) |
| 1594 | { | 1594 | { |
| 1595 | - maxAmplitude = recorder_->GetMaxAmplitude(); | 1595 | + return recorder_->GetMaxAmplitude(maxAmplitude); |
| 1596 | - return MSERR_OK; | ||
| 1597 | } | 1596 | } |
| 1598 | 1597 | ||
| 1599 | void AVRecorderImpl::SetWatermarkSync(::ohos::multimedia::image::image::weak::PixelMap watermark, | 1598 | void AVRecorderImpl::SetWatermarkSync(::ohos::multimedia::image::image::weak::PixelMap watermark, |
| @@ -965,7 +965,8 @@ public: | |||
| 965 | 965 | ||
| 966 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; | 966 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; |
| 967 | 967 | ||
| 968 | - virtual int32_t GetMaxAmplitude() = 0; | 968 | + virtual int32_t GetMaxAmplitude(int32_t &litude) = 0; |
| 969 | + | ||
| 969 | /** | 970 | /** |
| 970 | * @brief Check if the avrecorder has watermark capability. | 971 | * @brief Check if the avrecorder has watermark capability. |
| 971 | * | 972 | * |
| @@ -995,6 +996,16 @@ public: | |||
| 995 | */ | 996 | */ |
| 996 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; | 997 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; |
| 997 | 998 | ||
| 999 | + /** | ||
| 1000 | + * @brief Set custom info to avrecorder. | ||
| 1001 | + * | ||
| 1002 | + * @param customInfo metadata | ||
| 1003 | + * @return Returns {@link MSERR_OK} If the SetCustomInfo succeeds; returns an error code otherwise. | ||
| 1004 | + * @since 1.0 | ||
| 1005 | + * @version 1.0 | ||
| 1006 | + */ | ||
| 1007 | + virtual int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) = 0; | ||
| 1008 | + | ||
| 998 | /** @brief set interrupt mode to avrecorder. | 1009 | /** @brief set interrupt mode to avrecorder. |
| 999 | * | 1010 | * |
| 1000 | * @param muteWhenInterrupted muteWhenInterrupted true or false. | 1011 | * @param muteWhenInterrupted muteWhenInterrupted true or false. |
| @@ -47,6 +47,8 @@ | |||
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | + | ||
| 51 | + | ||
| 50 | 52 | ||
| 51 | 53 | ||
| 52 | extern "C" { | 54 | extern "C" { |
| @@ -87,6 +89,42 @@ OH_AVErrCode OH_AVRecorder_Prepare(OH_AVRecorder *recorder, OH_AVRecorder_Config | |||
| 87 | */ | 89 | */ |
| 88 | OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig(OH_AVRecorder *recorder, OH_AVRecorder_Config **config); | 90 | OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig(OH_AVRecorder *recorder, OH_AVRecorder_Config **config); |
| 89 | 91 | ||
| 92 | +/** | ||
| 93 | + * @brief Obtains the maximum amplitude of the current audio capturer. | ||
| 94 | + * The amplitude value is the max value from the last call to the current call. | ||
| 95 | + * For example, if you have obtained the maximum amplitude at 1s, and you call this API again at 2s, | ||
| 96 | + * then the return value is the maximum amplitude within the duration from 1s to 2s. | ||
| 97 | + * | ||
| 98 | + * This API can be called only after the **prepare()** API is called. | ||
| 99 | + * If this API is called after **stop()** is successfully called, an error is reported. | ||
| 100 | + * | ||
| 101 | + * @param recorder - Pointer to an OH_AVRecorder instance | ||
| 102 | + * @param amplitude - The max amplitude value of audio capturer | ||
| 103 | + * @return Function result code. | ||
| 104 | + * {@link AV_ERR_OK} if the execution is successful. | ||
| 105 | + * {@link AV_ERR_INVALID_VAL} if input recorder is nullptr. | ||
| 106 | + * {@link AV_ERR_INVALID_STATE} function called in invalid state, only available after prepare state, | ||
| 107 | + * and before stop state. | ||
| 108 | + * @since 26.0.0 | ||
| 109 | + */ | ||
| 110 | +OH_AVErrCode OH_AVRecorder_GetAudioCapturerMaxAmplitude(OH_AVRecorder *recorder, int32_t* amplitude); | ||
| 111 | + | ||
| 112 | +/** | ||
| 113 | + * @brief Set custom info (key value pairs) for the recording file of the recorder. | ||
| 114 | + * This custom info overwrites the value in config.metadata.customInfo (see {prepare()} and {OH_AVRecorder_Config}) | ||
| 115 | + * if they have same key. | ||
| 116 | + * This API can be called only after the **prepare()** API is called, before starting recoder. | ||
| 117 | + * | ||
| 118 | + * @param recorder - Pointer to an OH_AVRecorder instance | ||
| 119 | + * @param customInfo - The key value pairs added to the the recording file. | ||
| 120 | + * @return Function result code. | ||
| 121 | + * {@link AV_ERR_OK} if the execution is successful. | ||
| 122 | + * {@link AV_ERR_INVALID_VAL} if input recorder is nullptr or customInfo is nullptr. | ||
| 123 | + * {@link AV_ERR_INVALID_STATE} function called in invalid state (only available in prepared state) | ||
| 124 | + * @since 26.0.0 | ||
| 125 | + */ | ||
| 126 | +OH_AVErrCode OH_AVRecorder_SetCustomInfo(OH_AVRecorder *recorder, OH_AVFormat *customInfo); | ||
| 127 | + | ||
| 90 | /** | 128 | /** |
| 91 | * @brief Get input surface, it must be called between prepare completed and start. | 129 | * @brief Get input surface, it must be called between prepare completed and start. |
| 92 | * @syscap SystemCapability.Multimedia.Media.AVRecorder | 130 | * @syscap SystemCapability.Multimedia.Media.AVRecorder |
| @@ -751,12 +751,14 @@ int32_t HiRecorderImpl::GetAvailableEncoder(std::vector<EncoderCapabilityData> & | |||
| 751 | return (int32_t)ret; | 751 | return (int32_t)ret; |
| 752 | } | 752 | } |
| 753 | 753 | ||
| 754 | -int32_t HiRecorderImpl::GetMaxAmplitude() | 754 | +int32_t HiRecorderImpl::GetMaxAmplitude(int32_t &litude) |
| 755 | { | 755 | { |
| 756 | FALSE_RETURN_V_MSG_E(audioCaptureFilter_ != nullptr, | 756 | FALSE_RETURN_V_MSG_E(audioCaptureFilter_ != nullptr, |
| 757 | (int32_t)Status::ERROR_INVALID_OPERATION, "audioCaptureFilter_ is null, cannot get audio max amplitude"); | 757 | (int32_t)Status::ERROR_INVALID_OPERATION, "audioCaptureFilter_ is null, cannot get audio max amplitude"); |
| 758 | 758 | ||
| 759 | - return audioCaptureFilter_->GetMaxAmplitude(); | 759 | + Status ret = audioCaptureFilter_->GetMaxAmplitude(amplitude); |
| 760 | + | ||
| 761 | + return (int32_t)ret; | ||
| 760 | } | 762 | } |
| 761 | 763 | ||
| 762 | void HiRecorderImpl::ConfigureAudio(const RecorderParam &recParam) | 764 | void HiRecorderImpl::ConfigureAudio(const RecorderParam &recParam) |
| @@ -1256,6 +1258,13 @@ int32_t HiRecorderImpl::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 1256 | return static_cast<int32_t>(Status::OK); | 1258 | return static_cast<int32_t>(Status::OK); |
| 1257 | } | 1259 | } |
| 1258 | 1260 | ||
| 1261 | +Status HiRecorderImpl::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 1262 | +{ | ||
| 1263 | + FALSE_RETURN_V_MSG_E(muxerFilter_ != nullptr, Status::ERROR_NULL_POINTER, | ||
| 1264 | + "muxerFilter is nullptr, cannot set customInfo"); | ||
| 1265 | + return muxerFilter_->SetCustomInfo(customInfo); | ||
| 1266 | +} | ||
| 1267 | + | ||
| 1259 | int32_t HiRecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 1268 | int32_t HiRecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 1260 | { | 1269 | { |
| 1261 | muteWhenInterrupted_ = muteWhenInterrupted; | 1270 | muteWhenInterrupted_ = muteWhenInterrupted; |
| @@ -79,11 +79,12 @@ public: | |||
| 79 | void OnAudioCaptureChange(const AudioStandard::AudioCapturerChangeInfo &capturerChangeInfo); | 79 | void OnAudioCaptureChange(const AudioStandard::AudioCapturerChangeInfo &capturerChangeInfo); |
| 80 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo); | 80 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo); |
| 81 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo); | 81 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo); |
| 82 | - int32_t GetMaxAmplitude(); | 82 | + int32_t GetMaxAmplitude(int32_t &litude); |
| 83 | void SetCallingInfo(const std::string &bundleName, uint64_t instanceId); | 83 | void SetCallingInfo(const std::string &bundleName, uint64_t instanceId); |
| 84 | int32_t IsWatermarkSupported(bool &isWatermarkSupported); | 84 | int32_t IsWatermarkSupported(bool &isWatermarkSupported); |
| 85 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer); | 85 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer); |
| 86 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta); | 86 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta); |
| 87 | + Status SetCustomInfo(const std::shared_ptr<Meta> &customInfo); | ||
| 87 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); | 88 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); |
| 88 | 89 | ||
| 89 | private: | 90 | private: |
| @@ -608,7 +608,7 @@ public: | |||
| 608 | 608 | ||
| 609 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; | 609 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; |
| 610 | 610 | ||
| 611 | - virtual int32_t GetMaxAmplitude() = 0; | 611 | + virtual int32_t GetMaxAmplitude(int32_t &litude) = 0; |
| 612 | 612 | ||
| 613 | /** | 613 | /** |
| 614 | * @brief Custom parameter | 614 | * @brief Custom parameter |
| @@ -640,6 +640,7 @@ public: | |||
| 640 | virtual int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) = 0; | 640 | virtual int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) = 0; |
| 641 | 641 | ||
| 642 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; | 642 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; |
| 643 | + virtual int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) = 0; | ||
| 643 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; | 644 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; |
| 644 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; | 645 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; |
| 645 | }; | 646 | }; |
| @@ -206,9 +206,9 @@ public: | |||
| 206 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; | 206 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; |
| 207 | /** | 207 | /** |
| 208 | * Get current audio max amplitude. | 208 | * Get current audio max amplitude. |
| 209 | - * Return max amplitude. | 209 | + * Return MSERR_OK indicates success, or others indicate failed. |
| 210 | */ | 210 | */ |
| 211 | - virtual int32_t GetMaxAmplitude() = 0; | 211 | + virtual int32_t GetMaxAmplitude(int32_t &litude) = 0; |
| 212 | /** | 212 | /** |
| 213 | * Set App calling info for recording. | 213 | * Set App calling info for recording. |
| 214 | */ | 214 | */ |
| @@ -225,6 +225,10 @@ public: | |||
| 225 | * Set user meta | 225 | * Set user meta |
| 226 | */ | 226 | */ |
| 227 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; | 227 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; |
| 228 | + /** | ||
| 229 | + * Set custom info | ||
| 230 | + */ | ||
| 231 | + virtual Status SetCustomInfo(const std::shared_ptr<Meta> &customInfo) = 0; | ||
| 228 | 232 | ||
| 229 | /** | 233 | /** |
| 230 | * Set Interrupt strategy | 234 | * Set Interrupt strategy |
| @@ -535,13 +535,13 @@ int32_t RecorderClient::GetAvailableEncoder(std::vector<EncoderCapabilityData> & | |||
| 535 | return recorderProxy_->GetAvailableEncoder(encoderInfo); | 535 | return recorderProxy_->GetAvailableEncoder(encoderInfo); |
| 536 | } | 536 | } |
| 537 | 537 | ||
| 538 | -int32_t RecorderClient::GetMaxAmplitude() | 538 | +int32_t RecorderClient::GetMaxAmplitude(int32_t &litude) |
| 539 | { | 539 | { |
| 540 | std::lock_guard<std::mutex> lock(mutex_); | 540 | std::lock_guard<std::mutex> lock(mutex_); |
| 541 | CHECK_AND_RETURN_RET_LOG(recorderProxy_ != nullptr, MSERR_NO_MEMORY, "recorder service does not exist."); | 541 | CHECK_AND_RETURN_RET_LOG(recorderProxy_ != nullptr, MSERR_NO_MEMORY, "recorder service does not exist."); |
| 542 | 542 | ||
| 543 | MEDIA_LOGD("GetMaxAmplitude"); | 543 | MEDIA_LOGD("GetMaxAmplitude"); |
| 544 | - return recorderProxy_->GetMaxAmplitude(); | 544 | + return recorderProxy_->GetMaxAmplitude(amplitude); |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | int32_t RecorderClient::IsWatermarkSupported(bool &isWatermarkSupported) | 547 | int32_t RecorderClient::IsWatermarkSupported(bool &isWatermarkSupported) |
| @@ -571,6 +571,15 @@ int32_t RecorderClient::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 571 | return recorderProxy_->SetUserMeta(userMeta); | 571 | return recorderProxy_->SetUserMeta(userMeta); |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | +int32_t RecorderClient::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 575 | +{ | ||
| 576 | + std::lock_guard<std::mutex> lock(mutex_); | ||
| 577 | + CHECK_AND_RETURN_RET_LOG(recorderProxy_ != nullptr, MSERR_NO_MEMORY, "recorder service does not exist."); | ||
| 578 | + | ||
| 579 | + MEDIA_LOGD("SetCustomInfo"); | ||
| 580 | + return recorderProxy_->SetCustomInfo(customInfo); | ||
| 581 | +} | ||
| 582 | + | ||
| 574 | int32_t RecorderClient::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 583 | int32_t RecorderClient::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 575 | { | 584 | { |
| 576 | std::lock_guard<std::mutex> lock(mutex_); | 585 | std::lock_guard<std::mutex> lock(mutex_); |
| @@ -78,10 +78,11 @@ public: | |||
| 78 | int32_t GetLocation(Location &location) override; | 78 | int32_t GetLocation(Location &location) override; |
| 79 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; | 79 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; |
| 80 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; | 80 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; |
| 81 | - int32_t GetMaxAmplitude() override; | 81 | + int32_t GetMaxAmplitude(int32_t &litude) override; |
| 82 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; | 82 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; |
| 83 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; | 83 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; |
| 84 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; | 84 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; |
| 85 | + int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) override; | ||
| 85 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 86 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 86 | int32_t TransmitQos(QOS::QosLevel level) override; | 87 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 87 | // RecorderClient | 88 | // RecorderClient |
| @@ -95,10 +95,11 @@ public: | |||
| 95 | virtual int32_t SetVideoEnableBFrame(int32_t sourceId, bool enableBFrame) = 0; | 95 | virtual int32_t SetVideoEnableBFrame(int32_t sourceId, bool enableBFrame) = 0; |
| 96 | virtual int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) = 0; | 96 | virtual int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) = 0; |
| 97 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; | 97 | virtual int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) = 0; |
| 98 | - virtual int32_t GetMaxAmplitude() = 0; | 98 | + virtual int32_t GetMaxAmplitude(int32_t &litude) = 0; |
| 99 | virtual int32_t IsWatermarkSupported(bool &isWatermarkSupported) = 0; | 99 | virtual int32_t IsWatermarkSupported(bool &isWatermarkSupported) = 0; |
| 100 | virtual int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) = 0; | 100 | virtual int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) = 0; |
| 101 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; | 101 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; |
| 102 | + virtual int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) = 0; | ||
| 102 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; | 103 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; |
| 103 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; | 104 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; |
| 104 | /** | 105 | /** |
| @@ -159,6 +160,7 @@ public: | |||
| 159 | SET_INTERRUPT_STRATEGY, | 160 | SET_INTERRUPT_STRATEGY, |
| 160 | TRANSMIT_QOS, | 161 | TRANSMIT_QOS, |
| 161 | SET_AUDIO_AACPROFILE, | 162 | SET_AUDIO_AACPROFILE, |
| 163 | + SET_CUSTOMINFO, | ||
| 162 | }; | 164 | }; |
| 163 | 165 | ||
| 164 | DECLARE_INTERFACE_DESCRIPTOR(u"IStandardRecorderService"); | 166 | DECLARE_INTERFACE_DESCRIPTOR(u"IStandardRecorderService"); |
| @@ -954,7 +954,7 @@ int32_t RecorderServiceProxy::GetAvailableEncoder(std::vector<EncoderCapabilityD | |||
| 954 | return reply.ReadInt32(); | 954 | return reply.ReadInt32(); |
| 955 | } | 955 | } |
| 956 | 956 | ||
| 957 | -int32_t RecorderServiceProxy::GetMaxAmplitude() | 957 | +int32_t RecorderServiceProxy::GetMaxAmplitude(int32_t &litude) |
| 958 | { | 958 | { |
| 959 | MessageParcel data; | 959 | MessageParcel data; |
| 960 | MessageParcel reply; | 960 | MessageParcel reply; |
| @@ -966,9 +966,9 @@ int32_t RecorderServiceProxy::GetMaxAmplitude() | |||
| 966 | int error = Remote()->SendRequest(GET_MAX_AMPLITUDE, data, reply, option); | 966 | int error = Remote()->SendRequest(GET_MAX_AMPLITUDE, data, reply, option); |
| 967 | CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, | 967 | CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, |
| 968 | "GetMaxAmplitude failed, error: %{public}d", error); | 968 | "GetMaxAmplitude failed, error: %{public}d", error); |
| 969 | - int32_t amplitude = reply.ReadInt32(); | 969 | + amplitude = reply.ReadInt32(); |
| 970 | MEDIA_LOGI("GetMaxAmplitude amplitude result: %{public}d", amplitude); | 970 | MEDIA_LOGI("GetMaxAmplitude amplitude result: %{public}d", amplitude); |
| 971 | - return amplitude; | 971 | + return reply.ReadInt32(); |
| 972 | } | 972 | } |
| 973 | 973 | ||
| 974 | int32_t RecorderServiceProxy::IsWatermarkSupported(bool &isWatermarkSupported) | 974 | int32_t RecorderServiceProxy::IsWatermarkSupported(bool &isWatermarkSupported) |
| @@ -1025,6 +1025,25 @@ int32_t RecorderServiceProxy::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 1025 | return reply.ReadInt32(); | 1025 | return reply.ReadInt32(); |
| 1026 | } | 1026 | } |
| 1027 | 1027 | ||
| 1028 | +int32_t RecorderServiceProxy::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 1029 | +{ | ||
| 1030 | + (void)customInfo; | ||
| 1031 | + MessageParcel data; | ||
| 1032 | + MessageParcel reply; | ||
| 1033 | + MessageOption option; | ||
| 1034 | + | ||
| 1035 | + bool token = data.WriteInterfaceToken(RecorderServiceProxy::GetDescriptor()); | ||
| 1036 | + CHECK_AND_RETURN_RET_LOG(token, MSERR_INVALID_OPERATION, "Failed to write descriptor!"); | ||
| 1037 | + | ||
| 1038 | + CHECK_AND_RETURN_RET_LOG(customInfo->ToParcel(data), MSERR_INVALID_OPERATION, "write data failed"); | ||
| 1039 | + | ||
| 1040 | + int error = Remote()->SendRequest(SET_CUSTOMINFO, data, reply, option); | ||
| 1041 | + CHECK_AND_RETURN_RET_LOG(error == MSERR_OK, MSERR_INVALID_OPERATION, | ||
| 1042 | + "SetCustomInfo failed, error: %{public}d", error); | ||
| 1043 | + | ||
| 1044 | + return reply.ReadInt32(); | ||
| 1045 | +} | ||
| 1046 | + | ||
| 1028 | int32_t RecorderServiceProxy::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 1047 | int32_t RecorderServiceProxy::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 1029 | { | 1048 | { |
| 1030 | MessageParcel data; | 1049 | MessageParcel data; |
| @@ -74,10 +74,11 @@ public: | |||
| 74 | int32_t GetLocation(Location &location) override; | 74 | int32_t GetLocation(Location &location) override; |
| 75 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; | 75 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; |
| 76 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; | 76 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; |
| 77 | - int32_t GetMaxAmplitude() override; | 77 | + int32_t GetMaxAmplitude(int32_t &litude) override; |
| 78 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; | 78 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; |
| 79 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; | 79 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; |
| 80 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; | 80 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; |
| 81 | + int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) override; | ||
| 81 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 82 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 82 | int32_t TransmitQos(QOS::QosLevel level) override; | 83 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 83 | private: | 84 | private: |
| @@ -516,10 +516,10 @@ int32_t RecorderServiceStub::GetAvailableEncoder(std::vector<EncoderCapabilityDa | |||
| 516 | return recorderServer_->GetAvailableEncoder(encoderInfo); | 516 | return recorderServer_->GetAvailableEncoder(encoderInfo); |
| 517 | } | 517 | } |
| 518 | 518 | ||
| 519 | -int32_t RecorderServiceStub::GetMaxAmplitude() | 519 | +int32_t RecorderServiceStub::GetMaxAmplitude(int32_t &litude) |
| 520 | { | 520 | { |
| 521 | CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); | 521 | CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); |
| 522 | - return recorderServer_->GetMaxAmplitude(); | 522 | + return recorderServer_->GetMaxAmplitude(amplitude); |
| 523 | } | 523 | } |
| 524 | 524 | ||
| 525 | int32_t RecorderServiceStub::IsWatermarkSupported(bool &isWatermarkSupported) | 525 | int32_t RecorderServiceStub::IsWatermarkSupported(bool &isWatermarkSupported) |
| @@ -546,6 +546,12 @@ int32_t RecorderServiceStub::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 546 | return recorderServer_->SetUserMeta(userMeta); | 546 | return recorderServer_->SetUserMeta(userMeta); |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | +int32_t RecorderServiceStub::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 550 | +{ | ||
| 551 | + CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); | ||
| 552 | + return recorderServer_->SetCustomInfo(customInfo); | ||
| 553 | +} | ||
| 554 | + | ||
| 549 | int32_t RecorderServiceStub::TransmitQos(QOS::QosLevel level) | 555 | int32_t RecorderServiceStub::TransmitQos(QOS::QosLevel level) |
| 550 | { | 556 | { |
| 551 | CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); | 557 | CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); |
| @@ -1149,7 +1155,10 @@ int32_t RecorderServiceStub::GetAvailableEncoder(MessageParcel &data, MessagePar | |||
| 1149 | int32_t RecorderServiceStub::GetMaxAmplitude(MessageParcel &data, MessageParcel &reply) | 1155 | int32_t RecorderServiceStub::GetMaxAmplitude(MessageParcel &data, MessageParcel &reply) |
| 1150 | { | 1156 | { |
| 1151 | (void)data; | 1157 | (void)data; |
| 1152 | - reply.WriteInt32(GetMaxAmplitude()); | 1158 | + int32_t amplitude = 0; |
| 1159 | + int32_t ret = GetMaxAmplitude(amplitude); | ||
| 1160 | + reply.WriteInt32(amplitude); | ||
| 1161 | + reply.WriteInt32(ret); | ||
| 1153 | 1162 | ||
| 1154 | return MSERR_OK; | 1163 | return MSERR_OK; |
| 1155 | } | 1164 | } |
| @@ -1183,6 +1192,16 @@ int32_t RecorderServiceStub::SetUserMeta(MessageParcel &data, MessageParcel &rep | |||
| 1183 | return MSERR_OK; | 1192 | return MSERR_OK; |
| 1184 | } | 1193 | } |
| 1185 | 1194 | ||
| 1195 | +int32_t RecorderServiceStub::SetCustomInfo(MessageParcel &data, MessageParcel &reply) | ||
| 1196 | +{ | ||
| 1197 | + std::shared_ptr<Meta> customInfo = std::make_shared<Meta>(); | ||
| 1198 | + CHECK_AND_RETURN_RET_LOG(customInfo->FromParcel(data), MSERR_INVALID_OPERATION, | ||
| 1199 | + "read custom info failed"); | ||
| 1200 | + CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(SetCustomInfo(customInfo)), MSERR_INVALID_OPERATION, | ||
| 1201 | + "SetCustomInfo reply write failed"); | ||
| 1202 | + return MSERR_OK; | ||
| 1203 | +} | ||
| 1204 | + | ||
| 1186 | int32_t RecorderServiceStub::SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply) | 1205 | int32_t RecorderServiceStub::SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply) |
| 1187 | { | 1206 | { |
| 1188 | bool muteWhenInterrupted = false; | 1207 | bool muteWhenInterrupted = false; |
| @@ -80,10 +80,11 @@ public: | |||
| 80 | int32_t GetLocation(Location &location) override; | 80 | int32_t GetLocation(Location &location) override; |
| 81 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; | 81 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; |
| 82 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; | 82 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; |
| 83 | - int32_t GetMaxAmplitude() override; | 83 | + int32_t GetMaxAmplitude(int32_t &litude) override; |
| 84 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; | 84 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; |
| 85 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; | 85 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; |
| 86 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; | 86 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; |
| 87 | + int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) override; | ||
| 87 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 88 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 88 | int32_t TransmitQos(QOS::QosLevel level) override; | 89 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 89 | // MonitorServerObject override | 90 | // MonitorServerObject override |
| @@ -141,6 +142,7 @@ private: | |||
| 141 | int32_t IsWatermarkSupported(MessageParcel &data, MessageParcel &reply); | 142 | int32_t IsWatermarkSupported(MessageParcel &data, MessageParcel &reply); |
| 142 | int32_t SetWatermark(MessageParcel &data, MessageParcel &reply); | 143 | int32_t SetWatermark(MessageParcel &data, MessageParcel &reply); |
| 143 | int32_t SetUserMeta(MessageParcel &data, MessageParcel &reply); | 144 | int32_t SetUserMeta(MessageParcel &data, MessageParcel &reply); |
| 145 | + int32_t SetCustomInfo(MessageParcel &data, MessageParcel &reply); | ||
| 144 | int32_t SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply); | 146 | int32_t SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply); |
| 145 | int32_t TransmitQos(MessageParcel &data, MessageParcel &reply); | 147 | int32_t TransmitQos(MessageParcel &data, MessageParcel &reply); |
| 146 | int32_t CheckPermission(); | 148 | int32_t CheckPermission(); |
| @@ -1157,12 +1157,14 @@ int32_t RecorderServer::GetAvailableEncoder(std::vector<EncoderCapabilityData> & | |||
| 1157 | return result.Value(); | 1157 | return result.Value(); |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| 1160 | -int32_t RecorderServer::GetMaxAmplitude() | 1160 | +int32_t RecorderServer::GetMaxAmplitude(int32_t &litude) |
| 1161 | { | 1161 | { |
| 1162 | std::lock_guard<std::mutex> lock(mutex_); | 1162 | std::lock_guard<std::mutex> lock(mutex_); |
| 1163 | CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); | 1163 | CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); |
| 1164 | + CHECK_STATUS_FAILED_AND_LOGE_RET(status_ != REC_PREPARED && status_ != REC_RECORDING && status_ != REC_PAUSED, | ||
| 1165 | + MSERR_INVALID_STATE); | ||
| 1164 | auto task = std::make_shared<TaskHandler<int32_t>>([&, this] { | 1166 | auto task = std::make_shared<TaskHandler<int32_t>>([&, this] { |
| 1165 | - return recorderEngine_->GetMaxAmplitude(); | 1167 | + return recorderEngine_->GetMaxAmplitude(amplitude); |
| 1166 | }); | 1168 | }); |
| 1167 | int32_t ret = taskQue_.EnqueueTask(task); | 1169 | int32_t ret = taskQue_.EnqueueTask(task); |
| 1168 | CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); | 1170 | CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); |
| @@ -1221,6 +1223,36 @@ int32_t RecorderServer::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 1221 | return result.Value(); | 1223 | return result.Value(); |
| 1222 | } | 1224 | } |
| 1223 | 1225 | ||
| 1226 | +int32_t RecorderServer::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 1227 | +{ | ||
| 1228 | + MEDIA_LOGI("SetCustomInfo in"); | ||
| 1229 | + std::lock_guard<std::mutex> lock(mutex_); | ||
| 1230 | + MediaTrace trace("RecorderServer::SetCustomInfo"); | ||
| 1231 | + CHECK_STATUS_FAILED_AND_LOGE_RET(status_ != REC_PREPARED && status_ != REC_RECORDING && status_ != REC_PAUSED, | ||
| 1232 | + MSERR_INVALID_STATE); | ||
| 1233 | + CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); | ||
| 1234 | + auto task = std::make_shared<TaskHandler<Status>>([&, this] { | ||
| 1235 | + return recorderEngine_->SetCustomInfo(customInfo); | ||
| 1236 | + }); | ||
| 1237 | + int32_t ret = taskQue_.EnqueueTask(task); | ||
| 1238 | + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); | ||
| 1239 | + | ||
| 1240 | + int32_t result; | ||
| 1241 | + Status statusCode = task->GetResult().Value(); | ||
| 1242 | + if (statusCode == Status::NO_ERROR) { | ||
| 1243 | + result = MSERR_OK; | ||
| 1244 | + } else if (statusCode == Status::ERROR_NULL_POINTER) { | ||
| 1245 | + result = MSERR_NO_MEMORY; | ||
| 1246 | + } else if (statusCode == Status::ERROR_WRONG_STATE) { | ||
| 1247 | + result = MSERR_INVALID_STATE; | ||
| 1248 | + } else if (statusCode == Status::ERROR_INVALID_DATA) { | ||
| 1249 | + result = MSERR_INVALID_VAL; | ||
| 1250 | + } else { | ||
| 1251 | + result = MSERR_UNKNOWN; | ||
| 1252 | + } | ||
| 1253 | + return result; | ||
| 1254 | +} | ||
| 1255 | + | ||
| 1224 | int32_t RecorderServer::TransmitQos(QOS::QosLevel level) | 1256 | int32_t RecorderServer::TransmitQos(QOS::QosLevel level) |
| 1225 | { | 1257 | { |
| 1226 | MEDIA_LOGI("TransmitQos in %{public}d", static_cast<int32_t>(level)); | 1258 | MEDIA_LOGI("TransmitQos in %{public}d", static_cast<int32_t>(level)); |
| @@ -120,10 +120,11 @@ public: | |||
| 120 | int32_t GetLocation(Location &location) override; | 120 | int32_t GetLocation(Location &location) override; |
| 121 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; | 121 | int32_t GetCurrentCapturerChangeInfo(AudioRecorderChangeInfo &changeInfo) override; |
| 122 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; | 122 | int32_t GetAvailableEncoder(std::vector<EncoderCapabilityData> &encoderInfo) override; |
| 123 | - int32_t GetMaxAmplitude() override; | 123 | + int32_t GetMaxAmplitude(int32_t &litude) override; |
| 124 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; | 124 | int32_t IsWatermarkSupported(bool &isWatermarkSupported) override; |
| 125 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; | 125 | int32_t SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) override; |
| 126 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; | 126 | int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) override; |
| 127 | + int32_t SetCustomInfo(const std::shared_ptr<Meta> &customInfo) override; | ||
| 127 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 128 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 128 | int32_t TransmitQos(QOS::QosLevel level) override; | 129 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 129 | 130 | ||
| @@ -352,9 +352,9 @@ void TestRecorder::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | |||
| 352 | recorder->SetWillMuteWhenInterrupted(muteWhenInterrupted); | 352 | recorder->SetWillMuteWhenInterrupted(muteWhenInterrupted); |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | -void TestRecorder::GetMaxAmplitude() | 355 | +void TestRecorder::GetMaxAmplitude(int32_t &litude) |
| 356 | { | 356 | { |
| 357 | - recorder->GetMaxAmplitude(); | 357 | + recorder->GetMaxAmplitude(amplitude); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | bool TestRecorder::RequesetBuffer(const std::string &recorderType, VideoRecorderConfig_ &recorderConfig) | 360 | bool TestRecorder::RequesetBuffer(const std::string &recorderType, VideoRecorderConfig_ &recorderConfig) |
| @@ -86,7 +86,7 @@ public: | |||
| 86 | void SetVideoEnableStableQualityMode(int32_t sourceId, bool enableStableQualityMode); | 86 | void SetVideoEnableStableQualityMode(int32_t sourceId, bool enableStableQualityMode); |
| 87 | void SetVideoEnableBFrame(int32_t sourceId, bool enableBFrame); | 87 | void SetVideoEnableBFrame(int32_t sourceId, bool enableBFrame); |
| 88 | void GetMetaSurface(int32_t sourceId); | 88 | void GetMetaSurface(int32_t sourceId); |
| 89 | - void GetMaxAmplitude(); | 89 | + void GetMaxAmplitude(int32_t &litude); |
| 90 | void SetMetaConfigs(int32_t sourceId); | 90 | void SetMetaConfigs(int32_t sourceId); |
| 91 | void IsWatermarkSupported(bool &isWatermarkSupported); | 91 | void IsWatermarkSupported(bool &isWatermarkSupported); |
| 92 | void SetWillMuteWhenInterrupted(bool muteWhenInterrupted); | 92 | void SetWillMuteWhenInterrupted(bool muteWhenInterrupted); |
| @@ -134,7 +134,8 @@ bool RecorderServiceFuzzer::FuzzRecorderService(uint8_t *data, size_t size) | |||
| 134 | recoderServer->SetFileSplitDuration(FileSplitType::FILE_SPLIT_NORMAL, timestamp, duration); | 134 | recoderServer->SetFileSplitDuration(FileSplitType::FILE_SPLIT_NORMAL, timestamp, duration); |
| 135 | std::vector<EncoderCapabilityData> encoderInfo; | 135 | std::vector<EncoderCapabilityData> encoderInfo; |
| 136 | recoderServer->GetAvailableEncoder(encoderInfo); | 136 | recoderServer->GetAvailableEncoder(encoderInfo); |
| 137 | - recoderServer->GetMaxAmplitude(); | 137 | + int32_t amplitude; |
| 138 | + recoderServer->GetMaxAmplitude(amplitude); | ||
| 138 | recoderServer->Start(); | 139 | recoderServer->Start(); |
| 139 | recoderServer->Pause(); | 140 | recoderServer->Pause(); |
| 140 | recoderServer->Resume(); | 141 | recoderServer->Resume(); |
| @@ -141,7 +141,8 @@ void RecorderServiceStubFunctionsFuzzer::GetRecorderConfig( | |||
| 141 | std::vector<EncoderCapabilityData> encoderInfo; | 141 | std::vector<EncoderCapabilityData> encoderInfo; |
| 142 | recorderStub->GetAvailableEncoder(encoderInfo); | 142 | recorderStub->GetAvailableEncoder(encoderInfo); |
| 143 | 143 | ||
| 144 | - recorderStub->GetMaxAmplitude(); | 144 | + int32_t amplitude; |
| 145 | + recorderStub->GetMaxAmplitude(amplitude); | ||
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | bool RecorderServiceStubFunctionsFuzzer::FuzzRecorderServiceStubFunctions(uint8_t *data, size_t size) | 148 | bool RecorderServiceStubFunctionsFuzzer::FuzzRecorderServiceStubFunctions(uint8_t *data, size_t size) |
| @@ -57,6 +57,7 @@ bool RecorderSetCaptureRateFouncFuzzer::FuzzRecorderSetCaptureRate(uint8_t *data | |||
| 57 | bool enableBFrame = GetData<bool>(); | 57 | bool enableBFrame = GetData<bool>(); |
| 58 | bool isWatermark = GetData<bool>(); | 58 | bool isWatermark = GetData<bool>(); |
| 59 | bool whenInterrupted = GetData<bool>(); | 59 | bool whenInterrupted = GetData<bool>(); |
| 60 | + int32_t amplitude; | ||
| 60 | TestRecorder::SetVideoIsHdr(g_videoRecorderConfig.audioSourceId, isHdr); | 61 | TestRecorder::SetVideoIsHdr(g_videoRecorderConfig.audioSourceId, isHdr); |
| 61 | TestRecorder::SetVideoEnableTemporalScale(g_videoRecorderConfig.audioSourceId, temporalScale); | 62 | TestRecorder::SetVideoEnableTemporalScale(g_videoRecorderConfig.audioSourceId, temporalScale); |
| 62 | TestRecorder::SetVideoEnableStableQualityMode(g_videoRecorderConfig.audioSourceId, qualityMode); | 63 | TestRecorder::SetVideoEnableStableQualityMode(g_videoRecorderConfig.audioSourceId, qualityMode); |
| @@ -64,7 +65,7 @@ bool RecorderSetCaptureRateFouncFuzzer::FuzzRecorderSetCaptureRate(uint8_t *data | |||
| 64 | 65 | ||
| 65 | TestRecorder::GetMetaSurface(g_videoRecorderConfig.audioSourceId); | 66 | TestRecorder::GetMetaSurface(g_videoRecorderConfig.audioSourceId); |
| 66 | TestRecorder::SetMetaConfigs(g_videoRecorderConfig.audioSourceId); | 67 | TestRecorder::SetMetaConfigs(g_videoRecorderConfig.audioSourceId); |
| 67 | - TestRecorder::GetMaxAmplitude(); | 68 | + TestRecorder::GetMaxAmplitude(amplitude); |
| 68 | TestRecorder::IsWatermarkSupported(isWatermark); | 69 | TestRecorder::IsWatermarkSupported(isWatermark); |
| 69 | TestRecorder::SetWillMuteWhenInterrupted(whenInterrupted); | 70 | TestRecorder::SetWillMuteWhenInterrupted(whenInterrupted); |
| 70 | return true; | 71 | return true; |
| @@ -86,10 +86,11 @@ public: | |||
| 86 | MOCK_METHOD(int32_t, GetLocation, (Location &location), (override)); | 86 | MOCK_METHOD(int32_t, GetLocation, (Location &location), (override)); |
| 87 | MOCK_METHOD(int32_t, GetCurrentCapturerChangeInfo, (AudioRecorderChangeInfo &changeInfo), (override)); | 87 | MOCK_METHOD(int32_t, GetCurrentCapturerChangeInfo, (AudioRecorderChangeInfo &changeInfo), (override)); |
| 88 | MOCK_METHOD(int32_t, GetAvailableEncoder, (std::vector<EncoderCapabilityData> &encoderInfo), (override)); | 88 | MOCK_METHOD(int32_t, GetAvailableEncoder, (std::vector<EncoderCapabilityData> &encoderInfo), (override)); |
| 89 | - MOCK_METHOD(int32_t, GetMaxAmplitude, (), (override)); | 89 | + MOCK_METHOD(int32_t, GetMaxAmplitude, (int32_t &litude), (override)); |
| 90 | MOCK_METHOD(int32_t, IsWatermarkSupported, (bool &isWatermarkSupported), (override)); | 90 | MOCK_METHOD(int32_t, IsWatermarkSupported, (bool &isWatermarkSupported), (override)); |
| 91 | MOCK_METHOD(int32_t, SetWatermark, (std::shared_ptr<AVBuffer> &waterMarkBuffer), (override)); | 91 | MOCK_METHOD(int32_t, SetWatermark, (std::shared_ptr<AVBuffer> &waterMarkBuffer), (override)); |
| 92 | MOCK_METHOD(int32_t, SetUserMeta, (const std::shared_ptr<Meta> &userMeta), (override)); | 92 | MOCK_METHOD(int32_t, SetUserMeta, (const std::shared_ptr<Meta> &userMeta), (override)); |
| 93 | + MOCK_METHOD(int32_t, SetCustomInfo, (const std::shared_ptr<Meta> &customInfo), (override)); | ||
| 93 | MOCK_METHOD(int32_t, SetWillMuteWhenInterrupted, (bool muteWhenInterrupted), (override)); | 94 | MOCK_METHOD(int32_t, SetWillMuteWhenInterrupted, (bool muteWhenInterrupted), (override)); |
| 94 | MOCK_METHOD(int32_t, TransmitQos, (QOS::QosLevel level), (override)); | 95 | MOCK_METHOD(int32_t, TransmitQos, (QOS::QosLevel level), (override)); |
| 95 | MOCK_METHOD(int32_t, DoIpcAbnormality, (), (override)); | 96 | MOCK_METHOD(int32_t, DoIpcAbnormality, (), (override)); |
| @@ -81,6 +81,7 @@ ohos_unittest("recorder_native_unit_test") { | |||
| 81 | "player_framework:media_client", | 81 | "player_framework:media_client", |
| 82 | "resource_management:librawfile", | 82 | "resource_management:librawfile", |
| 83 | "window_manager:libdm", | 83 | "window_manager:libdm", |
| 84 | + "media_foundation:native_media_core", | ||
| 84 | ] | 85 | ] |
| 85 | 86 | ||
| 86 | if (player_framework_support_auto_create_file) { | 87 | if (player_framework_support_auto_create_file) { |
| @@ -903,6 +903,81 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_GetAVRecorderConfig_003, TestSize.Leve | |||
| 903 | MEDIA_LOGI("NativeRecorderUnitTest Recorder_GetAVRecorderConfig_003 out."); | 903 | MEDIA_LOGI("NativeRecorderUnitTest Recorder_GetAVRecorderConfig_003 out."); |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | +/** | ||
| 907 | + * @tc.name: Recorder_GetAudioCapturerMaxAmplitude_001 | ||
| 908 | + * @tc.desc: Test recorder GetAudioCapturerMaxAmplitude process 001 | ||
| 909 | + * @tc.type: FUNC | ||
| 910 | + */ | ||
| 911 | +HWTEST_F(NativeRecorderUnitTest, Recorder_GetAudioCapturerMaxAmplitude_001, TestSize.Level2) | ||
| 912 | +{ | ||
| 913 | + MEDIA_LOGI("NativeRecorderUnitTest Recorder_GetAudioCapturerMaxAmplitude_001 in."); | ||
| 914 | + | ||
| 915 | + OH_AVRecorder_Config config = config_; | ||
| 916 | + config.metadata.genre = strdup(""); | ||
| 917 | + config.metadata.videoOrientation = strdup("0"); | ||
| 918 | + config.metadata.customInfo.key = strdup(""); | ||
| 919 | + config.metadata.customInfo.value = strdup(""); | ||
| 920 | + | ||
| 921 | + int32_t outputFd = open((RECORDER_ROOT + "Recorder_GetAudioCapturerMaxAmplitude_001.mp4").c_str(), O_RDWR); | ||
| 922 | + const std::string fdHead = "fd://"; | ||
| 923 | + config.url = strdup((fdHead + std::to_string(outputFd)).c_str()); | ||
| 924 | + | ||
| 925 | + int32_t ret = AV_ERR_OK; | ||
| 926 | + ret = OH_AVRecorder_Prepare(recorder_, &config); | ||
| 927 | + EXPECT_EQ(ret, AV_ERR_OK); | ||
| 928 | + | ||
| 929 | + int32_t amplitude = 0; | ||
| 930 | + ret = OH_AVRecorder_GetAudioCapturerMaxAmplitude(recorder_, &litude); | ||
| 931 | + EXPECT_EQ(ret, AV_ERR_OK); | ||
| 932 | + | ||
| 933 | + free(config.url); | ||
| 934 | + free(config.metadata.genre); | ||
| 935 | + free(config.metadata.videoOrientation); | ||
| 936 | + free(config.metadata.customInfo.key); | ||
| 937 | + free(config.metadata.customInfo.value); | ||
| 938 | + | ||
| 939 | + MEDIA_LOGI("NativeRecorderUnitTest Recorder_GetAudioCapturerMaxAmplitude_001 out."); | ||
| 940 | +} | ||
| 941 | + | ||
| 942 | +/** | ||
| 943 | + * @tc.name: Recorder_SetCustomInfo_001 | ||
| 944 | + * @tc.desc: Test recorder SetCustomInfo process 001 | ||
| 945 | + * @tc.type: FUNC | ||
| 946 | + */ | ||
| 947 | +HWTEST_F(NativeRecorderUnitTest, Recorder_SetCustomInfo_001, TestSize.Level2) | ||
| 948 | +{ | ||
| 949 | + MEDIA_LOGI("NativeRecorderUnitTest Recorder_SetCustomInfo_001 in."); | ||
| 950 | + | ||
| 951 | + OH_AVRecorder_Config config = config_; | ||
| 952 | + config.metadata.genre = strdup(""); | ||
| 953 | + config.metadata.videoOrientation = strdup("0"); | ||
| 954 | + config.metadata.customInfo.key = strdup(""); | ||
| 955 | + config.metadata.customInfo.value = strdup(""); | ||
| 956 | + | ||
| 957 | + int32_t outputFd = open((RECORDER_ROOT + "Recorder_SetCustomInfo_001.mp4").c_str(), O_RDWR); | ||
| 958 | + const std::string fdHead = "fd://"; | ||
| 959 | + config.url = strdup((fdHead + std::to_string(outputFd)).c_str()); | ||
| 960 | + | ||
| 961 | + int32_t ret = AV_ERR_OK; | ||
| 962 | + ret = OH_AVRecorder_Prepare(recorder_, &config); | ||
| 963 | + EXPECT_EQ(ret, AV_ERR_OK); | ||
| 964 | + | ||
| 965 | + OH_AVFormat *customInfo = OH_AVFormat_Create(); | ||
| 966 | + OH_AVFormat_SetStringValue(customInfo, "com.openharmony.test", "Recorder_SetCustomInfo_001"); | ||
| 967 | + ret = OH_AVRecorder_SetCustomInfo(recorder_, customInfo); | ||
| 968 | + EXPECT_EQ(ret, AV_ERR_OK); | ||
| 969 | + | ||
| 970 | + OH_AVFormat_Destroy(customInfo); | ||
| 971 | + | ||
| 972 | + free(config.url); | ||
| 973 | + free(config.metadata.genre); | ||
| 974 | + free(config.metadata.videoOrientation); | ||
| 975 | + free(config.metadata.customInfo.key); | ||
| 976 | + free(config.metadata.customInfo.value); | ||
| 977 | + | ||
| 978 | + MEDIA_LOGI("NativeRecorderUnitTest Recorder_SetCustomInfo_001 out."); | ||
| 979 | +} | ||
| 980 | + | ||
| 906 | /** | 981 | /** |
| 907 | * @tc.name: Recorder_GetInputSurface_001 | 982 | * @tc.name: Recorder_GetInputSurface_001 |
| 908 | * @tc.desc: Test recorder GetInputSurface process 001 | 983 | * @tc.desc: Test recorder GetInputSurface process 001 |
| @@ -209,6 +209,8 @@ | |||
| 209 | <option name="shell" value="touch /data/test/media/Recorder_Prepare_003.mp4"/> | 209 | <option name="shell" value="touch /data/test/media/Recorder_Prepare_003.mp4"/> |
| 210 | <option name="shell" value="touch /data/test/media/Recorder_GetAVRecorderConfig_002.mp4"/> | 210 | <option name="shell" value="touch /data/test/media/Recorder_GetAVRecorderConfig_002.mp4"/> |
| 211 | <option name="shell" value="touch /data/test/media/Recorder_GetAVRecorderConfig_003.mp4"/> | 211 | <option name="shell" value="touch /data/test/media/Recorder_GetAVRecorderConfig_003.mp4"/> |
| 212 | + <option name="shell" value="touch /data/test/media/Recorder_GetAudioCapturerMaxAmplitude_001.mp4"/> | ||
| 213 | + <option name="shell" value="touch /data/test/media/Recorder_SetCustomInfo_001.mp4"/> | ||
| 212 | <option name="shell" value="touch /data/test/media/Recorder_GetInputSurface_002.mp4"/> | 214 | <option name="shell" value="touch /data/test/media/Recorder_GetInputSurface_002.mp4"/> |
| 213 | <option name="shell" value="touch /data/test/media/Recorder_UpdateRotation_002.mp4"/> | 215 | <option name="shell" value="touch /data/test/media/Recorder_UpdateRotation_002.mp4"/> |
| 214 | <option name="shell" value="touch /data/test/media/Recorder_Start_002.mp4"/> | 216 | <option name="shell" value="touch /data/test/media/Recorder_Start_002.mp4"/> |