class InStreamPeeker
Defined at line 16 of file ../../src/media/codec/examples/use_media_decoder/test/../in_stream_peeker.h
This wrapper of an InStream adds the ability to peek into the stream.
As with InStream, this class has blocking methods, and completion of those
methods relies on the FIDL thread being a separate thread.
Public Methods
void InStreamPeeker (async::Loop * fidl_loop, thrd_t fidl_thread, sys::ComponentContext * component_context, std::unique_ptr<InStream> in_stream_to_wrap, uint32_t max_peek_bytes)
in_stream_to_wrap - the underlying source of data, typically not capable
of peeking, to wrap such that peeking is possible.
max_peek_bytes - the maximum peek distance in bytes. Some usages will need
a peek distance that's as large as an AU, such as when searching for
pattern-based start codes. Others may not need much peek distance at
all, such as when headers at the start of each AU indicate the length
of the AU.
This InStreamPeeker takes ownership of in_stream_to_wrap and does not
provide any direct access to in_stream_to_wrap, since the read-ahead
performed by this instance would only confuse any direct use of
in_stream_to_wrap.
The in_stream_to_wrap is only called during ReadBytes() or PeekBytes(),
using the same thread as those calls are made on.
The first three parameters to this constructor are for consistency in
threading across all InStream types. We want the InStream base class to
be able to assert that methods are being called on the correct thread, etc.
Defined at line 11 of file ../../src/media/codec/examples/use_media_decoder/in_stream_peeker.cc
void ~InStreamPeeker ()
Defined at line 65 of file ../../src/media/codec/examples/use_media_decoder/in_stream_peeker.cc
uint32_t max_peek_bytes ()
Defined at line 71 of file ../../src/media/codec/examples/use_media_decoder/in_stream_peeker.cc
zx_status_t PeekBytes (uint32_t desired_bytes_to_peek, uint32_t * peek_bytes_out, uint8_t ** peek_buffer_out, zx::time just_fail_deadline)
Unlike ReadBytes, PeekBytes() does not advance cursor_position().
Unlike ReadBytes, PeekBytes() provides a memory address at which the caller
can observe peeked data. The *peek_buffer_out pointer remains valid to
read up to *peek_bytes_out from until the next call to any non-const method
or destructor of this instance.
If the timeout is exceeded, ZX_ERR_TIMED_OUT is returned, and
*peek_buffer_out is set to nullptr.
The *peek_bytes_out may be less than desired_bytes_to_peek only if the end
of input data is reached and has offset
<
cursor_position() +
desired_bytes_to_peek.
Defined at line 73 of file ../../src/media/codec/examples/use_media_decoder/in_stream_peeker.cc
void TossPeekedBytes (uint32_t bytes_to_toss)
Discard previously-peeked and not-yet-read/not-yet-tossed bytes.
This will assert in debug that bytes_to_toss is consistent with having
previously been peeked, but /may/ not catch all cases where this is called
incorrectly without a previous peek of all these bytes.
The caller must only call this for bytes which were previously peeked.
Defined at line 101 of file ../../src/media/codec/examples/use_media_decoder/in_stream_peeker.cc