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