Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromecast / media / base / switching_media_renderer.h
blobc32b1d438d5389918ece987f439e84ba18982da3
1 // Copyright 2015 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 CHROMECAST_MEDIA_BASE_SWITCHING_MEDIA_RENDERER_H_
6 #define CHROMECAST_MEDIA_BASE_SWITCHING_MEDIA_RENDERER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/renderer.h"
12 namespace media {
13 class DemuxerStreamProvider;
16 namespace chromecast {
17 namespace media {
19 // Chromecast's custom media renderer which is capable of selecting an
20 // appropriate media renderer at runtime depending on the content.
21 // We'll look at media types of media streams present in DemuxerStreamProvider
22 // and will use either CMA-based renderer (for media types that are supported by
23 // our hardware decoder - H264 and VP8 video, AAC and Vorbis audio) or the
24 // default Chrome media renderer (this will allow us to support audio codecs
25 // like FLAC and Opus, which are decoded in software).
26 class SwitchingMediaRenderer : public ::media::Renderer {
27 public:
28 SwitchingMediaRenderer(
29 scoped_ptr<::media::Renderer> default_renderer,
30 scoped_ptr<::media::Renderer> cma_renderer);
31 ~SwitchingMediaRenderer() override;
33 // ::media::Renderer implementation:
34 void Initialize(
35 ::media::DemuxerStreamProvider* demuxer_stream_provider,
36 const ::media::PipelineStatusCB& init_cb,
37 const ::media::StatisticsCB& statistics_cb,
38 const ::media::BufferingStateCB& buffering_state_cb,
39 const base::Closure& ended_cb,
40 const ::media::PipelineStatusCB& error_cb,
41 const base::Closure& waiting_for_decryption_key_cb) override;
42 void SetCdm(::media::CdmContext* cdm_context,
43 const ::media::CdmAttachedCB& cdm_attached_cb) override;
44 void Flush(const base::Closure& flush_cb) override;
45 void StartPlayingFrom(base::TimeDelta time) override;
46 void SetPlaybackRate(double playback_rate) override;
47 void SetVolume(float volume) override;
48 base::TimeDelta GetMediaTime() override;
49 bool HasAudio() override;
50 bool HasVideo() override;
52 private:
53 // Returns the pointer to the actual renderer being used
54 ::media::Renderer* GetRenderer() const;
56 ::media::DemuxerStreamProvider* demuxer_stream_provider_;
57 scoped_ptr<::media::Renderer> default_renderer_;
58 scoped_ptr<::media::Renderer> cma_renderer_;
60 DISALLOW_COPY_AND_ASSIGN(SwitchingMediaRenderer);
63 } // namespace media
64 } // namespace chromecast
66 #endif // CHROMECAST_MEDIA_BASE_SWITCHING_MEDIA_RENDERER_H_