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

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

Issue 1200323003: media: Quit MojoMediaApplication when no service is bound. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 5 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 "base/callback.h" 8 #include "base/callback.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "media/base/audio_decoder_config.h" 14 #include "media/base/audio_decoder_config.h"
15 #include "media/base/buffering_state.h" 15 #include "media/base/buffering_state.h"
16 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
17 #include "media/base/pipeline_status.h" 17 #include "media/base/pipeline_status.h"
18 #include "media/mojo/interfaces/media_renderer.mojom.h" 18 #include "media/mojo/interfaces/media_renderer.mojom.h"
19 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" 19 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
20 20
21 namespace mojo { 21 namespace mojo {
22 class ApplicationConnection; 22 class ApplicationConnection;
23 class AppRefCount;
23 } 24 }
24 25
25 namespace media { 26 namespace media {
26 27
27 class AudioRendererSink; 28 class AudioRendererSink;
28 class DemuxerStreamProviderShim; 29 class DemuxerStreamProviderShim;
29 class CdmContextProvider; 30 class CdmContextProvider;
30 class Renderer; 31 class Renderer;
31 class VideoRendererSink; 32 class VideoRendererSink;
32 33
33 // A mojo::MediaRenderer implementation that uses media::AudioRenderer to 34 // A mojo::MediaRenderer implementation that uses media::AudioRenderer to
34 // decode and render audio to a sink obtained from the ApplicationConnection. 35 // decode and render audio to a sink obtained from the ApplicationConnection.
35 class MEDIA_EXPORT MojoRendererService 36 class MEDIA_EXPORT MojoRendererService
36 : NON_EXPORTED_BASE(mojo::MediaRenderer) { 37 : NON_EXPORTED_BASE(mojo::MediaRenderer) {
37 public: 38 public:
38 // |cdm_context_provider| can be used to find the CdmContext to support 39 // |cdm_context_provider| can be used to find the CdmContext to support
39 // encrypted media. If null, encrypted media is not supported. 40 // encrypted media. If null, encrypted media is not supported.
40 MojoRendererService(CdmContextProvider* cdm_context_provider, 41 MojoRendererService(mojo::InterfaceRequest<mojo::MediaRenderer> request,
41 mojo::InterfaceRequest<mojo::MediaRenderer> request); 42 CdmContextProvider* cdm_context_provider,
43 scoped_ptr<mojo::AppRefCount> parent_app_refcount);
42 ~MojoRendererService() final; 44 ~MojoRendererService() final;
43 45
44 // mojo::MediaRenderer implementation. 46 // mojo::MediaRenderer implementation.
45 void Initialize(mojo::MediaRendererClientPtr client, 47 void Initialize(mojo::MediaRendererClientPtr client,
46 mojo::DemuxerStreamPtr audio, 48 mojo::DemuxerStreamPtr audio,
47 mojo::DemuxerStreamPtr video, 49 mojo::DemuxerStreamPtr video,
48 const mojo::Closure& callback) final; 50 const mojo::Closure& callback) final;
49 void Flush(const mojo::Closure& callback) final; 51 void Flush(const mojo::Closure& callback) final;
50 void StartPlayingFrom(int64_t time_delta_usec) final; 52 void StartPlayingFrom(int64_t time_delta_usec) final;
51 void SetPlaybackRate(double playback_rate) final; 53 void SetPlaybackRate(double playback_rate) final;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // Callback executed when a runtime error happens. 91 // Callback executed when a runtime error happens.
90 void OnError(PipelineStatus error); 92 void OnError(PipelineStatus error);
91 93
92 // Callback executed once Flush() completes. 94 // Callback executed once Flush() completes.
93 void OnFlushCompleted(const mojo::Closure& callback); 95 void OnFlushCompleted(const mojo::Closure& callback);
94 96
95 // Callback executed once SetCdm() completes. 97 // Callback executed once SetCdm() completes.
96 void OnCdmAttached(const mojo::Callback<void(bool)>& callback, bool success); 98 void OnCdmAttached(const mojo::Callback<void(bool)>& callback, bool success);
97 99
98 mojo::StrongBinding<mojo::MediaRenderer> binding_; 100 mojo::StrongBinding<mojo::MediaRenderer> binding_;
99
100 CdmContextProvider* cdm_context_provider_; 101 CdmContextProvider* cdm_context_provider_;
102 scoped_ptr<mojo::AppRefCount> parent_app_refcount_;
101 103
102 State state_; 104 State state_;
103 105
104 // Note: |renderer_| should be destructed before these objects to avoid access 106 // Note: |renderer_| should be destructed before these objects to avoid access
105 // violation. 107 // violation.
106 scoped_ptr<DemuxerStreamProviderShim> stream_provider_; 108 scoped_ptr<DemuxerStreamProviderShim> stream_provider_;
107 scoped_refptr<AudioRendererSink> audio_renderer_sink_; 109 scoped_refptr<AudioRendererSink> audio_renderer_sink_;
108 scoped_ptr<VideoRendererSink> video_renderer_sink_; 110 scoped_ptr<VideoRendererSink> video_renderer_sink_;
109 111
110 scoped_ptr<Renderer> renderer_; 112 scoped_ptr<Renderer> renderer_;
111 113
112 base::RepeatingTimer<MojoRendererService> time_update_timer_; 114 base::RepeatingTimer<MojoRendererService> time_update_timer_;
113 uint64_t last_media_time_usec_; 115 uint64_t last_media_time_usec_;
114 116
115 mojo::MediaRendererClientPtr client_; 117 mojo::MediaRendererClientPtr client_;
116 118
117 base::WeakPtr<MojoRendererService> weak_this_; 119 base::WeakPtr<MojoRendererService> weak_this_;
118 base::WeakPtrFactory<MojoRendererService> weak_factory_; 120 base::WeakPtrFactory<MojoRendererService> weak_factory_;
119 121
120 DISALLOW_COPY_AND_ASSIGN(MojoRendererService); 122 DISALLOW_COPY_AND_ASSIGN(MojoRendererService);
121 }; 123 };
122 124
123 } // namespace media 125 } // namespace media
124 126
125 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_ 127 #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