Skip to content
Snippets Groups Projects
Commit a48983d6 authored by Boris Grozev's avatar Boris Grozev
Browse files

Use 2 channels for the OPUS_RTP format (the payload-rtp-opus draft requires

opus to be advertised with 2 channels)
parent f7b42e0f
No related branches found
No related tags found
No related merge requests found
......@@ -183,6 +183,7 @@ public class MediaUtils
"opus",
MediaType.AUDIO,
Constants.OPUS_RTP,
2,
opusFormatParams,
null,
48000);
......@@ -418,12 +419,55 @@ private static void addMediaFormats(
* @param clockRates the optional list of clock rates of the
* <tt>MediaFormat</tt>s to be associated with <tt>rtpPayloadType</tt>
*/
private static void addMediaFormats(
byte rtpPayloadType,
String encoding,
MediaType mediaType,
String jmfEncoding,
Map<String, String> formatParameters,
Map<String, String> advancedAttributes,
double... clockRates)
{
addMediaFormats(
rtpPayloadType,
encoding,
mediaType,
jmfEncoding,
1 /* channel */,
formatParameters,
advancedAttributes,
clockRates);
}
/**
* Adds a new mapping of a specific RTP payload type to a list of
* <tt>MediaFormat</tt>s of a specific <tt>MediaType</tt>, with a specific
* JMF encoding and, optionally, with specific clock rates.
*
* @param rtpPayloadType the RTP payload type to be associated with a list
* of <tt>MediaFormat</tt>s
* @param encoding the well-known encoding (name) corresponding to
* <tt>rtpPayloadType</tt> (in contrast to the JMF-specific encoding
* specified by <tt>jmfEncoding</tt>)
* @param mediaType the <tt>MediaType</tt> of the <tt>MediaFormat</tt>s to
* be associated with <tt>rtpPayloadType</tt>
* @param jmfEncoding the JMF encoding of the <tt>MediaFormat</tt>s to be
* associated with <tt>rtpPayloadType</tt>
* @param channels number of channels
* @param formatParameters the set of format-specific parameters of the
* <tt>MediaFormat</tt>s to be associated with <tt>rtpPayloadType</tt>
* @param advancedAttributes the set of advanced attributes of the
* <tt>MediaFormat</tt>s to be associated with <tt>rtpPayload</tt>
* @param clockRates the optional list of clock rates of the
* <tt>MediaFormat</tt>s to be associated with <tt>rtpPayloadType</tt>
*/
@SuppressWarnings("unchecked")
private static void addMediaFormats(
byte rtpPayloadType,
String encoding,
MediaType mediaType,
String jmfEncoding,
int channels,
Map<String, String> formatParameters,
Map<String, String> advancedAttributes,
double... clockRates)
......@@ -441,7 +485,14 @@ private static void addMediaFormats(
switch (mediaType)
{
case AUDIO:
format = new AudioFormat(jmfEncoding);
if(channels == 1)
format = new AudioFormat(jmfEncoding);
else
format = new AudioFormat(
jmfEncoding,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
channels);
break;
case VIDEO:
format
......
......@@ -72,7 +72,7 @@ public class JNIDecoder
}
/**
* Number of channels
* Number of channels to decode into.
*/
private int channels = 1;
......@@ -191,8 +191,8 @@ protected int doProcess(Buffer inBuffer, Buffer outBuffer)
* operate as if PLC has been specified.
*/
boolean decodeFEC
= ((lostSeqNoCount != 0)
&& (lastFrameSizeInSamplesPerChannel != 0));
= ((lostSeqNoCount != 0)
&& (lastFrameSizeInSamplesPerChannel != 0));
if ((inBuffer.getFlags() & Buffer.FLAG_SKIP_FEC) != 0)
{
......@@ -215,8 +215,8 @@ protected int doProcess(Buffer inBuffer, Buffer outBuffer)
if (decodeFEC)
{
inLength
= (lostSeqNoCount == 1) ? inLength /* FEC */ : 0 /* PLC */;
inLength
= (lostSeqNoCount == 1) ? inLength /* FEC */ : 0 /* PLC */;
byte[] out
= validateByteArraySize(
......@@ -280,8 +280,8 @@ protected int doProcess(Buffer inBuffer, Buffer outBuffer)
+= frameSizeInSamplesPerChannel;
outBuffer.setFlags(
outBuffer.getFlags()
& ~(BUFFER_FLAG_FEC | BUFFER_FLAG_PLC));
outBuffer.getFlags()
& ~(BUFFER_FLAG_FEC | BUFFER_FLAG_PLC));
/*
* When we encounter a lost frame, we will presume that it was
......@@ -373,39 +373,9 @@ public Format setInputFormat(Format format)
if (inFormat != null)
{
double outSampleRate;
int outChannels;
if (outputFormat == null)
{
outSampleRate = Format.NOT_SPECIFIED;
outChannels = Format.NOT_SPECIFIED;
}
else
{
AudioFormat outAudioFormat = (AudioFormat) outputFormat;
outSampleRate = outAudioFormat.getSampleRate();
outChannels = outAudioFormat.getChannels();
}
AudioFormat inAudioFormat = (AudioFormat) inFormat;
double inSampleRate = inAudioFormat.getSampleRate();
int inChannels = inAudioFormat.getChannels();
if ((outSampleRate != inSampleRate) || (outChannels != inChannels))
{
setOutputFormat(
new AudioFormat(
AudioFormat.LINEAR,
inSampleRate,
16,
inChannels,
AudioFormat.LITTLE_ENDIAN,
AudioFormat.SIGNED,
/* frameSizeInBits */ Format.NOT_SPECIFIED,
/* frameRate */ Format.NOT_SPECIFIED,
Format.byteArray));
setOutputFormat(SUPPORTED_OUTPUT_FORMATS[0]);
}
}
return inFormat;
......
......@@ -64,7 +64,7 @@ public class JNIEncoder
Constants.OPUS_RTP,
48000,
/* sampleSizeInBits */ Format.NOT_SPECIFIED,
1,
/* channels */ 2,
/* endian */ Format.NOT_SPECIFIED,
/* signed */ Format.NOT_SPECIFIED,
/* frameSizeInBits */ Format.NOT_SPECIFIED,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment