* hb_list_getbytes ********************************************************************** * Assuming all items are of type hb_buffer_t, copy bytes from * the list to . What's copied is removed from the list. * The variable pointed by is set to the PTS of the buffer the * first byte has been got from. * The variable pointed by is set to the position of that byte * in
| 4284 | * in that buffer. |
| 4285 | *********************************************************************/ |
| 4286 | void hb_list_getbytes( hb_list_t * l, uint8_t * dst, int size, |
| 4287 | uint64_t * pts, uint64_t * pos ) |
| 4288 | { |
| 4289 | hb_buffer_t * buf; |
| 4290 | int copied; |
| 4291 | int copying; |
| 4292 | uint8_t has_pts; |
| 4293 | |
| 4294 | /* So we won't have to deal with NULL pointers */ |
| 4295 | uint64_t dummy1, dummy2; |
| 4296 | |
| 4297 | if( !pts ) pts = &dummy1; |
| 4298 | if( !pos ) pos = &dummy2; |
| 4299 | |
| 4300 | for( copied = 0, has_pts = 0; copied < size; ) |
| 4301 | { |
| 4302 | buf = hb_list_item( l, 0 ); |
| 4303 | copying = MIN( buf->size - buf->offset, size - copied ); |
| 4304 | memcpy( &dst[copied], &buf->data[buf->offset], copying ); |
| 4305 | |
| 4306 | if( !has_pts ) |
| 4307 | { |
| 4308 | *pts = buf->s.start; |
| 4309 | *pos = buf->offset; |
| 4310 | has_pts = 1; |
| 4311 | } |
| 4312 | |
| 4313 | buf->offset += copying; |
| 4314 | if( buf->offset >= buf->size ) |
| 4315 | { |
| 4316 | hb_list_rem( l, buf ); |
| 4317 | hb_buffer_close( &buf ); |
| 4318 | } |
| 4319 | |
| 4320 | copied += copying; |
| 4321 | } |
| 4322 | } |
| 4323 | |
| 4324 | /********************************************************************** |
| 4325 | * hb_list_empty |
no test coverage detected