try to set audio payload according to audio capture format

pull/95/head
Michel Promonet 6 years ago
parent 14519538a9
commit 41589c8220

@ -52,8 +52,9 @@ class ALSACapture
virtual int getWidth() {return -1;}
virtual int getHeight() {return -1;}
unsigned long getSampleRate() { return m_params.m_sampleRate; };
unsigned long getChannels () { return m_params.m_channels; };
unsigned long getSampleRate() { return m_params.m_sampleRate; }
unsigned long getChannels () { return m_params.m_channels; }
snd_pcm_format_t getFormat () { return m_fmt; }
private:
snd_pcm_t* m_pcm;

@ -232,6 +232,24 @@ snd_pcm_format_t decodeAudioFormat(const std::string& fmt)
}
return audioFmt;
}
std::string getRtpFormat(snd_pcm_format_t format, int sampleRate, int channels)
{
std::ostringstream os;
os << "audio/";
switch (format) {
case SND_PCM_FORMAT_S32_BE:
case SND_PCM_FORMAT_S32_LE:
os << "L32"
break;
case SND_PCM_FORMAT_S8:
os << "L8"
break;
default:
os << "L16"
break;
}
os << "/" << sampleRate << "/" << channels;
}
#endif
// -------------------------------------------------------
@ -651,9 +669,7 @@ int main(int argc, char** argv)
}
else
{
std::ostringstream os;
os << "audio/L16/" << audioCapture->getSampleRate() << "/" << audioCapture->getChannels();
rtpAudioFormat.assign(os.str());
rtpAudioFormat.assign(getAudioRtpFormat(audioCapture->getFormat(),audioCapture->getSampleRate(), audioCapture->getChannels()));
// extend buffer size if needed
if (audioCapture->getBufferSize() > OutPacketBuffer::maxSize)

Loading…
Cancel
Save