[M120 Migration][MM] Fix EME AD insert issue 67/308467/4
authorwuxiaoliang <xliang.wu@samsung.com>
Tue, 26 Mar 2024 06:08:00 +0000 (14:08 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 11 Apr 2024 05:18:16 +0000 (05:18 +0000)
Migrated from:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/299862/

Issue:
EME Stream insert AD stream, met JS error "unable to set ContentDecryptionModule object"

Reason:
When AD insert, cmd id not exist, will return error for setcdm, which result JS error.

Solution:
Follow previous tizen tv code logic, return success for setcdm directly.

another fixup:
StopLayerBoundUpdateTimer when video hole done

Change-Id: I3cd7aea9399d5823bb3ea12c815b5a732e74ab0a
Signed-off-by: wuxiaoliang <xliang.wu@samsung.com>
third_party/blink/renderer/modules/encryptedmedia/html_media_element_encrypted_media.cc
third_party/blink/renderer/platform/media/web_media_player_impl.cc

index 9a07de8..5bdf82b 100644 (file)
@@ -289,8 +289,12 @@ void SetMediaKeysHandler::Fail(ExceptionCode code,
 
 void SetMediaKeysHandler::ClearFailed(ExceptionCode code,
                                       const String& error_message) {
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO) << __func__ << "(" << code << ", " << error_message << ")";
+#else
   DVLOG(EME_LOG_LEVEL) << __func__ << "(" << code << ", " << error_message
                        << ")";
+#endif
   HTMLMediaElementEncryptedMedia& this_element =
       HTMLMediaElementEncryptedMedia::From(*element_);
 
@@ -303,8 +307,12 @@ void SetMediaKeysHandler::ClearFailed(ExceptionCode code,
 
 void SetMediaKeysHandler::SetFailed(ExceptionCode code,
                                     const String& error_message) {
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO) << __func__ << "(" << code << ", " << error_message << ")";
+#else
   DVLOG(EME_LOG_LEVEL) << __func__ << "(" << code << ", " << error_message
                        << ")";
+#endif
   HTMLMediaElementEncryptedMedia& this_element =
       HTMLMediaElementEncryptedMedia::From(*element_);
 
@@ -368,9 +376,14 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(
     ExceptionState& exception_state) {
   HTMLMediaElementEncryptedMedia& this_element =
       HTMLMediaElementEncryptedMedia::From(element);
+#if BUILDFLAG(IS_TIZEN_TV)
+  LOG(INFO) << __func__ << ": current(" << this_element.media_keys_.Get()
+            << "), new(" << media_keys << ")";
+#else
   DVLOG(EME_LOG_LEVEL) << __func__ << ": current("
                        << this_element.media_keys_.Get() << "), new("
                        << media_keys << ")";
+#endif
 
   // From http://w3c.github.io/encrypted-media/#setMediaKeys
 
index f11a400..368db18 100644 (file)
@@ -1652,14 +1652,21 @@ void WebMediaPlayerImpl::SetContentDecryptionModule(
     return;
   }
 
+  SetCdmInternal(cdm);
+
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Finish set media key directly
+  // Fix issue : AD insert case in EME stream, no cdm_id in this case and will
+  // return failed here. And then JS error occurred.
+  result.Complete();
+#else
   // Create a local copy of `result` to avoid problems with the callback
   // getting passed to the media thread and causing `result` to be destructed
   // on the wrong thread in some failure conditions. Blink should prevent
   // multiple simultaneous calls.
   DCHECK(!set_cdm_result_);
   set_cdm_result_ = std::make_unique<WebContentDecryptionModuleResult>(result);
-
-  SetCdmInternal(cdm);
+#endif
 }
 
 void WebMediaPlayerImpl::OnEncryptedMediaInitData(
@@ -2591,6 +2598,7 @@ void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) {
   DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing);
 
   TRACE_EVENT0("media", "WebMediaPlayerImpl::OnVideoNaturalSizeChange");
+  LOG(INFO) << __func__ << " : " << size.ToString();
 
   // The input `size` is from the decoded video frame, which is the original
   // natural size and need to be rotated accordingly.
@@ -4369,6 +4377,7 @@ void WebMediaPlayerImpl::CreateVideoHoleFrame() {
   gfx::Size size(pipeline_metadata_.natural_size.width(),
                  pipeline_metadata_.natural_size.height());
 
+  LOG(INFO) << __func__ << " : " << size.ToString();
   scoped_refptr<media::VideoFrame> video_frame =
       media::VideoFrame::CreateHoleFrame(size);
   if (video_frame)
@@ -4379,6 +4388,9 @@ void WebMediaPlayerImpl::OnDrawableContentRectChanged(gfx::Rect rect,
                                                       bool is_video) {
   gfx::RectF rect_f = static_cast<gfx::RectF>(rect);
   LOG(INFO) << __func__ << " : " << rect_f.ToString();
+
+  // Once video hole done, this timer not needed.
+  StopLayerBoundUpdateTimer();
   if (rect_f != last_computed_rect_)
     pipeline_controller_->SetMediaGeometry(rect_f);