summaryrefslogtreecommitdiffstats
path: root/PICA_media.h
diff options
context:
space:
mode:
Diffstat (limited to 'PICA_media.h')
-rw-r--r--PICA_media.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/PICA_media.h b/PICA_media.h
index c3ad75f..90276a2 100644
--- a/PICA_media.h
+++ b/PICA_media.h
@@ -104,6 +104,19 @@
#define PICA_MEDIA_CALL_INFO_MAXSIZE (PICA_PROTO_CALL_TOKENSIZE + PICA_PROTO_CALL_RESOLUTIONSIZE \
+ PICA_PROTO_CALL_MAXADDRS * PICA_PROTO_DIRECTC2C_ADDRLIST_ITEM_IPV4_SIZE)
+/* How often the receiving side of an active call sends 0x79, in milliseconds:
+ * the sender's rate adaptation finds out about a link that got worse at most
+ * this late, while the report costs next to nothing next to the media.
+ */
+#define PICA_MEDIA_REPORT_INTERVAL 2000
+/* The queuing delay a 0x79 carries is measured against the smallest one-way
+ * delay - arrival time less the packet's timestamp, clock offset included - of
+ * this many periods, the current one among them: half a minute. Long enough to
+ * see a queue that builds up over several seconds, short enough to follow the
+ * drift of the two clocks.
+ */
+#define PICA_MEDIA_DELAY_BASELINE_PERIODS 15
+
/* transport of the media packets of a call, reported by call_media_transport_cb */
#define PICA_CALL_TRANSPORT_C2C 0
#define PICA_CALL_TRANSPORT_MEDIAC2C 1
@@ -125,6 +138,39 @@ enum PICA_media_state
PICA_MEDIA_STATE_FAILED
};
+/* What the receiving side counts of one of the peer's two media streams for
+ * its 0x79 reports. */
+struct PICA_media_rxstream
+{
+ int started;
+ /* the highest sequence number received, with the times it wrapped
+ * around counted in the bits above it */
+ uint32_t max_seq;
+ /* max_seq when the current period started */
+ uint32_t period_max_seq;
+ /* in the current period */
+ uint32_t received;
+ uint32_t octets;
+};
+
+struct PICA_media_rxstats
+{
+ struct PICA_media_rxstream audio;
+ struct PICA_media_rxstream video;
+
+ /* PICA_media_now() when the current period started, 0 before the first */
+ uint64_t period_started;
+
+ /* one-way delays of the audio packets of the current period */
+ int64_t delay_sum;
+ uint32_t delay_count;
+ int64_t delay_min;
+ /* the smallest one of each of the last periods that had any */
+ int64_t delay_mins[PICA_MEDIA_DELAY_BASELINE_PERIODS];
+ int delay_mins_count;
+ int delay_mins_pos;
+};
+
struct PICA_media_listener
{
const struct PICA_acc *acc;
@@ -185,6 +231,9 @@ struct PICA_media_call
char video_codec[PICA_PROTO_CALL_CODECNAMESIZE + 1];
uint16_t video_width;
uint16_t video_height;
+
+ /* what has been received of the peer's media, for 0x79 */
+ struct PICA_media_rxstats rx;
};
struct PICA_media_channel
@@ -274,6 +323,22 @@ unsigned int PICA_media_call_write_info(struct PICA_c2c *c2c, unsigned char *buf
*/
int PICA_media_call_read_info(struct PICA_c2c *c2c, const unsigned char *buf, unsigned int len);
+/**
+ * Counts one accepted media packet of the peer's for the 0x79 reports.
+ * \param video 1 for 0x77, 0 for 0x76
+ * \param seq_num as in the packet, last fragment marker included
+ * \param size length of the packet's data, without the header
+ */
+void PICA_media_rx_packet(struct PICA_c2c *c2c, int video, uint16_t seq_num,
+ uint32_t timestamp, unsigned int size);
+
+/**
+ * When a report period is over, fills in the 0x79 for it and starts the next
+ * one. Starts the first period when called for the first time in a call.
+ * \return 1 if r has been filled in and is to be sent
+ */
+int PICA_media_rx_report(struct PICA_c2c *c2c, struct PICA_call_reception_report *r);
+
/** Releases everything PICA_media_call_prepare() made. */
void PICA_media_call_free(struct PICA_c2c *c2c);