Extend RTP frame sending API

Add osmo_rtp_send_frame_ext() which accept boolean parameter in addition
to arguments of osmo_rtp_send_frame() to explicitly set marker bit in
RTP header. Previously it was always unset which resulted in degradation
of speech quality for codecs with explicit talkspurt events (was tested
with AMR's ONSET).

Related: OS#1562
Change-Id: I23e6dccfad5643e662391a0a2abebbb45597ffd9
Reviewed-on: https://gerrit.osmocom.org/82
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index 3313798..eb78212 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -23,6 +23,7 @@
  */
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <inttypes.h>
 #include <netdb.h>
 
@@ -417,6 +418,22 @@
 int osmo_rtp_send_frame(struct osmo_rtp_socket *rs, const uint8_t *payload,
 			unsigned int payload_len, unsigned int duration)
 {
+	return osmo_rtp_send_frame_ext(rs, payload, payload_len, duration,
+				       false);
+}
+
+/*! \brief Send one RTP frame via a RTP socket
+ *  \param[in] rs OsmoRTP socket
+ *  \param[in] payload pointer to buffer with RTP payload data
+ *  \param[in] payload_len length of \a payload in bytes
+ *  \param[in] duration duration in number of RTP clock ticks
+ *  \param[in] marker the status of Marker bit in RTP header
+ *  \returns 0 on success, <0 in case of error.
+ */
+int osmo_rtp_send_frame_ext(struct osmo_rtp_socket *rs, const uint8_t *payload,
+			unsigned int payload_len, unsigned int duration,
+			bool marker)
+{
 	mblk_t *mblk;
 	int rc;
 
@@ -428,6 +445,7 @@
 	if (!mblk)
 		return -ENOMEM;
 
+	rtp_set_markbit(mblk, marker);
 	rc = rtp_session_sendm_with_ts(rs->sess, mblk,
 				       rs->tx_timestamp);
 	rs->tx_timestamp += duration;