| 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 #ifndef MEDIA_REMOTING_REMOTING_INTERSTITIAL_UI_H_ | 5 #ifndef MEDIA_REMOTING_REMOTING_INTERSTITIAL_UI_H_ |
| 6 #define MEDIA_REMOTING_REMOTING_INTERSTITIAL_UI_H_ | 6 #define MEDIA_REMOTING_REMOTING_INTERSTITIAL_UI_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "media/base/pipeline_metadata.h" | |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "ui/gfx/geometry/size.h" |
| 12 | 11 |
| 13 namespace media { | 12 namespace media { |
| 14 | 13 |
| 15 class VideoFrame; | |
| 16 class VideoRendererSink; | 14 class VideoRendererSink; |
| 17 | 15 |
| 16 enum RemotingInterstitialType { |
| 17 NONE, // No interstitial is drawn. Show background image only. |
| 18 SUCCESS, |
| 19 FAIL, |
| 20 }; |
| 21 |
| 18 class RemotingInterstitialUI { | 22 class RemotingInterstitialUI { |
| 19 public: | 23 public: |
| 20 RemotingInterstitialUI(VideoRendererSink* video_renderer_sink, | 24 explicit RemotingInterstitialUI(VideoRendererSink* video_renderer_sink); |
| 21 const PipelineMetadata& pipeline_metadata); | |
| 22 ~RemotingInterstitialUI(); | 25 ~RemotingInterstitialUI(); |
| 23 | 26 |
| 24 void ShowInterstitial(bool is_remoting_successful); | 27 // Draw remoting interstitial on |background_image| and show it. |
| 28 // |background_image| will be scaled to fit in |canvas_size|, but keep its |
| 29 // aspect ratio. When has different aspect ratio with |canvas_size|, scaled |
| 30 // |background_image| will be centered in the canvas. When |background_image| |
| 31 // is empty, interstitial will be drawn on a blank and black background. |
| 32 void ShowInterstitialOnSink(const SkBitmap& background_image, |
| 33 const gfx::Size& canvas_size, |
| 34 RemotingInterstitialType interstial_type); |
| 35 |
| 36 base::WeakPtr<RemotingInterstitialUI> GetWeakPtr() { |
| 37 return weak_factory_.GetWeakPtr(); |
| 38 } |
| 25 | 39 |
| 26 private: | 40 private: |
| 27 // Gets an 'interstitial' VideoFrame to paint on the media player when the | |
| 28 // video is being played remotely. | |
| 29 scoped_refptr<VideoFrame> GetInterstitial(const SkBitmap& background_image, | |
| 30 bool is_remoting_successful); | |
| 31 | |
| 32 VideoRendererSink* const video_renderer_sink_; // Outlives this class. | 41 VideoRendererSink* const video_renderer_sink_; // Outlives this class. |
| 33 PipelineMetadata pipeline_metadata_; | 42 base::WeakPtrFactory<RemotingInterstitialUI> weak_factory_; |
| 34 | 43 |
| 35 DISALLOW_COPY_AND_ASSIGN(RemotingInterstitialUI); | 44 DISALLOW_COPY_AND_ASSIGN(RemotingInterstitialUI); |
| 36 }; | 45 }; |
| 37 | 46 |
| 38 } // namespace media | 47 } // namespace media |
| 39 | 48 |
| 40 #endif // MEDIA_REMOTING_REMOTING_INTERSTITIAL_UI_H_ | 49 #endif // MEDIA_REMOTING_REMOTING_INTERSTITIAL_UI_H_ |
| OLD | NEW |