![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
rtpbuf.cpp@74:81c47fff88a5, 2014-11-24 (annotated)
- Committer:
- klauss
- Date:
- Mon Nov 24 16:43:16 2014 +0000
- Revision:
- 74:81c47fff88a5
- Parent:
- 60:b4ec6beb3be3
- Child:
- 119:ee6a53069455
validando organiza??o de arquivos | ainda em desenvolvimento.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #include <stdlib.h> |
klauss | 0:4d17cd9c8f9d | 2 | |
klauss | 0:4d17cd9c8f9d | 3 | #include "rtpbuf.h" |
klauss | 60:b4ec6beb3be3 | 4 | /* |
klauss | 0:4d17cd9c8f9d | 5 | static void xmemcpy(uint8_t * dest, uint8_t * src, uint16_t size) { |
klauss | 0:4d17cd9c8f9d | 6 | while (size--) *dest++ = *src++; |
klauss | 0:4d17cd9c8f9d | 7 | } |
klauss | 60:b4ec6beb3be3 | 8 | */ |
klauss | 0:4d17cd9c8f9d | 9 | /* |
klauss | 0:4d17cd9c8f9d | 10 | rtpbuf_t * rtpbuf_init(void) { |
klauss | 0:4d17cd9c8f9d | 11 | } |
klauss | 0:4d17cd9c8f9d | 12 | void rtpbuf_destroy(rtpbuf_t ** self) { |
klauss | 0:4d17cd9c8f9d | 13 | free(*self) |
klauss | 0:4d17cd9c8f9d | 14 | *self = NULL; |
klauss | 0:4d17cd9c8f9d | 15 | } |
klauss | 0:4d17cd9c8f9d | 16 | */ |
klauss | 0:4d17cd9c8f9d | 17 | |
klauss | 0:4d17cd9c8f9d | 18 | void rtpbuf_clear (rtpbuf_t * self) { |
klauss | 0:4d17cd9c8f9d | 19 | self->size = 0; |
klauss | 0:4d17cd9c8f9d | 20 | } |
klauss | 0:4d17cd9c8f9d | 21 | |
klauss | 0:4d17cd9c8f9d | 22 | void rtpbuf_put (rtpbuf_t * self, int size, uint8_t * data){ |
klauss | 0:4d17cd9c8f9d | 23 | if ((size + self->size) <= RTPBUF_BUFSIZE){ |
klauss | 0:4d17cd9c8f9d | 24 | xmemcpy((uint8_t*)self->b+self->size,data,size); |
klauss | 0:4d17cd9c8f9d | 25 | self->size += size; |
klauss | 0:4d17cd9c8f9d | 26 | //debug_msg("put %d -> %d",size,self->size); |
klauss | 0:4d17cd9c8f9d | 27 | } else { |
klauss | 0:4d17cd9c8f9d | 28 | //debug_msg("put-failed %d -> %d",size,self->size); |
klauss | 0:4d17cd9c8f9d | 29 | } |
klauss | 0:4d17cd9c8f9d | 30 | } |
klauss | 0:4d17cd9c8f9d | 31 | |
klauss | 0:4d17cd9c8f9d | 32 | uint8_t * rtpbuf_get (rtpbuf_t * self) { |
klauss | 0:4d17cd9c8f9d | 33 | if (self->size < RTPBUF_PKGSIZE) { |
klauss | 0:4d17cd9c8f9d | 34 | //debug_msg("get-failed %d", self->size); |
klauss | 0:4d17cd9c8f9d | 35 | return NULL; |
klauss | 0:4d17cd9c8f9d | 36 | } |
klauss | 0:4d17cd9c8f9d | 37 | //debug_msg("get %d", self->size); |
klauss | 0:4d17cd9c8f9d | 38 | return (uint8_t*) self->b; |
klauss | 0:4d17cd9c8f9d | 39 | } |
klauss | 0:4d17cd9c8f9d | 40 | |
klauss | 0:4d17cd9c8f9d | 41 | void rtpbuf_next (rtpbuf_t * self) { |
klauss | 0:4d17cd9c8f9d | 42 | if (self->size < RTPBUF_PKGSIZE) { |
klauss | 0:4d17cd9c8f9d | 43 | //debug_msg("next-failed %d", self->size); |
klauss | 0:4d17cd9c8f9d | 44 | } else { |
klauss | 0:4d17cd9c8f9d | 45 | //int i; |
klauss | 0:4d17cd9c8f9d | 46 | //i = self->size; |
klauss | 0:4d17cd9c8f9d | 47 | self->size -= RTPBUF_PKGSIZE; |
klauss | 0:4d17cd9c8f9d | 48 | if (self->size > 0) { |
klauss | 0:4d17cd9c8f9d | 49 | xmemcpy32(self->b, (self->b)+(RTPBUF_PKGSIZE>>2), self->size); |
klauss | 0:4d17cd9c8f9d | 50 | //debug_msg("nextA %d -> %d", i, self->size); |
klauss | 0:4d17cd9c8f9d | 51 | } else { |
klauss | 0:4d17cd9c8f9d | 52 | //debug_msg("nextB %d -> %d", i, self->size); |
klauss | 0:4d17cd9c8f9d | 53 | } |
klauss | 0:4d17cd9c8f9d | 54 | } |
klauss | 0:4d17cd9c8f9d | 55 | } |