From b83cdd18f6468695dd7693541432c70b8020ea3a Mon Sep 17 00:00:00 2001 From: Manjeet Date: Wed, 28 Feb 2024 18:04:10 +0530 Subject: [PATCH 01/16] [M120 Migration] Fix coverity issues This commit fixes following coverity issues CID 115640, 1027471, 1029366, 1079885, 1084336, 1273651, 1278478, 1280131, 1672601 Reference: https://review.tizen.org/gerrit/290923 Change-Id: Ib18b5bc86bb04770114c769e28b7e40a670b13a6 Signed-off-by: Manjeet --- .../content/browser/context_menu/context_menu_controller_base.cc | 3 +-- tizen_src/chromium_impl/content/common/paths_efl.cc | 5 ++++- tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.cc | 1 + .../browser/geolocation/geolocation_permission_context_efl.cc | 2 +- tizen_src/ewk/efl_integration/eweb_view.cc | 4 ++-- tizen_src/ewk/efl_integration/private/ewk_app_control_private.cc | 8 +++++--- tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h | 6 ++++++ tizen_src/ewk/efl_webview_app/app.c | 6 +++++- tizen_src/ewk/ubrowser/browser.cc | 6 +++++- 9 files changed, 30 insertions(+), 11 deletions(-) diff --git a/tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc b/tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc index b80d5f8..14517c1 100644 --- a/tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc +++ b/tizen_src/chromium_impl/content/browser/context_menu/context_menu_controller_base.cc @@ -639,8 +639,7 @@ const char* ContextMenuControllerBase::GetSelectedText() { if (!rwhva()) return ""; - std::string selected_text = base::UTF16ToUTF8(rwhva()->GetSelectedText()); - return selected_text.c_str(); + return base::UTF16ToUTF8(rwhva()->GetSelectedText()).c_str(); } } // namespace content diff --git a/tizen_src/chromium_impl/content/common/paths_efl.cc b/tizen_src/chromium_impl/content/common/paths_efl.cc index 0fd5132..cb9e93c 100644 --- a/tizen_src/chromium_impl/content/common/paths_efl.cc +++ b/tizen_src/chromium_impl/content/common/paths_efl.cc @@ -175,7 +175,10 @@ namespace PathsEfl { #if BUILDFLAG(IS_TIZEN) FilePath GetLibRootPath(void) { Dl_info dl_info; - dladdr((void*)GetLibRootPath, &dl_info); + if (!dladdr((void*)GetLibRootPath, &dl_info)) { + LOG(ERROR) << "dladdr failed"; + return FilePath(); + } FilePath lib_root_path(dl_info.dli_fname); lib_root_path = MakeAbsoluteFilePath(lib_root_path); diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.cc b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.cc index 691917c..ec09b82 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.cc +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_screen.cc @@ -47,6 +47,7 @@ gfx::Rect EflScreen::GetDisplaySize() { EflScreen::EflScreen() { display::Display display(kDisplayId); display.set_bounds(GetDisplaySize()); + display.set_panel_rotation(display::Display::ROTATE_0); display_list_.AddDisplay(display, display::DisplayList::Type::PRIMARY); screen_list.push_back(this); diff --git a/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc b/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc index 695ffe1..36cb521 100644 --- a/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/geolocation/geolocation_permission_context_efl.cc @@ -68,7 +68,7 @@ void GeolocationPermissionContextEfl::RequestPermissionOnUIThread( std::ignore = request.release(); else if (!request->IsDecided()) { // Reject permission if request is not suspended and not decided - std::move(callback).Run(PermissionStatus::DENIED); + request->RunCallback(false); } } } diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index bb6c8c6..5e33357 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -1419,7 +1419,7 @@ void EWebView::UpdateContextMenuWithParams( } Eina_Bool EWebView::DelayedPopulateAndShowContextMenu(void* data) { - if (IsMobileProfile) { + if (IsMobileProfile()) { EWebView* view = static_cast(data); if (view) { if (view->context_menu_ && @@ -2170,9 +2170,9 @@ bool EWebView::GetMHTMLData(Ewk_View_MHTML_Data_Get_Callback callback, if (!render_view_host) return false; +#if !defined(EWK_BRINGUP) // FIXME: m94 bringup MHTMLCallbackDetails* callback_details = new MHTMLCallbackDetails; callback_details->Set(callback, user_data); -#if !defined(EWK_BRINGUP) // FIXME: m94 bringup int mhtml_callback_id = mhtml_callback_map_.Add(callback_details); return render_view_host->Send(new EwkViewMsg_GetMHTMLData( render_view_host->GetRoutingID(), mhtml_callback_id)); diff --git a/tizen_src/ewk/efl_integration/private/ewk_app_control_private.cc b/tizen_src/ewk/efl_integration/private/ewk_app_control_private.cc index 904bee1..f59167e 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_app_control_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_app_control_private.cc @@ -106,8 +106,10 @@ bool _Ewk_App_Control::ParseNavigationParams() { // check start : "#AppControl" const std::string& buf = str_tok.token(); base::StringTokenizer check_start(buf, "#"); - check_start.GetNext(); - if (!check_start.GetNext() || check_start.token() != kAppControlStart) { + // GetNext() advances the tokenizer to the next delimiter. It's called + // twice here to read kAppControlStart, if any as the token value. + if (!check_start.GetNext() || !check_start.GetNext() || + check_start.token() != kAppControlStart) { LOG(ERROR) << __FUNCTION__ << " > #AppControl is missing! "; return false; } @@ -263,7 +265,7 @@ bool _Ewk_App_Control::MakeAppControl() { return FailHandling(); } - ret = pkgmgrinfo_appinfo_foreach_category( + pkgmgrinfo_appinfo_foreach_category( handle, [](const char* category, void* user_data) -> int { auto app_control = static_cast<_Ewk_App_Control*>(user_data); diff --git a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h index 0aba688..cd6bd04 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_geolocation_private.h @@ -12,6 +12,10 @@ class _Ewk_Security_Origin; +namespace content { +class GeolocationPermissionContextEfl; +} + // This holds the geolocation permission request data. // The callback present is the direct engine callback which need // to be called once the permission is determined by app. @@ -25,6 +29,8 @@ class _Ewk_Geolocation_Permission_Request : public Ewk_Suspendable_Object{ _Ewk_Security_Origin* GetOrigin() const { return origin_; } private: + friend class content::GeolocationPermissionContextEfl; + _Ewk_Security_Origin* origin_; void RunCallback(bool allowed) override; diff --git a/tizen_src/ewk/efl_webview_app/app.c b/tizen_src/ewk/efl_webview_app/app.c index 4bf9636..15aaed9 100644 --- a/tizen_src/ewk/efl_webview_app/app.c +++ b/tizen_src/ewk/efl_webview_app/app.c @@ -629,7 +629,11 @@ void __ewk_cookie_manager_async_hostnames_get_cb(Eina_List *hostnames, Ewk_Error printf("APP.C calling ewk_cookie_manager_cookies_clear\n"); if (!clear_cookie_called) { clear_cookie_called = EINA_TRUE; - printf("APP.c calling ewk_view_get_cookies_for_url:%s\n",ewk_view_get_cookies_for_url(view, start_url)); + char* cookies = ewk_view_get_cookies_for_url(view, start_url); + if (cookies) { + printf("APP.c calling ewk_view_get_cookies_for_url:%s\n", cookies); + free(cookies); + } ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get(context)); printf("APP.c calling ewk_cookie_manager_async_hostnames_with_cookies_get\n"); ewk_cookie_manager_async_hostnames_with_cookies_get(ewk_context_cookie_manager_get(context), diff --git a/tizen_src/ewk/ubrowser/browser.cc b/tizen_src/ewk/ubrowser/browser.cc index e8fbb19..80a1754 100644 --- a/tizen_src/ewk/ubrowser/browser.cc +++ b/tizen_src/ewk/ubrowser/browser.cc @@ -257,7 +257,11 @@ void Browser::StartInspectorServer() { void Browser::DidStartInspectorServer(unsigned port) { // Get IP address. struct ifaddrs* addrs; - getifaddrs(&addrs); + int rc = getifaddrs(&addrs); + if (rc == -1) { + log_error("getifaddrs() failed"); + return; + } char url[32] = {0}; // Find non local, up IP address. for (struct ifaddrs* iter = addrs; iter && iter->ifa_addr; -- 2.7.4 From cc78da331014f394ed61820b0cfa10a8a9f3bea2 Mon Sep 17 00:00:00 2001 From: "zhishun.zhou" Date: Wed, 28 Feb 2024 18:00:23 +0800 Subject: [PATCH 02/16] [M120 Migration] Notify media device state to webbrowser 1) web engine get current user media state from media device. 2) web engine notify webbrowser state by ewk callback. Add new ewk type: UserMediaState DECLARE_EWK_VIEW_CALLBACK(UserMediaState, "usermedia,state", void*) From patch: https://review.tizen.org/gerrit/#/c/294421/ Change-Id: I6acab4de98627aa478017512da79f1e0520236f8 Signed-off-by: zhishun.zhou Signed-off-by: xiaofang --- .../renderer_host/media/media_stream_manager.cc | 32 ++++++++++++++++ .../renderer_host/media/media_stream_manager.h | 15 ++++++++ .../render_frame_audio_input_stream_factory.cc | 38 +++++++++++++++++++ content/public/browser/web_contents_delegate.h | 6 +++ content/renderer/render_frame_impl.h | 3 +- media/mojo/mojom/BUILD.gn | 4 ++ media/mojo/mojom/audio_input_stream.mojom | 3 ++ services/audio/input_controller.cc | 38 ++++++++++++++++++- services/audio/input_controller.h | 20 ++++++++++ services/audio/input_stream.cc | 8 ++++ services/audio/input_stream.h | 4 ++ services/audio/public/cpp/input_ipc.h | 4 ++ .../renderer_audio_input_stream_factory.mojom | 4 ++ .../blink/public/web/web_local_frame_client.h | 6 +++ .../modules/media/audio/audio_input_ipc_factory.cc | 2 +- .../modules/media/audio/mojo_audio_input_ipc.cc | 27 +++++++++++++ .../modules/media/audio/mojo_audio_input_ipc.h | 16 +++++++- .../media/audio/tizen/capi_audio_input.h | 2 +- .../capture/video/tizen/camera_device_tizen.cc | 10 +++++ .../capture/video/tizen/camera_device_tizen.h | 5 +++ .../video/tizen/video_capture_device_tizen.cc | 44 ++++++++++++++++++++++ .../video/tizen/video_capture_device_tizen.h | 7 ++++ tizen_src/ewk/efl_integration/eweb_view.cc | 18 +++++++++ tizen_src/ewk/efl_integration/eweb_view.h | 3 ++ .../efl_integration/web_contents_delegate_efl.cc | 13 +++++++ .../efl_integration/web_contents_delegate_efl.h | 3 ++ 26 files changed, 329 insertions(+), 6 deletions(-) diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index 7cc2d2d..78a925a 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -104,6 +104,11 @@ #include "chromeos/lacros/lacros_service.h" #endif +#if BUILDFLAG(IS_TIZEN_TV) +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_delegate.h" +#endif + using blink::mojom::MediaDeviceType; namespace content { @@ -1628,6 +1633,11 @@ void MediaStreamManager::GenerateStreams( device_capture_configuration_change_cb, DeviceCaptureHandleChangeCallback device_capture_handle_change_cb) { DCHECK_CURRENTLY_ON(BrowserThread::IO); + +#if BUILDFLAG(IS_TIZEN_TV) + render_frame_host_id_ = render_frame_host_id; +#endif + SendLogMessage(GetGenerateStreamsLogString(render_frame_host_id, requester_id, page_request_id)); std::unique_ptr request = @@ -2423,6 +2433,28 @@ void MediaStreamManager::PostRequestToUI( media::AudioParameters::UnavailableDeviceParams()))); } +#if BUILDFLAG(IS_TIZEN_TV) +void MediaStreamManager::NotifyMediaStateChanged(uint32_t type, + uint32_t previous, + uint32_t current) { + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost( + content::RenderFrameHost::FromID(render_frame_host_id_)); + if (!web_contents) { + LOG(ERROR) << "web_contents is null"; + return; + } + + content::WebContentsDelegate* web_contents_delegate = + web_contents->GetDelegate(); + if (!web_contents_delegate) { + LOG(ERROR) << "web_contents_delegate is null"; + return; + } + + web_contents_delegate->NotifyMediaStateChanged(type, previous, current); +} +#endif void MediaStreamManager::SetUpRequest(const std::string& label) { DCHECK_CURRENTLY_ON(BrowserThread::IO); diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h index 840fe68..4434172 100644 --- a/content/browser/renderer_host/media/media_stream_manager.h +++ b/content/browser/renderer_host/media/media_stream_manager.h @@ -59,6 +59,10 @@ class Origin; namespace content { +#if BUILDFLAG(IS_TIZEN_TV) +enum MediaInputStreamType { NO_STREAM, AUDIO_CAPTURE, VIDEO_CAPTURE }; +#endif + class AudioInputDeviceManager; class AudioServiceListener; class FakeMediaStreamUIProxy; @@ -339,6 +343,13 @@ class CONTENT_EXPORT MediaStreamManager void NotifyDevicesChanged(blink::mojom::MediaDeviceType stream_type, const blink::WebMediaDeviceInfoArray& devices); +#if BUILDFLAG(IS_TIZEN_TV) + // Notify media(camera/microphone) status change to web browser. + void NotifyMediaStateChanged(uint32_t type, + uint32_t previous, + uint32_t current); +#endif + // This method is called when an audio or video device is removed. It makes // sure all MediaStreams that use a removed device are stopped and that the // render process is notified. Must be called on the IO thread. @@ -759,6 +770,10 @@ class CONTENT_EXPORT MediaStreamManager mojo::UniqueReceiverSet video_capture_hosts_; GenerateStreamTestCallback generate_stream_test_callback_; + +#if BUILDFLAG(IS_TIZEN_TV) + GlobalRenderFrameHostId render_frame_host_id_; +#endif }; } // namespace content diff --git a/content/browser/renderer_host/media/render_frame_audio_input_stream_factory.cc b/content/browser/renderer_host/media/render_frame_audio_input_stream_factory.cc index 587a9ee..6af445d 100644 --- a/content/browser/renderer_host/media/render_frame_audio_input_stream_factory.cc +++ b/content/browser/renderer_host/media/render_frame_audio_input_stream_factory.cc @@ -39,6 +39,10 @@ #include "third_party/blink/public/common/mediastream/media_stream_request.h" #include "url/origin.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "content/browser/browser_main_loop.h" +#endif + using blink::mojom::MediaDeviceType; namespace content { @@ -158,6 +162,11 @@ class RenderFrameAudioInputStreamFactory::Core final const base::UnguessableToken& input_stream_id, const std::string& raw_output_device_id); +#if BUILDFLAG(IS_TIZEN_TV) + void OnMediaStateChanged(uint32_t previous, uint32_t current); + void NotifyMediaStateChanged(uint32_t previous, uint32_t current); +#endif + const raw_ptr media_stream_manager_; const int process_id_; const int frame_id_; @@ -362,4 +371,33 @@ void RenderFrameAudioInputStreamFactory::Core:: raw_output_device_id); } +#if BUILDFLAG(IS_TIZEN_TV) +void RenderFrameAudioInputStreamFactory::Core::OnMediaStateChanged( + uint32_t previous, + uint32_t current) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce(&Core::NotifyMediaStateChanged, + weak_ptr_factory_.GetWeakPtr(), previous, current)); +} + +void RenderFrameAudioInputStreamFactory::Core::NotifyMediaStateChanged( + uint32_t previous, + uint32_t current) { + content::BrowserMainLoop* browser_main_loop = + content::BrowserMainLoop::GetInstance(); + if (!browser_main_loop) { + LOG(ERROR) << "browser_main_loop is null"; + return; + } + content::MediaStreamManager* msm = browser_main_loop->media_stream_manager(); + if (!msm) { + LOG(ERROR) << "MediaStreamManager is null"; + return; + } + msm->NotifyMediaStateChanged(content::MediaInputStreamType::AUDIO_CAPTURE, + previous, current); +} +#endif } // namespace content diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index f552c07..e7cdfd4 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -734,6 +734,12 @@ class CONTENT_EXPORT WebContentsDelegate { // Picture-in-Picture mode has ended. virtual void ExitPictureInPicture() {} +#if BUILDFLAG(IS_TIZEN_TV) + // Notify Media State to Web browser + virtual void NotifyMediaStateChanged(uint32_t type, + uint32_t previous, + uint32_t current) {}; +#endif #if BUILDFLAG(IS_ANDROID) // Updates information to determine whether a user gesture should carryover to // future navigations. This is needed so navigations within a certain diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index cdc7c32..1996d43 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -636,7 +636,8 @@ class CONTENT_EXPORT RenderFrameImpl blink::WebEncryptedMediaClient* EncryptedMediaClient() override; blink::WebString UserAgentOverride() override; absl::optional UserAgentMetadataOverride() override; - blink::mojom::RendererAudioInputStreamFactory* GetAudioInputStreamFactory(); + blink::mojom::RendererAudioInputStreamFactory* GetAudioInputStreamFactory() + override; bool AllowContentInitiatedDataUrlNavigations( const blink::WebURL& url) override; void PostAccessibilityEvent(const ui::AXEvent& event) override; diff --git a/media/mojo/mojom/BUILD.gn b/media/mojo/mojom/BUILD.gn index f6658cd..84f8d98 100644 --- a/media/mojo/mojom/BUILD.gn +++ b/media/mojo/mojom/BUILD.gn @@ -133,6 +133,10 @@ mojom("mojom") { enabled_features += [ "tizen_video_hole" ] } + if (tizen_product_tv) { + enabled_features += [ "is_tizen_tv" ] + } + shared_typemaps = [ { types = [ diff --git a/media/mojo/mojom/audio_input_stream.mojom b/media/mojo/mojom/audio_input_stream.mojom index ddc547a..5437365 100644 --- a/media/mojo/mojom/audio_input_stream.mojom +++ b/media/mojo/mojom/audio_input_stream.mojom @@ -23,6 +23,9 @@ interface AudioInputStream { interface AudioInputStreamClient { OnError(InputStreamErrorCode code); OnMutedStateChanged(bool is_muted); + + [EnableIf=is_tizen_tv] + OnMediaStateChanged(uint32 previous, uint32 current); }; // An AudioInputStreamObserver gets notifications about events related to an diff --git a/services/audio/input_controller.cc b/services/audio/input_controller.cc index aaa1f46..b569c15 100644 --- a/services/audio/input_controller.cc +++ b/services/audio/input_controller.cc @@ -333,8 +333,12 @@ void InputController::Record() { DCHECK(task_runner_->BelongsToCurrentThread()); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.RecordTime"); - if (!stream_ || audio_callback_) + if (!stream_ || audio_callback_) { +#if BUILDFLAG(IS_TIZEN_TV) + OnMediaStateChanged(AUDIO_IO_ERROR); +#endif return; + } event_handler_->OnLog("AIC::Record()"); @@ -370,6 +374,10 @@ void InputController::Record() { #endif stream_->Start(audio_callback_.get()); +#if BUILDFLAG(IS_TIZEN_TV) + OnMediaStateChanged(AUDIO_IO_STARTED); +#endif + return; } @@ -377,8 +385,12 @@ void InputController::Close() { DCHECK(task_runner_->BelongsToCurrentThread()); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CloseTime"); - if (!stream_) + if (!stream_) { +#if BUILDFLAG(IS_TIZEN_TV) + OnMediaStateChanged(AUDIO_IO_ERROR); +#endif return; + } check_muted_state_timer_.AbandonAndStop(); @@ -446,6 +458,10 @@ void InputController::Close() { stream_->Close(); stream_ = nullptr; +#if BUILDFLAG(IS_TIZEN_TV) + OnMediaStateChanged(AUDIO_IO_STOPPED); +#endif + sync_writer_->Close(); #if defined(AUDIO_POWER_MONITORING) @@ -550,6 +566,9 @@ void InputController::DoCreate(media::AudioManager* audio_manager, if (!stream) { LogCaptureStartupResult(CAPTURE_STARTUP_CREATE_STREAM_FAILED); event_handler_->OnError(STREAM_CREATE_ERROR); +#if BUILDFLAG(IS_TIZEN_TV) + OnMediaStateChanged(AUDIO_IO_ERROR); +#endif return; } @@ -558,6 +577,9 @@ void InputController::DoCreate(media::AudioManager* audio_manager, stream->Close(); LogCaptureStartupResult(CAPTURE_STARTUP_OPEN_STREAM_FAILED); event_handler_->OnError(MapOpenOutcomeToErrorCode(open_outcome)); +#if BUILDFLAG(IS_TIZEN_TV) + OnMediaStateChanged(AUDIO_IO_ERROR); +#endif return; } @@ -782,6 +804,18 @@ void InputController::DeliverProcessedAudio( } #endif +#if BUILDFLAG(IS_TIZEN_TV) +void InputController::OnMediaStateChanged(uint32_t current_state) { + DCHECK_CALLED_ON_VALID_THREAD(owning_thread_); + if (current_state != previous_state_) { + LOG(INFO) << "microphone state change previous: " << previous_state_ + << " ;current : " << current_state; + event_handler_->OnMediaStateChanged(previous_state_, current_state); + previous_state_ = current_state; + } +} +#endif + // static InputController::StreamType InputController::ParamsToStreamType( const media::AudioParameters& params) { diff --git a/services/audio/input_controller.h b/services/audio/input_controller.h index 884ade5..0d16241 100644 --- a/services/audio/input_controller.h +++ b/services/audio/input_controller.h @@ -47,6 +47,15 @@ class OutputTapper; class DeviceOutputListener; class ProcessingAudioFifo; +#if BUILDFLAG(IS_TIZEN_TV) +enum AudioIOState { + AUDIO_IO_IDLE, + AUDIO_IO_STARTED, + AUDIO_IO_STOPPED, + AUDIO_IO_ERROR +}; +#endif + // Only do power monitoring for non-mobile platforms to save resources. #if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) #define AUDIO_POWER_MONITORING @@ -141,6 +150,9 @@ class InputController final : public StreamMonitor { virtual void OnLog(base::StringPiece) = 0; // Called whenever the muted state of the underlying stream changes. virtual void OnMuted(bool is_muted) = 0; +#if BUILDFLAG(IS_TIZEN_TV) + virtual void OnMediaStateChanged(uint32_t previous, uint32_t current) = 0; +#endif protected: virtual ~EventHandler() {} @@ -209,6 +221,10 @@ class InputController final : public StreamMonitor { void OnStreamActive(Snoopable* snoopable) override; void OnStreamInactive(Snoopable* snoopable) override; +#if BUILDFLAG(IS_TIZEN_TV) + void OnMediaStateChanged(uint32_t current); +#endif + private: friend class InputControllerTestHelper; @@ -371,6 +387,10 @@ class InputController final : public StreamMonitor { // in the AudioCallback class in the cc file. std::unique_ptr audio_callback_; +#if BUILDFLAG(IS_TIZEN_TV) + uint32_t previous_state_{AUDIO_IO_IDLE}; +#endif + // A weak pointer factory that we use when posting tasks to the audio thread // that we want to be automatically discarded after Close() has been called // and that we do not want to keep the InputController instance alive diff --git a/services/audio/input_stream.cc b/services/audio/input_stream.cc index fbcb609..220a7b0 100644 --- a/services/audio/input_stream.cc +++ b/services/audio/input_stream.cc @@ -321,4 +321,12 @@ void InputStream::SendLogMessage(const char* format, ...) { va_end(args); } +#if BUILDFLAG(IS_TIZEN_TV) +void InputStream::OnMediaStateChanged(uint32_t previous, uint32_t current) { + DCHECK_CALLED_ON_VALID_SEQUENCE(owning_sequence_); + if (client_.get()) { + client_->OnMediaStateChanged(previous, current); + } +} +#endif } // namespace audio diff --git a/services/audio/input_stream.h b/services/audio/input_stream.h index 1b08341..db99d85 100644 --- a/services/audio/input_stream.h +++ b/services/audio/input_stream.h @@ -76,6 +76,10 @@ class InputStream final : public media::mojom::AudioInputStream, void OnLog(base::StringPiece) override; void OnMuted(bool is_muted) override; +#if BUILDFLAG(IS_TIZEN_TV) + void OnMediaStateChanged(uint32_t previous, uint32_t current) override; +#endif + private: void OnStreamError( absl::optional diff --git a/services/audio/public/cpp/input_ipc.h b/services/audio/public/cpp/input_ipc.h index 258ae0e..ebdd2bd 100644 --- a/services/audio/public/cpp/input_ipc.h +++ b/services/audio/public/cpp/input_ipc.h @@ -54,6 +54,10 @@ class COMPONENT_EXPORT(AUDIO_PUBLIC_CPP) InputIPC void OnError(media::mojom::InputStreamErrorCode code) override; void OnMutedStateChanged(bool is_muted) override; +#if BUILDFLAG(IS_TIZEN_TV) + void OnMediaStateChanged(uint32_t previous, uint32_t current) override {} +#endif + void StreamCreated(media::mojom::ReadOnlyAudioDataPipePtr data_pipe, bool is_muted, const absl::optional& stream_id); diff --git a/third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom b/third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom index dde423c..d7281b8 100644 --- a/third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom +++ b/third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom @@ -34,6 +34,10 @@ interface RendererAudioInputStreamFactory { AssociateInputAndOutputForAec( mojo_base.mojom.UnguessableToken input_stream_id, string output_device_id); + + // Notify Audio device state to web browser + [EnableIf=is_tizen_tv] + OnMediaStateChanged(uint32 previous, uint32 current); }; interface RendererAudioInputStreamFactoryClient { diff --git a/third_party/blink/public/web/web_local_frame_client.h b/third_party/blink/public/web/web_local_frame_client.h index 0931182..6fdde7c 100644 --- a/third_party/blink/public/web/web_local_frame_client.h +++ b/third_party/blink/public/web/web_local_frame_client.h @@ -63,6 +63,7 @@ #include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom-shared.h" #include "third_party/blink/public/mojom/loader/same_document_navigation_type.mojom-shared.h" #include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom-shared.h" +#include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom.h" #include "third_party/blink/public/mojom/portal/portal.mojom-shared.h" #include "third_party/blink/public/platform/child_url_loader_factory_bundle.h" #include "third_party/blink/public/platform/cross_variant_mojo_util.h" @@ -790,6 +791,11 @@ class BLINK_EXPORT WebLocalFrameClient { const base::UnguessableToken& input_stream_id, const std::string& output_device_id) {} + virtual blink::mojom::RendererAudioInputStreamFactory* + GetAudioInputStreamFactory() { + return nullptr; + } + // Notifies the observers of the origins for which subresource redirect // optimizations can be preloaded. virtual void PreloadSubresourceOptimizationsForOrigins( diff --git a/third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc b/third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc index c882187..339001e 100644 --- a/third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc +++ b/third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc @@ -90,7 +90,7 @@ std::unique_ptr AudioInputIPCFactory::CreateAudioInputIPC( const media::AudioSourceParameters& source_params) { CHECK(!source_params.session_id.is_empty()); return std::make_unique( - source_params, + frame_token, source_params, base::BindRepeating(&CreateMojoAudioInputStream, main_task_runner, frame_token), base::BindRepeating(&AssociateInputAndOutputForAec, main_task_runner, diff --git a/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.cc b/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.cc index 9ae6fee..fa9d962 100644 --- a/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.cc +++ b/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.cc @@ -17,10 +17,14 @@ namespace blink { MojoAudioInputIPC::MojoAudioInputIPC( + const blink::LocalFrameToken& frame_token, const media::AudioSourceParameters& source_params, StreamCreatorCB stream_creator, StreamAssociatorCB stream_associator) : source_params_(source_params), +#if BUILDFLAG(IS_TIZEN_TV) + frame_token_(frame_token), +#endif stream_creator_(std::move(stream_creator)), stream_associator_(std::move(stream_associator)) { DETACH_FROM_SEQUENCE(sequence_checker_); @@ -85,6 +89,16 @@ media::AudioProcessorControls* MojoAudioInputIPC::GetProcessorControls() { void MojoAudioInputIPC::CloseStream() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +#if BUILDFLAG(IS_TIZEN_TV) + auto* web_frame = static_cast( + blink::WebFrame::FromFrameToken(frame_token_)); + if (web_frame) { + web_frame->Client()->GetAudioInputStreamFactory()->OnMediaStateChanged( + audio_previous_state_, audio::AUDIO_IO_IDLE); + audio_previous_state_ = audio::AUDIO_IO_IDLE; + } +#endif + delegate_ = nullptr; factory_client_receiver_.reset(); stream_client_receiver_.reset(); @@ -153,4 +167,17 @@ void MojoAudioInputIPC::OnMutedStateChanged(bool is_muted) { delegate_->OnMuted(is_muted); } +#if BUILDFLAG(IS_TIZEN_TV) +void MojoAudioInputIPC::OnMediaStateChanged(uint32_t previous, + uint32_t current) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + auto* web_frame = static_cast( + blink::WebFrame::FromFrameToken(frame_token_)); + if (web_frame) { + audio_previous_state_ = current; + web_frame->Client()->GetAudioInputStreamFactory()->OnMediaStateChanged( + previous, current); + } +} +#endif } // namespace blink diff --git a/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.h b/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.h index c0adcba..a5a8ecf 100644 --- a/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.h +++ b/third_party/blink/renderer/modules/media/audio/mojo_audio_input_ipc.h @@ -21,8 +21,14 @@ #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom-blink.h" +#include "third_party/blink/public/web/web_local_frame.h" +#include "third_party/blink/public/web/web_local_frame_client.h" #include "third_party/blink/renderer/modules/modules_export.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "services/audio/input_controller.h" +#endif + namespace blink { // MojoAudioInputIPC is a renderer-side class for handling creation, @@ -51,7 +57,8 @@ class MODULES_EXPORT MojoAudioInputIPC base::RepeatingCallback; - MojoAudioInputIPC(const media::AudioSourceParameters& source_params, + MojoAudioInputIPC(const blink::LocalFrameToken& frame_token, + const media::AudioSourceParameters& source_params, StreamCreatorCB stream_creator, StreamAssociatorCB stream_associator); @@ -86,12 +93,19 @@ class MODULES_EXPORT MojoAudioInputIPC const absl::optional& stream_id) override; void OnError(media::mojom::InputStreamErrorCode code) override; void OnMutedStateChanged(bool is_muted) override; +#if BUILDFLAG(IS_TIZEN_TV) + void OnMediaStateChanged(uint32_t previous, uint32_t current) override; +#endif void OnDisconnect(uint32_t error, const std::string& reason); SEQUENCE_CHECKER(sequence_checker_); const media::AudioSourceParameters source_params_; +#if BUILDFLAG(IS_TIZEN_TV) + const blink::LocalFrameToken frame_token_; + uint32_t audio_previous_state_{audio::AUDIO_IO_IDLE}; +#endif StreamCreatorCB stream_creator_; StreamAssociatorCB stream_associator_; diff --git a/tizen_src/chromium_impl/media/audio/tizen/capi_audio_input.h b/tizen_src/chromium_impl/media/audio/tizen/capi_audio_input.h index bc9bd4b..826139f 100644 --- a/tizen_src/chromium_impl/media/audio/tizen/capi_audio_input.h +++ b/tizen_src/chromium_impl/media/audio/tizen/capi_audio_input.h @@ -60,7 +60,7 @@ class CapiAudioInputStream : public AgcAudioStream { AudioBlockFifo fifo_; private: - AudioManagerCapi* audio_manager_; + AudioManagerCapi* audio_manager_{nullptr}; double volume_; }; diff --git a/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.cc b/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.cc index 62a2236..2fab2f0 100644 --- a/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.cc +++ b/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.cc @@ -1054,4 +1054,14 @@ int CameraHandle::CameraSetStreamFlip(camera_flip_e flip) { return camera_attr_set_stream_flip(camera_handle_, flip); } +#if BUILDFLAG(IS_TIZEN_TV) +int CameraHandle::CameraSetStateChangedCb(camera_state_changed_cb callback, + void* data) { + return camera_set_state_changed_cb(camera_handle_, callback, data); +} + +int CameraHandle::CameraUnSetStateChangedCb() { + return camera_unset_state_changed_cb(camera_handle_); +} +#endif } // namespace media diff --git a/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.h b/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.h index 09adc72..e49d786 100644 --- a/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.h +++ b/tizen_src/chromium_impl/media/capture/video/tizen/camera_device_tizen.h @@ -188,6 +188,11 @@ class CameraHandle final { CameraHandle(const CameraHandle&) = delete; CameraHandle& operator=(const CameraHandle&) = delete; +#if BUILDFLAG(IS_TIZEN_TV) + int CameraSetStateChangedCb(camera_state_changed_cb callback, void* data); + int CameraUnSetStateChangedCb(); +#endif + private: bool GetSupportedPreviewResolutions( std::vector& supported_resolutions) const; diff --git a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc index 1003d4f..69836c0 100644 --- a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc +++ b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.cc @@ -17,6 +17,11 @@ #include "ui/display/display.h" #include "ui/display/screen.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "content/browser/browser_main_loop.h" +#include "content/browser/renderer_host/media/media_stream_manager.h" +#endif + namespace gfx { class Size; } @@ -813,6 +818,15 @@ void VideoCaptureDeviceTizen::OnAllocateAndStart( } } +#if BUILDFLAG(IS_TIZEN_TV) + /* add camera status callback to webbrowser */ + err = camera_instance_->CameraSetStateChangedCb(OnCameraStateChanged, this); + if (CAMERA_ERROR_NONE != err) { + SetErrorState(CameraHandle::GetErrorString(err), FROM_HERE); + return; + } +#endif + if (IsMobileProfile() && !IsEmulatorArch() && (camera_instance_->GetDeviceIndex() == CAMERA_DEVICE_CAMERA1)) { err = camera_instance_->CameraSetStreamFlip(CAMERA_FLIP_HORIZONTAL); @@ -841,6 +855,9 @@ void VideoCaptureDeviceTizen::OnStopAndDeAllocate() { else camera_instance_->CameraUnsetPreviewCb(); camera_instance_->CameraStopPreview(); +#if BUILDFLAG(IS_TIZEN_TV) + camera_instance_->CameraUnSetStateChangedCb(); +#endif if (IsMobileProfile()) ReleaseDisplayLock(); @@ -960,4 +977,31 @@ void VideoCaptureDeviceTizen::StopPreview() { SetErrorState(CameraHandle::GetErrorString(err), FROM_HERE); } +#if BUILDFLAG(IS_TIZEN_TV) +void VideoCaptureDeviceTizen::OnCameraStateChanged(camera_state_e previous, + camera_state_e current, + bool by_policy, + void* data) { + VideoCaptureDeviceTizen* video_capture_device_tizen = + static_cast(data); + if (!video_capture_device_tizen) { + LOG(ERROR) << "video_capture_device_tizen is null"; + return; + } + + content::BrowserMainLoop* browser_main_loop = + content::BrowserMainLoop::GetInstance(); + if (!browser_main_loop) { + LOG(ERROR) << "browser_main_loop is null"; + return; + } + content::MediaStreamManager* msm = browser_main_loop->media_stream_manager(); + if (!msm) { + LOG(ERROR) << "MediaStreamManager is null"; + return; + } + msm->NotifyMediaStateChanged(content::MediaInputStreamType::VIDEO_CAPTURE, + previous, current); +} +#endif } // namespace media diff --git a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h index da296e4..f10a00b 100644 --- a/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h +++ b/tizen_src/chromium_impl/media/capture/video/tizen/video_capture_device_tizen.h @@ -63,6 +63,13 @@ class VideoCaptureDeviceTizen : public VideoCaptureDevice, void* userData); static void CaptureCompletedCb(void* userData); +#if BUILDFLAG(IS_TIZEN_TV) + static void OnCameraStateChanged(camera_state_e previous, + camera_state_e current, + bool by_policy, + void* data); +#endif + void MaybeSuspend() override; void Resume() override; diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 5e33357..6c39a8d 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -102,6 +102,7 @@ #include "common/application_type.h" #include "devtools_port_manager.h" #include "public/ewk_media_downloadable_font_info.h" +#include "public/ewk_user_media_internal.h" #include "browser/mixed_content_observer.h" #endif @@ -3449,4 +3450,21 @@ bool EWebView::SetMixedContents(bool allow) { MixedContentObserver::FromWebContents(web_contents_.get()); return mixed_content_observer->MixedContentReply(allow); } + +void EWebView::NotifyMediaStateChanged(uint32_t device_type, + uint32_t previous, + uint32_t current) { + LOG(INFO) << "NotifyMediaStateChanged type : " << device_type + << " ;previous: " << previous << " ; current: " << current; + Ewk_User_Media_State_Info* user_media_state_info = + new _Ewk_User_Media_State_Info; + user_media_state_info->device_type = + static_cast(device_type); + user_media_state_info->previous_state = previous; + user_media_state_info->current_state = current; + SmartCallback().call( + static_cast(user_media_state_info)); + + delete user_media_state_info; +} #endif diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 2108ae3..87c9d0e 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -739,6 +739,9 @@ class EWebView { bool RWIInfoShowed() { return rwi_info_showed_; } GURL RWIURL() { return rwi_gurl_; } void OnDialogClosed(); + void NotifyMediaStateChanged(uint32_t type, + uint32_t previous, + uint32_t current); #endif // IS_TIZEN_TV void SetDidChangeThemeColorCallback( diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 98fdf55..ad3d799 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -208,6 +208,19 @@ WebContents* WebContentsDelegateEfl::OpenURLFromTab( return source; } +#if BUILDFLAG(IS_TIZEN_TV) +void WebContentsDelegateEfl::NotifyMediaStateChanged(uint32_t type, + uint32_t previous, + uint32_t current) { + if (!web_view_) { + LOG(ERROR) << "web_view_ is null"; + return; + } + + web_view_->NotifyMediaStateChanged(type, previous, current); +} +#endif + void WebContentsDelegateEfl::NavigationStateChanged( WebContents* source, InvalidateTypes changed_flags) { // We always notfiy clients about title invalidation, even if its text diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index 44cc7dd..5d0a080 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -138,6 +138,9 @@ class WebContentsDelegateEfl : public WebContentsDelegate { #if BUILDFLAG(IS_TIZEN_TV) void UpdateTargetURL(WebContents* source, const GURL& url) override; void ShowInspectorPortInfo(); + void NotifyMediaStateChanged(uint32_t type, + uint32_t previous, + uint32_t current) override; #endif #if defined(TIZEN_AUTOFILL) -- 2.7.4 From 52ff8f249822690c1d62d414ba32d90e5af60b98 Mon Sep 17 00:00:00 2001 From: "venu.musham" Date: Fri, 1 Mar 2024 11:53:46 +0530 Subject: [PATCH 03/16] fixup! RiscV support for M120. Clang setting was disabled for riscv build, due to this gcc build was enabled in QB, gcc build has complitation failures. Enable clang as default build for QB. Change-Id: I79b1b29205b4a14a9c72539cb401c187f97d1ba1 Signed-off-by: venu.musham --- packaging/chromium-efl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/chromium-efl.spec b/packaging/chromium-efl.spec index 5427994..bf7feab 100755 --- a/packaging/chromium-efl.spec +++ b/packaging/chromium-efl.spec @@ -224,7 +224,7 @@ BuildRequires: pkgconfig(capi-boost-tv) %define ARCHITECTURE riscv64 %endif -%{!?_clang: %define _clang 0} +%{!?_clang: %define _clang 1} %if "%{?gcov}" == "1" %define __enable_gcov 1 -- 2.7.4 From 150f9ae74e03fa94619f02f945c92236537953fd Mon Sep 17 00:00:00 2001 From: fang fengrong Date: Fri, 1 Mar 2024 19:08:25 +0800 Subject: [PATCH 04/16] [M120 Migration][VD] Support ewk apis of key event 1.Support ewk apis of key event in case some other application will use it. Support ewk_view_send_key_event & ewk_view_key_events_enabled_set. ewk_view_key_events_enabled_set: EINA_FALSE---delete keydown and keyup callback in chromium EINA_TRUE----add keydown and keyup callback in chromium If callback is delete, WRT use ewk_view_send_key_event to send keydown and keyup event to chromium. Currently WRT dose not use ewk interface, but we keep this API in case some other application will use it. 2.Add ewk_view_send_key_event to internal API header refer: https://review.tizen.org/gerrit/#/c/291454 Change-Id: I257fa7491efacb20b192fccfec1378d4630862cf Signed-off-by: fang fengrong --- .../renderer_host/rwhv_aura_common_helper_efl.cc | 12 +++ .../renderer_host/rwhv_aura_common_helper_efl.h | 3 + tizen_src/ewk/efl_integration/eweb_view.cc | 25 ++++++ tizen_src/ewk/efl_integration/eweb_view.h | 3 + tizen_src/ewk/efl_integration/public/ewk_view.cc | 20 ++++- .../ewk/efl_integration/public/ewk_view_internal.h | 14 ++++ tizen_src/ewk/unittest/BUILD.gn | 2 + ..._blink_ewk_view_key_events_enabled_set_func.cpp | 45 ++++++++++ .../utc_blink_ewk_view_send_key_event_func.cpp | 96 ++++++++++++++++++++++ 9 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_view_key_events_enabled_set_func.cpp create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_view_send_key_event_func.cpp diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc index 65adfd4..1f3a744 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.cc @@ -481,6 +481,18 @@ void RWHVAuraCommonHelperEfl::BackgroundColorReceived( web_contents_->GetDelegate()->BackgroundColorReceived(callback_id, bg_color); } +void RWHVAuraCommonHelperEfl::SetKeyEventsEnabled(bool enabled) { + if (auto* event_handler = GetEventHandler()) + event_handler->SetKeyEventsEnabled(enabled); +} + +void RWHVAuraCommonHelperEfl::SendKeyEvent(Evas_Object* ewk_view, + void* key_event, + bool is_press) { + if (auto* event_handler = GetEventHandler()) + event_handler->SendKeyEvent(ewk_view, key_event, is_press); +} + void RWHVAuraCommonHelperEfl::SetTouchEventsEnabled(bool enabled) { if (auto* event_handler = GetEventHandler()) event_handler->SetTouchEventsEnabled(enabled); diff --git a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h index 2576983..48bf752 100644 --- a/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h +++ b/tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_common_helper_efl.h @@ -120,6 +120,9 @@ class CONTENT_EXPORT RWHVAuraCommonHelperEfl { bool TouchEventsEnabled(); bool IsFocusedNodeContentEditable() const { return is_content_editable_; } + void SetKeyEventsEnabled(bool enabled); + void SendKeyEvent(Evas_Object* ewk_view, void* key_event, bool is_press); + void OnMouseOrTouchEvent(ui::Event* event); void FocusedNodeChanged(bool editable, #if BUILDFLAG(IS_TIZEN_TV) diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 6c39a8d..0b8b2a0 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -991,6 +991,31 @@ void EWebView::SetMouseEventsEnabled(bool enabled) { rwhva()->offscreen_helper()->SetTouchEventsEnabled(!enabled); } +bool EWebView::SetKeyEventsEnabled(bool enabled) { + if (!rwhva() || !rwhva()->aura_efl_helper()) { + LOG(WARNING) << "RWHV is not created yet!"; + return false; + } + + if (key_events_enabled_ == enabled) + return true; + + key_events_enabled_ = enabled; + rwhva()->aura_efl_helper()->SetKeyEventsEnabled(enabled); + return true; +} + +void EWebView::SendKeyEvent(Evas_Object* ewk_view, + void* key_event, + bool is_press) { + if (!rwhva() || !rwhva()->aura_efl_helper()) { + LOG(WARNING) << "RWHV is not created yet!"; + return; + } + + rwhva()->aura_efl_helper()->SendKeyEvent(ewk_view, key_event, is_press); +} + namespace { class JavaScriptCallbackDetails { diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 87c9d0e..9900db5 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -362,6 +362,8 @@ class EWebView { void SetTouchEventsEnabled(bool enabled); bool MouseEventsEnabled() const; void SetMouseEventsEnabled(bool enabled); + void SendKeyEvent(Evas_Object* ewk_view, void* key_event, bool is_press); + bool SetKeyEventsEnabled(bool enabled); void HandleTouchEvents(Ewk_Touch_Event_Type type, const Eina_List* points, const Evas_Modifier* modifiers); @@ -829,6 +831,7 @@ class EWebView { std::unique_ptr<_Ewk_Policy_Decision> window_policy_; Evas_Object* ewk_view_; Evas_Object* efl_main_layout_; + bool key_events_enabled_ = true; bool mouse_events_enabled_; double text_zoom_factor_; mutable std::string user_agent_; diff --git a/tizen_src/ewk/efl_integration/public/ewk_view.cc b/tizen_src/ewk/efl_integration/public/ewk_view.cc index 5d0c309..10b1b1a 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_view.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_view.cc @@ -1448,8 +1448,13 @@ void ewk_view_force_layout(const Evas_Object* o) } Eina_Bool ewk_view_send_key_event(Evas_Object* ewk_view, void* key_event, Eina_Bool is_press) { - LOG_EWK_API_MOCKUP(); - return false; + EWK_VIEW_IMPL_GET_OR_RETURN(ewk_view, impl, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(key_event, EINA_FALSE); +#if BUILDFLAG(IS_TIZEN_TV) + LOG(INFO) << "view: " << ewk_view << ", is_press :" << (bool)is_press; +#endif + impl->SendKeyEvent(ewk_view, key_event, !!is_press); + return EINA_TRUE; } Eina_Bool ewk_view_tts_mode_set(Evas_Object* view, ewk_tts_mode tts_mode) { @@ -1546,8 +1551,15 @@ Eina_Bool ewk_view_bg_color_set(Evas_Object* o, int r, int g, int b, int a) { } Eina_Bool ewk_view_key_events_enabled_set(Evas_Object* o, Eina_Bool enabled) { - LOG_EWK_API_MOCKUP(); - return false; +#if BUILDFLAG(IS_TIZEN_TV) + EWK_VIEW_IMPL_GET_OR_RETURN(o, impl, EINA_FALSE); + LOG(INFO)<< "ewk_view_key_events_enabled_set, enabled: " << (bool)enabled; + return impl->SetKeyEventsEnabled(!!enabled); +#else + LOG_EWK_API_MOCKUP("This API is only available in Tizen TV product."); + return EINA_FALSE; +#endif + } Eina_Bool ewk_view_bg_color_get(Evas_Object* view, diff --git a/tizen_src/ewk/efl_integration/public/ewk_view_internal.h b/tizen_src/ewk/efl_integration/public/ewk_view_internal.h index a7ba801..d57cc5a 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_view_internal.h +++ b/tizen_src/ewk/efl_integration/public/ewk_view_internal.h @@ -1505,6 +1505,20 @@ EXPORT_API void ewk_view_feed_mouse_wheel(Evas_Object* o, int x, int y); +/** + * @brief Sends key event. + * + * @since_tizen 2.4 + * + * @param[in] o The view object + * @param[in] key_event Evas_Event_Key_Down struct or Evas_Event_Key_Up struct + * @param[in] is_press EINA_TRUE: keydown, EINA_FALSE: keyup + * @return @c EINA_TRUE on success, otherwise @c EINA_FALSE + */ +EXPORT_API Eina_Bool ewk_view_send_key_event(Evas_Object* o, + void* key_event, + Eina_Bool is_press); + EXPORT_API void ewk_view_media_device_list_get(Evas_Object* o, Ewk_Media_Device_List_Get_Callback callback, void* user_data); #ifdef __cplusplus diff --git a/tizen_src/ewk/unittest/BUILD.gn b/tizen_src/ewk/unittest/BUILD.gn index e4fd33b..4eb65733 100644 --- a/tizen_src/ewk/unittest/BUILD.gn +++ b/tizen_src/ewk/unittest/BUILD.gn @@ -333,6 +333,7 @@ test("ewk_unittests") { "utc_blink_ewk_view_html_string_load_func.cpp", "utc_blink_ewk_view_inspector_server_stop_func.cpp", "utc_blink_ewk_view_javascript_confirm_reply_func.cpp", + "utc_blink_ewk_view_key_events_enabled_set_func.cpp", "utc_blink_ewk_view_load_progress_get_func.cpp", "utc_blink_ewk_view_main_frame_get_func.cpp", "utc_blink_ewk_view_main_frame_scrollbar_visible_set_func.cpp", @@ -355,6 +356,7 @@ test("ewk_unittests") { "utc_blink_ewk_view_scroll_pos_get_func.cpp", "utc_blink_ewk_view_scroll_set_func.cpp", "utc_blink_ewk_view_scroll_size_get_func.cpp", + "utc_blink_ewk_view_send_key_event_func.cpp", "utc_blink_ewk_view_session_data_get_func.cpp", "utc_blink_ewk_view_settings_get_func.cpp", "utc_blink_ewk_view_stop_func.cpp", diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_view_key_events_enabled_set_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_view_key_events_enabled_set_func.cpp new file mode 100644 index 0000000..f22c2e3 --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_view_key_events_enabled_set_func.cpp @@ -0,0 +1,45 @@ +// Copyright 2024 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +class utc_blink_ewk_view_key_events_enabled_set : public utc_blink_ewk_base {}; + +/** + * @brief Check if enable keydown & keyup callback is succeeds with + * correct webview + */ +TEST_F(utc_blink_ewk_view_key_events_enabled_set, POS_KEY_EVENTS_ENABLE) { + Eina_Bool result = + ewk_view_key_events_enabled_set(GetEwkWebView(), EINA_TRUE); + EXPECT_EQ(EINA_TRUE, result); +} + +/** + * @brief Check if disable keydown & keyup callback is succeeds with + * correct webview + */ +TEST_F(utc_blink_ewk_view_key_events_enabled_set, POS_KEY_EVENTS_DISABLE) { + Eina_Bool result = + ewk_view_key_events_enabled_set(GetEwkWebView(), EINA_FALSE); + EXPECT_EQ(EINA_TRUE, result); +} + +/** + * @brief Check if enable keydown & keyup callback is fails with + * null webview + */ +TEST_F(utc_blink_ewk_view_key_events_enabled_set, NEG_KEY_EVENTS_ENABLE) { + Eina_Bool result = ewk_view_key_events_enabled_set(NULL, EINA_TRUE); + EXPECT_EQ(EINA_FALSE, result); +} + +/** + * @brief Check if disable keydown & keyup callback is fails with + * null webview + */ +TEST_F(utc_blink_ewk_view_key_events_enabled_set, NEG_KEY_EVENTS_DISABLE) { + Eina_Bool result = ewk_view_key_events_enabled_set(NULL, EINA_FALSE); + EXPECT_EQ(EINA_FALSE, result); +} diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_view_send_key_event_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_view_send_key_event_func.cpp new file mode 100644 index 0000000..13ca44f --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_view_send_key_event_func.cpp @@ -0,0 +1,96 @@ +// Copyright 2024 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +class utc_blink_ewk_view_send_key_event : public utc_blink_ewk_base { + protected: + utc_blink_ewk_view_send_key_event() + : utc_blink_ewk_base(), space_str("space") {} + + // get Evas_Event_Key_Down + Evas_Event_Key_Down GetKeyDown() { + Evas_Event_Key_Down down_event; + memset(&down_event, 0, sizeof(Evas_Event_Key_Down)); + down_event.key = space_str.c_str(); + down_event.string = space_str.c_str(); + return down_event; + } + + // get Evas_Event_Key_Up + Evas_Event_Key_Up GetKeyUp() { + Evas_Event_Key_Up up_event; + memset(&up_event, 0, sizeof(Evas_Event_Key_Up)); + up_event.key = space_str.c_str(); + up_event.string = space_str.c_str(); + return up_event; + } + + protected: + std::string space_str; +}; + +/** + * @brief Check if send key down event is succeeds with + * correct webview. + */ +TEST_F(utc_blink_ewk_view_send_key_event, POS_SEND_KEY_DOWN_EVENT) { + Evas_Event_Key_Down down_event = GetKeyDown(); + void* key_event = static_cast(&down_event); + Eina_Bool result = + ewk_view_send_key_event(GetEwkWebView(), key_event, EINA_TRUE); + EXPECT_EQ(EINA_TRUE, result); +} + +/** + * @brief Check if send key up event is succeeds with + * correct webview. + */ +TEST_F(utc_blink_ewk_view_send_key_event, POS_SEND_KEY_UP_EVENT) { + Evas_Event_Key_Up up_event = GetKeyUp(); + void* key_event = static_cast(&up_event); + Eina_Bool result = + ewk_view_send_key_event(GetEwkWebView(), key_event, EINA_FALSE); + EXPECT_EQ(EINA_TRUE, result); +} + +/** + * @brief Check if send key up event is fails with + * null webview. + */ +TEST_F(utc_blink_ewk_view_send_key_event, NEG_SEND_KEY_UP_EVENT) { + Evas_Event_Key_Up up_event = GetKeyUp(); + void* key_event = static_cast(&up_event); + Eina_Bool result = ewk_view_send_key_event(NULL, key_event, EINA_FALSE); + EXPECT_EQ(EINA_FALSE, result); +} + +/** + * @brief Check if send key down event is fails with + * null webview. + */ +TEST_F(utc_blink_ewk_view_send_key_event, NEG_SEND_KEY_DOWN_EVENT) { + Evas_Event_Key_Down down_event = GetKeyDown(); + void* key_event = static_cast(&down_event); + Eina_Bool result = ewk_view_send_key_event(NULL, key_event, EINA_TRUE); + EXPECT_EQ(EINA_FALSE, result); +} + +/** + * @brief Check if send null key up event is fails with + * null webview. + */ +TEST_F(utc_blink_ewk_view_send_key_event, NEG_SEND_KEY_UP_EVENT_WITH_NULL) { + Eina_Bool result = ewk_view_send_key_event(NULL, NULL, EINA_FALSE); + EXPECT_EQ(EINA_FALSE, result); +} + +/** + * @brief Check if send null key up event is fails with + * correct webview. + */ +TEST_F(utc_blink_ewk_view_send_key_event, NEG_SEND_KEY_DOWN_EVENT_WITH_NULL) { + Eina_Bool result = ewk_view_send_key_event(GetEwkWebView(), NULL, EINA_FALSE); + EXPECT_EQ(EINA_FALSE, result); +} -- 2.7.4 From c224cdc7a589e297c264c5d989ba203e46e4e71f Mon Sep 17 00:00:00 2001 From: "zhishun.zhou" Date: Fri, 1 Mar 2024 17:49:39 +0800 Subject: [PATCH 05/16] [M120 Migration] Destroy mmplayer while video tag receive removedFrom issue:when exit app, video is still on screen. solution: when exit app, destroy the player. Patch from: https://review.tizen.org/gerrit/#/c/301621/ Change-Id: I1d21cba123b08ed69dc098a500a00e11486ff0bb Signed-off-by: yangzhiwen Signed-off-by: zhishun.zhou --- .../blink/renderer/core/html/media/html_media_element.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/third_party/blink/renderer/core/html/media/html_media_element.cc b/third_party/blink/renderer/core/html/media/html_media_element.cc index 3974d21..6c6014b 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element.cc @@ -4630,6 +4630,20 @@ void HTMLMediaElement::OnRemovedFromDocumentTimerFired(TimerBase*) { // removed from the Document. if (!PictureInPictureController::IsElementInPictureInPicture(this)) PauseInternal(PlayPromiseError::kPaused_RemovedFromDocument); +#if BUILDFLAG(IS_TIZEN_TV) + if (!media_source_attachment_) { + LOG(INFO) << "(" << (void*)this << ")" + << "HTMLMediaElement::removedFrom(clear)"; + ClearMediaPlayer(); + network_state_ = kNetworkEmpty; + ready_state_ = kHaveNothing; + ready_state_maximum_ = kHaveNothing; + seeking_ = false; + // Clear any pending events + SetShouldDelayLoadEvent(false); + async_event_queue_->CancelAllEvents(); + } +#endif } void HTMLMediaElement::AudioSourceProviderImpl::Wrap( -- 2.7.4 From 314b54993cb5f505b74891b4ff7a9969670414d1 Mon Sep 17 00:00:00 2001 From: yangzhiwen Date: Thu, 29 Feb 2024 14:40:01 +0800 Subject: [PATCH 06/16] [M120 Migration] Support Dash high bitrate void ewk_media_start_with_high_bit_rate(Evas_Object* ewkView, Eina_Bool high_bitrate) This API was added so that Dash streams can support Dash high bitrate. Process the URL of the video. migrate from: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/292658/ Change-Id: Ic452e289854b7efbca6ccb958f8a8f68eca3e7b2 Signed-off-by: yangzhiwen --- content/public/browser/web_contents_delegate.h | 2 ++ .../content/browser/media/tizen_renderer_impl.cc | 12 +++++++ .../content/browser/media/tizen_renderer_impl.h | 4 +++ .../media/base/efl/media_player_util_efl.h | 8 +++++ .../media/filters/media_player_bridge_capi_tv.cc | 37 ++++++++++++++++++++++ .../media/filters/media_player_bridge_capi_tv.h | 11 +++++++ .../media/filters/media_player_tizen.h | 2 ++ .../media/filters/media_player_tizen_client.h | 5 +++ tizen_src/ewk/efl_integration/eweb_view.cc | 5 +++ tizen_src/ewk/efl_integration/eweb_view.h | 3 ++ tizen_src/ewk/efl_integration/public/ewk_view.cc | 9 ++++-- .../efl_integration/web_contents_delegate_efl.cc | 4 +++ .../efl_integration/web_contents_delegate_efl.h | 1 + 13 files changed, 101 insertions(+), 2 deletions(-) diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index e7cdfd4..3798652 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -739,7 +739,9 @@ class CONTENT_EXPORT WebContentsDelegate { virtual void NotifyMediaStateChanged(uint32_t type, uint32_t previous, uint32_t current) {}; + virtual bool IsHighBitRate() const { return false; } #endif + #if BUILDFLAG(IS_ANDROID) // Updates information to determine whether a user gesture should carryover to // future navigations. This is needed so navigations within a certain 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 e3bfcf1..e380885 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 @@ -361,6 +361,18 @@ void TizenRendererImpl::Suspend() { is_suspended_ = true; } +#if BUILDFLAG(IS_TIZEN_TV) +content::WebContentsDelegate* TizenRendererImpl::GetWebContentsDelegate() + const { + content::WebContents* web_contents = GetWebContents(); + if (!web_contents) { + LOG(ERROR) << "web_contents is nullptr"; + return nullptr; + } + return web_contents->GetDelegate(); +} +#endif + void TizenRendererImpl::ToggleFullscreenMode(bool is_fullscreen, ToggledFullscreenCB cb) { if (media_player_) 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 13af303..bac0971 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 @@ -128,6 +128,10 @@ class CONTENT_EXPORT TizenRendererImpl uint32_t height) override; #endif +#if BUILDFLAG(IS_TIZEN_TV) + content::WebContentsDelegate* GetWebContentsDelegate() const override; +#endif + #if defined(TIZEN_VIDEO_HOLE) void SetVideoHole(bool is_video_hole) final; void SetMediaGeometry(const gfx::RectF& rect) final; diff --git a/tizen_src/chromium_impl/media/base/efl/media_player_util_efl.h b/tizen_src/chromium_impl/media/base/efl/media_player_util_efl.h index 2f74670..00cd6dd 100644 --- a/tizen_src/chromium_impl/media/base/efl/media_player_util_efl.h +++ b/tizen_src/chromium_impl/media/base/efl/media_player_util_efl.h @@ -10,6 +10,14 @@ #include "media/base/media_export.h" #include "url/gurl.h" +#define BLINKFREE(p) \ + do { \ + if (p) { \ + delete[] p; \ + p = 0; \ + } \ + } while (0) + namespace media { struct MediaFormatDeleter { diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc index 7cfb666..1a05845 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc @@ -4,6 +4,7 @@ #include "media/filters/media_player_bridge_capi_tv.h" +#include "media/base/efl/media_player_util_efl.h" #include "tizen_src/chromium_impl/media/filters/media_player_tizen_client.h" namespace { @@ -31,6 +32,8 @@ void MediaPlayerBridgeCapiTV::SetContentMimeType(const std::string& mime_type) { } void MediaPlayerBridgeCapiTV::Prepare() { + if (blink::IsHbbTV() && CheckHighBitRate() && stream_type_ == DASH_STREAM) + AppendUrlHighBitRate(url_.spec()); MediaPlayerBridgeCapi::Prepare(); } @@ -172,4 +175,38 @@ bool MediaPlayerBridgeCapiTV::GetLiveStreamingDuration(int64_t* min, return true; } +void MediaPlayerBridgeCapiTV::AppendUrlHighBitRate(const std::string& url) { + // don't use url.append("|STARTBITRATE=HIGHEST") to get hbbtv url + // "|" will be replaced with "%7C" + const char high_bitrate[] = "|STARTBITRATE=HIGHEST"; + int len = url.length() + strlen(high_bitrate) + 1; + char* str_url = new char[len]; + if (!str_url) { + return; + } + + memset(str_url, 0, len); + strncat(str_url, url.c_str(), url.length()); + strncat(str_url, high_bitrate, strlen(high_bitrate)); + hbbtv_url_ = str_url; + BLINKFREE(str_url); + LOG(INFO) << "hbbtv url:" << hbbtv_url_.c_str(); +} + +bool MediaPlayerBridgeCapiTV::CheckHighBitRate() { + if (!GetMediaPlayerClient()) { + LOG(ERROR) << "MediaPlayerClient is null"; + return false; + } + content::WebContentsDelegate* web_contents_delegate = + GetMediaPlayerClient()->GetWebContentsDelegate(); + if (!web_contents_delegate) { + LOG(ERROR) << "get web_contents_delegate fail"; + return false; + } + bool ret = web_contents_delegate->IsHighBitRate(); + LOG(INFO) << "get high bit rate: " << std::boolalpha << ret; + return ret; +} + } // namespace media diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h index b6c5a16..eeeba28 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h @@ -11,6 +11,13 @@ namespace media { +enum StreamType { + HLS_STREAM = 0, + DASH_STREAM, + TS_STREAM, + OTHER_STREAM, +}; + // This class is focus on HBBTV/HLS feature on Tizen TV. class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi { public: @@ -24,6 +31,8 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi { void Release() override; void SetContentMimeType(const std::string& mime_type) override; void PlaybackCompleteUpdate() override; + void AppendUrlHighBitRate(const std::string& url); + bool CheckHighBitRate(); protected: void PlayerPrepared() override; @@ -36,6 +45,8 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi { void UpdateSeekableTime(); bool GetLiveStreamingDuration(int64_t* min, int64_t* max); + StreamType stream_type_{OTHER_STREAM}; + std::string hbbtv_url_{""}; // url_ + HIGHBITRATE(if mpd) std::string mime_type_ = ""; bool is_live_stream_ = false; diff --git a/tizen_src/chromium_impl/media/filters/media_player_tizen.h b/tizen_src/chromium_impl/media/filters/media_player_tizen.h index defac69..c097ec1 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_tizen.h +++ b/tizen_src/chromium_impl/media/filters/media_player_tizen.h @@ -9,6 +9,7 @@ #include "base/task/single_thread_task_runner.h" #include "media/base/demuxer_stream.h" #include "media/filters/flags.h" +#include "third_party/blink/public/platform/web_application_type.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/tbm_buffer_handle.h" @@ -71,6 +72,7 @@ class MEDIA_EXPORT MediaPlayerTizen { virtual void SetVolume(double volume) = 0; virtual base::TimeDelta GetCurrentTime() = 0; + virtual MediaPlayerTizenClient* GetMediaPlayerClient() const {return nullptr;} virtual void ToggleFullscreenMode(bool is_fullscreen) {} #if defined(TIZEN_TBM_SUPPORT) diff --git a/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h b/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h index d98b4d9..71cb20d 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h +++ b/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h @@ -5,6 +5,7 @@ #ifndef MEDIA_FILTERS_MEDIA_PLAYER_TIZEN_CLIENT_H_ #define MEDIA_FILTERS_MEDIA_PLAYER_TIZEN_CLIENT_H_ +#include "content/public/browser/web_contents_delegate.h" #include "media/base/audio_decoder_config.h" #include "media/base/pipeline_status.h" #include "media/base/video_decoder_config.h" @@ -52,6 +53,10 @@ class MEDIA_EXPORT MediaPlayerTizenClient { uint32_t width, uint32_t height) = 0; #endif + +#if BUILDFLAG(IS_TIZEN_TV) + virtual content::WebContentsDelegate* GetWebContentsDelegate() const = 0; +#endif }; } // namespace media diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 0b8b2a0..bef9a78 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -3492,4 +3492,9 @@ void EWebView::NotifyMediaStateChanged(uint32_t device_type, delete user_media_state_info; } + +void EWebView::SetHighBitRate(Eina_Bool high_bitrate) { + LOG(INFO) << "high_bitrate: " << std::boolalpha << high_bitrate; + is_high_bitrate_ = high_bitrate; +} #endif diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 9900db5..1662c18 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -744,6 +744,8 @@ class EWebView { void NotifyMediaStateChanged(uint32_t type, uint32_t previous, uint32_t current); + void SetHighBitRate(Eina_Bool is_high_bitrate); + bool IsHighBitRate() const { return is_high_bitrate_; } #endif // IS_TIZEN_TV void SetDidChangeThemeColorCallback( @@ -940,6 +942,7 @@ class EWebView { bool use_early_rwi_; bool rwi_info_showed_; GURL rwi_gurl_; + bool is_high_bitrate_ = false; base::OnceClosure pending_setfocus_closure_; #endif diff --git a/tizen_src/ewk/efl_integration/public/ewk_view.cc b/tizen_src/ewk/efl_integration/public/ewk_view.cc index 10b1b1a..27c36b5 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_view.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_view.cc @@ -1732,9 +1732,14 @@ void ewk_media_set_parental_rating_result(Evas_Object* ewkView, const char* url, LOG_EWK_API_MOCKUP(); } -void ewk_media_start_with_high_bit_rate(Evas_Object* ewkView, Eina_Bool is_high_bitrate) +void ewk_media_start_with_high_bit_rate(Evas_Object* ewkView, Eina_Bool high_bitrate) { - LOG_EWK_API_MOCKUP(); +#if BUILDFLAG(IS_TIZEN_TV) + EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl); + impl->SetHighBitRate(high_bitrate); +#else + LOG_EWK_API_MOCKUP("Only for Tizen TV."); +#endif } double ewk_view_media_current_time_get(const Evas_Object *o) diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index ad3d799..18fb985 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -778,5 +778,9 @@ void WebContentsDelegateEfl::DidEdgeScrollBy(const gfx::Point& offset, if (web_view_) web_view_->InvokeEdgeScrollByCallback(offset, handled); } + +bool WebContentsDelegateEfl::IsHighBitRate() const { + return web_view_ ? web_view_->IsHighBitRate() : false; +} #endif } // namespace content diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index 5d0a080..9eca28d 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -141,6 +141,7 @@ class WebContentsDelegateEfl : public WebContentsDelegate { void NotifyMediaStateChanged(uint32_t type, uint32_t previous, uint32_t current) override; + bool IsHighBitRate() const override; #endif #if defined(TIZEN_AUTOFILL) -- 2.7.4 From 412ded7eb917bb71d73810b8e969e4254f8653dd Mon Sep 17 00:00:00 2001 From: Akshay Kanagali Date: Fri, 1 Mar 2024 14:06:11 +0530 Subject: [PATCH 07/16] fixup! [M120 Migration] Show the context menu and settings menu This patch disables the function call updateFocus in EflWindow::InitializeEventHandler for only chrome build which impacts settings menu and enables for other builds. Change-Id: I7a5613a2a1185a16c7e8ea2c91ce79c72793a232 Signed-off-by: Akshay Kanagali --- tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc index ad2ebe0..af45ee1 100644 --- a/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc +++ b/tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.cc @@ -477,6 +477,10 @@ void EflWindow::InitializeEventHandler() { // Set activation true on window to capture key events. delegate_->OnActivationChanged(true /*active*/); + // Set focus active for a newly opened window. +#if !defined(BUILD_CHROME) + UpdateFocus(true); +#endif efl_event_handler_ = std::make_unique(this); PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); } -- 2.7.4 From 5e63ff92bb08c8bf0a01a6ec52496b100b34364d Mon Sep 17 00:00:00 2001 From: jiangyuwei Date: Tue, 5 Mar 2024 06:33:47 +0800 Subject: [PATCH 08/16] [M120 Migration][VD] Add ewk_file_chooser_request APIs Evas smart callback, "file,chooser,request", has not been supported since Tizen 3.0. This patch implements ewk_file_chooser_request APIs to suport "file,chooser,request". API spec is same as Tizen 2.4(WebKit). - ewk_file_chooser_request_allow_multiple_files_get - ewk_file_chooser_request_accepted_mimetypes_get - ewk_file_chooser_request_cancel - ewk_file_chooser_request_files_choose - ewk_file_chooser_request_file_choose Reference: - https://review.tizen.org/gerrit/#/c/292148/ Change-Id: I62bb4192d615099f84766b2be5a29af0387ab3ee Signed-off-by: jiangyuwei --- .../blink/renderer/core/page/chrome_client_impl.cc | 13 +- tizen_src/ewk/efl_integration/BUILD.gn | 8 +- tizen_src/ewk/efl_integration/eweb_view.cc | 99 +------ tizen_src/ewk/efl_integration/eweb_view.h | 19 +- .../ewk/efl_integration/eweb_view_callbacks.h | 8 +- .../efl_integration/file_chooser_controller_efl.cc | 326 ++++++++++++++++++--- .../efl_integration/file_chooser_controller_efl.h | 47 +-- .../private/ewk_file_chooser_request_private.cc | 74 +++++ .../private/ewk_file_chooser_request_private.h | 44 +++ .../ewk/efl_integration/public/EWebKit_product.h | 1 + .../public/ewk_file_chooser_request.cc | 70 +++++ .../public/ewk_file_chooser_request_product.h | 108 +++++++ .../efl_integration/web_contents_delegate_efl.cc | 2 +- tizen_src/ewk/unittest/BUILD.gn | 5 + .../ewk_file_chooser_request/file_chooser.html | 9 + tizen_src/ewk/unittest/utc_blink_ewk_base.cpp | 11 + tizen_src/ewk/unittest/utc_blink_ewk_base.h | 4 +- ...chooser_request_accepted_mimetypes_get_func.cpp | 66 +++++ ...ooser_request_allow_multiple_files_get_func.cpp | 60 ++++ ..._blink_ewk_file_chooser_request_cancel_func.cpp | 52 ++++ ...k_ewk_file_chooser_request_file_choose_func.cpp | 53 ++++ ..._ewk_file_chooser_request_files_choose_func.cpp | 60 ++++ 22 files changed, 968 insertions(+), 171 deletions(-) create mode 100644 tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.cc create mode 100644 tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.h create mode 100644 tizen_src/ewk/efl_integration/public/ewk_file_chooser_request.cc create mode 100644 tizen_src/ewk/efl_integration/public/ewk_file_chooser_request_product.h create mode 100644 tizen_src/ewk/unittest/resources/ewk_file_chooser_request/file_chooser.html create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func.cpp create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func.cpp create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_cancel_func.cpp create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_file_choose_func.cpp create mode 100644 tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_files_choose_func.cpp diff --git a/third_party/blink/renderer/core/page/chrome_client_impl.cc b/third_party/blink/renderer/core/page/chrome_client_impl.cc index b7b83e0..bb971315 100644 --- a/third_party/blink/renderer/core/page/chrome_client_impl.cc +++ b/third_party/blink/renderer/core/page/chrome_client_impl.cc @@ -764,6 +764,9 @@ void ChromeClientImpl::OpenFileChooser( NotifyPopupOpeningObservers(); static const wtf_size_t kMaximumPendingFileChooseRequests = 4; +#if BUILDFLAG(IS_TIZEN_TV) + LOG(INFO) << "OpenFileChooser, queue size : " << file_chooser_queue_.size(); +#endif if (file_chooser_queue_.size() > kMaximumPendingFileChooseRequests) { // This check prevents too many file choose requests from getting // queued which could DoS the user. Getting these is most likely a @@ -778,14 +781,22 @@ void ChromeClientImpl::OpenFileChooser( file_chooser_queue_.push_back(file_chooser.get()); if (file_chooser_queue_.size() == 1) { // Actually show the browse dialog when this is the first request. - if (file_chooser->OpenFileChooser(*this)) + if (file_chooser->OpenFileChooser(*this)) { +#if BUILDFLAG(IS_TIZEN_TV) + file_chooser_queue_.EraseAt(0); +#endif return; + } // Choosing failed, so try the next chooser. DidCompleteFileChooser(*file_chooser); } } void ChromeClientImpl::DidCompleteFileChooser(FileChooser& chooser) { +#if BUILDFLAG(IS_TIZEN_TV) + if (file_chooser_queue_.empty()) + return; +#endif if (!file_chooser_queue_.empty() && file_chooser_queue_.front().get() != &chooser) { // This function is called even if |chooser| wasn't stored in diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index 2a48e3e..aebebfd 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -278,6 +278,8 @@ shared_library("chromium-ewk") { "eweb_view_callbacks.h", "ewk_global_data.cc", "ewk_global_data.h", + "file_chooser_controller_efl.cc", + "file_chooser_controller_efl.h", "geolocation_permission_popup.cc", "geolocation_permission_popup.h", "http_user_agent_settings_efl.cc", @@ -415,6 +417,8 @@ shared_library("chromium-ewk") { "private/ewk_error_private.cc", "private/ewk_error_private.h", "private/ewk_favicon_database_private.h", + "private/ewk_file_chooser_request_private.cc", + "private/ewk_file_chooser_request_private.h", "private/ewk_frame_private.cc", "private/ewk_frame_private.h", "private/ewk_geolocation_private.cc", @@ -508,6 +512,8 @@ shared_library("chromium-ewk") { "public/ewk_export.h", "public/ewk_favicon_database.cc", "public/ewk_favicon_database_internal.h", + "public/ewk_file_chooser_request.cc", + "public/ewk_file_chooser_request_product.h", "public/ewk_form_repost_decision.cc", "public/ewk_form_repost_decision_product.h", "public/ewk_frame.cc", @@ -690,8 +696,6 @@ shared_library("chromium-ewk") { "browser/quota_permission_context_efl.cc", "browser/quota_permission_context_efl.h", "chromium_ewk.gypi", - "file_chooser_controller_efl.cc", - "file_chooser_controller_efl.h", "renderer/plugins/hole_layer.cc", "renderer/plugins/hole_layer.h", "renderer/plugins/plugin_placeholder_avplayer.cc", diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index bef9a78..98e9661 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -9,7 +9,6 @@ #include #include "base/command_line.h" -#include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/functional/bind.h" #include "base/json/json_string_value_serializer.h" @@ -99,11 +98,12 @@ #endif #if BUILDFLAG(IS_TIZEN_TV) +#include "browser/mixed_content_observer.h" #include "common/application_type.h" #include "devtools_port_manager.h" +#include "private/ewk_file_chooser_request_private.h" #include "public/ewk_media_downloadable_font_info.h" #include "public/ewk_user_media_internal.h" -#include "browser/mixed_content_observer.h" #endif #if defined(TIZEN_PEPPER_EXTENSIONS) @@ -2512,28 +2512,20 @@ bool EWebView::IsDragging() const { return wcva()->wcva_helper()->IsDragging(); } -void EWebView::ShowFileChooser(content::RenderFrameHost* render_frame_host, - const blink::mojom::FileChooserParams& params) { +void EWebView::ShowFileChooser( + scoped_refptr listener, + const blink::mojom::FileChooserParams& params) { +#if BUILDFLAG(IS_TIZEN_TV) + LOG(INFO) << "File chooser request callback."; + file_chooser_request_.reset(new _Ewk_File_Chooser_Request( + std::move(listener), params.accept_types, params.mode)); + SmartCallback().call( + file_chooser_request_.get()); +#else if (!IsMobileProfile() && !IsWearableProfile()) return; - -#if !defined(EWK_BRINGUP) // FIXME: m71 bringup - if (params.capture) { - const std::string capture_types[] = {"video/*", "audio/*", "image/*"}; - unsigned int capture_types_num = - sizeof(capture_types) / sizeof(*capture_types); - for (unsigned int i = 0; i < capture_types_num; ++i) { - for (unsigned int j = 0; j < params.accept_types.size(); ++j) { - if (UTF16ToUTF8(params.accept_types[j]) == capture_types[i]) { - filechooser_mode_ = params.mode; - LaunchCamera(params.accept_types[j]); - return; - } - } - } - } file_chooser_.reset( - new content::FileChooserControllerEfl(render_frame_host, ¶ms)); + new content::FileChooserControllerEfl(std::move(listener), params)); file_chooser_->Open(); #endif } @@ -2880,71 +2872,6 @@ void EWebView::InitializeWindowTreeHost() { host_view->SetSize(bounds.size()); } -#if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP) -void EWebView::cameraResultCb(service_h request, - service_h reply, - service_result_e result, - void* data) { - if (!IsMobileProfile() && !IsWearableProfile()) - return; - - EWebView* webview = static_cast(data); - RenderViewHost* render_view_host = - webview->web_contents_->GetRenderViewHost(); - if (result == SERVICE_RESULT_SUCCEEDED) { - int ret = -1; - char** filesarray; - int number; - ret = service_get_extra_data_array(reply, SERVICE_DATA_SELECTED, - &filesarray, &number); - if (filesarray) { - for (int i = 0; i < number; i++) { - std::vector files; - if (!render_view_host) { - return; - } - if (filesarray[i]) { - GURL url(filesarray[i]); - if (!url.is_valid()) { - base::FilePath path(url.SchemeIsFile() ? url.path() - : filesarray[i]); - files.push_back(ui::SelectedFileInfo(path, base::FilePath())); - } - } - render_view_host->FilesSelectedInChooser(files, - webview->filechooser_mode_); - } - } - } else { - std::vector files; - if (render_view_host) { - render_view_host->FilesSelectedInChooser(files, - webview->filechooser_mode_); - } - } -} - -bool EWebView::LaunchCamera(std::u16string mimetype) { - service_h svcHandle = 0; - if (service_create(&svcHandle) < 0 || !svcHandle) { - LOG(ERROR) << __FUNCTION__ << " Service Creation Failed "; - return false; - } - service_set_operation(svcHandle, SERVICE_OPERATION_CREATE_CONTENT); - service_set_mime(svcHandle, UTF16ToUTF8(mimetype).c_str()); - service_add_extra_data(svcHandle, "CALLER", "Browser"); - - int ret = service_send_launch_request(svcHandle, cameraResultCb, this); - if (ret != SERVICE_ERROR_NONE) { - LOG(ERROR) << __FUNCTION__ << " Service Launch Failed "; - service_destroy(svcHandle); - return false; - } - service_destroy(svcHandle); - return true; -} -#endif - void EWebView::UrlRequestSet( const char* url, content::NavigationController::LoadURLType loadtype, diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 1662c18..f870b65 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -86,6 +86,10 @@ class _Ewk_Hit_Test; class Ewk_Context; class _Ewk_Quota_Permission_Request; +#if BUILDFLAG(IS_TIZEN_TV) +struct _Ewk_File_Chooser_Request; +#endif + #if defined(TIZEN_ATK_SUPPORT) class EWebAccessibility; #endif @@ -589,7 +593,7 @@ class EWebView { void GetSessionData(const char** data, unsigned* length) const; bool RestoreFromSessionData(const char* data, unsigned length); - void ShowFileChooser(content::RenderFrameHost* render_frame_host, + void ShowFileChooser(scoped_refptr listener, const blink::mojom::FileChooserParams&); void SetBrowserFont(); bool IsDragging() const; @@ -777,15 +781,6 @@ class EWebView { void RunPendingSetFocus(Eina_Bool focus); #endif -#if BUILDFLAG(IS_TIZEN) && !defined(EWK_BRINGUP) - static void cameraResultCb(service_h request, - service_h reply, - service_result_e result, - void* data); - - bool LaunchCamera(std::u16string mimetype); -#endif - JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl(); // Changes viewport without resizing Evas_Object representing webview @@ -842,7 +837,9 @@ class EWebView { std::string selected_text_cached_; std::unique_ptr context_menu_; -#if !defined(EWK_BRINGUP) // FIXME: m71 bringup +#if BUILDFLAG(IS_TIZEN_TV) + std::unique_ptr<_Ewk_File_Chooser_Request> file_chooser_request_; +#else std::unique_ptr file_chooser_; #endif std::unique_ptr popup_controller_; diff --git a/tizen_src/ewk/efl_integration/eweb_view_callbacks.h b/tizen_src/ewk/efl_integration/eweb_view_callbacks.h index be7eaf7..8b5b2e2 100644 --- a/tizen_src/ewk/efl_integration/eweb_view_callbacks.h +++ b/tizen_src/ewk/efl_integration/eweb_view_callbacks.h @@ -34,9 +34,9 @@ #include "private/ewk_geolocation_private.h" #include "private/ewk_policy_decision_private.h" #include "private/ewk_user_media_private.h" - #if BUILDFLAG(IS_TIZEN_TV) #include "private/ewk_autofill_profile_private.h" +#include "private/ewk_file_chooser_request_private.h" #endif typedef struct EwkObject Ewk_Auth_Request; @@ -61,7 +61,6 @@ enum CallbackType { DownloadJobFailed, DownloadJobFinished, DownloadJobRequested, - FileChooserRequest, NewFormSubmissionRequest, FaviconChanged, LoadError, @@ -161,6 +160,7 @@ enum CallbackType { LoginFormSubmitted, LoginFields, DidBlockInsecureContent, + FileChooserRequest, #endif URIChanged, DidNotAllowScript, @@ -235,7 +235,6 @@ DECLARE_EWK_VIEW_CALLBACK(Vibrate, "vibrate", uint32_t*); // Note: type 'void' means that no arguments are expected. -DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, "file,chooser,request", Ewk_File_Chooser_Request*); DECLARE_EWK_VIEW_CALLBACK(FormSubmit, "form,submit", const char*); DECLARE_EWK_VIEW_CALLBACK(LoadFinished, "load,finished", void); DECLARE_EWK_VIEW_CALLBACK(LoadStarted, "load,started", void); @@ -344,6 +343,9 @@ DECLARE_EWK_VIEW_CALLBACK(LoginFields, DECLARE_EWK_VIEW_CALLBACK(DidBlockInsecureContent, "did,block,insecure,content", void); +DECLARE_EWK_VIEW_CALLBACK(FileChooserRequest, + "file,chooser,request", + _Ewk_File_Chooser_Request*); #endif DECLARE_EWK_VIEW_CALLBACK(ContentsSizeChanged, "contents,size,changed", void); diff --git a/tizen_src/ewk/efl_integration/file_chooser_controller_efl.cc b/tizen_src/ewk/efl_integration/file_chooser_controller_efl.cc index e287f76..3a6efc0 100644 --- a/tizen_src/ewk/efl_integration/file_chooser_controller_efl.cc +++ b/tizen_src/ewk/efl_integration/file_chooser_controller_efl.cc @@ -2,43 +2,151 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/public/browser/render_frame_host.h" -#include "content/public/common/file_chooser_file_info.h" #include "file_chooser_controller_efl.h" -#include #include +#if BUILDFLAG(IS_TIZEN) +#include +#endif + #include "base/files/file_path.h" #include "base/strings/utf_string_conversions.h" +#include "content/public/browser/file_select_listener.h" +#include "tizen/system_info.h" + +using blink::mojom::FileChooserFileInfoPtr; +using blink::mojom::FileChooserParams; namespace content { -static void _fs_done(void* data, Evas_Object* obj, void* event_info) { - FileChooserControllerEfl* inst = static_cast(data); - RenderFrameHost* render_frame_host = inst->GetRenderFrameHost(); +namespace { - if (!render_frame_host) - return; +const char kDefaultTitleOpen[] = "Open"; +const char kDefaultTitleSave[] = "Save"; +const char kDefaultFileName[] = "/tmp"; + +const char kMimeTypeAudio[] = "audio/*"; +const char kMimeTypeImage[] = "image/*"; +const char kMimeTypeVideo[] = "video/*"; + +#if BUILDFLAG(IS_TIZEN) +static void DestroyAppHandle(app_control_h* handle) { + std::ignore = app_control_destroy(*handle); +} + +static void FileChooserResultCb(app_control_h request, + app_control_h reply, + app_control_result_e result, + void* data) { + auto* fcc = static_cast(data); + scoped_refptr listener = + fcc->GetFileSelectListener(); + + std::vector files; + + if (result == APP_CONTROL_RESULT_SUCCEEDED) { + char** selected_files = nullptr; + int file_count = 0; + int ret = app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, + &selected_files, &file_count); + + if (ret == APP_CONTROL_ERROR_NONE && file_count > 0) { + for (int i = 0; i < file_count; i++) { + base::FilePath path(selected_files[i]); + auto file_info = blink::mojom::NativeFileInfo::New(); + file_info->file_path = path; + files.push_back(blink::mojom::FileChooserFileInfo::NewNativeFile( + std::move(file_info))); + free(selected_files[i]); + } + free(selected_files); + } else { + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Failed to get extra data array. Error code: " << ret; + } + } else { + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Failed to launch file chooser application. Error code: " + << result; + } + + listener->FileSelected(std::move(files), base::FilePath(), + fcc->GetParams()->mode); +} + +static void CameraResultCb(app_control_h request, + app_control_h reply, + app_control_result_e result, + void* data) { + auto* fcc = static_cast(data); + scoped_refptr listener = + fcc->GetFileSelectListener(); + + std::vector files; + + if (result == APP_CONTROL_RESULT_SUCCEEDED) { + char** return_paths = nullptr; + int array_length = 0; + int ret = app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, + &return_paths, &array_length); + if (ret == APP_CONTROL_ERROR_NONE && array_length > 0) { + for (int i = 0; i < array_length; ++i) { + auto file_info = blink::mojom::NativeFileInfo::New(); + file_info->file_path = base::FilePath(return_paths[i]); + files.push_back(blink::mojom::FileChooserFileInfo::NewNativeFile( + std::move(file_info))); + free(return_paths[i]); + } + free(return_paths); + } else { + LOG(ERROR) << __PRETTY_FUNCTION__ + << "Fail to get selected data. ERR: " << ret; + } + } else { + LOG(ERROR) << __PRETTY_FUNCTION__ + << "Fail or cancel app control. ERR: " << result; + } + + listener->FileSelected(std::move(files), base::FilePath(), + fcc->GetParams()->mode); +} +#endif // IS_TIZEN + +static void FileSelectionDoneCb(void* data, + Evas_Object* obj, + void* event_info) { + FileChooserControllerEfl* inst = static_cast(data); + scoped_refptr listener = + inst->GetFileSelectListener(); + std::vector files; - std::vector files; const char* sel_path = static_cast(event_info); if (sel_path) { - GURL url(sel_path); - if (!url.is_valid()) { - base::FilePath path(url.SchemeIsFile() ? url.path() : sel_path); - content::FileChooserFileInfo file_info; - file_info.file_path = path; - files.push_back(file_info); - } + base::FilePath path(sel_path); + auto file_info = blink::mojom::NativeFileInfo::New(); + file_info->file_path = path; + files.push_back( + blink::mojom::FileChooserFileInfo::NewNativeFile(std::move(file_info))); } - render_frame_host->FilesSelectedInChooser(files, inst->GetParams()->mode); + listener->FileSelected(std::move(files), base::FilePath(), + inst->GetParams()->mode); evas_object_del(elm_object_top_widget_get(obj)); } +} // namespace + +FileChooserControllerEfl::FileChooserControllerEfl( + scoped_refptr listener, + const FileChooserParams& params) + : params_(params.Clone()) { + file_select_listener_ = std::move(listener); + ParseParams(); +} + void FileChooserControllerEfl::ParseParams() { - title_ = DEF_TITLE_OPEN; - def_file_name_ = DEF_FILE_NAME; + title_ = kDefaultTitleOpen; + file_name_ = kDefaultFileName; is_save_file_ = EINA_FALSE; folder_only_ = EINA_FALSE; @@ -46,16 +154,16 @@ void FileChooserControllerEfl::ParseParams() { return; switch (params_->mode) { - case FileChooserParams::Open: + case FileChooserParams::Mode::kOpen: break; - case FileChooserParams::OpenMultiple: + case FileChooserParams::Mode::kOpenMultiple: // only since elementary 1.8 break; - case FileChooserParams::UploadFolder: + case FileChooserParams::Mode::kUploadFolder: folder_only_ = EINA_TRUE; break; - case FileChooserParams::Save: - title_ = DEF_TITLE_SAVE; + case FileChooserParams::Mode::kSave: + title_ = kDefaultTitleSave; is_save_file_ = EINA_TRUE; break; default: @@ -65,15 +173,53 @@ void FileChooserControllerEfl::ParseParams() { if (!params_->title.empty()) title_ = base::UTF16ToUTF8(params_->title); - if (!params_->default_file_name.empty()) { - if (params_->default_file_name.EndsWithSeparator()) - def_file_name_ = params_->default_file_name.value(); - else - def_file_name_ = params_->default_file_name.DirName().value(); - } + if (params_->default_file_name.empty()) + return; + + if (params_->default_file_name.EndsWithSeparator()) + file_name_ = params_->default_file_name.value(); + else + file_name_ = params_->default_file_name.DirName().value(); +} + +scoped_refptr +FileChooserControllerEfl::GetFileSelectListener() { + return std::move(file_select_listener_); } void FileChooserControllerEfl::Open() { +#if BUILDFLAG(IS_TIZEN) + if (IsMobileProfile() && params_->use_media_capture) { + bool ret = false; + for (const auto& type : params_->accept_types) { + const std::string type_utf8 = base::UTF16ToUTF8(type); + if (type_utf8 == kMimeTypeImage || type_utf8 == kMimeTypeVideo) { + ret = LaunchCamera(type_utf8); + break; + } + } + if (!ret) { + GetFileSelectListener()->FileSelected( + std::vector(), base::FilePath(), + params_->mode); + } + return; + } +#endif + + if ((IsMobileProfile() || IsWearableProfile()) && !LaunchFileChooser()) { + GetFileSelectListener()->FileSelected(std::vector(), + base::FilePath(), params_->mode); + } else { + CreateAndShowFileChooser(); + } +} + +const blink::mojom::FileChooserParamsPtr FileChooserControllerEfl::GetParams() { + return std::move(params_); +} + +void FileChooserControllerEfl::CreateAndShowFileChooser() { Evas_Object* win = elm_win_util_standard_add("fileselector", title_.c_str()); elm_win_modal_set(win, EINA_TRUE); @@ -89,7 +235,7 @@ void FileChooserControllerEfl::Open() { elm_fileselector_expandable_set(fs, EINA_FALSE); /* start the fileselector in proper dir */ - elm_fileselector_path_set(fs, def_file_name_.c_str()); + elm_fileselector_path_set(fs, file_name_.c_str()); evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -97,11 +243,125 @@ void FileChooserControllerEfl::Open() { evas_object_show(fs); /* the 'done' cb is called when the user presses ok/cancel */ - evas_object_smart_callback_add(fs, "done", _fs_done, this); + evas_object_smart_callback_add(fs, "done", FileSelectionDoneCb, this); evas_object_resize(win, 400, 400); evas_object_show(win); } -} //namespace +bool FileChooserControllerEfl::LaunchFileChooser() { +#if BUILDFLAG(IS_TIZEN) + if (!IsMobileProfile() && !IsWearableProfile()) + return false; + + app_control_h service_handle = nullptr; + + int ret = app_control_create(&service_handle); + if (ret != APP_CONTROL_ERROR_NONE || !service_handle) { + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Failed to create file chooser service. Error code: " << ret; + return false; + } + + std::unique_ptr + service_handle_ptr(&service_handle, DestroyAppHandle); + + ret = app_control_set_operation(service_handle, APP_CONTROL_OPERATION_PICK); + if (ret != APP_CONTROL_ERROR_NONE) { + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Failed to set operation. Error code: " << ret; + return false; + } + + // If there is more than one valid MIME type or file extension supported, + // do not restrict selectable files to any specific type. The reason for this + // is that app_control does not support multiple MIME types, that is, + // each MIME type is associated with a particular external Tizen Application. + if (params_->accept_types.size() == 1) { + ret = app_control_set_mime( + service_handle, base::UTF16ToUTF8(params_->accept_types[0]).c_str()); + } else { + ret = app_control_set_mime(service_handle, "*/*"); + } + if (ret != APP_CONTROL_ERROR_NONE) { + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Failed to set specified mime type. Error code: " << ret; + return false; + } + + switch (params_->mode) { + case FileChooserParams::Mode::kOpen: + app_control_add_extra_data(service_handle, + APP_CONTROL_DATA_SELECTION_MODE, "single"); + break; + case FileChooserParams::Mode::kOpenMultiple: + app_control_add_extra_data(service_handle, + APP_CONTROL_DATA_SELECTION_MODE, "multiple"); + break; + default: + // cancel file chooser request + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Unsupported file chooser mode. Mode: " << params_->mode; + return false; + } + + app_control_add_extra_data(service_handle, APP_CONTROL_DATA_TYPE, "vcf"); + + ret = app_control_send_launch_request(service_handle, FileChooserResultCb, + this); + if (ret != APP_CONTROL_ERROR_NONE) { + LOG(ERROR) << __PRETTY_FUNCTION__ << " : " + << "Failed to send launch request. Error code: " << ret; + return false; + } + + return true; +#else + NOTIMPLEMENTED() << "This is only available on Tizen."; + return false; +#endif +} + +bool FileChooserControllerEfl::LaunchCamera(const std::string& mime_type) { +#if BUILDFLAG(IS_TIZEN) + if (!IsMobileProfile()) + return false; + + app_control_h handle = nullptr; + int ret = app_control_create(&handle); + if (ret != APP_CONTROL_ERROR_NONE || !handle) { + LOG(ERROR) << __PRETTY_FUNCTION__ + << "Fail to create app control. ERR: " << ret; + return false; + } + + std::unique_ptr handle_ptr( + &handle, DestroyAppHandle); + ret = app_control_set_operation(handle, APP_CONTROL_OPERATION_CREATE_CONTENT); + if (ret != APP_CONTROL_ERROR_NONE) { + LOG(ERROR) << __PRETTY_FUNCTION__ << "Fail to set operation. ERR: " << ret; + return false; + } + + ret = app_control_set_mime(handle, mime_type.c_str()); + if (ret != APP_CONTROL_ERROR_NONE) { + LOG(ERROR) << __PRETTY_FUNCTION__ << "Fail to set mime. ERR: " << ret; + return false; + } + + ret = app_control_send_launch_request(handle, CameraResultCb, this); + if (ret != APP_CONTROL_ERROR_NONE) { + LOG(ERROR) << __PRETTY_FUNCTION__ + << "Fail to send launch request. ERR: " << ret; + return false; + } + + return true; +#else + NOTIMPLEMENTED() << "This is only available on Tizen."; + return false; +#endif +} + +} //namespace diff --git a/tizen_src/ewk/efl_integration/file_chooser_controller_efl.h b/tizen_src/ewk/efl_integration/file_chooser_controller_efl.h index 3fb5eb6..322e07c 100644 --- a/tizen_src/ewk/efl_integration/file_chooser_controller_efl.h +++ b/tizen_src/ewk/efl_integration/file_chooser_controller_efl.h @@ -1,4 +1,4 @@ -// Copyright 2014 Samsung Electronics. All rights reserved. +// Copyright 2014-2017 Samsung Electronics. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,51 +6,33 @@ #define file_chooser_controller_efl_h #include +#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h" namespace content { -class RenderFrameHost; - -#define DEF_TITLE_OPEN "Open"; -#define DEF_TITLE_SAVE "Save"; -#define DEF_FILE_NAME "/tmp"; - +class FileSelectListener; class FileChooserControllerEfl { public: - FileChooserControllerEfl() : render_frame_host_(nullptr), params_(nullptr) { - ParseParams(); - } - - FileChooserControllerEfl(RenderFrameHost* render_frame_host, - const blink::mojom::FileChooserParams* params) - : render_frame_host_(render_frame_host), params_(params) { - ParseParams(); - } - ~FileChooserControllerEfl() { } + FileChooserControllerEfl(scoped_refptr listener, + const blink::mojom::FileChooserParams& params); + ~FileChooserControllerEfl() {} void Open(); - const blink::mojom::FileChooserParams* GetParams() { return params_; } + const blink::mojom::FileChooserParamsPtr GetParams(); - void SetParams(const blink::mojom::FileChooserParams* params) { - params_ = params; - } - - RenderFrameHost* GetRenderFrameHost() { - return render_frame_host_; - } - - void SetRenderFrameHost(RenderFrameHost* render_frame_host) { - render_frame_host_ = render_frame_host; - } + scoped_refptr GetFileSelectListener(); private: void ParseParams(); + void CreateAndShowFileChooser(); + bool LaunchFileChooser(); + bool LaunchCamera(const std::string& mime_type); - RenderFrameHost* render_frame_host_; - const blink::mojom::FileChooserParams* params_; + scoped_refptr file_select_listener_; + blink::mojom::FileChooserParamsPtr params_; std::string title_; - std::string def_file_name_; + std::string file_name_; Eina_Bool is_save_file_; Eina_Bool folder_only_; }; @@ -58,4 +40,3 @@ class FileChooserControllerEfl { } // namespace #endif // file_chooser_controller_efl_h - diff --git a/tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.cc b/tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.cc new file mode 100644 index 0000000..74ac5e8 --- /dev/null +++ b/tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.cc @@ -0,0 +1,74 @@ +#include "ewk_file_chooser_request_private.h" + +#include "base/files/file_path.h" +#include "base/strings/utf_string_conversions.h" +#include "content/public/browser/file_select_listener.h" + +using blink::mojom::FileChooserFileInfo; +using blink::mojom::FileChooserFileInfoPtr; +using blink::mojom::FileChooserParams; +using blink::mojom::NativeFileInfo; + +_Ewk_File_Chooser_Request::_Ewk_File_Chooser_Request( + scoped_refptr listener, + const std::vector& accept_types, + FileChooserParams::Mode mode) + : listener_(std::move(listener)), + accept_types_(accept_types), + mode_(mode) {} + +_Ewk_File_Chooser_Request::~_Ewk_File_Chooser_Request() { + if (!is_handled_) + FileSelectionCanceled(); +} + +Eina_List* _Ewk_File_Chooser_Request::GetAcceptTypes() const { + Eina_List* type_list = NULL; + for (const auto& type : accept_types_) { + type_list = eina_list_append( + type_list, eina_stringshare_add(base::UTF16ToASCII(type).c_str())); + } + return type_list; +} + +bool _Ewk_File_Chooser_Request::AllowMultipleSelection() const { + return mode_ == FileChooserParams::Mode::kOpenMultiple; +} + +void _Ewk_File_Chooser_Request::FileSelected(const Eina_List* files) { + size_t count = eina_list_count(files); + if (count > 1 && !AllowMultipleSelection()) { + LOG(INFO) << "Multiple selection is not allowed, " + "only the first file will be selected."; + FileSelected(static_cast(eina_list_nth(files, 0))); + return; + } + + std::vector file_info; + for (size_t i = 0; i < count; i++) { + auto path = base::FilePath(static_cast(eina_list_nth(files, i))); + file_info.push_back(FileChooserFileInfo::NewNativeFile( + NativeFileInfo::New(path, path.BaseName().AsUTF16Unsafe()))); + } + FileSelectedInternal(std::move(file_info)); +} + +void _Ewk_File_Chooser_Request::FileSelected(const char* file) { + std::vector file_info; + auto path = base::FilePath(file); + file_info.push_back(FileChooserFileInfo::NewNativeFile( + NativeFileInfo::New(path, path.BaseName().AsUTF16Unsafe()))); + FileSelectedInternal(std::move(file_info)); +} + +void _Ewk_File_Chooser_Request::FileSelectedInternal( + std::vector files) { + listener_->FileSelected(std::move(files), base::FilePath(), mode_); + is_handled_ = true; +} + +void _Ewk_File_Chooser_Request::FileSelectionCanceled() { + listener_->FileSelected(std::vector(), + base::FilePath(), mode_); + is_handled_ = true; +} diff --git a/tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.h b/tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.h new file mode 100644 index 0000000..129e3b1 --- /dev/null +++ b/tizen_src/ewk/efl_integration/private/ewk_file_chooser_request_private.h @@ -0,0 +1,44 @@ +// Copyright 2020 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EWK_EFL_INTEGRATION_PRIVATE_EWK_FILE_CHOOSER_REQUEST_PRIVATE_H_ +#define EWK_EFL_INTEGRATION_PRIVATE_EWK_FILE_CHOOSER_REQUEST_PRIVATE_H_ + +#include + +#include +#include + +#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h" + +namespace content { +class FileSelectListener; +} + +struct _Ewk_File_Chooser_Request { + public: + _Ewk_File_Chooser_Request(scoped_refptr listener, + const std::vector& accept_types, + blink::mojom::FileChooserParams::Mode mode); + ~_Ewk_File_Chooser_Request(); + + Eina_List* GetAcceptTypes() const; + bool AllowMultipleSelection() const; + void FileSelected(const Eina_List* files); + void FileSelected(const char* file); + void FileSelectionCanceled(); + + bool is_handled() const { return is_handled_; } + + private: + void FileSelectedInternal( + std::vector files); + + scoped_refptr listener_; + std::vector accept_types_; + blink::mojom::FileChooserParams::Mode mode_; + bool is_handled_ = false; +}; + +#endif // EWK_EFL_INTEGRATION_PRIVATE_EWK_FILE_CHOOSER_REQUEST_PRIVATE_H_ diff --git a/tizen_src/ewk/efl_integration/public/EWebKit_product.h b/tizen_src/ewk/efl_integration/public/EWebKit_product.h index 83ffcdc..4af251d 100644 --- a/tizen_src/ewk/efl_integration/public/EWebKit_product.h +++ b/tizen_src/ewk/efl_integration/public/EWebKit_product.h @@ -37,6 +37,7 @@ #include "ewk_context_menu_product.h" #include "ewk_context_product.h" #include "ewk_cookie_manager_product.h" +#include "ewk_file_chooser_request_product.h" #include "ewk_form_repost_decision_product.h" #include "ewk_highcontrast_product.h" #include "ewk_media_downloadable_font_info_product.h" diff --git a/tizen_src/ewk/efl_integration/public/ewk_file_chooser_request.cc b/tizen_src/ewk/efl_integration/public/ewk_file_chooser_request.cc new file mode 100644 index 0000000..259c22d --- /dev/null +++ b/tizen_src/ewk/efl_integration/public/ewk_file_chooser_request.cc @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * Copyright (C) 2020 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ewk_file_chooser_request_product.h" + +#include "private/ewk_file_chooser_request_private.h" + +/* LCOV_EXCL_START */ +EXPORT_API Eina_Bool ewk_file_chooser_request_allow_multiple_files_get(const Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, EINA_FALSE); + return request->AllowMultipleSelection(); +} + +EXPORT_API Eina_List* ewk_file_chooser_request_accepted_mimetypes_get(const Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, NULL); + return request->GetAcceptTypes(); +} + +EXPORT_API Eina_Bool ewk_file_chooser_request_cancel(Ewk_File_Chooser_Request* request) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, EINA_FALSE); + EINA_SAFETY_ON_TRUE_RETURN_VAL(request->is_handled(), EINA_FALSE); + request->FileSelectionCanceled(); + return EINA_TRUE; + +} + +EXPORT_API Eina_Bool ewk_file_chooser_request_files_choose(Ewk_File_Chooser_Request* request, const Eina_List* chosen_files) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, EINA_FALSE); + EINA_SAFETY_ON_TRUE_RETURN_VAL(request->is_handled(), EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(chosen_files, EINA_FALSE); + request->FileSelected(chosen_files); + return EINA_FALSE; +} + +EXPORT_API Eina_Bool ewk_file_chooser_request_file_choose(Ewk_File_Chooser_Request* request, const char* chosen_file) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(request, EINA_FALSE); + EINA_SAFETY_ON_TRUE_RETURN_VAL(request->is_handled(), EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(chosen_file, EINA_FALSE); + request->FileSelected(chosen_file); + return EINA_FALSE; +} +/* LCOV_EXCL_STOP */ diff --git a/tizen_src/ewk/efl_integration/public/ewk_file_chooser_request_product.h b/tizen_src/ewk/efl_integration/public/ewk_file_chooser_request_product.h new file mode 100644 index 0000000..3c84086 --- /dev/null +++ b/tizen_src/ewk/efl_integration/public/ewk_file_chooser_request_product.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * Copyright (C) 2020 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_file_chooser_request_product.h + * @brief Describes the Ewk File Chooser API. + */ + +#ifndef EWK_EFL_INTEGRATION_PUBLIC_EWK_FILE_CHOOSER_REQUEST_PRODUCT_H_ +#define EWK_EFL_INTEGRATION_PUBLIC_EWK_FILE_CHOOSER_REQUEST_PRODUCT_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for Ewk_File_Chooser_Request */ +typedef struct _Ewk_File_Chooser_Request Ewk_File_Chooser_Request; + +/** + * Queries if it is allowed to select multiple files or not. + * + * @param request request object to query + * + * @return @c EINA_TRUE if it is allowed to select multiple files, + * @c EINA_FALSE otherwise + */ +EXPORT_API Eina_Bool ewk_file_chooser_request_allow_multiple_files_get(const Ewk_File_Chooser_Request* request); + +/** + * Queries the list of accepted MIME types. + * + * Possible MIME types are: + * - "audio\/\*": All sound files are accepted + * - "video\/\*": All video files are accepted + * - "image\/\*": All image files are accepted + * - standard IANA MIME type (see http://www.iana.org/assignments/media-types/ for a complete list) + * + * @param request request object to query + * + * @return The list of accepted MIME types. The list items are guaranteed to be stringshared. + * The caller needs to free the list and its items after use + */ +EXPORT_API Eina_List* ewk_file_chooser_request_accepted_mimetypes_get(const Ewk_File_Chooser_Request* request); + +/** + * Cancels the file chooser request. + * + * @param request request object to cancel + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + */ +EXPORT_API Eina_Bool ewk_file_chooser_request_cancel(Ewk_File_Chooser_Request* request); + +/** + * Sets the files chosen by the user. + * + * @param request request object to update + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + * + * @see ewk_file_chooser_request_file_choose() + */ +EXPORT_API Eina_Bool ewk_file_chooser_request_files_choose(Ewk_File_Chooser_Request* request, const Eina_List* chosen_files); + +/** + * Sets the file chosen by the user. + * + * This is a convenience function in case only one file needs to be set. + * + * @param request request object to update + * + * @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise + * + * @see ewk_file_chooser_request_files_choose() + */ +EXPORT_API Eina_Bool ewk_file_chooser_request_file_choose(Ewk_File_Chooser_Request* request, const char* chosen_file); + +#ifdef __cplusplus +} +#endif + +#endif // EWK_EFL_INTEGRATION_PUBLIC_EWK_FILE_CHOOSER_REQUEST_PRODUCT_H_ diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 18fb985..5435c2e 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -643,7 +643,7 @@ void WebContentsDelegateEfl::RunFileChooser( RenderFrameHost* render_frame_host, scoped_refptr listener, const blink::mojom::FileChooserParams& params) { - web_view_->ShowFileChooser(render_frame_host, params); + web_view_->ShowFileChooser(std::move(listener), params); } std::unique_ptr WebContentsDelegateEfl::OpenColorChooser( diff --git a/tizen_src/ewk/unittest/BUILD.gn b/tizen_src/ewk/unittest/BUILD.gn index 4eb65733..3e170a2 100644 --- a/tizen_src/ewk/unittest/BUILD.gn +++ b/tizen_src/ewk/unittest/BUILD.gn @@ -166,6 +166,11 @@ test("ewk_unittests") { "utc_blink_ewk_error_type_get_func.cpp", "utc_blink_ewk_error_url_get_func.cpp", "utc_blink_ewk_favicon_database_icon_get_func.cpp", + "utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func.cpp", + "utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func.cpp", + "utc_blink_ewk_file_chooser_request_cancel_func.cpp", + "utc_blink_ewk_file_chooser_request_file_choose_func.cpp", + "utc_blink_ewk_file_chooser_request_files_choose_func.cpp", "utc_blink_ewk_frame_is_main_frame_func.cpp", "utc_blink_ewk_geolocation_permission_reply_func.cpp", "utc_blink_ewk_geolocation_permission_request_origin_get_func.cpp", diff --git a/tizen_src/ewk/unittest/resources/ewk_file_chooser_request/file_chooser.html b/tizen_src/ewk/unittest/resources/ewk_file_chooser_request/file_chooser.html new file mode 100644 index 0000000..59d2e2a --- /dev/null +++ b/tizen_src/ewk/unittest/resources/ewk_file_chooser_request/file_chooser.html @@ -0,0 +1,9 @@ + + +File chooser test + + + + + + diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_base.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_base.cpp index cf4e9ca..eed33a3 100644 --- a/tizen_src/ewk/unittest/utc_blink_ewk_base.cpp +++ b/tizen_src/ewk/unittest/utc_blink_ewk_base.cpp @@ -378,6 +378,17 @@ void utc_blink_ewk_base::EwkDeinit() ewk_webview = NULL; } +void utc_blink_ewk_base::FeedMouseClick(int x, int y, int button) { + if (!ewk_evas) + return; + + evas_event_feed_mouse_move(ewk_evas, x, y, ecore_time_get(), 0); + evas_event_feed_mouse_down(ewk_evas, button, EVAS_BUTTON_NONE, + ecore_time_get(), 0); + evas_event_feed_mouse_up(ewk_evas, button, EVAS_BUTTON_NONE, ecore_time_get(), + 0); +} + void utc_log(UtcLogSeverity severity, const char* format, ...) { static UtcLogSeverity minLogSeverity = -1; if (minLogSeverity == -1) { diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_base.h b/tizen_src/ewk/unittest/utc_blink_ewk_base.h index 17d7c84..2efd0b7 100644 --- a/tizen_src/ewk/unittest/utc_blink_ewk_base.h +++ b/tizen_src/ewk/unittest/utc_blink_ewk_base.h @@ -345,7 +345,9 @@ protected: inline Evas_Object* GetEwkWindow() const { return ewk_window; } inline Evas* GetEwkEvas() const { return ewk_evas; } -private: + void FeedMouseClick(int x, int y, int button); + + private: /** * Default "load,started" event callback, will call LoadStarted method * diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func.cpp new file mode 100644 index 0000000..9931d3e --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func.cpp @@ -0,0 +1,66 @@ +// Copyright 2020 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +static const char kUrl[] = "ewk_file_chooser_request/file_chooser.html"; + +class utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func + : public utc_blink_ewk_base { + protected: + void PostSetUp() override { + evas_object_smart_callback_add(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest, this); + } + + void PreTearDown() override { + evas_object_smart_callback_del(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest); + } + + void LoadFinished(Evas_Object* webview) override { + FeedMouseClick(15, 15, 1); + } + + static void OnFileChooserRequest(void* data, + Evas_Object* webview, + void* arg) { + ASSERT_TRUE(arg != NULL); + ASSERT_TRUE(data != NULL); + auto* owner = static_cast< + utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func*>(data); + auto* request = static_cast(arg); + owner->mime_types_ = + ewk_file_chooser_request_accepted_mimetypes_get(request); + owner->EventLoopStop(Success); + } + + Eina_List* mime_types_ = NULL; +}; + +/** + * @brief Checking whether the function returns a valid value. + */ +TEST_F(utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func, + POS_TEST) { + ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kUrl).c_str())); + EXPECT_EQ(Success, EventLoopStart()); + ASSERT_TRUE(NULL != mime_types_); + ASSERT_EQ(2u, eina_list_count(mime_types_)); + EXPECT_STREQ("image/png", static_cast(eina_list_nth(mime_types_, 0))); + EXPECT_STREQ("image/jpeg", static_cast(eina_list_nth(mime_types_, 1))); + void* mime_type; + EINA_LIST_FREE(mime_types_, mime_type) { + eina_stringshare_del(static_cast(mime_type)); + } +} + +/** + * @brief Checking whether the function works properly in case of NULL request. + */ +TEST_F(utc_blink_ewk_file_chooser_request_accepted_mimetypes_get_func, + NEG_TEST) { + mime_types_ = ewk_file_chooser_request_accepted_mimetypes_get(NULL); + ASSERT_TRUE(NULL == mime_types_); +} diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func.cpp new file mode 100644 index 0000000..0262270 --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func.cpp @@ -0,0 +1,60 @@ +// Copyright 2020 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +static const char kUrl[] = "ewk_file_chooser_request/file_chooser.html"; + +class utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func + : public utc_blink_ewk_base { + protected: + void PostSetUp() override { + evas_object_smart_callback_add(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest, this); + } + + void PreTearDown() override { + evas_object_smart_callback_del(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest); + } + + void LoadFinished(Evas_Object* webview) override { + FeedMouseClick(15, 15, 1); + } + + static void OnFileChooserRequest(void* data, + Evas_Object* webview, + void* arg) { + ASSERT_TRUE(arg != NULL); + ASSERT_TRUE(data != NULL); + auto* owner = static_cast< + utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func*>( + data); + auto* request = static_cast(arg); + owner->allow_multiple_ = + ewk_file_chooser_request_allow_multiple_files_get(request); + owner->EventLoopStop(Success); + } + + Eina_Bool allow_multiple_ = false; +}; + +/** + * @brief Checking whether the function returns a valid value. + */ +TEST_F(utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func, + POS_TEST) { + ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kUrl).c_str())); + EXPECT_EQ(Success, EventLoopStart()); + ASSERT_EQ(EINA_TRUE, allow_multiple_); +} + +/** + * @brief Checking whether the function works properly in case of NULL request. + */ +TEST_F(utc_blink_ewk_file_chooser_request_allow_multiple_files_get_func, + NEG_TEST) { + ASSERT_EQ(EINA_FALSE, + ewk_file_chooser_request_allow_multiple_files_get(NULL)); +} diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_cancel_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_cancel_func.cpp new file mode 100644 index 0000000..3e9ec65 --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_cancel_func.cpp @@ -0,0 +1,52 @@ +// Copyright 2020 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +static const char kUrl[] = "ewk_file_chooser_request/file_chooser.html"; + +class utc_blink_ewk_file_chooser_request_cancel_func + : public utc_blink_ewk_base { + protected: + void PostSetUp() override { + evas_object_smart_callback_add(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest, this); + } + + void PreTearDown() override { + evas_object_smart_callback_del(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest); + } + + void LoadFinished(Evas_Object* webview) override { + FeedMouseClick(15, 15, 1); + } + + static void OnFileChooserRequest(void* data, + Evas_Object* webview, + void* arg) { + ASSERT_TRUE(arg != NULL); + ASSERT_TRUE(data != NULL); + auto* owner = + static_cast(data); + auto* request = static_cast(arg); + ASSERT_TRUE(ewk_file_chooser_request_cancel(request)); + owner->EventLoopStop(Success); + } +}; + +/** + * @brief Checking whether the function returns a valid value. + */ +TEST_F(utc_blink_ewk_file_chooser_request_cancel_func, POS_TEST) { + ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kUrl).c_str())); + EXPECT_EQ(Success, EventLoopStart()); +} + +/** + * @brief Checking whether the function works properly in case of NULL request. + */ +TEST_F(utc_blink_ewk_file_chooser_request_cancel_func, NEG_TEST) { + ASSERT_EQ(EINA_FALSE, ewk_file_chooser_request_cancel(NULL)); +} diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_file_choose_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_file_choose_func.cpp new file mode 100644 index 0000000..a9e58f6 --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_file_choose_func.cpp @@ -0,0 +1,53 @@ +// Copyright 2020 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +static const char kUrl[] = "ewk_file_chooser_request/file_chooser.html"; + +class utc_blink_ewk_file_chooser_request_file_choose_func + : public utc_blink_ewk_base { + protected: + void PostSetUp() override { + evas_object_smart_callback_add(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest, this); + } + + void PreTearDown() override { + evas_object_smart_callback_del(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest); + } + + void LoadFinished(Evas_Object* webview) override { + FeedMouseClick(15, 15, 1); + } + + static void OnFileChooserRequest(void* data, + Evas_Object* webview, + void* arg) { + ASSERT_TRUE(arg != NULL); + ASSERT_TRUE(data != NULL); + auto* owner = + static_cast(data); + auto* request = static_cast(arg); + ASSERT_EQ(EINA_TRUE, + ewk_file_chooser_request_file_choose(request, "tmp/foo.png")); + owner->EventLoopStop(Success); + } +}; + +/** + * @brief Checking whether the function returns a valid value. + */ +TEST_F(utc_blink_ewk_file_chooser_request_file_choose_func, POS_TEST) { + ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kUrl).c_str())); + EXPECT_EQ(Success, EventLoopStart()); +} + +/** + * @brief Checking whether the function works properly in case of NULL request. + */ +TEST_F(utc_blink_ewk_file_chooser_request_file_choose_func, NEG_TEST) { + ASSERT_EQ(EINA_FALSE, ewk_file_chooser_request_file_choose(NULL, NULL)); +} diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_files_choose_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_files_choose_func.cpp new file mode 100644 index 0000000..aea54a4 --- /dev/null +++ b/tizen_src/ewk/unittest/utc_blink_ewk_file_chooser_request_files_choose_func.cpp @@ -0,0 +1,60 @@ +// Copyright 2020 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "utc_blink_ewk_base.h" + +static const char kUrl[] = "ewk_file_chooser_request/file_chooser.html"; + +class utc_blink_ewk_file_chooser_request_files_choose_func + : public utc_blink_ewk_base { + protected: + void PostSetUp() override { + evas_object_smart_callback_add(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest, this); + } + + void PreTearDown() override { + evas_object_smart_callback_del(GetEwkWebView(), "file,chooser,request", + OnFileChooserRequest); + } + + void LoadFinished(Evas_Object* webview) override { + FeedMouseClick(15, 15, 1); + } + + static void OnFileChooserRequest(void* data, + Evas_Object* webview, + void* arg) { + ASSERT_TRUE(arg != NULL); + ASSERT_TRUE(data != NULL); + auto* owner = + static_cast( + data); + auto* request = static_cast(arg); + Eina_List* files = NULL; + files = eina_list_append(files, eina_stringshare_add("/tmp/foo.png")); + files = eina_list_append(files, eina_stringshare_add("/tmp/bar.png")); + ASSERT_EQ(EINA_TRUE, ewk_file_chooser_request_files_choose(request, files)); + void* file; + EINA_LIST_FREE(files, file) { + eina_stringshare_del(static_cast(file)); + } + owner->EventLoopStop(Success); + } +}; + +/** + * @brief Checking whether the function returns a valid value. + */ +TEST_F(utc_blink_ewk_file_chooser_request_files_choose_func, POS_TEST) { + ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kUrl).c_str())); + EXPECT_EQ(Success, EventLoopStart()); +} + +/** + * @brief Checking whether the function works properly in case of NULL request. + */ +TEST_F(utc_blink_ewk_file_chooser_request_files_choose_func, NEG_TEST) { + ASSERT_EQ(EINA_FALSE, ewk_file_chooser_request_files_choose(NULL, NULL)); +} -- 2.7.4 From 116b3550e4b652c0fcd824fb0ee443bbac4c0d87 Mon Sep 17 00:00:00 2001 From: wuxiaoliang Date: Fri, 1 Mar 2024 13:37:46 +0800 Subject: [PATCH 09/16] [M120 Migration] Add new api for webbrowser to get media device list void ewk_view_media_device_list_get(Evas_Object* o, Ewk_Media_Device_List_Get_Callback callback, void* user_data); add this api for browser youtube to get audio input/audio output/video input device Migrated from: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/295121/ Change-Id: If3a30453dd05377c206d53cd6bba5ca383ad35a9 Signed-off-by: wuxiaoliang --- .../media/media_capture_devices_impl.cc | 37 +++++++++++++ .../media/media_capture_devices_impl.h | 10 ++++ .../renderer_host/media/media_devices_manager.cc | 36 +++++++++++++ .../renderer_host/media/media_devices_manager.h | 10 ++++ .../renderer_host/media/media_stream_manager.cc | 12 +++++ .../renderer_host/media/media_stream_manager.h | 3 +- content/public/browser/media_capture_devices.h | 14 +++++ tizen_src/ewk/efl_integration/eweb_view.cc | 61 ++++++++++++++++++++++ tizen_src/ewk/efl_integration/eweb_view.h | 37 +++++++++++++ tizen_src/ewk/efl_integration/public/ewk_view.cc | 9 +++- .../efl_integration/web_contents_delegate_efl.cc | 4 ++ .../efl_integration/web_contents_delegate_efl.h | 9 ++++ 12 files changed, 240 insertions(+), 2 deletions(-) diff --git a/content/browser/renderer_host/media/media_capture_devices_impl.cc b/content/browser/renderer_host/media/media_capture_devices_impl.cc index 6676c4d..f42078f 100644 --- a/content/browser/renderer_host/media/media_capture_devices_impl.cc +++ b/content/browser/renderer_host/media/media_capture_devices_impl.cc @@ -126,4 +126,41 @@ void MediaCaptureDevicesImpl::UpdateVideoDevicesOnUIThread( video_devices_ = devices; } +#if BUILDFLAG(IS_TIZEN_TV) +void MediaCaptureDevicesImpl::UpdateDeviceInfoOnUIThread( + const MediaDeviceEnumeration& device_infos) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + + if (!device_cb_.is_null()) + std::move(device_cb_).Run(device_infos); +} + +void MediaCaptureDevicesImpl::OnDeviceInfo( + const MediaDeviceEnumeration& device_infos) { + if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { + UpdateDeviceInfoOnUIThread(device_infos); + } else { + GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce(&MediaCaptureDevicesImpl::UpdateDeviceInfoOnUIThread, + base::Unretained(this), device_infos)); + } +} + +void MediaCaptureDevicesImpl::GetMediaDeviceList(EnumerationCallback cb) { + device_cb_ = std::move(cb); + MediaStreamManager* media_stream_manager = + BrowserMainLoop::GetInstance()->media_stream_manager(); + if (media_stream_manager != nullptr) { + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&MediaStreamManager::GetMediaDeviceList, + base::Unretained(media_stream_manager))); + } else { + LOG(ERROR) << "media_stream_manager is null."; + MediaDeviceEnumeration device_infos; + std::move(device_cb_).Run(device_infos); + } +} +#endif + } // namespace content diff --git a/content/browser/renderer_host/media/media_capture_devices_impl.h b/content/browser/renderer_host/media/media_capture_devices_impl.h index 7214e2d..3c9db08 100644 --- a/content/browser/renderer_host/media/media_capture_devices_impl.h +++ b/content/browser/renderer_host/media/media_capture_devices_impl.h @@ -29,6 +29,12 @@ class MediaCaptureDevicesImpl : public MediaCaptureDevices { void OnAudioCaptureDevicesChanged(const blink::MediaStreamDevices& devices); void OnVideoCaptureDevicesChanged(const blink::MediaStreamDevices& devices); +#if BUILDFLAG(IS_TIZEN_TV) + void GetMediaDeviceList(EnumerationCallback cb) override; + void OnDeviceInfo(const MediaDeviceEnumeration& device_info); + void UpdateDeviceInfoOnUIThread(const MediaDeviceEnumeration& device_info); +#endif + private: friend struct base::DefaultSingletonTraits; MediaCaptureDevicesImpl(); @@ -46,6 +52,10 @@ class MediaCaptureDevicesImpl : public MediaCaptureDevices { // A list of cached video capture devices. blink::MediaStreamDevices video_devices_; + +#if BUILDFLAG(IS_TIZEN_TV) + EnumerationCallback device_cb_; +#endif }; } // namespace content diff --git a/content/browser/renderer_host/media/media_devices_manager.cc b/content/browser/renderer_host/media/media_devices_manager.cc index f2a3252..880e009 100644 --- a/content/browser/renderer_host/media/media_devices_manager.cc +++ b/content/browser/renderer_host/media/media_devices_manager.cc @@ -50,6 +50,10 @@ #include "media/device_monitors/device_monitor_mac.h" #endif +#if BUILDFLAG(IS_TIZEN_TV) +#include "tizen_src/ewk/efl_integration/common/application_type.h" +#endif + namespace content { namespace { @@ -471,6 +475,21 @@ void MediaDevicesManager::EnumerateDevices( request_audio_input_capabilities, std::move(callback))))); } +#if BUILDFLAG(IS_TIZEN_TV) +void MediaDevicesManager::GetMediaDeviceList(EnumerationCallback cb) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + enum_cb_ = std::move(cb); + got_result_.fill(false); + for (auto& device : device_infos_) + device.clear(); + + for (size_t i = 0; + i < static_cast(MediaDeviceType::kNumMediaDeviceTypes); ++i) { + DoEnumerateDevices(static_cast(i)); + } +} +#endif + uint32_t MediaDevicesManager::SubscribeDeviceChangeNotifications( int render_process_id, int render_frame_id, @@ -1009,6 +1028,23 @@ void MediaDevicesManager::DevicesEnumerated( } else { DoEnumerateDevices(type); } + +#if BUILDFLAG(IS_TIZEN_TV) + // report device list to webbrowser + if (IsWebBrowser() && !enum_cb_.is_null()) { + got_result_[static_cast(type)] = true; + + for (const auto& device : snapshot) { + device_infos_[static_cast(type)].emplace_back( + device.device_id, device.label, device.group_id); + } + + bool finish = std::all_of(got_result_.begin(), got_result_.end(), + [](const bool result) { return result == true; }); + if (finish) + std::move(enum_cb_).Run(device_infos_); + } +#endif } void MediaDevicesManager::UpdateSnapshot( diff --git a/content/browser/renderer_host/media/media_devices_manager.h b/content/browser/renderer_host/media/media_devices_manager.h index 7a8a249..449f506 100644 --- a/content/browser/renderer_host/media/media_devices_manager.h +++ b/content/browser/renderer_host/media/media_devices_manager.h @@ -165,6 +165,10 @@ class CONTENT_EXPORT MediaDevicesManager get_salt_and_origin_cb_ = std::move(callback); } +#if BUILDFLAG(IS_TIZEN_TV) + void GetMediaDeviceList(EnumerationCallback cb); +#endif + private: friend class MediaDevicesManagerTest; struct EnumerationRequest; @@ -360,6 +364,12 @@ class CONTENT_EXPORT MediaDevicesManager mojo::UniqueReceiverSet dispatcher_hosts_; +#if BUILDFLAG(IS_TIZEN_TV) + EnumerationCallback enum_cb_; + MediaDeviceEnumeration device_infos_; + BoolDeviceTypes got_result_; +#endif + base::WeakPtrFactory weak_factory_{this}; }; diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc index 78a925a..ec5b3b2 100644 --- a/content/browser/renderer_host/media/media_stream_manager.cc +++ b/content/browser/renderer_host/media/media_stream_manager.cc @@ -2454,7 +2454,19 @@ void MediaStreamManager::NotifyMediaStateChanged(uint32_t type, web_contents_delegate->NotifyMediaStateChanged(type, previous, current); } + +void MediaStreamManager::GotDeviceInfo( + const MediaDeviceEnumeration& device_info) { + MediaCaptureDevicesImpl::GetInstance()->OnDeviceInfo(device_info); +} + +void MediaStreamManager::GetMediaDeviceList() { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + media_devices_manager_->GetMediaDeviceList(base::BindOnce( + &MediaStreamManager::GotDeviceInfo, base::Unretained(this))); +} #endif + void MediaStreamManager::SetUpRequest(const std::string& label) { DCHECK_CURRENTLY_ON(BrowserThread::IO); diff --git a/content/browser/renderer_host/media/media_stream_manager.h b/content/browser/renderer_host/media/media_stream_manager.h index 4434172..9883428 100644 --- a/content/browser/renderer_host/media/media_stream_manager.h +++ b/content/browser/renderer_host/media/media_stream_manager.h @@ -342,12 +342,13 @@ class CONTENT_EXPORT MediaStreamManager // capture device is plugged in or unplugged. void NotifyDevicesChanged(blink::mojom::MediaDeviceType stream_type, const blink::WebMediaDeviceInfoArray& devices); - #if BUILDFLAG(IS_TIZEN_TV) // Notify media(camera/microphone) status change to web browser. void NotifyMediaStateChanged(uint32_t type, uint32_t previous, uint32_t current); + void GetMediaDeviceList(); + void GotDeviceInfo(const MediaDeviceEnumeration& device_info); #endif // This method is called when an audio or video device is removed. It makes diff --git a/content/public/browser/media_capture_devices.h b/content/public/browser/media_capture_devices.h index 1581e3a..1260f66 100644 --- a/content/public/browser/media_capture_devices.h +++ b/content/public/browser/media_capture_devices.h @@ -9,6 +9,10 @@ #include "media/base/video_facing.h" #include "third_party/blink/public/common/mediastream/media_stream_request.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "third_party/blink/public/common/mediastream/media_devices.h" +#endif + namespace content { // This is a singleton class, used to get Audio/Video devices, it must be @@ -26,6 +30,16 @@ class CONTENT_EXPORT MediaCaptureDevices { media::VideoCaptureObserver* observer) = 0; virtual void RemoveAllVideoCaptureObservers() = 0; +#if BUILDFLAG(IS_TIZEN_TV) + using MediaDeviceEnumeration = + std::array( + blink::mojom::MediaDeviceType::kNumMediaDeviceTypes)>; + using EnumerationCallback = + base::OnceCallback; + virtual void GetMediaDeviceList(EnumerationCallback cb) = 0; +#endif + private: // This interface should only be implemented inside content. friend class MediaCaptureDevicesImpl; diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 98e9661..c6f8160 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -431,6 +431,7 @@ void EWebView::Initialize() { EWebView::~EWebView() { LOG(INFO) << "EWebView: " << this; + weak_factory_.InvalidateWeakPtrs(); auto cbce = static_cast( content::GetContentClientExport()->browser()); cbce->RemoveAcceptLangsChangedCallback(accept_langs_changed_callback_); @@ -3424,4 +3425,64 @@ void EWebView::SetHighBitRate(Eina_Bool high_bitrate) { LOG(INFO) << "high_bitrate: " << std::boolalpha << high_bitrate; is_high_bitrate_ = high_bitrate; } + +void EWebView::OnDeviceListed(const MediaDeviceEnumeration& devices) { + int device_count = 0; + EwkMediaDeviceInfo* device_list = nullptr; + for (const auto& device : devices) + device_count += device.size(); + + device_list = + (EwkMediaDeviceInfo*)malloc(sizeof(EwkMediaDeviceInfo) * device_count); + if (!device_list) { + LOG(ERROR) << "malloc EwkMediaDeviceInfo failed"; + device_cb_.Run(device_list, 0); + return; + } + + int idx = 0; + for (int i = 0; i < NUM_MEDIA_DEVICE_TYPES; i++) { + blink::WebMediaDeviceInfoArray array = devices[i]; + for (const auto& device : array) { + LOG(INFO) << "OnDeviceListed type:" << i + << ",device_id:" << device.device_id + << ",lable:" << device.label; + + // convert device info to ewk structure + EwkMediaDeviceInfo* data = &device_list[idx++]; + data->device_id = eina_stringshare_add(device.device_id.c_str()); + data->label = eina_stringshare_add(device.label.c_str()); + data->type = static_cast(i); + data->connected = true; + } + } + + device_cb_.Run(device_list, device_count); + + // free data + for (int i = 0; i < device_count; i++) { + EwkMediaDeviceInfo* device = &device_list[i]; + if (device->device_id) + eina_stringshare_del(device->device_id); + if (device->label) + eina_stringshare_del(device->label); + } + if (device_list) { + free(device_list); + device_list = NULL; + } +} + +void EWebView::GetMediaDeviceList(Ewk_Media_Device_List_Get_Callback callback, + void* userData) { + if (!web_contents_delegate_) { + LOG(ERROR) << "no web_contents_delegate_"; + return; + } + + device_cb_.Set(callback, userData); + + web_contents_delegate_->GetMediaDeviceList( + base::BindOnce(&EWebView::OnDeviceListed, weak_factory_.GetWeakPtr())); +} #endif diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index f870b65..de4f3d8 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -54,6 +54,10 @@ #include "public/ewk_value_product.h" #endif +#if BUILDFLAG(IS_TIZEN_TV) +#include "third_party/blink/public/common/mediastream/media_devices.h" +#endif + namespace aura { namespace client { class FocusClient; @@ -290,6 +294,28 @@ class DidChangeThemeColorCallback { void* user_data_; }; +#if BUILDFLAG(IS_TIZEN_TV) +class GetMediaDeviceCallback { + public: + GetMediaDeviceCallback() : func_(nullptr), user_data_(nullptr) {} + + void Set(Ewk_Media_Device_List_Get_Callback func, void* user_data) { + func_ = func; + user_data_ = user_data; + } + + void Run(EwkMediaDeviceInfo* device_list, int size) { + if (func_) { + (func_)(device_list, size, user_data_); + } + } + + private: + Ewk_Media_Device_List_Get_Callback func_; + void* user_data_; +}; +#endif + class WebViewAsyncRequestHitTestDataCallback; class JavaScriptDialogManagerEfl; class PermissionPopupManager; @@ -750,6 +776,12 @@ class EWebView { uint32_t current); void SetHighBitRate(Eina_Bool is_high_bitrate); bool IsHighBitRate() const { return is_high_bitrate_; } + + void GetMediaDeviceList(Ewk_Media_Device_List_Get_Callback callback, + void* userData); + using MediaDeviceEnumeration = + std::array; + void OnDeviceListed(const MediaDeviceEnumeration& devices); #endif // IS_TIZEN_TV void SetDidChangeThemeColorCallback( @@ -863,6 +895,10 @@ class EWebView { base::IDMap background_color_get_callback_map_; +#if BUILDFLAG(IS_TIZEN_TV) + GetMediaDeviceCallback device_cb_; +#endif + gfx::Size contents_size_; double progress_; mutable std::string title_; @@ -983,6 +1019,7 @@ class EWebView { #endif Ecore_Timer* delayed_show_context_menu_timer_ = nullptr; + base::WeakPtrFactory weak_factory_{this}; }; const unsigned int g_default_tilt_motion_sensitivity = 3; diff --git a/tizen_src/ewk/efl_integration/public/ewk_view.cc b/tizen_src/ewk/efl_integration/public/ewk_view.cc index 27c36b5..a96a0cb 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_view.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_view.cc @@ -1859,7 +1859,14 @@ void ewk_view_request_manifest(Evas_Object* o, } void ewk_view_media_device_list_get(Evas_Object* o, Ewk_Media_Device_List_Get_Callback callback, void* user_data) { - //TODO +#if BUILDFLAG(IS_TIZEN_TV) + LOG(INFO) << "ewk_view_media_device_list_get called"; + EWK_VIEW_IMPL_GET_OR_RETURN(o, impl); + EINA_SAFETY_ON_NULL_RETURN(callback); + impl->GetMediaDeviceList(callback, user_data); +#else + LOG_EWK_API_MOCKUP("Only for Tizen TV."); +#endif } void ewk_view_run_mixed_content_confirm_callback_set( diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 5435c2e..4825a63 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -219,6 +219,10 @@ void WebContentsDelegateEfl::NotifyMediaStateChanged(uint32_t type, web_view_->NotifyMediaStateChanged(type, previous, current); } + +void WebContentsDelegateEfl::GetMediaDeviceList(EnumerationCallback cb) { + MediaCaptureDevices::GetInstance()->GetMediaDeviceList(std::move(cb)); +} #endif void WebContentsDelegateEfl::NavigationStateChanged( diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index 9eca28d..55f3d7f 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -11,6 +11,10 @@ #include "public/ewk_view_internal.h" #include "third_party/blink/public/mojom/manifest/manifest.mojom.h" +#if BUILDFLAG(IS_TIZEN_TV) +#include "third_party/blink/public/common/mediastream/media_devices.h" +#endif + class JavaScriptDialogManagerEfl; namespace content { @@ -142,6 +146,11 @@ class WebContentsDelegateEfl : public WebContentsDelegate { uint32_t previous, uint32_t current) override; bool IsHighBitRate() const override; + using MediaDeviceEnumeration = + std::array; + using EnumerationCallback = + base::OnceCallback; + void GetMediaDeviceList(EnumerationCallback cb); #endif #if defined(TIZEN_AUTOFILL) -- 2.7.4 From 23a7cc4dd05ab920804ef0c96d6f2b61820685e0 Mon Sep 17 00:00:00 2001 From: wuxiaoliang Date: Mon, 4 Mar 2024 14:40:43 +0800 Subject: [PATCH 10/16] [M120 Migration][MM] Merge HDR and use RM API to get Codec resolution 1. Add max codec resolution for Sero TV. 2. Update VP9* codec info. 3. Set HDR info. 4. Not support spatial rendering feature. * Multiview resource allocation depends on left/right launch, and limitations are: - not support trick play - not support HDR - not support 360 video Migration from: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/290344/ https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/297093/ https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/290415/ Change-Id: If91d6130281ac10cc0dc5b414f819d1ff557b9a2 Signed-off-by: wuxiaoliang --- media/base/video_decoder_config.h | 9 ++ media/filters/stream_parser_factory.cc | 2 +- media/formats/webm/webm_colour_parser.cc | 41 +++++ media/formats/webm/webm_colour_parser.h | 4 + media/formats/webm/webm_video_client.cc | 5 + media/mojo/mojom/media_types.mojom | 2 + .../mojom/video_decoder_config_mojom_traits.cc | 7 + .../mojo/mojom/video_decoder_config_mojom_traits.h | 6 + packaging/chromium-efl.spec | 3 + .../media_capabilities/media_capabilities.cc | 11 ++ .../renderer/modules/mediasource/media_source.cc | 6 +- tizen_src/build/BUILD.gn | 13 ++ .../media/filters/esplusplayer_util.cc | 171 ++++++++++++++++++++- .../media/filters/esplusplayer_util.h | 15 ++ tizen_src/chromium_impl/media/media_efl.gni | 15 ++ 15 files changed, 304 insertions(+), 6 deletions(-) mode change 100755 => 100644 packaging/chromium-efl.spec diff --git a/media/base/video_decoder_config.h b/media/base/video_decoder_config.h index 2cdcc8a..32d882d 100644 --- a/media/base/video_decoder_config.h +++ b/media/base/video_decoder_config.h @@ -164,6 +164,11 @@ class MEDIA_EXPORT VideoDecoderConfig { void set_is_rtc(bool is_rtc) { is_rtc_ = is_rtc; } bool is_rtc() const { return is_rtc_; } +#if BUILDFLAG(IS_TIZEN_TV) + void set_hdr_info(const std::string& hdr_info) { hdr_info_ = hdr_info; } + const std::string& hdr_info() const { return hdr_info_; } +#endif + private: VideoCodec codec_ = VideoCodec::kUnknown; VideoCodecProfile profile_ = VIDEO_CODEC_PROFILE_UNKNOWN; @@ -191,6 +196,10 @@ class MEDIA_EXPORT VideoDecoderConfig { absl::optional hdr_metadata_; bool is_rtc_ = false; +#if BUILDFLAG(IS_TIZEN_TV) + std::string hdr_info_; +#endif + // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler // generated copy constructor and assignment operator. Since the extra data is // typically small, the performance impact is minimal. diff --git a/media/filters/stream_parser_factory.cc b/media/filters/stream_parser_factory.cc index 4cc65d1..aca8dff 100644 --- a/media/filters/stream_parser_factory.cc +++ b/media/filters/stream_parser_factory.cc @@ -94,7 +94,7 @@ struct SupportedTypeInfo { static const CodecInfo kVP8CodecInfo = {"vp8", CodecInfo::VIDEO, nullptr, CodecInfo::HISTOGRAM_VP8}; -static const CodecInfo kLegacyVP9CodecInfo = {"vp9", CodecInfo::VIDEO, nullptr, +static const CodecInfo kLegacyVP9CodecInfo = {"vp9*", CodecInfo::VIDEO, nullptr, CodecInfo::HISTOGRAM_VP9}; static const CodecInfo kVP9CodecInfo = {"vp09.*", CodecInfo::VIDEO, nullptr, CodecInfo::HISTOGRAM_VP9}; diff --git a/media/formats/webm/webm_colour_parser.cc b/media/formats/webm/webm_colour_parser.cc index 7680593..43c2a69 100644 --- a/media/formats/webm/webm_colour_parser.cc +++ b/media/formats/webm/webm_colour_parser.cc @@ -221,4 +221,45 @@ WebMColorMetadata WebMColourParser::GetWebMColorMetadata() const { return color_metadata; } +#if BUILDFLAG(IS_TIZEN_TV) +#define DEFAULT_ZERO(x) ((x == -1) ? 0 : x) +const std::string WebMColourParser::GetWebMHdrInfo() { + std::ostringstream s; + s << "matrixCoefficients:" << DEFAULT_ZERO(matrix_coefficients_) + << " bitsPerChannel:" << DEFAULT_ZERO(bits_per_channel_) + << " chromaSubsamplingHorz:" << DEFAULT_ZERO(chroma_subsampling_horz_) + << " chromaSubsamplingVert:" << DEFAULT_ZERO(chroma_subsampling_vert_) + << " cbSubsamplingHorz:" << DEFAULT_ZERO(cb_subsampling_horz_) + << " cbSubsamplingVert:" << DEFAULT_ZERO(cb_subsampling_vert_) + << " chromaSitingHorz:" << DEFAULT_ZERO(chroma_siting_horz_) + << " chromaSitingVert:" << DEFAULT_ZERO(chroma_siting_vert_) + << " range:" << DEFAULT_ZERO(range_) + << " transferCharacteristics:" << DEFAULT_ZERO(transfer_characteristics_) + << " primaries:" << DEFAULT_ZERO(primaries_) + << " maxCLL:" << DEFAULT_ZERO(max_content_light_level_) + << " maxFALL:" << DEFAULT_ZERO(max_content_light_level_) << " RX:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fRX + << " RY:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fRY + << " GX:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fGX + << " GY:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fGY + << " BX:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fBX + << " BY:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fBY + << " wX:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fWX + << " wY:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().primaries.fWY + << " luminanceMax:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().luminance_max + << " luminanceMin:" + << color_volume_metadata_parser_.GetColorVolumeMetadata().luminance_min; + + return s.str(); +} +#endif + } // namespace media diff --git a/media/formats/webm/webm_colour_parser.h b/media/formats/webm/webm_colour_parser.h index cb568a2d..49db1e5 100644 --- a/media/formats/webm/webm_colour_parser.h +++ b/media/formats/webm/webm_colour_parser.h @@ -69,6 +69,10 @@ class WebMColourParser : public WebMParserClient { WebMColorMetadata GetWebMColorMetadata() const; +#if BUILDFLAG(IS_TIZEN_TV) + const std::string GetWebMHdrInfo(); +#endif + private: // WebMParserClient implementation. WebMParserClient* OnListStart(int id) override; diff --git a/media/formats/webm/webm_video_client.cc b/media/formats/webm/webm_video_client.cc index 37d223d..15347cb 100644 --- a/media/formats/webm/webm_video_client.cc +++ b/media/formats/webm/webm_video_client.cc @@ -166,6 +166,11 @@ bool WebMVideoClient::InitializeConfig( color_space, kNoTransformation, coded_size, visible_rect, natural_size, codec_private, encryption_scheme); +#if defined(IS_TIZEN_TV) + if (colour_parsed_) + config->set_hdr_info(colour_parser_.GetWebMHdrInfo()); +#endif + return config->IsValidConfig(); } diff --git a/media/mojo/mojom/media_types.mojom b/media/mojo/mojom/media_types.mojom index 5f8a149..57eccec6 100644 --- a/media/mojo/mojom/media_types.mojom +++ b/media/mojo/mojom/media_types.mojom @@ -196,6 +196,8 @@ struct VideoDecoderConfig { EncryptionScheme encryption_scheme; VideoColorSpace color_space_info; gfx.mojom.HDRMetadata? hdr_metadata; + [EnableIf=is_tizen_tv] + string hdr_info; }; // Native struct media::SubsampleEntry; diff --git a/media/mojo/mojom/video_decoder_config_mojom_traits.cc b/media/mojo/mojom/video_decoder_config_mojom_traits.cc index fbb3712..a292413 100644 --- a/media/mojo/mojom/video_decoder_config_mojom_traits.cc +++ b/media/mojo/mojom/video_decoder_config_mojom_traits.cc @@ -63,6 +63,13 @@ bool StructTraitsset_level(input.level()); +#if BUILDFLAG(IS_TIZEN_TV) + std::string hdr; + if (!input.ReadHdrInfo(&hdr)) + return false; + output->set_hdr_info(hdr.c_str()); +#endif + if (!output->IsValidConfig()) return false; diff --git a/media/mojo/mojom/video_decoder_config_mojom_traits.h b/media/mojo/mojom/video_decoder_config_mojom_traits.h index f79c60f..072da542 100644 --- a/media/mojo/mojom/video_decoder_config_mojom_traits.h +++ b/media/mojo/mojom/video_decoder_config_mojom_traits.h @@ -74,6 +74,12 @@ struct StructTraits= 60 +BuildRequires: pkgconfig(resource-center-api) +%endif %endif %if "%{__enable_capi_thread_booster}" == "1" diff --git a/third_party/blink/renderer/modules/media_capabilities/media_capabilities.cc b/third_party/blink/renderer/modules/media_capabilities/media_capabilities.cc index 550bff33..af9d7a2 100644 --- a/third_party/blink/renderer/modules/media_capabilities/media_capabilities.cc +++ b/third_party/blink/renderer/modules/media_capabilities/media_capabilities.cc @@ -430,6 +430,11 @@ WebAudioConfiguration ToWebAudioConfiguration( if (configuration->hasSamplerate()) web_configuration.samplerate = configuration->samplerate(); +#if BUILDFLAG(IS_TIZEN_TV) + if (configuration->hasSpatialRendering()) + web_configuration.spatialRendering = configuration->spatialRendering(); +#endif + return web_configuration; } @@ -683,6 +688,12 @@ bool IsAudioConfigurationSupported( if (audio_config->hasSpatialRendering()) is_spatial_rendering = audio_config->spatialRendering(); +#if BUILDFLAG(IS_TIZEN_TV) + // Currently there is no support for spatial rendering feature + if (is_spatial_rendering) + return false; +#endif + return media::IsSupportedAudioType( {audio_codec, audio_profile, is_spatial_rendering}); } diff --git a/third_party/blink/renderer/modules/mediasource/media_source.cc b/third_party/blink/renderer/modules/mediasource/media_source.cc index d66cc97..4a8adf9 100644 --- a/third_party/blink/renderer/modules/mediasource/media_source.cc +++ b/third_party/blink/renderer/modules/mediasource/media_source.cc @@ -694,9 +694,9 @@ bool MediaSource::IsTypeSupportedInternal(ExecutionContext* context, bool result = supported == MIMETypeRegistry::kSupported; - DVLOG(2) << __func__ << "(" << type << ", " - << (enforce_codec_specificity ? "true" : "false") << ") -> " - << (result ? "true" : "false"); + LOG(INFO) << __func__ << "(" << type << ", " + << (enforce_codec_specificity ? "true" : "false") << ") -> " + << (result ? "true" : "false"); RecordIdentifiabilityMetric(context, type, result); return result; } diff --git a/tizen_src/build/BUILD.gn b/tizen_src/build/BUILD.gn index c57dcd9..f05af15 100644 --- a/tizen_src/build/BUILD.gn +++ b/tizen_src/build/BUILD.gn @@ -55,6 +55,19 @@ config("ecore-x-public") { } } +config("resource-center-api") { + if (tizen_product_tv && tizen_version >= 60) { + ldflags = [ "-lresource-center-api" ] + } +} + +tizen_pkg_config("libresource-center-api") { + packages = [] + if (tizen_product_tv && tizen_version >= 60) { + packages = [ "resource-center-api" ] + } +} + config("ecore-wayland") { if (is_tizen && use_wayland) { if (tizen_version >= 50) { diff --git a/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc b/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc index 6094401..13cb234 100644 --- a/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc +++ b/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc @@ -4,9 +4,23 @@ #include "tizen_src/chromium_impl/media/filters/esplusplayer_util.h" +#include + +#include "base/json/json_reader.h" #include "base/logging.h" +#include "tizen_src/chromium_impl/build/tizen_version.h" #if BUILDFLAG(IS_TIZEN_TV) +#include +#include +#include +#include +#include +#include "base/command_line.h" +#include "base/memory/ptr_util.h" +#include "content/public/common/content_switches.h" +#include "ewk/efl_integration/common/application_type.h" +#include "ewk/efl_integration/common/content_switches_efl.h" #include "tizen_src/chromium_impl/tizen/tizen_tv_platform.h" #endif @@ -185,22 +199,149 @@ PipelineStatus GetPipelineError(const esplusplayer_error_type error) { return PIPELINE_ERROR_DECODE; } +bool isProductTypeSero() { + bool is_sero = false; +#if BUILDFLAG(IS_TIZEN_TV) + is_sero = isTVRotated(); +#endif + + LOG(INFO) << "This product type is " << (is_sero ? "a Sero" : "not a Sero"); + return is_sero; +} + +#if BUILDFLAG(IS_TIZEN_TV) && TIZEN_VERSION_AT_LEAST(6, 0, 0) +gfx::Size GetDynamicMaxCodecResolution() { + int max_width = 0; + int max_height = 0; + int max_framerate = 0; + std::string app_id = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kTizenAppId); + + // resource center returns decodeer ability not resolution (ex.1088) + // http://wiki.vd.sec.samsung.net/display/OSS/02.+Max+Resolution + if (rc_get_max_video_resolution(app_id.c_str(), &max_width, &max_height, + &max_framerate) < 0) { + LOG(ERROR) << "Getting max video resolution failed in multiview mode."; + return {kFHDVideoMaxWidth, kFHDVideoMaxHeight}; + } + + // H.264 has to be decoded by 4K decoder(dvde) in multiview mode + // to support below scenario. + // Left FHD@30 (TVPlus) | Right FHD@60 (AirPlay is placed at right always) + // Refer to http://wiki.vd.sec.samsung.net/display/OSS/10.+Resource+table + if (max_width >= k8KVideoMaxWidth) { + return k8KVideoMaxSize; + } else if (max_width >= k4KVideoMaxWidth && max_width < k8KVideoMaxWidth) { + return k4KVideoMaxSize; + } else { + return kFHDVideoMaxSize; + } +} + +const char* GetRIVideoCodecName(esplusplayer_video_mime_type mime_type) { + switch (mime_type) { + case ESPLUSPLAYER_VIDEO_MIME_TYPE_AV1: + return RI_CODEC_NAME_AV1; + case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP8: + return RI_CODEC_NAME_VP8; + case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP9: + return RI_CODEC_NAME_VP9; + case ESPLUSPLAYER_VIDEO_MIME_TYPE_HEVC: + return RI_CODEC_NAME_HEVC; + case ESPLUSPLAYER_VIDEO_MIME_TYPE_H264: + return RI_CODEC_NAME_H264; + case ESPLUSPLAYER_VIDEO_MIME_TYPE_MJPEG: + return RI_CODEC_NAME_MJPEG; + default: + break; + } + return ""; +} + +gfx::Size GetMaxCodecResolutionRI(esplusplayer_video_mime_type mime_type, + bool is_video_hole) { + int max_width = 0; + int max_height = 0; + int max_framerate = 0; + const char* ri_video_codec = GetRIVideoCodecName(mime_type); + + // In portrait mode adaptive streaming has some problem + // when changing a resolution so Sero uses dvde decoder + // for all kind of codecs. + // The dvde decoder doesn't support VP8 and WMV. It is Sero product spec. + if (!*ri_video_codec) { + if (isProductTypeSero()) { + return k4KVideoMaxSize; + } else { + return kFHDVideoMaxSize; + } + } + + if (ri_video_codec == RI_CODEC_NAME_H264) { + if (is_video_hole && isProductTypeSero()) + return k4KVideoMaxSize; + else + return kFHDVideoMaxSize; + } + + if (ri_get_max_resolution(ri_video_codec, &max_width, &max_height, + &max_framerate) != RI_OK) { + LOG(WARNING) << "Failed to get video max information"; + const auto panel_resolution = GetPanelResolution(); + return {panel_resolution.width(), panel_resolution.height()}; + } + + if (max_width >= k8KVideoMaxWidth) { + max_width = k8KVideoMaxWidth; + max_height = k8KVideoMaxHeight; + } else if (max_width >= k4KVideoMaxWidth && max_width < k8KVideoMaxWidth) { + max_width = k4KVideoMaxWidth; + max_height = k4KVideoMaxHeight; + } else if (max_width >= kFHDVideoMaxWidth && max_width < k4KVideoMaxWidth) { + max_width = kFHDVideoMaxWidth; + max_height = kFHDVideoMaxHeight; + } + return {max_width, max_height}; +} +#endif + gfx::Size GetMaxCodecResolution(esplusplayer_video_mime_type mime_type, bool is_video_hole) { +#if BUILDFLAG(IS_TIZEN_TV) && TIZEN_VERSION_AT_LEAST(6, 0, 0) + if (media::IsMultiviewMode()) { + // Multiview specification: + // http://wiki.vd.sec.samsung.net/pages/viewpage.action?pageId=79211942 + return GetDynamicMaxCodecResolution(); + } + return GetMaxCodecResolutionRI(mime_type, is_video_hole); +#else switch (mime_type) { case ESPLUSPLAYER_VIDEO_MIME_TYPE_AV1: case ESPLUSPLAYER_VIDEO_MIME_TYPE_HEVC: case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP9: return k8KVideoMaxSize; case ESPLUSPLAYER_VIDEO_MIME_TYPE_H264: - if (is_video_hole) + // H.264 has to be decoded by dvde decoder in multiview mode + // to support below scenario. + // Left FHD@30 (TVPlus) | Right FHD@60 (AirPlay) + // Refer to http://wiki.vd.sec.samsung.net/display/OSS/10.+Resource+table + if (is_video_hole && isProductTypeSero()) return k4KVideoMaxSize; else return kFHDVideoMaxSize; case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP8: default: - return kFHDVideoMaxSize; + // In portrait mode adaptive streaming has some problem + // when changing a resolution so Sero uses dvde decoder + // for all kind of codecs. + // The dvde decoder doesn't support VP8 and WMV. It is Sero product spec. + if (isProductTypeSero()) + return k4KVideoMaxSize; + else + return kFHDVideoMaxSize; } +#endif } gfx::Size GetPanelResolution() { @@ -234,4 +375,30 @@ esplusplayer_display_rotation_type ConvertToESPlusPlayerDisplayRotation( } } +#if BUILDFLAG(IS_TIZEN_TV) +bool IsMultiviewMode() { + const char vconf_multiview_info[] = "memory/multiscreen/info"; + + char* multiview_info = vconf_get_str(vconf_multiview_info); + if (multiview_info) { + auto multiview_info_value = base::JSONReader::Read(multiview_info); + free(multiview_info); + if (!multiview_info_value || !multiview_info_value->is_dict()) { + LOG(ERROR) << "read vconf multiview info failed"; + return false; + } + + base::Value::Dict& dict = multiview_info_value->GetDict(); + + const std::string* mode_value = dict.FindString("mode"); + if (mode_value && *mode_value == "on") { + LOG(INFO) << "It is in multiview mode."; + return true; + } + } + + return false; +} +#endif + } // namespace media diff --git a/tizen_src/chromium_impl/media/filters/esplusplayer_util.h b/tizen_src/chromium_impl/media/filters/esplusplayer_util.h index 5086de1..0208cd8 100644 --- a/tizen_src/chromium_impl/media/filters/esplusplayer_util.h +++ b/tizen_src/chromium_impl/media/filters/esplusplayer_util.h @@ -13,6 +13,17 @@ #include "tizen_src/chromium_impl/media/filters/buffer_observer.h" #include "ui/gfx/geometry/size.h" +constexpr auto kFHDVideoMaxWidth = 1920; +constexpr auto kFHDVideoMaxHeight = 1080; +constexpr auto kQHDVideoMaxWidth = 2560; +constexpr auto kQHDVideoMaxHeight = 1440; +constexpr auto k4KVideoMaxWidth = 3840; +constexpr auto k4KVideoMaxHeight = 2160; +constexpr auto k4KDCIVideoMaxWidth = 4096; +constexpr auto k4KDCIVideoMaxHeight = 2160; +constexpr auto k8KVideoMaxWidth = 7680; +constexpr auto k8KVideoMaxHeight = 4320; + namespace media { constexpr int kElementryStreamCount = 2; // Audio, Video only. constexpr int kVideoFramerateDen = 100; @@ -43,6 +54,10 @@ gfx::Size GetMaxResolution(esplusplayer_video_mime_type mime_type, esplusplayer_display_rotation_type ConvertToESPlusPlayerDisplayRotation( int rotation); +#if BUILDFLAG(IS_TIZEN_TV) +bool IsMultiviewMode(); +#endif + } // namespace media #endif // MEDIA_FILTERS_ESPP_PLAYER_UTIL_H_ diff --git a/tizen_src/chromium_impl/media/media_efl.gni b/tizen_src/chromium_impl/media/media_efl.gni index e50eeba..edaf05c 100644 --- a/tizen_src/chromium_impl/media/media_efl.gni +++ b/tizen_src/chromium_impl/media/media_efl.gni @@ -24,8 +24,23 @@ if (tizen_multimedia) { "//tizen_src/build:esplusplayer", "//tizen_src/build:libesplusplayer", "//tizen_src/chromium_impl/media:media_efl_config", + "//tizen_src/build:tizen-tv-resource-manager-config", ] + if(tizen_product_tv) { + external_media_video_decode_config += [ + "//tizen_src/build:hdmicec-api", + "//tizen_src/build:libhdmicec-api", + ] + } + + if(tizen_product_tv) { + external_media_video_decode_config += [ + "//tizen_src/build:resource-center-api", + "//tizen_src/build:libresource-center-api", + ] + } + if (use_wayland) { external_media_video_decode_config += [ "//tizen_src/build:ecore-wayland", -- 2.7.4 From 56fd8f3efe0f23df915498ac61234c7fc61fe313 Mon Sep 17 00:00:00 2001 From: fang fengrong Date: Mon, 4 Mar 2024 20:09:26 +0800 Subject: [PATCH 11/16] [M120 Migration][VD] Fix ewk_view_focus_set fail issue WebBrowser set focus through ewk_view_focus_set api not work at first launch. Because when set focus, the offscreen_helper haven't been created, it cause don't SetFocus. So pending send focus till RenderFrameLive. refer: https://review.tizen.org/gerrit/#/c/298820/ Change-Id: I6a0722bd7853aefce9547864642383dc199ba7b5 Signed-off-by: fang fengrong --- tizen_src/ewk/efl_integration/eweb_view.cc | 12 ++++++++---- tizen_src/ewk/efl_integration/eweb_view.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index c6f8160..7e64d85 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -537,19 +537,23 @@ void EWebView::ResetContextMenuController() { #if BUILDFLAG(IS_TIZEN_TV) void EWebView::RunPendingSetFocus(Eina_Bool focus) { - if (!web_contents_ || !rwhva() || (HasFocus() == focus)) + SetFocusInternal(focus); +} + +void EWebView::SetFocusInternal(Eina_Bool focus) { + if (!rwhva() || !rwhva()->offscreen_helper() || (HasFocus() == focus)) return; rwhva()->offscreen_helper()->Focus(focus); } #endif void EWebView::SetFocus(Eina_Bool focus) { - if (!web_contents_ || !rwhva() || (HasFocus() == focus)) + if (!web_contents_) return; #if BUILDFLAG(IS_TIZEN_TV) if (web_contents_->GetPrimaryMainFrame()->IsRenderFrameLive()) { - rwhva()->offscreen_helper()->Focus(focus); + SetFocusInternal(focus); if (pending_setfocus_closure_) pending_setfocus_closure_.Reset(); @@ -564,7 +568,7 @@ void EWebView::SetFocus(Eina_Bool focus) { } Eina_Bool EWebView::HasFocus() const { - if (!rwhva()) + if (!rwhva() || !rwhva()->offscreen_helper()) return EINA_FALSE; return rwhva()->offscreen_helper()->HasFocus() ? EINA_TRUE : EINA_FALSE; diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index de4f3d8..055fd05 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -811,6 +811,7 @@ class EWebView { void InitInspectorServer(); void RunPendingSetFocus(Eina_Bool focus); + void SetFocusInternal(Eina_Bool focus); #endif JavaScriptDialogManagerEfl* GetJavaScriptDialogManagerEfl(); -- 2.7.4 From 207297b428e6e8e829b70b99038ff721a8a1e8e6 Mon Sep 17 00:00:00 2001 From: Qiang Ji Date: Mon, 4 Mar 2024 16:40:37 +0800 Subject: [PATCH 12/16] [M120 Migration] NUI related patch 1. Fix rotation issue for NUI app Ecore_Evas can't sense that NUI app has rotated, so get the wrong value from ecore_evas_rotation_get API refs: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/305631/ 2. Fix NUI video can't play issue NUI app use wayland window but video hole set as evas window default. refs: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/295315/ 3. Fix crash refs: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/297840/ Change-Id: Id043740ee26661581c754b5b2cbf71f65130f7ee Signed-off-by: Qiang Ji --- cc/trees/draw_property_utils.cc | 7 +++--- .../browser/web_contents/web_contents_view_aura.cc | 25 +++++++++++++++++++++- .../media/base/tizen/video_plane_controller.cc | 1 + .../media/base/tizen/video_plane_controller.h | 6 ++++++ .../media/filters/media_player_esplusplayer.cc | 3 ++- tizen_src/ewk/efl_integration/eweb_view.cc | 15 +++++++++++++ tizen_src/ewk/efl_integration/public/ewk_view.cc | 3 +++ 7 files changed, 55 insertions(+), 5 deletions(-) diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc index f55ffb1..c17fc58 100644 --- a/cc/trees/draw_property_utils.cc +++ b/cc/trees/draw_property_utils.cc @@ -255,9 +255,10 @@ ConditionalClip ComputeAccumulatedClip(PropertyTrees* property_trees, // contributing layer that escapes clip, this will find the nearest ancestor // that doesn't. while (target_node->clip_id > clip_node->id || - property_trees->effect_tree() - .GetRenderSurface(target_node->id) - ->has_contributing_layer_that_escapes_clip()) { + (property_trees->effect_tree().GetRenderSurface(target_node->id) && + property_trees->effect_tree() + .GetRenderSurface(target_node->id) + ->has_contributing_layer_that_escapes_clip())) { target_node = effect_tree.Node(target_node->target_id); } diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index 4831918..ca6e320 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -96,6 +96,15 @@ #include "wrt/public/browser/wrt.h" #endif +#if BUILDFLAG(IS_TIZEN_TV) +#include "ewk/efl_integration/common/application_type.h" +#include "ui/ozone/platform/efl/efl_screen.h" +#endif + +#if defined(TIZEN_TBM_SUPPORT) +#include "ui/compositor/compositor.h" +#endif + namespace content { std::unique_ptr CreateWebContentsView( @@ -919,7 +928,21 @@ void WebContentsViewAura::Focus() { #if BUILDFLAG(IS_TIZEN) void WebContentsViewAura::SetOrientation(int orientation) { LOG(INFO) << __FUNCTION__ << " " << orientation; - NOTIMPLEMENTED(); + + RenderWidgetHostViewAura* rwhv_aura = static_cast( + web_contents_->GetRenderWidgetHostView()); + if (rwhv_aura) { +#if defined(TIZEN_TBM_SUPPORT) + if (rwhv_aura->GetCompositor() && + rwhv_aura->GetCompositor()->use_tbm_surface_for_offscreen_rendering()) { + display::DeviceDisplayInfoEfl display_info; + display_info.SetRotationDegrees(orientation); + } +#endif + } + + TRACE_EVENT1("viz", "WebContentsViewAura::SetOrientation", "orientation", orientation); + orientation_ = orientation; } #endif diff --git a/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.cc b/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.cc index 01f35de..582fbe1 100644 --- a/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.cc +++ b/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.cc @@ -13,6 +13,7 @@ namespace media { void* VideoPlaneController::main_window_handle_ = nullptr; VideoPlaneController::RenderingMode VideoPlaneController::rendering_mode_ = VideoPlaneController::RenderingMode::OFFSCREEN; +bool VideoPlaneController::use_wayland_window = false; VideoPlaneController::VideoPlaneController() : should_crop_video_(false) {} diff --git a/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.h b/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.h index ccfc550..3520722 100644 --- a/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.h +++ b/tizen_src/chromium_impl/media/base/tizen/video_plane_controller.h @@ -26,6 +26,12 @@ class MEDIA_EXPORT VideoPlaneController { } static RenderingMode rendering_mode() { return rendering_mode_; } + static void set_use_wayland_window(bool use) { use_wayland_window = use; } + + static bool get_use_wayland_window() { return use_wayland_window; } + + static bool use_wayland_window; + VideoPlaneController(); virtual ~VideoPlaneController(); diff --git a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc index 4afa7e3..d7bd803 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc @@ -1407,7 +1407,8 @@ void MediaPlayerESPlusPlayer::PrepareVideoHole() { LOG(INFO) << __func__ << " set ESPLUSPLAYER_DISPLAY_TYPE_OVERLAY"; int player_error = ESPLUSPLAYER_ERROR_TYPE_NONE; if (video_plane_controller_->rendering_mode() == - VideoPlaneController::RenderingMode::OFFSCREEN) { + VideoPlaneController::RenderingMode::OFFSCREEN && + !video_plane_controller_->get_use_wayland_window()) { player_error = esplusplayer_set_display( esplayer_, ESPLUSPLAYER_DISPLAY_TYPE_OVERLAY, video_plane_controller_->GetVideoPlaneHandle()); diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 7e64d85..23037c1 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -166,6 +166,21 @@ void GetEinaRectFromGfxRect(const gfx::Rect& gfx_rect, #if BUILDFLAG(IS_TIZEN) static Eina_Bool RotateWindowCb(void* data, int type, void* event) { auto wv = static_cast(data); +#if defined(TIZEN_TBM_SUPPORT) + if (wv->rwhva() && wv->rwhva()->GetCompositor() && + wv->rwhva()->GetCompositor()->use_tbm_surface_for_offscreen_rendering()) { + Ecore_Wl2_Event_Window_Rotation* rotateEvent = + static_cast(event); + if (rotateEvent != nullptr) { + LOG(INFO) << "For NUI app, new ori " << rotateEvent->angle; + wv->SetOrientation(rotateEvent->angle); + } + return ECORE_CALLBACK_PASS_ON; + } +#endif + LOG(INFO) << "New ori " + << ecore_evas_rotation_get( + ecore_evas_ecore_evas_get(wv->GetEvas())); wv->SetOrientation( ecore_evas_rotation_get(ecore_evas_ecore_evas_get(wv->GetEvas()))); return ECORE_CALLBACK_PASS_ON; diff --git a/tizen_src/ewk/efl_integration/public/ewk_view.cc b/tizen_src/ewk/efl_integration/public/ewk_view.cc index a96a0cb..61f536b 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_view.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_view.cc @@ -1653,6 +1653,9 @@ void ewk_view_offscreen_rendering_enabled_set(Evas_Object* o, Eina_Bool enabled) #if defined(TIZEN_TBM_SUPPORT) EWK_VIEW_IMPL_GET_OR_RETURN(o, impl); impl->SetOffscreenRendering(enabled); +#if defined(TIZEN_VIDEO_HOLE) + media::VideoPlaneController::set_use_wayland_window(true); +#endif #else LOG_EWK_API_MOCKUP(); #endif -- 2.7.4 From 25f910c865ebf5b96b0765f9705f146b6495c703 Mon Sep 17 00:00:00 2001 From: yangzhiwen Date: Mon, 4 Mar 2024 16:57:42 +0800 Subject: [PATCH 13/16] [M120 Migration] Support Downloadable font info feature Migration from: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/292674/ Change-Id: I71b63bab8327083cc23aaccaf485e0364e1cbea5 Signed-off-by: yangzhiwen --- content/public/browser/web_contents_delegate.h | 4 ++++ .../media/filters/media_player_bridge_capi_tv.cc | 13 +++++++++++++ .../media/filters/media_player_bridge_capi_tv.h | 4 ++++ tizen_src/ewk/efl_integration/eweb_view.cc | 13 +++++++++++++ tizen_src/ewk/efl_integration/eweb_view.h | 4 ++++ tizen_src/ewk/efl_integration/eweb_view_callbacks.h | 2 ++ tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc | 11 +++++++++++ tizen_src/ewk/efl_integration/web_contents_delegate_efl.h | 4 ++++ 8 files changed, 55 insertions(+) diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 3798652..8776ed2 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -740,6 +740,10 @@ class CONTENT_EXPORT WebContentsDelegate { uint32_t previous, uint32_t current) {}; virtual bool IsHighBitRate() const { return false; } + virtual void NotifyDownloadableFontInfo(const std::string& scheme_id_uri, + const std::string& value, + const std::string& data, + int type) {} #endif #if BUILDFLAG(IS_ANDROID) diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc index 1a05845..da8a9a5 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc @@ -209,4 +209,17 @@ bool MediaPlayerBridgeCapiTV::CheckHighBitRate() { return ret; } +void MediaPlayerBridgeCapiTV::HandleDownloadableFontInfo( + const std::string& scheme_id_uri, + const std::string& value, + const std::string& data, + int type) { + content::WebContentsDelegate* web_contents_delegate = + GetMediaPlayerClient()->GetWebContentsDelegate(); + if (!web_contents_delegate) + return; + web_contents_delegate->NotifyDownloadableFontInfo(scheme_id_uri, value, data, + type); +} + } // namespace media diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h index eeeba28..68f09cf 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h @@ -33,6 +33,10 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi { void PlaybackCompleteUpdate() override; void AppendUrlHighBitRate(const std::string& url); bool CheckHighBitRate(); + void HandleDownloadableFontInfo(const std::string& scheme_id_uri, + const std::string& value, + const std::string& data, + int type); protected: void PlayerPrepared() override; diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 23037c1..9e830c0 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -3423,6 +3423,19 @@ bool EWebView::SetMixedContents(bool allow) { return mixed_content_observer->MixedContentReply(allow); } +void EWebView::NotifyDownloadableFontInfo(const char* scheme_id_uri, + const char* value, + const char* data, + int type) { + LOG(INFO) << "scheme_id_uri:" << scheme_id_uri << ",value:" << value + << ",data:" << data << ",type:" << type; + Ewk_Media_Downloadable_Font_Info* info = + ewkMediaDownloadableFontInfoCreate(scheme_id_uri, value, data, type); + SmartCallback().call( + static_cast(info)); + ewkMediaDownloadableFontInfoDelete(info); +} + void EWebView::NotifyMediaStateChanged(uint32_t device_type, uint32_t previous, uint32_t current) { diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 055fd05..6cb3204 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -376,6 +376,10 @@ class EWebView { void Stop(); #if BUILDFLAG(IS_TIZEN_TV) void SetFloatVideoWindowState(bool enabled); + void NotifyDownloadableFontInfo(const char* scheme_id_uri, + const char* value, + const char* data, + int type); #endif // IS_TIZEN_TV void SetSessionTimeout(uint64_t timeout); double GetTextZoomFactor() const; diff --git a/tizen_src/ewk/efl_integration/eweb_view_callbacks.h b/tizen_src/ewk/efl_integration/eweb_view_callbacks.h index 8b5b2e2..bd2cc64 100644 --- a/tizen_src/ewk/efl_integration/eweb_view_callbacks.h +++ b/tizen_src/ewk/efl_integration/eweb_view_callbacks.h @@ -114,6 +114,7 @@ enum CallbackType { EdgeTop, EdgeBottom, #if BUILDFLAG(IS_TIZEN_TV) + DownloadableFontInfo, EdgeScrollBottom, EdgeScrollLeft, EdgeScrollRight, @@ -284,6 +285,7 @@ DECLARE_EWK_VIEW_CALLBACK(EdgeTop, "edge,top", void); DECLARE_EWK_VIEW_CALLBACK(EdgeBottom, "edge,bottom", void); DECLARE_EWK_VIEW_CALLBACK(EdgeRight, "edge,right", void); #if BUILDFLAG(IS_TIZEN_TV) +DECLARE_EWK_VIEW_CALLBACK(DownloadableFontInfo, "on,downloadable,font", void*); DECLARE_EWK_VIEW_CALLBACK(EdgeScrollBottom, "edge,scroll,bottom", bool*); DECLARE_EWK_VIEW_CALLBACK(EdgeScrollLeft, "edge,scroll,left", bool*); DECLARE_EWK_VIEW_CALLBACK(EdgeScrollRight, "edge,scroll,right", bool*); diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 4825a63..f8a52dc 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -786,5 +786,16 @@ void WebContentsDelegateEfl::DidEdgeScrollBy(const gfx::Point& offset, bool WebContentsDelegateEfl::IsHighBitRate() const { return web_view_ ? web_view_->IsHighBitRate() : false; } + +void WebContentsDelegateEfl::NotifyDownloadableFontInfo( + const std::string& scheme_id_uri, + const std::string& value, + const std::string& data, + int type) { + if (!web_view_) + return; + web_view_->NotifyDownloadableFontInfo(scheme_id_uri.c_str(), value.c_str(), + data.c_str(), type); +} #endif } // namespace content diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index 55f3d7f..42fb4c7 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -77,6 +77,10 @@ class WebContentsDelegateEfl : public WebContentsDelegate { #if BUILDFLAG(IS_TIZEN_TV) //Browser edge scroll void DidEdgeScrollBy(const gfx::Point& offset, bool handled) override; + void NotifyDownloadableFontInfo(const std::string& scheme_id_uri, + const std::string& value, + const std::string& data, + int type) override; #endif void RequestCertificateConfirm( WebContents* web_contents, -- 2.7.4 From c09d91b89a4af97cee67c5ace08ec5b03509ded2 Mon Sep 17 00:00:00 2001 From: fangfengrong Date: Tue, 5 Mar 2024 11:08:55 +0800 Subject: [PATCH 14/16] [M120 Migration][VD] Don't set focus when FinishLoad For WRT type App, will set focus when app show: WRTNativeWindow::Show()->WRTNativeWindow::Focus(); For Browser/hbbtv type App, will set focus by ewk_view_focus_set api. Keep same with M94, don't set focus when FinishLoad, or else will cause two focus issue: one focus on webview, another focus on app(such as on webbrowser url). refer: https://review.tizen.org/gerrit/#/c/296637/ Change-Id: I61eee8952019b9cc342ad88503276bb6399a6d43 Signed-off-by: fangfengrong --- tizen_src/ewk/efl_integration/web_contents_observer_efl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tizen_src/ewk/efl_integration/web_contents_observer_efl.cc b/tizen_src/ewk/efl_integration/web_contents_observer_efl.cc index e22fefa..5027c50 100644 --- a/tizen_src/ewk/efl_integration/web_contents_observer_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_observer_efl.cc @@ -25,6 +25,7 @@ #include "ipc/ipc_message_macros.h" #include "printing/metafile_skia.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "tizen_src/chromium_impl/tizen/system_info.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" #include "url/gurl.h" @@ -154,7 +155,8 @@ void WebContentsObserverEfl::DidFinishLoad(RenderFrameHost* render_frame_host, #endif TTRACE_WEB("WebContentsObserverEfl::DidFinishLoad"); - web_contents_.Focus(); + if (IsMobileProfile() || IsWearableProfile()) + web_contents_.Focus(); } void WebContentsObserverEfl::DidFailLoad(RenderFrameHost* render_frame_host, -- 2.7.4 From 65ddc4d548ff47b622db319d07facb8c0672b5e0 Mon Sep 17 00:00:00 2001 From: "zhishun.zhou" Date: Tue, 5 Mar 2024 14:08:38 +0800 Subject: [PATCH 15/16] [M120 Migration][MM] Support webmedia playback state notification 1. webbrowser need playbackstart event to show miniplayer button, this patch implement ewk interface to notify player state to APP, at the same time it get translated url and drm information from APP; 2. Impement a switch kEnableMediaPlaybackNotification, set from ewk_settings_media_playback_notification_set; 3. Impement GetContentMIMEType from html media element and set it to esplayer; Patch from: https://review.tizen.org/gerrit/#/c/292410/ Change-Id: I88c787896baa4176769c3eb64214d94bee72ffaa Signed-off-by: xiaofang Signed-off-by: zhishun.zhou --- content/browser/web_contents/web_contents_impl.cc | 6 +++ content/public/browser/web_contents_delegate.h | 9 +++- content/public/common/content_switches.cc | 3 ++ content/public/common/content_switches.h | 1 + media/base/pipeline.h | 3 ++ media/base/pipeline_impl.cc | 37 ++++++++++++++ media/base/pipeline_impl.h | 3 ++ media/base/renderer.h | 4 ++ media/filters/pipeline_controller.cc | 6 +++ media/filters/pipeline_controller.h | 3 ++ media/mojo/clients/mojo_renderer.cc | 10 ++++ media/mojo/clients/mojo_renderer.h | 4 ++ media/mojo/clients/mojo_renderer_wrapper.cc | 7 +++ media/mojo/clients/mojo_renderer_wrapper.h | 4 ++ media/mojo/mojom/renderer.mojom | 3 ++ media/mojo/services/mojo_renderer_service.cc | 8 +++ media/mojo/services/mojo_renderer_service.h | 4 ++ net/base/mime_util.cc | 3 ++ .../web_preferences_mojom_traits.cc | 2 + .../common/web_preferences/web_preferences.h | 4 ++ .../web_preferences/web_preferences_mojom_traits.h | 5 ++ .../mojom/webpreferences/web_preferences.mojom | 3 ++ .../public/platform/web_media_player_client.h | 4 ++ third_party/blink/public/web/web_settings.h | 5 ++ .../renderer/core/exported/web_settings_impl.cc | 10 ++++ .../renderer/core/exported/web_settings_impl.h | 2 + .../blink/renderer/core/exported/web_view_impl.cc | 2 + third_party/blink/renderer/core/frame/settings.h | 13 +++++ .../renderer/core/html/media/html_media_element.cc | 32 ++++++++++++ .../renderer/core/html/media/html_media_element.h | 7 +++ .../platform/media/web_media_player_impl.cc | 5 ++ .../content/browser/media/tizen_renderer_impl.cc | 50 ++++++++++++++++++ .../content/browser/media/tizen_renderer_impl.h | 24 +++++++++ .../media/filters/media_player_bridge_capi.h | 6 ++- .../media/filters/media_player_bridge_capi_tv.cc | 37 ++++++++++++++ .../media/filters/media_player_esplusplayer.h | 4 +- .../media/filters/media_player_esplusplayer_tv.cc | 11 ++++ .../media/filters/media_player_tizen.h | 14 ++++- .../media/filters/media_player_tizen_client.h | 8 +++ tizen_src/ewk/efl_integration/BUILD.gn | 1 + tizen_src/ewk/efl_integration/eweb_view.cc | 59 ++++++++++++++++++++++ tizen_src/ewk/efl_integration/eweb_view.h | 14 +++++ .../public/ewk_media_playback_info.cc | 57 ++++++++++++++------- .../ewk/efl_integration/public/ewk_settings.cc | 12 +++++ .../efl_integration/web_contents_delegate_efl.cc | 22 ++++++++ .../efl_integration/web_contents_delegate_efl.h | 7 +++ 46 files changed, 514 insertions(+), 24 deletions(-) diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index c2d2248..46ae83a 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -3229,6 +3229,12 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() { prefs.user_gesture_required_for_presentation = !command_line.HasSwitch( switches::kDisableGestureRequirementForPresentation); +#if BUILDFLAG(IS_TIZEN_TV) + // Disallow media playback notification by default. + prefs.media_playback_notification_enabled = + command_line.HasSwitch(switches::kEnableMediaPlaybackNotification); +#endif + #if BUILDFLAG(IS_TIZEN) if (command_line.HasSwitch(switches::kMaxRefreshRate)) { int refresh_rate = 0; diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 8776ed2..2bf3192 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -735,10 +735,17 @@ class CONTENT_EXPORT WebContentsDelegate { virtual void ExitPictureInPicture() {} #if BUILDFLAG(IS_TIZEN_TV) + virtual void NotifyPlaybackState(int state, + int player_id, + const std::string& url, + const std::string& mime_type, + bool* media_resource_acquired, + std::string* translated_url, + std::string* drm_info) {} // Notify Media State to Web browser virtual void NotifyMediaStateChanged(uint32_t type, uint32_t previous, - uint32_t current) {}; + uint32_t current) {} virtual bool IsHighBitRate() const { return false; } virtual void NotifyDownloadableFontInfo(const std::string& scheme_id_uri, const std::string& value, diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 7b03c23..7f95a83 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -1078,6 +1078,9 @@ const char kMaxRefreshRate[] = "max-refresh-rate"; #endif #if BUILDFLAG(IS_TIZEN_TV) +// Enables media playback notification for other applications +const char kEnableMediaPlaybackNotification[] = + "enable-media-playback-notification"; // Enables dual decoding for webrtc video call const char kDualDecodingWebRTC[] = "enable-webrtc-dual-decoding"; // Enables multiplayers feature for web app diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 886b0f9..a851eed 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -300,6 +300,7 @@ CONTENT_EXPORT extern const char kMaxRefreshRate[]; #endif #if BUILDFLAG(IS_TIZEN_TV) +CONTENT_EXPORT extern const char kEnableMediaPlaybackNotification[]; CONTENT_EXPORT extern const char kDualDecodingWebRTC[]; CONTENT_EXPORT extern const char kEnableMultiPlayerForWebapp[]; #endif diff --git a/media/base/pipeline.h b/media/base/pipeline.h index 8e1f221..a2e4554 100644 --- a/media/base/pipeline.h +++ b/media/base/pipeline.h @@ -278,6 +278,9 @@ class MEDIA_EXPORT Pipeline { #if defined(TIZEN_VIDEO_HOLE) virtual void SetMediaGeometry(const gfx::RectF rect_f) = 0; #endif +#if BUILDFLAG(IS_TIZEN_TV) + virtual void SetContentMimeType(const std::string& mime_type) = 0; +#endif }; } // namespace media diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 2b991e6..bf67b12 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -110,6 +110,9 @@ class PipelineImpl::RendererWrapper final : public DemuxerHost, #if defined(TIZEN_VIDEO_HOLE) void SetMediaGeometry(const gfx::RectF rect_f); #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type); +#endif // |enabled_track_ids| contains track ids of enabled audio tracks. void OnEnabledAudioTracksChanged( @@ -268,6 +271,10 @@ class PipelineImpl::RendererWrapper final : public DemuxerHost, bool is_video_hole_; #endif +#if BUILDFLAG(IS_TIZEN_TV) + std::string mime_type_; +#endif + // Whether we've received the audio/video ended events. bool renderer_ended_; @@ -677,6 +684,16 @@ void PipelineImpl::RendererWrapper::SetMediaGeometry(const gfx::RectF rect_f) { } #endif +#if BUILDFLAG(IS_TIZEN_TV) +void PipelineImpl::RendererWrapper::SetContentMimeType( + const std::string& mime_type) { + DCHECK(media_task_runner_->RunsTasksInCurrentSequence()); + mime_type_ = mime_type; + if (shared_state_.renderer) + shared_state_.renderer->SetContentMimeType(mime_type_); +} +#endif + void PipelineImpl::RendererWrapper::CreateRendererInternal( PipelineStatusCallback done_cb) { DVLOG(1) << __func__; @@ -1165,6 +1182,10 @@ void PipelineImpl::RendererWrapper::CompleteSeek(base::TimeDelta seek_time, return; } +#if BUILDFLAG(IS_TIZEN_TV) + shared_state_.renderer->SetContentMimeType(mime_type_); +#endif + shared_state_.renderer->StartPlayingFrom( std::max(seek_time, demuxer_->GetStartTime())); { @@ -1300,6 +1321,12 @@ void PipelineImpl::RendererWrapper::InitializeRenderer( LOG(INFO) << __func__ << " call SetVideoHole : " << is_video_hole_; shared_state_.renderer->SetVideoHole(is_video_hole_); #endif +#if BUILDFLAG(IS_TIZEN_TV) + // We need to set the mime type before Initialize() in the case of URL streams + // where the content is dash, because the Initialize() calls prepare in this + // case, and the player needs the mime type to configure itself correctly. + shared_state_.renderer->SetContentMimeType(mime_type_); +#endif // Initialize Renderer and report timeout UMA. std::string uma_name = "Media.InitializeRendererTimeout"; @@ -1832,6 +1859,16 @@ void PipelineImpl::OnBufferingStateChange(BufferingState state, client_->OnBufferingStateChange(state, reason); } +#if BUILDFLAG(IS_TIZEN_TV) +void PipelineImpl::SetContentMimeType(const std::string& mime_type) { + DVLOG(2) << __func__ << "(" << mime_type << ")"; + DCHECK(thread_checker_.CalledOnValidThread()); + media_task_runner_->PostTask( + FROM_HERE, + base::BindOnce(&RendererWrapper::SetContentMimeType, + base::Unretained(renderer_wrapper_.get()), mime_type)); +} +#endif void PipelineImpl::OnDurationChange(base::TimeDelta duration) { DVLOG(2) << __func__; DCHECK(thread_checker_.CalledOnValidThread()); diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index 6d1adf6..cc738ac 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -174,6 +174,9 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline { void OnFallback(PipelineStatus fallback); void OnEnded(); void OnMetadata(const PipelineMetadata& metadata); +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type) override; +#endif void OnBufferingStateChange(BufferingState state, BufferingStateChangeReason reason); void OnDurationChange(base::TimeDelta duration); diff --git a/media/base/renderer.h b/media/base/renderer.h index 20b0330..1dc4f6b 100644 --- a/media/base/renderer.h +++ b/media/base/renderer.h @@ -107,6 +107,10 @@ class MEDIA_EXPORT Renderer { virtual void SetMediaGeometry(const gfx::RectF& rect) {} #endif +#if BUILDFLAG(IS_TIZEN_TV) + virtual void SetContentMimeType(const std::string& mime_type) {} +#endif + // Starts rendering from |time|. virtual void StartPlayingFrom(base::TimeDelta time) = 0; diff --git a/media/filters/pipeline_controller.cc b/media/filters/pipeline_controller.cc index 26a9dcc..32cd7d5 100644 --- a/media/filters/pipeline_controller.cc +++ b/media/filters/pipeline_controller.cc @@ -476,4 +476,10 @@ void PipelineController::OnTrackChangeComplete() { Dispatch(); } +#if BUILDFLAG(IS_TIZEN_TV) +void PipelineController::SetContentMimeType(const std::string& mime_type) { + if (pipeline_) + pipeline_->SetContentMimeType(mime_type); +} +#endif } // namespace media diff --git a/media/filters/pipeline_controller.h b/media/filters/pipeline_controller.h index 152a2ff..071ce06 100644 --- a/media/filters/pipeline_controller.h +++ b/media/filters/pipeline_controller.h @@ -163,6 +163,9 @@ class MEDIA_EXPORT PipelineController { void SetMediaGeometry(gfx::RectF rect_f); #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type); +#endif private: // Attempts to make progress from the current state to the target state. void Dispatch(); diff --git a/media/mojo/clients/mojo_renderer.cc b/media/mojo/clients/mojo_renderer.cc index f51b9b4..3a2a101 100644 --- a/media/mojo/clients/mojo_renderer.cc +++ b/media/mojo/clients/mojo_renderer.cc @@ -343,6 +343,16 @@ void MojoRenderer::OnStatisticsUpdate(const PipelineStatistics& stats) { client_->OnStatisticsUpdate(stats); } +#if BUILDFLAG(IS_TIZEN_TV) +void MojoRenderer::SetContentMimeType(const std::string& mime_type) { + DVLOG(2) << __func__ << " mime_type : " << mime_type; + DCHECK(task_runner_->RunsTasksInCurrentSequence()); + + if (remote_renderer_.is_bound()) + remote_renderer_->SetContentMimeType(mime_type); +} +#endif + void MojoRenderer::OnWaiting(WaitingReason reason) { DVLOG(1) << __func__; DCHECK(task_runner_->RunsTasksInCurrentSequence()); diff --git a/media/mojo/clients/mojo_renderer.h b/media/mojo/clients/mojo_renderer.h index bc24925..918f3d2 100644 --- a/media/mojo/clients/mojo_renderer.h +++ b/media/mojo/clients/mojo_renderer.h @@ -76,6 +76,10 @@ class MojoRenderer : public Renderer, public mojom::RendererClient { void SetMediaGeometry(const gfx::RectF& rect) override; #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type) override; +#endif + private: // mojom::RendererClient implementation, dispatched on the |task_runner_|. void OnTimeUpdate(base::TimeDelta time, diff --git a/media/mojo/clients/mojo_renderer_wrapper.cc b/media/mojo/clients/mojo_renderer_wrapper.cc index fda7f0d..823956f 100644 --- a/media/mojo/clients/mojo_renderer_wrapper.cc +++ b/media/mojo/clients/mojo_renderer_wrapper.cc @@ -76,4 +76,11 @@ base::TimeDelta MojoRendererWrapper::GetMediaTime() { return mojo_renderer_->GetMediaTime(); } +#if BUILDFLAG(IS_TIZEN_TV) +void MojoRendererWrapper::SetContentMimeType(const std::string& mime_type) { + if (mojo_renderer_) + mojo_renderer_->SetContentMimeType(mime_type); +} +#endif + } // namespace media diff --git a/media/mojo/clients/mojo_renderer_wrapper.h b/media/mojo/clients/mojo_renderer_wrapper.h index eee5a71..d0e1db3 100644 --- a/media/mojo/clients/mojo_renderer_wrapper.h +++ b/media/mojo/clients/mojo_renderer_wrapper.h @@ -48,6 +48,10 @@ class MojoRendererWrapper : public Renderer { void SetMediaGeometry(const gfx::RectF& rect) override; #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type) override; +#endif + base::TimeDelta GetMediaTime() override; private: diff --git a/media/mojo/mojom/renderer.mojom b/media/mojo/mojom/renderer.mojom index 82a8347..4efe13d 100644 --- a/media/mojo/mojom/renderer.mojom +++ b/media/mojo/mojom/renderer.mojom @@ -67,6 +67,9 @@ interface Renderer { [EnableIf=tizen_multimedia] ToggleFullscreenMode(bool is_fullscreen) => (); + + [EnableIf=is_tizen_tv] + SetContentMimeType(string mime_type); }; // A Mojo equivalent of media::RendererClient. See media/mojo/README.md diff --git a/media/mojo/services/mojo_renderer_service.cc b/media/mojo/services/mojo_renderer_service.cc index ce09ae4..4b2b405 100644 --- a/media/mojo/services/mojo_renderer_service.cc +++ b/media/mojo/services/mojo_renderer_service.cc @@ -209,6 +209,14 @@ void MojoRendererService::OnStatisticsUpdate(const PipelineStatistics& stats) { client_->OnStatisticsUpdate(stats); } +#if BUILDFLAG(IS_TIZEN_TV) +void MojoRendererService::SetContentMimeType(const std::string& mime_type) { + DVLOG(3) << __func__ << ", mime_type: " << mime_type; + if (renderer_) + renderer_->SetContentMimeType(mime_type); +} +#endif + void MojoRendererService::OnBufferingStateChange( BufferingState state, BufferingStateChangeReason reason) { diff --git a/media/mojo/services/mojo_renderer_service.h b/media/mojo/services/mojo_renderer_service.h index 87f08d0..d15ec87 100644 --- a/media/mojo/services/mojo_renderer_service.h +++ b/media/mojo/services/mojo_renderer_service.h @@ -82,6 +82,10 @@ class MEDIA_MOJO_EXPORT MojoRendererService final : public mojom::Renderer, void SetMediaGeometry(const gfx::RectF& rect) final; #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type) final; +#endif + private: enum State { STATE_UNINITIALIZED, diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index d4ac4b8..0d759e0 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -233,6 +233,9 @@ static const MimeInfo kSecondaryMappings[] = { {"text/x-sh", "sh"}, {"text/xml", "xsl,xbl,xslt"}, {"video/mpeg", "mpeg,mpg"}, +#if BUILDFLAG(IS_TIZEN_TV) + {"application/dash+xml", "mpd"}, +#endif }; // Finds mime type of |ext| from |mappings|. diff --git a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc index 8cf918b..1c09ddf 100644 --- a/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc +++ b/third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc @@ -263,6 +263,8 @@ bool StructTraitsallow_file_access_from_external_urls = data.allow_file_access_from_external_urls(); + out->media_playback_notification_enabled = + data.media_playback_notification_enabled(); #endif return true; } diff --git a/third_party/blink/public/common/web_preferences/web_preferences.h b/third_party/blink/public/common/web_preferences/web_preferences.h index 67c5df8..cb56a6a 100644 --- a/third_party/blink/public/common/web_preferences/web_preferences.h +++ b/third_party/blink/public/common/web_preferences/web_preferences.h @@ -320,6 +320,10 @@ struct BLINK_COMMON_EXPORT WebPreferences { unsigned tizen_version_release = 0; #endif +#if BUILDFLAG(IS_TIZEN_TV) + bool media_playback_notification_enabled = false; +#endif + // Whether download UI should be hidden on this page. bool hide_download_ui; diff --git a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h index c4a0153..0ed0971 100644 --- a/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h +++ b/third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h @@ -184,6 +184,11 @@ struct BLINK_COMMON_EXPORT StructTraitsSetMediaPlaybackNotificationEnabled(enabled); +} + +bool WebSettingsImpl::MediaPlaybackNotificationEnabled() { + return settings_->MediaPlaybackNotificationEnabled(); +} +#endif + #if defined(TIZEN_VIDEO_HOLE) void WebSettingsImpl::SetVideoHoleEnabled(bool enabled) { settings_->SetVideoHoleEnabled(enabled); diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.h b/third_party/blink/renderer/core/exported/web_settings_impl.h index 7a2a4ca..f64d55d 100644 --- a/third_party/blink/renderer/core/exported/web_settings_impl.h +++ b/third_party/blink/renderer/core/exported/web_settings_impl.h @@ -243,6 +243,8 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings { #if BUILDFLAG(IS_TIZEN_TV) void SetAllowFileAccessFromExternalURLs(bool) override; bool AllowFileAccessFromExternalURLs() override; + void SetMediaPlaybackNotificationEnabled(bool) override; + bool MediaPlaybackNotificationEnabled() override; #endif #if defined(TIZEN_ATK_SUPPORT) diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc index e50ecae..9684d22 100644 --- a/third_party/blink/renderer/core/exported/web_view_impl.cc +++ b/third_party/blink/renderer/core/exported/web_view_impl.cc @@ -1786,6 +1786,8 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs, #if BUILDFLAG(IS_TIZEN_TV) settings->SetAllowFileAccessFromExternalURLs( prefs.allow_file_access_from_external_urls); + settings->SetMediaPlaybackNotificationEnabled( + prefs.media_playback_notification_enabled); #endif #if BUILDFLAG(IS_EFL) diff --git a/third_party/blink/renderer/core/frame/settings.h b/third_party/blink/renderer/core/frame/settings.h index d4891f8..f424df9 100644 --- a/third_party/blink/renderer/core/frame/settings.h +++ b/third_party/blink/renderer/core/frame/settings.h @@ -87,6 +87,15 @@ class CORE_EXPORT Settings { void SetDelegate(SettingsDelegate*); +#if BUILDFLAG(IS_TIZEN_TV) + void SetMediaPlaybackNotificationEnabled(bool enabled) { + media_playback_notification_enabled_ = enabled; + } + bool MediaPlaybackNotificationEnabled() const { + return media_playback_notification_enabled_; + } +#endif + private: void Invalidate(SettingsDelegate::ChangeType); @@ -94,6 +103,10 @@ class CORE_EXPORT Settings { GenericFontFamilySettings generic_font_family_settings_; +#if BUILDFLAG(IS_TIZEN_TV) + bool media_playback_notification_enabled_ : 1 = false; +#endif + #if BUILDFLAG(IS_EFL) struct { unsigned major; diff --git a/third_party/blink/renderer/core/html/media/html_media_element.cc b/third_party/blink/renderer/core/html/media/html_media_element.cc index 6c6014b..919f526 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element.cc @@ -1353,6 +1353,11 @@ void HTMLMediaElement::LoadResource(const WebMediaPlayerSource& source, return; } +#if BUILDFLAG(IS_TIZEN_TV) + ContentType cont_type(content_type); + content_mime_type_ = cont_type.GetType().DeprecatedLower(); +#endif + // The resource fetch algorithm SetNetworkState(kNetworkLoading); @@ -4029,6 +4034,33 @@ void HTMLMediaElement::ContextDestroyed() { removed_from_document_timer_.Stop(); } +#if BUILDFLAG(IS_TIZEN_TV) +WebString HTMLMediaElement::GetContentMIMEType() { + // If the MIME type is missing or is not meaningful, try to figure it out from + // the URL. + if (content_mime_type_.empty() || + content_mime_type_ == "application/octet-stream" || + content_mime_type_ == "text/plain") { + if (current_src_.GetSourceIfVisible().ProtocolIsData()) + content_mime_type_ = + MimeTypeFromDataURL(current_src_.GetSourceIfVisible().GetString()); + else { + String last_path_component = + current_src_.GetSourceIfVisible().LastPathComponent(); + size_t pos = last_path_component.ReverseFind('.'); + if (pos != kNotFound) { + String extension = last_path_component.Substring(pos + 1); + String media_type = + MIMETypeRegistry::GetMIMETypeForExtension(extension); + if (!media_type.empty()) + content_mime_type_ = media_type; + } + } + } + return WebString(content_mime_type_); +} +#endif + bool HTMLMediaElement::HasPendingActivity() const { const auto result = HasPendingActivityInternal(); // TODO(dalecurtis): Replace c-style casts in followup patch. diff --git a/third_party/blink/renderer/core/html/media/html_media_element.h b/third_party/blink/renderer/core/html/media/html_media_element.h index 1613b3a..17e783f 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element.h +++ b/third_party/blink/renderer/core/html/media/html_media_element.h @@ -380,6 +380,10 @@ class CORE_EXPORT HTMLMediaElement WebMediaPlayer::LoadType GetLoadType() const; +#if BUILDFLAG(IS_TIZEN_TV) + WebString GetContentMIMEType() override; +#endif + bool HasMediaSource() const { return media_source_attachment_.get(); } // Return true if element is paused and won't resume automatically if it @@ -866,6 +870,9 @@ class CORE_EXPORT HTMLMediaElement bool live_playback_complete_ : 1; #endif +#if BUILDFLAG(IS_TIZEN_TV) + String content_mime_type_; +#endif // Set if the user has used the context menu to set the visibility of the // controls. absl::optional user_wants_controls_visible_; 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 27d5c3d..47767d0 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 @@ -2997,6 +2997,11 @@ media::PipelineStatus WebMediaPlayerImpl::OnDemuxerCreated( if (start_type != media::Pipeline::StartType::kNormal) { attempting_suspended_start_ = true; } +#if BUILDFLAG(IS_TIZEN_TV) + blink::WebString content_mime_type = + blink::WebString(client_->GetContentMIMEType()); + pipeline_controller_->SetContentMimeType(content_mime_type.Utf8()); +#endif pipeline_controller_->Start(start_type, demuxer, this, is_streaming, is_static); 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 e380885..dc2c609 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 @@ -61,6 +61,9 @@ TizenRendererImpl::TizenRendererImpl( #if defined(TIZEN_VIDEO_HOLE) video_rect_(gfx::RectF()), #endif +#if BUILDFLAG(IS_TIZEN_TV) + notify_playback_state_(media::kPlaybackStop), +#endif renderer_extension_receiver_(this, std::move(renderer_extension_receiver)), web_contents_(web_contents) { @@ -472,6 +475,53 @@ void TizenRendererImpl::OnStatisticsUpdate( const media::PipelineStatistics& stats) { NOTIMPLEMENTED(); } +#if BUILDFLAG(IS_TIZEN_TV) +void TizenRendererImpl::SetContentMimeType(const std::string& mime_type) { + mime_type_ = mime_type; + if (media_player_) + media_player_->SetContentMimeType(mime_type); +} + +bool TizenRendererImpl::PlaybackNotificationEnabled() { + content::WebContents* web_contents = GetWebContents(); + if (!web_contents) { + LOG(ERROR) << "web_contents is nullptr"; + return false; + } + blink::web_pref::WebPreferences web_preference = + web_contents->GetOrCreateWebPreferences(); + bool enable = web_preference.media_playback_notification_enabled; + LOG(INFO) << "media_playback_notification_enabled:" << enable; + return enable; +} + +void TizenRendererImpl::NotifyPlaybackState(int state, + int player_id, + const std::string& url, + const std::string& mime_type, + bool* media_resource_acquired, + std::string* translated_url, + std::string* drm_info) { + if (!PlaybackNotificationEnabled()) + return; + content::WebContentsDelegate* web_contents_delegate = + GetWebContentsDelegate(); + if (!web_contents_delegate) { + LOG(ERROR) << "GetWebContentsDelegate failed"; + return; + } + + if (notify_playback_state_ < media::kPlaybackReady && + state == media::kPlaybackStop) { + LOG(ERROR) << "player not Ready but notify Stop"; + } + + notify_playback_state_ = state; + web_contents_delegate->NotifyPlaybackState(state, player_id, url, mime_type, + media_resource_acquired, + translated_url, drm_info); +} +#endif void TizenRendererImpl::OnSeekableTimeChange(base::TimeDelta min_time, base::TimeDelta max_time, 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 bac0971..d9e66cd 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 @@ -114,6 +114,18 @@ class CONTENT_EXPORT TizenRendererImpl void OnVideoSizeChange(const gfx::Size& size) override; void OnDurationChange(base::TimeDelta duration) override; void OnBufferUpdate(base::TimeDelta time) override; + +#if BUILDFLAG(IS_TIZEN_TV) + bool PlaybackNotificationEnabled(); + void NotifyPlaybackState(int state, + int player_id = 0, + const std::string& url = "", + const std::string& mime_type = "", + bool* media_resource_acquired = NULL, + std::string* translated_url = NULL, + std::string* drm_info = NULL) override; +#endif + #if defined(TIZEN_TBM_SUPPORT) void OnNewTbmFrameAvailable(uint32_t player_id, gfx::TbmBufferHandle tbm_handle, @@ -138,6 +150,10 @@ class CONTENT_EXPORT TizenRendererImpl gfx::Rect GetViewportRect() const; #endif +#if BUILDFLAG(IS_TIZEN_TV) + void SetContentMimeType(const std::string& mime_type) override; +#endif + private: const float kDefaultVolume = 1.0; @@ -214,6 +230,14 @@ class CONTENT_EXPORT TizenRendererImpl gfx::RectF video_rect_; #endif +#if BUILDFLAG(IS_TIZEN_TV) + int notify_playback_state_; + // Stores the mime type. Required for URL streams which are DASH + // content, so that we can set it to the media_player_ before calling + // initialize / prepare. + std::string mime_type_; +#endif + WebContents* web_contents_ = nullptr; base::WeakPtrFactory weak_factory_{this}; diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi.h b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi.h index a3c7f27..4085727 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi.h +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi.h @@ -125,7 +125,9 @@ class MEDIA_EXPORT MediaPlayerBridgeCapi : public MediaPlayerTizen { uint32_t length, base::TimeDelta timestamp); #endif - MediaPlayerTizenClient* GetMediaPlayerClient() const { return client_; } + MediaPlayerTizenClient* GetMediaPlayerClient() const override { + return client_; + } player_state_e GetPlayerState(); // Both used by Tizen TV and other platform @@ -137,7 +139,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapi : public MediaPlayerTizen { virtual void UpdateDuration(); GURL url_; - int player_id_ = 0;; + int player_id_ = 0; int delayed_player_state_; player_h player_ = nullptr; diff --git a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc index da8a9a5..a741dfa 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc @@ -32,24 +32,61 @@ void MediaPlayerBridgeCapiTV::SetContentMimeType(const std::string& mime_type) { } void MediaPlayerBridgeCapiTV::Prepare() { + bool media_resource_acquired = false; + std::string translated_url; + std::string drm_info; + + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState( + kPlaybackLoad, player_id_, url_.spec(), mime_type_, + &media_resource_acquired, &translated_url, &drm_info); + + LOG(INFO) << "media_resource_acquired: " << media_resource_acquired + << ",translated_url:" << translated_url + << ",drm_info: " << drm_info; + + if (GetMediaPlayerClient() && + GetMediaPlayerClient()->PlaybackNotificationEnabled() && + blink::IsHbbTV() && !translated_url.empty()) + url_ = media::GetCleanURL(translated_url); + + if (url_.spec().find(".mpd") != std::string::npos) + stream_type_ = DASH_STREAM; + else if (url_.spec().find(".m3u") != std::string::npos) + stream_type_ = HLS_STREAM; + else if (mime_type_.find("application/dash+xml") != std::string::npos) { + char steaming_type_dash[] = "DASH"; + char steaming_type_dash_ex[] = "DASHEX"; + player_set_streaming_type( + player_, blink::IsHbbTV() ? steaming_type_dash_ex : steaming_type_dash); + stream_type_ = DASH_STREAM; + } if (blink::IsHbbTV() && CheckHighBitRate() && stream_type_ == DASH_STREAM) AppendUrlHighBitRate(url_.spec()); MediaPlayerBridgeCapi::Prepare(); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackReady, player_id_); } void MediaPlayerBridgeCapiTV::Release() { StopSeekableTimeUpdateTimer(); MediaPlayerBridgeCapi::Release(); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStop, player_id_); } bool MediaPlayerBridgeCapiTV::Play() { if (!MediaPlayerBridgeCapi::Play()) return false; + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStart, player_id_); return true; } void MediaPlayerBridgeCapiTV::PlaybackCompleteUpdate() { MediaPlayerBridgeCapi::PlaybackCompleteUpdate(); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackFinish, player_id_); } // namespace media void MediaPlayerBridgeCapiTV::PlayerPrepared() { diff --git a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.h b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.h index 2aecbd4..3727dd6 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.h +++ b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.h @@ -115,7 +115,9 @@ class MEDIA_EXPORT MediaPlayerESPlusPlayer : public MediaPlayerTizen { const media::AudioDecoderConfig& audio_config, esplusplayer_audio_stream_info* audio_stream_info); virtual bool ReadFromBufferQueue(DemuxerStream::Type type); - MediaPlayerTizenClient* GetMediaPlayerClient() const { return client_; } + MediaPlayerTizenClient* GetMediaPlayerClient() const override { + return client_; + } virtual esplusplayer_submit_status SubmitEsPacket( DemuxerStream::Type type, scoped_refptr buffer); diff --git a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer_tv.cc b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer_tv.cc index 00c53d1..839fcd8 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer_tv.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer_tv.cc @@ -21,6 +21,8 @@ MediaPlayerESPlusPlayerTV::~MediaPlayerESPlusPlayerTV() { void MediaPlayerESPlusPlayerTV::Initialize(VideoRendererSink* sink) { LOG(INFO) << "(" << static_cast(this) << ") " << __func__; MediaPlayerESPlusPlayer::Initialize(sink); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackLoad, player_id_); } void MediaPlayerESPlusPlayerTV::InitializeStreamConfig( @@ -32,17 +34,24 @@ void MediaPlayerESPlusPlayerTV::InitializeStreamConfig( bool MediaPlayerESPlusPlayerTV::Play() { LOG(INFO) << "(" << static_cast(this) << ") " << __func__; + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStart, player_id_, "", + "", NULL, NULL, NULL); return MediaPlayerESPlusPlayer::Play(); } void MediaPlayerESPlusPlayerTV::Prepare() { LOG(INFO) << "(" << static_cast(this) << ") " << __func__; MediaPlayerESPlusPlayer::Prepare(); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStop, player_id_); } void MediaPlayerESPlusPlayerTV::Release() { LOG(INFO) << "(" << static_cast(this) << ") " << __func__; MediaPlayerESPlusPlayer::Release(); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStop, player_id_); } void MediaPlayerESPlusPlayerTV::PostPrepareComplete() { @@ -125,6 +134,8 @@ void MediaPlayerESPlusPlayerTV::OnPrepareComplete(bool result) { void MediaPlayerESPlusPlayerTV::OnEos() { MediaPlayerESPlusPlayer::OnEos(); + if (GetMediaPlayerClient()) + GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackFinish, player_id_); } } // namespace media diff --git a/tizen_src/chromium_impl/media/filters/media_player_tizen.h b/tizen_src/chromium_impl/media/filters/media_player_tizen.h index c097ec1..0835ecf 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_tizen.h +++ b/tizen_src/chromium_impl/media/filters/media_player_tizen.h @@ -36,6 +36,16 @@ enum class PlayerRole { LocalCaptureStream = RemotePeerStream << 1 }; +enum PlaybackState { + kPlaybackLoad = 0, + // kPlaybackReady: player with both audio and video starts prepare and will + // acquire audio and video resources (if they are not already taken) + kPlaybackReady, + kPlaybackStart, + kPlaybackFinish, + kPlaybackStop, +}; + using PlayerRoleFlags = media::Flags; DEFINE_OPERATORS_FOR_FLAGS(MediaTypeFlags) @@ -72,7 +82,9 @@ class MEDIA_EXPORT MediaPlayerTizen { virtual void SetVolume(double volume) = 0; virtual base::TimeDelta GetCurrentTime() = 0; - virtual MediaPlayerTizenClient* GetMediaPlayerClient() const {return nullptr;} + virtual MediaPlayerTizenClient* GetMediaPlayerClient() const { + return nullptr; + } virtual void ToggleFullscreenMode(bool is_fullscreen) {} #if defined(TIZEN_TBM_SUPPORT) diff --git a/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h b/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h index 71cb20d..95078d0 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h +++ b/tizen_src/chromium_impl/media/filters/media_player_tizen_client.h @@ -55,6 +55,14 @@ class MEDIA_EXPORT MediaPlayerTizenClient { #endif #if BUILDFLAG(IS_TIZEN_TV) + virtual bool PlaybackNotificationEnabled() = 0; + virtual void NotifyPlaybackState(int state, + int player_id = 0, + const std::string& url = "", + const std::string& mime_type = "", + bool* media_resource_acquired = NULL, + std::string* translated_url = NULL, + std::string* drm_info = NULL) = 0; virtual content::WebContentsDelegate* GetWebContentsDelegate() const = 0; #endif }; diff --git a/tizen_src/ewk/efl_integration/BUILD.gn b/tizen_src/ewk/efl_integration/BUILD.gn index aebebfd..dcd44ee 100644 --- a/tizen_src/ewk/efl_integration/BUILD.gn +++ b/tizen_src/ewk/efl_integration/BUILD.gn @@ -543,6 +543,7 @@ shared_library("chromium-ewk") { "public/ewk_media_parental_rating_info.h", "public/ewk_media_parental_rating_info_product.h", "public/ewk_media_playback_info.cc", + "public/ewk_media_playback_info.h", "public/ewk_media_playback_info_product.h", "public/ewk_media_subtitle_info.cc", "public/ewk_media_subtitle_info_product.h", diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 9e830c0..d7594ff 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -103,6 +103,7 @@ #include "devtools_port_manager.h" #include "private/ewk_file_chooser_request_private.h" #include "public/ewk_media_downloadable_font_info.h" +#include "public/ewk_media_playback_info_product.h" #include "public/ewk_user_media_internal.h" #endif @@ -3436,6 +3437,64 @@ void EWebView::NotifyDownloadableFontInfo(const char* scheme_id_uri, ewkMediaDownloadableFontInfoDelete(info); } +std::vector EWebView::NotifyPlaybackState(int state, + int player_id, + const char* url, + const char* mime_type) { + std::vector data; + Ewk_Media_Playback_Info* playback_info = + ewkMediaPlaybackInfoCreate(player_id, url, mime_type); + + LOG(INFO) + << "player_id:" << player_id << ",state: " << state + << "(0-load : 1-videoready : 2-ready : 3-start : 4-finish : 5-stop)"; + switch (state) { + case kPlaybackLoad: + SmartCallback().call( + static_cast(playback_info)); + break; + case kPlaybackReady: + SmartCallback().call( + static_cast(playback_info)); + break; + case kPlaybackStart: + SmartCallback().call( + static_cast(playback_info)); + break; + case kPlaybackFinish: + SmartCallback().call( + static_cast(playback_info)); + break; + case kPlaybackStop: + SmartCallback().call( + static_cast(playback_info)); + break; + default: + NOTREACHED(); + data.push_back(""); + ewkMediaPlaybackInfoDelete(playback_info); + return data; + } + + bool media_resource_acquired = + ewk_media_playback_info_media_resource_acquired_get(playback_info) + ? true + : false; + data.push_back(media_resource_acquired ? "mediaResourceAcquired" : ""); + const char* translated_url = + ewk_media_playback_info_translated_url_get(playback_info); + data.push_back(translated_url ? std::string(translated_url) : ""); + const char* drm_info = ewk_media_playback_info_drm_info_get(playback_info); + data.push_back(drm_info ? std::string(drm_info) : ""); + + LOG(INFO) << "evasObject: " << ewk_view_ + << ", media_resource_acquired :" << media_resource_acquired + << ", translated_url:" << translated_url + << ", drm_info:" << drm_info; + ewkMediaPlaybackInfoDelete(playback_info); + return data; +} + void EWebView::NotifyMediaStateChanged(uint32_t device_type, uint32_t previous, uint32_t current) { diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 6cb3204..5cb5058 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -380,6 +380,10 @@ class EWebView { const char* value, const char* data, int type); + std::vector NotifyPlaybackState(int state, + int player_id, + const char* url, + const char* mime_type); #endif // IS_TIZEN_TV void SetSessionTimeout(uint64_t timeout); double GetTextZoomFactor() const; @@ -983,6 +987,16 @@ class EWebView { bool is_high_bitrate_ = false; base::OnceClosure pending_setfocus_closure_; + + enum PlaybackState { + kPlaybackLoad = 0, + // kPlaybackReady: player with both audio and video starts prepare and will + // acquire audio and video resources (if they are not already taken) + kPlaybackReady, + kPlaybackStart, + kPlaybackFinish, + kPlaybackStop, + }; #endif std::unique_ptr<_Ewk_Back_Forward_List> back_forward_list_; diff --git a/tizen_src/ewk/efl_integration/public/ewk_media_playback_info.cc b/tizen_src/ewk/efl_integration/public/ewk_media_playback_info.cc index 4f36ddbb..4d40594 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_media_playback_info.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_media_playback_info.cc @@ -40,42 +40,45 @@ struct _Ewk_Media_Playback_Info { const char* ewk_media_playback_info_media_url_get( Ewk_Media_Playback_Info* data) { - LOG_EWK_API_MOCKUP(); - return NULL; + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + return data->media_url; } const char* ewk_media_playback_info_mime_type_get( Ewk_Media_Playback_Info* data) { - LOG_EWK_API_MOCKUP(); - return NULL; + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + return data->mime_type; } const char* ewk_media_playback_info_translated_url_get( Ewk_Media_Playback_Info* data) { - LOG_EWK_API_MOCKUP(); - return NULL; + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + return data->translated_url; } const char* ewk_media_playback_info_drm_info_get( Ewk_Media_Playback_Info* data) { - LOG_EWK_API_MOCKUP(); - return NULL; + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + return data->drm_info; } void ewk_media_playback_info_media_resource_acquired_set( Ewk_Media_Playback_Info* data, Eina_Bool media_resource_acquired) { - LOG_EWK_API_MOCKUP(); + if(data) + data->media_resource_acquired = media_resource_acquired; } void ewk_media_playback_info_translated_url_set(Ewk_Media_Playback_Info* data, const char* translated_url) { - LOG_EWK_API_MOCKUP(); + if(data) + data->translated_url = eina_stringshare_add(translated_url ? translated_url : ""); } void ewk_media_playback_info_drm_info_set(Ewk_Media_Playback_Info* data, const char* drm_info) { - LOG_EWK_API_MOCKUP(); + if(data) + data->drm_info = eina_stringshare_add(drm_info ? drm_info : ""); } Ewk_Hardware_Decoders ewk_media_playback_info_decoder_get( @@ -93,8 +96,8 @@ void ewk_media_playback_info_decoder_set( const int ewk_media_playback_info_video_id_get(Ewk_Media_Playback_Info* data) { - LOG_EWK_API_MOCKUP(); - return 0; + EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0); + return data->video_id; } Ewk_Media_Playback_Info* ewkMediaPlaybackInfoCreate(const int player_id, @@ -102,21 +105,26 @@ Ewk_Media_Playback_Info* ewkMediaPlaybackInfoCreate(const int player_id, const char* mime_type) { #if BUILDFLAG(IS_TIZEN_TV) - LOG_EWK_API_MOCKUP(); - return NULL; + Ewk_Media_Playback_Info* playback_info = new Ewk_Media_Playback_Info; + playback_info->video_id = player_id; + playback_info->media_url = eina_stringshare_add(url ? url : ""); + playback_info->mime_type = eina_stringshare_add(mime_type ? mime_type : ""); + playback_info->media_resource_acquired = false; + playback_info->translated_url = 0; + playback_info->drm_info = 0; + return playback_info; #else LOG_EWK_API_MOCKUP("Only for Tizen TV."); return NULL; #endif - } Eina_Bool ewk_media_playback_info_media_resource_acquired_get( Ewk_Media_Playback_Info* data) { #if BUILDFLAG(IS_TIZEN_TV) - LOG_EWK_API_MOCKUP(); - return EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(data, false); + return data->media_resource_acquired; #else LOG_EWK_API_MOCKUP("Only for Tizen TV."); return EINA_FALSE; @@ -126,7 +134,18 @@ Eina_Bool ewk_media_playback_info_media_resource_acquired_get( void ewkMediaPlaybackInfoDelete(Ewk_Media_Playback_Info* data) { #if BUILDFLAG(IS_TIZEN_TV) - LOG_EWK_API_MOCKUP(); + if(!data) + return; + + if (data->media_url) + eina_stringshare_del(data->media_url); + if (data->mime_type) + eina_stringshare_del(data->mime_type); + if (data->translated_url) + eina_stringshare_del(data->translated_url); + if (data->drm_info) + eina_stringshare_del(data->drm_info); + delete data; #else LOG_EWK_API_MOCKUP("Only for Tizen TV."); #endif diff --git a/tizen_src/ewk/efl_integration/public/ewk_settings.cc b/tizen_src/ewk/efl_integration/public/ewk_settings.cc index 9f6b71b..5870cb3 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_settings.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_settings.cc @@ -729,13 +729,25 @@ void ewk_settings_default_audio_input_device_set(Ewk_Settings* settings, const c void ewk_settings_media_playback_notification_set(Ewk_Settings* settings, Eina_Bool enabled) { +#if BUILDFLAG(IS_TIZEN_TV) + EINA_SAFETY_ON_NULL_RETURN(settings); + LOG(INFO) << " set playback notification enabled:" << enabled; + settings->getPreferences().media_playback_notification_enabled = enabled; + ewkUpdateWebkitPreferences(settings->ewk_view()); +#else LOG_EWK_API_MOCKUP(); +#endif } Eina_Bool ewk_settings_media_playback_notification_get(const Ewk_Settings* settings) { +#if BUILDFLAG(IS_TIZEN_TV) + EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false); + return settings->getPreferences().media_playback_notification_enabled; +#else LOG_EWK_API_MOCKUP(); return EINA_FALSE; +#endif } void ewk_settings_media_subtitle_notification_set(Ewk_Settings *settings, Eina_Bool enabled) diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index f8a52dc..030db1b 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -797,5 +797,27 @@ void WebContentsDelegateEfl::NotifyDownloadableFontInfo( web_view_->NotifyDownloadableFontInfo(scheme_id_uri.c_str(), value.c_str(), data.c_str(), type); } + +void WebContentsDelegateEfl::NotifyPlaybackState(int state, + int player_id, + const std::string& url, + const std::string& mime_type, + bool* media_resource_acquired, + std::string* translated_url, + std::string* drm_info) { + if (!web_view_) + return; + std::vector data = web_view_->NotifyPlaybackState( + state, player_id, url.empty() ? "" : url.c_str(), + mime_type.empty() ? "" : mime_type.c_str()); + if (data.size()) { + if (media_resource_acquired) + *media_resource_acquired = !data.at(0).empty() ? true : false; + if (translated_url) + *translated_url = data.at(1); + if (drm_info) + *drm_info = data.at(2); + } +} #endif } // namespace content diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h index 42fb4c7..a056dce 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.h @@ -81,6 +81,13 @@ class WebContentsDelegateEfl : public WebContentsDelegate { const std::string& value, const std::string& data, int type) override; + void NotifyPlaybackState(int state, + int player_id, + const std::string& url, + const std::string& mime_type, + bool* media_resource_acquired, + std::string* translated_url, + std::string* drm_info) override; #endif void RequestCertificateConfirm( WebContents* web_contents, -- 2.7.4 From aeb02572b5015f13a6963d6c337d4c5f0380d44b Mon Sep 17 00:00:00 2001 From: chiragmaheshwari Date: Mon, 19 Feb 2024 14:25:15 +0530 Subject: [PATCH 16/16] [M120 Migration][VD][V8] Increase page size bits and min semi space size for performance. This change updates kPageSizeBits and kMinSemiSpaceSizeInKB values for product tv profile for performance. VD-CanvasMark-Pixelblur scores. BaseCode: 28.7 kPageSizeBits = 20, kMinSemiSpaceSizeInKB = 1024K: 33.3 References: 1. https://review.tizen.org/gerrit/290956 2. https://chromium-review.googlesource.com/c/v8/v8/+/1496367 3. https://chromium-review.googlesource.com/c/v8/v8/+/1529006 [2], [3] reduces heap/page size parameters in upstream. Though performance is improved with page size as 512K, it is increased to 1024K to keep performance in par with earlier versions. Change-Id: Id9cccbd678f4aa08eff4862bec12916a7ecdc86f Signed-off-by: chiragmaheshwari --- v8/src/base/build_config.h | 6 +++++- v8/src/heap/heap.cc | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/v8/src/base/build_config.h b/v8/src/base/build_config.h index 6733302..0ee2072 100644 --- a/v8/src/base/build_config.h +++ b/v8/src/base/build_config.h @@ -50,7 +50,11 @@ constexpr int kReturnAddressStackSlotCount = V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK ? 1 : 0; // Number of bits to represent the page size for paged spaces. -#if (defined(V8_HOST_ARCH_PPC) || defined(V8_HOST_ARCH_PPC64)) && !defined(_AIX) + +#if defined(OS_TIZEN_TV_PRODUCT) +const int kPageSizeBits = 20; +#elif (defined(V8_HOST_ARCH_PPC) || defined(V8_HOST_ARCH_PPC64)) && \ + !defined(_AIX) // Native PPC linux has large (64KB) physical pages. // Simulator (and Aix) need to use the same value as x64. constexpr int kPageSizeBits = 19; diff --git a/v8/src/heap/heap.cc b/v8/src/heap/heap.cc index a871dc5..ce11b27 100644 --- a/v8/src/heap/heap.cc +++ b/v8/src/heap/heap.cc @@ -4852,8 +4852,12 @@ size_t Heap::DefaultMinSemiSpaceSize() { static constexpr size_t kMinSemiSpaceSize = kHugePageSize * kPointerMultiplier; #else +#if defined(OS_TIZEN_TV_PRODUCT) + static constexpr size_t kMinSemiSpaceSize = 1024 * KB * kPointerMultiplier; +#else static constexpr size_t kMinSemiSpaceSize = 512 * KB * kPointerMultiplier; #endif +#endif static_assert(kMinSemiSpaceSize % (1 << kPageSizeBits) == 0); return kMinSemiSpaceSize; -- 2.7.4