From: Sun-woo Nam Date: Fri, 10 Mar 2023 03:48:19 +0000 (-0800) Subject: fixup! [MM] Implement MMPlayer(CAPI) path to support HBBTV. X-Git-Tag: submit/tizen/20230314.160016~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F289585%2F5;p=platform%2Fframework%2Fweb%2Fchromium-efl.git fixup! [MM] Implement MMPlayer(CAPI) path to support HBBTV. 1. Set user agent string for MMPlayer 2. Fix wrong condition checking: Check MediaResource::Type::URL instead of |demuxer_override_| because it is set as |null| after |SetDemuxer| function call. 3. Change the location of MediaUrlDemuxer creation: ContentRendererClientEfl -> ContentRendererClient These patches can be squashed into the original patch. Reference: https://review.tizen.org/gerrit/#/c/276946/ https://review.tizen.org/gerrit/#/c/278781/ https://review.tizen.org/gerrit/#/c/288024/ Change-Id: I76edfa42ffb8f9e16a4b5bfa6db3dfd95a7893b3 Signed-off-by: Sun-woo Nam --- diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc index c677267..631dd42 100644 --- a/content/public/renderer/content_renderer_client.cc +++ b/content/public/renderer/content_renderer_client.cc @@ -14,6 +14,13 @@ #include "ui/gfx/icc_profile.h" #include "url/gurl.h" +#if defined(TIZEN_MULTIMEDIA) && defined(OS_TIZEN_TV_PRODUCT) +#include "content/public/renderer/render_frame.h" +#include "media/base/media_url_demuxer.h" +#include "third_party/blink/public/web/web_local_frame.h" +#include "tizen_src/ewk/efl_integration/common/application_type.h" +#endif + namespace content { SkBitmap* ContentRendererClient::GetSadPluginBitmap() { @@ -73,6 +80,14 @@ std::unique_ptr ContentRendererClient::OverrideDemuxerForUrl( RenderFrame* render_frame, const GURL& url, scoped_refptr task_runner) { +#if defined(TIZEN_MULTIMEDIA) && defined(OS_TIZEN_TV_PRODUCT) + if (content::IsHbbTV()) { + blink::WebLocalFrame* frame = render_frame->GetWebFrame(); + return std::make_unique( + task_runner, url, frame->GetDocument().SiteForCookies(), + frame->GetDocument().TopFrameOrigin(), true, false); + } +#endif return nullptr; } diff --git a/third_party/blink/renderer/platform/media/web_media_player_impl.cc b/third_party/blink/renderer/platform/media/web_media_player_impl.cc index 4e9ffc6..1358144 100644 --- a/third_party/blink/renderer/platform/media/web_media_player_impl.cc +++ b/third_party/blink/renderer/platform/media/web_media_player_impl.cc @@ -2289,7 +2289,7 @@ bool WebMediaPlayerImpl::CanPlayThrough() { if (chunk_demuxer_) return true; #if defined(TIZEN_MULTIMEDIA) - if (demuxer_override_) { + if (demuxer_->GetType() == media::MediaResource::Type::URL) { // TODO : Need to check buffered status return true; } diff --git a/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc b/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc index 7f91026..78ebb4b 100644 --- a/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc +++ b/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc @@ -9,6 +9,7 @@ #include "base/task/single_thread_task_runner.h" #include "base/trace_event/trace_event.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/common/content_client_export.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -155,9 +156,7 @@ TizenRendererImpl::TizenRendererImpl( render_process_id_(process_id), routing_id_(routing_id), volume_(kDefaultVolume), -#if defined(TIZEN_VIDEO_HOLE) web_contents_(web_contents), -#endif renderer_extension_receiver_(this, std::move(renderer_extension_receiver)) { DCHECK_EQ(WebContents::FromRenderFrameHost( @@ -224,8 +223,17 @@ void TizenRendererImpl::Initialize(media::MediaResource* media_resource, if (media_resource_->GetType() == media::MediaResource::STREAM) { media_player_ = std::make_unique(); } else { + // When the type is media::MediaResource::URL + std::string user_agent; + if (web_contents_) { + user_agent = web_contents_->GetUserAgentOverride().ua_string_override; + if (user_agent.empty()) { + user_agent = + content::GetContentClientExport()->browser()->GetUserAgent(); + } + } media_player_ = std::make_unique( - media_resource->GetMediaUrlParams().media_url, volume_); + media_resource->GetMediaUrlParams().media_url, user_agent, volume_); } if (!media_player_->CreatePlayer()) { diff --git a/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h b/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h index fd4dc95..8c819d9 100644 --- a/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h +++ b/tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h @@ -191,11 +191,12 @@ class CONTENT_EXPORT TizenRendererImpl bool has_error_ = false; #if defined(TIZEN_VIDEO_HOLE) - WebContents* web_contents_; bool is_video_hole_ = false; gfx::RectF video_rect_; #endif + WebContents* web_contents_ = nullptr; + base::WeakPtrFactory weak_factory_{this}; }; diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.cc b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.cc index 905dc12..8cd45e4 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.cc @@ -13,9 +13,11 @@ namespace media { -MediaPlayerBridgeCapiAdapter::MediaPlayerBridgeCapiAdapter(const GURL& url, - double volume) - : url_(url), volume_(volume) { +MediaPlayerBridgeCapiAdapter::MediaPlayerBridgeCapiAdapter( + const GURL& url, + std::string& user_agent, + double volume) + : url_(url), user_agent_(user_agent), volume_(volume) { LOG(INFO) << "(" << static_cast(this) << ") " << __func__; player_id_ = MediaPlayerRegistry::GetInstance()->RegisterMediaPlayer(this); } @@ -31,10 +33,8 @@ bool MediaPlayerBridgeCapiAdapter::CreatePlayer() { if (media_player_) return true; - // TODO: Get user agent string from caller - std::string user_agent = ""; media_player_ = - media::MediaPlayerEfl::CreatePlayer(0, url_, volume_, this, user_agent); + media::MediaPlayerEfl::CreatePlayer(0, url_, volume_, this, user_agent_); return true; } diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.h b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.h index b65a555..824b5bc 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.h +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_adapter.h @@ -27,7 +27,9 @@ class VideoRendererSink; class MEDIA_EXPORT MediaPlayerBridgeCapiAdapter : public MediaPlayerTizen, public MediaPlayerManager { public: - MediaPlayerBridgeCapiAdapter(const GURL& url, double volume); + MediaPlayerBridgeCapiAdapter(const GURL& url, + std::string& user_agent, + double volume); ~MediaPlayerBridgeCapiAdapter() override; bool CreatePlayer() override; @@ -108,6 +110,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiAdapter : public MediaPlayerTizen, MediaPlayerTizenClientExtension* client_extension_ = nullptr; GURL url_; + std::string user_agent_; double volume_ = 1.0f; bool is_initialized_ = false; diff --git a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc index 63f5639..1faaaad 100644 --- a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc +++ b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc @@ -24,7 +24,6 @@ #include "content/public/renderer/content_renderer_client.h" #include "content/public/renderer/render_thread.h" #include "content/renderer/common_renderer_client.h" -#include "media/base/media_url_demuxer.h" #include "renderer/content_settings_client_efl.h" #include "renderer/gin_native_bridge_dispatcher.h" #include "renderer/plugins/plugin_placeholder_efl.h" @@ -39,7 +38,6 @@ #include "third_party/blink/public/web/web_element_collection.h" #include "third_party/blink/public/web/web_form_element.h" #include "third_party/blink/public/web/web_frame.h" -#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_settings.h" #include "third_party/blink/public/web/web_view.h" #include "url/gurl.h" @@ -350,23 +348,6 @@ void ContentRendererClientEfl::ApplyCustomMobileSettings(blink::WebView* webview } } -std::unique_ptr ContentRendererClientEfl::OverrideDemuxerForUrl( - content::RenderFrame* render_frame, - const GURL& url, - scoped_refptr task_runner) { - bool use_url_demuxer = false; -#if defined(OS_TIZEN_TV_PRODUCT) && !defined(EWK_BRINGUP) - use_url_demuxer = content::IsHbbTV(); -#endif - if (use_url_demuxer) { - blink::WebLocalFrame* frame = render_frame->GetWebFrame(); - return std::make_unique( - task_runner, url, frame->GetDocument().SiteForCookies(), - frame->GetDocument().TopFrameOrigin(), true, false); - } - return nullptr; -} - #if defined(TIZEN_MULTIMEDIA) bool ContentRendererClientEfl::IsIdleMediaSuspendEnabled() { LOG(INFO) << __func__ << ", Disable idle media suspend : return false"; diff --git a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h index 9d0b969..7ca20ad 100644 --- a/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h +++ b/tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.h @@ -90,11 +90,6 @@ class ContentRendererClientEfl : public content::ContentRendererClient { bool IsLinkVisited(uint64_t link_hash) override; - std::unique_ptr OverrideDemuxerForUrl( - content::RenderFrame* render_frame, - const GURL& url, - scoped_refptr task_runner) override; - #if defined(TIZEN_MULTIMEDIA) bool IsIdleMediaSuspendEnabled() override; #endif