Skip to content

Commit

Permalink
Update libs
Browse files Browse the repository at this point in the history
  • Loading branch information
negbie committed Jun 3, 2021
1 parent 0482cd5 commit d794611
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package gobaresip

import (
"bytes"
"encoding/json"
"fmt"
"strconv"
"strings"
"sync/atomic"
"time"
"unicode"

"github.com/goccy/go-json"
)

/*
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module github.com/negbie/go-baresip

go 1.16

require github.com/gorilla/websocket v1.4.2
require (
github.com/goccy/go-json v0.6.1
github.com/gorilla/websocket v1.4.2
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/goccy/go-json v0.6.1 h1:O7xC9WR7B09imThbRIEMIWK4MVcxOsLzWtGe16cv5SU=
github.com/goccy/go-json v0.6.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
14 changes: 4 additions & 10 deletions gobaresip.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ int mainLoop(){
import "C"
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net"
Expand All @@ -79,6 +78,8 @@ import (
"sync/atomic"
"time"
"unsafe"

"github.com/goccy/go-json"
)

//ResponseMsg
Expand Down Expand Up @@ -221,7 +222,7 @@ func (b *Baresip) read() {
b.eventChan <- e
if b.wsAddr != "" {
select {
case b.eventWsChan <- appendByte(e.RawJSON, []byte("\n")):
case b.eventWsChan <- e.RawJSON:
default:
}
}
Expand Down Expand Up @@ -271,21 +272,14 @@ func (b *Baresip) read() {
b.responseChan <- r
if b.wsAddr != "" {
select {
case b.responseWsChan <- appendByte(r.RawJSON, []byte("\n")):
case b.responseWsChan <- r.RawJSON:
default:
}
}
}
}
}

func appendByte(prefix []byte, suffix []byte) []byte {
b := make([]byte, len(prefix)+len(suffix))
n := copy(b, prefix)
copy(b[n:], suffix)
return b
}

func findID(data []byte) string {
if posA := bytes.Index(data, []byte("call id: ")); posA > 0 {
if posB := bytes.Index(data[posA:], []byte("\n")); posB > 0 {
Expand Down
2 changes: 2 additions & 0 deletions libbaresip/baresip/include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ const char *account_call_transfer(const struct account *acc);
const char *account_extra(const struct account *acc);
int account_uri_complete(const struct account *acc, struct mbuf *buf,
const char *uri);
int account_answerdelay(const struct account *acc);
void account_set_answerdelay(struct account *acc, int adelay);
bool account_sip_autoanswer(const struct account *acc);
void account_set_sip_autoanswer(struct account *acc, bool allow);
enum sipansbeep account_sipansbeep(const struct account *acc);
Expand Down
Binary file modified libbaresip/baresip/libbaresip.a
Binary file not shown.
Binary file modified libbaresip/openssl/libcrypto.a
Binary file not shown.
1 change: 1 addition & 0 deletions libbaresip/rem/include/rem_au.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum aufmt {
AUFMT_PCMU, /**< G.711 U-law */
AUFMT_FLOAT, /**< Float 32 bit (CPU endian) */
AUFMT_S24_3LE,/**< Signed 24bit Little Endian in 3bytes format */
AUFMT_RAW, /**< RAW PCM */
};

size_t aufmt_sample_size(enum aufmt fmt);
Expand Down
6 changes: 3 additions & 3 deletions libbaresip/rem/include/rem_auframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* Defines a frame of audio samples
*/
struct auframe {
int fmt; /**< Sample format (enum aufmt) */
enum aufmt fmt; /**< Sample format (enum aufmt) */
void *sampv; /**< Audio samples (must be mem_ref'd) */
size_t sampc; /**< Total number of audio samples */
uint64_t timestamp; /**< Timestamp in AUDIO_TIMEBASE units */
uint32_t srate; /**< Samplerate */
uint8_t ch; /**< Channels */
};

void auframe_init(struct auframe *af, int fmt, void *sampv, size_t sampc,
uint32_t srate, uint8_t ch);
void auframe_init(struct auframe *af, enum aufmt fmt, void *sampv,
size_t sampc, uint32_t srate, uint8_t ch);
size_t auframe_size(const struct auframe *af);
void auframe_mute(struct auframe *af);
Binary file modified libbaresip/rem/librem.a
Binary file not shown.
5 changes: 5 additions & 0 deletions ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const (
maxMessageSize = 1024
)

var (
newline = []byte{'\n'}
)

var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
Expand Down Expand Up @@ -94,6 +98,7 @@ func (c *client) writePump() {
// Add queued messages to the current websocket message.
n := len(c.send)
for i := 0; i < n; i++ {
w.Write(newline)
w.Write(<-c.send)
}

Expand Down

0 comments on commit d794611

Please sign in to comment.