ecu: add is_dtx_pause() method

The ECU API of libosmocodec is unfortunately a peculiar non-3GPP
entity: an ECU by itself, severed from Rx DTX handler functions,
which is a logical/conceptual function with no place in the standard
3GPP architecture.  The closest thing that exists in the standard
architecture is the TFO spec (TS 28.062 section C.3.2.1.1) calling
for an ECU application, but not comfort noise generation, in the case
of destination leg doing DTXd - but even then it is not a totally
"pure" ECU like libosmocodec API, it is an ECU plus a SID preener,
and the SID preening transform is not possible within the constraints
of existing libosmocodec ECU API.  Hence truly correct handling of
corner cases, particularly invalid SID, is sadly impossible in the
current libosmocodec ECU framework.

The only current user of this API is the UL path in osmo-bts-trx;
however, as described in OS#6040, we would like to move that ECU call
from osmo-bts-trx model-specific code to the common layer of osmo-bts.
The current osmo-bts-trx incarnation avoids the SID handling problem
by suppressing the call to ECU frame_out() after any SID (valid or
invalid) was received on the air, thus pausing the RTP stream instead
of emitting ECU output during DTXu pauses.  We would like to retain
the same behavior when we move this ECU call to the common layer,
into its proper place _after_ the link quality check in l1sap - but
the current method of flagging post-SID state in osmo-bts-trx will
no longer work on the other side of that link quality check.

As a workaround, have the ECU remember via a separate Boolean flag
whether it is in post-SID state or not (was the most recent frame_in()
any kind of SID or not), and provide is_dtx_pause() method to
retrieve this flag - the relocated ECU call in osmo-bts UL path
will use this new is_dtx_pause() method call to decide if it should
call frame_out() or switch to pausing RTP output.

Related: OS#6040
Change-Id: I3857be84bba12aaca0c2cca91458b7e13c5a642a
diff --git a/src/codec/ecu.c b/src/codec/ecu.c
index def72e6..cdb3e62 100644
--- a/src/codec/ecu.c
+++ b/src/codec/ecu.c
@@ -96,6 +96,20 @@
 	return g_ecu_ops[st->codec]->frame_out(st, frame_out);
 }
 
+/*! check if the current state of this ECU is a DTX pause.
+ *  \param[in] st ECU state/instance on which to operate
+ *  \return true if DTX pause, false otherwise */
+bool osmo_ecu_is_dtx_pause(struct osmo_ecu_state *st)
+{
+	if (st->codec >= ARRAY_SIZE(g_ecu_ops))
+		return false;
+	if (!g_ecu_ops[st->codec])
+		return false;
+	if (!g_ecu_ops[st->codec]->is_dtx_pause)
+		return false;
+	return g_ecu_ops[st->codec]->is_dtx_pause(st);
+}
+
 /***********************************************************************
  * low-level API for ECU implementations
  ***********************************************************************/