OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback.h" | |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
16 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
17 #include "media/base/buffering_state.h" | 16 #include "media/base/buffering_state.h" |
18 #include "media/base/pipeline_status.h" | 17 #include "media/base/pipeline_status.h" |
19 #include "media/base/renderer_client.h" | 18 #include "media/base/renderer_client.h" |
20 #include "media/mojo/interfaces/renderer.mojom.h" | 19 #include "media/mojo/interfaces/renderer.mojom.h" |
21 #include "media/mojo/services/media_mojo_export.h" | 20 #include "media/mojo/services/media_mojo_export.h" |
22 #include "mojo/public/cpp/bindings/strong_binding.h" | 21 #include "mojo/public/cpp/bindings/strong_binding.h" |
(...skipping 15 matching lines...) Expand all Loading... |
38 MojoRendererService( | 37 MojoRendererService( |
39 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, | 38 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, |
40 std::unique_ptr<media::Renderer> renderer, | 39 std::unique_ptr<media::Renderer> renderer, |
41 mojo::InterfaceRequest<mojom::Renderer> request); | 40 mojo::InterfaceRequest<mojom::Renderer> request); |
42 ~MojoRendererService() final; | 41 ~MojoRendererService() final; |
43 | 42 |
44 // mojom::Renderer implementation. | 43 // mojom::Renderer implementation. |
45 void Initialize(mojom::RendererClientPtr client, | 44 void Initialize(mojom::RendererClientPtr client, |
46 mojom::DemuxerStreamPtr audio, | 45 mojom::DemuxerStreamPtr audio, |
47 mojom::DemuxerStreamPtr video, | 46 mojom::DemuxerStreamPtr video, |
48 const InitializeCallback& callback) final; | 47 const mojo::Callback<void(bool)>& callback) final; |
49 void Flush(const FlushCallback& callback) final; | 48 void Flush(const mojo::Closure& callback) final; |
50 void StartPlayingFrom(int64_t time_delta_usec) final; | 49 void StartPlayingFrom(int64_t time_delta_usec) final; |
51 void SetPlaybackRate(double playback_rate) final; | 50 void SetPlaybackRate(double playback_rate) final; |
52 void SetVolume(float volume) final; | 51 void SetVolume(float volume) final; |
53 void SetCdm(int32_t cdm_id, const SetCdmCallback& callback) final; | 52 void SetCdm(int32_t cdm_id, const mojo::Callback<void(bool)>& callback) final; |
54 | 53 |
55 private: | 54 private: |
56 enum State { | 55 enum State { |
57 STATE_UNINITIALIZED, | 56 STATE_UNINITIALIZED, |
58 STATE_INITIALIZING, | 57 STATE_INITIALIZING, |
59 STATE_FLUSHING, | 58 STATE_FLUSHING, |
60 STATE_PLAYING, | 59 STATE_PLAYING, |
61 STATE_ERROR | 60 STATE_ERROR |
62 }; | 61 }; |
63 | 62 |
64 // RendererClient implementation. | 63 // RendererClient implementation. |
65 void OnError(PipelineStatus status) final; | 64 void OnError(PipelineStatus status) final; |
66 void OnEnded() final; | 65 void OnEnded() final; |
67 void OnStatisticsUpdate(const PipelineStatistics& stats) final; | 66 void OnStatisticsUpdate(const PipelineStatistics& stats) final; |
68 void OnBufferingStateChange(BufferingState state) final; | 67 void OnBufferingStateChange(BufferingState state) final; |
69 void OnWaitingForDecryptionKey() final; | 68 void OnWaitingForDecryptionKey() final; |
70 void OnVideoNaturalSizeChange(const gfx::Size& size) final; | 69 void OnVideoNaturalSizeChange(const gfx::Size& size) final; |
71 void OnVideoOpacityChange(bool opaque) final; | 70 void OnVideoOpacityChange(bool opaque) final; |
72 | 71 |
73 // Called when the DemuxerStreamProviderShim is ready to go (has a config, | 72 // Called when the DemuxerStreamProviderShim is ready to go (has a config, |
74 // pipe handle, etc) and can be handed off to a renderer for use. | 73 // pipe handle, etc) and can be handed off to a renderer for use. |
75 void OnStreamReady(const base::Callback<void(bool)>& callback); | 74 void OnStreamReady(const mojo::Callback<void(bool)>& callback); |
76 | 75 |
77 // Called when |audio_renderer_| initialization has completed. | 76 // Called when |audio_renderer_| initialization has completed. |
78 void OnRendererInitializeDone(const base::Callback<void(bool)>& callback, | 77 void OnRendererInitializeDone(const mojo::Callback<void(bool)>& callback, |
79 PipelineStatus status); | 78 PipelineStatus status); |
80 | 79 |
81 // Periodically polls the media time from the renderer and notifies the client | 80 // Periodically polls the media time from the renderer and notifies the client |
82 // if the media time has changed since the last update. If |force| is true, | 81 // if the media time has changed since the last update. If |force| is true, |
83 // the client is notified even if the time is unchanged. | 82 // the client is notified even if the time is unchanged. |
84 void UpdateMediaTime(bool force); | 83 void UpdateMediaTime(bool force); |
85 void CancelPeriodicMediaTimeUpdates(); | 84 void CancelPeriodicMediaTimeUpdates(); |
86 void SchedulePeriodicMediaTimeUpdates(); | 85 void SchedulePeriodicMediaTimeUpdates(); |
87 | 86 |
88 // Callback executed once Flush() completes. | 87 // Callback executed once Flush() completes. |
89 void OnFlushCompleted(const FlushCallback& callback); | 88 void OnFlushCompleted(const mojo::Closure& callback); |
90 | 89 |
91 // Callback executed once SetCdm() completes. | 90 // Callback executed once SetCdm() completes. |
92 void OnCdmAttached(scoped_refptr<MediaKeys> cdm, | 91 void OnCdmAttached(scoped_refptr<MediaKeys> cdm, |
93 const base::Callback<void(bool)>& callback, | 92 const mojo::Callback<void(bool)>& callback, |
94 bool success); | 93 bool success); |
95 | 94 |
96 mojo::StrongBinding<mojom::Renderer> binding_; | 95 mojo::StrongBinding<mojom::Renderer> binding_; |
97 | 96 |
98 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; | 97 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; |
99 | 98 |
100 State state_; | 99 State state_; |
101 | 100 |
102 std::unique_ptr<DemuxerStreamProviderShim> stream_provider_; | 101 std::unique_ptr<DemuxerStreamProviderShim> stream_provider_; |
103 | 102 |
(...skipping 13 matching lines...) Expand all Loading... |
117 | 116 |
118 base::WeakPtr<MojoRendererService> weak_this_; | 117 base::WeakPtr<MojoRendererService> weak_this_; |
119 base::WeakPtrFactory<MojoRendererService> weak_factory_; | 118 base::WeakPtrFactory<MojoRendererService> weak_factory_; |
120 | 119 |
121 DISALLOW_COPY_AND_ASSIGN(MojoRendererService); | 120 DISALLOW_COPY_AND_ASSIGN(MojoRendererService); |
122 }; | 121 }; |
123 | 122 |
124 } // namespace media | 123 } // namespace media |
125 | 124 |
126 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ | 125 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ |
OLD | NEW |