| 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 // VideoCaptureMemory is responsible for keeping track of TransportDIBs and |
| 6 // filling them with I420 video frames for IPC communication between |
| 7 // VideoCaptureHost and VideoCaptureMessageFilter. |
| 8 // It implements media::VideoCaptureDevice::EventHandler to get video frames |
| 9 // from a VideoCaptureDevice object and do color conversion straight into the |
| 10 // TransportDIBs to avoid a memory copy. |
| 11 |
| 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_MEMORY_H_ |
| 13 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_MEMORY_H_ |
| 14 |
| 15 #include <list> |
| 16 #include <map> |
| 17 |
| 18 #include "base/synchronization/lock.h" |
| 19 #include "media/video/capture/video_capture_device.h" |
| 20 #include "media/video/capture/video_capture_types.h" |
| 21 #include "ui/gfx/surface/transport_dib.h" |
| 22 |
| 23 class VideoCaptureMemory: public media::VideoCaptureDevice::EventHandler { |
| 24 public: |
| 25 struct VCEntryId { |
| 26 VCEntryId(int32 render_id, |
| 27 int device_id, |
| 28 media::VideoCaptureSessionId session_id) |
| 29 : render_id(render_id), |
| 30 device_id(device_id), |
| 31 session_id(session_id) { |
| 32 } |
| 33 // Render view id that requested the VideoCaptureDevice. |
| 34 int32 render_id; |
| 35 // Id created by VideoCaptureImpl to identify a session |
| 36 // between a VideoCaptureImpl and a VideoCaptureHost. |
| 37 int device_id; |
| 38 // The media stream session id of a specific VideoCaptureDevice. |
| 39 media::VideoCaptureSessionId session_id; |
| 40 }; |
| 41 |
| 42 class EventHandler { |
| 43 public: |
| 44 virtual void OnError(VideoCaptureMemory::VCEntryId entry) = 0; |
| 45 virtual void OnBufferReady(VideoCaptureMemory::VCEntryId entry, |
| 46 TransportDIB::Handle handle, |
| 47 base::Time timestamp) = 0; |
| 48 virtual void OnFrameInfo(VideoCaptureMemory::VCEntryId entry, |
| 49 int width, |
| 50 int height, |
| 51 int frame_rate) = 0; |
| 52 protected: |
| 53 virtual ~EventHandler() {} |
| 54 }; |
| 55 |
| 56 VideoCaptureMemory(VideoCaptureMemory::EventHandler* event_handler, |
| 57 VCEntryId entry_id); |
| 58 ~VideoCaptureMemory(); |
| 59 |
| 60 VCEntryId entry_id(); |
| 61 bool AddTransportDIB(TransportDIB::Handle handle); |
| 62 bool ReadyToDelete(); |
| 63 |
| 64 // Implement media::VideoCaptureDevice::EventHandler |
| 65 virtual void OnIncomingCapturedFrame(const uint8* data, |
| 66 int length, |
| 67 base::Time timestamp); |
| 68 virtual void OnError(); |
| 69 virtual void OnFrameInfo(const media::VideoCaptureDevice::Capability& info); |
| 70 |
| 71 private: |
| 72 typedef std::list<TransportDIB::Handle> DIBHANDLEList; |
| 73 typedef std::map<TransportDIB::Handle, TransportDIB*> DIBMap; |
| 74 |
| 75 // Lock to protect free_dibs_. |
| 76 base::Lock lock_; |
| 77 |
| 78 // Free DIBS that can be filled with video frames. |
| 79 DIBHANDLEList free_dibs_; |
| 80 // All DIBS created by this object. |
| 81 DIBMap owned_dibs_; |
| 82 EventHandler& event_handler_; |
| 83 VCEntryId entry_id_; |
| 84 media::VideoCaptureDevice::Capability frame_info_; |
| 85 }; |
| 86 |
| 87 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_MEMORY_H_ |
| OLD | NEW |