Replies: 1 comment 8 replies
-
If you specify the format as Opus, you have to send Opus-encoded audio data (by the way, the clock rate should be 48000, not 4800). If you don't want to encode as Opus, you can send the audio as PCMA as you can perform the encoding on your own: rtc::Description::Audio audio("audio", rtc::Description::Direction::SendRecv);
audio.addPcmaCodec(payloadType);
audio.addSSRC(ssrc, name);
std::shared_ptr<rtc::Track> track = peer_connection->addTrack(audio);
auto rtpConfig = std::make_shared<rtc::RtpPacketizationConfig>(ssrc, name, payloadType, 8000);
auto handler = std::make_shared<rtc::AudioRtpPacketizer>(rtpConfig);
handler->addToChain(std::make_shared<rtc::AudioRtpDepacketizer>());
handler->addToChain(std::make_shared<rtc::RtcpReceivingSession>());
handler->addToChain(std::make_shared<rtc::RtcpSrReporter>(rtpConfig));
track->setMediaHandler(handler); Samples must then be captured at 8KHz and encoded to G.711 PCMA. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I'm having trouble with the audio quality sent over an audio track and was hoping that someone could provide some tips.
The audio data comes as float values in the range [-1, 1] from the source, but to send them over the audio track I need a vector of bytes, and i suspect that the way I am converting the values might be the problem.
This is the setup of the audio track in a nutshell:
Now when sending data I get a vector of float values and create a vector of std::bytes like this:
On the other end of the connection I do the opposite to get float values again. The resulting audio is understandable but very distortet and croaky sounding.
I also tried converting the float values to 16 bit integers and creating a vector of bytes from that, but while it sounded different it does not at all sound better.
Does anyone have some tipps or hints want I might be doing wrong here? Or what is a good way to transform float values in the range [-1, 1] to std::byte values, so that they are suitable for sending via Track::send()?
Thanks in advance for any input and best regards,
Patrick
Beta Was this translation helpful? Give feedback.
All reactions