gobaresip

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2021 License: BSD-3-Clause Imports: 19 Imported by: 1

README

go-baresip

Is a tiny wrapper around baresip

Basic Usage

func main() {

    gb, err := gobaresip.New(gobaresip.SetConfigPath("."))
    if err != nil {
        log.Println(err)
        return
    }

    eChan := gb.GetEventChan()
    rChan := gb.GetResponseChan()

    go func() {
        for {
            select {
            case e, ok := <-eChan:
                if !ok {
                    continue
                }
                log.Println(e)
            case r, ok := <-rChan:
                if !ok {
                    continue
                }
                log.Println(r)
            }
        }
    }()

    go func() {
        // Give baresip some time to init and register ua
        time.Sleep(1 * time.Second)

        if err := gb.CmdDial("012345"); err != nil {
            log.Println(err)
        }
    }()

    err = gb.Run()
    if err != nil {
        log.Println(err)
    }
    defer gb.Close()
}

Documentation

Overview

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAudioPath

func SetAudioPath(opt string) func(*Baresip) error

SetAudioPath sets the audio path.

func SetConfigPath

func SetConfigPath(opt string) func(*Baresip) error

SetConfigPath sets the config path.

func SetCtrlTCPAddr

func SetCtrlTCPAddr(opt string) func(*Baresip) error

SetCtrlTCPAddr sets the ctrl_tcp modules address.

func SetDebug

func SetDebug(opt bool) func(*Baresip) error

SetDebug sets the debug mode.

func SetUserAgent

func SetUserAgent(opt string) func(*Baresip) error

SetUserAgent sets the UserAgent.

func SetWsAddr

func SetWsAddr(opt string) func(*Baresip) error

SetWsAddr sets the ws address.

Types

type Baresip

type Baresip struct {
	// contains filtered or unexported fields
}

func New

func New(options ...func(*Baresip) error) (*Baresip, error)

func (*Baresip) Close

func (b *Baresip) Close()

func (*Baresip) Cmd

func (b *Baresip) Cmd(command, params, token string) error

Cmd will send a raw baresip command over ctrl_tcp.

func (*Baresip) CmdAccept

func (b *Baresip) CmdAccept() error

CmdAccept will accept incoming call

func (*Baresip) CmdAcceptdir

func (b *Baresip) CmdAcceptdir(s string) error

CmdAcceptdir will accept incoming call with audio and videodirection.

func (*Baresip) CmdAnswermode

func (b *Baresip) CmdAnswermode(s string) error

CmdAnswermode will set answer mode

func (*Baresip) CmdAuplay

func (b *Baresip) CmdAuplay(s string) error

CmdAuplay will switch audio player

func (*Baresip) CmdAusrc

func (b *Baresip) CmdAusrc(s string) error

CmdAusrc will switch audio source

func (*Baresip) CmdAutocmdinfo

func (b *Baresip) CmdAutocmdinfo() error

func (*Baresip) CmdAutodial

func (b *Baresip) CmdAutodial(s string) error

CmdAutodial will dial number automatically

func (*Baresip) CmdAutodialadd

func (b *Baresip) CmdAutodialadd(s string) error

func (*Baresip) CmdAutodialdel

func (b *Baresip) CmdAutodialdel(s string) error

func (*Baresip) CmdAutodialdelay

func (b *Baresip) CmdAutodialdelay(n int) error

CmdAutodialdelay will set delay before auto dial [ms]

func (*Baresip) CmdAutohangup

func (b *Baresip) CmdAutohangup() error

CmdAutohangup will hangup call automatically

func (*Baresip) CmdAutohangupdelay

func (b *Baresip) CmdAutohangupdelay(n int) error

CmdAutohangupdelay will set delay before hangup [ms]

func (*Baresip) CmdAutohangupgap

func (b *Baresip) CmdAutohangupgap(s string) error

func (*Baresip) CmdCallstat

func (b *Baresip) CmdCallstat() error

CmdCallstat will show call status

func (*Baresip) CmdContact_next

func (b *Baresip) CmdContact_next() error

CmdContact_next will set next contact

func (*Baresip) CmdContact_prev

func (b *Baresip) CmdContact_prev() error

CmdContact_prev will set previous contact

func (*Baresip) CmdDial

func (b *Baresip) CmdDial(s string) error

CmdDial will dial number

func (*Baresip) CmdDialcontact

func (b *Baresip) CmdDialcontact() error

CmdDialcontact will dial current contact

func (*Baresip) CmdDialdir

func (b *Baresip) CmdDialdir(s string) error

CmdDialdir will dial with audio and videodirection

func (*Baresip) CmdHangup

func (b *Baresip) CmdHangup() error

CmdHangup will hangup call

func (*Baresip) CmdHangupID

func (b *Baresip) CmdHangupID(callID string) error

CmdHangupID will hangup call with Call-ID

func (*Baresip) CmdHangupall

func (b *Baresip) CmdHangupall(s string) error

CmdHangupall will hangup all calls with direction

func (*Baresip) CmdInsmod

func (b *Baresip) CmdInsmod(s string) error

CmdInsmod will load module

func (*Baresip) CmdListcalls

func (b *Baresip) CmdListcalls() error

CmdListcalls will list active calls

func (*Baresip) CmdQuit

func (b *Baresip) CmdQuit() error

CmdQuit will quit baresip

func (*Baresip) CmdReginfo

func (b *Baresip) CmdReginfo() error

CmdReginfo will list registration info

func (*Baresip) CmdRmmod

func (b *Baresip) CmdRmmod(s string) error

CmdRmmod will unload module

func (*Baresip) CmdSetadelay

func (b *Baresip) CmdSetadelay(n int) error

CmdSetadelay will set answer delay for outgoing call

func (*Baresip) CmdUadel

func (b *Baresip) CmdUadel(s string) error

CmdUadel will delete User-Agent

func (*Baresip) CmdUadelall

func (b *Baresip) CmdUadelall() error

CmdUadelall will delete all User-Agents

func (*Baresip) CmdUafind

func (b *Baresip) CmdUafind(s string) error

CmdUafind will find User-Agent <aor>

func (*Baresip) CmdUanew

func (b *Baresip) CmdUanew(s string) error

CmdUanew will create User-Agent

func (*Baresip) CmdUareg

func (b *Baresip) CmdUareg(s string) error

CmdUareg will register <regint> [index]

func (*Baresip) CmdWs

func (b *Baresip) CmdWs(raw []byte) error

func (*Baresip) GetEventChan

func (b *Baresip) GetEventChan() <-chan EventMsg

GetEventChan returns the receive-only EventMsg channel for reading data.

func (*Baresip) GetResponseChan

func (b *Baresip) GetResponseChan() <-chan ResponseMsg

GetResponseChan returns the receive-only ResponseMsg channel for reading data.

func (*Baresip) Run

func (b *Baresip) Run() error

Run a baresip instance

func (*Baresip) SetOption

func (b *Baresip) SetOption(options ...func(*Baresip) error) error

SetOption takes one or more option function and applies them in order to Baresip.

type CommandMsg

type CommandMsg struct {
	Command string `json:"command,omitempty"`
	Params  string `json:"params,omitempty"`
	Token   string `json:"token,omitempty"`
}

CommandMsg struct for ctrl_tcp

type EventMsg

type EventMsg struct {
	Event           bool   `json:"event,omitempty"`
	Type            string `json:"type,omitempty"`
	Class           string `json:"class,omitempty"`
	AccountAOR      string `json:"accountaor,omitempty"`
	Direction       string `json:"direction,omitempty"`
	PeerURI         string `json:"peeruri,omitempty"`
	PeerDisplayname string `json:"peerdisplayname,omitempty"`
	ID              string `json:"id,omitempty"`
	RemoteAudioDir  string `json:"remoteaudiodir,omitempty"`
	Param           string `json:"param,omitempty"`
	RawJSON         []byte `json:"-"`
}

EventMsg

type ResponseMsg

type ResponseMsg struct {
	Response bool   `json:"response,omitempty"`
	Ok       bool   `json:"ok,omitempty"`
	Data     string `json:"data,omitempty"`
	Token    string `json:"token,omitempty"`
	RawJSON  []byte `json:"-"`
}

ResponseMsg

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL