Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // VideoCaptureHost serves video capture related messages from | |
| 6 // VideCaptureMessageFilter which lives inside the render process. | |
| 7 // | |
| 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI | |
| 9 // thread, but all other operations and method calls happen on IO thread. | |
| 10 // | |
| 11 // Here's an example of a typical IPC dialog for video capture: | |
| 12 // | |
| 13 // Renderer VideoCaptureHost | |
| 14 // | | | |
| 15 // | VideoCaptureHostMsg_Start > | | |
| 16 // | < VideoCaptureMsg_DeviceInfo | | |
| 17 // | | | |
| 18 // | < VideoCaptureMsg_StateChanged | | |
| 19 // | (kStarted) | | |
| 20 // | < VideoCaptureMsg_BufferReady | | |
| 21 // | ... | | |
| 22 // | < VideoCaptureMsg_BufferReady | | |
| 23 // | ... | | |
| 24 // | VideoCaptureHostMsg_BufferReady > | | |
| 25 // | VideoCaptureHostMsg_BufferReady > | | |
| 26 // | | | |
| 27 // | ... | | |
| 28 // | | | |
| 29 // | < VideoCaptureMsg_BufferReady | | |
| 30 // | VideoCaptureHostMsg_Stop > | | |
| 31 // | VideoCaptureHostMsg_BufferReady > | | |
| 32 // | < VideoCaptureMsg_StateChanged | | |
| 33 // | (kStopped) | | |
| 34 // v v | |
| 35 | |
| 36 #ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ | |
| 37 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ | |
| 38 | |
| 39 #include <map> | |
| 40 | |
| 41 #include "base/memory/ref_counted.h" | |
| 42 #include "content/browser/browser_message_filter.h" | |
| 43 #include "content/browser/renderer_host/video_capture_memory.h" | |
| 44 #include "ipc/ipc_message.h" | |
| 45 | |
| 46 class VideoCaptureHost : public BrowserMessageFilter, | |
| 47 public VideoCaptureMemory::EventHandler { | |
| 48 public: | |
| 49 VideoCaptureHost(); | |
| 50 | |
| 51 // BrowserMessageFilter implementation. | |
| 52 virtual void OnChannelClosing(); | |
| 53 virtual void OnDestruct() const; | |
| 54 virtual bool OnMessageReceived(const IPC::Message& message, | |
| 55 bool* message_was_ok); | |
| 56 | |
| 57 // VideoCaptureMemory::EventHandler implementation. | |
| 58 virtual void OnError(VideoCaptureMemory::VideoCaptureMemoryId id); | |
| 59 virtual void OnBufferReady(VideoCaptureMemory::VideoCaptureMemoryId id, | |
| 60 TransportDIB::Handle handle, | |
| 61 base::Time timestamp); | |
| 62 virtual void OnFrameInfo(VideoCaptureMemory::VideoCaptureMemoryId id, | |
| 63 int width, | |
| 64 int height, | |
| 65 int frame_per_second); | |
| 66 virtual void OnReadyToDelete(VideoCaptureMemory::VideoCaptureMemoryId id); | |
| 67 | |
| 68 private: | |
| 69 friend class BrowserThread; | |
| 70 friend class DeleteTask<VideoCaptureHost>; | |
| 71 friend class MockVideoCaptureHost; | |
| 72 friend class VideoCaptureHostTest; | |
| 73 | |
| 74 typedef std::map<VideoCaptureMemory::VideoCaptureMemoryId, | |
| 75 scoped_refptr<VideoCaptureMemory> >EntryMap; | |
|
wjia(left Chromium)
2011/05/19 04:24:37
move typedef to where it's used.
Per K
2011/05/19 08:55:31
Done.
| |
| 76 | |
| 77 virtual ~VideoCaptureHost(); | |
| 78 | |
| 79 // IPC message: Start capture on the VideoCaptureDevice referenced by | |
| 80 // VideoCaptureParams::session_id. device_id is an id created by | |
| 81 // VideCaptureMessageFilter to identify a session | |
| 82 // between a VideCaptureMessageFilter and a VideoCaptureHost. | |
| 83 void OnStartCapture(const IPC::Message& msg, int device_id, | |
| 84 const media::VideoCaptureParams& params); | |
| 85 | |
| 86 // IPC message: Stop capture on device referenced by device_id. | |
| 87 void OnStopCapture(const IPC::Message& msg, int device_id); | |
| 88 | |
| 89 // IPC message: Pause capture on device referenced by device_id. | |
| 90 void OnPauseCapture(const IPC::Message& msg, int device_id); | |
| 91 | |
| 92 // IPC message: Receive an empty buffer from renderer. Send it to device | |
| 93 // referenced by |device_id|. | |
| 94 void OnReceiveEmptyBuffer(const IPC::Message& msg, | |
| 95 int device_id, | |
| 96 TransportDIB::Handle handle); | |
| 97 | |
| 98 | |
| 99 // Called on the IO thread when VideoCaptureMemory have | |
| 100 // reported that all DIBs have been returned. | |
| 101 void DoDeleteVideoCaptureMemory(VideoCaptureMemory::VideoCaptureMemoryId id); | |
| 102 | |
| 103 // Send a filled buffer to the VideoCaptureMessageFilter. | |
| 104 void DoSendFilledBuffer(int32 routing_id, | |
| 105 int device_id, | |
| 106 TransportDIB::Handle handle, | |
| 107 base::Time timestamp); | |
| 108 | |
| 109 // Send a information about frame resolution and frame rate | |
| 110 // to the VideoCaptureMessageFilter. | |
| 111 void DoSendFrameInfo(int32 routing_id, | |
| 112 int device_id, | |
| 113 int width, | |
| 114 int height, | |
| 115 int frame_per_second); | |
| 116 | |
| 117 // Handle error coming from VideoCaptureDevice. | |
| 118 void DoHandleError(int32 routing_id, int device_id); | |
| 119 | |
| 120 // A map of VideoCaptureMemory::VideoCaptureMemoryId to VideoCaptureMemory | |
| 121 // objects that is currently active. | |
| 122 EntryMap entries_; | |
| 123 | |
| 124 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); | |
| 125 }; | |
| 126 | |
| 127 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ | |
| OLD | NEW |