diff options
author | Mark Spencer <markster@digium.com> | 2003-04-19 18:12:41 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2003-04-19 18:12:41 +0000 |
commit | a03e42860f5ee777481ce06d3a4f7d5dfa8ca824 (patch) | |
tree | c43c0e77dcc7b32910759996a289129edd197a19 /channels/iax2-parser.c | |
parent | dea29b88c50a34e14b6b15275f5d6956c569bdff (diff) |
IAX2 updates, dial fix
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/iax2-parser.c')
-rwxr-xr-x | channels/iax2-parser.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c index 1187a9098..1e512a044 100755 --- a/channels/iax2-parser.c +++ b/channels/iax2-parser.c @@ -23,6 +23,10 @@ #include "iax2-parser.h" +static int frames = 0; +static int iframes = 0; +static int oframes = 0; + static void internaloutput(const char *str) { printf(str); @@ -165,7 +169,7 @@ static void dump_ies(unsigned char *iedata, int len) outputf("\n"); } -void iax_showframe(struct ast_iax2_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen) +void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen) { char *frames[] = { "(0?)", @@ -504,3 +508,52 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen) return 0; } +void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f) +{ + fr->af.frametype = f->frametype; + fr->af.subclass = f->subclass; + fr->af.mallocd = 0; /* Our frame is static relative to the container */ + fr->af.datalen = f->datalen; + fr->af.samples = f->samples; + fr->af.offset = AST_FRIENDLY_OFFSET; + fr->af.src = f->src; + fr->af.data = fr->afdata; + if (fr->af.datalen) + memcpy(fr->af.data, f->data, fr->af.datalen); +} + +struct iax_frame *iax_frame_new(int direction, int datalen) +{ + struct iax_frame *fr; + fr = malloc(sizeof(struct iax_frame) + datalen); + if (fr) { + fr->direction = direction; + fr->retrans = -1; + frames++; + if (fr->direction == DIRECTION_INGRESS) + iframes++; + else + oframes++; + } + return fr; +} + +void iax_frame_free(struct iax_frame *fr) +{ + /* Note: does not remove from scheduler! */ + if (fr->direction == DIRECTION_INGRESS) + iframes--; + else if (fr->direction == DIRECTION_OUTGRESS) + oframes--; + else { + errorf("Attempt to double free frame detected\n"); + return; + } + fr->direction = 0; + free(fr); + frames--; +} + +int iax_get_frames(void) { return frames; } +int iax_get_iframes(void) { return iframes; } +int iax_get_oframes(void) { return oframes; } |