diff options
Diffstat (limited to 'pjmedia/include')
-rw-r--r-- | pjmedia/include/pjmedia/errno.h | 5 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/jbuf.h | 120 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/session.h | 45 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/types.h | 14 |
4 files changed, 71 insertions, 113 deletions
diff --git a/pjmedia/include/pjmedia/errno.h b/pjmedia/include/pjmedia/errno.h index d57a23b6..8e5479aa 100644 --- a/pjmedia/include/pjmedia/errno.h +++ b/pjmedia/include/pjmedia/errno.h @@ -276,6 +276,11 @@ PJ_BEGIN_DECL +/************************************************************ + * JITTER BUFFER + ***********************************************************/ + + PJ_END_DECL #endif /* __PJMEDIA_ERRNO_H__ */ diff --git a/pjmedia/include/pjmedia/jbuf.h b/pjmedia/include/pjmedia/jbuf.h index 8ad89f38..d725c51c 100644 --- a/pjmedia/include/pjmedia/jbuf.h +++ b/pjmedia/include/pjmedia/jbuf.h @@ -30,106 +30,38 @@ * @{ */ -#include <pj/types.h> +#include <pjmedia/types.h> PJ_BEGIN_DECL -/** - * Opaque declaration of internal frame type used by jitter buffer. - */ -struct pj_jbframe; - - -/** - * Miscelaneous operation result/status. - */ -typedef enum jb_op_status -{ - PJ_JB_STATUS_TOO_OLD = -2, /** The packet is too old. */ - PJ_JB_STATUS_TOO_SOON = -3, /** The packet is too soon. */ - PJ_JB_STATUS_FRAME_NULL = -4, /** No packet can be retrieved */ - PJ_JB_STATUS_FRAME_MISSING = -5, /** The specified packet is missing/lost */ -} jb_op_status; - - -/* - * Frame list, container abstraction for ordered list with fixed maximum - * size. It is used internally by the jitter buffer. - */ -typedef struct pj_jbframelist +enum pjmedia_jb_frame_type { - unsigned head, count, maxcount; - struct pj_jbframe *frames; -} pj_jbframelist; - - -/** - * Jitter buffer implementation. - */ -typedef struct pj_jitter_buffer -{ - pj_jbframelist lst; /** The frame list. */ - int level; /** Current, real-time jitter level. */ - int max_level; /** Maximum level for the period. */ - unsigned prefetch; /** Prefetch count currently used. */ - unsigned get_cnt; /** Number of get operation during prefetch state. */ - unsigned min; /** Minimum jitter size, in packets. */ - unsigned max; /** Maximum jitter size, in packets. */ - pj_uint32_t lastseq; /** Last sequence number put to jitter buffer. */ - unsigned upd_count; /** Internal counter to manage update interval. */ - int state; /** Jitter buffer state (1==operational) */ - int last_op; /** Last jitter buffer operation. */ -} pj_jitter_buffer; - - -/** - * Initialize jitter buffer with the specified parameters. - * This function will allocate internal frame buffer from the specified pool. - * @param jb The jitter buffer to be initialized. - * @param pool Pool where memory will be allocated for the frame buffer. - * @param min The minimum value of jitter buffer, in packets. - * @param max The maximum value of jitter buffer, in packets. - * @param maxcount The maximum number of delay, in packets, which must be - * greater than max. - * @return PJ_SUCCESS on success. - */ -PJ_DECL(pj_status_t) pj_jb_init(pj_jitter_buffer *jb, pj_pool_t *pool, - unsigned min, unsigned max, unsigned maxcount); - -/** - * Reset jitter buffer according to the parameters specified when the jitter - * buffer was initialized. Any packets currently in the buffer will be - * discarded. - */ -PJ_DECL(void) pj_jb_reset(pj_jitter_buffer *jb); - -/** - * Put a pointer to the buffer with the specified sequence number. The pointer - * normally points to a buffer held by application, and this pointer will be - * returned later on when pj_jb_get() is called. The jitter buffer will not try - * to interpret the content of this pointer. - * @return: - * - PJ_SUCCESS on success. - * - PJ_JB_STATUS_TOO_OLD when the packet is too old. - * - PJ_JB_STATUS_TOO_SOON when the packet is too soon. - */ -PJ_DECL(pj_status_t) pj_jb_put( pj_jitter_buffer *jb, pj_uint32_t extseq, void *buf ); - -/** - * Get the earliest data from the jitter buffer. ONLY when the operation succeeds, - * the function returns both sequence number and a pointer in the parameters. - * This returned data corresponds to sequence number and pointer that were - * given to jitter buffer in the previous pj_jb_put operation. - * @return - * - PJ_SUCCESS on success - * - PJ_JB_STATUS_FRAME_NULL when there is no frames to be returned. - * - PJ_JB_STATUS_FRAME_MISSING if the jitter buffer detects that the packet - * is lost. Application may run packet concealment algorithm when it - * receives this status. - */ -PJ_DECL(pj_status_t) pj_jb_get( pj_jitter_buffer *jb, pj_uint32_t *extseq, void **buf ); + PJMEDIA_JB_MISSING_FRAME = 0, + PJMEDIA_JB_NORMAL_FRAME = 1, + PJMEDIA_JB_ZERO_FRAME = 2, +}; + + +#define PJMEDIA_JB_DEFAULT_INIT_PREFETCH 15 + + +PJ_DECL(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool, + int frame_size, + int initial_prefetch, + int max_count, + pjmedia_jbuf **p_jb); +PJ_DECL(pj_status_t) pjmedia_jbuf_destroy(pjmedia_jbuf *jb); +PJ_DECL(pj_status_t) pjmedia_jbuf_put_frame(pjmedia_jbuf *jb, + const void *frame, + pj_size_t frame_size, + int frame_seq); +PJ_DECL(pj_status_t) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb, + void *frame, + char *p_frame_type); +PJ_DECL(unsigned) pjmedia_jbuf_get_prefetch_size(pjmedia_jbuf *jb); +PJ_DECL(unsigned) pjmedia_jbuf_get_current_size(pjmedia_jbuf *jb); diff --git a/pjmedia/include/pjmedia/session.h b/pjmedia/include/pjmedia/session.h index cbef4424..17fae89c 100644 --- a/pjmedia/include/pjmedia/session.h +++ b/pjmedia/include/pjmedia/session.h @@ -39,6 +39,17 @@ PJ_BEGIN_DECL /** + * Session info, retrieved from a session by calling + * #pjmedia_session_get_info(). + */ +struct pjmedia_session_info +{ + unsigned stream_cnt; + pjmedia_stream_info stream_info[PJSDP_MAX_MEDIA]; +}; + + +/** * Create new session offering based on the local and remote SDP. * The session will start immediately. * @@ -66,6 +77,18 @@ PJ_DECL(pj_status_t) pjmedia_session_create( pjmedia_endpt *endpt, /** + * Get session info. + * + * @param session The session which info is being queried. + * @param info Pointer to receive session info. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_session_get_info( pjmedia_session *session, + pjmedia_session_info *info ); + + +/** * Activate all streams in media session for the specified direction. * * @param session The media session. @@ -137,28 +160,12 @@ PJ_DECL(pj_status_t) pjmedia_session_enum_streams(const pjmedia_session *session * indicators such as packet count, packet lost, jitter, delay, etc. * * @param session The media session. - * @param count On input, specifies the number of elements in - * the array. On output, the number will be filled - * with number of streams in the session. - * @param stat Array of stream statistics. - * - * @return PJ_SUCCESS on success. - */ -PJ_DECL(pj_status_t) pjmedia_session_get_stat(const pjmedia_session *session, - unsigned *count, - pjmedia_stream_stat stat[]); - -/** - * Get individual stream statistics. The stream statistic shows various - * indicators such as packet count, packet lost, jitter, delay, etc. - * - * @param s The media session. - * @param index The stream index. - * @param stat Stream statistics. + * @param index Stream index. + * @param stat Stream statistic. * * @return PJ_SUCCESS on success. */ -PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat(const pjmedia_session *s, +PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat(pjmedia_session *session, unsigned index, pjmedia_stream_stat *stat); diff --git a/pjmedia/include/pjmedia/types.h b/pjmedia/include/pjmedia/types.h index 726a33ec..cdbb129d 100644 --- a/pjmedia/include/pjmedia/types.h +++ b/pjmedia/include/pjmedia/types.h @@ -166,6 +166,11 @@ typedef struct pjmedia_channel_stat pjmedia_channel_stat; typedef struct pjmedia_session pjmedia_session; /** + * Media session info. + */ +typedef struct pjmedia_session_info pjmedia_session_info; + +/** * Forward declaration for SDP attribute (sdp.h) */ typedef struct pjmedia_sdp_attr pjmedia_sdp_attr; @@ -205,6 +210,15 @@ typedef enum pjmedia_sdp_neg_state pjmedia_sdp_neg_state; */ typedef struct pjmedia_sdp_neg pjmedia_sdp_neg; +/** + * Types of frame returned from jitter buffer (jbuf.h). + */ +typedef enum pjmedia_jb_frame_type pjmedia_jb_frame_type; + +/** + * Opaque declaration for jitter buffer. + */ +typedef struct pjmedia_jbuf pjmedia_jbuf; #endif /* __PJMEDIA_TYPES_H__ */ |