From 8c82a88ae75708fff2e16a535797d0e09061e733 Mon Sep 17 00:00:00 2001 From: wangxiake Date: Wed, 10 Sep 2025 11:52:16 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=9C=A8mediademuxer=E4=B8=AD=E8=B0=83?= =?UTF-8?q?=E7=94=A8=20Signed-off-by:=20wangxiake=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/demuxer/media_demuxer.cpp | 17 +++++++++++++++++ .../modules/demuxer/media_demuxer.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index 7a001684d..07f27fb76 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -3971,5 +3971,22 @@ void MediaDemuxer::HandleVideoSampleQueue() FALSE_RETURN_NOLOG(ret == Status::OK); sampleQueueMap_[videoTrackId_]->ReleaseBuffer(dstBuffer); } + +Status MediaDemuxer::BoostReadThreadPriority() +{ + MEDIA_LOG_I("MediaDemuxer::BoostReadThreadPriority called - forwarding to demuxer plugin"); + auto plugin = GetCurFFmpegPlugin(); + if (plugin == nullptr) { + MEDIA_LOG_W("No demuxer plugin available, cannot boost read thread priority"); + return Status::ERROR_INVALID_PARAMETER; + } + Status ret = plugin->BoostReadThreadPriority(); + if (ret != Status::OK) { + MEDIA_LOG_W("Demuxer plugin BoostReadThreadPriority failed, ret: " PUBLIC_LOG_D32, static_cast(ret)); + return ret; + } + MEDIA_LOG_I("Successfully forwarded BoostReadThreadPriority to demuxer plugin"); + return Status::OK; +} } // namespace Media } // namespace OHOS \ No newline at end of file diff --git a/services/media_engine/modules/demuxer/media_demuxer.h b/services/media_engine/modules/demuxer/media_demuxer.h index 2ba5f9e16..c714c6c8c 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.h +++ b/services/media_engine/modules/demuxer/media_demuxer.h @@ -190,6 +190,8 @@ public: return isVideoMuted_ || needRestore_; } void NotifyResumeUnMute(); + + Status BoostReadThreadPriority(); private: class AVBufferQueueProducerListener; class TrackWrapper; -- Gitee From ad10c565cf53bd89330d2009282b37489ff79428 Mon Sep 17 00:00:00 2001 From: wangxiake Date: Wed, 10 Sep 2025 20:35:56 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E6=89=8B=E8=A1=A8=E8=AE=BE=E5=A4=87=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20Signed-off-by:=20wangxiake=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../media_engine/modules/demuxer/media_demuxer.cpp | 11 +++++++++++ services/media_engine/modules/demuxer/media_demuxer.h | 1 + 2 files changed, 12 insertions(+) diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index 07f27fb76..944c84e4c 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -3988,5 +3988,16 @@ Status MediaDemuxer::BoostReadThreadPriority() MEDIA_LOG_I("Successfully forwarded BoostReadThreadPriority to demuxer plugin"); return Status::OK; } + +bool MediaDemuxer::IsWatchDevice() +{ + std::string deviceType = OHOS::system::GetDeviceType(); + if (deviceType == "wearable") { + MEDIA_LOG_I("Watch device detected by device type: %{public}s", deviceType.c_str()); + return true; + } + MEDIA_LOG_D("Non-watch device detected, device type: %{public}s", deviceType.c_str()); + return false; +} } // namespace Media } // namespace OHOS \ No newline at end of file diff --git a/services/media_engine/modules/demuxer/media_demuxer.h b/services/media_engine/modules/demuxer/media_demuxer.h index c714c6c8c..f57319908 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.h +++ b/services/media_engine/modules/demuxer/media_demuxer.h @@ -192,6 +192,7 @@ public: void NotifyResumeUnMute(); Status BoostReadThreadPriority(); + bool IsWatchDevice(); private: class AVBufferQueueProducerListener; class TrackWrapper; -- Gitee From 585a6dea172e9f6495e7020eb339bab78bf4afdb Mon Sep 17 00:00:00 2001 From: wangxiake Date: Wed, 10 Sep 2025 21:07:54 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97=20Sign?= =?UTF-8?q?ed-off-by:=20wangxiake=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../media_engine/modules/demuxer/media_demuxer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index 944c84e4c..1beeb4a1f 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -3974,18 +3974,18 @@ void MediaDemuxer::HandleVideoSampleQueue() Status MediaDemuxer::BoostReadThreadPriority() { - MEDIA_LOG_I("MediaDemuxer::BoostReadThreadPriority called - forwarding to demuxer plugin"); + MEDIA_LOG_I("Boost start"); auto plugin = GetCurFFmpegPlugin(); if (plugin == nullptr) { - MEDIA_LOG_W("No demuxer plugin available, cannot boost read thread priority"); + MEDIA_LOG_W("Demuxer not available, boost failed"); return Status::ERROR_INVALID_PARAMETER; } Status ret = plugin->BoostReadThreadPriority(); if (ret != Status::OK) { - MEDIA_LOG_W("Demuxer plugin BoostReadThreadPriority failed, ret: " PUBLIC_LOG_D32, static_cast(ret)); + MEDIA_LOG_W("Boost failed, ret: " PUBLIC_LOG_D32, static_cast(ret)); return ret; } - MEDIA_LOG_I("Successfully forwarded BoostReadThreadPriority to demuxer plugin"); + MEDIA_LOG_I("Boost success"); return Status::OK; } @@ -3993,10 +3993,10 @@ bool MediaDemuxer::IsWatchDevice() { std::string deviceType = OHOS::system::GetDeviceType(); if (deviceType == "wearable") { - MEDIA_LOG_I("Watch device detected by device type: %{public}s", deviceType.c_str()); + MEDIA_LOG_I("Watch detected by device type: %{public}s", deviceType.c_str()); return true; } - MEDIA_LOG_D("Non-watch device detected, device type: %{public}s", deviceType.c_str()); + MEDIA_LOG_D("Non-watch detected, device type: %{public}s", deviceType.c_str()); return false; } } // namespace Media -- Gitee From e51831efd243f0ccdeb79227274f3e8514df2fc7 Mon Sep 17 00:00:00 2001 From: wangxiake Date: Wed, 10 Sep 2025 21:23:44 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=97=A5=E5=BF=97=20Signed-off-by:=20wangx?= =?UTF-8?q?iake=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/media_engine/modules/demuxer/media_demuxer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index 1beeb4a1f..a2f449296 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -3974,18 +3974,18 @@ void MediaDemuxer::HandleVideoSampleQueue() Status MediaDemuxer::BoostReadThreadPriority() { - MEDIA_LOG_I("Boost start"); + MEDIA_LOG_I("Boost read thread priority start"); auto plugin = GetCurFFmpegPlugin(); if (plugin == nullptr) { - MEDIA_LOG_W("Demuxer not available, boost failed"); + MEDIA_LOG_W("Demuxer not available, boost read thread priority failed"); return Status::ERROR_INVALID_PARAMETER; } Status ret = plugin->BoostReadThreadPriority(); if (ret != Status::OK) { - MEDIA_LOG_W("Boost failed, ret: " PUBLIC_LOG_D32, static_cast(ret)); + MEDIA_LOG_W("Boost read thread priority failed, ret: " PUBLIC_LOG_D32, static_cast(ret)); return ret; } - MEDIA_LOG_I("Boost success"); + MEDIA_LOG_I("Read thread priority successfully boosted"); return Status::OK; } -- Gitee From 19c75db9ad8ba11bd088ff49beb42eb1eb2fe3df Mon Sep 17 00:00:00 2001 From: wxkkk Date: Wed, 10 Sep 2025 23:04:16 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wxkkk --- services/media_engine/modules/demuxer/media_demuxer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index a2f449296..fdcd05def 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -3975,7 +3975,7 @@ void MediaDemuxer::HandleVideoSampleQueue() Status MediaDemuxer::BoostReadThreadPriority() { MEDIA_LOG_I("Boost read thread priority start"); - auto plugin = GetCurFFmpegPlugin(); + std::shared_ptr plugin = GetCurFFmpegPlugin(); if (plugin == nullptr) { MEDIA_LOG_W("Demuxer not available, boost read thread priority failed"); return Status::ERROR_INVALID_PARAMETER; -- Gitee From 148efc698a089eb1e12bd46a266e872c8121c0f3 Mon Sep 17 00:00:00 2001 From: wxkkk Date: Fri, 12 Sep 2025 01:07:49 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=89=8B=E8=A1=A8=E8=A7=A3=E5=B0=81?= =?UTF-8?q?=E8=A3=85=E5=BC=82=E6=AD=A5=E7=BA=BF=E7=A8=8B=E4=BC=98=E5=85=88?= =?UTF-8?q?=E7=BA=A7=E6=8F=90=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wxkkk --- config.gni | 7 ++++++ .../modules/demuxer/media_demuxer.cpp | 23 ++++++++++--------- .../modules/demuxer/media_demuxer.h | 4 ++-- .../media_demuxer_unit_test.cpp | 16 +++++++++++++ .../media_demuxer_unit_test.h | 2 ++ 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/config.gni b/config.gni index 75c3f26f4..04086d90c 100644 --- a/config.gni +++ b/config.gni @@ -44,6 +44,7 @@ declare_args() { av_codec_enable_demuxer_lrc = false av_codec_enable_demuxer_sami = false av_codec_enable_demuxer_ass = false + av_codec_support_watch_device = false av_codec_support_camera_post_processor = false if (defined(global_parts_info) && defined(global_parts_info.hdf_drivers_interface_camera_ext)) { @@ -169,4 +170,10 @@ if (av_codec_enable_demuxer_sami) { if (av_codec_enable_demuxer_ass) { av_codec_defines += [ "SUPPORT_DEMUXER_ASS" ] +} + +if (av_codec_support_watch_device) { + av_codec_defines += [ "SUPPORT_WATCH_DEVICE" ] +} else { + av_codec_defines += [ "UNSUPPORT_WATCH_DEVICE" ] } \ No newline at end of file diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index fdcd05def..e12163edb 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -942,6 +942,16 @@ Status MediaDemuxer::SetDataSource(const std::shared_ptr &source) eventReceiver_->OnDfxEvent({"DEMUX", DfxEventType::DFX_INFO_PLAYER_EOS_SEEK, static_cast(snifferPluginName == inferPluginName)}); } +#ifdef SUPPORT_WATCH_DEVICE + MEDIA_LOG_I("Watch device, boosting read thread priority"); + Status boostRet = BoostReadThreadPriority(); + if (boostRet != Status::OK) { + MEDIA_LOGW("Failed to boost read thread priority, ret: %{public}d", + static_cast(boostRet)); + } else { + MEDIA_LOGI("Successfully boosted read thread priority for watch"); + } +#endif MEDIA_LOG_I("Out"); return res; } @@ -3972,6 +3982,7 @@ void MediaDemuxer::HandleVideoSampleQueue() sampleQueueMap_[videoTrackId_]->ReleaseBuffer(dstBuffer); } +#ifdef SUPPORT_WATCH_DEVICE Status MediaDemuxer::BoostReadThreadPriority() { MEDIA_LOG_I("Boost read thread priority start"); @@ -3988,16 +3999,6 @@ Status MediaDemuxer::BoostReadThreadPriority() MEDIA_LOG_I("Read thread priority successfully boosted"); return Status::OK; } - -bool MediaDemuxer::IsWatchDevice() -{ - std::string deviceType = OHOS::system::GetDeviceType(); - if (deviceType == "wearable") { - MEDIA_LOG_I("Watch detected by device type: %{public}s", deviceType.c_str()); - return true; - } - MEDIA_LOG_D("Non-watch detected, device type: %{public}s", deviceType.c_str()); - return false; -} +#endif } // namespace Media } // namespace OHOS \ No newline at end of file diff --git a/services/media_engine/modules/demuxer/media_demuxer.h b/services/media_engine/modules/demuxer/media_demuxer.h index f57319908..a0abb1121 100644 --- a/services/media_engine/modules/demuxer/media_demuxer.h +++ b/services/media_engine/modules/demuxer/media_demuxer.h @@ -190,9 +190,9 @@ public: return isVideoMuted_ || needRestore_; } void NotifyResumeUnMute(); - +#ifdef SUPPORT_WATCH_DEVICE Status BoostReadThreadPriority(); - bool IsWatchDevice(); +#endif private: class AVBufferQueueProducerListener; class TrackWrapper; diff --git a/test/unittest/media_demuxer_test/media_demuxer_unit_test.cpp b/test/unittest/media_demuxer_test/media_demuxer_unit_test.cpp index 1311b8fd3..b9fc0a02f 100644 --- a/test/unittest/media_demuxer_test/media_demuxer_unit_test.cpp +++ b/test/unittest/media_demuxer_test/media_demuxer_unit_test.cpp @@ -2255,4 +2255,20 @@ HWTEST_F(MediaDemuxerUnitTest, MediaDemuxer_SetMediaMuted, TestSize.Level1) demuxer->SetMediaMuted(Media::MediaType::MEDIA_TYPE_AUD, true); EXPECT_EQ(demuxer->isVideoMuted_, false); } + + +/** + * @tc.name: MediaDemuxer_BoostReadThreadPriority_001 + * @tc.desc: Test BoostReadThreadPriority basic functionality + * @tc.type: FUNC + */ +#ifdef SUPPORT_WATCH_DEVICE +HWTEST_F(MediaDemuxerUnitTest, MediaDemuxer_BoostReadThreadPriority_001, TestSize.Level1) +{ + std::shared_ptr demuxer = std::make_shared(); + ASSERT_NE(demuxer, nullptr); + Status ret = demuxer->BoostReadThreadPriority(); + EXPECT_EQ(ret, Status::OK); +} +#endif } \ No newline at end of file diff --git a/test/unittest/media_demuxer_test/media_demuxer_unit_test.h b/test/unittest/media_demuxer_test/media_demuxer_unit_test.h index cf3cd500a..b3a4ce4d7 100644 --- a/test/unittest/media_demuxer_test/media_demuxer_unit_test.h +++ b/test/unittest/media_demuxer_test/media_demuxer_unit_test.h @@ -192,10 +192,12 @@ public: size = 5000000; // cache for 5000000 return true; } +#ifdef SUPPORT_WATCH_DEVICE Status BoostReadThreadPriority() override { return mapStatus_[name_]; } +#endif private: std::map mapStatus_; std::string name_; -- Gitee