public class AudioConsumerUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.nio.ByteBuffer |
buffer |
private static int |
BYTES_PER_SAMPLE |
private AgoraRtcConn |
conn |
private int |
consumedFrameCount |
private static int |
INTERVAL_ONE_FRAME |
private static int |
INTERVAL_PCM_INTERRUPT |
private boolean |
isDirectSend |
private long |
lastSendTimestamp |
private int |
numOfChannels |
private int |
oneFrameSize |
private int |
sampleRate |
private static int |
START_BY_MAX_FRAME_SIZE |
private static int |
START_BY_MIN_FRAME_SIZE |
private int |
startCacheDataSize |
private long |
startedTimestamp |
| Constructor and Description |
|---|
AudioConsumerUtils(AgoraRtcConn conn,
int numOfChannels,
int sampleRate)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the cache.
|
int |
consume()
Consume data from the cache and return consume frame count.
|
private int |
directConsume() |
private byte[] |
extractData(int size,
long currentTime)
Extract data from the buffer.
|
private int |
getBufferSize() |
int |
getOneFrameSize() |
int |
getRemainingCacheDurationInMs()
Gets the remaining cache duration in milliseconds.
|
int |
getSamplesPerChannel(int dataSize)
Calculate samples per channel.
|
void |
pushPcmData(byte[] data)
Push pcm data into the cache.
|
void |
release() |
private int |
sendPcmData(byte[] data) |
private int |
undirectConsume() |
private static final int START_BY_MAX_FRAME_SIZE
private static final int START_BY_MIN_FRAME_SIZE
private static final int INTERVAL_ONE_FRAME
private static final int INTERVAL_PCM_INTERRUPT
private static final int BYTES_PER_SAMPLE
private AgoraRtcConn conn
private final int numOfChannels
private final int sampleRate
private final int oneFrameSize
private int startCacheDataSize
private java.nio.ByteBuffer buffer
private long startedTimestamp
private long lastSendTimestamp
private int consumedFrameCount
private final boolean isDirectSend
public AudioConsumerUtils(AgoraRtcConn conn, int numOfChannels, int sampleRate)
conn - The AgoraRtcConn.numOfChannels - The number of channels.sampleRate - The sample rate.public int getOneFrameSize()
public int getSamplesPerChannel(int dataSize)
dataSize - The data size.public void pushPcmData(byte[] data)
data - The pcm data.public int consume()
private int directConsume()
private int undirectConsume()
private byte[] extractData(int size,
long currentTime)
size - The size of the data.currentTime - The current time.private int sendPcmData(byte[] data)
private int getBufferSize()
public int getRemainingCacheDurationInMs()
public void clear()
public void release()