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

Side by Side 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: fix compiling errors on android Created 4 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015 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 #ifndef CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
6 #define CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
7
8 #include "base/memory/shared_memory.h"
9 #include "media/base/bitstream_buffer.h"
10
11 namespace content {
12
13 // Helper class to access a region of a SharedMemory.
14 class SharedMemoryRegion {
15 public:
16 // Creates a SharedMemoryRegion.
17 // The mapped memory region begins at |offset| bytes from the start of the
18 // shared memory and the length is |size|. It will take the ownership of
19 // the |handle| and release the resource when being destroyed.
20 SharedMemoryRegion(const base::SharedMemoryHandle& handle,
21 off_t offset,
dcheng 2016/01/22 18:27:39 Does it make sense to use off_t here? I know that
Pawel Osciak 2016/01/25 08:20:02 SharedMemory::MapAt(), which we pass this to uses
22 size_t size,
23 bool read_only);
24
25 // Creates a SharedMemoryRegion from the given |bistream_buffer|.
26 SharedMemoryRegion(const media::BitstreamBuffer& bitstream_buffer,
27 bool read_only);
28
29 // Maps the shared memory into the caller's address space.
30 // Return true on success, false otherwise.
31 bool Map();
32
33 // Gets a pointer to the mapped region if it has been mapped via Map().
34 // Returns |nullptr| if it is not mapped. The returned pointer points
35 // to the memory at the offset previously passed to the constructor.
36 void* memory();
37
38 size_t size() const { return size_; }
39
40 private:
41 base::SharedMemory shm_;
42 off_t offset_;
43 size_t size_;
44 size_t alignment_size_;
45
46 DISALLOW_COPY_AND_ASSIGN(SharedMemoryRegion);
47 };
48
49 } // namespace content
50
51 #endif // CONTENT_COMMON_GPU_MEDIA_SHARED_MEMORY_REGION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698