How to setup an L16 PCM Track? #1466
-
|
I have taken the "streamer" example and removed support for video leaving only OPUS. My frontend can successfully receive the OPUS audio packets and play them without complaint. I'm now adding support for L16 PCM so the user can select what format they want using a CLI argument. I have refactored the rtc_client_track_data rtc_sender::addPcm(const std::shared_ptr<rtc::PeerConnection> pc, const uint8_t payload_type,
const uint32_t ssrc, const std::string& cname, const std::string& msid, const std::function<void(void)> on_open)
{
const unsigned int clock_rate = 16000;
auto audio = rtc::Description::Audio(cname);
audio.addAudioCodec(payload_type, "L16/" + std::to_string(clock_rate) + "/1");
audio.addSSRC(ssrc, cname, msid, cname);
auto track = pc->addTrack(audio);
// create RTP configuration
auto rtp_config = std::make_shared<rtc::RtpPacketizationConfig>(ssrc, cname, payload_type, clock_rate);
// create packetizer
auto packetizer = std::make_shared<rtc::AudioRtpPacketizer<16000>>(rtp_config);
// add RTCP SR handler
auto sr_reporter = std::make_shared<rtc::RtcpSrReporter>(rtp_config);
packetizer->addToChain(sr_reporter);
// add RTCP NACK handler
auto nack_responder = std::make_shared<rtc::RtcpNackResponder>();
packetizer->addToChain(nack_responder);
// set handler
track->setMediaHandler(packetizer);
track->onOpen(on_open);
auto track_data = std::make_shared<ClientTrackData>(track, sr_reporter);
return track_data;
}I believe I have set this up to support streaming L16 PCM audio to my frontend however, I get the following error on my frontend TypeScript code when I set the local description: I don't get this error when using OPUS and as I've only changed the If anyone has any direction or examples on how to stream L16 PCM audio using Web RTC that would much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
You can't receive uncompressed PCM because it is not supported for WebRTC in browsers. You should use PCMA or PCMU instead. |
Beta Was this translation helpful? Give feedback.
You can't receive uncompressed PCM because it is not supported for WebRTC in browsers. You should use PCMA or PCMU instead.