{"id":20785554,"url":"https://github.com/folkertvanheusden/libhappy","last_synced_at":"2026-03-15T22:41:21.213Z","repository":{"id":39659955,"uuid":"488711770","full_name":"folkertvanheusden/libHappy","owner":"folkertvanheusden","description":"libHappy is a library with which you can interface an audio source/sink to a SIP server. It should be as easy to use as possible.","archived":false,"fork":false,"pushed_at":"2023-11-26T21:30:15.000Z","size":156,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T21:51:16.603Z","etag":null,"topics":["c-plus-plus","library","rtp","sdp","sip","voip"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/folkertvanheusden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["folkertvanheusden"]}},"created_at":"2022-05-04T19:03:26.000Z","updated_at":"2024-08-17T20:36:27.000Z","dependencies_parsed_at":"2023-11-26T22:24:51.662Z","dependency_job_id":"1a5f3353-f4fc-4851-a4f4-42b041915297","html_url":"https://github.com/folkertvanheusden/libHappy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folkertvanheusden%2FlibHappy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folkertvanheusden%2FlibHappy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folkertvanheusden%2FlibHappy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/folkertvanheusden%2FlibHappy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/folkertvanheusden","download_url":"https://codeload.github.com/folkertvanheusden/libHappy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252516278,"owners_count":21760749,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","library","rtp","sdp","sip","voip"],"created_at":"2024-11-17T14:46:16.113Z","updated_at":"2026-03-15T22:41:16.191Z","avatar_url":"https://github.com/folkertvanheusden.png","language":"C++","funding_links":["https://github.com/sponsors/folkertvanheusden"],"categories":[],"sub_categories":[],"readme":"what it is\n----------\n\nThis program allows you to interface to a VOIP/SIP server.\n\nWhen connected, you will receive audio and dtmf from incoming calls (only) via callbacks.\n\nVia these callbacks you will be notified of new sessions, you will receive audio and can send audio and you will be informed about DTMF key presses.\n\n\ncompiling the library\n---------------------\n\nrequired packages:\n* libsamplerate0-dev\n\nfor the alsa test program:\n* libasound2-dev\n\nYou need 'cmake' (and 'build-essentials' on debian/ubuntu) to build the library/test programs.\n\ncmake install\n\n... will install the library and a .pc-file (for pkg-config).\n\nNote that if the libg722 directory is empty, then invoke first (before running make):\n* cd libg722\n* git submodule init\n* git submodule update\n* cd ..\n\n\ndemo\n----\n\nCall +31317794512. Then in the main menu press '2' and in the second menu press '7'. You will/should hear music playing and if so, you can talk which will be heard by the people playing the music.\n\n\nusage\n-----\nSee testhappy[-alsa].cpp for examples how to use the library in your own program.\n\nUsing the library should be not too difficult.\n\nYou instantiate the 'sip' class with the following parameters\n\n* upstream SIP server: IP address of the SIP server you want to talk to (this server should route calls to the extension for which the library will register)\n\n* upstream SIP server user: username of the SIP account you want to use\n* upstream SIP server password: password of the SIP account you want to use\n\n* local IP address: this is only required if there is a NAT router between libhappy and the target sip-server or when the local IP address cannot automatically be determined, else use { }\n\n* local port: UDP port on which the library will listen for incoming SIP packets. normally you would set this to 0 for automatically choose one.\n\n* register interval: how often to login/notify the SIP server that we're ready to use the service\n\n* sample rate: sample rate of the audio send to/expected from the callbacks. E.g. 44100.\n\nThe last 5 parameters are pointers to the callback functions:\n\n* bool new\\_session(session\\_t \\*const session, const std::string \u0026 from)\n  Called when a new SIP session is starting. Return true if you're ready, false to deny.\n  session-\\\u003eheaders contains all the INVITE request-headers.\n  'from' is a copy of the SIP \"From\"-field. It contains the address of the caller.\n\n* bool recv\\_callback(const short \\*const samples, const size\\_t n\\_samples, sip\\_session\\_t \\*const session)\n  Called when the library received audio from \"the other end\" (the peer). Return false if you want to abort the session.\n\n* bool send\\_callback(short \\*\\*const samples, size\\_t \\*const n\\_samples, sip\\_session\\_t \\*const session)\n  Called when the library should transmit audio to the peer. Return false if you want to abort the session.\n\n* void end\\_session(sip\\_session\\_t \\*const session)\n  Called when the session is terminated by the other end.\n\n* void dtmf(const uint8\\_t dtmf\\_code, const bool is\\_end, const uint8\\_t volume, sip\\_session\\_t \\*const session)\n  Called when a DTMF code is received. This can come in multiple times, depending on how long someone keeps the button on the phone pressed.\n\n\nWhen the sip-class is instantiated with the parameters above then you can receive calls.\n\nWhen you invoke:\n\n    auto rc = initiate_call(const std::string \u0026 target, const std::string \u0026 local_address, const int timeout);\n\ne.g.:\n\n    auto rc = initiate_call(\"22222@vps001.vanheusden.com\", \"9997\", 15, true);\n\n...then libHappy will make a call to 22222@vps001.vanheusden.com with \"9997@upstream-sip-server\" as your local endpoint.\n15 is the number of seconds it will wait for the other end to respond.\n\nIf 'direct' is true then the library will connect directly to the peer, not via the 'upstream\\_sip\\_server.\n\n\nThe sip\\_session\\_t structure contains a few parameters relevant to the session.\nThe only ones you should use are:\n\n* call\\_id - this should be a unique identifier for a session.\n\n* private\\_data - this pointer can be used to store private session data. You should free it yourself in e.g. the end\\_session callback.\n\n* schema.frame\\_duration - this integer tells you how long (in milliseconds) a packet of data should be (maximum) when send\\_callback is invoked.\n\n\nThis library has been tested with the Asterisk VOIP server application (SIP and the new PJSIP drivers).\nYou may need to tell your VOIP server to use either ALAW, PCMA, ULAW, PCMU, G.722 or L16.\nWhen using PJSIP in Asterisk, set \"auth\\_type = md5\" for the libhappy endpoint.\n\n\nwritten by Folkert van Heusden \u003cmail@vanheusden.com\u003e in 2022-2023\n\nCC0 license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolkertvanheusden%2Flibhappy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffolkertvanheusden%2Flibhappy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffolkertvanheusden%2Flibhappy/lists"}