-
public class AudioPacketFactoryAudio Packet Structure Doc for Reve Conference: Here our main goal is to design redundant audio packet for a conference so that it can perform well in heavy packet loss environment. Frame 1 is always the primary audio packet and others are redundant. Audio Packet - Header : 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MediaID | Packet Type | Frame Count | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame 1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame 2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... | Audio Packet - Frame (single): 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frame Length | Flag/Silence | codec | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | Rms | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Timestamp | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ MediaID ( 2 bytes / 16 bits) = media ID of the audio packet sender Packet Type ( 1 byte / 8 bits) = Audio / Video / Control / other (special packet) : 00 => Audio ,01 => Video Frame Count ( 1 byte / 8 bits) = number of Frame or redundant data (audio) present Frame ( defined by Frame count ) = audio packet with info’s Frame Length ( 2 bytes / 16 bits ) = the length (bytes) of the Frame (first 12 bytes are fixed Frame header so length 130 means 12 bytes Frame header with 118 bytes of Frame data, there can be mulitple payloads) Flag/Silence ( 1 byte / 8 bits ) = silence bit (first bit is SILENCE bit and next 7 bits are reserved) Reserved (1 byte / 8 bits ) = Reserved for later usage Sequence Number ( 2 bytes / 16 bits ) = sequence number of the audio Frame Rms ( 2 bytes / 16 bits ) = rms value of the audio data Timestamp ( 4 bytes / 32 bits) = timestamp of the Frame (while created) Data ( defined by Frame length) = opus encoded audio bytes
-
-
Method Summary
Modifier and Type Method Description static intbuildAudioPacket(Array<byte> data, int offset, AudioFrame frame, boolean addRedundant, AudioTransmissionHandler audioManger)Build an Audio udp packet data based on the given AudioFrame Few extra redundant audio frame may be added in the same packet to overcome some packet loss. static voidparseAudioPacket(Array<byte> data, int offset, int len, AudioTransmissionHandler audioTransmissionHandler)Receive audio packet from meadia server and process/decode it, then push the data toparticipant. static intbuildRTCPPacketForSingleNACK(Array<byte> data, int offset, RTCPFrame frame)Build an Audio udp packet data based on the given AudioFrame Few extra redundant audio frame may be added in the same packet to overcome some packet loss. -
-
Method Detail
-
buildAudioPacket
static int buildAudioPacket(Array<byte> data, int offset, AudioFrame frame, boolean addRedundant, AudioTransmissionHandler audioManger)
Build an Audio udp packet data based on the given AudioFrame Few extra redundant audio frame may be added in the same packet to overcome some packet loss.
- Parameters:
data- byte array, where packet should be formed.offset- offset of the byte array to start putting the frames.frame- instance of AudioFrame defines the main audio frame need to be added in this packet.audioManger- instance of AudioTransmissionHandler media related information of this call.
-
parseAudioPacket
static void parseAudioPacket(Array<byte> data, int offset, int len, AudioTransmissionHandler audioTransmissionHandler)
Receive audio packet from meadia server and process/decode it, then push the data toparticipant.frameToBePlayed queue for mixing/playing
- Parameters:
data- encoded audio data with headers and other info'soffset- starting index, default to 0len- length of the received packet size so we have to traverse from offsetaudioTransmissionHandler- of this call
-
buildRTCPPacketForSingleNACK
static int buildRTCPPacketForSingleNACK(Array<byte> data, int offset, RTCPFrame frame)
Build an Audio udp packet data based on the given AudioFrame Few extra redundant audio frame may be added in the same packet to overcome some packet loss.
- Parameters:
data- byte array, where packet should be formed.offset- offset of the byte array to start putting the frames.frame- instance of RTCPFrame defines the main NACK type rtcp frame.
-
-
-
-