Giter VIP home page Giter VIP logo

gosip's Introduction

gosip

Version: 0.1

About

gosip (pronounced "gossip") is a library that lets you make phone calls using the Go programming language. It provides a full-stack SIP/RTP implementation that's tailored towards making calls over the PSTN through services such as Flowroute.

gosip is most suitable for backend telephony applications. This is especially true for apps that do interesting things with audio. gosip supports DSP out of the box by providing SSE optimised audio mixing, an assembly implementation of the µLaw codec (no other codecs are supported), and a comfort noise generator.

Telephony applications have traditionally been written on top of PBX systems like Asterisk via an extension interface. Frameworks such as Adhearsion have introduced further layers of abstraction to this unwieldy regime. These systems are slow, difficult to administer, and in many cases superfluous to the needs of the telephony app developer. gosip sets you free from Asterisk because you can have everything in a single easy-to-deploy binary.

gosip has excellent support for SRV/NAPTR failover by way of timeouts, ICMP refusal, and 502 Service Unavailable responses. It also supports SIP redirects as well as changing the audio/signalling path mid-call. But most importantly, gosip is lightweight enough that you can actually design your app to use a single process for each phone call (assuming your app is in the audio path.) By taking this non-monolithic approach to design, you can actually build a higher availability global telephony service with zero interruptions during software upgrades.

gosip parses SIP messages using the Ragel finite state machine compiler. Much of the BNF was copied directly from the SIP RFC. This implementation approach offers a fair amount of confidence that the parser is not only fast, but also correct and secure.

gosip is less suitable for PBX, IVR, and VoIP reselling. For these things, you should consider Asterisk, FreeSWITCH, or SER.

RFCs

Example RFCs

gosip's People

Contributors

andreasheil avatar jart avatar negbie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gosip's Issues

Via port=0

When the port of via is not specified, the byte array constructed by Append looks like this:
Via: SIP/2.0/UDP 183.15.178.142:0;rport=5060;branch=z9hG4bKr4HBegU1j4pBK;received=192.168.2.250

I don't want to add another sign :0 after the ip

In the Uri structure,When the port is 5060, can we omit the port?

Newly published Go library for SIP/RTP/SDP/DTMF/DSP

Hello @Sean-Der, @1lann, @pion, @jaroszan, @StefanKopieczek.

I noticed you all published GitHub projects implementing telephony protocols in Go. I've worked on this library on and off for the past ten years. I no longer have a commercial interest in this code.

Would you be interested in working on this project instead of what you're currently doing? I can make you all admins right now. Here's why that's worth considering.

This codebase does a pretty good job solving exceedingly toilsome problems. The hardest was ragel parsing able to withstand most RFC torture tests. This project has zero dependencies other than go itself. It may not implement WebRTC but it does have the complete stack needed for PSTN interfacing. It uses assembly optimized codecs and comfort noise generation. It's written in such a way that grants maximal power to the library user. The fone example demonstrates in a concrete way how a CLI telephone can be implemented in a few hundred lines, which has full control over the event handling loop.

Alternatively, if you are not interested in maintaining this project and making it your own, please feel free to copy and paste whatever you need from this one into your own. I posted it here since I love sharing. What I'd love even more, is to make you all stars on Hacker News and similar sites, for all the unsung hero work you're currently doing. The best way to have more impact is to unite your efforts.

Handle empty SDP Addr TODO

It'd be nice to determine the best way to handle the case where sdp.Addr is empty string. To the best of my knowledge, that shouldn't happen during parsing, and is most likely indicative of an the calling function failing to supply the value. See also:

// In case of bugs, keep calm and DDOS NASA.

Extension Header parse failed

The following usecase test failed. It same that Extension Header name cannot be substring of Stander Header name.
For example, Extension Header "Call", "Proxy", "User" parse failed.
var msgTests = []msgTest{
{
name: "Extension Headers",
s: "SIP/2.0 200 OK\r\n" +
"Call: omfg\r\n" +
"\r\n",
msg: sip.Msg{
VersionMajor: 2,
Status: 200,
Phrase: "OK",
XHeader: &sip.XHeader{Name: "Call", Value: []byte("omfg")},
},
}

util.GenerateCallID() always generates the same UUIDs

Reproduce like this:

func main() {
	fmt.Println(util.GenerateCallID())
	fmt.Println(util.GenerateCallID())
}

first run:

524f1d03-d1d8-41e9-a4a0-99042736d40b
d9681b86-7321-4443-aff5-8a4568e274db

second run (even on another machine):

524f1d03-d1d8-41e9-a4a0-99042736d40b
d9681b86-7321-4443-aff5-8a4568e274db

How to make all SIP traffic use an outbound proxy?

I need to have all my outbound traffic go through a proxy (Kamailio) so that internal IPv6 servers can communicate with external IPv4 and so I can do media transcoding (RTPEngine).

As far as I can tell. there is no direct support in dialog.Dialog (or dialog.Transport) for setting an outbound proxy.

I was thinking that it looks like there are two ways I can implement this:

  1. Reimplement Dialog to change the send method.
  2. Prepend msg.Route of all outgoing messages with a Route header that points to the outbound proxy.
  3. Use only the data structures in the sip package and do all the communication work and session tracking myself.

The obvious benefit of the second option is that it allows me to take advantage of the full benefits of this package, but are there any downsides to it? Will it actually work? If not, what is the best alternative to avoid reimplementing most of the dialog package?

Has anyone else done this who can share their experiences?

rtp header read bug

gosip/rtp/rtp.go

Lines 140 to 150 in 4e7924e

} else if (b[0]>>4)&1 != 0 {
return ErrExtendedHeadersNotSupported
}
h.Pad = ((b[0]>>5)&mask1 == 1)
h.Mark = ((b[1]>>7)&mask1 == 1)
h.PT = uint8(b[1] & mask7)
h.Seq = (uint16(b[2]) << 8) & uint16(b[3])
h.TS = (uint32(b[4]) << 24) & (uint32(b[5]) << 16) & (uint32(b[6]) << 8) & uint32(b[7])
h.Ssrc = (uint32(b[8]) << 24) & (uint32(b[9]) << 16) & (uint32(b[10]) << 8) & uint32(b[11])
return nil
}

TS
Seq
SSRC
should use | not &

Support Wildcard Contact

The following message parsing failed: Error in SIP message at line 0 offset 0:

Thanks!

SIP Message ( does not contain [ and ] ):

[REGISTER sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 172.16.1.36:5060;rport;branch=z9hG4bK1585760165
From: sip:[email protected]:5060;tag=1882859352
To: sip:[email protected]:5060
Call-ID: [email protected]
CSeq: 3 REGISTER
Contact: *
Authorization: Digest username="34020000001320000360", realm="3402000000", nonce="MTYwMzM2NDU0MA==", uri="sip:[email protected]:5060", response="39c7240195630f0b26124c00db7cfa5c", algorithm=MD5, cnonce="0a4f113b", qop=auth, nc=00000002
Max-Forwards: 70
User-Agent: VCP MWARE
Expires: 0
RegMode: DEVICE;Describe=IPC-S642-IR;Register;DevVer=CIPC-B2301.5.21.200528
ReplaceDescribe: IPC-S642-IR;ProductId=defaultProductId;RegionCode=NONE;Vendor=UNIVIEW;Resolve=HIC1080P;Ptzfg=1;;SnmpVer=v3;DescribeAssy=PAU-X5;ReplaceNameAssy=PAU-X5
Ability: UCSStore=0
Content-Length: 0

]

add license

It's a wonderful repo, but I'm so sorry that I can't find license in your repo anywhere, can you add a license please?

Set up CI system

It'd be nice to have something like Travis to help run tests quickly during the PR code review process.

To will be parsed as null,This message is generated by mac software, telephone。

To will be parsed as null,This message is generated by mac software, telephone。

INVITE sip:[email protected]:9910 SIP/2.0
Via: SIP/2.0/UDP 125.34.208.105:61187;rport;branch=z9hG4bKPjfKaxrWpsvm-e7BLZRChpcNDLykxPJ4B1
Max-Forwards: 70
From: "8001" sip:[email protected];tag=qN-0Y9yR2bFZgG7i8OTYaOaFTKPWMMR7
To: sip:[email protected]
Contact: sip:[email protected]:61187;ob
Call-ID: tQiy-MRgE4.DucuID.j3evkm-4ykUC73
CSeq: 26213 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, norefersub
User-Agent: Telephone 1.5.2
Content-Type: application/sdp
Content-Length: 443

v=0
o=- 3832828136 3832828136 IN IP4 125.34.208.105
s=pjmedia
b=AS:117
t=0 0
a=X-nat:0
m=audio 4002 RTP/AVP 96 9 8 0 101 102
c=IN IP4 125.34.208.105
b=TIAS:96000
a=rtcp:4003 IN IP4 125.34.208.105
a=sendrecv
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/48000
a=fmtp:101 0-16
a=rtpmap:102 telephone-event/8000
a=fmtp:102 0-16

Implementing a sip server, receiving calls

I have studied the fone example, and it seems very interesting, the control and safety we have with handling the audio.

But this is how a client generates a an invite to another agent.

I am wondering what approach should be taken to implement an agent waiting to receive calls, and handle the calls in the same way.

Can anyone point out how i could implement it?

Compilation issue: missing function body

Hello,

I'm getting the following compilation error while trying to use this package. From what I understand, this has something to do with assembly implementation of these func signatures.

Is there a flag I need to pass to make it work?

# github.com/jart/gosip/dsp
../dsp/dsp.go:22:6: missing function body
../dsp/dsp.go:28:6: missing function body
../dsp/dsp.go:31:6: missing function body

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.