diff options
Diffstat (limited to 'pjmedia/include')
-rw-r--r-- | pjmedia/include/pjmedia/rtcp.h | 86 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/rtp.h | 75 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/session.h | 2 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/stream.h | 24 |
4 files changed, 137 insertions, 50 deletions
diff --git a/pjmedia/include/pjmedia/rtcp.h b/pjmedia/include/pjmedia/rtcp.h index 78498a80..d327d4f6 100644 --- a/pjmedia/include/pjmedia/rtcp.h +++ b/pjmedia/include/pjmedia/rtcp.h @@ -146,6 +146,73 @@ typedef struct pjmedia_rtcp_ntp_rec pjmedia_rtcp_ntp_rec; /** + * Unidirectional RTP stream statistics. + */ +struct pjmedia_rtcp_stream_stat +{ + pj_time_val update; /**< Time of last update. */ + unsigned update_cnt; /**< Number of updates (to calculate avg) */ + pj_uint32_t pkt; /**< Total number of packets */ + pj_uint32_t bytes; /**< Total number of payload/bytes */ + unsigned discard; /**< Number of discarded packets. */ + unsigned loss; /**< Number of packets lost */ + unsigned reorder; /**< Number of out of order packets */ + unsigned dup; /**< Number of duplicates packets */ + + struct { + unsigned min; /**< Minimum loss period (in usec) */ + unsigned avg; /**< Average loss period (in usec) */ + unsigned max; /**< Maximum loss period (in usec) */ + unsigned last; /**< Last loss period (in usec) */ + } loss_period; /**< Lost period history. */ + + struct { + unsigned burst:1; /**< Burst/sequential packet lost detected */ + unsigned random:1; /**< Random packet lost detected. */ + } loss_type; /**< Types of loss detected. */ + + struct { + unsigned min; /**< Minimum jitter (in usec) */ + unsigned avg; /**< Average jitter (in usec) */ + unsigned max; /**< Maximum jitter (in usec) */ + unsigned last; /**< Last jitter (in usec) */ + } jitter; /**< Jitter history. */ +}; + + +/** + * @see pjmedia_rtcp_stream_stat + */ +typedef struct pjmedia_rtcp_stream_stat pjmedia_rtcp_stream_stat; + + + +/** + * Bidirectional RTP stream statistics. + */ +struct pjmedia_rtcp_stat +{ + pjmedia_rtcp_stream_stat tx; /**< Encoder stream statistics. */ + pjmedia_rtcp_stream_stat rx; /**< Decoder stream statistics. */ + + struct { + unsigned min; /**< Minimum round-trip delay (in usec) */ + unsigned avg; /**< Average round-trip delay (in usec) */ + unsigned max; /**< Maximum round-trip delay (in usec) */ + unsigned last; /**< Last round-trip delay (in usec) */ + } rtt; /**< Round trip delay history. */ + + unsigned rtt_update_cnt; /**< Nb of times rtt is updated. */ +}; + + +/** + * @see pjmedia_rtcp_stat + */ +typedef struct pjmedia_rtcp_stat pjmedia_rtcp_stat; + + +/** * RTCP session is used to monitor the RTP session of one endpoint. There * should only be one RTCP session for a bidirectional RTP streams. */ @@ -156,6 +223,7 @@ struct pjmedia_rtcp_session pjmedia_rtp_seq_session seq_ctrl; /**< RTCP sequence number control. */ unsigned clock_rate; /**< Clock rate of the stream */ + unsigned pkt_size; /**< Avg pkt size, in samples. */ pj_uint32_t received; /**< # pkt received */ pj_uint32_t exp_prior; /**< # pkt expected at last interval*/ pj_uint32_t rx_prior; /**< # pkt received at last interval*/ @@ -166,7 +234,8 @@ struct pjmedia_rtcp_session pj_uint32_t rx_lsr; /**< NTP ts in last SR received */ pj_timestamp rx_lsr_time;/**< Time when last SR is received */ pj_uint32_t peer_ssrc; /**< Peer SSRC */ - unsigned rtt_us; /**< End-to-end delay, in usec. */ + + pjmedia_rtcp_stat stat; /**< Bidirectional stream stat. */ }; /** @@ -178,11 +247,14 @@ typedef struct pjmedia_rtcp_session pjmedia_rtcp_session; /** * Initialize RTCP session. * - * @param session The session - * @param ssrc The SSRC used in to identify the session. + * @param session The session + * @param clock_rate Codec clock rate in samples per second. + * @param samples_per_frame Average number of samples per frame. + * @param ssrc The SSRC used in to identify the session. */ PJ_DECL(void) pjmedia_rtcp_init( pjmedia_rtcp_session *session, unsigned clock_rate, + unsigned samples_per_frame, pj_uint32_t ssrc ); @@ -201,10 +273,12 @@ PJ_DECL(void) pjmedia_rtcp_fini( pjmedia_rtcp_session *session); * @param session The session. * @param seq The RTP packet sequence number, in host byte order. * @param ts The RTP packet timestamp, in host byte order. + * @param payload Size of the payload. */ PJ_DECL(void) pjmedia_rtcp_rx_rtp( pjmedia_rtcp_session *session, - pj_uint16_t seq, - pj_uint32_t ts ); + unsigned seq, + unsigned ts, + unsigned payload); /** @@ -216,7 +290,7 @@ PJ_DECL(void) pjmedia_rtcp_rx_rtp( pjmedia_rtcp_session *session, * RTP header) in bytes. */ PJ_DECL(void) pjmedia_rtcp_tx_rtp( pjmedia_rtcp_session *session, - pj_uint16_t ptsize ); + unsigned ptsize ); /** diff --git a/pjmedia/include/pjmedia/rtp.h b/pjmedia/include/pjmedia/rtp.h index 34c576bd..87a73c81 100644 --- a/pjmedia/include/pjmedia/rtp.h +++ b/pjmedia/include/pjmedia/rtp.h @@ -180,6 +180,48 @@ typedef struct pjmedia_rtp_session pjmedia_rtp_session; /** + * This structure is used to receive additional information about the + * state of incoming RTP packet. + */ +struct pjmedia_rtp_status +{ + union { + struct flag { + int bad:1; /**< General flag to indicate that sequence is + bad, and application should not process + this packet. More information will be given + in other flags. */ + int badpt:1; /**< Bad payload type. */ + int dup:1; /**< Indicates duplicate packet */ + int outorder:1; /**< Indicates out of order packet */ + int probation:1;/**< Indicates that session is in probation + until more packets are received. */ + int restart:1; /**< Indicates that sequence number has made + a large jump, and internal base sequence + number has been adjusted. */ + } flag; /**< Status flags. */ + + pj_uint16_t value; /**< Status value, to conveniently address all + flags. */ + + } status; /**< Status information union. */ + + pj_uint16_t diff; /**< Sequence number difference from previous + packet. Normally the value should be 1. + Value greater than one may indicate packet + loss. If packet with lower sequence is + received, the value will be set to zero. + If base sequence has been restarted, the + value will be one. */ +}; + +/** + * @see pjmedia_rtp_status + */ +typedef struct pjmedia_rtp_status pjmedia_rtp_status; + + +/** * This function will initialize the RTP session according to given parameters. * * @param ses The session. @@ -241,12 +283,12 @@ PJ_DECL(pj_status_t) pjmedia_rtp_decode_rtp( pjmedia_rtp_session *ses, * * @param ses The session. * @param hdr The RTP header of the incoming packet. - * - * @return PJ_SUCCESS if the packet is valid and can be processed, - * otherwise will return the appropriate status code. + * @param seq_st Optional structure to receive the status of the RTP packet + * processing. */ -PJ_DECL(pj_status_t) pjmedia_rtp_session_update( pjmedia_rtp_session *ses, - const pjmedia_rtp_hdr *hdr); +PJ_DECL(void) pjmedia_rtp_session_update( pjmedia_rtp_session *ses, + const pjmedia_rtp_hdr *hdr, + pjmedia_rtp_status *seq_st); /* @@ -265,25 +307,16 @@ void pjmedia_rtp_seq_init(pjmedia_rtp_seq_session *seq_ctrl, /** - * Internal function to restart the sequence number control, shared by RTCP - * implementation. - * - * @param seq_ctrl The sequence control instance. - * @param seq Sequence number to restart. - */ -void pjmedia_rtp_seq_restart(pjmedia_rtp_seq_session *seq_ctrl, - pj_uint16_t seq); - -/** * Internal function update sequence control, shared by RTCP implementation. * - * @param seq_ctrl The sequence control instance. - * @param seq Sequence number to update. - * - * @return PJ_SUCCESS if the sequence number can be accepted. + * @param seq_ctrl The sequence control instance. + * @param seq Sequence number to update. + * @param seq_status Optional structure to receive additional information + * about the packet. */ -pj_status_t pjmedia_rtp_seq_update(pjmedia_rtp_seq_session *seq_ctrl, - pj_uint16_t seq); +void pjmedia_rtp_seq_update( pjmedia_rtp_seq_session *seq_ctrl, + pj_uint16_t seq, + pjmedia_rtp_status *seq_status); /** * @} diff --git a/pjmedia/include/pjmedia/session.h b/pjmedia/include/pjmedia/session.h index 898744d4..762f9b8d 100644 --- a/pjmedia/include/pjmedia/session.h +++ b/pjmedia/include/pjmedia/session.h @@ -217,7 +217,7 @@ PJ_DECL(pj_status_t) pjmedia_session_get_port( pjmedia_session *session, */ PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat(pjmedia_session *session, unsigned index, - pjmedia_stream_stat *sta); + pjmedia_rtcp_stat *stat); /** * Dial DTMF digit to the stream, using RFC 2833 mechanism. diff --git a/pjmedia/include/pjmedia/stream.h b/pjmedia/include/pjmedia/stream.h index 91f50dc3..90d2a2f6 100644 --- a/pjmedia/include/pjmedia/stream.h +++ b/pjmedia/include/pjmedia/stream.h @@ -29,6 +29,7 @@ #include <pjmedia/codec.h> #include <pjmedia/endpoint.h> #include <pjmedia/port.h> +#include <pjmedia/rtcp.h> #include <pj/sock.h> PJ_BEGIN_DECL @@ -82,27 +83,6 @@ struct pjmedia_stream_info /** - * Individual channel statistic. - */ -struct pjmedia_channel_stat -{ - pj_uint32_t pkt; /**< Total number of packets. */ - pj_uint32_t bytes; /**< Total number of bytes, including RTP hdr. */ - pj_uint32_t lost; /**< Total number of packet lost */ -}; - -/** - * Stream statistic. - */ -struct pjmedia_stream_stat -{ - pjmedia_channel_stat enc; /**< Encoder statistics. */ - pjmedia_channel_stat dec; /**< Decoder statistics. */ -}; - - - -/** * Create a media stream based on the specified stream parameter. * All channels in the stream initially will be inactive. * @@ -164,7 +144,7 @@ PJ_DECL(pj_status_t) pjmedia_stream_start(pjmedia_stream *stream); * @return PJ_SUCCESS on success. */ PJ_DECL(pj_status_t) pjmedia_stream_get_stat( const pjmedia_stream *stream, - pjmedia_stream_stat *stat); + pjmedia_rtcp_stat *stat); /** * Pause the individual channel in the stream. |