Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromecast / renderer / media / media_channel_proxy.h
blobc7c46965bf66b68109e66784a66d80450b9c7eca
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_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_
6 #define CHROMECAST_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chromecast/media/cma/pipeline/load_type.h"
12 #include "chromecast/renderer/media/cma_message_filter_proxy.h"
14 namespace IPC {
15 class Message;
18 namespace chromecast {
19 namespace media {
21 // MediaChannelProxy - Manage the lifetime of a CMA ipc channel.
22 // Must be invoked from the IO thread of the renderer process.
23 class MediaChannelProxy
24 : public base::RefCountedThreadSafe<MediaChannelProxy> {
25 public:
26 MediaChannelProxy();
28 // Opens a CMA ipc channel.
29 void Open(LoadType load_type);
31 // Closes the ipc channel.
32 void Close();
34 // Returns the ID of the CMA ipc channel.
35 // Returns 0 or negative ID if no channel has been opened.
36 int GetId() { return id_; }
38 // Manages delegates.
39 bool SetMediaDelegate(
40 const CmaMessageFilterProxy::MediaDelegate& media_delegate);
41 bool SetAudioDelegate(
42 const CmaMessageFilterProxy::AudioDelegate& audio_delegate);
43 bool SetVideoDelegate(
44 const CmaMessageFilterProxy::VideoDelegate& video_delegate);
46 // Sends an IPC message over this CMA ipc channel.
47 bool Send(scoped_ptr<IPC::Message> message);
49 private:
50 friend class base::RefCountedThreadSafe<MediaChannelProxy>;
51 virtual ~MediaChannelProxy();
53 // Message filter running on the renderer side.
54 scoped_refptr<CmaMessageFilterProxy> filter_;
56 // Indicates whether the CMA channel is open.
57 bool is_open_;
59 // Unique identifier per media pipeline.
60 int id_;
62 DISALLOW_COPY_AND_ASSIGN(MediaChannelProxy);
65 } // namespace media
66 } // namespace chromecast
68 #endif // CHROMECAST_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_