Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: media/mojo/services/mojo_renderer_service.h

Issue 2491043003: MediaResource refactoring to support multiple streams (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <memory> 9 #include <memory>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "base/unguessable_token.h" 17 #include "base/unguessable_token.h"
18 #include "media/base/buffering_state.h" 18 #include "media/base/buffering_state.h"
19 #include "media/base/demuxer_stream_provider.h" 19 #include "media/base/media_resource.h"
20 #include "media/base/pipeline_status.h" 20 #include "media/base/pipeline_status.h"
21 #include "media/base/renderer_client.h" 21 #include "media/base/renderer_client.h"
22 #include "media/mojo/interfaces/renderer.mojom.h" 22 #include "media/mojo/interfaces/renderer.mojom.h"
23 #include "media/mojo/services/media_mojo_export.h" 23 #include "media/mojo/services/media_mojo_export.h"
24 #include "mojo/public/cpp/bindings/strong_binding.h" 24 #include "mojo/public/cpp/bindings/strong_binding.h"
25 25
26 namespace media { 26 namespace media {
27 27
28 class AudioRendererSink; 28 class AudioRendererSink;
29 class DemuxerStreamProviderShim; 29 class MediaResourceShim;
30 class ContentDecryptionModule; 30 class ContentDecryptionModule;
31 class MojoCdmServiceContext; 31 class MojoCdmServiceContext;
32 class Renderer; 32 class Renderer;
33 class VideoRendererSink; 33 class VideoRendererSink;
34 34
35 // A mojom::Renderer implementation that use a media::Renderer to render 35 // A mojom::Renderer implementation that use a media::Renderer to render
36 // media streams. 36 // media streams.
37 class MEDIA_MOJO_EXPORT MojoRendererService 37 class MEDIA_MOJO_EXPORT MojoRendererService
38 : NON_EXPORTED_BASE(public mojom::Renderer), 38 : NON_EXPORTED_BASE(public mojom::Renderer),
39 public RendererClient { 39 public RendererClient {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // RendererClient implementation. 91 // RendererClient implementation.
92 void OnError(PipelineStatus status) final; 92 void OnError(PipelineStatus status) final;
93 void OnEnded() final; 93 void OnEnded() final;
94 void OnStatisticsUpdate(const PipelineStatistics& stats) final; 94 void OnStatisticsUpdate(const PipelineStatistics& stats) final;
95 void OnBufferingStateChange(BufferingState state) final; 95 void OnBufferingStateChange(BufferingState state) final;
96 void OnWaitingForDecryptionKey() final; 96 void OnWaitingForDecryptionKey() final;
97 void OnVideoNaturalSizeChange(const gfx::Size& size) final; 97 void OnVideoNaturalSizeChange(const gfx::Size& size) final;
98 void OnVideoOpacityChange(bool opaque) final; 98 void OnVideoOpacityChange(bool opaque) final;
99 void OnDurationChange(base::TimeDelta duration) final; 99 void OnDurationChange(base::TimeDelta duration) final;
100 100
101 // Called when the DemuxerStreamProviderShim is ready to go (has a config, 101 // Called when the MediaResourceShim is ready to go (has a config,
102 // pipe handle, etc) and can be handed off to a renderer for use. 102 // pipe handle, etc) and can be handed off to a renderer for use.
103 void OnStreamReady(const base::Callback<void(bool)>& callback); 103 void OnStreamReady(const base::Callback<void(bool)>& callback);
104 104
105 // Called when |audio_renderer_| initialization has completed. 105 // Called when |audio_renderer_| initialization has completed.
106 void OnRendererInitializeDone(const base::Callback<void(bool)>& callback, 106 void OnRendererInitializeDone(const base::Callback<void(bool)>& callback,
107 PipelineStatus status); 107 PipelineStatus status);
108 108
109 // Periodically polls the media time from the renderer and notifies the client 109 // Periodically polls the media time from the renderer and notifies the client
110 // if the media time has changed since the last update. 110 // if the media time has changed since the last update.
111 // If |force| is true, the client is notified even if the time is unchanged. 111 // If |force| is true, the client is notified even if the time is unchanged.
112 // If |range| is true, an interpolation time range is reported. 112 // If |range| is true, an interpolation time range is reported.
113 void UpdateMediaTime(bool force); 113 void UpdateMediaTime(bool force);
114 void CancelPeriodicMediaTimeUpdates(); 114 void CancelPeriodicMediaTimeUpdates();
115 void SchedulePeriodicMediaTimeUpdates(); 115 void SchedulePeriodicMediaTimeUpdates();
116 116
117 // Callback executed once Flush() completes. 117 // Callback executed once Flush() completes.
118 void OnFlushCompleted(const FlushCallback& callback); 118 void OnFlushCompleted(const FlushCallback& callback);
119 119
120 // Callback executed once SetCdm() completes. 120 // Callback executed once SetCdm() completes.
121 void OnCdmAttached(scoped_refptr<ContentDecryptionModule> cdm, 121 void OnCdmAttached(scoped_refptr<ContentDecryptionModule> cdm,
122 const base::Callback<void(bool)>& callback, 122 const base::Callback<void(bool)>& callback,
123 bool success); 123 bool success);
124 124
125 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; 125 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_;
126 126
127 State state_; 127 State state_;
128 double playback_rate_; 128 double playback_rate_;
129 129
130 std::unique_ptr<DemuxerStreamProvider> stream_provider_; 130 std::unique_ptr<MediaResource> media_resource_;
131 131
132 base::RepeatingTimer time_update_timer_; 132 base::RepeatingTimer time_update_timer_;
133 base::TimeDelta last_media_time_; 133 base::TimeDelta last_media_time_;
134 134
135 mojom::RendererClientAssociatedPtr client_; 135 mojom::RendererClientAssociatedPtr client_;
136 136
137 // Hold a reference to the CDM set on the |renderer_| so that the CDM won't be 137 // Hold a reference to the CDM set on the |renderer_| so that the CDM won't be
138 // destructed while the |renderer_| is still using it. 138 // destructed while the |renderer_| is still using it.
139 scoped_refptr<ContentDecryptionModule> cdm_; 139 scoped_refptr<ContentDecryptionModule> cdm_;
140 140
141 // Audio and Video sinks. 141 // Audio and Video sinks.
142 // May be null if underlying |renderer_| does not use them. 142 // May be null if underlying |renderer_| does not use them.
143 scoped_refptr<AudioRendererSink> audio_sink_; 143 scoped_refptr<AudioRendererSink> audio_sink_;
144 std::unique_ptr<VideoRendererSink> video_sink_; 144 std::unique_ptr<VideoRendererSink> video_sink_;
145 145
146 // Note: Destroy |renderer_| first to avoid access violation into other 146 // Note: Destroy |renderer_| first to avoid access violation into other
147 // members, e.g. |stream_provider_|, |cdm_|, |audio_sink_|, and 147 // members, e.g. |media_resource_|, |cdm_|, |audio_sink_|, and
148 // |video_sink_|. 148 // |video_sink_|.
149 // Must use "media::" because "Renderer" is ambiguous. 149 // Must use "media::" because "Renderer" is ambiguous.
150 std::unique_ptr<media::Renderer> renderer_; 150 std::unique_ptr<media::Renderer> renderer_;
151 151
152 // Registers a new request in the ScopedSurfaceRequestManager. 152 // Registers a new request in the ScopedSurfaceRequestManager.
153 // Returns the token to be used to fulfill the request. 153 // Returns the token to be used to fulfill the request.
154 InitiateSurfaceRequestCB initiate_surface_request_cb_; 154 InitiateSurfaceRequestCB initiate_surface_request_cb_;
155 155
156 // Callback to be called when an invalid or unexpected message is received. 156 // Callback to be called when an invalid or unexpected message is received.
157 // TODO(tguilbert): Revisit how to do InitiateScopedSurfaceRequest() so that 157 // TODO(tguilbert): Revisit how to do InitiateScopedSurfaceRequest() so that
158 // we can eliminate this callback. See http://crbug.com/669606 158 // we can eliminate this callback. See http://crbug.com/669606
159 base::Closure bad_message_cb_; 159 base::Closure bad_message_cb_;
160 160
161 base::WeakPtr<MojoRendererService> weak_this_; 161 base::WeakPtr<MojoRendererService> weak_this_;
162 base::WeakPtrFactory<MojoRendererService> weak_factory_; 162 base::WeakPtrFactory<MojoRendererService> weak_factory_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(MojoRendererService); 164 DISALLOW_COPY_AND_ASSIGN(MojoRendererService);
165 }; 165 };
166 166
167 } // namespace media 167 } // namespace media
168 168
169 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ 169 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698