class CodecBuffer

Defined at line 37 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

TODO(dustingreen): Support BufferCollection buffers.

These are 1:1 with Codec buffers, but not necessarily 1:1 with core codec

buffers.

The const-ness of a CodecBuffer refers to the fields of the CodecBuffer

instance, not to the data pointed at by buffer_base().

Protected Members

CodecImpl * parent_
Info buffer_info_
CodecVmoRange vmo_range_
weak_ptr video_frame_
uint8_t * buffer_base_
bool is_mapped_
pmt pinned_
bool is_known_contiguous_
zx_paddr_t contiguous_paddr_base_

Public Methods

std::unique_ptr<CodecBuffer> CreateFromVmo (uint32_t buffer_index, zx::vmo vmo, uint32_t vmo_usable_start, uint32_t vmo_usable_size, bool need_write, bool is_physically_contiguous)

Defined at line 61 of file ../../src/media/lib/test/codec_buffer.cc

bool GetDupVmo (bool is_for_write, zx::vmo * out_vmo)

Each successful call to this method dups the VMO handle, with basic rights

+ read + optional write depending on is_for_write.

Defined at line 26 of file ../../src/media/lib/test/codec_buffer.cc

uint32_t buffer_index ()

In buffer-per-packet mode this is equal to the corresponding packet index,

for purposes of mapping from packet_index to buffer_index.

Defined at line 14 of file ../../src/media/lib/test/codec_buffer.cc

uint8_t * base ()

The vaddr of the start of the mapped VMO for this buffer.

This will return nullptr if there's no VMO mapping because CPU access isn't

possible. In that case the vaddr data pointer passed around regarding a

packet will be an offset into the buffer / VMO, and is only meaningful

with respect to a CodecBuffer that's also passed alongside.

Defined at line 32 of file ../../src/media/lib/test/include/lib/media/test/codec_buffer.h

size_t size_bytes ()

Defined at line 33 of file ../../src/media/lib/test/include/lib/media/test/codec_buffer.h

bool is_physically_contiguous ()

For testing.

Defined at line 39 of file ../../src/media/lib/test/include/lib/media/test/codec_buffer.h

uint64_t lifetime_ordinal ()

This is the same value as buffer_lifetime_ordinal in StreamProcessor FIDL.

Defined at line 40 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

uint32_t index ()

This matches the buffer_index field of fuchsia::media::Packet when the packet refers to this

buffer.

Defined at line 44 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

CodecPort port ()

Defined at line 46 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

bool is_secure ()

Defined at line 48 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

bool is_known_contiguous ()

Defined at line 84 of file ../../src/media/lib/codec_impl/codec_buffer.cc

zx_paddr_t physical_base ()

This will ZX_PANIC() if the buffer hasn't been pinned yet, or if !is_known_contiguous().

Defined at line 86 of file ../../src/media/lib/codec_impl/codec_buffer.cc

size_t size ()

Defined at line 95 of file ../../src/media/lib/codec_impl/codec_buffer.cc

const zx::vmo & vmo ()

The main VMO.

Defined at line 35 of file ../../src/media/lib/test/include/lib/media/test/codec_buffer.h

uint64_t vmo_offset ()

The offset within the main VMO where data of this CodecBuffer starts. The vmo_offset() is not

required to be divisible by page size.

Defined at line 36 of file ../../src/media/lib/test/include/lib/media/test/codec_buffer.h

void SetVideoFrame (std::weak_ptr<VideoFrame> video_frame)

The use of weak_ptr

<

> here is to emphasize that we don't need shared_ptr

<

>

to keep the VideoFrame(s) alive. We'd use a raw pointer here if it weren't

for needing to convert to a shared_ptr

<

> to call certain methods that

expect shared_ptr

<

>.

This is marked const because it only mutates a mutable field, which is

considered mutable because it's about establishing an association between

video_frame and CodecBuffer after CodecBuffer has been constructed.

Defined at line 101 of file ../../src/media/lib/codec_impl/codec_buffer.cc

std::weak_ptr<VideoFrame> video_frame ()

Defined at line 105 of file ../../src/media/lib/codec_impl/codec_buffer.cc

zx_status_t Pin ()

Unpin is automatic during ~CodecBuffer.

Defined at line 107 of file ../../src/media/lib/codec_impl/codec_buffer.cc

bool is_pinned ()

Defined at line 149 of file ../../src/media/lib/codec_impl/codec_buffer.cc

void CacheFlush (uint32_t flush_offset, uint32_t length)

Defined at line 151 of file ../../src/media/lib/codec_impl/codec_buffer.cc

void CacheFlushAndInvalidate (uint32_t flush_offset, uint32_t length)

Defined at line 155 of file ../../src/media/lib/codec_impl/codec_buffer.cc

Protected Methods

void CodecBuffer (CodecImpl * parent, Info buffer_info, CodecVmoRange vmo_range)

Defined at line 15 of file ../../src/media/lib/codec_impl/codec_buffer.cc

void ~CodecBuffer ()

Defined at line 20 of file ../../src/media/lib/codec_impl/codec_buffer.cc

bool Map ()

Maps a page-aligned portion of the VMO including vmo_usable_start to vmo_usable_start +

vmo_usable_size.

Defined at line 47 of file ../../src/media/lib/codec_impl/codec_buffer.cc

void FakeMap (uint8_t * fake_map_addr)

FakeMap() exists because most CodecAdapter(s) expect to have a CodecBuffer::base() and "data"

vaddr(s) within the buffer, even when buffers are secure. IIUC, mapping to secure buffer +

cached policy on the VMO + speculative execution + aarch64 potentially would

randomly/spuriously fault even if the code never actually touched the mapping. So instead of

mapping, we use a VMAR to reserve some vaddr space, but without any VMOs backing the VMAR, so

any actual accesses to any part of the VMAR will fault, and any speculative accesses won't

spuriuously/randomly fault. We only need one VMAR across all buffers of a BufferCollection, so

CodecImpl passes in the vaddr of that VMAR here. The fake_map_addr is in keeping with trying

to minimize the differences between non-secure and secure cases; it's just that we can't have

an actual mapping to the secure physical pages at the moment. In addition, by not actually

mapping buffers we can't touch anyway, we presumably save some page table resources.

The fake_map_addr is used as the a page-aligned base address for a fake mapping. Client code

must not touch memory at buffer_base() when a fake mapping is in effect, but if client code

does anyway, that thread will cleanly fault (not get stuck reading, not seem to let a write

happen, not be reading/writing any arbitrary other data in the process's address space). The

fake_map_addr vaddr region is guaranteed to have enough vaddr pages to accommodate

vmo_usable_start % PAGE_SIZE + vmo_usable_size (so that an access within the bounds of the

buffer will reliably fault cleanly).

Defined at line 73 of file ../../src/media/lib/codec_impl/codec_buffer.cc

void CacheFlushInternal (uint32_t flush_offset, uint32_t length, bool also_invalidate)

Defined at line 159 of file ../../src/media/lib/codec_impl/codec_buffer.cc

void CodecBuffer (const CodecBuffer & to_copy)

Defined at line 163 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

CodecBuffer & operator= (const CodecBuffer & to_copy)

Defined at line 164 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

void CodecBuffer (CodecBuffer && to_move)

Defined at line 165 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

CodecBuffer & operator= (CodecBuffer && to_move)

Defined at line 166 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_buffer.h

Records

Friends

class CodecBufferForTest
class default_delete
class unique_ptr
class CodecImpl