ref: 7f4244b437ff9d531a2b996cb15879422e0510d4
parent: cada9355b58d32691dd4edd5c4cc232434519a76
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Fri Apr 28 13:13:51 EDT 2017
Some encoding code
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -238,7 +238,15 @@
}
static void encode_buffer(OggOpusEnc *enc) {
-
+ while (enc->buffer_end-enc->buffer_start > enc->frame_size + enc->decision_delay) {
+ unsigned char packet[MAX_PACKET_SIZE];
+ opus_multistream_encode_float(enc->st, &enc->buffer[enc->channels*enc->buffer_start],
+ enc->buffer_end-enc->buffer_start, packet, MAX_PACKET_SIZE);
+ /* FIXME: Write the packet to the stream. */
+ enc->buffer_start += frame_size;
+ }
+ /* This function must never leave the buffer full. */
+ assert(enc->buffer_end < BUFFER_SAMPLES);
}
/* Add/encode any number of float samples to the file. */