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

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

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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 "media/base/buffering_state.h" 17 #include "media/base/buffering_state.h"
18 #include "media/base/demuxer_stream_provider.h" 18 #include "media/base/demuxer_stream_provider.h"
19 #include "media/base/pipeline_status.h" 19 #include "media/base/pipeline_status.h"
20 #include "media/base/renderer_client.h" 20 #include "media/base/renderer_client.h"
21 #include "media/mojo/interfaces/renderer.mojom.h" 21 #include "media/mojo/interfaces/renderer.mojom.h"
22 #include "media/mojo/services/media_mojo_export.h" 22 #include "media/mojo/services/media_mojo_export.h"
23 #include "mojo/public/cpp/bindings/strong_binding.h"
24 23
25 namespace media { 24 namespace media {
26 25
27 class AudioRendererSink; 26 class AudioRendererSink;
28 class DemuxerStreamProviderShim; 27 class DemuxerStreamProviderShim;
29 class MediaKeys; 28 class MediaKeys;
30 class MojoCdmServiceContext; 29 class MojoCdmServiceContext;
31 class Renderer; 30 class Renderer;
32 class VideoRendererSink; 31 class VideoRendererSink;
33 32
34 // A mojom::Renderer implementation that use a media::Renderer to render 33 // A mojom::Renderer implementation that use a media::Renderer to render
35 // media streams. 34 // media streams.
36 class MEDIA_MOJO_EXPORT MojoRendererService 35 class MEDIA_MOJO_EXPORT MojoRendererService
37 : NON_EXPORTED_BASE(public mojom::Renderer), 36 : NON_EXPORTED_BASE(public mojom::Renderer),
38 public RendererClient { 37 public RendererClient {
39 public: 38 public:
40 // |mojo_cdm_service_context| can be used to find the CDM to support 39 // |mojo_cdm_service_context| can be used to find the CDM to support
41 // encrypted media. If null, encrypted media is not supported. 40 // encrypted media. If null, encrypted media is not supported.
42 MojoRendererService( 41 MojoRendererService(
43 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, 42 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
44 scoped_refptr<AudioRendererSink> audio_sink, 43 scoped_refptr<AudioRendererSink> audio_sink,
45 std::unique_ptr<VideoRendererSink> video_sink, 44 std::unique_ptr<VideoRendererSink> video_sink,
46 std::unique_ptr<media::Renderer> renderer, 45 std::unique_ptr<media::Renderer> renderer);
47 mojo::InterfaceRequest<mojom::Renderer> request);
48 ~MojoRendererService() final; 46 ~MojoRendererService() final;
49 47
50 // mojom::Renderer implementation. 48 // mojom::Renderer implementation.
51 void Initialize(mojom::RendererClientPtr client, 49 void Initialize(mojom::RendererClientPtr client,
52 mojom::DemuxerStreamPtr audio, 50 mojom::DemuxerStreamPtr audio,
53 mojom::DemuxerStreamPtr video, 51 mojom::DemuxerStreamPtr video,
54 const base::Optional<GURL>& url, 52 const base::Optional<GURL>& url,
55 const InitializeCallback& callback) final; 53 const InitializeCallback& callback) final;
56 void Flush(const FlushCallback& callback) final; 54 void Flush(const FlushCallback& callback) final;
57 void StartPlayingFrom(base::TimeDelta time_delta) final; 55 void StartPlayingFrom(base::TimeDelta time_delta) final;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void SchedulePeriodicMediaTimeUpdates(); 93 void SchedulePeriodicMediaTimeUpdates();
96 94
97 // Callback executed once Flush() completes. 95 // Callback executed once Flush() completes.
98 void OnFlushCompleted(const FlushCallback& callback); 96 void OnFlushCompleted(const FlushCallback& callback);
99 97
100 // Callback executed once SetCdm() completes. 98 // Callback executed once SetCdm() completes.
101 void OnCdmAttached(scoped_refptr<MediaKeys> cdm, 99 void OnCdmAttached(scoped_refptr<MediaKeys> cdm,
102 const base::Callback<void(bool)>& callback, 100 const base::Callback<void(bool)>& callback,
103 bool success); 101 bool success);
104 102
105 mojo::StrongBinding<mojom::Renderer> binding_;
106
107 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; 103 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_;
108 104
109 State state_; 105 State state_;
110 double playback_rate_; 106 double playback_rate_;
111 107
112 std::unique_ptr<DemuxerStreamProvider> stream_provider_; 108 std::unique_ptr<DemuxerStreamProvider> stream_provider_;
113 109
114 base::RepeatingTimer time_update_timer_; 110 base::RepeatingTimer time_update_timer_;
115 base::TimeDelta last_media_time_; 111 base::TimeDelta last_media_time_;
116 112
(...skipping 16 matching lines...) Expand all
133 129
134 base::WeakPtr<MojoRendererService> weak_this_; 130 base::WeakPtr<MojoRendererService> weak_this_;
135 base::WeakPtrFactory<MojoRendererService> weak_factory_; 131 base::WeakPtrFactory<MojoRendererService> weak_factory_;
136 132
137 DISALLOW_COPY_AND_ASSIGN(MojoRendererService); 133 DISALLOW_COPY_AND_ASSIGN(MojoRendererService);
138 }; 134 };
139 135
140 } // namespace media 136 } // namespace media
141 137
142 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ 138 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_media_application.cc ('k') | media/mojo/services/mojo_renderer_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698