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

Unified Diff: content/common/gpu/media/shared_memory_region.h

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address posciak's comments Created 4 years, 12 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/common/gpu/media/shared_memory_region.h
diff --git a/content/common/gpu/media/shared_memory_region.h b/content/common/gpu/media/shared_memory_region.h
new file mode 100644
index 0000000000000000000000000000000000000000..c5bb2c7c4e3d0146b32b35725c0fe23726d51303
--- /dev/null
+++ b/content/common/gpu/media/shared_memory_region.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2015 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 CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
+#define CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
+
+#include "base/memory/shared_memory.h"
+#include "media/base/bitstream_buffer.h"
+
+namespace content {
+
+// Helper class to access a region of a SharedMemory.
+class SharedMemoryRegion {
+ public:
+ // Creates a SharedMemoryRegion.
+ // The mapped memory region begins at |offset| bytes from the start of the
+ // shared memory and the length is |size|. SharedMemoryRegion will take the
+ // ownership of the |handle| and release the resource when it was destroyed.
+ // Please make sure |handle| is not |auto_close|.
Pawel Osciak 2016/01/05 06:22:51 Could we instead call SharedMemory::DuplicateHandl
Owen Lin 2016/01/06 03:45:46 Oops, I was confused by the document. https://cod
+ SharedMemoryRegion(const base::SharedMemoryHandle& handle,
+ off_t offset,
+ size_t size,
+ bool read_only);
+
+ // Creates a SharedMemoryRegion from the given |bistream_buffer|.
+ SharedMemoryRegion(const media::BitstreamBuffer& bitstream_buffer,
+ bool read_only);
+
+ // Maps the shared memory into the caller's address space.
+ // Return true on success, false otherwise.
+ bool Map();
+
+ // Gets a pointer to the mapped region if it has been mapped via Map().
+ // Returns |nullptr| if it is not mapped. The mapped region begins at
+ // |offset| bytes from the start of the whole shared memory.
Pawel Osciak 2016/01/05 06:22:51 The returned pointer points to the memory at the o
Owen Lin 2016/01/06 03:45:46 Done.
+ void* memory();
+
+ size_t size() const { return size_; }
+
+ private:
+ base::SharedMemory shm_;
+ off_t offset_;
+ size_t size_;
+ size_t extra_size_;
Pawel Osciak 2016/01/05 06:22:51 Nit: s/extra_size_/aligned_size_/
Owen Lin 2016/01/06 03:45:46 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(SharedMemoryRegion);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_

Powered by Google App Engine
This is Rietveld 408576698