try to set audio payload according to audio capture format

This commit is contained in:
Michel Promonet 2018-04-04 23:45:27 +02:00
parent 14519538a9
commit 41589c8220
2 changed files with 22 additions and 5 deletions

View File

@ -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;

View File

@ -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)