summaryrefslogtreecommitdiffstats
path: root/media/video/capture/screen/shared_buffer.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-28 23:54:03 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-28 23:54:03 +0000
commit497d8a9857e7383f979b89694aff8dd403c176fe (patch)
tree2f07bb42d4a7a8e94e959c90dacbfa62eed1debd /media/video/capture/screen/shared_buffer.h
parentbac4ae80a786d68bfc18ca46f0adfcc4a1c43b0f (diff)
downloadchromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.zip
chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.tar.gz
chromium_src-497d8a9857e7383f979b89694aff8dd403c176fe.tar.bz2
Move screen capturers from remoting/capturer to media/video/capturer/screen
Screen capturers will be used in content, and so they have to be moved to avoid dependency on remoting/capturer in content. Beside moving the files this CL also renames classes as follows: remoting::VideoFrameCapturer -> media::ScreenCapturer remoting::VideoFrame -> media::ScreenCaptureFrame remoting::CaptureData -> media::ScreenCaptureData BUG=134249 Review URL: https://codereview.chromium.org/12047101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video/capture/screen/shared_buffer.h')
-rw-r--r--media/video/capture/screen/shared_buffer.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/media/video/capture/screen/shared_buffer.h b/media/video/capture/screen/shared_buffer.h
new file mode 100644
index 0000000..4c77b6a0
--- /dev/null
+++ b/media/video/capture/screen/shared_buffer.h
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 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.
+
+#ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_H_
+#define MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/process.h"
+#include "base/shared_memory.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+// Represents a memory buffer that can be shared between multiple processes.
+// It is more or less a convenience wrapper around base::SharedMemory providing
+// ref-counted lifetime management and unique buffer identifiers.
+class MEDIA_EXPORT SharedBuffer
+ : public base::RefCountedThreadSafe<SharedBuffer> {
+ public:
+ // Creates a new shared memory buffer of the given size and maps it to
+ // the memory of the calling process. If the operation fails for any reason,
+ // ptr() method will return NULL. This constructor set the identifier of this
+ // buffer to 0.
+ explicit SharedBuffer(uint32 size);
+
+ // Opens an existing shared memory buffer and maps it to the memory of
+ // the calling process (in read only mode). If the operation fails for any
+ // reason, ptr() method will return NULL.
+ SharedBuffer(int id, base::SharedMemoryHandle handle, uint32 size);
+
+ // Opens an existing shared memory buffer created by a different process and
+ // maps it to the memory of the calling process (in read only mode). If
+ // the operation fails for any reason, ptr() method will return NULL.
+ SharedBuffer(int id, base::SharedMemoryHandle handle,
+ base::ProcessHandle process, uint32 size);
+
+ // Returns pointer to the beginning of the allocated data buffer. Returns NULL
+ // if the object initialization failed for any reason.
+ void* ptr() const { return shared_memory_.memory(); }
+
+ // Returns handle of the shared memory section containing the allocated
+ // data buffer.
+ base::SharedMemoryHandle handle() const { return shared_memory_.handle(); }
+
+ // Calls SharedMemory::ShareToProcess to share the handle with a different
+ // process.
+ bool ShareToProcess(base::ProcessHandle process,
+ base::SharedMemoryHandle* new_handle);
+
+ int id() const { return id_; }
+ uint32 size() const { return size_; }
+
+ void set_id(int id) { id_ = id; }
+
+ private:
+ friend class base::RefCountedThreadSafe<SharedBuffer>;
+ virtual ~SharedBuffer();
+
+ // Unique identifier of the buffer or 0 if ID hasn't been set.
+ int id_;
+
+ // Shared memory section backing up the buffer.
+ base::SharedMemory shared_memory_;
+
+ // Size of the buffer in bytes.
+ uint32 size_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedBuffer);
+};
+
+} // namespace media
+
+#endif // MEDIA_VIDEO_CAPTURE_SCREEN_SHARED_BUFFER_H_