Don't send a SHChangeNotify for creating an app icon when creating a shortcut.
[chromium-blink-merge.git] / media / mojo / services / mojo_renderer_service.h
blob2046e9d8d19812a5608f4bc4d7f237f76a60bcc8
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/timer/timer.h"
14 #include "media/base/audio_decoder_config.h"
15 #include "media/base/buffering_state.h"
16 #include "media/base/media_export.h"
17 #include "media/base/pipeline_status.h"
18 #include "media/mojo/interfaces/media_renderer.mojom.h"
19 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
21 namespace mojo {
22 class ApplicationConnection;
25 namespace media {
27 class AudioRendererSink;
28 class DemuxerStreamProviderShim;
29 class Renderer;
31 // A mojo::MediaRenderer implementation that uses media::AudioRenderer to
32 // decode and render audio to a sink obtained from the ApplicationConnection.
33 class MEDIA_EXPORT MojoRendererService
34 : NON_EXPORTED_BASE(public mojo::InterfaceImpl<mojo::MediaRenderer>) {
35 public:
36 MojoRendererService();
37 ~MojoRendererService() override;
39 // mojo::MediaRenderer implementation.
40 void Initialize(mojo::MediaRendererClientPtr client,
41 mojo::DemuxerStreamPtr audio,
42 mojo::DemuxerStreamPtr video,
43 const mojo::Closure& callback) override;
44 void Flush(const mojo::Closure& callback) override;
45 void StartPlayingFrom(int64_t time_delta_usec) override;
46 void SetPlaybackRate(float playback_rate) override;
47 void SetVolume(float volume) override;
49 private:
50 enum State {
51 STATE_UNINITIALIZED,
52 STATE_INITIALIZING,
53 STATE_FLUSHING,
54 STATE_PLAYING,
55 STATE_ERROR
58 // Called when the DemuxerStreamProviderShim is ready to go (has a config,
59 // pipe handle, etc) and can be handed off to a renderer for use.
60 void OnStreamReady(const mojo::Closure& callback);
62 // Called when |audio_renderer_| initialization has completed.
63 void OnRendererInitializeDone(const mojo::Closure& callback,
64 PipelineStatus status);
66 // Callback executed by filters to update statistics.
67 void OnUpdateStatistics(const PipelineStatistics& stats);
69 // Periodically polls the media time from the renderer and notifies the client
70 // if the media time has changed since the last update. If |force| is true,
71 // the client is notified even if the time is unchanged.
72 void UpdateMediaTime(bool force);
73 void CancelPeriodicMediaTimeUpdates();
74 void SchedulePeriodicMediaTimeUpdates();
76 // Callback executed by audio renderer when buffering state changes.
77 // TODO(tim): Need old and new.
78 void OnBufferingStateChanged(BufferingState new_buffering_state);
80 // Callback executed when a renderer has ended.
81 void OnRendererEnded();
83 // Callback executed when a runtime error happens.
84 void OnError(PipelineStatus error);
86 // Callback executed once Flush() completes.
87 void OnFlushCompleted(const mojo::Closure& callback);
89 State state_;
91 scoped_refptr<AudioRendererSink> audio_renderer_sink_;
92 scoped_ptr<Renderer> renderer_;
93 scoped_ptr<DemuxerStreamProviderShim> stream_provider_;
95 base::RepeatingTimer<MojoRendererService> time_update_timer_;
96 uint64_t last_media_time_usec_;
98 mojo::MediaRendererClientPtr client_;
100 base::WeakPtr<MojoRendererService> weak_this_;
101 base::WeakPtrFactory<MojoRendererService> weak_factory_;
103 DISALLOW_COPY_AND_ASSIGN(MojoRendererService);
106 } // namespace media
108 #endif // MEDIA_MOJO_SERVICES_MOJO_RENDERER_SERVICE_H_