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

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

Issue 2643743002: Mojify demuxers and allow running {Chunk/FFmpeg}Demuxer in a Utility Process (Closed)
Patch Set: Rebase and make sure to unbind mojom::DemuxerPtr on the bound thread during termination Created 3 years, 10 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
« no previous file with comments | « media/mojo/services/mojo_media_client.cc ('k') | media/mojo/services/mojo_renderer_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 13 matching lines...) Expand all
24 #include "media/mojo/interfaces/video_renderer_sink.mojom.h" 24 #include "media/mojo/interfaces/video_renderer_sink.mojom.h"
25 #include "media/mojo/services/media_mojo_export.h" 25 #include "media/mojo/services/media_mojo_export.h"
26 #include "mojo/public/cpp/bindings/strong_binding.h" 26 #include "mojo/public/cpp/bindings/strong_binding.h"
27 27
28 namespace media { 28 namespace media {
29 29
30 class AudioRendererSink; 30 class AudioRendererSink;
31 class MediaResourceShim; 31 class MediaResourceShim;
32 class ContentDecryptionModule; 32 class ContentDecryptionModule;
33 class MojoCdmServiceContext; 33 class MojoCdmServiceContext;
34 class MojoDemuxerServiceContext;
34 class Renderer; 35 class Renderer;
36 class MediaUrlDemuxer;
35 class VideoRendererSink; 37 class VideoRendererSink;
36 38
37 // A mojom::Renderer implementation that use a media::Renderer to render 39 // A mojom::Renderer implementation that use a media::Renderer to render
38 // media streams. 40 // media streams.
39 class MEDIA_MOJO_EXPORT MojoRendererService 41 class MEDIA_MOJO_EXPORT MojoRendererService
40 : NON_EXPORTED_BASE(public mojom::Renderer), 42 : NON_EXPORTED_BASE(public mojom::Renderer),
41 public RendererClient { 43 public RendererClient {
42 public: 44 public:
43 using InitiateSurfaceRequestCB = base::Callback<base::UnguessableToken()>; 45 using InitiateSurfaceRequestCB = base::Callback<base::UnguessableToken()>;
44 46
45 // Helper function to bind MojoRendererService with a StrongBinding, 47 // Helper function to bind MojoRendererService with a StrongBinding,
46 // which is safely accessible via the returned StrongBindingPtr. 48 // which is safely accessible via the returned StrongBindingPtr.
47 static mojo::StrongBindingPtr<mojom::Renderer> Create( 49 static mojo::StrongBindingPtr<mojom::Renderer> Create(
50 base::WeakPtr<MojoDemuxerServiceContext> mojo_demuxer_service_context,
48 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, 51 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
49 scoped_refptr<AudioRendererSink> audio_sink, 52 scoped_refptr<AudioRendererSink> audio_sink,
50 std::unique_ptr<VideoRendererSink> video_sink, 53 std::unique_ptr<VideoRendererSink> video_sink,
51 std::unique_ptr<media::Renderer> renderer, 54 std::unique_ptr<media::Renderer> renderer,
52 InitiateSurfaceRequestCB initiate_surface_request_cb, 55 InitiateSurfaceRequestCB initiate_surface_request_cb,
53 mojo::InterfaceRequest<mojom::Renderer> request); 56 mojo::InterfaceRequest<mojom::Renderer> request);
54 57
55 // |mojo_cdm_service_context| can be used to find the CDM to support 58 // |mojo_cdm_service_context| can be used to find the CDM to support
56 // encrypted media. If null, encrypted media is not supported. 59 // encrypted media. If null, encrypted media is not supported.
57 MojoRendererService( 60 MojoRendererService(
61 base::WeakPtr<MojoDemuxerServiceContext> mojo_demuxer_service_context,
58 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, 62 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
59 scoped_refptr<AudioRendererSink> audio_sink, 63 scoped_refptr<AudioRendererSink> audio_sink,
60 std::unique_ptr<VideoRendererSink> video_sink, 64 std::unique_ptr<VideoRendererSink> video_sink,
61 std::unique_ptr<media::Renderer> renderer, 65 std::unique_ptr<media::Renderer> renderer,
62 InitiateSurfaceRequestCB initiate_surface_request_cb); 66 InitiateSurfaceRequestCB initiate_surface_request_cb);
63 67
64 ~MojoRendererService() final; 68 ~MojoRendererService() final;
65 69
66 // mojom::Renderer implementation. 70 // mojom::Renderer implementation.
67 void Initialize(mojom::RendererClientAssociatedPtrInfo client, 71 void Initialize(mojom::RendererClientAssociatedPtrInfo client,
72 int32_t demuxer_id,
68 base::Optional<std::vector<mojom::DemuxerStreamPtr>> streams, 73 base::Optional<std::vector<mojom::DemuxerStreamPtr>> streams,
69 mojom::AudioRendererSinkPtr audio_renderer_sink_ptr, 74 mojom::AudioRendererSinkPtr audio_renderer_sink_ptr,
70 mojom::VideoRendererSinkPtr video_renderer_sink_ptr, 75 mojom::VideoRendererSinkPtr video_renderer_sink_ptr,
71 const base::Optional<GURL>& media_url, 76 const base::Optional<GURL>& media_url,
72 const base::Optional<GURL>& first_party_for_cookies, 77 const base::Optional<GURL>& first_party_for_cookies,
73 const InitializeCallback& callback) final; 78 const InitializeCallback& callback) final;
74 void Flush(const FlushCallback& callback) final; 79 void Flush(const FlushCallback& callback) final;
75 void StartPlayingFrom(base::TimeDelta time_delta) final; 80 void StartPlayingFrom(base::TimeDelta time_delta) final;
76 void SetPlaybackRate(double playback_rate) final; 81 void SetPlaybackRate(double playback_rate) final;
77 void SetVolume(float volume) final; 82 void SetVolume(float volume) final;
(...skipping 19 matching lines...) Expand all
97 void OnEnded() final; 102 void OnEnded() final;
98 void OnStatisticsUpdate(const PipelineStatistics& stats) final; 103 void OnStatisticsUpdate(const PipelineStatistics& stats) final;
99 void OnBufferingStateChange(BufferingState state) final; 104 void OnBufferingStateChange(BufferingState state) final;
100 void OnWaitingForDecryptionKey() final; 105 void OnWaitingForDecryptionKey() final;
101 void OnVideoNaturalSizeChange(const gfx::Size& size) final; 106 void OnVideoNaturalSizeChange(const gfx::Size& size) final;
102 void OnVideoOpacityChange(bool opaque) final; 107 void OnVideoOpacityChange(bool opaque) final;
103 void OnDurationChange(base::TimeDelta duration) final; 108 void OnDurationChange(base::TimeDelta duration) final;
104 109
105 // Called when the MediaResourceShim is ready to go (has a config, 110 // Called when the MediaResourceShim is ready to go (has a config,
106 // pipe handle, etc) and can be handed off to a renderer for use. 111 // pipe handle, etc) and can be handed off to a renderer for use.
107 void OnStreamReady(const base::Callback<void(bool)>& callback); 112 void OnStreamReady(const InitializeCallback& callback);
108 113
109 // Called when |audio_renderer_| initialization has completed. 114 // Called when |audio_renderer_| initialization has completed.
110 void OnRendererInitializeDone(const base::Callback<void(bool)>& callback, 115 void OnRendererInitializeDone(const InitializeCallback& callback,
111 PipelineStatus status); 116 PipelineStatus status);
112 117
113 // Periodically polls the media time from the renderer and notifies the client 118 // Periodically polls the media time from the renderer and notifies the client
114 // if the media time has changed since the last update. 119 // if the media time has changed since the last update.
115 // If |force| is true, the client is notified even if the time is unchanged. 120 // If |force| is true, the client is notified even if the time is unchanged.
116 // If |range| is true, an interpolation time range is reported. 121 // If |range| is true, an interpolation time range is reported.
117 void UpdateMediaTime(bool force); 122 void UpdateMediaTime(bool force);
118 void CancelPeriodicMediaTimeUpdates(); 123 void CancelPeriodicMediaTimeUpdates();
119 void SchedulePeriodicMediaTimeUpdates(); 124 void SchedulePeriodicMediaTimeUpdates();
120 125
121 // Callback executed once Flush() completes. 126 // Callback executed once Flush() completes.
122 void OnFlushCompleted(const FlushCallback& callback); 127 void OnFlushCompleted(const FlushCallback& callback);
123 128
124 // Callback executed once SetCdm() completes. 129 // Callback executed once SetCdm() completes.
125 void OnCdmAttached(scoped_refptr<ContentDecryptionModule> cdm, 130 void OnCdmAttached(scoped_refptr<ContentDecryptionModule> cdm,
126 const base::Callback<void(bool)>& callback, 131 const base::Callback<void(bool)>& callback,
127 bool success); 132 bool success);
128 133
134 void OnDemuxerInitialized(const InitializeCallback& callback,
135 PipelineStatus status);
136 void InitializeRenderer(const InitializeCallback& callback);
137
138 base::WeakPtr<MojoDemuxerServiceContext> mojo_demuxer_service_context_;
129 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; 139 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_;
130 140
131 State state_; 141 State state_;
132 double playback_rate_; 142 double playback_rate_;
133 143
134 std::unique_ptr<MediaResource> media_resource_; 144 std::unique_ptr<MediaResourceShim> media_resource_shim_;
145 std::unique_ptr<MediaUrlDemuxer> media_url_demuxer_;
146 MediaResource* media_resource_;
135 147
136 base::RepeatingTimer time_update_timer_; 148 base::RepeatingTimer time_update_timer_;
137 base::TimeDelta last_media_time_; 149 base::TimeDelta last_media_time_;
138 150
139 mojom::RendererClientAssociatedPtr client_; 151 mojom::RendererClientAssociatedPtr client_;
140 152
141 // Hold a reference to the CDM set on the |renderer_| so that the CDM won't be 153 // Hold a reference to the CDM set on the |renderer_| so that the CDM won't be
142 // destructed while the |renderer_| is still using it. 154 // destructed while the |renderer_| is still using it.
143 scoped_refptr<ContentDecryptionModule> cdm_; 155 scoped_refptr<ContentDecryptionModule> cdm_;
144 156
(...skipping 19 matching lines...) Expand all
164 176
165 base::WeakPtr<MojoRendererService> weak_this_; 177 base::WeakPtr<MojoRendererService> weak_this_;
166 base::WeakPtrFactory<MojoRendererService> weak_factory_; 178 base::WeakPtrFactory<MojoRendererService> weak_factory_;
167 179
168 DISALLOW_COPY_AND_ASSIGN(MojoRendererService); 180 DISALLOW_COPY_AND_ASSIGN(MojoRendererService);
169 }; 181 };
170 182
171 } // namespace media 183 } // namespace media
172 184
173 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ 185 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_media_client.cc ('k') | media/mojo/services/mojo_renderer_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698