go-sip-ua icon indicating copy to clipboard operation
go-sip-ua copied to clipboard

a way to get rtp stream ?

Open pascal-pro opened this issue 4 years ago • 3 comments

Hello, I wanted to try your library but I never managed to get the audio streams back. More concretely, I use freeswitch like ipbx, I can connect myself, receive the call event, pick up the call, as in the example, and then I don't know what to do. When I try to read or write to the ports present in the SDP, with gstreamer, I have the impression that there are already reads or writes on these RTP streams. Is there an ontrack function like in the pion/webrtc library?

pascal-pro avatar Dec 07 '20 10:12 pascal-pro

@pascal-ace Sorry for the slow reply, I got back to this line after a long time. I am ready to add RTP relay support, will try to add pion/webrtc to support rtp streams. If you have any ideas or wishes, We can communicate here. :)

cloudwebrtc avatar Dec 31 '20 23:12 cloudwebrtc

My main interest is simply to get the audio streams, to send them to gstreamer for processing. For the integration of pion/webrtc, I have a directory : link it's just a test, not even trying since I managed to get the websocket audio with the example. Only on an ipbx freeswitch. I'm on their slack if you want to talk directly.

pascal-pro avatar Jan 01 '21 18:01 pascal-pro

I use this lib to make SIP call server .The vender has different address and port for SIP and RTP server.And I behind a router(IP:192.168.100.27), if I don't send a udp packet contain RTP protocol to vender's RTP server,I can't received any packet.

c.ua.InviteStateHandler = func(s *session.Session, req *sip.Request, resp *sip.Response, status session.Status) {
	c.logger.Infof("InviteStateHandler: state => %v, type => %s", status, s.Direction())
	switch status {
	case session.Provisional: //After response for 1XX
		if len(s.RemoteSdp()) == 0 {
			break
		}

		//send RTP packet to vender RTP server
		c.logger.Info("  - - - - - - -Write RTP - - - - - ")
		str := "80000000a1b622ca54480d92fffffffffffff……THIS_IS_RTP_PACKET_ENCODE_BY_HEX"
		b, _ := hex.DecodeString(str)

		remoteSDP, err := sdp.ParseString(s.RemoteSdp())
		if err != nil {
			c.logger.Errorf("Error Get Remote SDP:%v", err)
			return
		}
		remoteIP, remotePort := mock.GetRemoteIpPort(remoteSDP)
		//send RTP packet to vender RTP server
		c.remoteRTPAddr = &net.UDPAddr{IP: net.ParseIP(remoteIP), Port: remotePort}
		c.logger.Infof("Got remoteIp:%s,remotePort:%d", remoteIP, remotePort)
		_, err = c.UDPSteam.Send(b, c.remoteRTPAddr)


		if err != nil {
			c.logger.Errorf("Error In Send UDP message %v", err)
			return
		}
		...

And then,I can received rtp package.

Windforce17 avatar Mar 19 '21 06:03 Windforce17