Skip to content

Instantly share code, notes, and snippets.

@vassjozsef
Last active May 26, 2023 11:22
Show Gist options
  • Save vassjozsef/29e4d8d97afe53d3d94789a7bd709bf5 to your computer and use it in GitHub Desktop.
Save vassjozsef/29e4d8d97afe53d3d94789a7bd709bf5 to your computer and use it in GitHub Desktop.
Create Audio Sending Stream
webrtc::AudioSendStream* createAudioSendStream(
uint32_t ssrc,
uint8_t payloadType,
webrtc::Transport* transport,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audioEncoderFactory,
webrtc::Call* call)
{
webrtc::AudioSendStream::Config config{transport};
config.rtp.ssrc = ssrc;
config.rtp.extensions = {{"urn:ietf:params:rtp-hdrext:ssrc-audio-level", 1}};
config.encoder_factory = audioEncoderFactory;
const webrtc::SdpAudioFormat kOpusFormat = {"opus", 48000, 2};
config.send_codec_spec =
webrtc::AudioSendStream::Config::SendCodecSpec(payloadType, kOpusFormat);
webrtc::AudioSendStream* audioStream = call->CreateAudioSendStream(config);
audioStream->Start();
return audioStream;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment