mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
fix breakage from slin endianness commit earlier today (sorry :-()
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5375 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -559,7 +559,7 @@ static int phone_write_buf(struct phone_pvt *p, const char *buf, int len, int fr
|
|||||||
if (space < len)
|
if (space < len)
|
||||||
len = space;
|
len = space;
|
||||||
if (swap)
|
if (swap)
|
||||||
ast_memcpy_byteswap(p->obuf+p->obuflen, buf, len/2);
|
ast_swapcopy_samples(p->obuf+p->obuflen, buf, len/2);
|
||||||
else
|
else
|
||||||
memcpy(p->obuf + p->obuflen, buf, len);
|
memcpy(p->obuf + p->obuflen, buf, len);
|
||||||
p->obuflen += len;
|
p->obuflen += len;
|
||||||
|
@@ -859,7 +859,7 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
|
|||||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
/* We need to byte-swap slinear samples from network byte order */
|
/* We need to byte-swap slinear samples from network byte order */
|
||||||
if (fr->af.subclass == AST_FORMAT_SLINEAR) {
|
if (fr->af.subclass == AST_FORMAT_SLINEAR) {
|
||||||
ast_memcpy_byteswap(fr->af.data, f->data, fr->af.samples);
|
ast_swapcopy_samples(fr->af.data, f->data, fr->af.samples);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
memcpy(fr->af.data, f->data, fr->af.datalen);
|
memcpy(fr->af.data, f->data, fr->af.datalen);
|
||||||
|
4
frame.c
4
frame.c
@@ -402,11 +402,11 @@ int ast_fr_fdhangup(int fd)
|
|||||||
return ast_fr_fdwrite(fd, &hangup);
|
return ast_fr_fdwrite(fd, &hangup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_swapcopy_samples(void *dst, void *src, int samples)
|
void ast_swapcopy_samples(void *dst, const void *src, int samples)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned short *dst_s = dst;
|
unsigned short *dst_s = dst;
|
||||||
unsigned short *src_s = src;
|
const unsigned short *src_s = src;
|
||||||
|
|
||||||
for (i=0; i<samples; i++)
|
for (i=0; i<samples; i++)
|
||||||
dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
|
dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
|
||||||
|
@@ -301,7 +301,7 @@ int ast_fr_fdwrite(int fd, struct ast_frame *frame);
|
|||||||
*/
|
*/
|
||||||
int ast_fr_fdhangup(int fd);
|
int ast_fr_fdhangup(int fd);
|
||||||
|
|
||||||
void ast_swapcopy_samples(void *dst, void *src, int samples);
|
void ast_swapcopy_samples(void *dst, const void *src, int samples);
|
||||||
|
|
||||||
/* Helpers for byteswapping native samples to/from
|
/* Helpers for byteswapping native samples to/from
|
||||||
little-endian and big-endian. */
|
little-endian and big-endian. */
|
||||||
|
22
rtp.c
22
rtp.c
@@ -76,6 +76,7 @@ struct ast_rtp {
|
|||||||
unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
|
unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
|
||||||
unsigned int ssrc;
|
unsigned int ssrc;
|
||||||
unsigned int lastts;
|
unsigned int lastts;
|
||||||
|
unsigned int lastdigitts;
|
||||||
unsigned int lastrxts;
|
unsigned int lastrxts;
|
||||||
unsigned int lastividtimestamp;
|
unsigned int lastividtimestamp;
|
||||||
unsigned int lastovidtimestamp;
|
unsigned int lastovidtimestamp;
|
||||||
@@ -1014,6 +1015,7 @@ void ast_rtp_reset(struct ast_rtp *rtp)
|
|||||||
memset(&rtp->txcore, 0, sizeof(rtp->txcore));
|
memset(&rtp->txcore, 0, sizeof(rtp->txcore));
|
||||||
memset(&rtp->dtmfmute, 0, sizeof(rtp->dtmfmute));
|
memset(&rtp->dtmfmute, 0, sizeof(rtp->dtmfmute));
|
||||||
rtp->lastts = 0;
|
rtp->lastts = 0;
|
||||||
|
rtp->lastdigitts = 0;
|
||||||
rtp->lastrxts = 0;
|
rtp->lastrxts = 0;
|
||||||
rtp->lastividtimestamp = 0;
|
rtp->lastividtimestamp = 0;
|
||||||
rtp->lastovidtimestamp = 0;
|
rtp->lastovidtimestamp = 0;
|
||||||
@@ -1107,7 +1109,7 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
|||||||
/* Get a pointer to the header */
|
/* Get a pointer to the header */
|
||||||
rtpheader = (unsigned int *)data;
|
rtpheader = (unsigned int *)data;
|
||||||
rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload << 16) | (rtp->seqno++));
|
rtpheader[0] = htonl((2 << 30) | (1 << 23) | (payload << 16) | (rtp->seqno++));
|
||||||
rtpheader[1] = htonl(rtp->lastts);
|
rtpheader[1] = htonl(rtp->lastdigitts);
|
||||||
rtpheader[2] = htonl(rtp->ssrc);
|
rtpheader[2] = htonl(rtp->ssrc);
|
||||||
rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
|
rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
|
||||||
for (x=0;x<6;x++) {
|
for (x=0;x<6;x++) {
|
||||||
@@ -1117,20 +1119,24 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
|||||||
ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||||
if(rtp_debug_test_addr(&rtp->them))
|
if(rtp_debug_test_addr(&rtp->them))
|
||||||
ast_verbose("Sent RTP packet to %s:%d (type %d, seq %d, ts %d, len %d)\n"
|
ast_verbose("Sent RTP packet to %s:%d (type %d, seq %d, ts %d, len %d)\n"
|
||||||
, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastts,res - hdrlen);
|
, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (x == 2) {
|
|
||||||
/* Clear marker bit and increment seqno */
|
/* Clear marker bit and increment seqno */
|
||||||
rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno++));
|
rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno++));
|
||||||
|
/* For the last three packets, set the duration and the end bit */
|
||||||
|
if (x == 2) {
|
||||||
/* Make duration 800 (100ms) */
|
/* Make duration 800 (100ms) */
|
||||||
rtpheader[3] |= htonl((800));
|
rtpheader[3] |= htonl((800));
|
||||||
/* Set the End bit for the last 3 */
|
/* Set the End bit for the last 3 */
|
||||||
rtpheader[3] |= htonl((1 << 23));
|
rtpheader[3] |= htonl((1 << 23));
|
||||||
} else if ( x < 5) {
|
|
||||||
rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno++));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Increment the digit timestamp by 100ms, to ensure that digits
|
||||||
|
sent sequentially with no intervening non-digit packets do not
|
||||||
|
get sent with the same timestamp.
|
||||||
|
*/
|
||||||
|
rtp->lastdigitts += 800;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1256,6 +1262,12 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* If the timestamp for non-digit packets has moved beyond the timestamp
|
||||||
|
for digits, update the digit timestamp.
|
||||||
|
*/
|
||||||
|
if (rtp->lastts > rtp->lastdigitts)
|
||||||
|
rtp->lastdigitts = rtp->lastts;
|
||||||
|
|
||||||
/* Get a pointer to the header */
|
/* Get a pointer to the header */
|
||||||
rtpheader = (unsigned char *)(f->data - hdrlen);
|
rtpheader = (unsigned char *)(f->data - hdrlen);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user