Changeset 191
- Timestamp:
- 11/27/07 11:04:08
(10 months ago)
- Author:
- sip
- Message:
Fixed memory leak in frame allocation
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r186 |
r191 |
|
| 778 | 778 | /* Packetize outgoing frame */ |
|---|
| 779 | 779 | if ((send=create_ast_frame(frame,&vt))!=NULL) |
|---|
| | 780 | { |
|---|
| 780 | 781 | /* Send frame */ |
|---|
| 781 | 782 | ast_write(pseudo,send); |
|---|
| | 783 | /* Free frame */ |
|---|
| | 784 | ast_frfree(send); |
|---|
| | 785 | } |
|---|
| 782 | 786 | /* Delete frame */ |
|---|
| 783 | 787 | FrameDestroy(frame); |
|---|
| r190 |
r191 |
|
| 232 | 232 | static int mp4_rtp_read(struct mp4rtp *p) |
|---|
| 233 | 233 | { |
|---|
| 234 | | struct ast_frame *f; |
|---|
| | 234 | unsigned char buffer[sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 1500]; |
|---|
| | 235 | struct ast_frame *f = (struct ast_frame *) buffer; |
|---|
| 235 | 236 | int next = 0; |
|---|
| 236 | 237 | int last = 0; |
|---|
| … | … | |
| 262 | 263 | last = 1; |
|---|
| 263 | 264 | |
|---|
| 264 | | /* malloc frame & data */ |
|---|
| 265 | | f = (struct ast_frame *) malloc(sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 1500); |
|---|
| 266 | | |
|---|
| 267 | 265 | /* Unset */ |
|---|
| 268 | | memset(f, 0, sizeof(struct ast_frame) + 1500); |
|---|
| | 266 | memset(f, 0, sizeof(struct ast_frame) + 1500 + AST_FRIENDLY_OFFSET); |
|---|
| 269 | 267 | |
|---|
| 270 | 268 | /* Let mp4 lib allocate memory */ |
|---|
| … | … | |
| 309 | 307 | return -1; |
|---|
| 310 | 308 | } |
|---|
| 311 | | |
|---|
| 312 | | /* if (f->frametype == AST_FRAME_VIDEO) { |
|---|
| 313 | | ast_log(LOG_DEBUG, "successfully read rtp video packet with %d bytes\n", f->datalen); |
|---|
| 314 | | } else if (f->frametype == AST_FRAME_VOICE) { |
|---|
| 315 | | ast_log(LOG_DEBUG, "successfully read rtp audio packet with %d bytes\n", f->datalen); |
|---|
| 316 | | dump_buffer_hex("audio buffer:",f->data,f->datalen); |
|---|
| 317 | | } */ |
|---|
| 318 | 309 | |
|---|
| 319 | 310 | /* Write frame */ |
|---|
| r190 |
r191 |
|
| 986 | 986 | static int rtsp_play(struct ast_channel *chan,char *ip, int port, char *url) |
|---|
| 987 | 987 | { |
|---|
| 988 | | struct ast_frame *f; |
|---|
| 989 | | struct ast_frame *sendFrame; |
|---|
| | 988 | struct ast_frame *f = NULL; |
|---|
| | 989 | struct ast_frame *sendFrame = NULL; |
|---|
| 990 | 990 | |
|---|
| 991 | 991 | int infds[5]; |
|---|
| … | … | |
| 1063 | 1063 | infds[4] = player->videoRtcp; |
|---|
| 1064 | 1064 | |
|---|
| 1065 | | |
|---|
| 1066 | 1065 | /* Send request */ |
|---|
| 1067 | 1066 | if (!RtspPlayerDescribe(player,url)) |
|---|
| … | … | |
| 1072 | 1071 | goto rtsp_play_end; |
|---|
| 1073 | 1072 | } |
|---|
| | 1073 | |
|---|
| | 1074 | /* malloc frame & data */ |
|---|
| | 1075 | sendFrame = (struct ast_frame *) malloc(sizeof(struct ast_frame) + rtpSize); |
|---|
| | 1076 | |
|---|
| | 1077 | /* Set data pointer */ |
|---|
| | 1078 | rtpBuffer = (void*)sendFrame + AST_FRIENDLY_OFFSET; |
|---|
| 1074 | 1079 | |
|---|
| 1075 | 1080 | /* log */ |
|---|
| … | … | |
| 1392 | 1397 | rtpLen = 0; |
|---|
| 1393 | 1398 | |
|---|
| 1394 | | /* malloc frame & data */ |
|---|
| 1395 | | sendFrame = (struct ast_frame *) malloc(sizeof(struct ast_frame) + rtpSize); |
|---|
| 1396 | 1399 | /* Clean frame */ |
|---|
| 1397 | 1400 | memset(sendFrame,0,sizeof(struct ast_frame) + rtpSize); |
|---|
| 1398 | | /* Set data pointer */ |
|---|
| 1399 | | rtpBuffer = (void*)sendFrame + AST_FRIENDLY_OFFSET; |
|---|
| | 1401 | |
|---|
| 1400 | 1402 | |
|---|
| 1401 | 1403 | /* Read rtp packet */ |
|---|
| … | … | |
| 1506 | 1508 | /* Teardown */ |
|---|
| 1507 | 1509 | RtspPlayerTeardown(player); |
|---|
| | 1510 | |
|---|
| | 1511 | /* Free frame */ |
|---|
| | 1512 | if (sendFrame) |
|---|
| | 1513 | /* Free memory */ |
|---|
| | 1514 | free(sendFrame); |
|---|
| 1508 | 1515 | |
|---|
| 1509 | 1516 | /* If ther was a sdp */ |
|---|
| r187 |
r191 |
|
| 173 | 173 | /* Send */ |
|---|
| 174 | 174 | vtc->channel->tech->write_video(vtc->channel, send); |
|---|
| | 175 | |
|---|
| | 176 | /* Free frame */ |
|---|
| | 177 | free(send); |
|---|
| 175 | 178 | } |
|---|
| 176 | 179 | |
|---|
Download in other formats:
|
|