| 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_ | 5 #ifndef CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ |
| 6 #define CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ | 6 #define CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #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" | 10 #include "chromecast/browser/media/video_resolution_policy.h" |
| 11 #include "chromecast/media/base/media_resource_tracker.h" |
| 11 #include "media/base/renderer.h" | 12 #include "media/base/renderer.h" |
| 12 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
| 16 } // namespace base | 17 } // namespace base |
| 17 | 18 |
| 18 namespace media { | 19 namespace media { |
| 19 class MediaLog; | 20 class MediaLog; |
| 20 } // namespace media | 21 } // namespace media |
| 21 | 22 |
| 22 namespace chromecast { | 23 namespace chromecast { |
| 23 class TaskRunnerImpl; | 24 class TaskRunnerImpl; |
| 24 | 25 |
| 25 namespace media { | 26 namespace media { |
| 26 class BalancedMediaTaskRunnerFactory; | 27 class BalancedMediaTaskRunnerFactory; |
| 27 class CastCdmContext; | 28 class CastCdmContext; |
| 28 class MediaPipelineImpl; | 29 class MediaPipelineImpl; |
| 29 | 30 |
| 30 class CastRenderer : public ::media::Renderer, | 31 class CastRenderer : public ::media::Renderer, |
| 31 public VideoResolutionPolicy::Observer { | 32 public VideoResolutionPolicy::Observer { |
| 32 public: | 33 public: |
| 33 CastRenderer(const CreateMediaPipelineBackendCB& create_backend_cb, | 34 CastRenderer(const CreateMediaPipelineBackendCB& create_backend_cb, |
| 34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 35 const std::string& audio_device_id, | 36 const std::string& audio_device_id, |
| 36 VideoResolutionPolicy* video_resolution_policy); | 37 VideoResolutionPolicy* video_resolution_policy, |
| 38 MediaResourceTracker* media_resource_tracker); |
| 37 ~CastRenderer() final; | 39 ~CastRenderer() final; |
| 38 | 40 |
| 39 // ::media::Renderer implementation. | 41 // ::media::Renderer implementation. |
| 40 void Initialize(::media::DemuxerStreamProvider* demuxer_stream_provider, | 42 void Initialize(::media::DemuxerStreamProvider* demuxer_stream_provider, |
| 41 ::media::RendererClient* client, | 43 ::media::RendererClient* client, |
| 42 const ::media::PipelineStatusCB& init_cb) final; | 44 const ::media::PipelineStatusCB& init_cb) final; |
| 43 void SetCdm(::media::CdmContext* cdm_context, | 45 void SetCdm(::media::CdmContext* cdm_context, |
| 44 const ::media::CdmAttachedCB& cdm_attached_cb) final; | 46 const ::media::CdmAttachedCB& cdm_attached_cb) final; |
| 45 void Flush(const base::Closure& flush_cb) final; | 47 void Flush(const base::Closure& flush_cb) final; |
| 46 void StartPlayingFrom(base::TimeDelta time) final; | 48 void StartPlayingFrom(base::TimeDelta time) final; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 void OnBufferingStateChange(::media::BufferingState state); | 63 void OnBufferingStateChange(::media::BufferingState state); |
| 62 void OnWaitingForDecryptionKey(); | 64 void OnWaitingForDecryptionKey(); |
| 63 void OnVideoNaturalSizeChange(const gfx::Size& size); | 65 void OnVideoNaturalSizeChange(const gfx::Size& size); |
| 64 void OnVideoOpacityChange(bool opaque); | 66 void OnVideoOpacityChange(bool opaque); |
| 65 void CheckVideoResolutionPolicy(); | 67 void CheckVideoResolutionPolicy(); |
| 66 | 68 |
| 67 const CreateMediaPipelineBackendCB create_backend_cb_; | 69 const CreateMediaPipelineBackendCB create_backend_cb_; |
| 68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 70 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 69 std::string audio_device_id_; | 71 std::string audio_device_id_; |
| 70 VideoResolutionPolicy* video_resolution_policy_; | 72 VideoResolutionPolicy* video_resolution_policy_; |
| 73 MediaResourceTracker* media_resource_tracker_; |
| 74 // Must outlive |pipeline_| to properly count resource usage. |
| 75 std::unique_ptr<MediaResourceTracker::ScopedUsage> media_resource_usage_; |
| 76 |
| 71 ::media::RendererClient* client_; | 77 ::media::RendererClient* client_; |
| 72 CastCdmContext* cast_cdm_context_; | 78 CastCdmContext* cast_cdm_context_; |
| 73 scoped_refptr<BalancedMediaTaskRunnerFactory> media_task_runner_factory_; | 79 scoped_refptr<BalancedMediaTaskRunnerFactory> media_task_runner_factory_; |
| 74 std::unique_ptr<TaskRunnerImpl> backend_task_runner_; | 80 std::unique_ptr<TaskRunnerImpl> backend_task_runner_; |
| 75 std::unique_ptr<MediaPipelineImpl> pipeline_; | 81 std::unique_ptr<MediaPipelineImpl> pipeline_; |
| 76 bool eos_[2]; | 82 bool eos_[2]; |
| 77 gfx::Size video_res_; | 83 gfx::Size video_res_; |
| 84 |
| 78 base::WeakPtrFactory<CastRenderer> weak_factory_; | 85 base::WeakPtrFactory<CastRenderer> weak_factory_; |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(CastRenderer); | 86 DISALLOW_COPY_AND_ASSIGN(CastRenderer); |
| 81 }; | 87 }; |
| 82 | 88 |
| 83 } // namespace media | 89 } // namespace media |
| 84 } // namespace chromecast | 90 } // namespace chromecast |
| 85 | 91 |
| 86 #endif // CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ | 92 #endif // CHROMECAST_BROWSER_MEDIA_CAST_RENDERER_H_ |
| OLD | NEW |