Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / chromecast / browser / media / media_pipeline_host.h
blob18502e4ff4308a20acf9241d50534b7882fe60ae
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 CHROMECAST_BROWSER_MEDIA_MEDIA_PIPELINE_HOST_H_
6 #define CHROMECAST_BROWSER_MEDIA_MEDIA_PIPELINE_HOST_H_
8 #include <map>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/threading/thread_checker.h"
16 #include "base/time/time.h"
17 #include "chromecast/common/media/cma_ipc_common.h"
18 #include "chromecast/media/cma/backend/media_pipeline_device.h"
19 #include "chromecast/media/cma/pipeline/load_type.h"
20 #include "media/base/pipeline_status.h"
22 namespace base {
23 class SharedMemory;
24 class SingleThreadTaskRunner;
27 namespace media {
28 class AudioDecoderConfig;
29 class VideoDecoderConfig;
32 namespace chromecast {
33 namespace media {
34 struct AvPipelineClient;
35 class BrowserCdmCast;
36 struct MediaPipelineClient;
37 class MediaPipelineImpl;
38 struct VideoPipelineClient;
40 class MediaPipelineHost {
41 public:
42 MediaPipelineHost();
43 ~MediaPipelineHost();
45 void Initialize(
46 LoadType load_type,
47 const MediaPipelineClient& client,
48 const media::CreatePipelineDeviceCB& create_pipeline_device_cb);
50 void SetAvPipe(TrackId track_id,
51 scoped_ptr<base::SharedMemory> shared_mem,
52 const base::Closure& pipe_read_activity_cb,
53 const base::Closure& av_pipe_set_cb);
54 void AudioInitialize(TrackId track_id,
55 const AvPipelineClient& client,
56 const ::media::AudioDecoderConfig& config,
57 const ::media::PipelineStatusCB& status_cb);
58 void VideoInitialize(TrackId track_id,
59 const VideoPipelineClient& client,
60 const std::vector<::media::VideoDecoderConfig>& configs,
61 const ::media::PipelineStatusCB& status_cb);
62 void StartPlayingFrom(base::TimeDelta time);
63 void Flush(const ::media::PipelineStatusCB& status_cb);
64 void Stop();
66 void SetPlaybackRate(double playback_rate);
67 void SetVolume(TrackId track_id, float playback_rate);
68 void SetCdm(BrowserCdmCast* cdm);
70 void NotifyPipeWrite(TrackId track_id);
72 private:
73 base::ThreadChecker thread_checker_;
75 scoped_ptr<MediaPipelineImpl> media_pipeline_;
77 // The shared memory for a track id must be valid until Stop is invoked on
78 // that track id.
79 struct MediaTrackHost;
80 typedef std::map<TrackId, MediaTrackHost*> MediaTrackMap;
81 MediaTrackMap media_track_map_;
83 DISALLOW_COPY_AND_ASSIGN(MediaPipelineHost);
86 } // namespace media
87 } // namespace chromecast
89 #endif // CHROMECAST_BROWSER_MEDIA_MEDIA_PIPELINE_HOST_H_