pion/webrtc - How do I set audio sink and source in GO Pion API?

884 Views Asked by At

I'm working on a CLI Go app to run in the background on my Linux server. This is an implementation of pion/webrtc. My Go app is connecting to the Janus, but not receiving or sending audio. I need to send microphone audio and receive audio from Janus. I guess that I should link my audio sink/source in pion, but I'm confused.

I'm not sure about this code:

// Create a audio track
opusTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: "audio/opus"}, "audio", "pion")
if err != nil {
    panic(err)
} else if _, err = peerConnection.AddTrack(opusTrack); err != nil {
    panic(err)
}

Neither this:

    gst.CreatePipeline("opus", []*webrtc.TrackLocalStaticSample{opusTrack}, "audiotestsrc").Start()

I used the sample code of pion/example-webrtc-applications/janus-gateway.

My whole code here.

Thanks for helping!

1

There are 1 best solutions below

0
moigamijunior On

This is what I got:

    gst.CreatePipeline("opus", []*webrtc.TrackLocalStaticSample{opusTrack}, "autoaudiosrc").Start()

"autoaudiosrc" is the matter.

Linux Ubuntu Server 21.04.4