a2dp: improve a2dp sink codec data flushing

Let codec decides when rtp packet need to be sent (terminated by MTU size in most case).
LDAC encoding loop can now be terminated by reading if frame_num is written, no 'frame_count' updating is needed.
RTP payload fragmentation can now be implemented more easily based on this.
This commit is contained in:
Huang-Huang Bao 2021-03-31 17:50:15 +08:00 committed by Wim Taymans
parent 7b9792ffab
commit 5c93f780cf
6 changed files with 56 additions and 170 deletions

View file

@ -377,11 +377,6 @@ static void codec_deinit(void *data)
free(this);
}
static int codec_get_num_blocks(void *data)
{
return 1;
}
static int codec_get_block_size(void *data)
{
struct impl *this = data;
@ -407,7 +402,7 @@ static int codec_start_encode (void *data,
static int codec_encode(void *data,
const void *src, size_t src_size,
void *dst, size_t dst_size,
size_t *dst_out)
size_t *dst_out, int *need_flush)
{
struct impl *this = data;
int res;
@ -445,6 +440,7 @@ static int codec_encode(void *data,
return -EINVAL;
*dst_out = out_args.numOutBytes;
*need_flush = 1;
return out_args.numInSamples * this->samplesize;
}
@ -498,7 +494,6 @@ const struct a2dp_codec a2dp_codec_aac = {
.init = codec_init,
.deinit = codec_deinit,
.get_block_size = codec_get_block_size,
.get_num_blocks = codec_get_num_blocks,
.start_encode = codec_start_encode,
.encode = codec_encode,
.abr_process = codec_abr_process,