Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Unified Diff: content/browser/renderer_host/video_capture_memory.h

Issue 7002027: VideoCaptureHost (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/video_capture_memory.h
===================================================================
--- content/browser/renderer_host/video_capture_memory.h (revision 0)
+++ content/browser/renderer_host/video_capture_memory.h (revision 0)
@@ -0,0 +1,87 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// VideoCaptureMemory is responsible for keeping track of TransportDIBs and
+// filling them with I420 video frames for IPC communication between
+// VideoCaptureHost and VideoCaptureMessageFilter.
+// It implements media::VideoCaptureDevice::EventHandler to get video frames
+// from a VideoCaptureDevice object and do color conversion straight into the
+// TransportDIBs to avoid a memory copy.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_MEMORY_H_
+#define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_MEMORY_H_
+
+#include <list>
+#include <map>
+
+#include "base/synchronization/lock.h"
+#include "media/video/capture/video_capture_device.h"
+#include "media/video/capture/video_capture_types.h"
+#include "ui/gfx/surface/transport_dib.h"
+
+class VideoCaptureMemory: public media::VideoCaptureDevice::EventHandler {
+ public:
+ struct VCEntryId {
+ VCEntryId(int32 render_id,
+ int device_id,
+ media::VideoCaptureSessionId session_id)
+ : render_id(render_id),
+ device_id(device_id),
+ session_id(session_id) {
+ }
+ // Render view id that requested the VideoCaptureDevice.
+ int32 render_id;
+ // Id created by VideoCaptureImpl to identify a session
+ // between a VideoCaptureImpl and a VideoCaptureHost.
+ int device_id;
+ // The media stream session id of a specific VideoCaptureDevice.
+ media::VideoCaptureSessionId session_id;
+ };
+
+ class EventHandler {
+ public:
+ virtual void OnError(VideoCaptureMemory::VCEntryId entry) = 0;
+ virtual void OnBufferReady(VideoCaptureMemory::VCEntryId entry,
+ TransportDIB::Handle handle,
+ base::Time timestamp) = 0;
+ virtual void OnFrameInfo(VideoCaptureMemory::VCEntryId entry,
+ int width,
+ int height,
+ int frame_rate) = 0;
+ protected:
+ virtual ~EventHandler() {}
+ };
+
+ VideoCaptureMemory(VideoCaptureMemory::EventHandler* event_handler,
+ VCEntryId entry_id);
+ ~VideoCaptureMemory();
+
+ VCEntryId entry_id();
+ bool AddTransportDIB(TransportDIB::Handle handle);
+ bool ReadyToDelete();
+
+ // Implement media::VideoCaptureDevice::EventHandler
+ virtual void OnIncomingCapturedFrame(const uint8* data,
+ int length,
+ base::Time timestamp);
+ virtual void OnError();
+ virtual void OnFrameInfo(const media::VideoCaptureDevice::Capability& info);
+
+ private:
+ typedef std::list<TransportDIB::Handle> DIBHANDLEList;
+ typedef std::map<TransportDIB::Handle, TransportDIB*> DIBMap;
+
+ // Lock to protect free_dibs_.
+ base::Lock lock_;
+
+ // Free DIBS that can be filled with video frames.
+ DIBHANDLEList free_dibs_;
+ // All DIBS created by this object.
+ DIBMap owned_dibs_;
+ EventHandler& event_handler_;
+ VCEntryId entry_id_;
+ media::VideoCaptureDevice::Capability frame_info_;
+};
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_MEMORY_H_

Powered by Google App Engine
This is Rietveld 408576698