class CodecImpl
Defined at line 73 of file ../../src/media/lib/codec_impl/include/lib/media/codec_impl/codec_impl.h
Error handling:
There are two types of errors, per-CodecImpl errors and per-devhost-process
errors.
Per-CodecImpl:
We handle per-Codec protocol errors and the like by calling Unbind() on the
CodecImpl, which fairly soon results in ~CodecImpl async, but does not exit
the whole devhost process. We also handle a few per-CodecImpl errors this
way even though some of those are closer to being caused by per-devhost
conditions, just in case.
Per-devhost-process:
In contrast, per-devhost error conditions, like the inability to post work to
the shared_fidl_thread(), are handled by exiting the devhost, because those
conditions are not really unique to any one CodecImpl.
Public Methods
void CodecImpl (fidl::ClientEnd<fuchsia_sysmem2::Allocator> sysmem, std::unique_ptr<CodecAdmission> codec_admission, async_dispatcher_t * shared_fidl_dispatcher, thrd_t shared_fidl_thread, StreamProcessorParams params, fidl::InterfaceRequest<fuchsia::media::StreamProcessor> request)
The CodecImpl will take care of doing set_error_handler() on the sysmem
connection. The sysmem connection should be set up to use the
shared_fidl_dispatcher.
Defined at line 125 of file ../../src/media/lib/codec_impl/codec_impl.cc
void ~CodecImpl ()
Defined at line 165 of file ../../src/media/lib/codec_impl/codec_impl.cc
std::mutex & lock ()
This is only intended for use by LocalCodecFactory in creating the
appropriate CodecAdapter.
Defined at line 224 of file ../../src/media/lib/codec_impl/codec_impl.cc
void SetLifetimeTracking (std::vector<zx::eventpair> lifetime_tracking_eventpair)
Defined at line 226 of file ../../src/media/lib/codec_impl/codec_impl.cc
void SetCodecMetrics (CodecMetrics * codec_metrics)
The LocalCodecFactory optionally calls this method between construction and
SetCoreCodecAdapter(). If this method is not called, CodecImpl will treat
any call to onCoreCodecLogEvent() as a nop, and will not require that the
CodecAdapter sub-class implement CoreCodecMetricsImplementation().
Defined at line 232 of file ../../src/media/lib/codec_impl/codec_impl.cc
void SetCoreCodecAdapter (std::unique_ptr<CodecAdapter> codec_adapter)
The LocalCodecFactory calls this method once just after CodecImpl
construction and just before BindAsync().
There's only one CodecAdapter for the lifetime of the CodecImpl. This
mechanism intentionally doesn't permit switching input format to a
completely different format, and a CodecAdapter is free to reject any
format change it wants to reject. Before giving up, a client that uses
per-stream input format overrides should go around one more time with a
freshly created Codec created directly with the new format if the client
gets a Codec failure having overridden the input format on a stream of a
Codec such that the stream's input format doesn't exactly match the Codec's
input format (at least for now).
Defined at line 237 of file ../../src/media/lib/codec_impl/codec_impl.cc
void SetCodecDiagnostics (CodecDiagnostics * codec_diagnostics)
The LocalCodecFactory optionally calls this method after SetCoreCodecAdapter() and before
CoreCodecInit(). This method is a passthrough to the underlying
CodecAdapter::SetCodecDiagnostics() method. Not that the codec does not retain any ownership
of the CodecDiagnostics. The pointer is guaranteed to live longer than the codec_impl and if
this method is called, the pointer will not be nullptr.
Defined at line 244 of file ../../src/media/lib/codec_impl/codec_impl.cc
void BindAsync (fit::closure error_handler)
BindAsync()
This enables serving Codec (soon).
Must be called on shared_fidl_thread.
It remains permitted to cause ~CodecImpl (on shared_fidl_thread) after this
call.
The core codec initialization and actual binding occur shortly later async
after the start of this call, possibly after this call has returned. This
is to avoid core codec initialization slowing down the shared_fidl_thread()
which may be handling other stream data for a different CodecImpl instance.
Any error, including those encountered before binding is fully complete,
will call error_handler on a clean stack on shared_fidl_thread(), after
this call (also on shared_fidl_thread()) returns. If the client code runs
~CodecImpl on shared_fidl_thread instead (before error_handler has run on
shared_fidl_thread), the error_handler will be deleted without being run.
The error_handler is expected to trigger ~CodecImpl to run, either
synchronously during error_handler(), or shortly after async. In other
words it's the responsibility of client code to delete the CodecImpl in a
timely manner during or soon after error_handler(). Until ~CodecImpl, the
CodecAdmission won't be released, and the channel itself won't be closed
(intentionally, to ensure the old instance is cleaned up before a new
instance is created based on a client retry triggered by server channel
closure).
Defined at line 262 of file ../../src/media/lib/codec_impl/codec_impl.cc
void EnableOnStreamFailed ()
Codec interface
Defined at line 372 of file ../../src/media/lib/codec_impl/codec_impl.cc
void SetInputBufferPartialSettings (fuchsia::media::StreamBufferPartialSettings input_settings)
Defined at line 390 of file ../../src/media/lib/codec_impl/codec_impl.cc
void SetOutputBufferPartialSettings (fuchsia::media::StreamBufferPartialSettings output_settings)
Defined at line 477 of file ../../src/media/lib/codec_impl/codec_impl.cc
void CompleteOutputBufferPartialSettings (uint64_t buffer_lifetime_ordinal)
Defined at line 495 of file ../../src/media/lib/codec_impl/codec_impl.cc
void FlushEndOfStreamAndCloseStream (uint64_t stream_lifetime_ordinal)
Defined at line 552 of file ../../src/media/lib/codec_impl/codec_impl.cc
void CloseCurrentStream (uint64_t stream_lifetime_ordinal, bool release_input_buffers, bool release_output_buffers)
Defined at line 656 of file ../../src/media/lib/codec_impl/codec_impl.cc
void Sync (SyncCallback callback)
Defined at line 694 of file ../../src/media/lib/codec_impl/codec_impl.cc
void RecycleOutputPacket (fuchsia::media::PacketHeader available_output_packet)
Defined at line 741 of file ../../src/media/lib/codec_impl/codec_impl.cc
void QueueInputFormatDetails (uint64_t stream_lifetime_ordinal, fuchsia::media::FormatDetails format_details)
Defined at line 821 of file ../../src/media/lib/codec_impl/codec_impl.cc
void QueueInputPacket (fuchsia::media::Packet packet)
Defined at line 908 of file ../../src/media/lib/codec_impl/codec_impl.cc
void QueueInputEndOfStream (uint64_t stream_lifetime_ordinal)
Defined at line 1171 of file ../../src/media/lib/codec_impl/codec_impl.cc
zx_status_t Pin (uint32_t options, const zx::vmo & vmo, uint64_t offset, uint64_t size, zx_paddr_t * addrs, size_t addrs_count, zx::pmt * pmt)
This way CodecBuffer doesn't use the core_codec_bti_ directly.
Defined at line 1241 of file ../../src/media/lib/codec_impl/codec_impl.cc
void Fail (const char * format)
Complain sync, then Unbind() async. Even if more than one caller
complains, the async Unbind() work will only run once (but in such cases it
can be nice to see all the complaining in case multiple things fail at
once). While more than one source of failure can complain, only one will
actually trigger Unbind() work, and the rest will just return knowing that
Unbind() work is started. The Unbind() work itself will synchronize such
that other-thread sources of failure are no longer possible (can no longer
even complain) before deallocating "this".
Callers to Fail() must not be holding lock_. On return from Fail(), "this"
must not be touched as it can already be deallocated.
Defined at line 3167 of file ../../src/media/lib/codec_impl/codec_impl.cc
void FailLocked (const char * format)
Callers to FailLocked() must hold lock_ during the call. On return from
FailLocked(), the caller can know that "this" is still allocated only up
to the point where the caller releases lock_. Callers are encouraged not
to touch "this" after the call to FailLocked() besides releasing lock_,
for consistency with how Fail() is used; that said, the unlock itself is
safe.
Defined at line 3178 of file ../../src/media/lib/codec_impl/codec_impl.cc
void FailFatalLocked (const char * format)
Report a devhost-fatal error. This method never returns - instead we
fault the whole process. This should only be used in cases where we
don't really expect an error, and where a client can't unilaterally induce
the error - but in case the error happens despite not being expected, we
want nice output that's easy to debug.
Defined at line 3189 of file ../../src/media/lib/codec_impl/codec_impl.cc