OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // VideoCaptureHost serves video capture related messages from | 5 // VideoCaptureHost serves video capture related messages from |
6 // VideoCaptureMessageFilter which lives inside the render process. | 6 // VideoCaptureMessageFilter which lives inside the render process. |
7 // | 7 // |
8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI | 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI |
9 // thread, but all other operations and method calls happen on IO thread. | 9 // thread, but all other operations and method calls happen on IO thread. |
10 // | 10 // |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 #include <map> | 39 #include <map> |
40 | 40 |
41 #include "base/memory/ref_counted.h" | 41 #include "base/memory/ref_counted.h" |
42 #include "base/sequenced_task_runner_helpers.h" | 42 #include "base/sequenced_task_runner_helpers.h" |
43 #include "content/browser/renderer_host/media/video_capture_controller.h" | 43 #include "content/browser/renderer_host/media/video_capture_controller.h" |
44 #include "content/common/content_export.h" | 44 #include "content/common/content_export.h" |
45 #include "content/public/browser/browser_message_filter.h" | 45 #include "content/public/browser/browser_message_filter.h" |
46 #include "ipc/ipc_message.h" | 46 #include "ipc/ipc_message.h" |
47 | 47 |
| 48 namespace content { |
| 49 |
48 class CONTENT_EXPORT VideoCaptureHost | 50 class CONTENT_EXPORT VideoCaptureHost |
49 : public content::BrowserMessageFilter, | 51 : public BrowserMessageFilter, |
50 public VideoCaptureControllerEventHandler { | 52 public VideoCaptureControllerEventHandler { |
51 public: | 53 public: |
52 VideoCaptureHost(); | 54 VideoCaptureHost(); |
53 | 55 |
54 // content::BrowserMessageFilter implementation. | 56 // BrowserMessageFilter implementation. |
55 virtual void OnChannelClosing() OVERRIDE; | 57 virtual void OnChannelClosing() OVERRIDE; |
56 virtual void OnDestruct() const OVERRIDE; | 58 virtual void OnDestruct() const OVERRIDE; |
57 virtual bool OnMessageReceived(const IPC::Message& message, | 59 virtual bool OnMessageReceived(const IPC::Message& message, |
58 bool* message_was_ok) OVERRIDE; | 60 bool* message_was_ok) OVERRIDE; |
59 | 61 |
60 // VideoCaptureControllerEventHandler implementation. | 62 // VideoCaptureControllerEventHandler implementation. |
61 virtual void OnError(const VideoCaptureControllerID& id) OVERRIDE; | 63 virtual void OnError(const VideoCaptureControllerID& id) OVERRIDE; |
62 virtual void OnBufferCreated(const VideoCaptureControllerID& id, | 64 virtual void OnBufferCreated(const VideoCaptureControllerID& id, |
63 base::SharedMemoryHandle handle, | 65 base::SharedMemoryHandle handle, |
64 int length, int buffer_id) OVERRIDE; | 66 int length, int buffer_id) OVERRIDE; |
65 virtual void OnBufferReady(const VideoCaptureControllerID& id, | 67 virtual void OnBufferReady(const VideoCaptureControllerID& id, |
66 int buffer_id, | 68 int buffer_id, |
67 base::Time timestamp) OVERRIDE; | 69 base::Time timestamp) OVERRIDE; |
68 virtual void OnFrameInfo(const VideoCaptureControllerID& id, | 70 virtual void OnFrameInfo(const VideoCaptureControllerID& id, |
69 int width, | 71 int width, |
70 int height, | 72 int height, |
71 int frame_per_second) OVERRIDE; | 73 int frame_per_second) OVERRIDE; |
72 virtual void OnPaused(const VideoCaptureControllerID& id) OVERRIDE; | 74 virtual void OnPaused(const VideoCaptureControllerID& id) OVERRIDE; |
73 | 75 |
74 private: | 76 private: |
75 friend class content::BrowserThread; | 77 friend class BrowserThread; |
76 friend class base::DeleteHelper<VideoCaptureHost>; | 78 friend class base::DeleteHelper<VideoCaptureHost>; |
77 friend class MockVideoCaptureHost; | 79 friend class MockVideoCaptureHost; |
78 friend class VideoCaptureHostTest; | 80 friend class VideoCaptureHostTest; |
79 | 81 |
80 virtual ~VideoCaptureHost(); | 82 virtual ~VideoCaptureHost(); |
81 | 83 |
82 // IPC message: Start capture on the VideoCaptureDevice referenced by | 84 // IPC message: Start capture on the VideoCaptureDevice referenced by |
83 // VideoCaptureParams::session_id. |device_id| is an id created by | 85 // VideoCaptureParams::session_id. |device_id| is an id created by |
84 // VideoCaptureMessageFilter to identify a session | 86 // VideoCaptureMessageFilter to identify a session |
85 // between a VideoCaptureMessageFilter and a VideoCaptureHost. | 87 // between a VideoCaptureMessageFilter and a VideoCaptureHost. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // Handle error coming from VideoCaptureDevice. | 128 // Handle error coming from VideoCaptureDevice. |
127 void DoHandleErrorOnIOThread(const VideoCaptureControllerID& controller_id); | 129 void DoHandleErrorOnIOThread(const VideoCaptureControllerID& controller_id); |
128 | 130 |
129 void DoPausedOnIOThread(const VideoCaptureControllerID& controller_id); | 131 void DoPausedOnIOThread(const VideoCaptureControllerID& controller_id); |
130 | 132 |
131 void DeleteVideoCaptureControllerOnIOThread( | 133 void DeleteVideoCaptureControllerOnIOThread( |
132 const VideoCaptureControllerID& controller_id); | 134 const VideoCaptureControllerID& controller_id); |
133 | 135 |
134 // Returns the video capture manager. This is a virtual function so that | 136 // Returns the video capture manager. This is a virtual function so that |
135 // the unit tests can inject their own MediaStreamManager. | 137 // the unit tests can inject their own MediaStreamManager. |
136 virtual media_stream::VideoCaptureManager* GetVideoCaptureManager(); | 138 virtual VideoCaptureManager* GetVideoCaptureManager(); |
137 | 139 |
138 struct Entry; | 140 struct Entry; |
139 typedef std::map<VideoCaptureControllerID, Entry*> EntryMap; | 141 typedef std::map<VideoCaptureControllerID, Entry*> EntryMap; |
140 // A map of VideoCaptureControllerID to its state and VideoCaptureController. | 142 // A map of VideoCaptureControllerID to its state and VideoCaptureController. |
141 EntryMap entries_; | 143 EntryMap entries_; |
142 | 144 |
143 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); | 145 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); |
144 }; | 146 }; |
145 | 147 |
| 148 } // namespace content |
| 149 |
146 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 150 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
OLD | NEW |