Created
January 5, 2010 10:39
-
-
Save anonymous/269310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: channels/chan_rtmp.c | |
=================================================================== | |
--- channels/chan_rtmp.c (revision 234093) | |
+++ channels/chan_rtmp.c (working copy) | |
@@ -73,6 +73,8 @@ | |
static char context[AST_MAX_EXTENSION] = "default"; | |
static char type[] = "RTMP"; | |
+#define RTMP_FRAME_BUFFER_MAX 4096 | |
+ | |
/** | |
* This structure stores information about an RTMP connection : | |
* - the number of streams (FLEX NetStream objects) that form the Asterisk | |
@@ -111,6 +113,8 @@ | |
* Read from pipe[0], write to pipe[1] | |
*/ | |
int pipe[2]; | |
+ | |
+ unsigned char buf[RTMP_FRAME_BUFFER_MAX]; | |
}; | |
#ifdef LOW_MEMORY | |
@@ -524,14 +528,9 @@ | |
static struct ast_frame *rtmp_read(struct ast_channel *ast) { | |
struct rtmp_pvt *p = ast->tech_pvt; | |
int res; | |
- char *buf = NULL; | |
static struct ast_frame f; | |
- buf = ast_malloc(4096); | |
- if (!buf) { | |
- return NULL; | |
- } | |
- | |
+ memset(p->buf, 0, sizeof(p->buf)); | |
f.frametype = AST_FRAME_NULL; | |
f.subclass.codec = 0; | |
f.samples = 0; | |
@@ -543,7 +542,7 @@ | |
f.delivery.tv_sec = 0; | |
f.delivery.tv_usec = 0; | |
- res = read(p->pipe[0], buf, 4096); | |
+ res = read(p->pipe[0], p->buf, RTMP_FRAME_BUFFER_MAX); | |
if (!res) { | |
ast_log(LOG_ERROR, "Failed to read frame from channel %s\n", ast->name); | |
return &f; | |
@@ -553,11 +552,10 @@ | |
f.subclass.codec = AST_FORMAT_SLINEAR; | |
f.samples = res / 2; | |
f.datalen = res; | |
- f.data.ptr = buf; | |
+ f.data.ptr = p->buf; | |
ast_debug(7, "Read %d bytes as a frame on %s\n", res, ast->name); | |
- ast_free(buf); | |
return &f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment