已合并
【录制框架】AVRecorder补充NDK接口 #7580
刘祥创建于 3月20日
【录制框架】AVRecorder补充NDK接口 #7580
已合并
共 24 个文件变更+48-204
| @@ -92,7 +92,6 @@ 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), | ||
| 96 | DECLARE_NAPI_FUNCTION("isWatermarkSupported", JsIsWatermarkSupported), | 95 | DECLARE_NAPI_FUNCTION("isWatermarkSupported", JsIsWatermarkSupported), |
| 97 | DECLARE_NAPI_FUNCTION("setWillMuteWhenInterrupted", JsSetWillMuteWhenInterrupted), | 96 | DECLARE_NAPI_FUNCTION("setWillMuteWhenInterrupted", JsSetWillMuteWhenInterrupted), |
| 98 | 97 | ||
| @@ -418,48 +417,6 @@ napi_value AVRecorderNapi::JsSetMetadata(napi_env env, napi_callback_info info) | |||
| 418 | napi_value result = nullptr; | 417 | napi_value result = nullptr; |
| 419 | napi_get_undefined(env, &result); | 418 | napi_get_undefined(env, &result); |
| 420 | 419 | ||
| 421 | - AVRecorderNapi *jsRecorder = AVRecorderNapi::GetJsInstanceAndArgs(env, info, argCount, args); | ||
| 422 | - CHECK_AND_RETURN_RET_LOG(jsRecorder != nullptr, result, "failed to GetJsInstanceAndArgs"); | ||
| 423 | - | ||
| 424 | - uint64_t accessTokenIDEx = IPCSkeleton::GetCallingFullTokenID(); | ||
| 425 | - bool isSystemApp = Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIDEx); | ||
| 426 | - if (!isSystemApp) { | ||
| 427 | - jsRecorder->ErrorCallback(MSERR_EXT_API9_PERMISSION_DENIED, "JsSetMetadata", "not system app"); | ||
| 428 | - return result; | ||
| 429 | - } | ||
| 430 | - | ||
| 431 | - CHECK_AND_RETURN_RET_LOG(jsRecorder->taskQue_ != nullptr, result, "taskQue is nullptr!"); | ||
| 432 | - CHECK_AND_RETURN_RET_LOG(jsRecorder->CheckStateMachine(opt) == MSERR_OK, result, "on error state"); | ||
| 433 | - CHECK_AND_RETURN_RET_LOG(jsRecorder->CheckRepeatOperation(opt) == MSERR_OK, result, "on error Operation"); | ||
| 434 | - | ||
| 435 | - std::map<std::string, std::string> recordMeta; | ||
| 436 | - CommonNapi::GetPropertyMap(env, args[0], recordMeta); | ||
| 437 | - CHECK_AND_RETURN_RET_LOG(recordMeta.size() != 0, result, "recordMeta has no data"); | ||
| 438 | - | ||
| 439 | - auto task = std::make_shared<TaskHandler<void>>([jsRecorder, recordMeta]() { | ||
| 440 | - if (jsRecorder != nullptr) { | ||
| 441 | - (void)jsRecorder->SetMetadata(recordMeta); | ||
| 442 | - } | ||
| 443 | - }); | ||
| 444 | - (void)jsRecorder->taskQue_->EnqueueTask(task); | ||
| 445 | - | ||
| 446 | - MEDIA_LOGI("Js %{public}s End", opt.c_str()); | ||
| 447 | - return result; | ||
| 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); | 420 | auto asyncCtx = std::make_unique<AVRecorderAsyncContext>(env); |
| 464 | CHECK_AND_RETURN_RET_LOG(asyncCtx != nullptr, result, "failed to get AsyncContext"); | 421 | CHECK_AND_RETURN_RET_LOG(asyncCtx != nullptr, result, "failed to get AsyncContext"); |
| 465 | AVRecorderNapi *jsRecorder = AVRecorderNapi::GetJsInstanceAndArgs(env, info, argCount, args); | 422 | AVRecorderNapi *jsRecorder = AVRecorderNapi::GetJsInstanceAndArgs(env, info, argCount, args); |
| @@ -472,9 +429,9 @@ napi_value AVRecorderNapi::JsSetCustomInfo(napi_env env, napi_callback_info info | |||
| 472 | CHECK_AND_RETURN_RET_LOG(recordMeta.size() != 0, result, "recordMeta has no data"); | 429 | CHECK_AND_RETURN_RET_LOG(recordMeta.size() != 0, result, "recordMeta has no data"); |
| 473 | 430 | ||
| 474 | asyncCtx->task_ = std::make_shared<TaskHandler<RetInfo>>([jsRecorder, recordMeta]() { | 431 | asyncCtx->task_ = std::make_shared<TaskHandler<RetInfo>>([jsRecorder, recordMeta]() { |
| 475 | - int32_t ret = jsRecorder->SetCustomInfo(recordMeta); | 432 | + int32_t ret = jsRecorder->SetMetadata(recordMeta); |
| 476 | - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(ret, "SetCustomInfoTask", ""), | 433 | + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, GetRetInfo(ret, "SetMetadataTask", ""), |
| 477 | - "SetCustomInfoTask failed"); | 434 | + "SetMetadataTask failed"); |
| 478 | return RetInfo(MSERR_EXT_API9_OK, ""); | 435 | return RetInfo(MSERR_EXT_API9_OK, ""); |
| 479 | }); | 436 | }); |
| 480 | (void)jsRecorder->taskQue_->EnqueueTask(asyncCtx->task_); | 437 | (void)jsRecorder->taskQue_->EnqueueTask(asyncCtx->task_); |
| @@ -1734,16 +1691,6 @@ int32_t AVRecorderNapi::SetMetadata(const std::map<std::string, std::string> &re | |||
| 1734 | return recorder_->SetUserMeta(userMeta); | 1691 | return recorder_->SetUserMeta(userMeta); |
| 1735 | } | 1692 | } |
| 1736 | 1693 | ||
| 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 | - | ||
| 1747 | int32_t AVRecorderNapi::ConfigAVBufferMeta(std::shared_ptr<PixelMap> &pixelMap, | 1694 | int32_t AVRecorderNapi::ConfigAVBufferMeta(std::shared_ptr<PixelMap> &pixelMap, |
| 1748 | std::shared_ptr<WatermarkConfig> &watermarkConfig, std::shared_ptr<Meta> &meta) | 1695 | std::shared_ptr<WatermarkConfig> &watermarkConfig, std::shared_ptr<Meta> &meta) |
| 1749 | { | 1696 | { |
| @@ -60,7 +60,6 @@ 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"; | ||
| 64 | const std::string SET_WILL_MUTE_WHEN_INTERRUPTED = "SetWillMuteWhenInterrupted"; | 63 | const std::string SET_WILL_MUTE_WHEN_INTERRUPTED = "SetWillMuteWhenInterrupted"; |
| 65 | } | 64 | } |
| 66 | 65 | ||
| @@ -96,7 +95,6 @@ const std::map<std::string, std::vector<std::string>> stateCtrlList = { | |||
| 96 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, | 95 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, |
| 97 | AVRecordergOpt::SET_WATERMARK, | 96 | AVRecordergOpt::SET_WATERMARK, |
| 98 | AVRecordergOpt::SET_METADATA, | 97 | AVRecordergOpt::SET_METADATA, |
| 99 | - AVRecordergOpt::SET_CUSTOM_INFO, | ||
| 100 | }}, | 98 | }}, |
| 101 | {AVRecorderState::STATE_STARTED, { | 99 | {AVRecorderState::STATE_STARTED, { |
| 102 | AVRecordergOpt::START, | 100 | AVRecordergOpt::START, |
| @@ -111,7 +109,6 @@ const std::map<std::string, std::vector<std::string>> stateCtrlList = { | |||
| 111 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, | 109 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, |
| 112 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, | 110 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, |
| 113 | AVRecordergOpt::SET_METADATA, | 111 | AVRecordergOpt::SET_METADATA, |
| 114 | - AVRecordergOpt::SET_CUSTOM_INFO, | ||
| 115 | }}, | 112 | }}, |
| 116 | {AVRecorderState::STATE_PAUSED, { | 113 | {AVRecorderState::STATE_PAUSED, { |
| 117 | AVRecordergOpt::PAUSE, | 114 | AVRecordergOpt::PAUSE, |
| @@ -125,7 +122,6 @@ const std::map<std::string, std::vector<std::string>> stateCtrlList = { | |||
| 125 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, | 122 | AVRecordergOpt::GET_AV_RECORDER_CONFIG, |
| 126 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, | 123 | AVRecordergOpt::IS_WATERMARK_SUPPORTED, |
| 127 | AVRecordergOpt::SET_METADATA, | 124 | AVRecordergOpt::SET_METADATA, |
| 128 | - AVRecordergOpt::SET_CUSTOM_INFO, | ||
| 129 | }}, | 125 | }}, |
| 130 | {AVRecorderState::STATE_STOPPED, { | 126 | {AVRecorderState::STATE_STOPPED, { |
| 131 | AVRecordergOpt::STOP, | 127 | AVRecordergOpt::STOP, |
| @@ -233,10 +229,6 @@ private: | |||
| 233 | * setMetadata(metadata: Record<string, string>): void; | 229 | * setMetadata(metadata: Record<string, string>): void; |
| 234 | */ | 230 | */ |
| 235 | static napi_value JsSetMetadata(napi_env env, napi_callback_info info); | 231 | 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); | ||
| 240 | /** | 232 | /** |
| 241 | * getInputSurface(callback: AsyncCallback<string>): void | 233 | * getInputSurface(callback: AsyncCallback<string>): void |
| 242 | * getInputSurface(): Promise<string> | 234 | * getInputSurface(): Promise<string> |
| @@ -394,7 +386,6 @@ private: | |||
| 394 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); | 386 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); |
| 395 | int32_t SetWatermark(std::shared_ptr<PixelMap> &pixelMap, std::shared_ptr<WatermarkConfig> &watermarkConfig); | 387 | int32_t SetWatermark(std::shared_ptr<PixelMap> &pixelMap, std::shared_ptr<WatermarkConfig> &watermarkConfig); |
| 396 | int32_t SetMetadata(const std::map<std::string, std::string> &recordMeta); | 388 | int32_t SetMetadata(const std::map<std::string, std::string> &recordMeta); |
| 397 | - int32_t SetCustomInfo(const std::map<std::string, std::string> &recordMeta); | ||
| 398 | 389 | ||
| 399 | void ErrorCallback(int32_t errCode, const std::string &operate, const std::string &add = ""); | 390 | void ErrorCallback(int32_t errCode, const std::string &operate, const std::string &add = ""); |
| 400 | void StateCallback(const std::string &state); | 391 | void StateCallback(const std::string &state); |
| @@ -617,25 +617,25 @@ OH_AVErrCode OH_AVRecorder_GetAudioCapturerMaxAmplitude(OH_AVRecorder *recorder, | |||
| 617 | return AV_ERR_OK; | 617 | return AV_ERR_OK; |
| 618 | } | 618 | } |
| 619 | 619 | ||
| 620 | -OH_AVErrCode OH_AVRecorder_SetCustomInfo(OH_AVRecorder *recorder, OH_AVFormat *customInfo) | 620 | +OH_AVErrCode OH_AVRecorder_SetMetadata(OH_AVRecorder *recorder, OH_AVFormat *metadata) |
| 621 | { | 621 | { |
| 622 | - MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_SetCustomInfo in."); | 622 | + MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_SetMetadata in."); |
| 623 | CHECK_AND_RETURN_RET_LOG(recorder != nullptr, AV_ERR_INVALID_VAL, "input recorder is nullptr!"); | 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!"); | 624 | + CHECK_AND_RETURN_RET_LOG(metadata != nullptr, AV_ERR_INVALID_VAL, "input metadata is nullptr!"); |
| 625 | 625 | ||
| 626 | struct RecorderObject *recorderObj = reinterpret_cast<RecorderObject *>(recorder); | 626 | struct RecorderObject *recorderObj = reinterpret_cast<RecorderObject *>(recorder); |
| 627 | CHECK_AND_RETURN_RET_LOG(recorderObj != nullptr, AV_ERR_INVALID_VAL, "recorderObj is nullptr"); | 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"); | 628 | CHECK_AND_RETURN_RET_LOG(recorderObj->recorder_ != nullptr, AV_ERR_INVALID_VAL, "recorder_ is null"); |
| 629 | 629 | ||
| 630 | - std::shared_ptr<Meta> meta = customInfo->format_.GetMeta(); | 630 | + std::shared_ptr<Meta> meta = metadata->format_.GetMeta(); |
| 631 | - int32_t ret = recorderObj->recorder_->SetCustomInfo(meta); | 631 | + int32_t ret = recorderObj->recorder_->SetUserMeta(meta); |
| 632 | 632 | ||
| 633 | CHECK_AND_RETURN_RET_LOG(ret != MSERR_INVALID_STATE, AV_ERR_INVALID_STATE, "Invalid state"); | 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"); | 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"); | 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!"); | 636 | + CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_UNKNOWN, "SetMetadata failed!"); |
| 637 | 637 | ||
| 638 | - MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_SetCustomInfo out."); | 638 | + MEDIA_LOGD("Native AVRecorder: OH_AVRecorder_SetMetadata out."); |
| 639 | return AV_ERR_OK; | 639 | return AV_ERR_OK; |
| 640 | } | 640 | } |
| 641 | 641 | ||
| @@ -272,6 +272,7 @@ const std::map<MediaServiceErrCode, MediaServiceExtErrCodeAPI9> MSERRCODE_TO_EXT | |||
| 272 | {MSERR_RS_DATA_FALLBACK_FAILED, MSERR_EXT_API20_HARDWARE_FAILED}, | 272 | {MSERR_RS_DATA_FALLBACK_FAILED, MSERR_EXT_API20_HARDWARE_FAILED}, |
| 273 | {MSERR_LPP_INSTANCE_EXCEED_LIMIT, MSERR_EXT_API20_HARDWARE_FAILED}, | 273 | {MSERR_LPP_INSTANCE_EXCEED_LIMIT, MSERR_EXT_API20_HARDWARE_FAILED}, |
| 274 | {MSERR_HARDWARE_ERROR, MSERR_EXT_API20_HARDWARE_FAILED}, | 274 | {MSERR_HARDWARE_ERROR, MSERR_EXT_API20_HARDWARE_FAILED}, |
| 275 | + {MSERR_PARAM_OUT_OF_RANGE, MSERR_EXT_API20_PARAM_ERROR_OUT_OF_RANGE}, | ||
| 275 | }; | 276 | }; |
| 276 | 277 | ||
| 277 | const std::map<MediaServiceExtErrCodeAPI9, std::string> MSEXTERRCODE_API9_INFOS = { | 278 | const std::map<MediaServiceExtErrCodeAPI9, std::string> MSEXTERRCODE_API9_INFOS = { |
| @@ -438,12 +438,6 @@ 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 | - | ||
| 447 | int32_t RecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 441 | int32_t RecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 448 | { | 442 | { |
| 449 | CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); | 443 | CHECK_AND_RETURN_RET_LOG(recorderService_ != nullptr, MSERR_INVALID_OPERATION, "recorder service does not exist."); |
| @@ -79,7 +79,6 @@ public: | |||
| 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; | ||
| 83 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 82 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 84 | private: | 83 | private: |
| 85 | std::shared_ptr<IRecorderService> recorderService_ = nullptr; | 84 | std::shared_ptr<IRecorderService> recorderService_ = nullptr; |
| @@ -996,16 +996,6 @@ public: | |||
| 996 | */ | 996 | */ |
| 997 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; | 997 | virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; |
| 998 | 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 | - | ||
| 1009 | /** @brief set interrupt mode to avrecorder. | 999 | /** @brief set interrupt mode to avrecorder. |
| 1010 | * | 1000 | * |
| 1011 | * @param muteWhenInterrupted muteWhenInterrupted true or false. | 1001 | * @param muteWhenInterrupted muteWhenInterrupted true or false. |
| @@ -102,28 +102,36 @@ OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig(OH_AVRecorder *recorder, OH_AVRec | |||
| 102 | * @param amplitude - The max amplitude value of audio capturer | 102 | * @param amplitude - The max amplitude value of audio capturer |
| 103 | * @return Function result code. | 103 | * @return Function result code. |
| 104 | * {@link AV_ERR_OK} if the execution is successful. | 104 | * {@link AV_ERR_OK} if the execution is successful. |
| 105 | - * {@link AV_ERR_INVALID_VAL} if input recorder is nullptr. | 105 | + * {@link AV_ERR_INVALID_VAL} if input recorder is nullptr or amplitude is nullptr. |
| 106 | - * {@link AV_ERR_INVALID_STATE} function called in invalid state, only available after prepare state, | 106 | + * {@link AV_ERR_INVALID_STATE} function called in invalid state. |
| 107 | - * and before stop state. | 107 | + * {@link AV_ERR_NO_MEMORY} failed to malloc memory. |
| 108 | + * {@link AV_ERR_UNKNOWN} unknown error. | ||
| 109 | + * | ||
| 108 | * @since 26.0.0 | 110 | * @since 26.0.0 |
| 109 | */ | 111 | */ |
| 110 | -OH_AVErrCode OH_AVRecorder_GetAudioCapturerMaxAmplitude(OH_AVRecorder *recorder, int32_t* amplitude); | 112 | +OH_AVErrCode OH_AVRecorder_GetAudioCapturerMaxAmplitude(OH_AVRecorder *recorder, int32_t *amplitude); |
| 111 | 113 | ||
| 112 | /** | 114 | /** |
| 113 | - * @brief Set custom info (key value pairs) for the recording file of the recorder. | 115 | + * @brief Set metadata (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}) | 116 | + * This metadata overwrites the value in config.metadata.customInfo (see {prepare()} and {OH_AVRecorder_Config}) |
| 115 | * if they have same key. | 117 | * if they have same key. |
| 116 | - * This API can be called only after the **prepare()** API is called, before starting recoder. | 118 | + * This API can be called only after the **prepare()** API is called, before stop recorder. |
| 117 | * | 119 | * |
| 118 | * @param recorder - Pointer to an OH_AVRecorder instance | 120 | * @param recorder - Pointer to an OH_AVRecorder instance |
| 119 | - * @param customInfo - The key value pairs added to the the recording file. | 121 | + * @param metadata - The key-value pairs added to the the recording file. |
| 122 | + * The key string should start with "com.openharmony.". | ||
| 123 | + * The length of value can't be more than 256 bytes. | ||
| 120 | * @return Function result code. | 124 | * @return Function result code. |
| 121 | * {@link AV_ERR_OK} if the execution is successful. | 125 | * {@link AV_ERR_OK} if the execution is successful. |
| 122 | - * {@link AV_ERR_INVALID_VAL} if input recorder is nullptr or customInfo is nullptr. | 126 | + * {@link AV_ERR_INVALID_VAL} if input recorder is nullptr or metadata is nullptr |
| 123 | - * {@link AV_ERR_INVALID_STATE} function called in invalid state (only available in prepared state) | 127 | + * or the length of value exceed max length. |
| 128 | + * {@link AV_ERR_INVALID_STATE} function called in invalid state. | ||
| 129 | + * {@link AV_ERR_NO_MEMORY} failed to malloc memory. | ||
| 130 | + * {@link AV_ERR_UNKNOWN} unknown error. | ||
| 131 | + * | ||
| 124 | * @since 26.0.0 | 132 | * @since 26.0.0 |
| 125 | */ | 133 | */ |
| 126 | -OH_AVErrCode OH_AVRecorder_SetCustomInfo(OH_AVRecorder *recorder, OH_AVFormat *customInfo); | 134 | +OH_AVErrCode OH_AVRecorder_SetMetadata(OH_AVRecorder *recorder, OH_AVFormat *metadata); |
| 127 | 135 | ||
| 128 | /** | 136 | /** |
| 129 | * @brief Get input surface, it must be called between prepare completed and start. | 137 | * @brief Get input surface, it must be called between prepare completed and start. |
| @@ -1250,19 +1250,11 @@ int32_t HiRecorderImpl::SetWatermark(std::shared_ptr<AVBuffer> &waterMarkBuffer) | |||
| 1250 | return static_cast<int32_t>(videoEncoderFilter_->SetWatermark(waterMarkBuffer)); | 1250 | return static_cast<int32_t>(videoEncoderFilter_->SetWatermark(waterMarkBuffer)); |
| 1251 | } | 1251 | } |
| 1252 | 1252 | ||
| 1253 | -int32_t HiRecorderImpl::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | 1253 | +Status HiRecorderImpl::SetUserMeta(const std::shared_ptr<Meta> &usermeta) |
| 1254 | -{ | ||
| 1255 | - FALSE_RETURN_V_MSG_E(muxerFilter_ != nullptr, static_cast<int32_t>(Status::ERROR_NULL_POINTER), | ||
| 1256 | - "muxerFilter is nullptr, cannot set usermeta"); | ||
| 1257 | - muxerFilter_->SetUserMeta(userMeta); | ||
| 1258 | - return static_cast<int32_t>(Status::OK); | ||
| 1259 | -} | ||
| 1260 | - | ||
| 1261 | -Status HiRecorderImpl::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 1262 | { | 1254 | { |
| 1263 | FALSE_RETURN_V_MSG_E(muxerFilter_ != nullptr, Status::ERROR_NULL_POINTER, | 1255 | FALSE_RETURN_V_MSG_E(muxerFilter_ != nullptr, Status::ERROR_NULL_POINTER, |
| 1264 | - "muxerFilter is nullptr, cannot set customInfo"); | 1256 | + "muxerFilter is nullptr, cannot set usermeta"); |
| 1265 | - return muxerFilter_->SetCustomInfo(customInfo); | 1257 | + return muxerFilter_->SetUserMeta(usermeta); |
| 1266 | } | 1258 | } |
| 1267 | 1259 | ||
| 1268 | int32_t HiRecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 1260 | int32_t HiRecorderImpl::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| @@ -83,8 +83,7 @@ public: | |||
| 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 | + Status SetUserMeta(const std::shared_ptr<Meta> &userMeta); |
| 87 | - Status SetCustomInfo(const std::shared_ptr<Meta> &customInfo); | ||
| 88 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); | 87 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted); |
| 89 | 88 | ||
| 90 | private: | 89 | private: |
| @@ -640,7 +640,6 @@ 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; | ||
| 644 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; | 643 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; |
| 645 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; | 644 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; |
| 646 | }; | 645 | }; |
| @@ -224,11 +224,7 @@ public: | |||
| 224 | /** | 224 | /** |
| 225 | * Set user meta | 225 | * Set user meta |
| 226 | */ | 226 | */ |
| 227 | - virtual int32_t SetUserMeta(const std::shared_ptr<Meta> &userMeta) = 0; | 227 | + virtual Status 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; | ||
| 232 | 228 | ||
| 233 | /** | 229 | /** |
| 234 | * Set Interrupt strategy | 230 | * Set Interrupt strategy |
| @@ -571,15 +571,6 @@ 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 | - | ||
| 583 | int32_t RecorderClient::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 574 | int32_t RecorderClient::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 584 | { | 575 | { |
| 585 | std::lock_guard<std::mutex> lock(mutex_); | 576 | std::lock_guard<std::mutex> lock(mutex_); |
| @@ -82,7 +82,6 @@ public: | |||
| 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; | ||
| 86 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 85 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 87 | int32_t TransmitQos(QOS::QosLevel level) override; | 86 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 88 | // RecorderClient | 87 | // RecorderClient |
| @@ -99,7 +99,6 @@ public: | |||
| 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; | ||
| 103 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; | 102 | virtual int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) = 0; |
| 104 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; | 103 | virtual int32_t TransmitQos(QOS::QosLevel level) = 0; |
| 105 | /** | 104 | /** |
| @@ -160,7 +159,6 @@ public: | |||
| 160 | SET_INTERRUPT_STRATEGY, | 159 | SET_INTERRUPT_STRATEGY, |
| 161 | TRANSMIT_QOS, | 160 | TRANSMIT_QOS, |
| 162 | SET_AUDIO_AACPROFILE, | 161 | SET_AUDIO_AACPROFILE, |
| 163 | - SET_CUSTOMINFO, | ||
| 164 | }; | 162 | }; |
| 165 | 163 | ||
| 166 | DECLARE_INTERFACE_DESCRIPTOR(u"IStandardRecorderService"); | 164 | DECLARE_INTERFACE_DESCRIPTOR(u"IStandardRecorderService"); |
| @@ -1025,25 +1025,6 @@ 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 | - | ||
| 1047 | int32_t RecorderServiceProxy::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) | 1028 | int32_t RecorderServiceProxy::SetWillMuteWhenInterrupted(bool muteWhenInterrupted) |
| 1048 | { | 1029 | { |
| 1049 | MessageParcel data; | 1030 | MessageParcel data; |
| @@ -78,7 +78,6 @@ public: | |||
| 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; | ||
| 82 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 81 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 83 | int32_t TransmitQos(QOS::QosLevel level) override; | 82 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 84 | private: | 83 | private: |
| @@ -174,8 +174,6 @@ void RecorderServiceStub::FillRecFuncPart3() | |||
| 174 | [this](MessageParcel &data, MessageParcel &reply) { return SetVideoEnableBFrame(data, reply); }; | 174 | [this](MessageParcel &data, MessageParcel &reply) { return SetVideoEnableBFrame(data, reply); }; |
| 175 | recFuncs_[TRANSMIT_QOS] = | 175 | recFuncs_[TRANSMIT_QOS] = |
| 176 | [this](MessageParcel &data, MessageParcel &reply) { return TransmitQos(data, reply); }; | 176 | [this](MessageParcel &data, MessageParcel &reply) { return TransmitQos(data, reply); }; |
| 177 | - recFuncs_[SET_CUSTOMINFO] = | ||
| 178 | - [this](MessageParcel &data, MessageParcel &reply) { return SetCustomInfo(data, reply); }; | ||
| 179 | } | 177 | } |
| 180 | 178 | ||
| 181 | int32_t RecorderServiceStub::DestroyStub() | 179 | int32_t RecorderServiceStub::DestroyStub() |
| @@ -548,12 +546,6 @@ int32_t RecorderServiceStub::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 548 | return recorderServer_->SetUserMeta(userMeta); | 546 | return recorderServer_->SetUserMeta(userMeta); |
| 549 | } | 547 | } |
| 550 | 548 | ||
| 551 | -int32_t RecorderServiceStub::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | ||
| 552 | -{ | ||
| 553 | - CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); | ||
| 554 | - return recorderServer_->SetCustomInfo(customInfo); | ||
| 555 | -} | ||
| 556 | - | ||
| 557 | int32_t RecorderServiceStub::TransmitQos(QOS::QosLevel level) | 549 | int32_t RecorderServiceStub::TransmitQos(QOS::QosLevel level) |
| 558 | { | 550 | { |
| 559 | CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); | 551 | CHECK_AND_RETURN_RET_LOG(recorderServer_ != nullptr, MSERR_NO_MEMORY, "recorder server is nullptr"); |
| @@ -1194,16 +1186,6 @@ int32_t RecorderServiceStub::SetUserMeta(MessageParcel &data, MessageParcel &rep | |||
| 1194 | return MSERR_OK; | 1186 | return MSERR_OK; |
| 1195 | } | 1187 | } |
| 1196 | 1188 | ||
| 1197 | -int32_t RecorderServiceStub::SetCustomInfo(MessageParcel &data, MessageParcel &reply) | ||
| 1198 | -{ | ||
| 1199 | - std::shared_ptr<Meta> customInfo = std::make_shared<Meta>(); | ||
| 1200 | - CHECK_AND_RETURN_RET_LOG(customInfo->FromParcel(data), MSERR_INVALID_OPERATION, | ||
| 1201 | - "read custom info failed"); | ||
| 1202 | - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(SetCustomInfo(customInfo)), MSERR_INVALID_OPERATION, | ||
| 1203 | - "SetCustomInfo reply write failed"); | ||
| 1204 | - return MSERR_OK; | ||
| 1205 | -} | ||
| 1206 | - | ||
| 1207 | int32_t RecorderServiceStub::SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply) | 1189 | int32_t RecorderServiceStub::SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply) |
| 1208 | { | 1190 | { |
| 1209 | bool muteWhenInterrupted = false; | 1191 | bool muteWhenInterrupted = false; |
| @@ -84,7 +84,6 @@ public: | |||
| 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; | ||
| 88 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 87 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 89 | int32_t TransmitQos(QOS::QosLevel level) override; | 88 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 90 | // MonitorServerObject override | 89 | // MonitorServerObject override |
| @@ -142,7 +141,6 @@ private: | |||
| 142 | int32_t IsWatermarkSupported(MessageParcel &data, MessageParcel &reply); | 141 | int32_t IsWatermarkSupported(MessageParcel &data, MessageParcel &reply); |
| 143 | int32_t SetWatermark(MessageParcel &data, MessageParcel &reply); | 142 | int32_t SetWatermark(MessageParcel &data, MessageParcel &reply); |
| 144 | int32_t SetUserMeta(MessageParcel &data, MessageParcel &reply); | 143 | int32_t SetUserMeta(MessageParcel &data, MessageParcel &reply); |
| 145 | - int32_t SetCustomInfo(MessageParcel &data, MessageParcel &reply); | ||
| 146 | int32_t SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply); | 144 | int32_t SetWillMuteWhenInterrupted(MessageParcel &data, MessageParcel &reply); |
| 147 | int32_t TransmitQos(MessageParcel &data, MessageParcel &reply); | 145 | int32_t TransmitQos(MessageParcel &data, MessageParcel &reply); |
| 148 | int32_t CheckPermission(); | 146 | int32_t CheckPermission(); |
| @@ -1210,29 +1210,11 @@ int32_t RecorderServer::SetUserMeta(const std::shared_ptr<Meta> &userMeta) | |||
| 1210 | MEDIA_LOGI("SetUserMeta in"); | 1210 | MEDIA_LOGI("SetUserMeta in"); |
| 1211 | std::lock_guard<std::mutex> lock(mutex_); | 1211 | std::lock_guard<std::mutex> lock(mutex_); |
| 1212 | MediaTrace trace("RecorderServer::SetUserMeta"); | 1212 | MediaTrace trace("RecorderServer::SetUserMeta"); |
| 1213 | - CHECK_STATUS_FAILED_AND_LOGE_RET(status_ != REC_PREPARED && status_ != REC_RECORDING && status_ != REC_PAUSED, | ||
| 1214 | - MSERR_INVALID_OPERATION); | ||
| 1215 | - CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); | ||
| 1216 | - auto task = std::make_shared<TaskHandler<int32_t>>([&, this] { | ||
| 1217 | - return recorderEngine_->SetUserMeta(userMeta); | ||
| 1218 | - }); | ||
| 1219 | - int32_t ret = taskQue_.EnqueueTask(task); | ||
| 1220 | - CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); | ||
| 1221 | - | ||
| 1222 | - auto result = task->GetResult(); | ||
| 1223 | - return result.Value(); | ||
| 1224 | -} | ||
| 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, | 1213 | CHECK_STATUS_FAILED_AND_LOGE_RET(status_ != REC_PREPARED && status_ != REC_RECORDING && status_ != REC_PAUSED, |
| 1232 | MSERR_INVALID_STATE); | 1214 | MSERR_INVALID_STATE); |
| 1233 | CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); | 1215 | CHECK_AND_RETURN_RET_LOG(recorderEngine_ != nullptr, MSERR_NO_MEMORY, "engine is nullptr"); |
| 1234 | auto task = std::make_shared<TaskHandler<Status>>([&, this] { | 1216 | auto task = std::make_shared<TaskHandler<Status>>([&, this] { |
| 1235 | - return recorderEngine_->SetCustomInfo(customInfo); | 1217 | + return recorderEngine_->SetUserMeta(userMeta); |
| 1236 | }); | 1218 | }); |
| 1237 | int32_t ret = taskQue_.EnqueueTask(task); | 1219 | int32_t ret = taskQue_.EnqueueTask(task); |
| 1238 | CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); | 1220 | CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, ret, "EnqueueTask failed"); |
| @@ -1246,7 +1228,7 @@ int32_t RecorderServer::SetCustomInfo(const std::shared_ptr<Meta> &customInfo) | |||
| 1246 | } else if (statusCode == Status::ERROR_WRONG_STATE) { | 1228 | } else if (statusCode == Status::ERROR_WRONG_STATE) { |
| 1247 | result = MSERR_INVALID_STATE; | 1229 | result = MSERR_INVALID_STATE; |
| 1248 | } else if (statusCode == Status::ERROR_INVALID_DATA) { | 1230 | } else if (statusCode == Status::ERROR_INVALID_DATA) { |
| 1249 | - result = MSERR_INVALID_VAL; | 1231 | + result = MSERR_PARAM_OUT_OF_RANGE; |
| 1250 | } else { | 1232 | } else { |
| 1251 | result = MSERR_UNKNOWN; | 1233 | result = MSERR_UNKNOWN; |
| 1252 | } | 1234 | } |
| @@ -124,7 +124,6 @@ public: | |||
| 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; | ||
| 128 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; | 127 | int32_t SetWillMuteWhenInterrupted(bool muteWhenInterrupted) override; |
| 129 | int32_t TransmitQos(QOS::QosLevel level) override; | 128 | int32_t TransmitQos(QOS::QosLevel level) override; |
| 130 | 129 | ||
| @@ -90,7 +90,6 @@ public: | |||
| 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)); | ||
| 94 | MOCK_METHOD(int32_t, SetWillMuteWhenInterrupted, (bool muteWhenInterrupted), (override)); | 93 | MOCK_METHOD(int32_t, SetWillMuteWhenInterrupted, (bool muteWhenInterrupted), (override)); |
| 95 | MOCK_METHOD(int32_t, TransmitQos, (QOS::QosLevel level), (override)); | 94 | MOCK_METHOD(int32_t, TransmitQos, (QOS::QosLevel level), (override)); |
| 96 | MOCK_METHOD(int32_t, DoIpcAbnormality, (), (override)); | 95 | MOCK_METHOD(int32_t, DoIpcAbnormality, (), (override)); |
| @@ -940,13 +940,13 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_GetAudioCapturerMaxAmplitude_001, Test | |||
| 940 | } | 940 | } |
| 941 | 941 | ||
| 942 | /** | 942 | /** |
| 943 | - * @tc.name: Recorder_SetCustomInfo_001 | 943 | + * @tc.name: Recorder_SetMetadata_001 |
| 944 | - * @tc.desc: Test recorder SetCustomInfo process 001 | 944 | + * @tc.desc: Test recorder SetMetadata process 001 |
| 945 | * @tc.type: FUNC | 945 | * @tc.type: FUNC |
| 946 | */ | 946 | */ |
| 947 | -HWTEST_F(NativeRecorderUnitTest, Recorder_SetCustomInfo_001, TestSize.Level2) | 947 | +HWTEST_F(NativeRecorderUnitTest, Recorder_SetMetadata_001, TestSize.Level2) |
| 948 | { | 948 | { |
| 949 | - MEDIA_LOGI("NativeRecorderUnitTest Recorder_SetCustomInfo_001 in."); | 949 | + MEDIA_LOGI("NativeRecorderUnitTest Recorder_SetMetadata_001 in."); |
| 950 | 950 | ||
| 951 | OH_AVRecorder_Config config = config_; | 951 | OH_AVRecorder_Config config = config_; |
| 952 | config.metadata.genre = strdup(""); | 952 | config.metadata.genre = strdup(""); |
| @@ -954,7 +954,7 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_SetCustomInfo_001, TestSize.Level2) | |||
| 954 | config.metadata.customInfo.key = strdup(""); | 954 | config.metadata.customInfo.key = strdup(""); |
| 955 | config.metadata.customInfo.value = strdup(""); | 955 | config.metadata.customInfo.value = strdup(""); |
| 956 | 956 | ||
| 957 | - int32_t outputFd = open((RECORDER_ROOT + "Recorder_SetCustomInfo_001.mp4").c_str(), O_RDWR); | 957 | + int32_t outputFd = open((RECORDER_ROOT + "Recorder_SetMetadata_001.mp4").c_str(), O_RDWR); |
| 958 | const std::string fdHead = "fd://"; | 958 | const std::string fdHead = "fd://"; |
| 959 | config.url = strdup((fdHead + std::to_string(outputFd)).c_str()); | 959 | config.url = strdup((fdHead + std::to_string(outputFd)).c_str()); |
| 960 | 960 | ||
| @@ -962,12 +962,12 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_SetCustomInfo_001, TestSize.Level2) | |||
| 962 | ret = OH_AVRecorder_Prepare(recorder_, &config); | 962 | ret = OH_AVRecorder_Prepare(recorder_, &config); |
| 963 | EXPECT_EQ(ret, AV_ERR_OK); | 963 | EXPECT_EQ(ret, AV_ERR_OK); |
| 964 | 964 | ||
| 965 | - OH_AVFormat *customInfo = OH_AVFormat_Create(); | 965 | + OH_AVFormat *metadata = OH_AVFormat_Create(); |
| 966 | - OH_AVFormat_SetStringValue(customInfo, "com.openharmony.test", "Recorder_SetCustomInfo_001"); | 966 | + OH_AVFormat_SetStringValue(metadata, "com.openharmony.test", "Recorder_SetMetadata_001"); |
| 967 | - ret = OH_AVRecorder_SetCustomInfo(recorder_, customInfo); | 967 | + ret = OH_AVRecorder_SetMetadata(recorder_, metadata); |
| 968 | EXPECT_EQ(ret, AV_ERR_OK); | 968 | EXPECT_EQ(ret, AV_ERR_OK); |
| 969 | 969 | ||
| 970 | - OH_AVFormat_Destroy(customInfo); | 970 | + OH_AVFormat_Destroy(metadata); |
| 971 | 971 | ||
| 972 | free(config.url); | 972 | free(config.url); |
| 973 | free(config.metadata.genre); | 973 | free(config.metadata.genre); |
| @@ -975,7 +975,7 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_SetCustomInfo_001, TestSize.Level2) | |||
| 975 | free(config.metadata.customInfo.key); | 975 | free(config.metadata.customInfo.key); |
| 976 | free(config.metadata.customInfo.value); | 976 | free(config.metadata.customInfo.value); |
| 977 | 977 | ||
| 978 | - MEDIA_LOGI("NativeRecorderUnitTest Recorder_SetCustomInfo_001 out."); | 978 | + MEDIA_LOGI("NativeRecorderUnitTest Recorder_SetMetadata_001 out."); |
| 979 | } | 979 | } |
| 980 | 980 | ||
| 981 | /** | 981 | /** |
| @@ -210,7 +210,7 @@ | |||
| 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"/> | 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"/> | 213 | + <option name="shell" value="touch /data/test/media/Recorder_SetMetadata_001.mp4"/> |
| 214 | <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"/> |
| 215 | <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"/> |
| 216 | <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"/> |