Index: media/remoting/remoting_renderer_controller.cc |
diff --git a/media/remoting/remoting_renderer_controller.cc b/media/remoting/remoting_renderer_controller.cc |
index 5f0d37eacdbc7a5939d49d5b0941e7077d07da8f..c07cdea5ba30848b957d2e67bae6a0cdc8407a1d 100644 |
--- a/media/remoting/remoting_renderer_controller.cc |
+++ b/media/remoting/remoting_renderer_controller.cc |
@@ -7,10 +7,21 @@ |
#include "base/bind.h" |
#include "base/logging.h" |
#include "base/threading/thread_checker.h" |
+#include "media/base/video_util.h" |
#include "media/remoting/remoting_cdm_context.h" |
namespace media { |
+namespace { |
+ |
+gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { |
+ if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) |
+ return gfx::Size(natural_size.height(), natural_size.width()); |
+ return natural_size; |
+} |
+ |
+} // namespace |
+ |
RemotingRendererController::RemotingRendererController( |
scoped_refptr<RemotingSourceImpl> remoting_source) |
: remoting_source_(remoting_source), weak_factory_(this) { |
@@ -43,6 +54,8 @@ void RemotingRendererController::OnSessionStateChanged() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
VLOG(1) << "OnSessionStateChanged: " << remoting_source_->state(); |
+ |
+ UpdateInterstitial(); |
UpdateAndMaybeSwitch(); |
} |
@@ -103,17 +116,22 @@ void RemotingRendererController::OnMetadataChanged( |
const PipelineMetadata& metadata) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ const gfx::Size old_size = pipeline_metadata_.natural_size; |
pipeline_metadata_ = metadata; |
is_encrypted_ = false; |
if (has_video()) { |
- video_decoder_config_ = metadata.video_decoder_config; |
- is_encrypted_ |= video_decoder_config_.is_encrypted(); |
+ is_encrypted_ |= metadata.video_decoder_config.is_encrypted(); |
+ pipeline_metadata_.natural_size = GetRotatedVideoSize( |
+ pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); |
} |
if (has_audio()) { |
- audio_decoder_config_ = metadata.audio_decoder_config; |
- is_encrypted_ |= audio_decoder_config_.is_encrypted(); |
+ is_encrypted_ |= metadata.audio_decoder_config.is_encrypted(); |
} |
+ |
+ if (pipeline_metadata_.natural_size != old_size) |
+ UpdateInterstitial(); |
+ |
UpdateAndMaybeSwitch(); |
} |
@@ -121,13 +139,13 @@ bool RemotingRendererController::IsVideoCodecSupported() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK(has_video()); |
- switch (video_decoder_config_.codec()) { |
+ switch (pipeline_metadata_.video_decoder_config.codec()) { |
case VideoCodec::kCodecH264: |
case VideoCodec::kCodecVP8: |
return true; |
default: |
VLOG(2) << "Remoting does not support video codec: " |
- << video_decoder_config_.codec(); |
+ << pipeline_metadata_.video_decoder_config.codec(); |
return false; |
} |
} |
@@ -136,7 +154,7 @@ bool RemotingRendererController::IsAudioCodecSupported() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK(has_audio()); |
- switch (audio_decoder_config_.codec()) { |
+ switch (pipeline_metadata_.audio_decoder_config.codec()) { |
case AudioCodec::kCodecAAC: |
case AudioCodec::kCodecMP3: |
case AudioCodec::kCodecPCM: |
@@ -156,7 +174,7 @@ bool RemotingRendererController::IsAudioCodecSupported() { |
return true; |
default: |
VLOG(2) << "Remoting does not support audio codec: " |
- << audio_decoder_config_.codec(); |
+ << pipeline_metadata_.audio_decoder_config.codec(); |
return false; |
} |
} |
@@ -243,4 +261,40 @@ void RemotingRendererController::UpdateAndMaybeSwitch() { |
} |
} |
+void RemotingRendererController::SetShowInterstitialCallback( |
+ const ShowInterstitialCallback& cb) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ show_interstitial_cb_ = cb; |
+ UpdateInterstitial(); |
+} |
+ |
+void RemotingRendererController::UpdateInterstitial() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ if (!remote_rendering_started_ || show_interstitial_cb_.is_null() || |
+ pipeline_metadata_.natural_size.IsEmpty()) |
+ return; |
+ |
+ RemotingInterstitialType type; |
+ switch (remoting_source_->state()) { |
+ case SESSION_STARTED: |
+ type = RemotingInterstitialType::IN_SESSION; |
+ break; |
+ case SESSION_PERMANENTLY_STOPPED: |
+ type = RemotingInterstitialType::ENCRYPTED_MEDIA_FATAL_ERROR; |
+ break; |
+ case SESSION_UNAVAILABLE: |
+ case SESSION_CAN_START: |
+ case SESSION_STARTING: |
+ case SESSION_STOPPING: |
+ return; |
+ } |
+ |
+ // The "BETWEEN_SESSIONS" interstitial will only be painted by |
+ // RemoteRendererImpl when it is destructed. |
+ DCHECK(type != RemotingInterstitialType::BETWEEN_SESSIONS); |
miu
2016/12/20 23:15:50
Per above comments, please remove this.
xjz
2016/12/20 23:54:55
Done.
|
+ |
+ // TODO(xjz): Download poster image when available. |
+ show_interstitial_cb_.Run(SkBitmap(), pipeline_metadata_.natural_size, type); |
+} |
+ |
} // namespace media |