| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // VideCaptureMessageFilter which lives inside the render process. | 6 // VideCaptureMessageFilter 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 26 matching lines...) Expand all Loading... |
| 37 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ | 37 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ |
| 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 "content/browser/browser_message_filter.h" | 42 #include "content/browser/browser_message_filter.h" |
| 43 #include "content/browser/renderer_host/video_capture_controller.h" | 43 #include "content/browser/renderer_host/video_capture_controller.h" |
| 44 #include "ipc/ipc_message.h" | 44 #include "ipc/ipc_message.h" |
| 45 | 45 |
| 46 class VideoCaptureHost : public BrowserMessageFilter, | 46 class VideoCaptureHost : public BrowserMessageFilter, |
| 47 public VideoCaptureController::EventHandler { | 47 public VideoCaptureControllerEventHandler { |
| 48 public: | 48 public: |
| 49 VideoCaptureHost(); | 49 VideoCaptureHost(); |
| 50 | 50 |
| 51 // BrowserMessageFilter implementation. | 51 // BrowserMessageFilter implementation. |
| 52 virtual void OnChannelClosing(); | 52 virtual void OnChannelClosing(); |
| 53 virtual void OnDestruct() const; | 53 virtual void OnDestruct() const; |
| 54 virtual bool OnMessageReceived(const IPC::Message& message, | 54 virtual bool OnMessageReceived(const IPC::Message& message, |
| 55 bool* message_was_ok); | 55 bool* message_was_ok); |
| 56 | 56 |
| 57 // VideoCaptureController::EventHandler implementation. | 57 // VideoCaptureControllerEventHandler implementation. |
| 58 virtual void OnError(VideoCaptureController::ControllerId id); | 58 virtual void OnError(const VideoCaptureControllerID& id); |
| 59 virtual void OnBufferReady(VideoCaptureController::ControllerId id, | 59 virtual void OnBufferReady(const VideoCaptureControllerID& id, |
| 60 TransportDIB::Handle handle, | 60 TransportDIB::Handle handle, |
| 61 base::Time timestamp); | 61 base::Time timestamp); |
| 62 virtual void OnFrameInfo(VideoCaptureController::ControllerId id, | 62 virtual void OnFrameInfo(const VideoCaptureControllerID& id, |
| 63 int width, | 63 int width, |
| 64 int height, | 64 int height, |
| 65 int frame_per_second); | 65 int frame_per_second); |
| 66 virtual void OnReadyToDelete(VideoCaptureController::ControllerId id); | 66 virtual void OnReadyToDelete(const VideoCaptureControllerID& id); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 friend class BrowserThread; | 69 friend class BrowserThread; |
| 70 friend class DeleteTask<VideoCaptureHost>; | 70 friend class DeleteTask<VideoCaptureHost>; |
| 71 friend class MockVideoCaptureHost; | 71 friend class MockVideoCaptureHost; |
| 72 friend class VideoCaptureHostTest; | 72 friend class VideoCaptureHostTest; |
| 73 | 73 |
| 74 virtual ~VideoCaptureHost(); | 74 virtual ~VideoCaptureHost(); |
| 75 | 75 |
| 76 // IPC message: Start capture on the VideoCaptureDevice referenced by | 76 // IPC message: Start capture on the VideoCaptureDevice referenced by |
| (...skipping 11 matching lines...) Expand all Loading... |
| 88 | 88 |
| 89 // IPC message: Receive an empty buffer from renderer. Send it to device | 89 // IPC message: Receive an empty buffer from renderer. Send it to device |
| 90 // referenced by |device_id|. | 90 // referenced by |device_id|. |
| 91 void OnReceiveEmptyBuffer(const IPC::Message& msg, | 91 void OnReceiveEmptyBuffer(const IPC::Message& msg, |
| 92 int device_id, | 92 int device_id, |
| 93 TransportDIB::Handle handle); | 93 TransportDIB::Handle handle); |
| 94 | 94 |
| 95 | 95 |
| 96 // Called on the IO thread when VideoCaptureController have | 96 // Called on the IO thread when VideoCaptureController have |
| 97 // reported that all DIBs have been returned. | 97 // reported that all DIBs have been returned. |
| 98 void DoDeleteVideoCaptureController(VideoCaptureController::ControllerId id); | 98 void DoDeleteVideoCaptureController(const VideoCaptureControllerID& id); |
| 99 | 99 |
| 100 // Send a filled buffer to the VideoCaptureMessageFilter. | 100 // Send a filled buffer to the VideoCaptureMessageFilter. |
| 101 void DoSendFilledBuffer(int32 routing_id, | 101 void DoSendFilledBuffer(int32 routing_id, |
| 102 int device_id, | 102 int device_id, |
| 103 TransportDIB::Handle handle, | 103 TransportDIB::Handle handle, |
| 104 base::Time timestamp); | 104 base::Time timestamp); |
| 105 | 105 |
| 106 // Send a information about frame resolution and frame rate | 106 // Send a information about frame resolution and frame rate |
| 107 // to the VideoCaptureMessageFilter. | 107 // to the VideoCaptureMessageFilter. |
| 108 void DoSendFrameInfo(int32 routing_id, | 108 void DoSendFrameInfo(int32 routing_id, |
| 109 int device_id, | 109 int device_id, |
| 110 int width, | 110 int width, |
| 111 int height, | 111 int height, |
| 112 int frame_per_second); | 112 int frame_per_second); |
| 113 | 113 |
| 114 // Handle error coming from VideoCaptureDevice. | 114 // Handle error coming from VideoCaptureDevice. |
| 115 void DoHandleError(int32 routing_id, int device_id); | 115 void DoHandleError(int32 routing_id, int device_id); |
| 116 | 116 |
| 117 typedef std::map<VideoCaptureController::ControllerId, | 117 typedef std::map<VideoCaptureControllerID, |
| 118 scoped_refptr<VideoCaptureController> >EntryMap; | 118 scoped_refptr<VideoCaptureController> >EntryMap; |
| 119 | 119 |
| 120 // A map of VideoCaptureController::ControllerId to VideoCaptureController | 120 // A map of VideoCaptureControllerID to VideoCaptureController |
| 121 // objects that is currently active. | 121 // objects that is currently active. |
| 122 EntryMap entries_; | 122 EntryMap entries_; |
| 123 | 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); | 124 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ | 127 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ |
| OLD | NEW |