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_
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"
24 class SingleThreadTaskRunner
;
28 class AudioDecoderConfig
;
29 class VideoDecoderConfig
;
32 namespace chromecast
{
34 struct AvPipelineClient
;
36 struct MediaPipelineClient
;
37 class MediaPipelineImpl
;
38 struct VideoPipelineClient
;
40 class MediaPipelineHost
{
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
);
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
);
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
79 struct MediaTrackHost
;
80 typedef std::map
<TrackId
, MediaTrackHost
*> MediaTrackMap
;
81 MediaTrackMap media_track_map_
;
83 DISALLOW_COPY_AND_ASSIGN(MediaPipelineHost
);
87 } // namespace chromecast
89 #endif // CHROMECAST_BROWSER_MEDIA_MEDIA_PIPELINE_HOST_H_