Commit 53ebabe3 authored by Matthew Cary's avatar Matthew Cary Committed by Commit Bot

media: Add UnsafeSharedMemoryRegion BitstreamBuffer ctor

Add an UnsafeSharedMemoryRegion constructor for BitstreamBuffer.
While BitstreamBuffer continues to represent its shared memory
internally by base::subtle::PlatformSharedMemoryRegion due to
being used sometimes read-only and sometimes writable, this
constructor makes the bitstream buffer easier to use in the common
case of client/tests which create a buffer backed by unsafe
(writable) shared memory.

Bug: 849207
Change-Id: I271bcd389e936ab2e7207bb2684fc6bcd8c2d529
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695264
Commit-Queue: Matthew Cary (CET) <mattcary@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681431}
parent c1a03706
......@@ -23,6 +23,18 @@ BitstreamBuffer::BitstreamBuffer(
offset_(offset),
presentation_timestamp_(presentation_timestamp) {}
BitstreamBuffer::BitstreamBuffer(int32_t id,
base::UnsafeSharedMemoryRegion region,
size_t size,
off_t offset,
base::TimeDelta presentation_timestamp)
: id_(id),
region_(base::UnsafeSharedMemoryRegion::TakeHandleForSerialization(
std::move(region))),
size_(size),
offset_(offset),
presentation_timestamp_(presentation_timestamp) {}
BitstreamBuffer::BitstreamBuffer(int32_t id,
base::SharedMemoryHandle handle,
bool read_only,
......
......@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/memory/platform_shared_memory_region.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/time/time.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decrypt_config.h"
......@@ -42,6 +43,13 @@ class MEDIA_EXPORT BitstreamBuffer {
off_t offset = 0,
base::TimeDelta presentation_timestamp = kNoTimestamp);
// As above, creating by unwrapping a base::UnsafeSharedMemoryRegion.
BitstreamBuffer(int32_t id,
base::UnsafeSharedMemoryRegion region,
size_t size,
off_t offset = 0,
base::TimeDelta presentation_timestamp = kNoTimestamp);
// As above, but creates by duplicating a SharedMemoryHandle.
// TODO(https://crbug.com/793446): remove once legacy shared memory has been
// converted.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment