cloudwebrtc / go-sip-ua

Go SIP UA library for client/b2bua
Apache License 2.0
215 stars 84 forks source link

a way to get rtp stream ? #15

Open pascal-pro opened 3 years ago

pascal-pro commented 3 years ago

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?

cloudwebrtc commented 3 years ago

@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. :)

pascal-pro commented 3 years ago

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.

Windforce17 commented 3 years ago

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.