diff options
author | Alfred E. Heggestad <aeh@db.org> | 2014-02-09 12:13:14 +0100 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2014-02-09 12:13:14 +0100 |
commit | d6bcd7c20bb142fc598e3173126f0993f8ba7d59 (patch) | |
tree | a9912a129d9818c4a133f3847092f556d4b266e5 | |
parent | ad3acd71826fa718d8bfd587fdf71576fc598260 (diff) |
fakevideo: new module for fake video input/output
Suggested-by: Fadeev Alexander
-rw-r--r-- | docs/README | 116 | ||||
-rw-r--r-- | mk/modules.mk | 3 | ||||
-rw-r--r-- | modules/fakevideo/fakevideo.c | 182 | ||||
-rw-r--r-- | modules/fakevideo/module.mk | 11 |
4 files changed, 312 insertions, 0 deletions
diff --git a/docs/README b/docs/README index 7fe24bd..2468bfd 100644 --- a/docs/README +++ b/docs/README @@ -7,6 +7,121 @@ Copyright (c) 2010 - 2014 Creytiv.com Distributed under BSD license +Features: + +* Call features: + - Unlimited number of SIP accounts + - Unlimited number of calls + - Unattended call transfer + - Auto answer + - Call hold and resume + - Microphone mute + - Call waiting + - Call recording + - Peer to peer calls + - Video calls + - Instant Messaging + - Custom ring tones + - Repeat last call (redial) + - Message Waiting Indication (MWI) + - Address book with presence + +* Signaling: + - SIP protocol support + - SIP outbound protocol for NAT-traversal + - SIP Re-invite + - SIP Routes + - SIP early media support + - DNS NAPTR/SRV support + - Multiple accounts support + - DTMF support (RTP, SIP INFO) + +* Security: + - Signalling encryption (TLS) + - Audio and video encryption (Secure RTP) + - DTLS-SRTP key exchange protocol + - ZRTP key exchange protocol + - SDES key exchange protocol + +* Audio: + - Low latency audio pipeline + - High definition audio codecs + - Audio device configuration + - Audio filter plugins + - Internal audio resampler for fixed sampling rates + - Linear 16 bit wave format support for ringtones + - Packet loss concealment (PLC) + - Configurable ringtone playback device + - Automatic gain control (AGC) and Noise reducation + - Acoustic echo control (AEC) + +* Audio-codecs: + - AMR narrowband, AMR wideband + - BroadVoice32 BV32 + - CELT + - G.711 + - G.722 + - G.726 + - GSM + - iLBC + - iSAC + - L16 + - Opus + - Silk + - Speex + +* Audio-drivers: + - Advanced Linux Sound Architecture (ALSA) audio-driver + - Android OpenSLES audio-driver + - Gstreamer playbin input audio-driver + - MacOSX/iOS coreaudio/audiounit audio-driver + - Open Sound System (OSS) audio-driver + - Portaudio audio-driver + - Windows winwave audio-driver + +* Video: + - Support for H.264, H.263, VP8, MPEG-4 Video + - Configurable resolution/framerate/bitrate + - Configurable video input/output + - Support for asymmetric video + +* Video-codecs: + - H.264 + - H.263 + - VP8 + - MPEG-4 + +* Video-drivers: + - iOS avcapture video-source + - FFmpeg libavformat/avdevice input + - Cairo video-source test module + - Direct Show video-source + - MacOSX QTcapture/quicktime video-source + - RST media player + - Linux V4L/V4L2 video-source + - X11 grabber video-source + - DirectFB video-output + - OpenGL/OpenGLES video-output + - SDL/SDL2 video-output + - X11 video-output + +* NAT-traversal: + - STUN support + - TURN server support + - ICE and ICE-lite support + - NATPMP support + +* Networking: + - multihoming, IPv4/IPv6 + - automatic network roaming + +* Management: + - Embedded web-server with HTTP interface + - Command-line console over UDP/TCP + - Command line interface (CLI) + - Simple configuration files + + Design goals: * Minimalistic and modular VoIP client @@ -38,6 +153,7 @@ directfb DirectFB video display module dshow Windows DirectShow video source dtls_srtp DTLS-SRTP end-to-end encryption evdev Linux input driver +fakevideo Fake video input/output driver g711 G.711 audio codec g722 G.722 audio codec g7221 G.722.1 audio codec diff --git a/mk/modules.mk b/mk/modules.mk index 64428a4..f5fedc7 100644 --- a/mk/modules.mk +++ b/mk/modules.mk @@ -205,6 +205,9 @@ MODULES += aubridge endif ifneq ($(USE_VIDEO),) MODULES += vidloop selfview vidbridge +ifneq ($(HAVE_PTHREAD),) +MODULES += fakevideo +endif endif diff --git a/modules/fakevideo/fakevideo.c b/modules/fakevideo/fakevideo.c new file mode 100644 index 0000000..fbeeb60 --- /dev/null +++ b/modules/fakevideo/fakevideo.c @@ -0,0 +1,182 @@ +/** + * @file fakevideo.c Fake video source and video display + * + * Copyright (C) 2010 Creytiv.com + */ +#define _BSD_SOURCE 1 +#include <unistd.h> +#include <pthread.h> +#include <re.h> +#include <rem.h> +#include <baresip.h> + + +struct vidsrc_st { + struct vidsrc *vs; /* inheritance */ + struct vidframe *frame; + pthread_t thread; + bool run; + int fps; + vidsrc_frame_h *frameh; + void *arg; +}; + +struct vidisp_st { + struct vidisp *vd; /* inheritance */ +}; + + +static struct vidsrc *vidsrc; +static struct vidisp *vidisp; + + +static void *read_thread(void *arg) +{ + struct vidsrc_st *st = arg; + uint64_t ts = tmr_jiffies(); + + while (st->run) { + + if (tmr_jiffies() < ts) { + sys_msleep(4); + continue; + } + + st->frameh(st->frame, st->arg); + + ts += (1000/st->fps); + } + + return NULL; +} + + +static void src_destructor(void *arg) +{ + struct vidsrc_st *st = arg; + + if (st->run) { + st->run = false; + pthread_join(st->thread, NULL); + } + + mem_deref(st->frame); + mem_deref(st->vs); +} + + +static void disp_destructor(void *arg) +{ + struct vidisp_st *st = arg; + + mem_deref(st->vd); +} + + +static int src_alloc(struct vidsrc_st **stp, struct vidsrc *vs, + struct media_ctx **ctx, struct vidsrc_prm *prm, + const struct vidsz *size, const char *fmt, + const char *dev, vidsrc_frame_h *frameh, + vidsrc_error_h *errorh, void *arg) +{ + struct vidsrc_st *st; + int err; + + (void)ctx; + (void)fmt; + (void)dev; + (void)errorh; + + if (!stp || !prm || !size || !frameh) + return EINVAL; + + st = mem_zalloc(sizeof(*st), src_destructor); + if (!st) + return ENOMEM; + + st->vs = mem_ref(vs); + st->fps = prm->fps; + st->frameh = frameh; + st->arg = arg; + + err = vidframe_alloc(&st->frame, VID_FMT_YUV420P, size); + if (err) + goto out; + + st->run = true; + err = pthread_create(&st->thread, NULL, read_thread, st); + if (err) { + st->run = false; + goto out; + } + + out: + if (err) + mem_deref(st); + else + *stp = st; + + return err; +} + + +static int disp_alloc(struct vidisp_st **stp, struct vidisp *vd, + struct vidisp_prm *prm, const char *dev, + vidisp_resize_h *resizeh, void *arg) +{ + struct vidisp_st *st; + (void)prm; + (void)dev; + (void)resizeh; + (void)arg; + + if (!stp || !vd) + return EINVAL; + + st = mem_zalloc(sizeof(*st), disp_destructor); + if (!st) + return ENOMEM; + + st->vd = mem_ref(vd); + + *stp = st; + + return 0; +} + + +static int display(struct vidisp_st *st, const char *title, + const struct vidframe *frame) +{ + (void)st; + (void)title; + (void)frame; + + return 0; +} + + +static int module_init(void) +{ + int err = 0; + err |= vidsrc_register(&vidsrc, "fakevideo", src_alloc, NULL); + err |= vidisp_register(&vidisp, "fakevideo", disp_alloc, NULL, + display, NULL); + return err; +} + + +static int module_close(void) +{ + vidsrc = mem_deref(vidsrc); + vidisp = mem_deref(vidisp); + return 0; +} + + +EXPORT_SYM const struct mod_export DECL_EXPORTS(fakevideo) = { + "fakevideo", + "fakevideo", + module_init, + module_close +}; diff --git a/modules/fakevideo/module.mk b/modules/fakevideo/module.mk new file mode 100644 index 0000000..fbe1e63 --- /dev/null +++ b/modules/fakevideo/module.mk @@ -0,0 +1,11 @@ +# +# module.mk +# +# Copyright (C) 2010 Creytiv.com +# + +MOD := fakevideo +$(MOD)_SRCS += fakevideo.c +$(MOD)_LFLAGS += + +include mk/mod.mk |