[M120 Migration][VD] Optimize debugging in log 61/307761/4
authoryangzhiwen <zw714.yang@samsung.com>
Wed, 13 Mar 2024 01:35:25 +0000 (09:35 +0800)
committerYanqing Lu <yanqing.lu@samsung.com>
Wed, 13 Mar 2024 11:05:02 +0000 (11:05 +0000)
Add player id in logs.

patch from:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/301267/

Change-Id: Ib05a00ca6b1d147e8418b081f4b70aa6a9c7dfa0
Signed-off-by: yangzhiwen <zw714.yang@samsung.com>
base/logging.h
media/base/pipeline_impl.cc
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc
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_tizen.h

index 0955b9c..19a7de2 100644 (file)
@@ -511,6 +511,8 @@ BASE_EXPORT int GetDisableAllVLogLevel();
 #define LOG_IF(severity, condition) \
   LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
 
+#define LOG_ID(severity, id) LOG(severity) << "[" << id << "]: "
+
 // The VLOG macros log with negative verbosities.
 #define VLOG_STREAM(verbose_level) \
   ::logging::LogMessage(__FILE__, __LINE__, -(verbose_level)).stream()
index e707a0d..63aaf7d 100644 (file)
@@ -1093,7 +1093,7 @@ void PipelineImpl::RendererWrapper::OnVideoConfigChange(
 void PipelineImpl::RendererWrapper::ToggleFullscreenMode(
     bool is_fullscreen,
     ToggledFullscreenCB cb) {
-  LOG(INFO) << __func__;
+  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
   if (shared_state_.renderer)
     shared_state_.renderer->ToggleFullscreenMode(is_fullscreen, std::move(cb));
 }
@@ -1102,7 +1102,7 @@ void PipelineImpl::RendererWrapper::OnRequestSuspend(bool resource_conflict) {
   if (state_ == kSuspending || state_ == kSuspended)
     return;
 
-  LOG(INFO) << __func__;
+  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
   request_suspend_task_handle_ = main_task_runner_->PostCancelableDelayedTask(
       base::subtle::PostDelayedTaskPassKey(), FROM_HERE,
       base::BindOnce(&PipelineImpl::OnRequestSuspend, weak_pipeline_,
@@ -1111,7 +1111,8 @@ void PipelineImpl::RendererWrapper::OnRequestSuspend(bool resource_conflict) {
 }
 
 void PipelineImpl::RendererWrapper::OnRequestSeek(base::TimeDelta time) {
-  LOG(INFO) << __func__ << " time:" << time;
+  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
+            << " time:" << time;
 
   if (!media_task_runner_->RunsTasksInCurrentSequence()) {
     media_task_runner_->PostTask(
@@ -1218,7 +1219,8 @@ void PipelineImpl::RendererWrapper::SetState(State next_state) {
 
 void PipelineImpl::RendererWrapper::CompleteSeek(base::TimeDelta seek_time,
                                                  PipelineStatus status) {
-  DVLOG(1) << __func__ << ": seek_time=" << seek_time << ", status=" << status;
+  DVLOG(1) << "(" << static_cast<void*>(this) << ") " << __func__
+           << ": status=" << status;
   DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
   DCHECK(state_ == kStarting || state_ == kSeeking || state_ == kResuming);
 
@@ -1297,7 +1299,7 @@ void PipelineImpl::RendererWrapper::InitializeDemuxer(
 
 void PipelineImpl::RendererWrapper::CreateRenderer(
     PipelineStatusCallback done_cb) {
-  DVLOG(1) << __func__;
+  DVLOG(1) << "(" << static_cast<void*>(this) << ") " << __func__;
   DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
   DCHECK(state_ == kStarting || state_ == kResuming);
 
@@ -1314,7 +1316,8 @@ void PipelineImpl::RendererWrapper::CreateRenderer(
 void PipelineImpl::RendererWrapper::OnRendererCreated(
     PipelineStatusCallback done_cb,
     std::unique_ptr<Renderer> renderer) {
-  DVLOG(1) << __func__ << ": renderer=" << renderer.get();
+  DVLOG(1) << "(" << static_cast<void*>(this) << ") " << __func__
+           << ": renderer=" << renderer.get();
   DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
 
   if (!renderer) {
@@ -1333,7 +1336,7 @@ void PipelineImpl::RendererWrapper::OnRendererCreated(
 
 void PipelineImpl::RendererWrapper::InitializeRenderer(
     PipelineStatusCallback done_cb) {
-  DVLOG(1) << __func__;
+  DVLOG(1) << "(" << static_cast<void*>(this) << ") " << __func__;
   DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
 
   switch (demuxer_->GetType()) {
@@ -1377,7 +1380,8 @@ void PipelineImpl::RendererWrapper::InitializeRenderer(
       was_played_with_user_activation_);
 
 #if defined(TIZEN_VIDEO_HOLE)
-  LOG(INFO) << __func__ << " call SetVideoHole : " << is_video_hole_;
+  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
+            << " call SetVideoHole : " << is_video_hole_;
   shared_state_.renderer->SetVideoHole(is_video_hole_);
 #endif
 #if BUILDFLAG(IS_TIZEN_TV)
@@ -1783,7 +1787,8 @@ base::TimeDelta PipelineImpl::GetMediaTime() const {
     return last_media_time_;
   }
 
-  DVLOG(3) << __func__ << ": " << media_time.InMilliseconds() << " ms";
+  DVLOG(3) << "(" << this << ") " << __func__ << ": "
+           << media_time.InMilliseconds() << " ms";
   last_media_time_ = media_time;
   return last_media_time_;
 }
index 5d58dd6..46c28dc 100644 (file)
@@ -67,7 +67,8 @@ TizenRendererImpl::TizenRendererImpl(
       renderer_extension_receiver_(this,
                                    std::move(renderer_extension_receiver)),
       web_contents_(web_contents) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
   DCHECK_EQ(WebContents::FromRenderFrameHost(
                 RenderFrameHost::FromID(process_id, routing_id)),
             web_contents);
@@ -96,7 +97,8 @@ TizenRendererImpl::TizenRendererImpl(
       video_rect_(gfx::RectF()),
 #endif
       renderer_extension_receiver_(this) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
   // TODO(dalecurtis): Remove once experiments for http://crbug.com/470940 are
   // complete.
   int threshold_ms = 0;
@@ -109,7 +111,8 @@ TizenRendererImpl::TizenRendererImpl(
 }
 
 TizenRendererImpl::~TizenRendererImpl() {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
   DCHECK(task_runner_->BelongsToCurrentThread());
 
   weak_factory_.InvalidateWeakPtrs();
@@ -128,7 +131,8 @@ TizenRendererImpl::~TizenRendererImpl() {
 void TizenRendererImpl::Initialize(media::MediaResource* media_resource,
                                    media::RendererClient* client,
                                    media::PipelineStatusCallback init_cb) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
   DCHECK(task_runner_->BelongsToCurrentThread());
   DCHECK_EQ(state_, STATE_UNINITIALIZED);
   DCHECK(init_cb);
@@ -178,7 +182,7 @@ void TizenRendererImpl::Initialize(media::MediaResource* media_resource,
                 web_contents->GetRenderWidgetHostView())) {
       view_aura->SetWebViewMovedCallback(base::BindRepeating(
           &TizenRendererImpl::OnWebViewMoved, base::Unretained(this)));
-      LOG(INFO) << "SetPositionMovedCallbacks called!";
+      LOG_ID(INFO, player_id_) << "SetPositionMovedCallbacks called!";
     }
   }
 #endif
@@ -191,8 +195,9 @@ void TizenRendererImpl::Initialize(media::MediaResource* media_resource,
 
   if (!media::MediaPlayerRegistry::GetInstance()->ActivateMediaPlayer(
           player_id_, !resource_conflicted_)) {
-    LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-              << " Can not initialize the player id: " << player_id_;
+    LOG_ID(INFO, player_id_)
+        << "(" << static_cast<void*>(this) << ") " << __func__
+        << " Can not initialize the player id: " << player_id_;
     return;
   }
 
@@ -220,7 +225,7 @@ void TizenRendererImpl::SetStreamInfo() {
 
 void TizenRendererImpl::SetPlayerInitialize() {
   if (media_player_->IsInitialized()) {
-    LOG(INFO) << __func__ << " Already initialized.";
+    LOG_ID(INFO, player_id_) << __func__ << " Already initialized.";
     return;
   }
 
@@ -236,7 +241,7 @@ void TizenRendererImpl::SetPlayerInitialize() {
 
 void TizenRendererImpl::SetPlayerPrepare() {
   if (!media_player_->CanPrepare()) {
-    LOG(INFO) << __func__ << " Already preparing or prepared.";
+    LOG_ID(INFO, player_id_) << __func__ << " Already preparing or prepared.";
     return;
   }
 
@@ -283,8 +288,8 @@ void TizenRendererImpl::Flush(base::OnceClosure flush_cb) {
 }
 
 void TizenRendererImpl::Seek(base::TimeDelta time, base::OnceClosure seek_cb) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-            << " time : " << time.InMicroseconds();
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__ << " time : " << time.InMicroseconds();
   media_player_->Seek(time, std::move(seek_cb));
 }
 
@@ -337,7 +342,7 @@ gfx::Rect TizenRendererImpl::GetViewportRect() const {
 
 void TizenRendererImpl::OnWebViewMoved() {
   if (media_player_) {
-    LOG(INFO) << __func__ << " Reset WebView-Position.";
+    LOG_ID(INFO, player_id_) << __func__ << " Reset WebView-Position.";
     SetPlayerMediaGeometry();
   }
 }
@@ -349,12 +354,13 @@ content::WebContents* TizenRendererImpl::GetWebContents() const {
 }
 
 void TizenRendererImpl::Suspend() {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
   if (is_suspended_)
     return;
 
   if (!media_player_) {
-    LOG(INFO) << "media_player_ is not created yet";
+    LOG_ID(INFO, player_id_) << "media_player_ is not created yet";
     return;
   }
 
@@ -369,7 +375,7 @@ content::WebContentsDelegate* TizenRendererImpl::GetWebContentsDelegate()
     const {
   content::WebContents* web_contents = GetWebContents();
   if (!web_contents) {
-    LOG(ERROR) << "web_contents is nullptr";
+    LOG_ID(ERROR, player_id_) << "web_contents is nullptr";
     return nullptr;
   }
   return web_contents->GetDelegate();
@@ -384,8 +390,8 @@ void TizenRendererImpl::ToggleFullscreenMode(bool is_fullscreen,
 }
 
 void TizenRendererImpl::StartPlayingFrom(base::TimeDelta time) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-            << " time : " << time.InMicroseconds();
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__ << " time : " << time.InMicroseconds();
   DCHECK(media_player_);
   DCHECK(task_runner_->BelongsToCurrentThread());
   TRACE_EVENT1("media", "TizenRendererImpl::StartPlayingFrom", "time_us",
@@ -400,8 +406,9 @@ void TizenRendererImpl::StartPlayingFrom(base::TimeDelta time) {
 }
 
 void TizenRendererImpl::SetPlaybackRate(double playback_rate) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__ << " "
-            << playback_rate << "/ " << playback_rate_;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__ << " " << playback_rate << "/ "
+                           << playback_rate_;
   DCHECK(task_runner_->BelongsToCurrentThread());
   TRACE_EVENT1("media", "TizenRendererImpl::SetPlaybackRate", "rate",
                playback_rate);
@@ -420,7 +427,8 @@ void TizenRendererImpl::SetPlaybackRate(double playback_rate) {
 }
 
 void TizenRendererImpl::SetVolume(float volume) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
   DCHECK(task_runner_->BelongsToCurrentThread());
   if (volume_ == volume)
     return;
@@ -486,19 +494,19 @@ void TizenRendererImpl::SetParentalRatingResult(bool is_pass) {
   if (media_player_)
     media_player_->SetParentalRatingResult(is_pass);
   else
-    LOG(ERROR) << "media_player_ is null";
+    LOG_ID(ERROR, player_id_) << "media_player_ is null";
 }
 
 bool TizenRendererImpl::PlaybackNotificationEnabled() {
   content::WebContents* web_contents = GetWebContents();
   if (!web_contents) {
-    LOG(ERROR) << "web_contents is nullptr";
+    LOG_ID(ERROR, player_id_) << "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;
+  LOG_ID(INFO, player_id_) << "media_playback_notification_enabled:" << enable;
   return enable;
 }
 
@@ -514,13 +522,13 @@ void TizenRendererImpl::NotifyPlaybackState(int state,
   content::WebContentsDelegate* web_contents_delegate =
       GetWebContentsDelegate();
   if (!web_contents_delegate) {
-    LOG(ERROR) << "GetWebContentsDelegate failed";
+    LOG_ID(ERROR, player_id_) << "GetWebContentsDelegate failed";
     return;
   }
 
   if (notify_playback_state_ < media::kPlaybackReady &&
       state == media::kPlaybackStop) {
-    LOG(ERROR) << "player not Ready but notify Stop";
+    LOG_ID(ERROR, player_id_) << "player not Ready but notify Stop";
   }
 
   notify_playback_state_ = state;
@@ -600,10 +608,11 @@ void TizenRendererImpl::OnRequestSeek(base::TimeDelta time) {
 }
 
 void TizenRendererImpl::OnRequestSuspend(bool resource_conflicted) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, player_id_) << "(" << static_cast<void*>(this) << ") "
+                           << __func__;
 
   if (is_suspended_) {
-    LOG(INFO) << " Media is already suspended.";
+    LOG_ID(INFO, player_id_) << " Media is already suspended.";
     return;
   }
 
index 4f408b5..5d5025c 100644 (file)
@@ -118,6 +118,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapi : public MediaPlayerTizen {
   void OnMediaDataChange(int player_id, int width, int height, int media);
   bool IsPlayerSuspended() { return suspended_; }
   bool player_prepared_{false};
+  int GetPlayerId() override { return player_id_; }
 
  protected:
   void OnMediaError(MediaError error_type);
index b18eaa3..8e7420a 100644 (file)
@@ -38,17 +38,19 @@ MediaPlayerBridgeCapiTV::MediaPlayerBridgeCapiTV(const GURL& url,
                                                  const std::string& user_agent,
                                                  double volume)
     : MediaPlayerBridgeCapi(url, user_agent, volume), weak_factory_(this) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, GetPlayerId())
+      << "(" << static_cast<void*>(this) << ") " << __func__;
 }
 
 MediaPlayerBridgeCapiTV::~MediaPlayerBridgeCapiTV() {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, GetPlayerId())
+      << "(" << static_cast<void*>(this) << ") " << __func__;
   weak_factory_.InvalidateWeakPtrs();
 }
 
 void MediaPlayerBridgeCapiTV::SetContentMimeType(const std::string& mime_type) {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-            << " mime_type : " << mime_type;
+  LOG_ID(INFO, GetPlayerId()) << "(" << static_cast<void*>(this) << ") "
+                              << __func__ << " mime_type : " << mime_type;
   mime_type_ = mime_type;
 }
 
@@ -62,14 +64,15 @@ void MediaPlayerBridgeCapiTV::Prepare() {
         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;
+  LOG_ID(INFO, GetPlayerId())
+      << "media_resource_acquired: " << media_resource_acquired
+      << ",translated_url:" << translated_url << ",drm_info: " << drm_info;
 
   if (mime_type_.find("application/vnd.oipf.contentaccessstreaming+xml") !=
       std::string::npos) {
-    LOG(INFO) << "CASD url,waiting for hbbtv parse the real url and set "
-                 "translated url";
+    LOG_ID(INFO, GetPlayerId())
+        << "CASD url,waiting for hbbtv parse the real url and set "
+           "translated url";
     return;
   }
 
@@ -77,7 +80,7 @@ void MediaPlayerBridgeCapiTV::Prepare() {
       GetMediaPlayerClient()->PlaybackNotificationEnabled() &&
       blink::IsHbbTV()) {
     if (!SetDrmInfo(drm_info)) {
-      LOG(ERROR) << "SetDrmInfo failed";
+      LOG_ID(ERROR, GetPlayerId()) << "SetDrmInfo failed";
       return;
     }
     if (!translated_url.empty())
@@ -116,19 +119,21 @@ void MediaPlayerBridgeCapiTV::Release() {
 }
 
 bool MediaPlayerBridgeCapiTV::Play() {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-            << ",current_time:" << GetCurrentTime().InSecondsF();
+  LOG_ID(INFO, GetPlayerId())
+      << "(" << static_cast<void*>(this) << ") " << __func__
+      << ",current_time:" << GetCurrentTime().InSecondsF();
 
   // HBBTV run in preloading and preplay mode. If no prepread do prepare
   // in PlayerPrePlay(), otherwise do normal Play.
   if (blink::IsHbbTV() && !player_prepared_) {
     if (!PlayerPrePlay())
-      LOG(ERROR) << "HBBTV prePlay fail.";
+      LOG_ID(ERROR, GetPlayerId()) << "HBBTV prePlay fail.";
     return false;
   }
 
   if (blink::IsHbbTV() && !parental_rating_pass_) {
-    LOG(INFO) << "parental rating authenticatoin is not pass yet,waiting...";
+    LOG_ID(INFO, GetPlayerId())
+        << "parental rating authenticatoin is not pass yet,waiting...";
     delayed_player_state_ = PLAYER_STATE_DELAYED_PLAY;
     MediaPlayerBridgeCapi::ExecuteDelayedPlayerState();
     return false;
@@ -143,8 +148,9 @@ bool MediaPlayerBridgeCapiTV::Play() {
 
 void MediaPlayerBridgeCapiTV::Pause(bool is_media_related_action) {
   if (!player_prepared_) {
-    LOG(INFO) << "(" << static_cast<void*>(this)
-              << "), pause while player is not prepared, pause delay";
+    LOG_ID(INFO, GetPlayerId())
+        << "(" << static_cast<void*>(this)
+        << "), pause while player is not prepared, pause delay";
     delayed_player_state_ = PLAYER_STATE_DELAYED_PAUSE;
     return;
   }
@@ -196,9 +202,9 @@ void MediaPlayerBridgeCapiTV::OnSeekableTimeUpdateTimerFired() {
 void MediaPlayerBridgeCapiTV::GetAdaptiveStreamingInfo() {
   int ret = player_get_adaptive_streaming_info(player_, &is_live_stream_,
                                                PLAYER_ADAPTIVE_INFO_IS_LIVE);
-  if (ret == PLAYER_ERROR_NONE && is_live_stream_) {
-    LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-              << " A live stream.";
+  if (ret != PLAYER_ERROR_NONE || is_live_stream_) {
+    LOG_ID(INFO, GetPlayerId()) << "(" << static_cast<void*>(this) << ") "
+                                << __func__ << " A live stream.";
   }
 }
 
@@ -222,8 +228,8 @@ void MediaPlayerBridgeCapiTV::UpdateSeekableTime() {
 
   GetAdaptiveStreamingInfo();
   if (!is_live_stream_) {
-    LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__
-              << " changed to static stream";
+    LOG_ID(INFO, GetPlayerId()) << "(" << static_cast<void*>(this) << ") "
+                                << __func__ << " changed to static stream";
     if (GetMediaPlayerClient())
       GetMediaPlayerClient()->OnSeekableTimeChange({}, {}, is_live_stream_);
     MediaPlayerBridgeCapi::UpdateDuration();
@@ -250,37 +256,41 @@ bool MediaPlayerBridgeCapiTV::GetLiveStreamingDuration(int64_t* min,
   const std::string duration(live_duration);
   const std::string::size_type delimiter = duration.find('|');
   if (delimiter == std::string::npos) {
-    LOG(ERROR) << "(" << static_cast<void*>(this) << ") " << __func__
-               << " Failed to find delimiter | in duration: " << duration;
+    LOG_ID(ERROR, GetPlayerId())
+        << "(" << static_cast<void*>(this) << ") " << __func__
+        << " Failed to find delimiter | in duration: " << duration;
     return false;
   }
 
   const std::string duration_min = duration.substr(0, delimiter);
   if (duration_min.empty()) {
-    LOG(ERROR) << "(" << static_cast<void*>(this) << ") " << __func__
-               << " Failed empty min sub str: " << duration << ", "
-               << delimiter;
+    LOG_ID(ERROR, GetPlayerId())
+        << "(" << static_cast<void*>(this) << ") " << __func__
+        << " Failed empty min sub str: " << duration << ", " << delimiter;
     return false;
   }
 
   int64_t out_min = 0;
   if (!base::StringToInt64(duration_min, &out_min)) {
-    LOG(ERROR) << "(" << static_cast<void*>(this) << ") " << __func__
-               << " Failed to get min from duration: " << duration;
+    LOG_ID(ERROR, GetPlayerId())
+        << "(" << static_cast<void*>(this) << ") " << __func__
+        << " Failed to get min from duration: " << duration;
     return false;
   }
 
   const std::string duration_max = duration.substr(delimiter + 1);
   if (duration_max.empty()) {
-    LOG(ERROR) << "(" << static_cast<void*>(this) << ") " << __func__
-               << " empty max sub str: " << duration << ", " << delimiter;
+    LOG_ID(ERROR, GetPlayerId())
+        << "(" << static_cast<void*>(this) << ") " << __func__
+        << " empty max sub str: " << duration << ", " << delimiter;
     return false;
   }
 
   int64_t out_max = 0;
   if (!base::StringToInt64(duration_max, &out_max)) {
-    LOG(ERROR) << "(" << static_cast<void*>(this) << ") " << __func__
-               << " Failed to get max from duration: " << duration;
+    LOG_ID(ERROR, GetPlayerId())
+        << "(" << static_cast<void*>(this) << ") " << __func__
+        << " Failed to get max from duration: " << duration;
     return false;
   }
 
@@ -365,22 +375,22 @@ void MediaPlayerBridgeCapiTV::AppendUrlHighBitRate(const std::string& url) {
   strncat(str_url, high_bitrate, strlen(high_bitrate));
   hbbtv_url_ = str_url;
   BLINKFREE(str_url);
-  LOG(INFO) << "hbbtv url:" << hbbtv_url_.c_str();
+  LOG_ID(INFO, GetPlayerId()) << "hbbtv url:" << hbbtv_url_.c_str();
 }
 
 bool MediaPlayerBridgeCapiTV::CheckHighBitRate() {
   if (!GetMediaPlayerClient()) {
-    LOG(ERROR) << "MediaPlayerClient is null";
+    LOG_ID(ERROR, GetPlayerId()) << "MediaPlayerClient is null";
     return false;
   }
   content::WebContentsDelegate* web_contents_delegate =
       GetMediaPlayerClient()->GetWebContentsDelegate();
   if (!web_contents_delegate) {
-    LOG(ERROR) << "get web_contents_delegate fail";
+    LOG_ID(ERROR, GetPlayerId()) << "get web_contents_delegate fail";
     return false;
   }
   bool ret = web_contents_delegate->IsHighBitRate();
-  LOG(INFO) << "get high bit rate: " << std::boolalpha << ret;
+  LOG_ID(INFO, GetPlayerId()) << "get high bit rate: " << std::boolalpha << ret;
   return ret;
 }
 
@@ -398,7 +408,8 @@ void MediaPlayerBridgeCapiTV::HandleDownloadableFontInfo(
 }
 
 bool MediaPlayerBridgeCapiTV::PreloadIfNeeded(int& ret) {
-  LOG(INFO) << "PreloadIfNeeded, is_preloaded_ " << is_preloaded_;
+  LOG_ID(INFO, GetPlayerId())
+      << "PreloadIfNeeded, is_preloaded_ " << is_preloaded_;
   if (blink::IsHbbTV() && !is_preloaded_) {
     ret = player_preloading_async(player_, -1, PlayerPreLoadingCb, this);
     return true;
@@ -408,8 +419,8 @@ bool MediaPlayerBridgeCapiTV::PreloadIfNeeded(int& ret) {
   if (GetMediaPlayerClient())
     GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackReady, player_id_);
   else
-    LOG(ERROR) << "(" << static_cast<void*>(this)
-               << "), GetMediaPlayerClient return null";
+    LOG_ID(ERROR, GetPlayerId()) << "(" << static_cast<void*>(this)
+                                 << "), GetMediaPlayerClient return null";
   SetDisplayAtPausedState();
   return false;
 }
@@ -422,13 +433,16 @@ void MediaPlayerBridgeCapiTV::SetDisplayAtPausedState() {
     ret = player_display_video_at_paused_state(player_, true);
 
   if (ret != PLAYER_ERROR_NONE)
-    LOG(ERROR) << "player_display_video_at_paused_state() failed";
+    LOG_ID(ERROR, GetPlayerId())
+        << "player_display_video_at_paused_state() failed";
 }
 
 void MediaPlayerBridgeCapiTV::UpdateDuration() {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, GetPlayerId())
+      << "(" << static_cast<void*>(this) << ") " << __func__;
   if (blink::IsHbbTV() && !is_preloaded_) {
-    LOG(INFO) << "HBBTV preload not finished, no need update duration. ";
+    LOG_ID(INFO, GetPlayerId())
+        << "HBBTV preload not finished, no need update duration. ";
     return;
   }
   if (is_live_stream_) {
@@ -466,10 +480,12 @@ void MediaPlayerBridgeCapiTV::UpdateDuration() {
 }
 
 void MediaPlayerBridgeCapiTV::UpdateMediaType() {
-  LOG(INFO) << "(" << static_cast<void*>(this) << ") " << __func__;
+  LOG_ID(INFO, GetPlayerId())
+      << "(" << static_cast<void*>(this) << ") " << __func__;
 
   if (blink::IsHbbTV() && !is_preloaded_) {
-    LOG(INFO) << "HBBTV preload not finished, no need update media type. ";
+    LOG_ID(INFO, GetPlayerId())
+        << "HBBTV preload not finished, no need update media type. ";
     return;
   }
   MediaPlayerBridgeCapi::UpdateMediaType();
@@ -501,7 +517,7 @@ void MediaPlayerBridgeCapiTV::OnPlayerPreloading() {
 bool MediaPlayerBridgeCapiTV::HBBTVResourceAcquired() {
   bool media_resource_acquired = false;
   if (!GetMediaPlayerClient()) {
-    LOG(ERROR) << "MediaPlayerTizenClient is nullptr";
+    LOG_ID(ERROR, GetPlayerId()) << "MediaPlayerTizenClient is nullptr";
     return false;
   }
 
@@ -510,14 +526,14 @@ bool MediaPlayerBridgeCapiTV::HBBTVResourceAcquired() {
       &media_resource_acquired, NULL, NULL);
   if (!media_resource_acquired) {
     GetMediaPlayerClient()->NotifyPlaybackState(kPlaybackStop, player_id_);
-    LOG(ERROR) << "HBBTV media resource acquired failed";
+    LOG_ID(ERROR, GetPlayerId()) << "HBBTV media resource acquired failed";
   }
   return media_resource_acquired;
 }
 
 void MediaPlayerBridgeCapiTV::PlayerPreloaded() {
-  LOG(INFO) << "PlayerPreloaded,this: " << this
-            << ",player_prepared_:" << player_prepared_;
+  LOG_ID(INFO, GetPlayerId()) << "PlayerPreloaded,this: " << this
+                              << ",player_prepared_:" << player_prepared_;
 
   is_preloaded_ = true;
   is_live_stream_ = CheckLiveStreaming();
@@ -533,7 +549,7 @@ void MediaPlayerBridgeCapiTV::PlayerPreloaded() {
   UpdateDuration();
   UpdateMediaType();
   if (GetMediaType() == MediaType::Invalid) {
-    LOG(ERROR) << "Media type is not valid!";
+    LOG_ID(ERROR, GetPlayerId()) << "Media type is not valid!";
     return;
   }
 
@@ -550,21 +566,21 @@ void MediaPlayerBridgeCapiTV::PlayerPreloaded() {
 }
 
 bool MediaPlayerBridgeCapiTV::PlayerPrePlay() {
-  LOG(INFO) << "PlayerPrePlay, this: " << this
-            << ",is_player_prepared : " << player_prepared_;
+  LOG_ID(INFO, GetPlayerId()) << "PlayerPrePlay, this: " << this
+                              << ",is_player_prepared : " << player_prepared_;
   if (IsPlayerSuspended()) {
-    LOG(INFO) << "PlayerPrePlay while player is suspended";
+    LOG_ID(INFO, GetPlayerId()) << "PlayerPrePlay while player is suspended";
     return false;
   }
 
   if (!HBBTVResourceAcquired()) {
-    LOG(INFO)
+    LOG_ID(INFO, GetPlayerId())
         << "PlayerPrePlay while it's not in case of HBBTV Resource Acquired";
     return false;
   }
 
   delayed_player_state_ = PLAYER_STATE_DELAYED_PLAY;
-  LOG(INFO) << "begin to |player_prepare_async|";
+  LOG_ID(INFO, GetPlayerId()) << "begin to |player_prepare_async|";
 
   SetDisplayAtPausedState();
   int ret = SetPlayerPrepareAsync();
@@ -596,11 +612,11 @@ bool MediaPlayerBridgeCapiTV::SetDrmInfo(std::string& drm_info) {
 
     std::string trim_key = drm_info_pair.at(0);
     std::string trim_value = drm_info_pair.at(1);
-    LOG(INFO) << "trim_key: " << trim_key.c_str()
-              << ",trim_value: " << trim_value.c_str();
+    LOG_ID(INFO, GetPlayerId()) << "trim_key: " << trim_key.c_str()
+                                << ",trim_value: " << trim_value.c_str();
 
     if (!SetMediaDRMInfo(trim_key, trim_value)) {
-      LOG(ERROR)
+      LOG_ID(ERROR, GetPlayerId())
           << "MediaPlayerBridgeCapiTV::SetDrmInfo SetMediaDRMInfo failed";
       return false;
     }
@@ -611,8 +627,9 @@ bool MediaPlayerBridgeCapiTV::SetDrmInfo(std::string& drm_info) {
 
 bool MediaPlayerBridgeCapiTV::SetMediaDRMInfo(const std::string& type_data,
                                               const std::string& value_data) {
-  LOG(INFO) << "player_set_drm_info(type_length(" << type_data.length() << ") "
-            << " value_length(" << value_data.length() << ")) ";
+  LOG_ID(INFO, GetPlayerId())
+      << "player_set_drm_info(type_length(" << type_data.length() << ") "
+      << " value_length(" << value_data.length() << ")) ";
   int ret = PLAYER_ERROR_INVALID_OPERATION;
   const void* type_data_ptr = type_data.c_str();
   const void* value_data_ptr = value_data.c_str();
@@ -628,7 +645,7 @@ bool MediaPlayerBridgeCapiTV::SetMediaDRMInfo(const std::string& type_data,
 }
 
 void MediaPlayerBridgeCapiTV::OnDrmError(int err_code, char* err_str) {
-  LOG(ERROR) << "OnDrmError err_str[" << err_str << "]";
+  LOG_ID(ERROR, GetPlayerId()) << "OnDrmError err_str[" << err_str << "]";
   if (!task_runner_->BelongsToCurrentThread()) {
     task_runner_->PostTask(
         FROM_HERE,
@@ -642,15 +659,16 @@ void MediaPlayerBridgeCapiTV::HandleParentalRatingInfo(const std::string& info,
                                                        const std::string& url) {
   content::WebContentsDelegate* web_contents_delegate =
       GetMediaPlayerClient()->GetWebContentsDelegate();
-  if (!web_contents_delegate){
-    LOG(ERROR) << "web_contents_delegate is null";
+  if (!web_contents_delegate) {
+    LOG_ID(ERROR, GetPlayerId()) << "web_contents_delegate is null";
     return;
   }
   web_contents_delegate->NotifyParentalRatingInfo(info, url);
 }
 
 void MediaPlayerBridgeCapiTV::SetParentalRatingResult(bool is_pass) {
-  LOG(INFO) << "ParentalRatingResult:" << std::boolalpha << is_pass;
+  LOG_ID(INFO, GetPlayerId())
+      << "ParentalRatingResult:" << std::boolalpha << is_pass;
   parental_rating_pass_ = is_pass;
 
   // if authentication fail, raise MEDIA_ERROR_DECODE
@@ -660,7 +678,7 @@ void MediaPlayerBridgeCapiTV::SetParentalRatingResult(bool is_pass) {
   }
 
   if (player_prepared_) {
-    LOG(INFO) << "player already prepared,execute play";
+    LOG_ID(INFO, GetPlayerId()) << "player already prepared,execute play";
     ExecuteDelayedPlayerState();
   }
 }
index b7da999..d4b9de5 100644 (file)
@@ -107,6 +107,7 @@ class MEDIA_EXPORT MediaPlayerTizen {
   virtual void SetHardwareResource(int config) {}
   virtual void EnableTbmBufferCallback(bool enable) {}
   virtual void SetAppInfo() {}
+  virtual int GetPlayerId() { return -1; }
   virtual void SetContentMimeType(const std::string& mime_type) {}
   virtual void SetParentalRatingResult(bool is_pass) {}
 };