Skip to content
Snippets Groups Projects
Commit 86343ef2 authored by Alexandre Bourget's avatar Alexandre Bourget
Browse files

Fix comments on libiax2

parent a1f6c4ac
Branches
No related tags found
No related merge requests found
...@@ -158,57 +158,57 @@ ...@@ -158,57 +158,57 @@
/* Full frames are always delivered reliably */ /* Full frames are always delivered reliably */
struct ast_iax2_full_hdr { struct ast_iax2_full_hdr {
unsigned short scallno; /** Source call number -- high bit must be 1 */ unsigned short scallno; /**< Source call number -- high bit must be 1 */
unsigned short dcallno; /** Destination call number -- high bit is 1 if retransmission */ unsigned short dcallno; /**< Destination call number -- high bit is 1 if retransmission */
unsigned int ts; /** 32-bit timestamp in milliseconds (from 1st transmission) */ unsigned int ts; /**< 32-bit timestamp in milliseconds (from 1st transmission) */
unsigned char oseqno; /** Packet number (outgoing) */ unsigned char oseqno; /**< Packet number (outgoing) */
unsigned char iseqno; /** Packet number (next incoming expected) */ unsigned char iseqno; /**< Packet number (next incoming expected) */
char type; /** Frame type */ char type; /**< Frame type */
unsigned char csub; /** Compressed subclass */ unsigned char csub; /**< Compressed subclass */
unsigned char iedata[0]; unsigned char iedata[0];
} __PACKED; } __PACKED;
/* Mini header is used only for voice frames -- delivered unreliably */ /* Mini header is used only for voice frames -- delivered unreliably */
struct ast_iax2_mini_hdr { struct ast_iax2_mini_hdr {
unsigned short callno; /** Source call number -- high bit must be 0, rest must be non-zero */ unsigned short callno; /**< Source call number -- high bit must be 0, rest must be non-zero */
unsigned short ts; /** 16-bit Timestamp (high 16 bits from last ast_iax2_full_hdr) */ unsigned short ts; /**< 16-bit Timestamp (high 16 bits from last ast_iax2_full_hdr) */
/** Frametype implicitly VOICE_FRAME */ /**< Frametype implicitly VOICE_FRAME */
/** subclass implicit from last ast_iax2_full_hdr */ /**< subclass implicit from last ast_iax2_full_hdr */
unsigned char data[0]; unsigned char data[0];
} __PACKED; } __PACKED;
struct ast_iax2_meta_hdr { struct ast_iax2_meta_hdr {
unsigned short zeros; /** Zeros field -- must be zero */ unsigned short zeros; /**< Zeros field -- must be zero */
unsigned char metacmd; /** Meta command */ unsigned char metacmd; /**< Meta command */
unsigned char cmddata; /** Command Data */ unsigned char cmddata; /**< Command Data */
unsigned char data[0]; unsigned char data[0];
} __PACKED; } __PACKED;
struct ast_iax2_video_hdr { struct ast_iax2_video_hdr {
unsigned short zeros; /** Zeros field -- must be zero */ unsigned short zeros; /**< Zeros field -- must be zero */
unsigned short callno; /** Video call number */ unsigned short callno; /**< Video call number */
unsigned short ts; /** Timestamp and mark if present */ unsigned short ts; /**< Timestamp and mark if present */
unsigned char data[0]; unsigned char data[0];
} __PACKED; } __PACKED;
struct ast_iax2_meta_trunk_hdr { struct ast_iax2_meta_trunk_hdr {
unsigned int ts; /** 32-bit timestamp for all messages */ unsigned int ts; /**< 32-bit timestamp for all messages */
unsigned char data[0]; unsigned char data[0];
} __PACKED; } __PACKED;
struct ast_iax2_meta_trunk_entry { struct ast_iax2_meta_trunk_entry {
unsigned short callno; /** Call number */ unsigned short callno; /**< Call number */
unsigned short len; /** Length of data for this callno */ unsigned short len; /**< Length of data for this callno */
} __PACKED; } __PACKED;
#define IAX_FIRMWARE_MAGIC 0x69617879 #define IAX_FIRMWARE_MAGIC 0x69617879
struct ast_iax2_firmware_header { struct ast_iax2_firmware_header {
unsigned int magic; /** Magic number */ unsigned int magic; /**< Magic number */
unsigned short version; /** Software version */ unsigned short version; /**< Software version */
unsigned char devname[16]; /** Device */ unsigned char devname[16]; /**< Device */
unsigned int datalen; /** Data length of file beyond header */ unsigned int datalen; /**< Data length of file beyond header */
unsigned char chksum[16]; /** Checksum of all data */ unsigned char chksum[16]; /**< Checksum of all data */
unsigned char data[0]; unsigned char data[0];
} __PACKED; } __PACKED;
......
...@@ -55,43 +55,43 @@ enum jb_frame_type { ...@@ -55,43 +55,43 @@ enum jb_frame_type {
typedef struct jb_conf { typedef struct jb_conf {
/* settings */ /* settings */
long max_jitterbuf; /* defines a hard clamp to use in setting the jitter buffer delay */ long max_jitterbuf; /**< defines a hard clamp to use in setting the jitter buffer delay */
long resync_threshold; /* the jb will resync when delay increases to (2 * jitter) + this param */ long resync_threshold; /**< the jb will resync when delay increases to (2 * jitter) + this param */
long max_contig_interp; /* the max interp frames to return in a row */ long max_contig_interp; /**< the max interp frames to return in a row */
long target_extra; /* amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */ long target_extra; /**< amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */
} jb_conf; } jb_conf;
typedef struct jb_info { typedef struct jb_info {
jb_conf conf; jb_conf conf;
/* statistics */ /* statistics */
long frames_in; /* number of frames input to the jitterbuffer.*/ long frames_in; /**< number of frames input to the jitterbuffer.*/
long frames_out; /* number of frames output from the jitterbuffer.*/ long frames_out; /**< number of frames output from the jitterbuffer.*/
long frames_late; /* number of frames which were too late, and dropped.*/ long frames_late; /**< number of frames which were too late, and dropped.*/
long frames_lost; /* number of missing frames.*/ long frames_lost; /**< number of missing frames.*/
long frames_dropped; /* number of frames dropped (shrinkage) */ long frames_dropped; /**< number of frames dropped (shrinkage) */
long frames_ooo; /* number of frames received out-of-order */ long frames_ooo; /**< number of frames received out-of-order */
long frames_cur; /* number of frames presently in jb, awaiting delivery.*/ long frames_cur; /**< number of frames presently in jb, awaiting delivery.*/
long jitter; /* jitter measured within current history interval*/ long jitter; /**< jitter measured within current history interval*/
long min; /* minimum lateness within current history interval */ long min; /**< minimum lateness within current history interval */
long current; /* the present jitterbuffer adjustment */ long current; /**< the present jitterbuffer adjustment */
long target; /* the target jitterbuffer adjustment */ long target; /**< the target jitterbuffer adjustment */
long losspct; /* recent lost frame percentage (* 1000) */ long losspct; /**< recent lost frame percentage (* 1000) */
long next_voice_ts; /* the ts of the next frame to be read from the jb - in receiver's time */ long next_voice_ts; /**< the ts of the next frame to be read from the jb - in receiver's time */
long last_voice_ms; /* the duration of the last voice frame */ long last_voice_ms; /**< the duration of the last voice frame */
long silence_begin_ts; /* the time of the last CNG frame, when in silence */ long silence_begin_ts; /**< the time of the last CNG frame, when in silence */
long last_adjustment; /* the time of the last adjustment */ long last_adjustment; /**< the time of the last adjustment */
long last_delay; /* the last now added to history */ long last_delay; /**< the last now added to history */
long cnt_delay_discont; /* the count of discontinuous delays */ long cnt_delay_discont; /**< the count of discontinuous delays */
long resync_offset; /* the amount to offset ts to support resyncs */ long resync_offset; /**< the amount to offset ts to support resyncs */
long cnt_contig_interp; /* the number of contiguous interp frames returned */ long cnt_contig_interp; /**< the number of contiguous interp frames returned */
} jb_info; } jb_info;
typedef struct jb_frame { typedef struct jb_frame {
void *data; /* the frame data */ void *data; /**< the frame data */
long ts; /* the relative delivery time expected */ long ts; /**< the relative delivery time expected */
long ms; /* the time covered by this frame, in sec/8000 */ long ms; /**< the time covered by this frame, in sec/8000 */
enum jb_frame_type type; /* the type of frame */ enum jb_frame_type type; /**< the type of frame */
struct jb_frame *next, *prev; struct jb_frame *next, *prev;
} jb_frame; } jb_frame;
...@@ -99,29 +99,30 @@ typedef struct jitterbuf { ...@@ -99,29 +99,30 @@ typedef struct jitterbuf {
jb_info info; jb_info info;
/* history */ /* history */
long history[JB_HISTORY_SZ]; /* history */ long history[JB_HISTORY_SZ]; /**< history */
int hist_ptr; /* points to index in history for next entry */ int hist_ptr; /**< points to index in history for next entry */
long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /* a sorted buffer of the max delays (highest first) */ long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /**< a sorted buffer of the max delays (highest first) */
long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /* a sorted buffer of the min delays (lowest first) */ long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /**< a sorted buffer of the min delays (lowest first) */
int hist_maxbuf_valid; /* are the "maxbuf"/minbuf valid? */ int hist_maxbuf_valid; /**< are the "maxbuf"/minbuf valid? */
jb_frame *frames; /* queued frames */ jb_frame *frames; /**< queued frames */
jb_frame *free; /* free frames (avoid malloc?) */ jb_frame *free; /**< free frames (avoid malloc?) */
} jitterbuf; } jitterbuf;
/* new jitterbuf */ /** new jitterbuf */
jitterbuf * jb_new(void); jitterbuf * jb_new(void);
/* destroy jitterbuf */ /** destroy jitterbuf */
void jb_destroy(jitterbuf *jb); void jb_destroy(jitterbuf *jb);
/* reset jitterbuf */ /** reset jitterbuf */
/* NOTE: The jitterbuffer should be empty before you call this, otherwise /* NOTE: The jitterbuffer should be empty before you call this, otherwise
* you will leak queued frames, and some internal structures */ * you will leak queued frames, and some internal structures */
void jb_reset(jitterbuf *jb); void jb_reset(jitterbuf *jb);
/* queue a frame data=frame data, timings (in ms): ms=length of frame (for voice), ts=ts (sender's time) /** queue a frame data=frame data, timings (in ms): ms=length of frame (for voice), ts=ts (sender's time)
*
* now=now (in receiver's time) return value is one of * now=now (in receiver's time) return value is one of
* JB_OK: Frame added. Last call to jb_next() still valid * JB_OK: Frame added. Last call to jb_next() still valid
* JB_DROP: Drop this frame immediately * JB_DROP: Drop this frame immediately
...@@ -129,7 +130,8 @@ void jb_reset(jitterbuf *jb); ...@@ -129,7 +130,8 @@ void jb_reset(jitterbuf *jb);
*/ */
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now); enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now);
/* get a frame for time now (receiver's time) return value is one of /** get a frame for time now (receiver's time) return value is one of
*
* JB_OK: You've got frame! * JB_OK: You've got frame!
* JB_DROP: Here's an audio frame you should just drop. Ask me again for this time.. * JB_DROP: Here's an audio frame you should just drop. Ask me again for this time..
* JB_NOFRAME: There's no frame scheduled for this time. * JB_NOFRAME: There's no frame scheduled for this time.
...@@ -138,7 +140,7 @@ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type t ...@@ -138,7 +140,7 @@ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type t
*/ */
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl); enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frame, long now, long interpl);
/* unconditionally get frames from jitterbuf until empty */ /** unconditionally get frames from jitterbuf until empty */
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout); enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout);
/* when is the next frame due out, in receiver's time (0=EMPTY) /* when is the next frame due out, in receiver's time (0=EMPTY)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment