+static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
+{
+ RTPMuxContext *s = s1->priv_data;
+ AVStream *st = s1->streams[0];
+ int frame_duration = av_get_audio_frame_duration(st->codec, 0);
+ int frame_size = st->codec->block_align;
+ int frames = size / frame_size;
+
+ while (frames > 0) {
+ int n = FFMIN(s->max_frames_per_packet - s->num_frames, frames);
+
+ if (!s->num_frames) {
+ s->buf_ptr = s->buf;
+ s->timestamp = s->cur_timestamp;
+ }
+ memcpy(s->buf_ptr, buf, n * frame_size);
+ frames -= n;
+ s->num_frames += n;
+ s->buf_ptr += n * frame_size;
+ buf += n * frame_size;
+ s->cur_timestamp += n * frame_duration;
+
+ if (s->num_frames == s->max_frames_per_packet) {
+ ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 1);
+ s->num_frames = 0;
+ }
+ }
+ return 0;
+}
+