OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROMECAST_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_ | |
6 #define CHROMECAST_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "chromecast/media/cma/pipeline/load_type.h" | |
13 #include "chromecast/renderer/media/cma_message_filter_proxy.h" | |
14 | |
15 namespace IPC { | |
16 class Message; | |
17 } | |
18 | |
19 namespace chromecast { | |
20 namespace media { | |
21 | |
22 // MediaChannelProxy - Manage the lifetime of a CMA ipc channel. | |
23 // Must be invoked from the IO thread of the renderer process. | |
24 class MediaChannelProxy | |
25 : public base::RefCountedThreadSafe<MediaChannelProxy> { | |
26 public: | |
27 MediaChannelProxy(); | |
28 | |
29 // Opens a CMA ipc channel. | |
30 void Open(LoadType load_type); | |
31 | |
32 // Closes the ipc channel. | |
33 void Close(); | |
34 | |
35 // Returns the ID of the CMA ipc channel. | |
36 // Returns 0 or negative ID if no channel has been opened. | |
37 int GetId() { return id_; } | |
38 | |
39 // Manages delegates. | |
40 bool SetMediaDelegate( | |
41 const CmaMessageFilterProxy::MediaDelegate& media_delegate); | |
42 bool SetAudioDelegate( | |
43 const CmaMessageFilterProxy::AudioDelegate& audio_delegate); | |
44 bool SetVideoDelegate( | |
45 const CmaMessageFilterProxy::VideoDelegate& video_delegate); | |
46 | |
47 // Sends an IPC message over this CMA ipc channel. | |
48 bool Send(std::unique_ptr<IPC::Message> message); | |
49 | |
50 private: | |
51 friend class base::RefCountedThreadSafe<MediaChannelProxy>; | |
52 virtual ~MediaChannelProxy(); | |
53 | |
54 // Message filter running on the renderer side. | |
55 scoped_refptr<CmaMessageFilterProxy> filter_; | |
56 | |
57 // Indicates whether the CMA channel is open. | |
58 bool is_open_; | |
59 | |
60 // Unique identifier per media pipeline. | |
61 int id_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(MediaChannelProxy); | |
64 }; | |
65 | |
66 } // namespace media | |
67 } // namespace chromecast | |
68 | |
69 #endif // CHROMECAST_RENDERER_MEDIA_MEDIA_CHANNEL_PROXY_H_ | |
OLD | NEW |