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"
18 namespace chromecast
{
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
> {
28 // Opens a CMA ipc channel.
29 void Open(LoadType load_type
);
31 // Closes the ipc channel.
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_
; }
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
);
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.
59 // Unique identifier per media pipeline.
62 DISALLOW_COPY_AND_ASSIGN(MediaChannelProxy
);
66 } // namespace chromecast
68 #endif // CHROMECAST_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_