Skip to content

Commit

Permalink
Merge pull request #6 from alfredh/master
Browse files Browse the repository at this point in the history
Merge Upstream
  • Loading branch information
sreimers committed May 23, 2015
2 parents 1833f3a + 034ec8f commit e6e9657
Show file tree
Hide file tree
Showing 20 changed files with 431 additions and 55 deletions.
6 changes: 3 additions & 3 deletions docs/COPYING
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Copyright (c) 2010 - 2014, Alfred E. Heggestad
Copyright (c) 2010 - 2014, Richard Aas
Copyright (c) 2010 - 2014, Creytiv.com
Copyright (c) 2010 - 2015, Alfred E. Heggestad
Copyright (c) 2010 - 2015, Richard Aas
Copyright (c) 2010 - 2015, Creytiv.com
All rights reserved.


Expand Down
2 changes: 1 addition & 1 deletion docs/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ README
------

Baresip is a portable and modular SIP User-Agent with audio and video support
Copyright (c) 2010 - 2014 Creytiv.com
Copyright (c) 2010 - 2015 Creytiv.com

Distributed under BSD license

Expand Down
4 changes: 4 additions & 0 deletions include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,13 @@ enum presence_status {

struct contact;

int contact_init(void);
void contact_close(void);
int contact_add(struct contact **contactp, const struct pl *addr);
int contacts_print(struct re_printf *pf, void *unused);
void contact_set_presence(struct contact *c, enum presence_status status);
bool contact_block_access(const char *uri);
struct contact *contact_find(const char *uri);
struct sip_addr *contact_addr(const struct contact *c);
struct list *contact_list(void);
const char *contact_str(const struct contact *c);
Expand Down
17 changes: 5 additions & 12 deletions modules/avcapture/avcapture.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <AVFoundation/AVFoundation.h>


static struct vidsrc *vidsrcv[4];
static struct vidsrc *vidsrc;


@interface avcap : NSObject < AVCaptureVideoDataOutputSampleBufferDelegate >
Expand Down Expand Up @@ -354,7 +354,6 @@ static int module_init(void)
AVCaptureDevice *dev = nil;
NSAutoreleasePool *pool;
Class cls = NSClassFromString(@"AVCaptureDevice");
size_t i = 0;
int err = 0;
if (!cls)
return ENOSYS;
Expand All @@ -366,14 +365,11 @@ static int module_init(void)

const char *name = [[dev localizedName] UTF8String];

if (i >= ARRAY_SIZE(vidsrcv))
break;

err = vidsrc_register(&vidsrcv[i++], name, alloc, update);
if (err)
break;
debug("avcapture: found video device '%s'\n", name);
}

err = vidsrc_register(&vidsrc, "avcapture", alloc, update);

[pool drain];

return err;
Expand All @@ -382,10 +378,7 @@ static int module_init(void)

static int module_close(void)
{
size_t i;

for (i=0; i<ARRAY_SIZE(vidsrcv); i++)
vidsrcv[i] = mem_deref(vidsrcv[i]);
vidsrc = mem_deref(vidsrc);

return 0;
}
Expand Down
10 changes: 9 additions & 1 deletion modules/contact/contact.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,18 @@ static int write_template(const char *file)
"#\n"
"# addr-params:\n"
"# ;presence={none,p2p}\n"
"# ;access={allow,block}\n"
"#\n"
"\n"
"\n"
"\"Echo Server\" <sip:[email protected]>\n"
"\"%s\" <sip:%s@%s>;presence=p2p\n",
"\"%s\" <sip:%s@%s>;presence=p2p\n"
"\n"
"# Access rules\n"
"\"Catch All\" <sip:*@*>;access=block\n"
"\"Good Friend\" <sip:[email protected]>;access=allow\n"
"\n"
,
user, user, domain);

if (f)
Expand Down
2 changes: 1 addition & 1 deletion modules/v4l2/v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <re.h>
#include <rem.h>
#include <baresip.h>
#if defined (OPENBSD)
#if defined (OPENBSD) || defined (NETBSD)
#include <sys/videoio.h>
#else
#include <linux/videodev2.h>
Expand Down
20 changes: 18 additions & 2 deletions modules/vidloop/vidloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct video_loop {
struct tmr tmr_bw;
uint16_t seq;
bool need_conv;
int err;
};


Expand All @@ -65,8 +66,17 @@ static int display(struct video_loop *vl, struct vidframe *frame)
err |= st->vf->dech(st, frame);
}

if (err) {
warning("vidloop: error in video-filters (%m)\n", err);
}

/* display frame */
(void)vidisp_display(vl->vidisp, "Video Loop", frame);
err = vidisp_display(vl->vidisp, "Video Loop", frame);
if (err == ENODEV) {
info("vidloop: video-display was closed\n");
vl->vidisp = mem_deref(vl->vidisp);
vl->err = err;
}

return err;
}
Expand Down Expand Up @@ -265,7 +275,13 @@ static void timeout_bw(void *arg)
{
struct video_loop *vl = arg;

tmr_start(&vl->tmr_bw, 5000, timeout_bw, vl);
if (vl->err) {
info("error in video-loop -- closing (%m)\n", vl->err);
gvl = mem_deref(gvl);
return;
}

tmr_start(&vl->tmr_bw, 2000, timeout_bw, vl);

calc_bitrate(vl);
print_status(vl);
Expand Down
72 changes: 60 additions & 12 deletions modules/x11/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct vidisp_st {
bool xshmat;
bool internal;
enum vidfmt pixfmt;
Atom XwinDeleted;
};


Expand All @@ -52,34 +53,48 @@ static int error_handler(Display *d, XErrorEvent *e)
}


static void destructor(void *arg)
static void close_window(struct vidisp_st *st)
{
struct vidisp_st *st = arg;

if (st->image) {
st->image->data = NULL;
XDestroyImage(st->image);
}

if (st->gc)
if (st->gc && st->disp) {
XFreeGC(st->disp, st->gc);
st->gc = NULL;
}

if (st->xshmat)
if (st->xshmat && st->disp) {
XShmDetach(st->disp, &st->shm);
}

if (st->shm.shmaddr != (char *)-1)
if (st->shm.shmaddr != (char *)-1) {
shmdt(st->shm.shmaddr);
st->shm.shmaddr = (char *)-1;
}

if (st->shm.shmid >= 0)
shmctl(st->shm.shmid, IPC_RMID, NULL);

if (st->disp) {
if (st->internal && st->win)
if (st->internal && st->win) {
XDestroyWindow(st->disp, st->win);
st->win = 0;
}

XCloseDisplay(st->disp);
st->disp = NULL;
}
}


static void destructor(void *arg)
{
struct vidisp_st *st = arg;

if (st->image) {
st->image->data = NULL;
XDestroyImage(st->image);
}

close_window(st);

mem_deref(st->vd);
}

Expand All @@ -96,6 +111,12 @@ static int create_window(struct vidisp_st *st, const struct vidsz *sz)
XClearWindow(st->disp, st->win);
XMapRaised(st->disp, st->win);

/*
* setup to catch window deletion
*/
st->XwinDeleted = XInternAtom(st->disp, "WM_DELETE_WINDOW", True);
XSetWMProtocols(st->disp, st->win, &st->XwinDeleted, 1);

return 0;
}

Expand Down Expand Up @@ -261,6 +282,33 @@ static int display(struct vidisp_st *st, const char *title,
struct vidframe frame_rgb;
int err = 0;

if (!st->disp)
return ENODEV;

/*
* check for window delete - without blocking
*/
while (XPending(st->disp)) {

XEvent e;

XNextEvent(st->disp, &e);

if (e.type == ClientMessage) {
if ((Atom) e.xclient.data.l[0] == st->XwinDeleted) {

info("x11: window deleted\n");

/*
* we have to bail as all of the display
* pointers are bad.
*/
close_window(st);
return ENODEV;
}
}
}

if (!vidsz_cmp(&st->size, &frame->size)) {
char capt[256];

Expand Down
5 changes: 3 additions & 2 deletions modules/zrtp/zrtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static int verify_sas(struct re_printf *pf, void *arg)
char *s2h;
char rzid[ZRTP_STRING16] = "";
zrtp_status_t s;
zrtp_string16_t remote_zid;
zrtp_string16_t remote_zid = ZSTR_INIT_EMPTY(remote_zid);

if (str_len(carg->prm) != 24) {
warning("zrtp: invalid remote ZID (%s)\n", carg->prm);
Expand All @@ -289,7 +289,8 @@ static int verify_sas(struct re_printf *pf, void *arg)
warning("zrtp: str2hex failed (%s)\n", s2h);
return EINVAL;
}
zrtp_zstrcpyc(ZSTR_GV(remote_zid), rzid);
zrtp_zstrncpyc(ZSTR_GV(remote_zid), (const char*)rzid,
sizeof(zrtp_zid_t));

s = zrtp_cache_set_verified(zrtp_global->cache,
ZSTR_GV(remote_zid),
Expand Down
Binary file modified share/busy.wav
Binary file not shown.
Binary file modified share/error.wav
Binary file not shown.
Binary file modified share/message.wav
Binary file not shown.
Binary file modified share/notfound.wav
Binary file not shown.
Binary file modified share/ring.wav
Binary file not shown.
15 changes: 14 additions & 1 deletion src/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ static void audio_error_handler(int err, const char *str, void *arg)
}


static void video_error_handler(int err, const char *str, void *arg)
{
struct call *call = arg;
MAGIC_CHECK(call);

warning("call: video device error: %m (%s)\n", err, str);

call_stream_stop(call);
call_event_handler(call, CALL_EVENT_CLOSED, str);
}


static void menc_error_handler(int err, void *arg)
{
struct call *call = arg;
Expand Down Expand Up @@ -523,7 +535,8 @@ int call_alloc(struct call **callp, const struct config *cfg, struct list *lst,
acc->mnat, call->mnats,
acc->menc, call->mencs,
"main",
account_vidcodecl(call->acc));
account_vidcodecl(call->acc),
video_error_handler, call);
if (err)
goto out;
}
Expand Down
Loading

0 comments on commit e6e9657

Please sign in to comment.