diff --git a/services/services/recorder/server/media_library_adapter.cpp b/services/services/recorder/server/media_library_adapter.cpp index 8d1b8c4ecad1f8f633b187c742f6e6d56473561e..5048f2e1a89127af7d2bb4cb73ec74e523f42511 100644 --- a/services/services/recorder/server/media_library_adapter.cpp +++ b/services/services/recorder/server/media_library_adapter.cpp @@ -205,8 +205,9 @@ bool CreateMediaLibrary(int32_t &fd, std::string &uri) recorderPhotoProxy->SetDisplayName(CreateDisplayName()); photoAssetProxy->AddPhotoProxy((sptr&)recorderPhotoProxy); uri = photoAssetProxy->GetPhotoAssetUri(); - MEDIA_LOGD("video uri:%{public}s", uri.c_str()); + MEDIA_LOGI("video uri:%{public}s", uri.c_str()); fd = mediaLibraryManager->OpenAsset(uri, "rw"); + MEDIA_LOGI("video fd:%{public}d", fd); return true; } } // namespace MeidaLibraryAdapter diff --git a/services/services/recorder/server/recorder_server.cpp b/services/services/recorder/server/recorder_server.cpp index ee0c3d1446c978b1ff02c35774921a3362a849d8..94241a3e688a304ec8589cbcd5074ae867c55dd3 100644 --- a/services/services/recorder/server/recorder_server.cpp +++ b/services/services/recorder/server/recorder_server.cpp @@ -725,7 +725,7 @@ int32_t RecorderServer::SetFileGenerationMode(FileGenerationMode mode) CHECK_AND_RETURN_RET_LOG(config_.withVideo, MSERR_INVALID_OPERATION, "Audio-only scenarios are not supported"); CHECK_AND_RETURN_RET_LOG(MeidaLibraryAdapter::CreateMediaLibrary(config_.url, config_.uri), MSERR_UNKNOWN, "get fd failed"); - MEDIA_LOGD("video Fd:%{public}d", config_.url); + MEDIA_LOGI("video Fd:%{public}d", config_.url); config_.fileGenerationMode = mode; OutFd outFileFd(config_.url); auto task = std::make_shared>([&, this] { diff --git a/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp b/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp index 62077fe86e086702d764ff8a78136ae3a19dbf50..f42ebf0fe8f0097677b72884cf6c8392da855d4c 100644 --- a/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp +++ b/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp @@ -603,6 +603,55 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_Prepare_007, TestSize.Level2) MEDIA_LOGI("NativeRecorderUnitTest Recorder_Prepare_007 out."); } +/** + * @tc.name: Recorder_Prepare_008 + * @tc.desc: Test recorder preparation process success situation + * @tc.type: FUNC + */ +HWTEST_F(NativeRecorderUnitTest, Recorder_Prepare_008, TestSize.Level2) +{ + MEDIA_LOGI("NativeRecorderUnitTest Recorder_Prepare_008 in."); + + OH_AVRecorder_Config config = config_; + config.url = strdup(""); + config.metadata.genre = strdup(""); + config.metadata.videoOrientation = nullptr; + config.metadata.customInfo.key = strdup("abc"); + config.metadata.customInfo.value = strdup("123"); + config.profile.audioBitrate = 96000; + config.profile.audioChannels = 2; + config.profile.audioCodec = OH_AVRecorder_CodecMimeType::AVRECORDER_AUDIO_AAC; + config.profile.audioSampleRate = 48000; + config.profile.fileFormat = OH_AVRecorder_ContainerFormatType::AVRECORDER_CFT_MPEG_4; + config.profile.videoBitrate = 2000000; + config.profile.videoCodec = OH_AVRecorder_CodecMimeType::AVRECORDER_VIDEO_AVC; + config.profile.videoFrameWidth = 1280; + config.profile.videoFrameHeight = 720; + config.profile.videoFrameRate = 30; + config.profile.isHdr = false; + config.profile.enableTemporalScale = false; + config.audioSourceType = OH_AVRecorder_AudioSourceType::AVRECORDER_MIC; + config.videoSourceType = OH_AVRecorder_VideoSourceType::AVRECORDER_SURFACE_YUV; + config.fileGenerationMode = OH_AVRecorder_FileGenerationMode::AVRECORDER_AUTO_CREATE_CAMERA_SCENE; + + int32_t ret = AV_ERR_OK; + ret = OH_AVRecorder_Prepare(recorder_, &config); + + #ifdef SUPPORT_RECORDER_CREATE_FILE + EXPECT_EQ(ret, AV_ERR_OK); + #else + EXPECT_EQ(ret, AV_ERR_INVALID_VAL); + #endif + + free(config.url); + free(config.metadata.genre); + free(config.metadata.videoOrientation); + free(config.metadata.customInfo.key); + free(config.metadata.customInfo.value); + + MEDIA_LOGI("NativeRecorderUnitTest Recorder_Prepare_008 out."); +} + /** * @tc.name: Recorder_Prepare_009 * @tc.desc: Test recorder preparation process success situation 2 @@ -950,6 +999,97 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_UpdateRotation_002, TestSize.Level2) MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_002 out."); } +/** + * @tc.name: Recorder_UpdateRotation_003 + * @tc.desc: Test recorder UpdateRotation process 003 + * @tc.type: FUNC + */ +HWTEST_F(NativeRecorderUnitTest, Recorder_UpdateRotation_003, TestSize.Level2) +{ + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_003 in."); + + OH_AVRecorder_Config config = config_; + config.url = strdup(""); + config.metadata.genre = strdup(""); + config.metadata.videoOrientation = strdup("0"); + config.metadata.customInfo.key = strdup(""); + config.metadata.customInfo.value = strdup(""); + config.fileGenerationMode = OH_AVRecorder_FileGenerationMode::AVRECORDER_AUTO_CREATE_CAMERA_SCENE; + + int32_t rotation = 90; + + int32_t ret = AV_ERR_OK; + + ret = OH_AVRecorder_Prepare(recorder_, &config); + #ifdef SUPPORT_RECORDER_CREATE_FILE + EXPECT_EQ(ret, AV_ERR_OK); + #else + EXPECT_EQ(ret, AV_ERR_INVALID_VAL); + #endif + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + + free(config.url); + free(config.metadata.genre); + free(config.metadata.videoOrientation); + free(config.metadata.customInfo.key); + free(config.metadata.customInfo.value); + + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_003 out."); +} + +/** + * @tc.name: Recorder_UpdateRotation_004 + * @tc.desc: Test recorder UpdateRotation process 004 + * @tc.type: FUNC + */ +HWTEST_F(NativeRecorderUnitTest, Recorder_UpdateRotation_004, TestSize.Level2) +{ + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_004 in."); + + OH_AVRecorder_Config config = config_; + config.url = strdup(""); + config.metadata.genre = strdup(""); + config.metadata.videoOrientation = strdup("0"); + config.metadata.customInfo.key = strdup(""); + config.metadata.customInfo.value = strdup(""); + config.fileGenerationMode = OH_AVRecorder_FileGenerationMode::AVRECORDER_AUTO_CREATE_CAMERA_SCENE; + + int32_t ret = AV_ERR_OK; + + ret = OH_AVRecorder_Prepare(recorder_, &config); + #ifdef SUPPORT_RECORDER_CREATE_FILE + EXPECT_EQ(ret, AV_ERR_OK); + #else + EXPECT_EQ(ret, AV_ERR_INVALID_VAL); + #endif + + int32_t rotation = 0; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + rotation = 90; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + rotation = 180; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + rotation = 270; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + free(config.url); + free(config.metadata.genre); + free(config.metadata.videoOrientation); + free(config.metadata.customInfo.key); + free(config.metadata.customInfo.value); + + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_004 out."); +} + /** * @tc.name: Recorder_Start_001 * @tc.desc: Test recorder start process 001