class CodecClient
Defined at line 42 of file ../../src/media/lib/test/include/lib/media/test/codec_client.h
This class is just _a_ codec client, and should be read as an example only,
and probably not a fully complete example either. This class is just here
to organize the code involved in setting up a Codec with input buffers and
packets, feeding it input data in a single Stream, setting up the output
buffers and packets, and ensuring that all input data is processed into
output.
A Codec client that wants to seek a logical stream or re-use a Codec to
decode another logical stream would likely want to make more use of the
stream_lifetime_ordinal to feed input data and to accept output data (vs.
this example which has only one Stream lifetime which isn't visible outside
this class. Re-using a Codec instance for a new stream is encouraged,
especially when the output format isn't likely to change from stream to
stream, which avoids re-configuring output buffers across the stream switch.
The use of particular threads of execution to call this class is intended to
clarify reasonable ordering and concurrency of messages sent and processed on
the Codec interface. There is no requirement that a Codec client use
dedicated threads to achieve a permitted and useful ordering. The client does
of course need to stay within the sequencing rules of the interface.
Public Methods
void CodecClient (async::Loop * loop, thrd_t loop_thread, fidl::InterfaceHandle<fuchsia::sysmem2::Allocator> sysmem)
loop - The loop that all the FIDL work will run on. We configure this
explicitly instead of using the default loop per thread mechanism, because
we want to be very sure that we'll be posting to the correct loop to send
messages using that loop's single thread, as ProxyController doesn't have
a lock_ in it.
Defined at line 49 of file ../../src/media/lib/test/codec_client.cc
void ~CodecClient ()
Defined at line 104 of file ../../src/media/lib/test/codec_client.cc
fidl::InterfaceRequest<fuchsia::media::StreamProcessor> GetTheRequestOnce ()
Separate from Start() because we don't wan this class to handle the Codec
creation, so the caller needs a server endpoint to send off to a Codec
server (via the CodecFactory).
Defined at line 106 of file ../../src/media/lib/test/codec_client.cc
void SetMinInputBufferSize (uint32_t min_input_buffer_size)
Can optionally be called before Start(), to set the min buffer size that'll
be requested via sysmem.
Defined at line 111 of file ../../src/media/lib/test/codec_client.cc
void SetMinOutputBufferSize (uint32_t min_output_buffer_size)
Defined at line 116 of file ../../src/media/lib/test/codec_client.cc
void SetMinOutputBufferCount (uint32_t min_buffer_count)
Defined at line 121 of file ../../src/media/lib/test/codec_client.cc
void Start ()
Get the Codec into a state where it's ready to process input data.
Defined at line 126 of file ../../src/media/lib/test/codec_client.cc
void set_is_output_secure (bool is_output_secure)
Defined at line 134 of file ../../src/media/lib/test/include/lib/media/test/codec_client.h
void set_is_input_secure (bool is_input_secure)
Defined at line 135 of file ../../src/media/lib/test/include/lib/media/test/codec_client.h
void set_in_lax_mode (bool lax_mode)
Defined at line 136 of file ../../src/media/lib/test/include/lib/media/test/codec_client.h
void set_is_output_tiled (bool is_output_tiled)
Defined at line 137 of file ../../src/media/lib/test/include/lib/media/test/codec_client.h
std::unique_ptr<fuchsia::media::Packet> BlockingGetFreeInputPacket ()
On this thread, wait for an available input packet_index, and when one is
available, create a new Packet object to represent that packet_index
and return that. The packet_index will be filled out, but not the rest of
the packet. It's up to the caller to set stream_lifetime_ordinal and other
fields.
Since in this example we're using a buffer per packet, waiting for a free
packet is also waiting for a free buffer, with the same index as
packet_index.
To return eventually, this call relies on output being accepted on an
ongoing basis from the Codec using some other thread(s), processed, and
those output packets freed back to the codec.
Defined at line 465 of file ../../src/media/lib/test/codec_client.cc
const CodecBuffer & BlockingGetFreeInputBufferForPacket (fuchsia::media::Packet * packet)
Updates input_packet_index_to_buffer_index_[packet->packet_index()] and
packet->set_buffer_index().
Defined at line 500 of file ../../src/media/lib/test/codec_client.cc
const CodecBuffer & GetInputBufferByIndex (uint32_t packet_index)
Defined at line 516 of file ../../src/media/lib/test/codec_client.cc
const CodecBuffer & GetOutputBufferByIndex (uint32_t packet_index)
Defined at line 520 of file ../../src/media/lib/test/codec_client.cc
void QueueInputFormatDetails (uint64_t stream_lifetime_ordinal, fuchsia::media::FormatDetails input_format_details)
Defined at line 524 of file ../../src/media/lib/test/codec_client.cc
void QueueInputPacket (std::unique_ptr<fuchsia::media::Packet> packet)
Queue an input packet to the codec.
Defined at line 532 of file ../../src/media/lib/test/codec_client.cc
void QueueInputEndOfStream (uint64_t stream_lifetime_ordinal)
Defined at line 556 of file ../../src/media/lib/test/codec_client.cc
void FlushEndOfStreamAndCloseStream (uint64_t stream_lifetime_ordinal)
Defined at line 562 of file ../../src/media/lib/test/codec_client.cc
std::unique_ptr<CodecOutput> BlockingGetEmittedOutput ()
Use the current thread to do what is necessary to get an output packet.
Near the start, this will include configuring output buffers once. In
steady state this thread will just wait for an output packet to show up or
the stream to be done. If an end_of_stream packet shows up, this method
will return that packet.
The returned Packet itself will remain valid and readable as long as
the caller keeps it around. However, if the caller calls
BlockingGetEmittedOutput() again, the entire set of output buffers
can get deallocated and replacement buffers allocated, rendering the
meaning of the returned Packet only usable until
BlockingGetEmittedOutput() is called again. This means the calling
code needs to go ahead and do whatever it wants to do with the output
data in the corresponding output buffer before calling this method again.
A real client can delay output buffer re-configuration until previous
output data has been fully processed, or can ensure that old output buffers
remain live until the old output data is done with them (configuring new
output buffers doesn't inherently delete the old ones, but having both
around at once does use more resources concurrently).
Defined at line 568 of file ../../src/media/lib/test/codec_client.cc
void RecycleOutputPacket (fuchsia::media::PacketHeader free_packet)
Recycle an output packet for re-use.
Defined at line 938 of file ../../src/media/lib/test/codec_client.cc
void Stop ()
Defined at line 320 of file ../../src/media/lib/test/codec_client.cc
void DoNotQueueInputPacketAfterAll (std::unique_ptr<fuchsia::media::Packet> packet)
This can be used to return a packet and its buffer instead of sending the packet to the codec.
This is useful in tests that intentionally skip input frames. The packet must still be filled
out for sending. This method won't send the packet, and instead will skip sending the packet
and put the packet and buffer back in free lists, as if the packet had been sent via
QueueInputPacket and returned from codec with OnFreeInputPacket.
Defined at line 341 of file ../../src/media/lib/test/codec_client.cc
Friends
class CodecStream