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 CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ |
| 6 #define CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ |
| 7 |
5 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
6 #include "chromecast/browser/media/media_pipeline_backend_factory.h" | 9 #include "chromecast/browser/media/media_pipeline_backend_factory.h" |
| 10 #include "chromecast/browser/media/video_resolution_policy.h" |
7 #include "media/base/renderer.h" | 11 #include "media/base/renderer.h" |
8 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
9 | 13 |
10 namespace base { | 14 namespace base { |
11 class SingleThreadTaskRunner; | 15 class SingleThreadTaskRunner; |
12 } // namespace base | 16 } // namespace base |
13 | 17 |
14 namespace media { | 18 namespace media { |
15 class MediaLog; | 19 class MediaLog; |
16 } // namespace media | 20 } // namespace media |
17 | 21 |
18 namespace chromecast { | 22 namespace chromecast { |
19 class TaskRunnerImpl; | 23 class TaskRunnerImpl; |
20 | 24 |
21 namespace media { | 25 namespace media { |
22 class BalancedMediaTaskRunnerFactory; | 26 class BalancedMediaTaskRunnerFactory; |
23 class CastCdmContext; | 27 class CastCdmContext; |
24 class MediaPipelineImpl; | 28 class MediaPipelineImpl; |
25 | 29 |
26 class CastRenderer : public ::media::Renderer { | 30 class CastRenderer : public ::media::Renderer, |
| 31 public VideoResolutionPolicy::Observer { |
27 public: | 32 public: |
28 CastRenderer(const CreateMediaPipelineBackendCB& create_backend_cb, | 33 CastRenderer(const CreateMediaPipelineBackendCB& create_backend_cb, |
29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
30 const std::string& audio_device_id); | 35 const std::string& audio_device_id, |
| 36 VideoResolutionPolicy* video_resolution_policy); |
31 ~CastRenderer() final; | 37 ~CastRenderer() final; |
32 | 38 |
33 // ::media::Renderer implementation. | 39 // ::media::Renderer implementation. |
34 void Initialize(::media::DemuxerStreamProvider* demuxer_stream_provider, | 40 void Initialize(::media::DemuxerStreamProvider* demuxer_stream_provider, |
35 ::media::RendererClient* client, | 41 ::media::RendererClient* client, |
36 const ::media::PipelineStatusCB& init_cb) final; | 42 const ::media::PipelineStatusCB& init_cb) final; |
37 void SetCdm(::media::CdmContext* cdm_context, | 43 void SetCdm(::media::CdmContext* cdm_context, |
38 const ::media::CdmAttachedCB& cdm_attached_cb) final; | 44 const ::media::CdmAttachedCB& cdm_attached_cb) final; |
39 void Flush(const base::Closure& flush_cb) final; | 45 void Flush(const base::Closure& flush_cb) final; |
40 void StartPlayingFrom(base::TimeDelta time) final; | 46 void StartPlayingFrom(base::TimeDelta time) final; |
41 void SetPlaybackRate(double playback_rate) final; | 47 void SetPlaybackRate(double playback_rate) final; |
42 void SetVolume(float volume) final; | 48 void SetVolume(float volume) final; |
43 base::TimeDelta GetMediaTime() final; | 49 base::TimeDelta GetMediaTime() final; |
44 bool HasAudio() final; | 50 bool HasAudio() final; |
45 bool HasVideo() final; | 51 bool HasVideo() final; |
46 | 52 |
| 53 // VideoResolutionPolicy::Observer implementation. |
| 54 void OnVideoResolutionPolicyChanged() override; |
| 55 |
47 private: | 56 private: |
48 enum Stream { STREAM_AUDIO, STREAM_VIDEO }; | 57 enum Stream { STREAM_AUDIO, STREAM_VIDEO }; |
49 void OnError(::media::PipelineStatus status); | 58 void OnError(::media::PipelineStatus status); |
50 void OnEnded(Stream stream); | 59 void OnEnded(Stream stream); |
51 void OnStatisticsUpdate(const ::media::PipelineStatistics& stats); | 60 void OnStatisticsUpdate(const ::media::PipelineStatistics& stats); |
52 void OnBufferingStateChange(::media::BufferingState state); | 61 void OnBufferingStateChange(::media::BufferingState state); |
53 void OnWaitingForDecryptionKey(); | 62 void OnWaitingForDecryptionKey(); |
54 void OnVideoNaturalSizeChange(const gfx::Size& size); | 63 void OnVideoNaturalSizeChange(const gfx::Size& size); |
55 void OnVideoOpacityChange(bool opaque); | 64 void OnVideoOpacityChange(bool opaque); |
| 65 void CheckVideoResolutionPolicy(); |
56 | 66 |
57 const CreateMediaPipelineBackendCB create_backend_cb_; | 67 const CreateMediaPipelineBackendCB create_backend_cb_; |
58 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
59 std::string audio_device_id_; | 69 std::string audio_device_id_; |
| 70 VideoResolutionPolicy* video_resolution_policy_; |
60 ::media::RendererClient* client_; | 71 ::media::RendererClient* client_; |
61 CastCdmContext* cast_cdm_context_; | 72 CastCdmContext* cast_cdm_context_; |
62 scoped_refptr<BalancedMediaTaskRunnerFactory> media_task_runner_factory_; | 73 scoped_refptr<BalancedMediaTaskRunnerFactory> media_task_runner_factory_; |
63 std::unique_ptr<TaskRunnerImpl> backend_task_runner_; | 74 std::unique_ptr<TaskRunnerImpl> backend_task_runner_; |
64 std::unique_ptr<MediaPipelineImpl> pipeline_; | 75 std::unique_ptr<MediaPipelineImpl> pipeline_; |
65 bool eos_[2]; | 76 bool eos_[2]; |
| 77 gfx::Size video_res_; |
66 base::WeakPtrFactory<CastRenderer> weak_factory_; | 78 base::WeakPtrFactory<CastRenderer> weak_factory_; |
67 | 79 |
68 DISALLOW_COPY_AND_ASSIGN(CastRenderer); | 80 DISALLOW_COPY_AND_ASSIGN(CastRenderer); |
69 }; | 81 }; |
70 | 82 |
71 } // namespace media | 83 } // namespace media |
72 } // namespace chromecast | 84 } // namespace chromecast |
| 85 |
| 86 #endif // CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ |
OLD | NEW |