| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/remoting/remoting_renderer_controller.h" | 5 #include "media/remoting/remoting_renderer_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "media/remoting/remoting_cdm_context.h" | 10 #include "media/remoting/remoting_cdm_context.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 namespace { | |
| 15 | |
| 16 gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { | |
| 17 if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) | |
| 18 return gfx::Size(natural_size.height(), natural_size.width()); | |
| 19 return natural_size; | |
| 20 } | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 RemotingRendererController::RemotingRendererController( | 14 RemotingRendererController::RemotingRendererController( |
| 25 scoped_refptr<RemotingSourceImpl> remoting_source) | 15 scoped_refptr<RemotingSourceImpl> remoting_source) |
| 26 : remoting_source_(remoting_source), weak_factory_(this) { | 16 : remoting_source_(remoting_source), weak_factory_(this) { |
| 27 remoting_source_->AddClient(this); | 17 remoting_source_->AddClient(this); |
| 28 } | 18 } |
| 29 | 19 |
| 30 RemotingRendererController::~RemotingRendererController() { | 20 RemotingRendererController::~RemotingRendererController() { |
| 31 DCHECK(thread_checker_.CalledOnValidThread()); | 21 DCHECK(thread_checker_.CalledOnValidThread()); |
| 32 remoting_source_->RemoveClient(this); | 22 remoting_source_->RemoveClient(this); |
| 33 } | 23 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 156 } |
| 167 | 157 |
| 168 void RemotingRendererController::OnMetadataChanged( | 158 void RemotingRendererController::OnMetadataChanged( |
| 169 const PipelineMetadata& metadata) { | 159 const PipelineMetadata& metadata) { |
| 170 DCHECK(thread_checker_.CalledOnValidThread()); | 160 DCHECK(thread_checker_.CalledOnValidThread()); |
| 171 | 161 |
| 172 const gfx::Size old_size = pipeline_metadata_.natural_size; | 162 const gfx::Size old_size = pipeline_metadata_.natural_size; |
| 173 pipeline_metadata_ = metadata; | 163 pipeline_metadata_ = metadata; |
| 174 | 164 |
| 175 is_encrypted_ = false; | 165 is_encrypted_ = false; |
| 176 if (has_video()) { | 166 if (has_video()) |
| 177 is_encrypted_ |= metadata.video_decoder_config.is_encrypted(); | 167 is_encrypted_ |= metadata.video_decoder_config.is_encrypted(); |
| 178 pipeline_metadata_.natural_size = GetRotatedVideoSize( | 168 if (has_audio()) |
| 179 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); | |
| 180 } | |
| 181 if (has_audio()) { | |
| 182 is_encrypted_ |= metadata.audio_decoder_config.is_encrypted(); | 169 is_encrypted_ |= metadata.audio_decoder_config.is_encrypted(); |
| 183 } | |
| 184 | 170 |
| 185 if (pipeline_metadata_.natural_size != old_size) | 171 if (pipeline_metadata_.natural_size != old_size) |
| 186 UpdateInterstitial(base::nullopt); | 172 UpdateInterstitial(base::nullopt); |
| 187 | 173 |
| 188 UpdateAndMaybeSwitch(); | 174 UpdateAndMaybeSwitch(); |
| 189 } | 175 } |
| 190 | 176 |
| 191 bool RemotingRendererController::IsVideoCodecSupported() { | 177 bool RemotingRendererController::IsVideoCodecSupported() { |
| 192 DCHECK(thread_checker_.CalledOnValidThread()); | 178 DCHECK(thread_checker_.CalledOnValidThread()); |
| 193 DCHECK(has_video()); | 179 DCHECK(has_video()); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 const GURL& download_url, | 381 const GURL& download_url, |
| 396 const SkBitmap& image) { | 382 const SkBitmap& image) { |
| 397 DCHECK(thread_checker_.CalledOnValidThread()); | 383 DCHECK(thread_checker_.CalledOnValidThread()); |
| 398 | 384 |
| 399 if (download_url != poster_url_) | 385 if (download_url != poster_url_) |
| 400 return; // The poster image URL has changed during the download. | 386 return; // The poster image URL has changed during the download. |
| 401 UpdateInterstitial(image); | 387 UpdateInterstitial(image); |
| 402 } | 388 } |
| 403 | 389 |
| 404 } // namespace media | 390 } // namespace media |
| OLD | NEW |