From 3bf80f578e468f626041baabf41d2d8e25b15cdb Mon Sep 17 00:00:00 2001 From: zeng Date: Fri, 5 Sep 2025 11:08:16 +0800 Subject: [PATCH 1/3] add audio info Signed-off-by: zeng --- .../capi/screencapture/native_avscreen_capture.cpp | 2 ++ interfaces/inner_api/native/av_common.h | 6 ++++++ interfaces/kits/c/native_avscreen_capture_base.h | 10 +++++++++- .../screen_capture/server/screen_capture_server.cpp | 3 +++ .../src/screen_capture_server_function_unittest.cpp | 2 +- .../src/screen_capture_unit_test_state.cpp | 2 +- 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp index 9b955f712..ae929b520 100644 --- a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp +++ b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp @@ -637,6 +637,8 @@ AVScreenCaptureConfig OH_AVScreenCapture_Convert(OH_AVScreenCaptureConfig config config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MPEG_4A; } else if (config.recorderInfo.fileFormat == CFT_MPEG_4) { config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MPEG_4; + } else if (config.recorderInfo.fileFormat == CFT_MKV) { + config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MKV; } return config_; } diff --git a/interfaces/inner_api/native/av_common.h b/interfaces/inner_api/native/av_common.h index 55da53ee7..57889ec6a 100644 --- a/interfaces/inner_api/native/av_common.h +++ b/interfaces/inner_api/native/av_common.h @@ -89,6 +89,8 @@ enum OutputFormatType : int32_t { FORMAT_MPEG_4 = 2, /** M4A format */ FORMAT_M4A = 6, + /** MKV format */ + FORMAT_MKV = 7, /** AMR format */ FORMAT_AMR = 8, /** mp3 format */ @@ -134,6 +136,10 @@ enum AudioCodecFormat : int32_t { AUDIO_MPEG = 4, /** G711-mulaw format */ AUDIO_G711MU = 5, + /** G711-mulaw format */ + AUDIO_OPUS = 6, + /** G711-mulaw format */ + AUDIO_FLAC = 7, /** AUDIO_AMR_NB format */ AUDIO_AMR_NB = 9, /** AUDIO_AMR_WB format */ diff --git a/interfaces/kits/c/native_avscreen_capture_base.h b/interfaces/kits/c/native_avscreen_capture_base.h index f88931093..de31f9b00 100644 --- a/interfaces/kits/c/native_avscreen_capture_base.h +++ b/interfaces/kits/c/native_avscreen_capture_base.h @@ -99,6 +99,12 @@ typedef enum OH_AudioCodecFormat { OH_AUDIO_DEFAULT = 0, /* Advanced Audio Coding Low Complexity (AAC-LC) */ OH_AAC_LC = 3, + /* (MP3) */ + OH_MP3 = 4, + /* (OPUS) */ + OH_OPUS = 6, + /* (FLAC) */ + OH_FLAC = 7, /* Invalid value */ OH_AUDIO_CODEC_FORMAT_BUTT, } OH_AudioCodecFormat; @@ -174,7 +180,9 @@ typedef enum OH_ContainerFormatType { /* Audio format type -- m4a */ CFT_MPEG_4A = 0, /* Video format type -- mp4 */ - CFT_MPEG_4 = 1 + CFT_MPEG_4 = 1, + /* Video format type -- mkv */ + CFT_MKV = 2 } OH_ContainerFormatType; /** diff --git a/services/services/screen_capture/server/screen_capture_server.cpp b/services/services/screen_capture/server/screen_capture_server.cpp index a1a6707ce..13ac0f07e 100644 --- a/services/services/screen_capture/server/screen_capture_server.cpp +++ b/services/services/screen_capture/server/screen_capture_server.cpp @@ -64,6 +64,7 @@ namespace Media { static const std::string MP4 = "mp4"; static const std::string M4A = "m4a"; +static const std::string MKV = "mkv"; static const std::string USER_CHOICE_ALLOW = "true"; static const std::string USER_CHOICE_DENY = "false"; @@ -1155,6 +1156,8 @@ int32_t ScreenCaptureServer::SetRecorderInfo(RecorderInfo recorderInfo) fileFormat_ = OutputFormatType::FORMAT_MPEG_4; } else if (M4A.compare(recorderInfo.fileFormat) == 0) { fileFormat_ = OutputFormatType::FORMAT_M4A; + } else if (MKV.compare(recorderInfo.fileFormat) == 0) { + fileFormat_ = OutputFormatType::FORMAT_MKV; } else { MEDIA_LOGE("invalid fileFormat type"); FaultScreenCaptureEventWrite(appName_, instanceId_, avType_, dataMode_, diff --git a/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp b/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp index fecefad6f..c5d8e2490 100644 --- a/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp +++ b/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp @@ -269,7 +269,7 @@ int32_t ScreenCaptureServerFunctionTest::SetRecorderInfo(std::string name, { OpenFileFd(name); recorderInfo.url = "fd://" + std::to_string(outputFd_); - recorderInfo.fileFormat = "mp4"; + recorderInfo.fileFormat = "mkv"; return MSERR_OK; } diff --git a/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp b/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp index 565518dcf..1d1ee0dc9 100644 --- a/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp +++ b/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp @@ -568,7 +568,7 @@ int32_t ScreenCaptureUnitTest::SetRecorderInfo(std::string name, RecorderInfo &r { OpenFileFd(name); recorderInfo.url = "fd://" + to_string(outputFd_); - recorderInfo.fileFormat = "mp4"; + recorderInfo.fileFormat = "mkv"; return MSERR_OK; } -- Gitee From 9c497557f13fb7f634e8cb698cccce6d0dfc9bb0 Mon Sep 17 00:00:00 2001 From: zeng Date: Fri, 5 Sep 2025 11:17:09 +0800 Subject: [PATCH 2/3] add info Signed-off-by: zeng --- .../native/capi/screencapture/native_avscreen_capture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp index ae929b520..602b02ca0 100644 --- a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp +++ b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp @@ -632,7 +632,7 @@ AVScreenCaptureConfig OH_AVScreenCapture_Convert(OH_AVScreenCaptureConfig config }; if (config.recorderInfo.url != nullptr) { config_.recorderInfo.url = config.recorderInfo.url; - } + }/ if (config.recorderInfo.fileFormat == CFT_MPEG_4A) { config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MPEG_4A; } else if (config.recorderInfo.fileFormat == CFT_MPEG_4) { -- Gitee From 0e94faf4a2d4b25269fbe0d70cf379f556742211 Mon Sep 17 00:00:00 2001 From: zeng Date: Fri, 5 Sep 2025 13:23:49 +0800 Subject: [PATCH 3/3] update resubmit Signed-off-by: zeng --- .../native/capi/screencapture/native_avscreen_capture.cpp | 4 +--- .../services/screen_capture/server/screen_capture_server.cpp | 3 --- .../server/src/screen_capture_server_function_unittest.cpp | 2 +- .../src/screen_capture_unit_test_state.cpp | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp index 602b02ca0..9b955f712 100644 --- a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp +++ b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp @@ -632,13 +632,11 @@ AVScreenCaptureConfig OH_AVScreenCapture_Convert(OH_AVScreenCaptureConfig config }; if (config.recorderInfo.url != nullptr) { config_.recorderInfo.url = config.recorderInfo.url; - }/ + } if (config.recorderInfo.fileFormat == CFT_MPEG_4A) { config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MPEG_4A; } else if (config.recorderInfo.fileFormat == CFT_MPEG_4) { config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MPEG_4; - } else if (config.recorderInfo.fileFormat == CFT_MKV) { - config_.recorderInfo.fileFormat = ContainerFormatType::CFT_MKV; } return config_; } diff --git a/services/services/screen_capture/server/screen_capture_server.cpp b/services/services/screen_capture/server/screen_capture_server.cpp index 439e0f82e..c96e07f6d 100644 --- a/services/services/screen_capture/server/screen_capture_server.cpp +++ b/services/services/screen_capture/server/screen_capture_server.cpp @@ -64,7 +64,6 @@ namespace Media { static const std::string MP4 = "mp4"; static const std::string M4A = "m4a"; -static const std::string MKV = "mkv"; static const std::string USER_CHOICE_ALLOW = "true"; static const std::string USER_CHOICE_DENY = "false"; @@ -1154,8 +1153,6 @@ int32_t ScreenCaptureServer::SetRecorderInfo(RecorderInfo recorderInfo) fileFormat_ = OutputFormatType::FORMAT_MPEG_4; } else if (M4A.compare(recorderInfo.fileFormat) == 0) { fileFormat_ = OutputFormatType::FORMAT_M4A; - } else if (MKV.compare(recorderInfo.fileFormat) == 0) { - fileFormat_ = OutputFormatType::FORMAT_MKV; } else { MEDIA_LOGE("invalid fileFormat type"); FaultScreenCaptureEventWrite(appName_, instanceId_, avType_, dataMode_, diff --git a/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp b/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp index cd2db88c1..393d0da4c 100644 --- a/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp +++ b/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp @@ -269,7 +269,7 @@ int32_t ScreenCaptureServerFunctionTest::SetRecorderInfo(std::string name, { OpenFileFd(name); recorderInfo.url = "fd://" + std::to_string(outputFd_); - recorderInfo.fileFormat = "mkv"; + recorderInfo.fileFormat = "mp4"; return MSERR_OK; } diff --git a/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp b/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp index 1d1ee0dc9..565518dcf 100644 --- a/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp +++ b/test/unittest/screen_capture_test/screen_capture_unittest/src/screen_capture_unit_test_state.cpp @@ -568,7 +568,7 @@ int32_t ScreenCaptureUnitTest::SetRecorderInfo(std::string name, RecorderInfo &r { OpenFileFd(name); recorderInfo.url = "fd://" + to_string(outputFd_); - recorderInfo.fileFormat = "mkv"; + recorderInfo.fileFormat = "mp4"; return MSERR_OK; } -- Gitee