[M120 Migration][MM] Support webmedia playback state notification 20/307120/4
authorzhishun.zhou <zhishun.zhou@samsung.com>
Tue, 5 Mar 2024 06:08:38 +0000 (14:08 +0800)
committerzhishun.zhou <zhishun.zhou@samsung.com>
Tue, 5 Mar 2024 09:27:56 +0000 (17:27 +0800)
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 <fang.xiao@samsung.com>
Signed-off-by: zhishun.zhou <zhishun.zhou@samsung.com>
46 files changed:
content/browser/web_contents/web_contents_impl.cc
content/public/browser/web_contents_delegate.h
content/public/common/content_switches.cc
content/public/common/content_switches.h
media/base/pipeline.h
media/base/pipeline_impl.cc
media/base/pipeline_impl.h
media/base/renderer.h
media/filters/pipeline_controller.cc
media/filters/pipeline_controller.h
media/mojo/clients/mojo_renderer.cc
media/mojo/clients/mojo_renderer.h
media/mojo/clients/mojo_renderer_wrapper.cc
media/mojo/clients/mojo_renderer_wrapper.h
media/mojo/mojom/renderer.mojom
media/mojo/services/mojo_renderer_service.cc
media/mojo/services/mojo_renderer_service.h
net/base/mime_util.cc
third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
third_party/blink/public/common/web_preferences/web_preferences.h
third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
third_party/blink/public/mojom/webpreferences/web_preferences.mojom
third_party/blink/public/platform/web_media_player_client.h
third_party/blink/public/web/web_settings.h
third_party/blink/renderer/core/exported/web_settings_impl.cc
third_party/blink/renderer/core/exported/web_settings_impl.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/frame/settings.h
third_party/blink/renderer/core/html/media/html_media_element.cc
third_party/blink/renderer/core/html/media/html_media_element.h
third_party/blink/renderer/platform/media/web_media_player_impl.cc
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h
tizen_src/chromium_impl/media/filters/media_player_bridge_capi.h
tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc
tizen_src/chromium_impl/media/filters/media_player_esplusplayer.h
tizen_src/chromium_impl/media/filters/media_player_esplusplayer_tv.cc
tizen_src/chromium_impl/media/filters/media_player_tizen.h
tizen_src/chromium_impl/media/filters/media_player_tizen_client.h
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/public/ewk_media_playback_info.cc
tizen_src/ewk/efl_integration/public/ewk_settings.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h

index c2d22482763991e6696253585976ebb78eb3d192..46ae83a13b3b20ea11cb46a301614c7e0ace779c 100644 (file)
@@ -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;
index 8776ed2b46841a136baf47c6914f4643b0688bbc..2bf3192ea36ca6c9deebaeb9c431d9ffb50c0e6e 100644 (file)
@@ -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,
index 7b03c23586ef4e2444fc967a0eed231680db283c..7f95a83d153c6a8e866ce0977012273bca0b4aad 100644 (file)
@@ -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
index 886b0f97d64410d5dcafce2c4758ada722327714..a851eedbd1eeb8e0df0a7cd2afdcc9a7352b63f6 100644 (file)
@@ -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
index 8e1f2216a9cbbfc17f699ed1392f29a9267a3852..a2e455465bbafe09796cd70e2b13fcc6fe3dfe0a 100644 (file)
@@ -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
index 2b991e6492a0f01e5337d81fbd11b22662891c0e..bf67b12a86899d87c379d6b555bf51a384c1ba0f 100644 (file)
@@ -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());
index 6d1adf6d8a197a9fe12f1ad06bd7ee9c66d88142..cc738ac68730c3e3d06dc38c0f4cfb3202b0a01e 100644 (file)
@@ -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);
index 20b0330ea0f562fd46e96e0a50de0755f675fab0..1dc4f6b02a8ca9026900f12684f9d7185db9b689 100644 (file)
@@ -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;
 
index 26a9dccb77b25462a186cc429bee1e4f9f98b507..32cd7d5af7c82520679548e66ed30909e94d4f45 100644 (file)
@@ -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
index 152a2ff2fa09a09d8d463b9a6380b6916cf4e4e0..071ce065a585d04fe00ef12e56932da1716bc6c8 100644 (file)
@@ -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();
index f51b9b476cf598b1e8c33dcd3530b2f59c45f78d..3a2a101eaa8b19cd2f330c60acc16de90c6bb597 100644 (file)
@@ -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());
index bc24925e336a8615223f93c3971aacde42ca50ab..918f3d2644b614068d00555ed4101b3d54b01c1d 100644 (file)
@@ -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,
index fda7f0d7175c01bc00cd51a06d5a8dd5110671c5..823956fb353b88a66067c69686ad8d6cb9b929dd 100644 (file)
@@ -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
index eee5a71401096304eaee6875faef3657dee14127..d0e1db3d708b5441f0c5f132028587410f597a5e 100644 (file)
@@ -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:
index 82a834751dcc7624bf72acdcc9f797e9063460e2..4efe13d754a2081f7e9916251db2559ca6b7fb2a 100644 (file)
@@ -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
index ce09ae417eecf263640c95d8ceae9c1a65d74729..4b2b405b0847d144e94309b7754e89dd455232e4 100644 (file)
@@ -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) {
index 87f08d0768faaf9d564c14c0cca869320ddc0ff5..d15ec8716c10162144b7287c9f03556a2be0aa54 100644 (file)
@@ -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,
index d4ac4b84f8f033be4fb09ab5df3fc55a0728d0bf..0d759e0cea48ef761dab1c90a2d4367ba3613e65 100644 (file)
@@ -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|.
index 8cf918bea5026ea8db9b88e8d008640f2e2f7087..1c09ddfe60b339d734e820437d65aa0528c07ba8 100644 (file)
@@ -263,6 +263,8 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
 #if BUILDFLAG(IS_TIZEN_TV)
   out->allow_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;
 }
index 67c5df83d570ad6e2c2acb6e0d3deae9c61bfd30..cb56a6a60988350946199d47cbd6a9bf89977c52 100644 (file)
@@ -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;
 
index c4a015367ac1b567b82b6c92d0da9442398870c6..0ed0971c958c36ddf9a991bf8bfa7f83f32dd99e 100644 (file)
@@ -184,6 +184,11 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
       const blink::web_pref::WebPreferences& r) {
     return r.additional_shared_array_buffer_schemes;
   }
+
+  static bool media_playback_notification_enabled(
+      const blink::web_pref::WebPreferences& r) {
+    return r.media_playback_notification_enabled;
+  }
 #endif
 
   static bool webgl1_enabled(const blink::web_pref::WebPreferences& r) {
index 76e30061319cb92c703b65a849d6e3c9d207d61b..617e848433d9a5a9989867c4abec79ccd0d9cb9a 100644 (file)
@@ -529,6 +529,9 @@ struct WebPreferences {
   // blocking user's access to the background web content.
   bool modal_context_menu = true;
 
+  [EnableIf=is_tizen_tv]
+  bool media_playback_notification_enabled;
+
   [EnableIf=is_tizen_tv]
   bool allow_file_access_from_external_urls;
 
index a9ec4d6397b213816e0776d27b55ed4c0a8efd79..3a24a573ade0a8c1256af9c6dda227b60962dbbe 100644 (file)
@@ -227,6 +227,10 @@ class BLINK_PLATFORM_EXPORT WebMediaPlayerClient {
   virtual void SuspendPlayer() {}
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual WebString GetContentMIMEType() = 0;
+#endif
+
  protected:
   ~WebMediaPlayerClient() = default;
 };
index 7d12ff72c495e1e384cec87e28541af72301e96c..ab84944aee7dac988c85608fd90b23b4e4854bc6 100644 (file)
@@ -306,6 +306,11 @@ class WebSettings {
   virtual void SetVideoHoleEnabled(bool) = 0;
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  virtual void SetMediaPlaybackNotificationEnabled(bool) = 0;
+  virtual bool MediaPlaybackNotificationEnabled() = 0;
+#endif
+
  protected:
   ~WebSettings() = default;
 };
index 34e9c9d00b53d30086137622ae16a818440a83ad..e9d6b3c223b3a573592379ee51d35cbc735a95b5 100644 (file)
@@ -850,6 +850,16 @@ bool WebSettingsImpl::GetAccessibilityEnabled() {
 }
 #endif
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void WebSettingsImpl::SetMediaPlaybackNotificationEnabled(bool enabled) {
+  settings_->SetMediaPlaybackNotificationEnabled(enabled);
+}
+
+bool WebSettingsImpl::MediaPlaybackNotificationEnabled() {
+  return settings_->MediaPlaybackNotificationEnabled();
+}
+#endif
+
 #if defined(TIZEN_VIDEO_HOLE)
 void WebSettingsImpl::SetVideoHoleEnabled(bool enabled) {
   settings_->SetVideoHoleEnabled(enabled);
index 7a2a4ca38698bd3fca75e04bb6317385b09cf1bf..f64d55d3f464f2c3fa34e118b640f7685c7c4bde 100644 (file)
@@ -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)
index e50ecae9b44674e3d9a833077306c6502e2cc334..9684d22e129abf5373c285a6457df5a2ac4fbe5c 100644 (file)
@@ -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)
index d4891f836710f7b11f9e3c69d1736a87050f51ef..f424df97f50584deceb3077c8f370f5684ef0f3d 100644 (file)
@@ -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;
index 6c6014bcce6f62b6dab9ac4c536faf5713f0596a..919f5265bcffa758211c7b962c44cca61f7522d3 100644 (file)
@@ -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.
index 1613b3a7a8284168180d492a956d64bbd9fb3ebc..17e783fd47e68c560ac747d1f6ca8b0dae29ec0c 100644 (file)
@@ -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<bool> user_wants_controls_visible_;
index 27d5c3d13eef13b016783f23c1760d2a4951401c..47767d05b686b1ee2f101245fb03d1edb91e2feb 100644 (file)
@@ -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);
index e380885c1054ef234b49f428222d5e63a51aa048..dc2c609d2a5a0a6475a25231949610910550f1d5 100644 (file)
@@ -60,6 +60,9 @@ TizenRendererImpl::TizenRendererImpl(
       volume_(kDefaultVolume),
 #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)),
@@ -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,
index bac09713b64a50ef7a90e6b11d6739a0d21af10a..d9e66cd1328b9699abd2ac54f7714f4a037b0722 100644 (file)
@@ -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<TizenRendererImpl> weak_factory_{this};
index a3c7f2779c9cb73dcdddb55b29f511f8d4940c0b..4085727116b88f8b8def7bdaba70c9e80f778fab 100644 (file)
@@ -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;
 
index da8a9a5f1d74432ca49991854ba4163d5840cf01..a741dfa28f76e519f5e907750440fbd4e8c2d714 100644 (file)
@@ -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() {
index 2aecbd43ec5cb8e138b3959fcf054116a25d2dcd..3727dd664ad84fd5d72d76ae63f73a003ede9d8f 100644 (file)
@@ -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<DecoderBuffer> buffer);
index 00c53d1efb141115354abb7ad04a4b23702cea11..839fcd8cfbf279fe0c65c76821eb262695e6dc71 100644 (file)
@@ -21,6 +21,8 @@ MediaPlayerESPlusPlayerTV::~MediaPlayerESPlusPlayerTV() {
 void MediaPlayerESPlusPlayerTV::Initialize(VideoRendererSink* sink) {
   LOG(INFO) << "(" << static_cast<void*>(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<void*>(this) << ") " << __func__;
+  if (GetMediaPlayerClient())
+    GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStart, player_id_, "",
+                                                "", NULL, NULL, NULL);
   return MediaPlayerESPlusPlayer::Play();
 }
 
 void MediaPlayerESPlusPlayerTV::Prepare() {
   LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
   MediaPlayerESPlusPlayer::Prepare();
+  if (GetMediaPlayerClient())
+    GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStop, player_id_);
 }
 
 void MediaPlayerESPlusPlayerTV::Release() {
   LOG(INFO) << "(" << static_cast<void*>(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
index c097ec1846190d502653bf58295604d29cc07631..0835ecfa0479d722ef56164242671db3c2bdde0f 100644 (file)
@@ -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<PlayerRole>;
 
 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)
index 71cb20d71b82192da09aca116f71f94465e66cbf..95078d009457862a792bdc13bf2e4e7ce819dbb9 100644 (file)
@@ -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
 };
index aebebfda35acae48d8b00cf3227903e7abd62d41..dcd44ee52f43061132282e7d278dbe0677894421 100644 (file)
@@ -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",
index 9e830c0c73bbf5bcecd016d64f8e168d3f244c00..d7594ff08b2681d5595ded5b6510c2b248405385 100644 (file)
 #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<std::string> EWebView::NotifyPlaybackState(int state,
+                                                       int player_id,
+                                                       const char* url,
+                                                       const char* mime_type) {
+  std::vector<std::string> 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<EWebViewCallbacks::PlaybackLoad>().call(
+          static_cast<void*>(playback_info));
+      break;
+    case kPlaybackReady:
+      SmartCallback<EWebViewCallbacks::PlaybackReady>().call(
+          static_cast<void*>(playback_info));
+      break;
+    case kPlaybackStart:
+      SmartCallback<EWebViewCallbacks::PlaybackStart>().call(
+          static_cast<void*>(playback_info));
+      break;
+    case kPlaybackFinish:
+      SmartCallback<EWebViewCallbacks::PlaybackFinish>().call(
+          static_cast<void*>(playback_info));
+      break;
+    case kPlaybackStop:
+      SmartCallback<EWebViewCallbacks::PlaybackStop>().call(
+          static_cast<void*>(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) {
index 6cb3204d8f9c10f0a047b141345462aa3dbe1754..5cb50584888a391e402acebe32d86f8a617e7219 100644 (file)
@@ -380,6 +380,10 @@ class EWebView {
                                   const char* value,
                                   const char* data,
                                   int type);
+  std::vector<std::string> 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_;
index 4f36ddbbacd19a97a20a335f490853c321c9111d..4d40594348653a92b146f65094a8758088022f4d 100644 (file)
@@ -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
index 9f6b71b47f21d70edba76a2e6fe06e3625f033e0..5870cb32d3b22f311f01f43707522b0fa4822194 100644 (file)
@@ -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)
index f8a52dcedff3e4c20cec8b3f512487738dc50354..030db1bd1c61e0768d72c898a28c2862183321f6 100644 (file)
@@ -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<std::string> 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
index 42fb4c7e5b86914ebe4d63de847ae8bf2b03e03c..a056dce0755fd4a1aa6f6a87824f6a360831d96c 100644 (file)
@@ -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,