mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Buffer clusters to have time to probe them for metadata, like keyframes.
This commit is contained in:
parent
def5a4cf6c
commit
f461ff6763
@ -77,6 +77,7 @@ struct ebml_st {
|
||||
unsigned long long copy_len;
|
||||
|
||||
int cluster_start;
|
||||
int flush_cluster;
|
||||
|
||||
int position;
|
||||
unsigned char *buffer;
|
||||
@ -377,8 +378,24 @@ static int ebml_read_space(ebml_t *ebml)
|
||||
/* return up until just before a new cluster starts */
|
||||
read_space = ebml->cluster_start;
|
||||
} else {
|
||||
/* return what we have */
|
||||
read_space = ebml->position;
|
||||
|
||||
if (ebml->position == EBML_SLICE_SIZE) {
|
||||
/* The current cluster fills the buffer,
|
||||
* we have no choice but to start flushing it.
|
||||
*/
|
||||
|
||||
ebml->flush_cluster = 1;
|
||||
}
|
||||
|
||||
if (ebml->flush_cluster) {
|
||||
/* return what we have */
|
||||
read_space = ebml->position;
|
||||
} else {
|
||||
/* wait until we've read more, so the parser has
|
||||
* time to gather metadata
|
||||
*/
|
||||
read_space = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return read_space;
|
||||
@ -568,6 +585,8 @@ static int ebml_wrote(ebml_t *ebml, int len)
|
||||
* sync point.
|
||||
*/
|
||||
if (ebml->cluster_start >= 0) {
|
||||
/* Allow the cluster in the read buffer to flush. */
|
||||
ebml->flush_cluster = 1;
|
||||
processing = 0;
|
||||
} else {
|
||||
|
||||
@ -580,6 +599,9 @@ static int ebml_wrote(ebml_t *ebml, int len)
|
||||
/* Mark this sync point */
|
||||
ebml->cluster_start = ebml->position;
|
||||
|
||||
/* Buffer data to give us time to probe for keyframes, etc. */
|
||||
ebml->flush_cluster = 0;
|
||||
|
||||
/* Copy cluster tag to read buffer */
|
||||
ebml->copy_len = tag_length;
|
||||
ebml->parse_state = EBML_STATE_COPYING_TO_DATA;
|
||||
|
Loading…
Reference in New Issue
Block a user