Class OpusUtil
- java.lang.Object
-
- com.google.android.exoplayer2.audio.OpusUtil
-
public class OpusUtil extends Object
Utility methods for handling Opus audio streams.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_BYTES_PER_SECONDMaximum achievable Opus bitrate.static intSAMPLE_RATEOpus streams are always 48000 Hz.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<byte[]>buildInitializationData(byte[] header)Builds codec initialization data from an Opus Identification Header.static intgetChannelCount(byte[] header)Parses the channel count from an Opus Identification Header.static longgetPacketDurationUs(byte[] buffer)Returns the duration of the given audio packet.static intparsePacketAudioSampleCount(ByteBuffer buffer)Returns the number of audio samples in the given audio packet.
-
-
-
Field Detail
-
SAMPLE_RATE
public static final int SAMPLE_RATE
Opus streams are always 48000 Hz.- See Also:
- Constant Field Values
-
MAX_BYTES_PER_SECOND
public static final int MAX_BYTES_PER_SECOND
Maximum achievable Opus bitrate.- See Also:
- Constant Field Values
-
-
Method Detail
-
getChannelCount
public static int getChannelCount(byte[] header)
Parses the channel count from an Opus Identification Header.- Parameters:
header- An Opus Identification Header, as defined by RFC 7845.- Returns:
- The parsed channel count.
-
buildInitializationData
public static List<byte[]> buildInitializationData(byte[] header)
Builds codec initialization data from an Opus Identification Header.- Parameters:
header- An Opus Identification Header, as defined by RFC 7845.- Returns:
- Codec initialization data suitable for an Opus MediaCodec.
-
parsePacketAudioSampleCount
public static int parsePacketAudioSampleCount(ByteBuffer buffer)
Returns the number of audio samples in the given audio packet.The buffer's position is not modified.
- Parameters:
buffer- The audio packet.- Returns:
- Returns the number of audio samples in the packet.
-
getPacketDurationUs
public static long getPacketDurationUs(byte[] buffer)
Returns the duration of the given audio packet.- Parameters:
buffer- The audio packet.- Returns:
- Returns the duration of the given audio packet, in microseconds.
-
-