├── AUTHORS ├── NEWS ├── README ├── ChangeLog ├── .gitignore ├── src ├── dbus │ ├── audio-source-introspect.xml │ ├── audio-encoder-introspect.xml │ ├── live-streamer.conf │ ├── video-osd-introspect.xml │ ├── video-encoder-introspect.xml │ ├── Makefile.am │ ├── dbus-video-osd.h │ ├── dbus-audio-source.h │ ├── dbus-audio-encoder.h │ ├── dbus-ipcam-base.h │ ├── dbus-video-source.h │ ├── dbus-video-encoder.h │ ├── dbus-audio-source.cpp │ ├── dbusxx-libev-integration.h │ ├── dbus-audio-encoder.cpp │ ├── video-source-introspect.xml │ └── dbusxx-libev-integration.cpp ├── platform │ ├── Makefile.am │ ├── hi3516cv300 │ │ ├── Makefile.am │ │ ├── himpp-base.cpp │ │ ├── himpp-common.h │ │ ├── himpp-base.h │ │ ├── himpp-video-sensor.h │ │ ├── himpp-sysctl.h │ │ ├── himpp-media.h │ │ ├── himpp-video-region.h │ │ ├── himpp-sysctl.cpp │ │ ├── himpp-ircut.h │ │ ├── himpp-video-venc.h │ │ ├── himpp-video-vpss.h │ │ └── himpp-video-viu.h │ ├── hi3516ev200 │ │ ├── Makefile.am │ │ ├── himpp-common.h │ │ ├── himpp-base.cpp │ │ ├── himpp-base.h │ │ ├── himpp-video-sensor.h │ │ ├── himpp-sysctl.h │ │ ├── himpp-media.h │ │ ├── himpp-video-region.h │ │ ├── himpp-sysctl.cpp │ │ ├── himpp-ircut.h │ │ ├── himpp-video-venc.h │ │ ├── himpp-video-vpss.h │ │ └── himpp-video-viu.h │ └── hi3518v200 │ │ ├── Makefile.am │ │ ├── himpp-base.cpp │ │ ├── himpp-common.h │ │ ├── himpp-base.h │ │ ├── himpp-video-sensor.h │ │ ├── himpp-media.h │ │ ├── himpp-sysctl.h │ │ ├── himpp-video-region.h │ │ ├── himpp-sysctl.cpp │ │ ├── himpp-ircut.h │ │ ├── himpp-video-venc.h │ │ ├── himpp-video-vpss.h │ │ └── himpp-video-viu.h ├── common │ ├── Makefile.am │ ├── audio-source.cpp │ ├── audio-source.h │ ├── audio-encoder.h │ ├── audio-encoder.cpp │ ├── media-common.h │ ├── media-element.h │ ├── media-common.cpp │ ├── media-stream.cpp │ ├── media-element.cpp │ ├── video-encoder.h │ ├── video-osd.h │ ├── media-stream.h │ └── video-encoder.cpp ├── rtsp-server │ ├── Makefile.am │ ├── LiveStreamOutput.hh │ ├── DynamicRTSPServer.cpp │ ├── DynamicRTSPServer.hh │ ├── AACAudioEncoder.hh │ ├── EvUsageEnvironment.h │ └── LiveStreamOutput.cpp ├── Makefile.am └── ipcam-runtime.h ├── Makefile.am ├── m4 ├── ltversion.m4 ├── ltsugar.m4 └── lt~obsolete.m4 └── config.h.in /AUTHORS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | *.bak 4 | *.anjuta 5 | .anjuta* 6 | autom4te.cache/* 7 | -------------------------------------------------------------------------------- /src/dbus/audio-source-introspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | ## Created by Anjuta 3 | 4 | SUBDIRS = src 5 | 6 | dist_doc_DATA = \ 7 | README \ 8 | COPYING \ 9 | AUTHORS \ 10 | ChangeLog \ 11 | INSTALL \ 12 | NEWS 13 | 14 | 15 | 16 | # Remove doc directory on uninstall 17 | uninstall-local: 18 | -rm -r $(docdir) 19 | -------------------------------------------------------------------------------- /src/dbus/audio-encoder-introspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/platform/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | 4 | SUBDIRS = 5 | 6 | if ENABLE_HI3518V100 7 | endif 8 | 9 | if ENABLE_HI3518V200 10 | SUBDIRS += hi3518v200 11 | endif 12 | 13 | if ENABLE_HI3516CV300 14 | SUBDIRS += hi3516cv300 15 | endif 16 | 17 | if ENABLE_HI3516EV200 18 | SUBDIRS += hi3516ev200 19 | endif 20 | 21 | if ENABLE_HI3520V100 22 | endif 23 | 24 | if ENABLE_HI3520DV200 25 | endif 26 | -------------------------------------------------------------------------------- /src/dbus/live-streamer.conf: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/common/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | 4 | AM_CPPFLAGS = \ 5 | -I$(top_srcdir)/src -I$(srcdir) -I$(builddir) \ 6 | $(DBUSXX_CFLAGS) \ 7 | $(FREETYPE_CFLAGS) \ 8 | $(FONTCONFIG_CFLAGS) \ 9 | $(SDL_CFLAGS) 10 | 11 | AM_CFLAGS = -Wall 12 | AM_CXXFLAGS = -Wall 13 | 14 | 15 | noinst_LTLIBRARIES = \ 16 | libcommon.la 17 | 18 | libcommon_la_SOURCES = \ 19 | media-common.cpp \ 20 | media-common.h \ 21 | media-element.cpp \ 22 | media-element.h \ 23 | media-stream.cpp \ 24 | media-stream.h \ 25 | video-source.cpp \ 26 | video-source.h \ 27 | video-encoder.cpp \ 28 | video-encoder.h \ 29 | audio-source.cpp \ 30 | audio-source.h \ 31 | audio-encoder.cpp \ 32 | audio-encoder.h \ 33 | video-osd.cpp \ 34 | video-osd.h 35 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /src/rtsp-server/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AM_CPPFLAGS = \ 4 | -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ 5 | -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ 6 | -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ 7 | -I$(top_srcdir)/src -I$(top_srcdir)/src/common -I$(srcdir) \ 8 | $(LIVE555_CPPFLAGS) \ 9 | $(DBUSXX_CFLAGS) 10 | 11 | AM_CFLAGS = -Wall 12 | AM_CXXFLAGS = -Wall 13 | 14 | noinst_LTLIBRARIES = \ 15 | librtsp-server.la 16 | 17 | librtsp_server_la_SOURCES = \ 18 | EvUsageEnvironment.cpp \ 19 | EvUsageEnvironment.h \ 20 | DynamicRTSPServer.cpp \ 21 | DynamicRTSPServer.hh \ 22 | LiveStreamInput.cpp \ 23 | LiveStreamInput.hh \ 24 | LiveStreamOutput.cpp \ 25 | LiveStreamOutput.hh 26 | 27 | if ENABLE_VO_AACENC 28 | librtsp_server_la_SOURCES += \ 29 | AACAudioEncoder.cpp \ 30 | AACAudioEncoder.hh 31 | endif 32 | -------------------------------------------------------------------------------- /src/dbus/video-osd-introspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/common/audio-source.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * audio-source.cpp 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include "audio-source.h" 21 | 22 | 23 | namespace Ipcam { 24 | namespace Media { 25 | 26 | AudioSource::AudioSource() 27 | { 28 | } 29 | 30 | AudioSource::~AudioSource() 31 | { 32 | } 33 | 34 | uint32_t AudioSource::getChannels() 35 | { 36 | throw IpcamError(property_not_implemented); 37 | } 38 | 39 | } //namespace Media 40 | } //namespace Ipcam 41 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | 4 | AM_CPPFLAGS = \ 5 | -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ 6 | -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ 7 | -I. -I$(top_srcdir)/src -I$(top_srcdir)/src/common \ 8 | -I$(top_srcdir)/src/rtsp-server -I$(top_srcdir)/src/dbus \ 9 | -I$(top_builddir)/src/dbus \ 10 | $(LIVE555_CPPFLAGS) \ 11 | $(DBUSXX_CFLAGS) \ 12 | $(SDL_CFLAGS) \ 13 | $(HI3516CV300_CPPFLAGS) 14 | 15 | AM_CFLAGS = -Wall 16 | AM_CXXFLAGS = -Wall 17 | 18 | noinst_LTLIBRARIES = \ 19 | libhi3516cv300.la 20 | 21 | libhi3516cv300_la_SOURCES = \ 22 | himpp-common.h \ 23 | himpp-base.cpp \ 24 | himpp-base.h \ 25 | himpp-sysctl.cpp \ 26 | himpp-sysctl.h \ 27 | himpp-audio.cpp \ 28 | himpp-audio.h \ 29 | himpp-video-sensor.cpp \ 30 | himpp-video-sensor.h \ 31 | himpp-video-isp.cpp \ 32 | himpp-video-isp.h \ 33 | himpp-video-viu.cpp \ 34 | himpp-video-viu.h \ 35 | himpp-video-vpss.cpp \ 36 | himpp-video-vpss.h \ 37 | himpp-video-venc.cpp \ 38 | himpp-video-venc.h \ 39 | himpp-video-region.cpp \ 40 | himpp-video-region.h \ 41 | himpp-media.cpp \ 42 | himpp-media.h \ 43 | himpp-ircut.cpp \ 44 | himpp-ircut.h 45 | 46 | libhi3516cv300_la_LIBADD = \ 47 | $(top_builddir)/src/common/libcommon.la 48 | 49 | EXTRA_DIST = 50 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | 4 | AM_CPPFLAGS = \ 5 | -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ 6 | -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ 7 | -I. -I$(top_srcdir)/src -I$(top_srcdir)/src/common \ 8 | -I$(top_srcdir)/src/rtsp-server -I$(top_srcdir)/src/dbus \ 9 | -I$(top_builddir)/src/dbus \ 10 | $(LIVE555_CPPFLAGS) \ 11 | $(DBUSXX_CFLAGS) \ 12 | $(SDL_CFLAGS) \ 13 | $(HI3516EV200_CPPFLAGS) 14 | 15 | AM_CFLAGS = -Wall 16 | AM_CXXFLAGS = -Wall 17 | 18 | noinst_LTLIBRARIES = \ 19 | libhi3516ev200.la 20 | 21 | libhi3516ev200_la_SOURCES = \ 22 | himpp-common.h \ 23 | himpp-base.cpp \ 24 | himpp-base.h \ 25 | himpp-sysctl.cpp \ 26 | himpp-sysctl.h \ 27 | himpp-audio.cpp \ 28 | himpp-audio.h \ 29 | himpp-video-sensor.cpp \ 30 | himpp-video-sensor.h \ 31 | himpp-video-isp.cpp \ 32 | himpp-video-isp.h \ 33 | himpp-video-viu.cpp \ 34 | himpp-video-viu.h \ 35 | himpp-video-vpss.cpp \ 36 | himpp-video-vpss.h \ 37 | himpp-video-venc.cpp \ 38 | himpp-video-venc.h \ 39 | himpp-video-region.cpp \ 40 | himpp-video-region.h \ 41 | himpp-media.cpp \ 42 | himpp-media.h \ 43 | himpp-ircut.cpp \ 44 | himpp-ircut.h 45 | 46 | libhi3516ev200_la_LIBADD = \ 47 | $(top_builddir)/src/common/libcommon.la 48 | 49 | EXTRA_DIST = 50 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | 4 | AM_CPPFLAGS = \ 5 | -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ 6 | -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ 7 | -I. -I$(top_srcdir)/src -I$(top_srcdir)/src/common \ 8 | -I$(top_srcdir)/src/rtsp-server -I$(top_srcdir)/src/dbus \ 9 | -I$(top_builddir)/src/dbus \ 10 | $(LIVE555_CPPFLAGS) \ 11 | $(DBUSXX_CFLAGS) \ 12 | $(SDL_CFLAGS) \ 13 | $(HI3518V200_CPPFLAGS) 14 | 15 | AM_CFLAGS = -Wall 16 | AM_CXXFLAGS = -Wall 17 | 18 | noinst_LTLIBRARIES = \ 19 | libhi3518v200.la 20 | 21 | libhi3518v200_la_SOURCES = \ 22 | himpp-common.h \ 23 | himpp-base.cpp \ 24 | himpp-base.h \ 25 | himpp-sysctl.cpp \ 26 | himpp-sysctl.h \ 27 | himpp-audio.cpp \ 28 | himpp-audio.h \ 29 | himpp-video-sensor.cpp \ 30 | himpp-video-sensor.h \ 31 | himpp-video-isp.cpp \ 32 | himpp-video-isp.h \ 33 | himpp-video-viu.cpp \ 34 | himpp-video-viu.h \ 35 | himpp-video-vpss.cpp \ 36 | himpp-video-vpss.h \ 37 | himpp-video-venc.cpp \ 38 | himpp-video-venc.h \ 39 | himpp-video-region.cpp \ 40 | himpp-video-region.h \ 41 | himpp-media.cpp \ 42 | himpp-media.h \ 43 | himpp-ircut.cpp \ 44 | himpp-ircut.h 45 | 46 | libhi3518v200_la_LIBADD = \ 47 | $(top_builddir)/src/common/libcommon.la 48 | 49 | EXTRA_DIST = 50 | 51 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-base.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-element.cc 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include "himpp-base.h" 23 | 24 | HimppVideoElement::HimppVideoElement(HimppVideoElement* source) 25 | : VideoElement(VIDEO_ELEMENT(source)) 26 | { 27 | } 28 | 29 | MPP_CHN_S* HimppVideoElement::bindSource() 30 | { 31 | return NULL; 32 | } 33 | 34 | HimppAudioElement::HimppAudioElement(HimppAudioElement* source) 35 | : AudioElement(AUDIO_ELEMENT(source)) 36 | { 37 | } 38 | 39 | MPP_CHN_S* HimppAudioElement::bindSource() 40 | { 41 | return NULL; 42 | } 43 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-base.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-element.cc 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include "himpp-base.h" 23 | 24 | HimppVideoElement::HimppVideoElement(HimppVideoElement* source) 25 | : VideoElement(VIDEO_ELEMENT(source)) 26 | { 27 | } 28 | 29 | MPP_CHN_S* HimppVideoElement::bindSource() 30 | { 31 | return NULL; 32 | } 33 | 34 | HimppAudioElement::HimppAudioElement(HimppAudioElement* source) 35 | : AudioElement(AUDIO_ELEMENT(source)) 36 | { 37 | } 38 | 39 | MPP_CHN_S* HimppAudioElement::bindSource() 40 | { 41 | return NULL; 42 | } 43 | -------------------------------------------------------------------------------- /src/common/audio-source.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * audio-source.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _AUDIO_SOURCE_H_ 21 | #define _AUDIO_SOURCE_H_ 22 | 23 | #include 24 | 25 | namespace Ipcam { 26 | namespace Media { 27 | 28 | class AudioSource; 29 | 30 | #define AUDIO_SOURCE(o) dynamic_cast(o) 31 | 32 | class AudioSource 33 | { 34 | public: 35 | virtual ~AudioSource(); 36 | 37 | virtual uint32_t getChannels() = 0; 38 | 39 | protected: 40 | AudioSource(); 41 | }; 42 | 43 | } //namespace Media 44 | } //namespace Ipcam 45 | 46 | #endif // _AUDIO_SOURCE_H_ 47 | 48 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-common.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-common.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_COMMON_H_ 21 | #define _HIMPP_COMMON_H_ 22 | 23 | #define HIMPP_SYS_ALIGN_WIDTH 16 24 | #define HIMPP_PIXEL_FORMAT PIXEL_FORMAT_YUV_SEMIPLANAR_420 25 | 26 | #define ROUNDUP(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) 27 | #define ROUNDUP16(x) ROUNDUP(x, 16) 28 | #define ROUNDUP64(x) ROUNDUP(x, 64) 29 | 30 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 31 | 32 | #define HIMPP_PRINT(fmt, ...) \ 33 | printf("[%s:%d]:" fmt, __FILE__, __LINE__, ##__VA_ARGS__) 34 | 35 | #endif // _HIMPP_COMMON_H_ 36 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-common.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-common.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_COMMON_H_ 21 | #define _HIMPP_COMMON_H_ 22 | 23 | #define HIMPP_SYS_ALIGN_WIDTH 16 24 | #define HIMPP_PIXEL_FORMAT PIXEL_FORMAT_YUV_SEMIPLANAR_420 25 | 26 | #define ROUNDUP(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) 27 | #define ROUNDUP16(x) ROUNDUP(x, 16) 28 | #define ROUNDUP64(x) ROUNDUP(x, 64) 29 | 30 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 31 | 32 | #define HIMPP_PRINT(fmt, ...) \ 33 | printf("[%s:%d]:" fmt, __FILE__, __LINE__, ##__VA_ARGS__) 34 | 35 | #endif // _HIMPP_COMMON_H_ 36 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-common.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-common.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_COMMON_H_ 21 | #define _HIMPP_COMMON_H_ 22 | 23 | #define HIMPP_SYS_ALIGN_WIDTH 16 24 | #define HIMPP_PIXEL_FORMAT PIXEL_FORMAT_YVU_SEMIPLANAR_420 25 | 26 | #define ROUNDUP(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) 27 | #define ROUNDUP16(x) ROUNDUP(x, 16) 28 | #define ROUNDUP64(x) ROUNDUP(x, 64) 29 | 30 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 31 | 32 | #define HIMPP_PRINT(fmt, ...) \ 33 | printf("[%s:%d]:" fmt, __FILE__, __LINE__, ##__VA_ARGS__) 34 | 35 | #endif // _HIMPP_COMMON_H_ 36 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-base.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-element.cc 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include "himpp-base.h" 23 | 24 | HimppVideoElement::HimppVideoElement(HimppVideoElement* source) 25 | : VideoElement(VIDEO_ELEMENT(source)) 26 | { 27 | } 28 | 29 | MPP_CHN_S* HimppVideoElement::bindSource() 30 | { 31 | HimppVideoElement *el = dynamic_cast(source()); 32 | return el ? el->bindSource() : NULL; 33 | } 34 | 35 | HimppAudioElement::HimppAudioElement(HimppAudioElement* source) 36 | : AudioElement(AUDIO_ELEMENT(source)) 37 | { 38 | } 39 | 40 | MPP_CHN_S* HimppAudioElement::bindSource() 41 | { 42 | return NULL; 43 | } 44 | -------------------------------------------------------------------------------- /src/dbus/video-encoder-introspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/common/audio-encoder.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * audio-encoder.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _AUDIO_ENCODER_H_ 21 | #define _AUDIO_ENCODER_H_ 22 | 23 | #include 24 | 25 | namespace Ipcam { 26 | namespace Media { 27 | 28 | class AudioEncoder; 29 | 30 | #define AUDIO_ENCODER(o) dynamic_cast(o) 31 | 32 | class AudioEncoder 33 | { 34 | public: 35 | virtual ~AudioEncoder(); 36 | 37 | virtual AudioEncodingType getEncoding(); 38 | virtual uint32_t getBitrate(); 39 | virtual void setBitrate(uint32_t value); 40 | virtual uint32_t getSampleRate(); 41 | virtual void setSampleRate(uint32_t value); 42 | }; 43 | 44 | } //namespace Media 45 | } //namespace Ipcam 46 | 47 | #endif // _AUDIO_ENCODER_H_ 48 | 49 | -------------------------------------------------------------------------------- /src/dbus/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AM_CPPFLAGS = \ 4 | -I$(top_srcdir)/src -I$(top_srcdir)/src/common \ 5 | -I$(srcdir) -I$(builddir) \ 6 | $(DBUSXX_CFLAGS) 7 | 8 | AM_CFLAGS = -Wall 9 | AM_CXXFLAGS = -Wall 10 | 11 | noinst_LTLIBRARIES = \ 12 | libdbus-iface.la 13 | 14 | BUILT_SOURCES = \ 15 | audio-source-server-glue.h \ 16 | audio-encoder-server-glue.h \ 17 | video-source-server-glue.h \ 18 | video-encoder-server-glue.h \ 19 | video-osd-server-glue.h 20 | 21 | libdbus_iface_la_SOURCES = \ 22 | dbusxx-libev-integration.cpp \ 23 | dbusxx-libev-integration.h \ 24 | $(BUILT_SOURCES) \ 25 | dbus-ipcam-base.cpp \ 26 | dbus-ipcam-base.h \ 27 | dbus-audio-source.cpp \ 28 | dbus-audio-source.h \ 29 | dbus-audio-encoder.cpp \ 30 | dbus-audio-encoder.h \ 31 | dbus-video-osd.cpp \ 32 | dbus-video-osd.h \ 33 | dbus-video-source.cpp \ 34 | dbus-video-source.h \ 35 | dbus-video-encoder.cpp \ 36 | dbus-video-encoder.h 37 | 38 | libdbus_iface_la_LIBADD = \ 39 | $(top_builddir)/src/common/libcommon.la 40 | 41 | %-server-glue.h: %-introspect.xml 42 | dbusxx-xml2cpp $^ --adaptor=$@ 43 | 44 | CLEANFILES = $(BUILT_SOURCES) 45 | 46 | dist-hook: 47 | cd $(distdir); rm -f $(BUILT_SOURCES) 48 | 49 | dbuspolicydir=$(sysconfdir)/dbus-1/system.d 50 | dbuspolicy_DATA = \ 51 | live-streamer.conf 52 | 53 | EXTRA_DIST = \ 54 | video-source-introspect.xml \ 55 | video-encoder-introspect.xml \ 56 | video-osd-introspect.xml \ 57 | audio-source-introspect.xml \ 58 | audio-encoder-introspect.xml \ 59 | live-streamer.conf 60 | -------------------------------------------------------------------------------- /src/rtsp-server/LiveStreamOutput.hh: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * LiveStreamOutput.h 4 | * Copyright (C) 2019 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _LIVESTREAMOUTPUT_H_ 21 | #define _LIVESTREAMOUTPUT_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | using namespace Ipcam::Media; 28 | 29 | class LiveAudioSink; 30 | 31 | class AudioOutputStream 32 | { 33 | public: 34 | AudioOutputStream(UsageEnvironment& env, AudioStreamSink& sink, 35 | struct in_addr &addr, portNumBits num); 36 | ~AudioOutputStream(); 37 | 38 | void play(); 39 | void stop(); 40 | 41 | private: 42 | AudioStreamSink& streamSink; 43 | bool streamStarted; 44 | Groupsock rtpGroupsock; 45 | RTPSource* rtpSource; 46 | LiveAudioSink* rtpSink; 47 | }; 48 | 49 | #endif // _LIVESTREAMOUTPUT_H_ 50 | 51 | -------------------------------------------------------------------------------- /src/common/audio-encoder.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * audio-encoder.cpp 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include "audio-encoder.h" 21 | 22 | 23 | namespace Ipcam { 24 | namespace Media { 25 | 26 | AudioEncoder::~AudioEncoder() 27 | { 28 | } 29 | 30 | AudioEncodingType AudioEncoder::getEncoding() 31 | { 32 | throw IpcamError(property_not_implemented); 33 | } 34 | 35 | uint32_t AudioEncoder::getBitrate() 36 | { 37 | throw IpcamError(property_not_implemented); 38 | } 39 | 40 | void AudioEncoder::setBitrate(uint32_t value) 41 | { 42 | throw IpcamError(property_not_implemented); 43 | } 44 | 45 | uint32_t AudioEncoder::getSampleRate() 46 | { 47 | throw IpcamError(property_not_implemented); 48 | } 49 | 50 | void AudioEncoder::setSampleRate(uint32_t value) 51 | { 52 | throw IpcamError(property_not_implemented); 53 | } 54 | 55 | } //namespace Media 56 | } //namespace Ipcam 57 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-base.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-base.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_ELEMENT_H_ 21 | #define _HIMPP_ELEMENT_H_ 22 | 23 | #include 24 | #include 25 | 26 | using namespace Ipcam::Media; 27 | 28 | class HimppVideoElement; 29 | class HimppAudioElement; 30 | 31 | #define HIMPP_VIDEO_ELEMENT(e) dynamic_cast(e) 32 | #define HIMPP_AUDIO_ELEMENT(e) dynamic_cast(e) 33 | 34 | class HimppVideoElement : virtual public VideoElement 35 | { 36 | public: 37 | HimppVideoElement(HimppVideoElement* source); 38 | virtual MPP_CHN_S* bindSource(); 39 | }; 40 | 41 | class HimppAudioElement : virtual public AudioElement 42 | { 43 | public: 44 | HimppAudioElement(HimppAudioElement* source); 45 | virtual MPP_CHN_S* bindSource(); 46 | }; 47 | 48 | #endif // _HIMPP_ELEMENT_H_ 49 | 50 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-base.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-base.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_ELEMENT_H_ 21 | #define _HIMPP_ELEMENT_H_ 22 | 23 | #include 24 | #include 25 | 26 | using namespace Ipcam::Media; 27 | 28 | class HimppVideoElement; 29 | class HimppAudioElement; 30 | 31 | #define HIMPP_VIDEO_ELEMENT(e) dynamic_cast(e) 32 | #define HIMPP_AUDIO_ELEMENT(e) dynamic_cast(e) 33 | 34 | class HimppVideoElement : virtual public VideoElement 35 | { 36 | public: 37 | HimppVideoElement(HimppVideoElement* source); 38 | virtual MPP_CHN_S* bindSource(); 39 | }; 40 | 41 | class HimppAudioElement : virtual public AudioElement 42 | { 43 | public: 44 | HimppAudioElement(HimppAudioElement* source); 45 | virtual MPP_CHN_S* bindSource(); 46 | }; 47 | 48 | #endif // _HIMPP_ELEMENT_H_ 49 | 50 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-base.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-base.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_ELEMENT_H_ 21 | #define _HIMPP_ELEMENT_H_ 22 | 23 | #include 24 | #include 25 | 26 | using namespace Ipcam::Media; 27 | 28 | class HimppVideoElement; 29 | class HimppAudioElement; 30 | 31 | #define HIMPP_VIDEO_ELEMENT(e) dynamic_cast(e) 32 | #define HIMPP_AUDIO_ELEMENT(e) dynamic_cast(e) 33 | 34 | class HimppVideoElement : virtual public VideoElement 35 | { 36 | public: 37 | HimppVideoElement(HimppVideoElement* source); 38 | virtual MPP_CHN_S* bindSource(); 39 | }; 40 | 41 | class HimppAudioElement : virtual public AudioElement 42 | { 43 | public: 44 | HimppAudioElement(HimppAudioElement* source); 45 | virtual MPP_CHN_S* bindSource(); 46 | }; 47 | 48 | #endif // _HIMPP_ELEMENT_H_ 49 | 50 | -------------------------------------------------------------------------------- /src/dbus/dbus-video-osd.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-video-osd.h 4 | * Copyright (C) 2016 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _DBUS_VIDEO_OSD_H_ 21 | #define _DBUS_VIDEO_OSD_H_ 22 | 23 | #include "video-osd.h" 24 | #include "dbus-ipcam-base.h" 25 | #include "video-osd-server-glue.h" 26 | 27 | using namespace Ipcam::Media; 28 | 29 | namespace DBus { 30 | 31 | class VideoOSD: 32 | public ipcam::Media::OSD_adaptor, 33 | public IpcamBase 34 | { 35 | public: 36 | VideoOSD(IpcamRuntime& runtime, std::string obj_path, Ipcam::Media::VideoOSD* video_osd); 37 | void do_property_get 38 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value); 39 | void do_property_set 40 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); 41 | protected: 42 | Ipcam::Media::VideoOSD* _video_osd; 43 | }; 44 | 45 | } // namespace DBus 46 | 47 | #endif // _DBUS_VIDEO_OSD_H_ 48 | 49 | -------------------------------------------------------------------------------- /src/dbus/dbus-audio-source.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-audio-source.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _DBUS_AUDIO_SOURCE_H_ 21 | #define _DBUS_AUDIO_SOURCE_H_ 22 | 23 | #include "dbus-ipcam-base.h" 24 | #include "audio-source-server-glue.h" 25 | 26 | using namespace Ipcam::Media; 27 | 28 | namespace DBus { 29 | 30 | class AudioSource : 31 | public ipcam::Media::AudioSource_adaptor, 32 | public IpcamBase 33 | { 34 | public: 35 | AudioSource(IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::AudioSource* source); 36 | void do_property_get 37 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value); 38 | void do_property_set 39 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); 40 | protected: 41 | Ipcam::Media::AudioSource* _audio_source; 42 | }; 43 | 44 | } // namespace DBus 45 | 46 | #endif // _DBUS_AUDIO_SOURCE_H_ 47 | 48 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-video-sensor.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-sensor.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_SENSOR_H_ 21 | #define _HIMPP_VIDEO_SENSOR_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | struct HIMPP_SENSOR_CONFIG; 30 | 31 | class HimppVideoSensor 32 | { 33 | public: 34 | HimppVideoSensor(HIMPP_SENSOR_CONFIG *config); 35 | ~HimppVideoSensor(); 36 | 37 | std::string getSensorName(); 38 | std::string getModulePath(); 39 | 40 | operator combo_dev_attr_t* (); 41 | operator ISP_PUB_ATTR_S* (); 42 | operator VI_DEV_ATTR_S* (); 43 | private: 44 | HIMPP_SENSOR_CONFIG *sensor_config; 45 | }; 46 | 47 | typedef std::unordered_map HimppVideoSensorMap; 48 | 49 | extern HimppVideoSensorMap himpp_video_sensor_map; 50 | 51 | #endif // _HIMPP_VIDEO_SENSOR_H_ 52 | 53 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-video-sensor.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-sensor.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_SENSOR_H_ 21 | #define _HIMPP_VIDEO_SENSOR_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | struct HIMPP_SENSOR_CONFIG; 30 | 31 | class HimppVideoSensor 32 | { 33 | public: 34 | HimppVideoSensor(HIMPP_SENSOR_CONFIG *config); 35 | ~HimppVideoSensor(); 36 | 37 | std::string getSensorName(); 38 | std::string getModulePath(); 39 | 40 | operator combo_dev_attr_t* (); 41 | operator ISP_PUB_ATTR_S* (); 42 | operator VI_DEV_ATTR_S* (); 43 | private: 44 | HIMPP_SENSOR_CONFIG *sensor_config; 45 | }; 46 | 47 | typedef std::unordered_map HimppVideoSensorMap; 48 | 49 | extern HimppVideoSensorMap himpp_video_sensor_map; 50 | 51 | #endif // _HIMPP_VIDEO_SENSOR_H_ 52 | 53 | -------------------------------------------------------------------------------- /src/dbus/dbus-audio-encoder.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-audio-encoder.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _DBUS_AUDIO_ENCODER_H_ 21 | #define _DBUS_AUDIO_ENCODER_H_ 22 | 23 | #include "dbus-ipcam-base.h" 24 | #include "audio-encoder-server-glue.h" 25 | 26 | using namespace Ipcam::Media; 27 | 28 | namespace DBus { 29 | 30 | class AudioEncoder : 31 | public ipcam::Media::AudioEncoder_adaptor, 32 | public IpcamBase 33 | { 34 | public: 35 | AudioEncoder(IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::AudioEncoder* encoder); 36 | void do_property_get 37 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value); 38 | void do_property_set 39 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); 40 | protected: 41 | Ipcam::Media::AudioEncoder* _audio_encoder; 42 | }; 43 | 44 | } // namespace DBus 45 | 46 | #endif // _DBUS_AUDIO_ENCODER_H_ 47 | 48 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-video-sensor.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-sensor.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_SENSOR_H_ 21 | #define _HIMPP_VIDEO_SENSOR_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | struct HIMPP_SENSOR_CONFIG; 30 | 31 | class HimppVideoSensor 32 | { 33 | public: 34 | HimppVideoSensor(HIMPP_SENSOR_CONFIG *config); 35 | ~HimppVideoSensor(); 36 | 37 | const char* getSensorName(); 38 | const char* getModulePath(); 39 | const char* getObjectName(); 40 | 41 | operator combo_dev_attr_t* (); 42 | operator ISP_PUB_ATTR_S* (); 43 | operator VI_DEV_ATTR_S* (); 44 | operator VI_PIPE_ATTR_S* (); 45 | private: 46 | HIMPP_SENSOR_CONFIG *sensor_config; 47 | }; 48 | 49 | typedef std::unordered_map HimppVideoSensorMap; 50 | 51 | extern HimppVideoSensorMap himpp_video_sensor_map; 52 | 53 | #endif // _HIMPP_VIDEO_SENSOR_H_ 54 | 55 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-sysctl.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-sysctl.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_SYSCTL_H_ 21 | #define _HIMPP_SYSCTL_H_ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class HimppSysctl: public MediaElement 31 | { 32 | public: 33 | HimppSysctl(HI_U32 align_width = HIMPP_SYS_ALIGN_WIDTH, HI_U32 max_pool_cnt = VB_MAX_COMM_POOLS); 34 | ~HimppSysctl(); 35 | 36 | void addVideoBuffer(HI_U32 blksiz, HI_U32 blkcnt); 37 | void setAlignWidth(HI_U32 value); 38 | void setMaxPoolCount(HI_U32 value); 39 | 40 | protected: 41 | void doEnableElement(); 42 | void doDisableElement(); 43 | 44 | private: 45 | struct VideoBuffer 46 | { 47 | VideoBuffer(HI_U32 blksiz, HI_U32 blkcnt) 48 | : blksiz(blksiz), blkcnt(blkcnt) {} 49 | HI_U32 blksiz; 50 | HI_U32 blkcnt; 51 | }; 52 | HI_U32 alignWidth; 53 | HI_U32 maxPoolCount; 54 | std::list buffers; 55 | }; 56 | 57 | #endif // _HIMPP_SYSCTL_H_ 58 | 59 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-sysctl.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-sysctl.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_SYSCTL_H_ 21 | #define _HIMPP_SYSCTL_H_ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class HimppSysctl: public MediaElement 31 | { 32 | public: 33 | HimppSysctl(HI_U32 align_width = HIMPP_SYS_ALIGN_WIDTH, HI_U32 max_pool_cnt = VB_MAX_COMM_POOLS); 34 | ~HimppSysctl(); 35 | 36 | void addVideoBuffer(HI_U32 blksiz, HI_U32 blkcnt); 37 | void setAlignWidth(HI_U32 value); 38 | void setMaxPoolCount(HI_U32 value); 39 | 40 | protected: 41 | void doEnableElement(); 42 | void doDisableElement(); 43 | 44 | private: 45 | struct VideoBuffer 46 | { 47 | VideoBuffer(HI_U32 blksiz, HI_U32 blkcnt) 48 | : blksiz(blksiz), blkcnt(blkcnt) {} 49 | HI_U32 blksiz; 50 | HI_U32 blkcnt; 51 | }; 52 | HI_U32 alignWidth; 53 | HI_U32 maxPoolCount; 54 | std::list buffers; 55 | }; 56 | 57 | #endif // _HIMPP_SYSCTL_H_ 58 | 59 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-media.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-media.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_MEDIA_H_ 21 | #define _HIMPP_MEDIA_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace Ipcam::Media; 30 | 31 | class HimppMedia; 32 | 33 | typedef std::vector> PlatformArguments; 34 | 35 | class HimppMedia 36 | { 37 | public: 38 | HimppMedia(IpcamRuntime* runtime, PlatformArguments& args); 39 | ~HimppMedia(); 40 | 41 | private: 42 | typedef std::unique_ptr MediaElementUPtr; 43 | typedef std::unordered_map MediaElementMap; 44 | typedef std::list AudioStreamSinkList; 45 | MediaElementMap _elements; 46 | AudioStreamSinkList _audiosinks; 47 | IpcamRuntime* _runtime; 48 | HimppSysctl _sysctl; 49 | 50 | MediaElement* buildElementPipe(const std::string& description); 51 | }; 52 | 53 | #endif // _HIMPP_MEDIA_H_ 54 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-sysctl.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-sysctl.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_SYSCTL_H_ 21 | #define _HIMPP_SYSCTL_H_ 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class HimppSysctl: public MediaElement 31 | { 32 | public: 33 | HimppSysctl(HI_U32 align_width = HIMPP_SYS_ALIGN_WIDTH, HI_U32 max_pool_cnt = VB_MAX_COMM_POOLS); 34 | ~HimppSysctl(); 35 | 36 | void addVideoBuffer(HI_U32 blksiz, HI_U32 blkcnt); 37 | void setAlignWidth(HI_U32 value); 38 | void setMaxPoolCount(HI_U32 value); 39 | 40 | protected: 41 | void doEnableElement(); 42 | void doDisableElement(); 43 | 44 | private: 45 | struct VideoBuffer 46 | { 47 | VideoBuffer(HI_U32 blksiz, HI_U32 blkcnt) 48 | : blksiz(blksiz), blkcnt(blkcnt) {} 49 | HI_U32 blksiz; 50 | HI_U32 blkcnt; 51 | }; 52 | HI_U32 alignWidth; 53 | HI_U32 maxPoolCount; 54 | std::list buffers; 55 | }; 56 | 57 | #endif // _HIMPP_SYSCTL_H_ 58 | 59 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-media.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-media.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_MEDIA_H_ 21 | #define _HIMPP_MEDIA_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace Ipcam::Media; 30 | 31 | class HimppMedia; 32 | 33 | typedef std::vector> PlatformArguments; 34 | 35 | class HimppMedia 36 | { 37 | public: 38 | HimppMedia(IpcamRuntime* runtime, PlatformArguments& args); 39 | ~HimppMedia(); 40 | 41 | private: 42 | typedef std::unique_ptr MediaElementUPtr; 43 | typedef std::unordered_map MediaElementMap; 44 | typedef std::list AudioStreamSinkList; 45 | MediaElementMap _elements; 46 | AudioStreamSinkList _audiosinks; 47 | IpcamRuntime* _runtime; 48 | HimppSysctl _sysctl; 49 | 50 | MediaElement* buildElementPipe(const std::string& description); 51 | }; 52 | 53 | #endif // _HIMPP_MEDIA_H_ 54 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-media.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-media.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_MEDIA_H_ 21 | #define _HIMPP_MEDIA_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace Ipcam::Media; 30 | 31 | class HimppMedia; 32 | 33 | typedef std::vector> PlatformArguments; 34 | 35 | class HimppMedia 36 | { 37 | public: 38 | HimppMedia(IpcamRuntime* runtime, PlatformArguments& args); 39 | ~HimppMedia(); 40 | 41 | private: 42 | typedef std::unique_ptr MediaElementUPtr; 43 | typedef std::unordered_map MediaElementMap; 44 | typedef std::list AudioStreamSinkList; 45 | MediaElementMap _elements; 46 | AudioStreamSinkList _audiosinks; 47 | IpcamRuntime* _runtime; 48 | HimppSysctl _sysctl; 49 | 50 | MediaElement* buildElementPipe(const std::string& description); 51 | }; 52 | 53 | #endif // _HIMPP_MEDIA_H_ 54 | -------------------------------------------------------------------------------- /src/common/media-common.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * media-common.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _MEDIA_COMMON_H_ 21 | #define _MEDIA_COMMON_H_ 22 | 23 | #include 24 | #include 25 | 26 | typedef DBus::ErrorFailed IpcamError; 27 | 28 | namespace Ipcam { 29 | namespace Media { 30 | 31 | extern const char *property_not_implemented; 32 | extern const char *interface_not_implemented; 33 | 34 | class Resolution 35 | { 36 | public: 37 | Resolution(uint32_t w, uint32_t h); 38 | Resolution(std::string dimension); 39 | 40 | operator std::string (); 41 | 42 | uint32_t width() const { return _width; } 43 | uint32_t height() const { return _height; } 44 | bool valid() const { return (_width > 0) && (_height > 0); } 45 | bool operator == (const Resolution& r) const { 46 | return (r._width == _width) && (r._height == _height); 47 | } 48 | bool operator != (const Resolution& r) const { 49 | return (r._width != _width) || (r._height != _height); 50 | } 51 | 52 | private: 53 | uint32_t _width; 54 | uint32_t _height; 55 | }; 56 | 57 | struct Position { 58 | int x; 59 | int y; 60 | Position(int x, int y) : x(x), y(y) {} 61 | }; 62 | 63 | struct Size { 64 | uint32_t w; 65 | uint32_t h; 66 | Size(uint32_t w, uint32_t h) : w(w), h(h) {} 67 | }; 68 | 69 | } // namespace Media 70 | } // namespace Ipcam 71 | 72 | #endif // _MEDIA_COMMON_H_ 73 | 74 | -------------------------------------------------------------------------------- /src/rtsp-server/DynamicRTSPServer.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /********** 3 | This library is free software; you can redistribute it and/or modify it under 4 | the terms of the GNU Lesser General Public License as published by the 5 | Free Software Foundation; either version 2.1 of the License, or (at your 6 | option) any later version. (See .) 7 | 8 | This library is distributed in the hope that it will be useful, but WITHOUT 9 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 11 | more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this library; if not, write to the Free Software Foundation, Inc., 15 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | **********/ 17 | // Copyright (c) 1996-2015, Live Networks, Inc. All rights reserved 18 | // A subclass of "RTSPServer" that creates "ServerMediaSession"s on demand, 19 | // based on whether or not the specified stream name exists as a file 20 | // Implementation 21 | 22 | #include "DynamicRTSPServer.hh" 23 | #include 24 | #include 25 | 26 | DynamicRTSPServer* 27 | DynamicRTSPServer::createNew(UsageEnvironment& env, Port ourPort, 28 | UserAuthenticationDatabase* authDatabase, 29 | unsigned reclamationTestSeconds) { 30 | int ourSocket = setUpOurSocket(env, ourPort); 31 | if (ourSocket == -1) return NULL; 32 | 33 | return new DynamicRTSPServer(env, ourSocket, ourPort, authDatabase, reclamationTestSeconds); 34 | } 35 | 36 | DynamicRTSPServer::DynamicRTSPServer(UsageEnvironment& env, int ourSocket, Port ourPort, 37 | UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds) 38 | : RTSPServerSupportingHTTPStreaming(env, ourSocket, ourPort, authDatabase, reclamationTestSeconds) { 39 | } 40 | 41 | DynamicRTSPServer::~DynamicRTSPServer() { 42 | } 43 | 44 | ServerMediaSession* DynamicRTSPServer 45 | ::lookupServerMediaSession(char const* streamName, Boolean isFirstLookupInSession) 46 | { 47 | return RTSPServer::lookupServerMediaSession(streamName); 48 | } 49 | -------------------------------------------------------------------------------- /src/rtsp-server/DynamicRTSPServer.hh: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /********** 3 | This library is free software; you can redistribute it and/or modify it under 4 | the terms of the GNU Lesser General Public License as published by the 5 | Free Software Foundation; either version 2.1 of the License, or (at your 6 | option) any later version. (See .) 7 | 8 | This library is distributed in the hope that it will be useful, but WITHOUT 9 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 11 | more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this library; if not, write to the Free Software Foundation, Inc., 15 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | **********/ 17 | // Copyright (c) 1996-2015, Live Networks, Inc. All rights reserved 18 | // A subclass of "RTSPServer" that creates "ServerMediaSession"s on demand, 19 | // based on whether or not the specified stream name exists as a file 20 | // Header file 21 | 22 | #ifndef _DYNAMIC_RTSP_SERVER_HH 23 | #define _DYNAMIC_RTSP_SERVER_HH 24 | 25 | #ifndef _RTSP_SERVER_SUPPORTING_HTTP_STREAMING_HH 26 | #include "RTSPServerSupportingHTTPStreaming.hh" 27 | #endif 28 | #include 29 | #include 30 | 31 | class DynamicRTSPServer: public RTSPServerSupportingHTTPStreaming 32 | { 33 | public: 34 | static DynamicRTSPServer* createNew(UsageEnvironment& env, Port ourPort, 35 | UserAuthenticationDatabase* authDatabase, 36 | unsigned reclamationTestSeconds = 65); 37 | 38 | void addStreamPath(const std::string &path, const std::string &location); 39 | 40 | protected: 41 | DynamicRTSPServer(UsageEnvironment& env, int ourSocket, Port ourPort, 42 | UserAuthenticationDatabase* authDatabase, unsigned reclamationTestSeconds); 43 | // called only by createNew(); 44 | virtual ~DynamicRTSPServer(); 45 | 46 | protected: // redefined virtual functions 47 | virtual ServerMediaSession* 48 | lookupServerMediaSession(char const* streamName, Boolean isFirstLookupInSession); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/dbus/dbus-ipcam-base.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-ipcam-base.h 4 | * Copyright (C) 2016 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _DBUS_IPCAM_BASE_H_ 21 | #define _DBUS_IPCAM_BASE_H_ 22 | 23 | #include 24 | #include 25 | 26 | namespace DBus 27 | { 28 | 29 | class IpcamBase : 30 | public IntrospectableAdaptor, 31 | public PropertiesAdaptor, 32 | public ObjectAdaptor 33 | { 34 | public: 35 | IpcamBase(IpcamRuntime &runtime, const Path &path); 36 | virtual ~IpcamBase(); 37 | 38 | #ifdef HAVE_JSONCPP_SUPPORT 39 | virtual void LoadConfig(); 40 | #endif 41 | 42 | protected: 43 | virtual void do_property_get(InterfaceAdaptor &interface, const std::string &property, Variant &value) = 0; 44 | virtual void do_property_set(InterfaceAdaptor &interface, const std::string &property, const Variant &value) = 0; 45 | 46 | protected: 47 | IpcamRuntime& _runtime; 48 | typedef std::function PropertyGet; 49 | typedef std::function PropertySet; 50 | class PropertyHandler { 51 | public: 52 | PropertyHandler(PropertyGet get, PropertySet set) 53 | : Get(get), Set(set) {} 54 | PropertyGet Get; 55 | PropertySet Set; 56 | }; 57 | std::unordered_map _prop_handler; 58 | 59 | private: 60 | void on_get_property(DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value); 61 | void on_set_property(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); 62 | }; 63 | 64 | } /* namespace DBus */ 65 | 66 | #endif // _DBUS_IPCAM_BASE_H_ 67 | 68 | -------------------------------------------------------------------------------- /src/dbus/dbus-video-source.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-video-source.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _DBUS_VIDEO_SOURCE_H_ 21 | #define _DBUS_VIDEO_SOURCE_H_ 22 | 23 | #include "dbus-ipcam-base.h" 24 | #include "video-source-server-glue.h" 25 | 26 | using namespace Ipcam::Media; 27 | 28 | namespace DBus { 29 | 30 | class VideoSource : 31 | public ipcam::Media::VideoSource_adaptor, 32 | public ipcam::Media::VideoSource::Imaging_adaptor, 33 | public ipcam::Media::VideoSource::Imaging::AntiFlicker_adaptor, 34 | public ipcam::Media::VideoSource::Imaging::BacklightCompensation_adaptor, 35 | public ipcam::Media::VideoSource::Imaging::Focus_adaptor, 36 | public ipcam::Media::VideoSource::Imaging::Exposure_adaptor, 37 | public ipcam::Media::VideoSource::Imaging::WhiteBalance_adaptor, 38 | public ipcam::Media::VideoSource::Imaging::WideDynamicRange_adaptor, 39 | public ipcam::Media::VideoSource::Imaging::LDC_adaptor, 40 | public ipcam::Media::VideoSource::Imaging::Gamma_adaptor, 41 | public ipcam::Media::VideoSource::Imaging::NoiseReduction_adaptor, 42 | public ipcam::Media::VideoSource::Imaging::IrCutFilter_adaptor, 43 | public IpcamBase 44 | { 45 | public: 46 | VideoSource(IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::VideoSource* video_source); 47 | 48 | void do_property_get 49 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value); 50 | void do_property_set 51 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); 52 | protected: 53 | Ipcam::Media::VideoSource* _video_source; 54 | }; 55 | 56 | } // namespace DBus 57 | 58 | #endif // _DBUS_VIDEO_SOURCE_H_ 59 | -------------------------------------------------------------------------------- /src/dbus/dbus-video-encoder.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-video-encoder.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _DBUS_VIDEO_ENCODER_H_ 21 | #define _DBUS_VIDEO_ENCODER_H_ 22 | 23 | #include "dbus-ipcam-base.h" 24 | #include "dbus-video-osd.h" 25 | #include "video-encoder-server-glue.h" 26 | 27 | using namespace Ipcam::Media; 28 | 29 | namespace DBus { 30 | 31 | typedef std::unordered_map VideoOSDTable; 32 | 33 | class VideoEncoder : 34 | public ipcam::Media::VideoEncoder_adaptor, 35 | public ipcam::Media::VideoEncoder::RateControl_adaptor, 36 | public ipcam::Media::VideoEncoder::OSD_adaptor, 37 | public DBus::IpcamBase 38 | { 39 | public: 40 | VideoEncoder(IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::VideoEncoder* encoder); 41 | 42 | void do_property_get 43 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value); 44 | void do_property_set 45 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); 46 | 47 | #ifdef HAVE_JSONCPP_SUPPORT 48 | void LoadConfig(); 49 | #endif 50 | 51 | uint32_t CreateOSD(); 52 | void DeleteOSD(const uint32_t& index); 53 | std::map GetOSDs(); 54 | protected: 55 | Ipcam::Media::VideoEncoder* _video_encoder; 56 | private: 57 | VideoOSDTable _osds; 58 | VideoOSD& NewOSD(const uint32_t index); 59 | }; 60 | 61 | class H264VideoEncoder : 62 | public VideoEncoder, 63 | public ipcam::Media::VideoEncoder::H264_adaptor 64 | { 65 | public: 66 | H264VideoEncoder(IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::H264VideoEncoder* encoder); 67 | }; 68 | 69 | } // namespace DBus 70 | 71 | #endif // _DBUS_VIDEO_ENCODER_H_ 72 | 73 | -------------------------------------------------------------------------------- /src/rtsp-server/AACAudioEncoder.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * AACAudioEncoder.hh 3 | * Copyright (C) 2015 Watson Xu 4 | * 5 | * live-streamer is free software: you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License as published by the 7 | * Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * live-streamer is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | * See the GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program. If not, see . 17 | */ 18 | // "LIVE555 Streaming Media" interface to an AAC audio encoder. 19 | // C++ header 20 | 21 | #ifndef _AAC_AUDIO_ENCODER_HH 22 | #define _AAC_AUDIO_ENCODER_HH 23 | 24 | #include "FramedFilter.hh" 25 | 26 | class AACAudioEncoder: public FramedFilter { 27 | public: 28 | static AACAudioEncoder* createNew(UsageEnvironment& env, 29 | FramedSource* inputPCMSource, 30 | unsigned numChannels, unsigned samplingRate, 31 | unsigned outputKbps); 32 | 33 | protected: 34 | AACAudioEncoder(UsageEnvironment& env, FramedSource* inputPCMSource, 35 | unsigned numChannels, unsigned samplingRate, unsigned outputKbps); 36 | // called only by createNew() 37 | virtual ~AACAudioEncoder(); 38 | 39 | private: 40 | // redefined virtual functions: 41 | virtual void doGetNextFrame(); 42 | 43 | private: 44 | static void afterGettingFrame(void* clientData, unsigned frameSize, 45 | unsigned numTruncatedBytes, 46 | struct timeval presentationTime, 47 | unsigned durationInMicroseconds); 48 | void afterGettingFrame1(unsigned frameSize, 49 | unsigned numTruncatedBytes, 50 | struct timeval presentationTime, 51 | unsigned durationInMicroseconds); 52 | 53 | private: 54 | void* fEncoderHandle; 55 | unsigned long fNumSamplesPerFrame; 56 | unsigned fMicrosecondsPerFrame; 57 | double fMicrosecondsPerByte; 58 | unsigned char* fInputSampleBuffer; 59 | unsigned fInputSampleBufferSize; 60 | unsigned fInputSampleBufferBytesDesired; 61 | unsigned fInputSampleBufferBytesUsed; 62 | struct timeval fLastInputDataPresentationTime; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/common/media-element.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * media-element.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _MEDIA_ELEMENT_H_ 21 | #define _MEDIA_ELEMENT_H_ 22 | 23 | #include 24 | #include 25 | 26 | namespace Ipcam { 27 | namespace Media { 28 | 29 | class MediaElement; 30 | class VideoElement; 31 | class AudioElement; 32 | 33 | #define MEDIA_ELEMENT(o) dynamic_cast(o) 34 | #define VIDEO_ELEMENT(o) dynamic_cast(o) 35 | #define AUDIO_ELEMENT(o) dynamic_cast(o) 36 | 37 | #define MEFLAGS_INITIAL_ENABLED (1 << 0) 38 | 39 | // Base for A/V componments 40 | class MediaElement 41 | { 42 | public: 43 | virtual ~MediaElement(); 44 | 45 | virtual void enable(); // enable streaming 46 | virtual void disable(); // disable streaming 47 | 48 | uint32_t& flags() { return _flags; } 49 | 50 | bool is_enabled() { return (_enable_count > 0); } 51 | inline MediaElement* source() { return _source; } 52 | 53 | protected: 54 | MediaElement(MediaElement* source); 55 | 56 | virtual void doEnableElement() = 0; 57 | virtual void doDisableElement() = 0; 58 | 59 | private: 60 | MediaElement* _source; 61 | std::atomic _enable_count; 62 | uint32_t _flags; 63 | }; 64 | 65 | // Base for video compoments 66 | class VideoElement : public MediaElement 67 | { 68 | public: 69 | virtual ~VideoElement(); 70 | 71 | virtual Resolution resolution(); 72 | virtual uint32_t framerate(); 73 | 74 | protected: 75 | VideoElement(VideoElement* upstream); 76 | }; 77 | 78 | // Base for audio componments 79 | class AudioElement : public MediaElement 80 | { 81 | public: 82 | virtual ~AudioElement(); 83 | 84 | virtual uint32_t samplerate(); 85 | virtual uint32_t channels(); 86 | 87 | protected: 88 | AudioElement(AudioElement* upstream); 89 | }; 90 | 91 | } // namespace Media 92 | } // namespace Ipcam 93 | 94 | #endif // _MEDIA_ELEMENT_H_ 95 | 96 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | AM_CPPFLAGS = \ 4 | -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ 5 | -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ 6 | $(LIVE555_CPPFLAGS) \ 7 | $(DBUSXX_CFLAGS) \ 8 | $(FREETYPE_CFLAGS) \ 9 | $(FONTCONFIG_CFLAGS) \ 10 | $(SDL_CFLAGS) \ 11 | -I$(srcdir) -I$(srcdir)/common \ 12 | -I$(srcdir)/rtsp-server \ 13 | -I$(srcdir)/dbus -I$(builddir)/dbus 14 | 15 | AM_CFLAGS = -Wall 16 | AM_CXXFLAGS = -Wall 17 | 18 | SUBDIRS = \ 19 | common \ 20 | rtsp-server \ 21 | dbus \ 22 | platform 23 | 24 | bin_PROGRAMS = live-streamer 25 | 26 | live_streamer_SOURCES = \ 27 | main.cpp \ 28 | ipcam-runtime.cpp \ 29 | ipcam-runtime.h 30 | 31 | live_streamer_LDFLAGS = $(LIVE555_LDFLAGS) \ 32 | $(DBUSXX_LIBS) \ 33 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(SDL_LIBS) \ 34 | $(LIBEV_LDFLAGS) -ldl 35 | 36 | live_streamer_CPPFLAGS = $(AM_CPPFLAGS) 37 | live_streamer_LDADD = \ 38 | $(builddir)/common/libcommon.la \ 39 | $(builddir)/dbus/libdbus-iface.la \ 40 | $(builddir)/rtsp-server/librtsp-server.la 41 | 42 | if ENABLE_JSONCPP 43 | live_streamer_CPPFLAGS += $(JSONCPP_CPPFLAGS) 44 | live_streamer_LDFLAGS += $(JSONCPP_LIBS) 45 | endif 46 | 47 | if ENABLE_VO_AACENC 48 | live_streamer_CPPFLAGS += $(VO_AACENC_CPPFLAGS) 49 | live_streamer_LDFLAGS += $(VO_AACENC_LIBS) 50 | endif 51 | 52 | if ENABLE_HI3518V100 53 | live_streamer_CPPFLAGS += $(HI3518V100_CPPFLAGS) -I$(srcdir)/platform/hi3518v100 54 | live_streamer_LDFLAGS += $(HI3518V100_LDFLAGS) 55 | live_streamer_LDADD += $(builddir)/platform/hi3518v100/libhi3518v100.la 56 | endif 57 | 58 | if ENABLE_HI3518V200 59 | live_streamer_CPPFLAGS += $(HI3518V200_CPPFLAGS) -I$(srcdir)/platform/hi3518v200 60 | live_streamer_LDFLAGS += $(HI3518V200_LDFLAGS) 61 | live_streamer_LDADD += $(builddir)/platform/hi3518v200/libhi3518v200.la 62 | endif 63 | 64 | if ENABLE_HI3516CV300 65 | live_streamer_CPPFLAGS += $(HI3516CV300_CPPFLAGS) -I$(srcdir)/platform/hi3516cv300 66 | live_streamer_LDFLAGS += $(HI3516CV300_LDFLAGS) 67 | live_streamer_LDADD += $(builddir)/platform/hi3516cv300/libhi3516cv300.la 68 | endif 69 | 70 | if ENABLE_HI3516EV200 71 | live_streamer_CPPFLAGS += $(HI3516EV200_CPPFLAGS) -I$(srcdir)/platform/hi3516ev200 72 | live_streamer_LDFLAGS += $(HI3516EV200_LDFLAGS) 73 | live_streamer_LDADD += $(builddir)/platform/hi3516ev200/libhi3516ev200.la 74 | endif 75 | 76 | if ENABLE_HI3520V100 77 | live_streamer_CPPFLAGS += $(HI3520V100_CPPFLAGS) -I$(srcdir)/platform/hi3520v100 78 | live_streamer_LDFLAGS += $(HI3520V100_LDFLAGS) 79 | live_streamer_LDADD += $(builddir)/platform/hi3520v100/libhi3520v100.la 80 | endif 81 | 82 | if ENABLE_HI3520DV200 83 | live_streamer_CPPFLAGS += $(HI3520DV200_CPPFLAGS) -I$(srcdir)/platform/hi3520v100 84 | live_streamer_LDFLAGS += $(HI3520DV200_LDFLAGS) 85 | live_streamer_LDADD += $(builddir)/platform/hi3520v100/libhi3520v100.la 86 | endif 87 | -------------------------------------------------------------------------------- /src/dbus/dbus-audio-source.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-audio-source.cpp 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #include "dbus-audio-source.h" 28 | 29 | namespace DBus { 30 | 31 | #define AUDIOSOURCE_INTERFACE "ipcam.Media.AudioSource" 32 | 33 | #define DEFINE_PROP(prop, get, set) \ 34 | _prop_handler.emplace(std::piecewise_construct, \ 35 | std::forward_as_tuple(prop), \ 36 | std::forward_as_tuple(get, set)) 37 | 38 | AudioSource::AudioSource 39 | (IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::AudioSource* source) 40 | : IpcamBase(runtime, obj_path), 41 | _audio_source(source) 42 | { 43 | assert(source != NULL); 44 | 45 | // Handler of ipcam.Media.Source 46 | DEFINE_PROP(AUDIOSOURCE_INTERFACE ".Channels", 47 | [this](DBus::InterfaceAdaptor &interface, 48 | const std::string &property, DBus::Variant &value) 49 | { 50 | value.writer().append_uint32(_audio_source->getChannels()); 51 | }, 52 | [this](DBus::InterfaceAdaptor &interface, 53 | const std::string &property, const DBus::Variant &value) 54 | { 55 | throw DBus::ErrorFailed("Readonly property"); 56 | }); 57 | } 58 | 59 | void AudioSource::do_property_get 60 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value) 61 | { 62 | value.clear(); 63 | 64 | auto iter = _prop_handler.find(interface.name() + "." + property); 65 | if (iter == _prop_handler.end()) 66 | throw DBus::ErrorFailed("Requested interface or property not found"); 67 | iter->second.Get(interface, property, value); 68 | } 69 | 70 | void AudioSource::do_property_set 71 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value) 72 | { 73 | auto iter = _prop_handler.find(interface.name() + "." + property); 74 | if (iter == _prop_handler.end()) 75 | throw DBus::ErrorFailed("Requested interface or property not found"); 76 | iter->second.Set(interface, property, value); 77 | } 78 | 79 | } // namespace DBus 80 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-video-region.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-region.h 4 | * Copyright (C) 2016 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_REGION_H_ 21 | #define _HIMPP_VIDEO_REGION_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace Ipcam::Media; 29 | 30 | class HimppVideoRegion; 31 | 32 | #define HIMPP_VIDEO_REGION(o) dynamic_cast(o) 33 | 34 | class HimppRegionAllocator 35 | { 36 | public: 37 | HimppRegionAllocator(); 38 | ~HimppRegionAllocator(); 39 | 40 | RGN_HANDLE allocHandle(); 41 | void freeHandle(RGN_HANDLE handle); 42 | private: 43 | std::bitset _region_bmp; 44 | }; 45 | 46 | class HimppVideoRegion : public SoftRenderVideoOSD 47 | { 48 | public: 49 | HimppVideoRegion(HimppVideoElement* container, RGN_HANDLE handle); 50 | ~HimppVideoRegion(); 51 | 52 | void doEnableElement(); 53 | void doDisableElement(); 54 | 55 | uint32_t regionId() { return (uint32_t)_rgn_handle; } 56 | 57 | bool getVisible(); 58 | void setVisible(bool value); 59 | Size getSize(); 60 | void setSize(Size value); 61 | uint32_t getForegroundColor(); 62 | void setForegroundColor(uint32_t value); 63 | uint32_t getBackgroundColor(); 64 | void setBackgroundColor(uint32_t value); 65 | 66 | Position getPosition(); 67 | void setPosition(Position value); 68 | uint32_t getForegroundAlpha(); 69 | void setForegroundAlpha(uint32_t value); 70 | uint32_t getBackgroundAlpha(); 71 | void setBackgroundAlpha(uint32_t value); 72 | bool getInvertColor(); 73 | void setInvertColor(bool value); 74 | 75 | void updateDisplay(SDL_Surface* surface); 76 | 77 | private: 78 | RGN_HANDLE _rgn_handle; 79 | bool _visible; 80 | Position _position; 81 | Size _size; 82 | uint32_t _fgcolor; 83 | uint32_t _bgcolor; 84 | uint32_t _fgalpha; 85 | uint32_t _bgalpha; 86 | uint32_t _layer; 87 | bool _invert_color; 88 | BITMAP_S _bitmap; 89 | SDL_Surface* _surface; 90 | }; 91 | 92 | extern HimppRegionAllocator himpp_region_allocator; 93 | 94 | #endif // _HIMPP_VIDEO_REGION_H_ 95 | 96 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-video-region.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-region.h 4 | * Copyright (C) 2016 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_REGION_H_ 21 | #define _HIMPP_VIDEO_REGION_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace Ipcam::Media; 29 | 30 | class HimppVideoRegion; 31 | 32 | #define HIMPP_VIDEO_REGION(o) dynamic_cast(o) 33 | 34 | class HimppRegionAllocator 35 | { 36 | public: 37 | HimppRegionAllocator(); 38 | ~HimppRegionAllocator(); 39 | 40 | RGN_HANDLE allocHandle(); 41 | void freeHandle(RGN_HANDLE handle); 42 | private: 43 | std::bitset _region_bmp; 44 | }; 45 | 46 | class HimppVideoRegion : public SoftRenderVideoOSD 47 | { 48 | public: 49 | HimppVideoRegion(HimppVideoElement* container, RGN_HANDLE handle); 50 | ~HimppVideoRegion(); 51 | 52 | void doEnableElement(); 53 | void doDisableElement(); 54 | 55 | uint32_t regionId() { return (uint32_t)_rgn_handle; } 56 | 57 | bool getVisible(); 58 | void setVisible(bool value); 59 | Size getSize(); 60 | void setSize(Size value); 61 | uint32_t getForegroundColor(); 62 | void setForegroundColor(uint32_t value); 63 | uint32_t getBackgroundColor(); 64 | void setBackgroundColor(uint32_t value); 65 | 66 | Position getPosition(); 67 | void setPosition(Position value); 68 | uint32_t getForegroundAlpha(); 69 | void setForegroundAlpha(uint32_t value); 70 | uint32_t getBackgroundAlpha(); 71 | void setBackgroundAlpha(uint32_t value); 72 | bool getInvertColor(); 73 | void setInvertColor(bool value); 74 | 75 | void updateDisplay(SDL_Surface* surface); 76 | 77 | private: 78 | RGN_HANDLE _rgn_handle; 79 | bool _visible; 80 | Position _position; 81 | Size _size; 82 | uint32_t _fgcolor; 83 | uint32_t _bgcolor; 84 | uint32_t _fgalpha; 85 | uint32_t _bgalpha; 86 | uint32_t _layer; 87 | bool _invert_color; 88 | BITMAP_S _bitmap; 89 | SDL_Surface* _surface; 90 | }; 91 | 92 | extern HimppRegionAllocator himpp_region_allocator; 93 | 94 | #endif // _HIMPP_VIDEO_REGION_H_ 95 | 96 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-video-region.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-region.h 4 | * Copyright (C) 2016 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_REGION_H_ 21 | #define _HIMPP_VIDEO_REGION_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using namespace Ipcam::Media; 29 | 30 | class HimppVideoRegion; 31 | 32 | #define HIMPP_VIDEO_REGION(o) dynamic_cast(o) 33 | 34 | class HimppRegionAllocator 35 | { 36 | public: 37 | HimppRegionAllocator(); 38 | ~HimppRegionAllocator(); 39 | 40 | RGN_HANDLE allocHandle(); 41 | void freeHandle(RGN_HANDLE handle); 42 | private: 43 | std::bitset _region_bmp; 44 | }; 45 | 46 | class HimppVideoRegion : public SoftRenderVideoOSD 47 | { 48 | public: 49 | HimppVideoRegion(HimppVideoElement* container, RGN_HANDLE handle); 50 | ~HimppVideoRegion(); 51 | 52 | void doEnableElement(); 53 | void doDisableElement(); 54 | 55 | uint32_t regionId() { return (uint32_t)_rgn_handle; } 56 | 57 | bool getVisible(); 58 | void setVisible(bool value); 59 | Size getSize(); 60 | void setSize(Size value); 61 | uint32_t getForegroundColor(); 62 | void setForegroundColor(uint32_t value); 63 | uint32_t getBackgroundColor(); 64 | void setBackgroundColor(uint32_t value); 65 | 66 | Position getPosition(); 67 | void setPosition(Position value); 68 | uint32_t getForegroundAlpha(); 69 | void setForegroundAlpha(uint32_t value); 70 | uint32_t getBackgroundAlpha(); 71 | void setBackgroundAlpha(uint32_t value); 72 | bool getInvertColor(); 73 | void setInvertColor(bool value); 74 | 75 | void updateDisplay(SDL_Surface* surface); 76 | 77 | private: 78 | RGN_HANDLE _rgn_handle; 79 | bool _visible; 80 | Position _position; 81 | Size _size; 82 | uint32_t _fgcolor; 83 | uint32_t _bgcolor; 84 | uint32_t _fgalpha; 85 | uint32_t _bgalpha; 86 | uint32_t _layer; 87 | bool _invert_color; 88 | BITMAP_S _bitmap; 89 | SDL_Surface* _surface; 90 | }; 91 | 92 | extern HimppRegionAllocator himpp_region_allocator; 93 | 94 | #endif // _HIMPP_VIDEO_REGION_H_ 95 | 96 | -------------------------------------------------------------------------------- /src/dbus/dbusxx-libev-integration.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * 4 | * D-Bus++ - C++ bindings for D-Bus 5 | * 6 | * Copyright (C) 2015 Watson Xu 7 | * 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | */ 24 | 25 | 26 | #ifndef __DBUSXX_LIBEV_INTEGRATION_H 27 | #define __DBUSXX_LIBEV_INTEGRATION_H 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | namespace DBus 35 | { 36 | 37 | namespace Ev 38 | { 39 | 40 | class BusDispatcher; 41 | 42 | class DXXAPI BusTimeout : public Timeout 43 | { 44 | private: 45 | 46 | BusTimeout(Timeout::Internal *, ev::loop_ref &, int); 47 | 48 | ~BusTimeout(); 49 | 50 | void toggle(); 51 | 52 | void timeout_handler(ev::timer &, int); 53 | 54 | void _enable(); 55 | 56 | void _disable(); 57 | 58 | private: 59 | 60 | ev::loop_ref &_loop; 61 | int _priority; 62 | ev::timer _timer; 63 | 64 | friend class BusDispatcher; 65 | }; 66 | 67 | class DXXAPI BusWatch : public Watch 68 | { 69 | private: 70 | 71 | BusWatch(Watch::Internal *, ev::loop_ref &, int); 72 | 73 | ~BusWatch(); 74 | 75 | void toggle(); 76 | 77 | void watch_handler(ev::io &, int); 78 | 79 | void _enable(); 80 | 81 | void _disable(); 82 | 83 | private: 84 | 85 | ev::loop_ref &_loop; 86 | int _priority; 87 | ev::io _io; 88 | 89 | friend class BusDispatcher; 90 | }; 91 | 92 | class DXXAPI BusDispatcher : public Dispatcher 93 | { 94 | public: 95 | 96 | BusDispatcher(); 97 | ~BusDispatcher(); 98 | 99 | void attach(ev::loop_ref *); 100 | 101 | void enter() {} 102 | 103 | void leave() {} 104 | 105 | Timeout *add_timeout(Timeout::Internal *); 106 | 107 | void rem_timeout(Timeout *); 108 | 109 | Watch *add_watch(Watch::Internal *); 110 | 111 | void rem_watch(Watch *); 112 | 113 | void set_priority(int priority); 114 | 115 | void prepare_handler(ev::prepare &, int); 116 | void check_handler(ev::check &, int); 117 | 118 | private: 119 | 120 | ev::loop_ref _loop; 121 | int _priority; 122 | ev::check _check; 123 | ev::prepare _prepare; 124 | }; 125 | 126 | } /* namespace Ev */ 127 | 128 | } /* namespace DBus */ 129 | 130 | #endif//__DBUSXX_LIBEV_INTEGRATION_H 131 | -------------------------------------------------------------------------------- /src/common/media-common.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * media-common.cpp 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include "media-common.h" 23 | 24 | namespace Ipcam { 25 | namespace Media { 26 | 27 | struct ResolutionEntry 28 | { 29 | const char *name; 30 | uint16_t width; 31 | uint16_t height; 32 | }; 33 | 34 | static ResolutionEntry _resolution_table[] = { 35 | { .name = "QCIF", .width = 176, .height = 144 }, 36 | { .name = "CIF", .width = 352, .height = 288 }, 37 | { .name = "D1", .width = 720, .height = 576 }, 38 | { .name = "960H", .width = 960, .height = 576 }, 39 | { .name = "2CIF", .width = 360, .height = 576 }, 40 | { .name = "QVGA", .width = 320, .height = 240 }, 41 | { .name = "VGA", .width = 640, .height = 480 }, 42 | { .name = "XGA", .width = 1024, .height = 760 }, 43 | { .name = "SXGA", .width = 1400, .height = 1050 }, 44 | { .name = "UXGA", .width = 1600, .height = 1200 }, 45 | { .name = "QXGA", .width = 2048, .height = 1536 }, 46 | { .name = "WVGA", .width = 800, .height = 480 }, 47 | { .name = "WSXGA", .width = 1680, .height = 1050 }, 48 | { .name = "720P", .width = 1280, .height = 720 }, 49 | { .name = "1080P", .width = 1920, .height = 1080 }, 50 | { .name = NULL, .width = 0, .height = 0 } 51 | }; 52 | 53 | const char *property_not_implemented = "Requested property not implemented"; 54 | const char *interface_not_implemented = "Requested interface not implemented"; 55 | 56 | Resolution::Resolution(uint32_t w, uint32_t h) 57 | : _width(w), _height(h) 58 | { 59 | } 60 | 61 | Resolution::Resolution(std::string resolution) 62 | : _width(0), _height(0) 63 | { 64 | ResolutionEntry *ent = _resolution_table; 65 | 66 | while (ent->name) { 67 | if (strcasecmp(resolution.c_str(), ent->name) == 0) { 68 | _width = ent->width; 69 | _height = ent->height; 70 | return; 71 | } 72 | ent++; 73 | } 74 | 75 | static std::regex re("([0-9]+)[xX]([0-9]+)"); 76 | std::cmatch cm; 77 | if (std::regex_match(resolution.c_str(), cm, re)) { 78 | _width = std::stoul(cm[1]); 79 | _height = std::stoul(cm[2]); 80 | } 81 | } 82 | 83 | Resolution::operator std::string () 84 | { 85 | ResolutionEntry *ent = _resolution_table; 86 | 87 | while (ent->name) { 88 | if (ent->width == _width && ent->height == _height) 89 | return std::string(ent->name); 90 | ent++; 91 | } 92 | 93 | return std::to_string(_width) + "x" + std::to_string(_height); 94 | } 95 | 96 | } // namespace Media 97 | } // namespace Ipcam 98 | -------------------------------------------------------------------------------- /src/common/media-stream.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * media-stream.cpp 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include "media-stream.h" 21 | 22 | namespace Ipcam { 23 | namespace Media { 24 | 25 | 26 | ////////////////////////////////////////////////////////////////////////////// 27 | // StreamSource 28 | ////////////////////////////////////////////////////////////////////////////// 29 | 30 | StreamSource::~StreamSource() 31 | { 32 | } 33 | 34 | void StreamSource::attach(StreamSink* sink) 35 | { 36 | if (!dynamic_cast(sink)) return; // Sanity check 37 | 38 | _sinks.insert(sink); 39 | } 40 | 41 | void StreamSource::detach(StreamSink* sink) 42 | { 43 | if (!dynamic_cast(sink)) return; // Sanity check 44 | 45 | _sinks.erase(sink); 46 | } 47 | 48 | void StreamSource::streamData(StreamBuffer* buffer) 49 | { 50 | for (auto sink : _sinks) { 51 | sink->streamData(buffer); 52 | } 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////////// 57 | // StreamSink 58 | ////////////////////////////////////////////////////////////////////////////// 59 | 60 | void StreamSink::play() 61 | { 62 | } 63 | 64 | void StreamSink::stop() 65 | { 66 | } 67 | 68 | void StreamSink::pause() 69 | { 70 | } 71 | 72 | void StreamSink::resume() 73 | { 74 | } 75 | 76 | 77 | ////////////////////////////////////////////////////////////////////////////// 78 | // VideoStreamSource 79 | ////////////////////////////////////////////////////////////////////////////// 80 | 81 | VideoStreamSource::~VideoStreamSource() 82 | { 83 | } 84 | 85 | ////////////////////////////////////////////////////////////////////////////// 86 | // H264VideoStreamSource 87 | ////////////////////////////////////////////////////////////////////////////// 88 | 89 | H264VideoStreamSource::~H264VideoStreamSource() 90 | { 91 | } 92 | 93 | ////////////////////////////////////////////////////////////////////////////// 94 | // JPEGVideoStreamSource 95 | ////////////////////////////////////////////////////////////////////////////// 96 | 97 | JPEGVideoStreamSource::~JPEGVideoStreamSource() 98 | { 99 | } 100 | 101 | ////////////////////////////////////////////////////////////////////////////// 102 | // AudioStreamSource 103 | ////////////////////////////////////////////////////////////////////////////// 104 | 105 | AudioStreamSource::~AudioStreamSource() 106 | { 107 | } 108 | 109 | } //namespace Media 110 | } //namespace Ipcam 111 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-sysctl.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-sysctl.cpp 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "himpp-sysctl.h" 24 | 25 | HimppSysctl::HimppSysctl(HI_U32 align_width, HI_U32 max_pool_cnt) 26 | : MediaElement(NULL), alignWidth(align_width), maxPoolCount(max_pool_cnt) 27 | { 28 | } 29 | 30 | HimppSysctl::~HimppSysctl() 31 | { 32 | } 33 | 34 | void HimppSysctl::addVideoBuffer(HI_U32 blksiz, HI_U32 blkcnt) 35 | { 36 | buffers.emplace(buffers.end(), blksiz, blkcnt); 37 | } 38 | 39 | void HimppSysctl::setAlignWidth(HI_U32 value) 40 | { 41 | alignWidth = value; 42 | } 43 | 44 | void HimppSysctl::setMaxPoolCount(HI_U32 value) 45 | { 46 | maxPoolCount = value; 47 | } 48 | 49 | void HimppSysctl::doEnableElement() 50 | { 51 | HI_S32 s32Ret = HI_FAILURE; 52 | 53 | VB_CONF_S vbconf; 54 | memset(&vbconf, 0, sizeof(vbconf)); 55 | vbconf.u32MaxPoolCnt = maxPoolCount; 56 | int i = 0; 57 | for (auto &b : buffers) { 58 | vbconf.astCommPool[i].u32BlkSize = b.blksiz; 59 | vbconf.astCommPool[i].u32BlkCnt = b.blkcnt; 60 | i++; 61 | } 62 | 63 | HI_MPI_SYS_Exit(); 64 | HI_MPI_VB_Exit(); 65 | 66 | s32Ret = HI_MPI_VB_SetConf(&vbconf); 67 | if (s32Ret != HI_SUCCESS) { 68 | HIMPP_PRINT("HI_MPI_VB_SetConf failed [%#x]\n", s32Ret); 69 | throw IpcamError("Failed to set vb config"); 70 | } 71 | 72 | s32Ret = HI_MPI_VB_Init(); 73 | if (s32Ret != HI_SUCCESS) { 74 | HIMPP_PRINT("HI_MPI_VB_Init failed [%#x]\n", s32Ret); 75 | throw IpcamError("Failed to init vb"); 76 | } 77 | 78 | MPP_SYS_CONF_S sysconf = { 79 | .u32AlignWidth = alignWidth 80 | }; 81 | s32Ret = HI_MPI_SYS_SetConf(&sysconf); 82 | if (s32Ret != HI_SUCCESS) { 83 | HIMPP_PRINT("HI_MPI_SYS_SetConf failed [%#x]\n", s32Ret); 84 | goto err_vb_cleanup; 85 | } 86 | 87 | s32Ret = HI_MPI_SYS_Init(); 88 | if (s32Ret != HI_SUCCESS) { 89 | HIMPP_PRINT("HI_MPI_SYS_Init failed [%#x]\n", s32Ret); 90 | goto err_vb_cleanup; 91 | } 92 | 93 | return; 94 | 95 | err_vb_cleanup: 96 | HI_MPI_VB_Exit(); 97 | throw IpcamError("Failed to init sys"); 98 | } 99 | 100 | void HimppSysctl::doDisableElement() 101 | { 102 | HI_S32 s32Ret; 103 | 104 | if ((s32Ret = HI_MPI_SYS_Exit()) != HI_SUCCESS) { 105 | HIMPP_PRINT("HI_MPI_SYS_Exit failed [%#x]\n", s32Ret); 106 | } 107 | if ((s32Ret = HI_MPI_VB_Exit()) != HI_SUCCESS) { 108 | HIMPP_PRINT("HI_MPI_VB_Exit failed [%#x]\n", s32Ret); 109 | } 110 | if ((s32Ret = HI_MPI_SYS_CloseFd()) != HI_SUCCESS) { 111 | HIMPP_PRINT("HI_MPI_SYS_CloseFd failed [%#x]\n", s32Ret); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-sysctl.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-sysctl.cpp 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "himpp-sysctl.h" 24 | 25 | HimppSysctl::HimppSysctl(HI_U32 align_width, HI_U32 max_pool_cnt) 26 | : MediaElement(NULL), alignWidth(align_width), maxPoolCount(max_pool_cnt) 27 | { 28 | } 29 | 30 | HimppSysctl::~HimppSysctl() 31 | { 32 | } 33 | 34 | void HimppSysctl::addVideoBuffer(HI_U32 blksiz, HI_U32 blkcnt) 35 | { 36 | buffers.emplace(buffers.end(), blksiz, blkcnt); 37 | } 38 | 39 | void HimppSysctl::setAlignWidth(HI_U32 value) 40 | { 41 | alignWidth = value; 42 | } 43 | 44 | void HimppSysctl::setMaxPoolCount(HI_U32 value) 45 | { 46 | maxPoolCount = value; 47 | } 48 | 49 | void HimppSysctl::doEnableElement() 50 | { 51 | HI_S32 s32Ret = HI_FAILURE; 52 | 53 | VB_CONF_S vbconf; 54 | memset(&vbconf, 0, sizeof(vbconf)); 55 | vbconf.u32MaxPoolCnt = maxPoolCount; 56 | int i = 0; 57 | for (auto &b : buffers) { 58 | vbconf.astCommPool[i].u32BlkSize = b.blksiz; 59 | vbconf.astCommPool[i].u32BlkCnt = b.blkcnt; 60 | i++; 61 | } 62 | 63 | HI_MPI_SYS_Exit(); 64 | HI_MPI_VB_Exit(); 65 | 66 | s32Ret = HI_MPI_VB_SetConf(&vbconf); 67 | if (s32Ret != HI_SUCCESS) { 68 | HIMPP_PRINT("HI_MPI_VB_SetConf failed [%#x]\n", s32Ret); 69 | throw IpcamError("Failed to set vb config"); 70 | } 71 | 72 | s32Ret = HI_MPI_VB_Init(); 73 | if (s32Ret != HI_SUCCESS) { 74 | HIMPP_PRINT("HI_MPI_VB_Init failed [%#x]\n", s32Ret); 75 | throw IpcamError("Failed to init vb"); 76 | } 77 | 78 | MPP_SYS_CONF_S sysconf = { 79 | .u32AlignWidth = alignWidth 80 | }; 81 | s32Ret = HI_MPI_SYS_SetConf(&sysconf); 82 | if (s32Ret != HI_SUCCESS) { 83 | HIMPP_PRINT("HI_MPI_SYS_SetConf failed [%#x]\n", s32Ret); 84 | goto err_vb_cleanup; 85 | } 86 | 87 | s32Ret = HI_MPI_SYS_Init(); 88 | if (s32Ret != HI_SUCCESS) { 89 | HIMPP_PRINT("HI_MPI_SYS_Init failed [%#x]\n", s32Ret); 90 | goto err_vb_cleanup; 91 | } 92 | 93 | return; 94 | 95 | err_vb_cleanup: 96 | HI_MPI_VB_Exit(); 97 | throw IpcamError("Failed to init sys"); 98 | } 99 | 100 | void HimppSysctl::doDisableElement() 101 | { 102 | HI_S32 s32Ret; 103 | 104 | if ((s32Ret = HI_MPI_SYS_Exit()) != HI_SUCCESS) { 105 | HIMPP_PRINT("HI_MPI_SYS_Exit failed [%#x]\n", s32Ret); 106 | } 107 | if ((s32Ret = HI_MPI_VB_Exit()) != HI_SUCCESS) { 108 | HIMPP_PRINT("HI_MPI_VB_Exit failed [%#x]\n", s32Ret); 109 | } 110 | if ((s32Ret = HI_MPI_SYS_CloseFd()) != HI_SUCCESS) { 111 | HIMPP_PRINT("HI_MPI_SYS_CloseFd failed [%#x]\n", s32Ret); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-sysctl.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-sysctl.cpp 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "himpp-sysctl.h" 24 | 25 | HimppSysctl::HimppSysctl(HI_U32 align_width, HI_U32 max_pool_cnt) 26 | : MediaElement(NULL), alignWidth(align_width), maxPoolCount(max_pool_cnt) 27 | { 28 | } 29 | 30 | HimppSysctl::~HimppSysctl() 31 | { 32 | } 33 | 34 | void HimppSysctl::addVideoBuffer(HI_U32 blksiz, HI_U32 blkcnt) 35 | { 36 | buffers.emplace(buffers.end(), blksiz, blkcnt); 37 | } 38 | 39 | void HimppSysctl::setAlignWidth(HI_U32 value) 40 | { 41 | alignWidth = value; 42 | } 43 | 44 | void HimppSysctl::setMaxPoolCount(HI_U32 value) 45 | { 46 | maxPoolCount = value; 47 | } 48 | 49 | void HimppSysctl::doEnableElement() 50 | { 51 | HI_S32 s32Ret = HI_FAILURE; 52 | 53 | VB_CONFIG_S vbconf; 54 | memset(&vbconf, 0, sizeof(vbconf)); 55 | vbconf.u32MaxPoolCnt = maxPoolCount; 56 | int i = 0; 57 | for (auto &b : buffers) { 58 | vbconf.astCommPool[i].u64BlkSize = b.blksiz; 59 | vbconf.astCommPool[i].u32BlkCnt = b.blkcnt; 60 | i++; 61 | } 62 | 63 | HI_MPI_SYS_Exit(); 64 | HI_MPI_VB_Exit(); 65 | 66 | s32Ret = HI_MPI_VB_SetConfig(&vbconf); 67 | if (s32Ret != HI_SUCCESS) { 68 | HIMPP_PRINT("HI_MPI_VB_SetConfig failed [%#x]\n", s32Ret); 69 | throw IpcamError("Failed to set vb config"); 70 | } 71 | 72 | s32Ret = HI_MPI_VB_Init(); 73 | if (s32Ret != HI_SUCCESS) { 74 | HIMPP_PRINT("HI_MPI_VB_Init failed [%#x]\n", s32Ret); 75 | throw IpcamError("Failed to init vb"); 76 | } 77 | 78 | MPP_SYS_CONFIG_S sysconf = { 79 | .u32Align = alignWidth 80 | }; 81 | s32Ret = HI_MPI_SYS_SetConfig(&sysconf); 82 | if (s32Ret != HI_SUCCESS) { 83 | HIMPP_PRINT("HI_MPI_SYS_SetConf failed [%#x]\n", s32Ret); 84 | goto err_vb_cleanup; 85 | } 86 | 87 | s32Ret = HI_MPI_SYS_Init(); 88 | if (s32Ret != HI_SUCCESS) { 89 | HIMPP_PRINT("HI_MPI_SYS_Init failed [%#x]\n", s32Ret); 90 | goto err_vb_cleanup; 91 | } 92 | 93 | return; 94 | 95 | err_vb_cleanup: 96 | HI_MPI_VB_Exit(); 97 | throw IpcamError("Failed to init sys"); 98 | } 99 | 100 | void HimppSysctl::doDisableElement() 101 | { 102 | HI_S32 s32Ret; 103 | 104 | if ((s32Ret = HI_MPI_SYS_Exit()) != HI_SUCCESS) { 105 | HIMPP_PRINT("HI_MPI_SYS_Exit failed [%#x]\n", s32Ret); 106 | } 107 | if ((s32Ret = HI_MPI_VB_Exit()) != HI_SUCCESS) { 108 | HIMPP_PRINT("HI_MPI_VB_Exit failed [%#x]\n", s32Ret); 109 | } 110 | if ((s32Ret = HI_MPI_SYS_CloseFd()) != HI_SUCCESS) { 111 | HIMPP_PRINT("HI_MPI_SYS_CloseFd failed [%#x]\n", s32Ret); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* define if the compiler supports basic C++11 syntax */ 4 | #undef HAVE_CXX11 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_DLFCN_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_EV_H 11 | 12 | /* support Hi3516cv300 MPP */ 13 | #undef HAVE_HI3516CV300_SUPPORT 14 | 15 | /* support Hi3516ev200 MPP */ 16 | #undef HAVE_HI3516EV200_SUPPORT 17 | 18 | /* support Hi3518v100 MPP */ 19 | #undef HAVE_HI3518V100_SUPPORT 20 | 21 | /* support Hi3518v200 MPP */ 22 | #undef HAVE_HI3518V200_SUPPORT 23 | 24 | /* support Hi3520dv200 MPP */ 25 | #undef HAVE_HI3520DV200_SUPPORT 26 | 27 | /* support Hi3520 MPP */ 28 | #undef HAVE_HI3520V100_SUPPORT 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_INTTYPES_H 32 | 33 | /* jsoncpp support */ 34 | #undef HAVE_JSONCPP_SUPPORT 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_MEMORY_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_STDINT_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_STDLIB_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_STRINGS_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_STRING_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_SYS_STAT_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_SYS_TYPES_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_UNISTD_H 59 | 60 | /* vo-aacenc support */ 61 | #undef HAVE_VO_AACENC_SUPPORT 62 | 63 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 64 | */ 65 | #undef LT_OBJDIR 66 | 67 | /* Name of package */ 68 | #undef PACKAGE 69 | 70 | /* Define to the address where bug reports for this package should be sent. */ 71 | #undef PACKAGE_BUGREPORT 72 | 73 | /* Define to the full name of this package. */ 74 | #undef PACKAGE_NAME 75 | 76 | /* Define to the full name and version of this package. */ 77 | #undef PACKAGE_STRING 78 | 79 | /* Define to the one symbol short name of this package. */ 80 | #undef PACKAGE_TARNAME 81 | 82 | /* Define to the home page for this package. */ 83 | #undef PACKAGE_URL 84 | 85 | /* Define to the version of this package. */ 86 | #undef PACKAGE_VERSION 87 | 88 | /* Define to 1 if you have the ANSI C header files. */ 89 | #undef STDC_HEADERS 90 | 91 | /* Enable extensions on AIX 3, Interix. */ 92 | #ifndef _ALL_SOURCE 93 | # undef _ALL_SOURCE 94 | #endif 95 | /* Enable GNU extensions on systems that have them. */ 96 | #ifndef _GNU_SOURCE 97 | # undef _GNU_SOURCE 98 | #endif 99 | /* Enable threading extensions on Solaris. */ 100 | #ifndef _POSIX_PTHREAD_SEMANTICS 101 | # undef _POSIX_PTHREAD_SEMANTICS 102 | #endif 103 | /* Enable extensions on HP NonStop. */ 104 | #ifndef _TANDEM_SOURCE 105 | # undef _TANDEM_SOURCE 106 | #endif 107 | /* Enable general extensions on Solaris. */ 108 | #ifndef __EXTENSIONS__ 109 | # undef __EXTENSIONS__ 110 | #endif 111 | 112 | 113 | /* Version number of package */ 114 | #undef VERSION 115 | 116 | /* Define to 1 if on MINIX. */ 117 | #undef _MINIX 118 | 119 | /* Define to 2 if the system does not provide POSIX.1 features except with 120 | this defined. */ 121 | #undef _POSIX_1_SOURCE 122 | 123 | /* Define to 1 if you need to in order for `stat' and other things to work. */ 124 | #undef _POSIX_SOURCE 125 | -------------------------------------------------------------------------------- /src/ipcam-runtime.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * ipcam-runtime.h 4 | * Copyright (C) 2016 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _IPCAM_RUNTIME_H_ 21 | #define _IPCAM_RUNTIME_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef HAVE_JSONCPP_SUPPORT 34 | #include 35 | #endif 36 | 37 | using namespace Ipcam::Media; 38 | 39 | class RTSPServer; 40 | 41 | class ServerMediaSession; 42 | class ServerMediaSubsession; 43 | class AudioOutputStream; 44 | 45 | namespace DBus 46 | { 47 | class Connection; 48 | class AudioSource; 49 | class AudioEncoder; 50 | class VideoSource; 51 | class VideoEncoder; 52 | } 53 | 54 | typedef ServerMediaSession* RTSPStream; 55 | typedef ServerMediaSubsession* RTSPSubstream; 56 | 57 | class IpcamRuntime 58 | { 59 | public: 60 | IpcamRuntime(std::string config_file, ev::default_loop &loop, RTSPServer *rtspServer, DBus::Connection *conn); 61 | ~IpcamRuntime(); 62 | 63 | RTSPStream addRTSPStream(const std::string& path, VideoStreamSource* video, AudioStreamSource* audio); 64 | void addAudioSource(AudioSource* audio_source); 65 | void addAudioEncoder(AudioEncoder* audio_encoder); 66 | void addVideoSource(VideoSource* video_source); 67 | void addVideoEncoder(VideoEncoder* video_encoder); 68 | 69 | void addAudioOutputStream(in_addr addr, uint16_t portNum, AudioStreamSink* sink); 70 | 71 | ev::default_loop &mainloop() { return _loop; } 72 | DBus::Connection &dbus_conn() { return *_dbus_connection; } 73 | #ifdef HAVE_JSONCPP_SUPPORT 74 | Json::Value &config_root() { return _config_root; } 75 | void LoadConfig(); 76 | void SaveConfig(); 77 | #endif 78 | 79 | private: 80 | ev::default_loop& _loop; 81 | RTSPServer* _rtsp_server; 82 | DBus::Connection* _dbus_connection; 83 | #ifdef HAVE_JSONCPP_SUPPORT 84 | Json::Value _config_root; 85 | std::string _config_name; 86 | bool _config_dirty; 87 | ev::timer _config_timer; 88 | void config_timer_handler(ev::timer& w, int revents); 89 | #endif 90 | 91 | typedef std::list IpcamStreamList; 92 | typedef std::list> IpcamAudioSourceList; 93 | typedef std::list> IpcamAudioEncoderList; 94 | typedef std::list> IpcamVideoSourceList; 95 | typedef std::list> IpcamVideoEncoderList; 96 | typedef std::list> IpcamAudioOutStreamList; 97 | 98 | IpcamStreamList _stream_list; 99 | IpcamAudioSourceList _audio_source_list; 100 | IpcamAudioEncoderList _audio_encoder_list; 101 | IpcamVideoSourceList _video_source_list; 102 | IpcamVideoEncoderList _video_encoder_list; 103 | IpcamAudioOutStreamList _aout_stream_list; 104 | }; 105 | 106 | #endif // _IPCAM_RUNTIME_H_ 107 | 108 | -------------------------------------------------------------------------------- /src/dbus/dbus-audio-encoder.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * dbus-audio-encoder.cpp 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifdef HAVE_CONFIG_H 21 | #include 22 | #endif 23 | 24 | #include 25 | #include 26 | 27 | #include "dbus-audio-encoder.h" 28 | 29 | namespace DBus { 30 | 31 | #define AUDIOENCODER_INTERFACE "ipcam.Media.AudioEncoder" 32 | 33 | #define DEFINE_PROP(prop, get, set) \ 34 | _prop_handler.emplace(std::piecewise_construct, \ 35 | std::forward_as_tuple(prop), \ 36 | std::forward_as_tuple(get, set)) 37 | 38 | AudioEncoder::AudioEncoder 39 | (IpcamRuntime &runtime, std::string obj_path, Ipcam::Media::AudioEncoder* encoder) 40 | : IpcamBase(runtime, obj_path), 41 | _audio_encoder(encoder) 42 | { 43 | assert(encoder != NULL); 44 | 45 | // Handler of ipcam.Media.AudioEncoder 46 | DEFINE_PROP(AUDIOENCODER_INTERFACE ".Encoding", 47 | [this](DBus::InterfaceAdaptor &interface, 48 | const std::string &property, DBus::Variant &value) 49 | { 50 | value.writer().append_uint32((uint32_t)_audio_encoder->getEncoding()); 51 | }, 52 | [this](DBus::InterfaceAdaptor &interface, 53 | const std::string &property, const DBus::Variant &value) 54 | { 55 | throw IpcamError("Readonly property"); 56 | }); 57 | DEFINE_PROP(AUDIOENCODER_INTERFACE ".Bitrate", 58 | [this](DBus::InterfaceAdaptor &interface, 59 | const std::string &property, DBus::Variant &value) 60 | { 61 | value.writer().append_uint32((uint32_t)_audio_encoder->getBitrate()); 62 | }, 63 | [this](DBus::InterfaceAdaptor &interface, 64 | const std::string &property, const DBus::Variant &value) 65 | { 66 | _audio_encoder->setBitrate((uint32_t)value); 67 | }); 68 | DEFINE_PROP(AUDIOENCODER_INTERFACE ".SampleRate", 69 | [this](DBus::InterfaceAdaptor &interface, 70 | const std::string &property, DBus::Variant &value) 71 | { 72 | value.writer().append_uint32((uint32_t)_audio_encoder->getSampleRate()); 73 | }, 74 | [this](DBus::InterfaceAdaptor &interface, 75 | const std::string &property, const DBus::Variant &value) 76 | { 77 | _audio_encoder->setSampleRate((uint32_t)value); 78 | }); 79 | } 80 | 81 | void AudioEncoder::do_property_get 82 | (DBus::InterfaceAdaptor &interface, const std::string &property, DBus::Variant &value) 83 | { 84 | value.clear(); 85 | 86 | auto iter = _prop_handler.find(interface.name() + "." + property); 87 | if (iter == _prop_handler.end()) 88 | throw DBus::ErrorFailed("Requested interface or property not found"); 89 | iter->second.Get(interface, property, value); 90 | } 91 | 92 | void AudioEncoder::do_property_set 93 | (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value) 94 | { 95 | auto iter = _prop_handler.find(interface.name() + "." + property); 96 | if (iter == _prop_handler.end()) 97 | throw DBus::ErrorFailed("Requested interface or property not found"); 98 | iter->second.Set(interface, property, value); 99 | } 100 | 101 | } //namespace DBus 102 | -------------------------------------------------------------------------------- /src/common/media-element.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * media-element.cpp 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | #include "media-element.h" 23 | 24 | namespace Ipcam { 25 | namespace Media { 26 | 27 | 28 | ////////////////////////////////////////////////////////////////////////////// 29 | // MediaElement 30 | ////////////////////////////////////////////////////////////////////////////// 31 | 32 | MediaElement::MediaElement(MediaElement* source) 33 | : _source(source), _enable_count(0), _flags(0) 34 | { 35 | } 36 | 37 | MediaElement::~MediaElement() 38 | { 39 | } 40 | 41 | void MediaElement::enable() 42 | { 43 | assert(_enable_count >= 0); 44 | 45 | if (_enable_count++ == 0) { 46 | if (_source) { 47 | try { 48 | _source->enable(); 49 | } 50 | catch (IpcamError &e) { 51 | _enable_count--; 52 | throw e; 53 | } 54 | } 55 | 56 | try { 57 | doEnableElement(); 58 | } 59 | catch (IpcamError &e) { 60 | if (_source) _source->disable(); 61 | 62 | _enable_count--; 63 | 64 | throw e; 65 | } 66 | } 67 | } 68 | 69 | void MediaElement::disable() 70 | { 71 | assert(_enable_count > 0); 72 | 73 | if (_enable_count-- == 1) { 74 | doDisableElement(); 75 | 76 | if (_source) _source->disable(); 77 | } 78 | } 79 | 80 | 81 | ////////////////////////////////////////////////////////////////////////////// 82 | // VideoElement 83 | ////////////////////////////////////////////////////////////////////////////// 84 | 85 | VideoElement::VideoElement(VideoElement* upstream) 86 | : MediaElement(MEDIA_ELEMENT(upstream)) 87 | { 88 | } 89 | 90 | VideoElement::~VideoElement() 91 | { 92 | } 93 | 94 | Resolution VideoElement::resolution() 95 | { 96 | VideoElement* upstream = VIDEO_ELEMENT(source()); 97 | 98 | if (upstream == NULL) 99 | throw IpcamError("Not implemented"); 100 | 101 | return upstream->resolution(); 102 | } 103 | 104 | uint32_t VideoElement::framerate() 105 | { 106 | VideoElement* upstream = VIDEO_ELEMENT(source()); 107 | 108 | if (upstream == NULL) 109 | throw IpcamError("Not implemented"); 110 | 111 | return upstream->framerate(); 112 | } 113 | 114 | 115 | ////////////////////////////////////////////////////////////////////////////// 116 | // AudioElement 117 | ////////////////////////////////////////////////////////////////////////////// 118 | 119 | AudioElement::AudioElement(AudioElement* source) 120 | : MediaElement(MEDIA_ELEMENT(source)) 121 | { 122 | } 123 | 124 | AudioElement::~AudioElement() 125 | { 126 | } 127 | 128 | uint32_t AudioElement::samplerate() 129 | { 130 | AudioElement* upstream = AUDIO_ELEMENT(source()); 131 | 132 | if (!upstream) 133 | throw IpcamError("Not implemented"); 134 | 135 | return upstream->samplerate(); 136 | } 137 | 138 | uint32_t AudioElement::channels() 139 | { 140 | AudioElement* upstream = AUDIO_ELEMENT(source()); 141 | 142 | if (!upstream) 143 | throw IpcamError("Not implemented"); 144 | 145 | return upstream->channels(); 146 | } 147 | 148 | } // namespace Media 149 | } // namespace Ipcam 150 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-ircut.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-ircut.h 4 | * Copyright (C) 2018 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_IRCUT_H_ 21 | #define _HIMPP_IRCUT_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class HimppIrCut; 28 | 29 | #define HIMPP_IRCUT(o) dynamic_cast(o) 30 | 31 | class IODevice 32 | { 33 | public: 34 | enum DIR { IN, OUT }; 35 | 36 | IODevice(); 37 | IODevice(const char* name, DIR dir); 38 | virtual ~IODevice(); 39 | 40 | bool is_open() { return filedesc >= 0; } 41 | int initialize(const char* name, DIR dir); 42 | int setValue(int value); 43 | int getValue(int& value); 44 | 45 | private: 46 | int filedesc; 47 | }; 48 | 49 | class HimppIrCut: public HimppVideoElement, public DefaultVideoSource 50 | { 51 | public: 52 | class Imaging : public DefaultVideoSource::Imaging 53 | { 54 | public: 55 | class IrCutFilter : public DefaultVideoSource::Imaging::IrCutFilter 56 | { 57 | public: 58 | IrCutFilter(Imaging& imaging); 59 | virtual ~IrCutFilter(); 60 | 61 | IrCutFilterMode getMode(); 62 | void setMode(IrCutFilterMode value); 63 | int32_t getThreshold(); 64 | void setThreshold(int32_t value); 65 | uint32_t getHysteresis(); 66 | void setHysteresis(uint32_t value); 67 | uint32_t getBrightness(); 68 | void setBrightness(uint32_t value); 69 | }; 70 | public: 71 | Imaging(HimppIrCut& ircut); 72 | ~Imaging(); 73 | 74 | // implementation of VideoSource::Imaging 75 | VideoSource::Imaging::IrCutFilter& ircutfilter(); 76 | public: 77 | IrCutFilter _ircutfilter; 78 | }; 79 | public: 80 | HimppIrCut(HimppVideoElement* source, std::unordered_map params); 81 | virtual ~HimppIrCut(); 82 | 83 | // implementation of HimppVideoElement 84 | MPP_CHN_S* bindSource(); 85 | 86 | // implementation of VideoSource 87 | VideoSource::Imaging& imaging(); 88 | 89 | IrCutFilterMode getMode(); 90 | void setMode(IrCutFilterMode value); 91 | int32_t getThreshold(); 92 | void setThreshold(int32_t value); 93 | uint32_t getHysteresis(); 94 | void setHysteresis(uint32_t value); 95 | uint32_t getBrightness(); 96 | void setBrightness(uint32_t value); 97 | 98 | protected: 99 | void doEnableElement(); 100 | void doDisableElement(); 101 | 102 | private: 103 | void sensor_timer_handler(ev::timer& w, int revents); 104 | void ircut_timer_handler(ev::timer& w, int revents); 105 | void ircut_on(); 106 | void ircut_off(); 107 | 108 | private: 109 | Imaging _imaging; 110 | 111 | IrCutFilterMode _mode; 112 | int32_t _threshold; 113 | uint32_t _hysteresis; 114 | uint32_t _brightness; 115 | int _debounce_count; 116 | IrCutFilterMode _status; 117 | IODevice _sensor_dev; // Sensor ADC input 118 | IODevice _ircutp_dev; // IRCUT+ 119 | IODevice _ircutn_dev; // IRCUT- 120 | IODevice _irleden_dev; // IRLED enable 121 | IODevice _irledbr_dev; // IRLED brightness 122 | ev::timer _sensor_timer; 123 | ev::timer _ircut_timer; 124 | }; 125 | 126 | #endif // _HIMPP_IRCUT_H_ 127 | 128 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-ircut.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-ircut.h 4 | * Copyright (C) 2018 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_IRCUT_H_ 21 | #define _HIMPP_IRCUT_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class HimppIrCut; 28 | 29 | #define HIMPP_IRCUT(o) dynamic_cast(o) 30 | 31 | class IODevice 32 | { 33 | public: 34 | enum DIR { IN, OUT }; 35 | 36 | IODevice(); 37 | IODevice(const char* name, DIR dir); 38 | virtual ~IODevice(); 39 | 40 | bool is_open() { return filedesc >= 0; } 41 | int initialize(const char* name, DIR dir); 42 | int setValue(int value); 43 | int getValue(int& value); 44 | 45 | private: 46 | int filedesc; 47 | }; 48 | 49 | class HimppIrCut: public HimppVideoElement, public DefaultVideoSource 50 | { 51 | public: 52 | class Imaging : public DefaultVideoSource::Imaging 53 | { 54 | public: 55 | class IrCutFilter : public DefaultVideoSource::Imaging::IrCutFilter 56 | { 57 | public: 58 | IrCutFilter(Imaging& imaging); 59 | virtual ~IrCutFilter(); 60 | 61 | IrCutFilterMode getMode(); 62 | void setMode(IrCutFilterMode value); 63 | int32_t getThreshold(); 64 | void setThreshold(int32_t value); 65 | uint32_t getHysteresis(); 66 | void setHysteresis(uint32_t value); 67 | uint32_t getBrightness(); 68 | void setBrightness(uint32_t value); 69 | }; 70 | public: 71 | Imaging(HimppIrCut& ircut); 72 | ~Imaging(); 73 | 74 | // implementation of VideoSource::Imaging 75 | VideoSource::Imaging::IrCutFilter& ircutfilter(); 76 | public: 77 | IrCutFilter _ircutfilter; 78 | }; 79 | public: 80 | HimppIrCut(HimppVideoElement* source, std::unordered_map params); 81 | virtual ~HimppIrCut(); 82 | 83 | // implementation of HimppVideoElement 84 | MPP_CHN_S* bindSource(); 85 | 86 | // implementation of VideoSource 87 | VideoSource::Imaging& imaging(); 88 | 89 | IrCutFilterMode getMode(); 90 | void setMode(IrCutFilterMode value); 91 | int32_t getThreshold(); 92 | void setThreshold(int32_t value); 93 | uint32_t getHysteresis(); 94 | void setHysteresis(uint32_t value); 95 | uint32_t getBrightness(); 96 | void setBrightness(uint32_t value); 97 | 98 | protected: 99 | void doEnableElement(); 100 | void doDisableElement(); 101 | 102 | private: 103 | void sensor_timer_handler(ev::timer& w, int revents); 104 | void ircut_timer_handler(ev::timer& w, int revents); 105 | void ircut_on(); 106 | void ircut_off(); 107 | 108 | private: 109 | Imaging _imaging; 110 | 111 | IrCutFilterMode _mode; 112 | int32_t _threshold; 113 | uint32_t _hysteresis; 114 | uint32_t _brightness; 115 | int _debounce_count; 116 | IrCutFilterMode _status; 117 | IODevice _sensor_dev; // Sensor ADC input 118 | IODevice _ircutp_dev; // IRCUT+ 119 | IODevice _ircutn_dev; // IRCUT- 120 | IODevice _irleden_dev; // IRLED enable 121 | IODevice _irledbr_dev; // IRLED brightness 122 | ev::timer _sensor_timer; 123 | ev::timer _ircut_timer; 124 | }; 125 | 126 | #endif // _HIMPP_IRCUT_H_ 127 | 128 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-ircut.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-ircut.h 4 | * Copyright (C) 2018 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_IRCUT_H_ 21 | #define _HIMPP_IRCUT_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class HimppIrCut; 28 | 29 | #define HIMPP_IRCUT(o) dynamic_cast(o) 30 | 31 | class IODevice 32 | { 33 | public: 34 | enum DIR { IN, OUT }; 35 | 36 | IODevice(); 37 | IODevice(const char* name, DIR dir); 38 | virtual ~IODevice(); 39 | 40 | bool is_open() { return filedesc >= 0; } 41 | int initialize(const char* name, DIR dir); 42 | int setValue(int value); 43 | int getValue(int& value); 44 | 45 | private: 46 | int filedesc; 47 | }; 48 | 49 | class HimppIrCut: public HimppVideoElement, public DefaultVideoSource 50 | { 51 | public: 52 | class Imaging : public DefaultVideoSource::Imaging 53 | { 54 | public: 55 | class IrCutFilter : public DefaultVideoSource::Imaging::IrCutFilter 56 | { 57 | public: 58 | IrCutFilter(Imaging& imaging); 59 | virtual ~IrCutFilter(); 60 | 61 | IrCutFilterMode getMode(); 62 | void setMode(IrCutFilterMode value); 63 | int32_t getThreshold(); 64 | void setThreshold(int32_t value); 65 | uint32_t getHysteresis(); 66 | void setHysteresis(uint32_t value); 67 | uint32_t getBrightness(); 68 | void setBrightness(uint32_t value); 69 | }; 70 | public: 71 | Imaging(HimppIrCut& ircut); 72 | ~Imaging(); 73 | 74 | // implementation of VideoSource::Imaging 75 | VideoSource::Imaging::IrCutFilter& ircutfilter(); 76 | public: 77 | IrCutFilter _ircutfilter; 78 | }; 79 | public: 80 | HimppIrCut(HimppVideoElement* source, std::unordered_map params); 81 | virtual ~HimppIrCut(); 82 | 83 | // implementation of HimppVideoElement 84 | MPP_CHN_S* bindSource(); 85 | 86 | // implementation of VideoSource 87 | VideoSource::Imaging& imaging(); 88 | 89 | IrCutFilterMode getMode(); 90 | void setMode(IrCutFilterMode value); 91 | int32_t getThreshold(); 92 | void setThreshold(int32_t value); 93 | uint32_t getHysteresis(); 94 | void setHysteresis(uint32_t value); 95 | uint32_t getBrightness(); 96 | void setBrightness(uint32_t value); 97 | 98 | protected: 99 | void doEnableElement(); 100 | void doDisableElement(); 101 | 102 | private: 103 | void sensor_timer_handler(ev::timer& w, int revents); 104 | void ircut_timer_handler(ev::timer& w, int revents); 105 | void ircut_on(); 106 | void ircut_off(); 107 | 108 | private: 109 | Imaging _imaging; 110 | 111 | IrCutFilterMode _mode; 112 | int32_t _threshold; 113 | uint32_t _hysteresis; 114 | uint32_t _brightness; 115 | int _debounce_count; 116 | IrCutFilterMode _status; 117 | IODevice _sensor_dev; // Sensor ADC input 118 | IODevice _ircutp_dev; // IRCUT+ 119 | IODevice _ircutn_dev; // IRCUT- 120 | IODevice _irleden_dev; // IRLED enable 121 | IODevice _irledbr_dev; // IRLED brightness 122 | ev::timer _sensor_timer; 123 | ev::timer _ircut_timer; 124 | }; 125 | 126 | #endif // _HIMPP_IRCUT_H_ 127 | 128 | -------------------------------------------------------------------------------- /src/common/video-encoder.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * video-encoder.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _VIDEO_ENCODER_H_ 21 | #define _VIDEO_ENCODER_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace Ipcam { 29 | namespace Media { 30 | 31 | enum RateCtrlMode { CBR, VBR, FIXQP }; 32 | enum H264Profile { BASELINE, MAIN, HIGH, SVC_T }; 33 | 34 | class VideoEncoder; 35 | class H264VideoEncoder; 36 | class JPEGVideoEncoder; 37 | 38 | #define VIDEO_ENCODER(o) dynamic_cast(o) 39 | #define H264_VIDEO_ENCODER(o) dynamic_cast(o) 40 | #define JPEG_VIDEO_ENCODER(o) dynamic_cast(o) 41 | 42 | // control interface for video encoder 43 | class VideoEncoder 44 | { 45 | public: 46 | virtual ~VideoEncoder(); 47 | 48 | virtual VideoEncodingType getEncoding(); 49 | virtual Resolution getResolution(); 50 | virtual void setResolution(Resolution value); 51 | virtual uint32_t getFramerate(); 52 | virtual void setFramerate(uint32_t value); 53 | virtual RateCtrlMode getRcMode(); 54 | virtual void setRcMode(RateCtrlMode value); 55 | virtual uint32_t getBitrate(); 56 | virtual void setBitrate(uint32_t value); 57 | 58 | virtual VideoOSD* CreateOSD(); 59 | virtual void DeleteOSD(VideoOSD* osd); 60 | 61 | protected: 62 | VideoEncoder(); 63 | }; 64 | 65 | class H264VideoEncoder : public virtual VideoEncoder 66 | { 67 | public: 68 | struct FrameRefMode { 69 | uint32_t Base; 70 | uint32_t Enhanced; 71 | bool EnablePred; 72 | FrameRefMode(uint32_t base, uint32_t enhanced, bool enablepred) 73 | : Base(base), Enhanced(enhanced), EnablePred(enablepred) {} 74 | }; 75 | struct IntraRefreshParam { 76 | bool EnableRefresh; 77 | bool EnableISlice; 78 | uint32_t RefreshLineNum; 79 | uint32_t ReqIQp; 80 | IntraRefreshParam(bool refresh_en, bool islice_en, uint32_t linenum, uint32_t reqiqp) 81 | : EnableRefresh(refresh_en), EnableISlice(islice_en), RefreshLineNum(linenum), ReqIQp(reqiqp) {} 82 | }; 83 | public: 84 | virtual ~H264VideoEncoder(); 85 | 86 | virtual H264Profile getH264Profile(); 87 | virtual void setH264Profile(H264Profile value); 88 | virtual uint32_t getGovLength(); 89 | virtual void setGovLength(uint32_t value); 90 | virtual uint32_t getMinQP(); 91 | virtual void setMinQP(uint32_t value); 92 | virtual uint32_t getMaxQP(); 93 | virtual void setMaxQP(uint32_t value); 94 | 95 | virtual void setFrameRefMode(FrameRefMode value); 96 | virtual FrameRefMode getFrameRefMode(); 97 | virtual void setIntraRefresh(IntraRefreshParam value); 98 | virtual IntraRefreshParam getIntraRefresh(); 99 | 100 | protected: 101 | H264VideoEncoder(); 102 | }; 103 | 104 | class JPEGVideoEncoder : virtual public VideoEncoder 105 | { 106 | public: 107 | virtual ~JPEGVideoEncoder(); 108 | 109 | protected: 110 | JPEGVideoEncoder(); 111 | }; 112 | 113 | } // namespace Media 114 | } // namespace Ipcam 115 | 116 | #endif // _VIDEO_ENCODER_H_ 117 | 118 | -------------------------------------------------------------------------------- /src/dbus/video-source-introspect.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/rtsp-server/EvUsageEnvironment.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * EvUsageEnvironment.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef __EV_USAGE_ENVIRONMENT_H__ 21 | #define __EV_USAGE_ENVIRONMENT_H__ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class EvTaskScheduler: public TaskScheduler 31 | { 32 | public: 33 | static EvTaskScheduler* createNew(ev::default_loop& loop); 34 | virtual ~EvTaskScheduler(); 35 | virtual TaskToken scheduleDelayedTask(int64_t microseconds, TaskFunc* proc, 36 | void* clientData); 37 | virtual void unscheduleDelayedTask(TaskToken& prevTask); 38 | virtual void setBackgroundHandling(int socketNum, int conditionSet, 39 | BackgroundHandlerProc* handlerProc, 40 | void* clientData); 41 | virtual void moveSocketHandling(int oldSocketNum, int newSocketNum); 42 | virtual void doEventLoop(char volatile* watchVariable = NULL); 43 | virtual EventTriggerId createEventTrigger(TaskFunc* eventHandlerProc); 44 | virtual void deleteEventTrigger(EventTriggerId eventTriggerId); 45 | virtual void triggerEvent(EventTriggerId eventTriggerId, void* clientData = NULL); 46 | virtual void internalError(); 47 | 48 | protected: 49 | EvTaskScheduler(ev::default_loop& loop); 50 | 51 | private: 52 | struct DelayedTask : public ev::timer 53 | { 54 | DelayedTask(ev::loop_ref& loop, uint64_t usec, TaskFunc* proc, void* data); 55 | TaskToken token() { return (TaskToken)fToken; } 56 | 57 | TaskFunc* fCallback; 58 | void* fData; 59 | long fToken; 60 | static long tokenCounter; 61 | }; 62 | struct BackgroundHandling : public ev::io 63 | { 64 | BackgroundHandling(ev::loop_ref& loop, int fd, int events, 65 | BackgroundHandlerProc* proc, void* data); 66 | 67 | BackgroundHandlerProc* fCallback; 68 | void* fData; 69 | }; 70 | struct EventTrigger : public ev::async 71 | { 72 | EventTrigger(ev::loop_ref& loop, TaskFunc* proc); 73 | 74 | void setClientData(void* clientData) { fData = clientData; } 75 | EventTriggerId triggerId() { return (EventTriggerId)fTriggerId; } 76 | 77 | TaskFunc* fCallback; 78 | void* fData; 79 | uint32_t fTriggerId; 80 | static uint32_t triggerCounter; 81 | }; 82 | 83 | void delayed_task_thunk(ev::timer& w, int revents); 84 | void background_handling_thunk(ev::io& w, int revents); 85 | void event_trigger_thunk(ev::async& w, int revents); 86 | 87 | typedef std::unique_ptr DelayedTaskPtr; 88 | typedef std::unique_ptr BackgroundHandlingPtr; 89 | typedef std::unique_ptr EventTriggerPtr; 90 | typedef std::unordered_map BackgroundHandlingMap; 91 | typedef std::unordered_map DelayedTaskMap; 92 | typedef std::unordered_map EventTriggerMap; 93 | 94 | ev::loop_ref& fMainLoop; 95 | BackgroundHandlingMap fBackgroundHandlingMap; 96 | DelayedTaskMap fDelayedTaskMap; 97 | EventTriggerMap fEventTriggerMap; 98 | }; 99 | 100 | #endif // __EV_USAGE_ENVIRONMENT_H__ 101 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-video-venc.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-venc.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VENC_H_ 21 | #define _HIMPP_VIDEO_VENC_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace Ipcam::Media; 30 | 31 | class HimppVencChan; 32 | 33 | #define HIMPP_VENC_CHAN(o) dynamic_cast(o) 34 | 35 | class HimppVencChan : 36 | public HimppVideoElement, 37 | public H264VideoEncoder, 38 | public JPEGVideoEncoder, 39 | public H264VideoStreamSource, 40 | public JPEGVideoStreamSource 41 | { 42 | public: 43 | HimppVencChan(HimppVideoElement* source, VideoEncodingType encoding, VENC_CHN chnid); 44 | ~HimppVencChan(); 45 | 46 | // implementation of HimppElement 47 | MPP_CHN_S* bindSource(); 48 | // implementation of HimppVideoElement/VideoStreamSource 49 | Resolution resolution(); 50 | uint32_t framerate(); 51 | 52 | // implementation of VideoStreamSource 53 | VideoEncodingType encoding(); 54 | uint32_t bitrate(); 55 | void attach(StreamSink* sink); 56 | void detach(StreamSink* sink); 57 | void play(); 58 | void stop(); 59 | void resume(); 60 | void pause(); 61 | 62 | // implementation of VideoEncoder 63 | VideoEncodingType getEncoding(); 64 | Resolution getResolution(); 65 | void setResolution(Resolution value); 66 | uint32_t getFramerate(); 67 | void setFramerate(uint32_t value); 68 | void setRcMode(RateCtrlMode value); 69 | RateCtrlMode getRcMode(); 70 | void setBitrate(uint32_t value); 71 | uint32_t getBitrate(); 72 | 73 | // implentation of H264VideoEncoder 74 | void setH264Profile(H264Profile value); 75 | H264Profile getH264Profile(); 76 | void setGovLength(uint32_t value); 77 | uint32_t getGovLength(); 78 | void setMinQP(uint32_t value); 79 | uint32_t getMinQP(); 80 | void setMaxQP(uint32_t value); 81 | uint32_t getMaxQP(); 82 | void setFrameRefMode(FrameRefMode value); 83 | FrameRefMode getFrameRefMode(); 84 | void setIntraRefresh(IntraRefreshParam value); 85 | IntraRefreshParam getIntraRefresh(); 86 | 87 | void requestIDR(); 88 | 89 | VideoOSD* CreateOSD(); 90 | void DeleteOSD(VideoOSD*); 91 | 92 | // local functions 93 | VENC_CHN channelId() { return _chnid; } 94 | 95 | protected: 96 | // implementation of MediaElement 97 | void doEnableElement(); 98 | void doDisableElement(); 99 | 100 | private: 101 | MPP_CHN_S _mpp_chn; 102 | VENC_CHN _chnid; 103 | VideoEncodingType _encoding; 104 | H264Profile _h264profile; 105 | RateCtrlMode _rcmode; 106 | Resolution _resolution; 107 | uint32_t _framerate; 108 | uint32_t _bitrate; 109 | uint32_t _gop; 110 | uint32_t _min_qp; 111 | uint32_t _max_qp; 112 | FrameRefMode _refmode; 113 | IntraRefreshParam _intrarefresh; 114 | 115 | ev::io _io; 116 | 117 | std::set _osds; 118 | 119 | void watch_handler(ev::io& w, int revents); 120 | 121 | void prepareRcAttr(VENC_RC_ATTR_S &rcattr); 122 | void prepareChnAttr(VENC_CHN_ATTR_S &chnattr); 123 | }; 124 | 125 | #endif // _HIMPP_VIDEO_VENC_H_ 126 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-video-venc.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-venc.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VENC_H_ 21 | #define _HIMPP_VIDEO_VENC_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace Ipcam::Media; 30 | 31 | class HimppVencChan; 32 | 33 | #define HIMPP_VENC_CHAN(o) dynamic_cast(o) 34 | 35 | class HimppVencChan : 36 | public HimppVideoElement, 37 | public H264VideoEncoder, 38 | public JPEGVideoEncoder, 39 | public H264VideoStreamSource, 40 | public JPEGVideoStreamSource 41 | { 42 | public: 43 | HimppVencChan(HimppVideoElement* source, VideoEncodingType encoding, VENC_CHN chnid); 44 | ~HimppVencChan(); 45 | 46 | // implementation of HimppElement 47 | MPP_CHN_S* bindSource(); 48 | // implementation of HimppVideoElement/VideoStreamSource 49 | Resolution resolution(); 50 | uint32_t framerate(); 51 | 52 | // implementation of VideoStreamSource 53 | VideoEncodingType encoding(); 54 | uint32_t bitrate(); 55 | void attach(StreamSink* sink); 56 | void detach(StreamSink* sink); 57 | void play(); 58 | void stop(); 59 | void resume(); 60 | void pause(); 61 | 62 | // implementation of VideoEncoder 63 | VideoEncodingType getEncoding(); 64 | Resolution getResolution(); 65 | void setResolution(Resolution value); 66 | uint32_t getFramerate(); 67 | void setFramerate(uint32_t value); 68 | void setRcMode(RateCtrlMode value); 69 | RateCtrlMode getRcMode(); 70 | void setBitrate(uint32_t value); 71 | uint32_t getBitrate(); 72 | 73 | // implentation of H264VideoEncoder 74 | void setH264Profile(H264Profile value); 75 | H264Profile getH264Profile(); 76 | void setGovLength(uint32_t value); 77 | uint32_t getGovLength(); 78 | void setMinQP(uint32_t value); 79 | uint32_t getMinQP(); 80 | void setMaxQP(uint32_t value); 81 | uint32_t getMaxQP(); 82 | void setFrameRefMode(FrameRefMode value); 83 | FrameRefMode getFrameRefMode(); 84 | void setIntraRefresh(IntraRefreshParam value); 85 | IntraRefreshParam getIntraRefresh(); 86 | 87 | void requestIDR(); 88 | 89 | VideoOSD* CreateOSD(); 90 | void DeleteOSD(VideoOSD*); 91 | 92 | // local functions 93 | VENC_CHN channelId() { return _chnid; } 94 | 95 | protected: 96 | // implementation of MediaElement 97 | void doEnableElement(); 98 | void doDisableElement(); 99 | 100 | private: 101 | MPP_CHN_S _mpp_chn; 102 | VENC_CHN _chnid; 103 | VideoEncodingType _encoding; 104 | H264Profile _h264profile; 105 | RateCtrlMode _rcmode; 106 | Resolution _resolution; 107 | uint32_t _framerate; 108 | uint32_t _bitrate; 109 | uint32_t _gop; 110 | uint32_t _min_qp; 111 | uint32_t _max_qp; 112 | VENC_CROP_CFG_S _crop_cfg; 113 | FrameRefMode _refmode; 114 | IntraRefreshParam _intrarefresh; 115 | 116 | ev::io _io; 117 | 118 | std::set _osds; 119 | 120 | void watch_handler(ev::io& w, int revents); 121 | 122 | void prepareRcAttr(VENC_RC_ATTR_S &rcattr); 123 | void prepareChnAttr(VENC_CHN_ATTR_S &chnattr); 124 | }; 125 | 126 | #endif // _HIMPP_VIDEO_VENC_H_ 127 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-video-venc.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-venc.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VENC_H_ 21 | #define _HIMPP_VIDEO_VENC_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace Ipcam::Media; 30 | 31 | class HimppVencChan; 32 | 33 | #define HIMPP_VENC_CHAN(o) dynamic_cast(o) 34 | 35 | class HimppVencChan : 36 | public HimppVideoElement, 37 | public H264VideoEncoder, 38 | public JPEGVideoEncoder, 39 | public H264VideoStreamSource, 40 | public JPEGVideoStreamSource 41 | { 42 | public: 43 | HimppVencChan(HimppVideoElement* source, VideoEncodingType encoding, VENC_CHN chnid); 44 | ~HimppVencChan(); 45 | 46 | // implementation of HimppElement 47 | MPP_CHN_S* bindSource(); 48 | // implementation of HimppVideoElement/VideoStreamSource 49 | Resolution resolution(); 50 | uint32_t framerate(); 51 | 52 | // implementation of VideoStreamSource 53 | VideoEncodingType encoding(); 54 | uint32_t bitrate(); 55 | void attach(StreamSink* sink); 56 | void detach(StreamSink* sink); 57 | void play(); 58 | void stop(); 59 | void resume(); 60 | void pause(); 61 | 62 | // implementation of VideoEncoder 63 | VideoEncodingType getEncoding(); 64 | Resolution getResolution(); 65 | void setResolution(Resolution value); 66 | uint32_t getFramerate(); 67 | void setFramerate(uint32_t value); 68 | void setRcMode(RateCtrlMode value); 69 | RateCtrlMode getRcMode(); 70 | void setBitrate(uint32_t value); 71 | uint32_t getBitrate(); 72 | 73 | // implentation of H264VideoEncoder 74 | void setH264Profile(H264Profile value); 75 | H264Profile getH264Profile(); 76 | void setGovLength(uint32_t value); 77 | uint32_t getGovLength(); 78 | void setMinQP(uint32_t value); 79 | uint32_t getMinQP(); 80 | void setMaxQP(uint32_t value); 81 | uint32_t getMaxQP(); 82 | void setFrameRefMode(FrameRefMode value); 83 | FrameRefMode getFrameRefMode(); 84 | void setIntraRefresh(IntraRefreshParam value); 85 | IntraRefreshParam getIntraRefresh(); 86 | 87 | void requestIDR(); 88 | 89 | VideoOSD* CreateOSD(); 90 | void DeleteOSD(VideoOSD*); 91 | 92 | // local functions 93 | VENC_CHN channelId() { return _chnid; } 94 | 95 | protected: 96 | // implementation of MediaElement 97 | void doEnableElement(); 98 | void doDisableElement(); 99 | 100 | private: 101 | MPP_CHN_S _mpp_chn; 102 | VENC_CHN _chnid; 103 | VideoEncodingType _encoding; 104 | H264Profile _h264profile; 105 | RateCtrlMode _rcmode; 106 | Resolution _resolution; 107 | uint32_t _framerate; 108 | uint32_t _bitrate; 109 | uint32_t _gop; 110 | uint32_t _min_qp; 111 | uint32_t _max_qp; 112 | VENC_CROP_CFG_S _crop_cfg; 113 | FrameRefMode _refmode; 114 | IntraRefreshParam _intrarefresh; 115 | 116 | ev::io _io; 117 | 118 | std::set _osds; 119 | 120 | void watch_handler(ev::io& w, int revents); 121 | 122 | void prepareRcAttr(VENC_RC_ATTR_S &rcattr); 123 | void prepareChnAttr(VENC_CHN_ATTR_S &chnattr); 124 | }; 125 | 126 | #endif // _HIMPP_VIDEO_VENC_H_ 127 | -------------------------------------------------------------------------------- /src/common/video-osd.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * video-osd.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _VIDEO_OSD_H_ 21 | #define _VIDEO_OSD_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class _TTF_Font; 29 | typedef struct _TTF_Font TTF_Font; 30 | class SDL_Surface; 31 | 32 | namespace Ipcam { 33 | namespace Media { 34 | 35 | class VideoOSD; 36 | class SoftRenderVideoOSD; 37 | 38 | #define VIDEO_OSD(o) dynamic_cast(o) 39 | #define SOFT_RENDER_VIDEO_OSD(o) dynamic_cast(o) 40 | 41 | enum OSDType { TEXT_OSD, DATETIME_OSD, IMAGE_OSD }; 42 | 43 | class VideoOSD 44 | { 45 | public: 46 | virtual ~VideoOSD(); 47 | 48 | virtual OSDType getType(); 49 | virtual void setType(OSDType value); 50 | virtual bool getVisible(); 51 | virtual void setVisible(bool value); 52 | virtual Position getPosition(); 53 | virtual void setPosition(Position value); 54 | virtual Size getSize(); 55 | virtual void setSize(Size value); 56 | virtual uint32_t getForegroundColor(); 57 | virtual void setForegroundColor(uint32_t value); 58 | virtual uint32_t getBackgroundColor(); 59 | virtual void setBackgroundColor(uint32_t value); 60 | virtual uint32_t getForegroundAlpha(); 61 | virtual void setForegroundAlpha(uint32_t value); 62 | virtual uint32_t getBackgroundAlpha(); 63 | virtual void setBackgroundAlpha(uint32_t value); 64 | virtual bool getInvertColor(); 65 | virtual void setInvertColor(bool value); 66 | 67 | virtual std::string getText(); 68 | virtual void setText(std::string value); 69 | virtual std::string getFontName(); 70 | virtual void setFontName(std::string value); 71 | virtual uint32_t getFontSize(); 72 | virtual void setFontSize(uint32_t value); 73 | virtual uint32_t getFontColor(); 74 | virtual void setFontColor(uint32_t value); 75 | 76 | virtual std::string getImagePath(); 77 | virtual void setImagePath(std::string value); 78 | 79 | protected: 80 | VideoOSD(); 81 | }; 82 | 83 | class SoftRenderVideoOSD : virtual public MediaElement, public VideoOSD 84 | { 85 | public: 86 | SoftRenderVideoOSD(VideoElement* container); 87 | virtual ~SoftRenderVideoOSD(); 88 | 89 | virtual OSDType getType(); 90 | virtual void setType(OSDType value); 91 | virtual std::string getText(); 92 | virtual void setText(std::string value); 93 | virtual std::string getFontName(); 94 | virtual void setFontName(std::string value); 95 | virtual uint32_t getFontColor(); 96 | virtual void setFontColor(uint32_t value); 97 | virtual std::string getImagePath(); 98 | virtual void setImagePath(std::string value); 99 | 100 | virtual void updateDisplay(SDL_Surface* surface) = 0; 101 | 102 | MediaElement* container() { return _container; } 103 | 104 | private: 105 | MediaElement* _container; 106 | TTF_Font* _ttf_font; 107 | ev::timer _timer; 108 | OSDType _osd_type; 109 | std::string _text; 110 | std::string _font_name; 111 | uint32_t _font_color; 112 | std::string _image_path; 113 | 114 | std::string getPlainText(std::string text); 115 | void timeout_handler(ev::timer& w, int revents); 116 | void loadImage(std::string path); 117 | void renderText(std::string text); 118 | }; 119 | 120 | } // namespace Media 121 | } // namespace Ipcam 122 | 123 | #endif // _VIDEO_OSD_H_ 124 | 125 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-video-vpss.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-vpss-group.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VPSS_GROUP_H_ 21 | #define _HIMPP_VIDEO_VPSS_GROUP_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | class HimppVpssGroup; 32 | class HimppVpssChan; 33 | 34 | #define HIMPP_VPSS_GROUP(o) dynamic_cast(o) 35 | #define HIMPP_VPSS_CHAN(o) dynamic_cast(o) 36 | 37 | class HimppVpssGroup : public HimppVideoElement, public DefaultVideoSource 38 | { 39 | public: 40 | class Imaging : public DefaultVideoSource::Imaging 41 | { 42 | public: 43 | // NoiseReduction 44 | class NoiseReduction : public DefaultVideoSource::Imaging::NoiseReduction 45 | { 46 | public: 47 | NoiseReduction(Imaging& imaging); 48 | ~NoiseReduction(); 49 | // implemention of Ipcam::Media::VideoSource::Imaging::NoiseReduction 50 | VNRMode getMode(); 51 | void setMode(VNRMode value); 52 | uint32_t getLevel(); 53 | void setLevel(uint32_t value); 54 | NrParamTable& getParamTable(); 55 | void setParamTable(NrParamTable& value); 56 | private: 57 | VNRMode _mode; 58 | uint32_t _level; 59 | NrParamTable _param_table; 60 | }; 61 | 62 | public: 63 | Imaging(HimppVpssGroup& group); 64 | ~Imaging(); 65 | 66 | // implementation of VideoSource::Imaging 67 | VideoSource::Imaging::NoiseReduction& noisereduction(); 68 | 69 | private: 70 | NoiseReduction _noisereduction; 71 | }; 72 | public: 73 | HimppVpssGroup(HimppVideoElement* source, VPSS_GRP grpid); 74 | ~HimppVpssGroup(); 75 | 76 | // implementation of VideoSource 77 | VideoSource::Imaging& imaging(); 78 | 79 | VPSS_GRP groupId() { return _grpid; }; 80 | 81 | protected: 82 | void doEnableElement(); 83 | void doDisableElement(); 84 | 85 | private: 86 | void timeout_handler(ev::timer& w, int revents); 87 | void enableNR(bool enable); 88 | void enableAutoNR(bool enable); 89 | void setNRStrength(int32_t YSFStr, int32_t YTFStr); 90 | 91 | private: 92 | Imaging _imaging; 93 | VPSS_GRP _grpid; 94 | ev::timer _timer; 95 | HimppVideoISP* _isp; 96 | }; 97 | 98 | class HimppVpssChan : public HimppVideoElement, public DefaultVideoSource 99 | { 100 | public: 101 | HimppVpssChan(HimppVideoElement* source, VPSS_CHN chnid); 102 | ~HimppVpssChan(); 103 | 104 | // implementation of HimppVideoElement 105 | MPP_CHN_S* bindSource(); 106 | virtual Resolution resolution(); 107 | virtual uint32_t framerate(); 108 | 109 | // implementation of Ipcam::Media::VideoSource 110 | uint32_t getFrameRate(); 111 | void setFrameRate(uint32_t value); 112 | Resolution getResolution(); 113 | void setResolution(Resolution value); 114 | 115 | VPSS_GRP groupId() { return _grpid; } 116 | VPSS_CHN channelId() { return _chnid; } 117 | 118 | protected: 119 | void doEnableElement(); 120 | void doDisableElement(); 121 | 122 | private: 123 | enum VPSS_CHN_TYPE { 124 | VPSS_CHN_TYPE_PHY, 125 | VPSS_CHN_TYPE_BYPASS, 126 | VPSS_CHN_TYPE_EXT 127 | }; 128 | VPSS_GRP _grpid; 129 | VPSS_CHN _chnid; 130 | VPSS_CHN_TYPE _type; 131 | MPP_CHN_S _mpp_chn; 132 | Resolution _resolution; 133 | uint32_t _framerate; 134 | }; 135 | 136 | #endif // _HIMPP_VIDEO_VPSS_GROUP_H_ 137 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-video-vpss.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-vpss-group.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VPSS_GROUP_H_ 21 | #define _HIMPP_VIDEO_VPSS_GROUP_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | class HimppVpssGroup; 32 | class HimppVpssChan; 33 | 34 | #define HIMPP_VPSS_GROUP(o) dynamic_cast(o) 35 | #define HIMPP_VPSS_CHAN(o) dynamic_cast(o) 36 | 37 | class HimppVpssGroup : public HimppVideoElement, public DefaultVideoSource 38 | { 39 | public: 40 | class Imaging : public DefaultVideoSource::Imaging 41 | { 42 | public: 43 | // NoiseReduction 44 | class NoiseReduction : public DefaultVideoSource::Imaging::NoiseReduction 45 | { 46 | public: 47 | NoiseReduction(Imaging& imaging); 48 | ~NoiseReduction(); 49 | // implemention of Ipcam::Media::VideoSource::Imaging::NoiseReduction 50 | VNRMode getMode(); 51 | void setMode(VNRMode value); 52 | uint32_t getLevel(); 53 | void setLevel(uint32_t value); 54 | NrParamTable& getParamTable(); 55 | void setParamTable(NrParamTable& value); 56 | private: 57 | VNRMode _mode; 58 | uint32_t _level; 59 | NrParamTable _param_table; 60 | }; 61 | 62 | public: 63 | Imaging(HimppVpssGroup& group); 64 | ~Imaging(); 65 | 66 | // implementation of VideoSource::Imaging 67 | VideoSource::Imaging::NoiseReduction& noisereduction(); 68 | 69 | private: 70 | NoiseReduction _noisereduction; 71 | }; 72 | public: 73 | HimppVpssGroup(HimppVideoElement* source, VPSS_GRP grpid); 74 | ~HimppVpssGroup(); 75 | 76 | // implementation of VideoSource 77 | VideoSource::Imaging& imaging(); 78 | virtual uint32_t getFrameRate(); 79 | virtual void setFrameRate(uint32_t value); 80 | virtual Resolution getResolution(); 81 | virtual void setResolution(Resolution value); 82 | 83 | VPSS_GRP groupId() { return _grpid; }; 84 | 85 | protected: 86 | void doEnableElement(); 87 | void doDisableElement(); 88 | 89 | private: 90 | void timeout_handler(ev::timer& w, int revents); 91 | void enableNR(bool enable); 92 | void enableAutoNR(bool enable); 93 | void setNRStrength(int32_t YSFStr, int32_t YTFStr); 94 | 95 | private: 96 | Imaging _imaging; 97 | VPSS_GRP _grpid; 98 | Resolution _resolution; 99 | uint32_t _framerate; 100 | }; 101 | 102 | class HimppVpssChan : public HimppVideoElement, public DefaultVideoSource 103 | { 104 | public: 105 | HimppVpssChan(HimppVideoElement* source, VPSS_CHN chnid); 106 | ~HimppVpssChan(); 107 | 108 | // implementation of HimppVideoElement 109 | MPP_CHN_S* bindSource(); 110 | 111 | // implementation of Ipcam::Media::VideoSource 112 | uint32_t getFrameRate(); 113 | void setFrameRate(uint32_t value); 114 | Resolution getResolution(); 115 | void setResolution(Resolution value); 116 | 117 | VPSS_GRP groupId() { return _grpid; } 118 | VPSS_CHN channelId() { return _chnid; } 119 | 120 | protected: 121 | void doEnableElement(); 122 | void doDisableElement(); 123 | 124 | private: 125 | enum VPSS_CHN_TYPE { 126 | VPSS_CHN_TYPE_PHY, 127 | VPSS_CHN_TYPE_BYPASS, 128 | VPSS_CHN_TYPE_EXT 129 | }; 130 | VPSS_GRP _grpid; 131 | VPSS_CHN _chnid; 132 | VPSS_CHN_TYPE _type; 133 | MPP_CHN_S _mpp_chn; 134 | Resolution _resolution; 135 | uint32_t _framerate; 136 | }; 137 | 138 | #endif // _HIMPP_VIDEO_VPSS_GROUP_H_ 139 | -------------------------------------------------------------------------------- /src/platform/hi3516ev200/himpp-video-viu.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-viu.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VIU_H_ 21 | #define _HIMPP_VIDEO_VIU_H_ 22 | 23 | #include 24 | #include 25 | 26 | class HimppViDev; 27 | class HimppViChan; 28 | 29 | #define HIMPP_VI_DEV(o) dynamic_cast(o) 30 | #define HIMPP_VI_CHAN(o) dynamic_cast(o) 31 | 32 | class HimppViDev : public HimppVideoElement, public DefaultVideoSource 33 | { 34 | public: 35 | HimppViDev(HimppVideoElement* source, VI_DEV devid, std::string sensor); 36 | ~HimppViDev(); 37 | 38 | // implementation of HimppVideoElement 39 | //MPP_CHN_S* bindSource(); 40 | 41 | // implementation of VideoSource 42 | virtual uint32_t getFrameRate(); 43 | virtual void setFrameRate(uint32_t value); 44 | virtual Resolution getResolution(); 45 | virtual void setResolution(Resolution value); 46 | 47 | HimppVideoSensor* sensor() { return _video_sensor; } 48 | VI_DEV deviceId() { return _devid; } 49 | 50 | VI_VPSS_MODE_E getOnlineMode() const { return _online_mode; } 51 | void setOnlineMode(VI_VPSS_MODE_E mode) { _online_mode = mode; } 52 | 53 | const POINT_S& getCropOffset() const { return _crop_offset; } 54 | void setCropOffset(const POINT_S& offset) { _crop_offset = offset; } 55 | 56 | protected: 57 | void doEnableElement(); 58 | void doDisableElement(); 59 | 60 | private: 61 | bool initializeMipi(); 62 | void cleanupMipi(); 63 | 64 | private: 65 | HimppVideoSensor* _video_sensor; 66 | VI_DEV _devid; 67 | VI_VPSS_MODE_E _online_mode; 68 | Resolution _resolution; 69 | uint32_t _framerate; 70 | POINT_S _crop_offset; 71 | }; 72 | 73 | class HimppViChan : public HimppVideoElement, public DefaultVideoSource 74 | { 75 | public: 76 | class Imaging : public DefaultVideoSource::Imaging 77 | { 78 | public: 79 | class LDC : public DefaultVideoSource::Imaging::LDC 80 | { 81 | public: 82 | LDC(Imaging& imaging); 83 | ~LDC(); 84 | 85 | // implementation of VideoSource::Imaging::LDC 86 | LDCMode getMode(); 87 | void setMode(LDCMode value); 88 | int32_t getRatio(); 89 | void setRatio(int32_t value); 90 | public: 91 | LDCMode _ldc_mode; 92 | int32_t _ldc_ratio; 93 | }; 94 | public: 95 | Imaging(HimppViChan& vichan); 96 | ~Imaging(); 97 | 98 | // implementation of VideoSource::Imaging 99 | bool getMirror(); 100 | void setMirror(bool value); 101 | bool getFlip(); 102 | void setFlip(bool value); 103 | uint32_t getRotateAngle(); 104 | void setRotateAngle(uint32_t value); 105 | 106 | VideoSource::Imaging::LDC& ldc(); 107 | public: 108 | LDC _ldc; 109 | bool _mirror; 110 | bool _flip; 111 | ROTATION_E _rotate; 112 | }; 113 | 114 | public: 115 | HimppViChan(HimppVideoElement* source, VI_CHN chnid); 116 | ~HimppViChan(); 117 | 118 | // implementation of HimppVideoElement 119 | MPP_CHN_S* bindSource(); 120 | 121 | // implementation of VideoSource 122 | VideoSource::Imaging& imaging(); 123 | virtual uint32_t getFrameRate(); 124 | virtual void setFrameRate(uint32_t value); 125 | virtual Resolution getResolution(); 126 | virtual void setResolution(Resolution value); 127 | 128 | VI_CHN channelId() { return _chnid; } 129 | 130 | protected: 131 | void doEnableElement(); 132 | void doDisableElement(); 133 | 134 | private: 135 | Imaging _imaging; 136 | VI_CHN _chnid; 137 | MPP_CHN_S _mpp_chn; 138 | Resolution _resolution; 139 | uint32_t _framerate; 140 | }; 141 | 142 | #endif // _HIMPP_VIDEO_VIU_H_ 143 | -------------------------------------------------------------------------------- /src/common/media-stream.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * video-stream.h 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _MEDIA_STREAM_H_ 21 | #define _MEDIA_STREAM_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace Ipcam { 28 | namespace Media { 29 | 30 | enum VideoEncodingType { H265, H264, MJPEG, JPEG, MPEG4 }; 31 | enum AudioEncodingType { ADPCM, LPCM, G711A, G711U, G726, AAC }; 32 | 33 | class StreamBuffer; 34 | class H264StreamBuffer; 35 | class JPEGStreamBuffer; 36 | 37 | class StreamSource; 38 | class VideoStreamSource; 39 | class H264VideoStreamSource; 40 | class JPEGVideoStreamSource; 41 | class AudioStreamSource; 42 | class StreamSink; 43 | 44 | #define STREAM_SOURCE(o) dynamic_cast(o) 45 | #define VIDEO_STREAM_SOURCE(o) dynamic_cast(o) 46 | #define H264_VIDEO_STREAM_SOURCE(o) dynamic_cast(o) 47 | #define JPEG_VIDEO_STREAM_SOURCE(o) dynamic_cast(o) 48 | #define AUDIO_STREAM_SOURCE(o) dynamic_cast(o) 49 | 50 | #define STREAM_SINK(o) dynamic_cast(o) 51 | #define AUDIO_STREAM_SINK(o) dynamic_cast(o) 52 | 53 | struct StreamBuffer 54 | { 55 | struct timeval tstamp; 56 | uint32_t pack_count; 57 | struct Pack { 58 | uint8_t* addr; 59 | uint32_t len; 60 | } *pack; 61 | }; 62 | 63 | struct H264StreamBuffer : public StreamBuffer 64 | { 65 | bool keyframe; 66 | }; 67 | 68 | struct JPEGStreamBuffer : public StreamBuffer 69 | { 70 | uint8_t qfactor; 71 | uint8_t width; 72 | uint8_t height; 73 | }; 74 | 75 | class StreamSource 76 | { 77 | public: 78 | virtual ~StreamSource(); 79 | 80 | virtual void attach(StreamSink* sink); 81 | virtual void detach(StreamSink* sink); 82 | 83 | virtual void play() = 0; 84 | virtual void stop() = 0; 85 | virtual void pause() = 0; 86 | virtual void resume() = 0; 87 | 88 | protected: 89 | void streamData(StreamBuffer* buffer); 90 | 91 | private: 92 | typedef std::set StreamSinkSet; 93 | StreamSinkSet _sinks; 94 | }; 95 | 96 | class StreamSink 97 | { 98 | public: 99 | virtual void streamData(StreamBuffer* buffer) = 0; 100 | virtual void play(); 101 | virtual void stop(); 102 | virtual void pause(); 103 | virtual void resume(); 104 | }; 105 | 106 | class VideoStreamSource : public StreamSource 107 | { 108 | public: 109 | virtual ~VideoStreamSource(); 110 | 111 | virtual VideoEncodingType encoding() = 0; 112 | virtual uint32_t bitrate() = 0; 113 | virtual Resolution resolution() = 0; 114 | virtual uint32_t framerate() = 0; 115 | }; 116 | 117 | class H264VideoStreamSource : virtual public VideoStreamSource 118 | { 119 | public: 120 | virtual ~H264VideoStreamSource(); 121 | 122 | virtual void requestIDR() = 0; 123 | }; 124 | 125 | class JPEGVideoStreamSource : virtual public VideoStreamSource 126 | { 127 | public: 128 | virtual ~JPEGVideoStreamSource(); 129 | }; 130 | 131 | class AudioStreamSource : public StreamSource 132 | { 133 | public: 134 | virtual ~AudioStreamSource(); 135 | 136 | virtual AudioEncodingType encoding() = 0; 137 | virtual uint32_t bitrate() = 0; 138 | virtual uint32_t channels() = 0; 139 | virtual uint32_t samplerate() = 0; 140 | }; 141 | 142 | class AudioStreamSink : public StreamSink 143 | { 144 | public: 145 | virtual AudioEncodingType encoding() = 0; 146 | virtual uint32_t bitrate() = 0; 147 | virtual uint32_t channels() = 0; 148 | virtual uint32_t samplerate() = 0; 149 | }; 150 | 151 | } //namespace Media 152 | } //namespace Ipcam 153 | 154 | #endif // _MEDIA_STREAM_H_ 155 | 156 | -------------------------------------------------------------------------------- /src/rtsp-server/LiveStreamOutput.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * LiveStreamOutput.cpp 4 | * Copyright (C) 2019 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "LiveStreamOutput.hh" 26 | 27 | 28 | #define AUDIO_BUFFER_SIZE 2048 29 | 30 | class LiveAudioSink : public MediaSink { 31 | public: 32 | static LiveAudioSink* createNew(UsageEnvironment& env, StreamSink& sink); 33 | virtual ~LiveAudioSink(); 34 | 35 | protected: 36 | LiveAudioSink(UsageEnvironment& env, StreamSink &sink); 37 | 38 | Boolean continuePlaying(); 39 | static void afterGettingFrame(void* clientData, unsigned frameSize, 40 | unsigned numTruncatedBytes, 41 | struct timeval presentationTime, 42 | unsigned durationInMicroseconds); 43 | void afterGettingFrame(unsigned frameSize, 44 | unsigned numTruncatedBytes, 45 | struct timeval presentationTime); 46 | 47 | protected: 48 | StreamSink &fStreamSink; 49 | u_int8_t* fReceiveBuffer; 50 | }; 51 | 52 | LiveAudioSink* LiveAudioSink::createNew(UsageEnvironment& env, StreamSink& sink) 53 | { 54 | return new LiveAudioSink(env, sink); 55 | } 56 | 57 | LiveAudioSink::LiveAudioSink(UsageEnvironment& env, StreamSink& sink) 58 | : MediaSink(env), fStreamSink(sink) 59 | { 60 | fReceiveBuffer = new u_int8_t[AUDIO_BUFFER_SIZE]; 61 | } 62 | 63 | LiveAudioSink::~LiveAudioSink() 64 | { 65 | delete [] fReceiveBuffer; 66 | } 67 | 68 | Boolean LiveAudioSink::continuePlaying() 69 | { 70 | if (fSource == NULL) return False; 71 | 72 | fSource->getNextFrame(fReceiveBuffer, AUDIO_BUFFER_SIZE, 73 | afterGettingFrame, this, 74 | onSourceClosure, this); 75 | 76 | return True; 77 | } 78 | 79 | void LiveAudioSink::afterGettingFrame(void* clientData, unsigned frameSize, 80 | unsigned numTruncatedBytes, 81 | struct timeval presentationTime, 82 | unsigned /*durationInMicroseconds*/) 83 | { 84 | LiveAudioSink* sink = (LiveAudioSink*)clientData; 85 | sink->afterGettingFrame(frameSize, numTruncatedBytes, presentationTime); 86 | } 87 | 88 | void LiveAudioSink::afterGettingFrame(unsigned frameSize, 89 | unsigned numTruncatedBytes, 90 | struct timeval presentationTime) 91 | { 92 | StreamBuffer::Pack pack = { 93 | .addr = fReceiveBuffer, 94 | .len = frameSize 95 | }; 96 | StreamBuffer buffer = { 97 | .tstamp = {0}, 98 | .pack_count = 1, 99 | .pack = &pack, 100 | }; 101 | 102 | fStreamSink.streamData(&buffer); 103 | 104 | continuePlaying(); 105 | } 106 | 107 | void afterPlaying(void* /*clientData*/) 108 | { 109 | } 110 | 111 | AudioOutputStream::AudioOutputStream 112 | (UsageEnvironment& env, AudioStreamSink& sink, struct in_addr &addr, portNumBits num) 113 | : streamSink(sink), streamStarted(false), 114 | rtpGroupsock(env, addr, Port(num), 0) 115 | { 116 | rtpSink = LiveAudioSink::createNew(env, streamSink); 117 | 118 | rtpSource = SimpleRTPSource::createNew(env, &rtpGroupsock, 96, 119 | streamSink.samplerate(), 120 | "audio/PCMA", 0, False); 121 | 122 | rtpSink->startPlaying(*rtpSource, afterPlaying, this); 123 | } 124 | 125 | AudioOutputStream::~AudioOutputStream() 126 | { 127 | stop(); 128 | 129 | if (rtpSink) Medium::close(rtpSink); 130 | if (rtpSource) Medium::close(rtpSource); 131 | } 132 | 133 | void AudioOutputStream::play() 134 | { 135 | if (!streamStarted) { 136 | streamSink.play(); 137 | streamStarted = true; 138 | } 139 | } 140 | 141 | void AudioOutputStream::stop() 142 | { 143 | if (streamStarted) { 144 | streamSink.stop(); 145 | streamStarted = false; 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/common/video-encoder.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * video-encoder.cpp 4 | * Copyright (C) 2017 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #include "video-encoder.h" 21 | 22 | namespace Ipcam { 23 | namespace Media { 24 | 25 | ////////////////////////////////////////////////////////////////////////////// 26 | // VideoEncoder 27 | ////////////////////////////////////////////////////////////////////////////// 28 | 29 | VideoEncoder::VideoEncoder() 30 | { 31 | } 32 | 33 | VideoEncoder::~VideoEncoder() 34 | { 35 | } 36 | 37 | VideoEncodingType VideoEncoder::getEncoding() 38 | { 39 | throw IpcamError(property_not_implemented); 40 | } 41 | 42 | Resolution VideoEncoder::getResolution() 43 | { 44 | throw IpcamError(property_not_implemented); 45 | } 46 | 47 | void VideoEncoder::setResolution(Resolution value) 48 | { 49 | throw IpcamError(property_not_implemented); 50 | } 51 | 52 | RateCtrlMode VideoEncoder::getRcMode() 53 | { 54 | throw IpcamError(property_not_implemented); 55 | } 56 | 57 | void VideoEncoder::setRcMode(RateCtrlMode value) 58 | { 59 | throw IpcamError(property_not_implemented); 60 | } 61 | 62 | uint32_t VideoEncoder::getFramerate() 63 | { 64 | throw IpcamError(property_not_implemented); 65 | } 66 | 67 | void VideoEncoder::setFramerate(uint32_t value) 68 | { 69 | throw IpcamError(property_not_implemented); 70 | } 71 | 72 | uint32_t VideoEncoder::getBitrate() 73 | { 74 | throw IpcamError(property_not_implemented); 75 | } 76 | 77 | void VideoEncoder::setBitrate(uint32_t value) 78 | { 79 | throw IpcamError(property_not_implemented); 80 | } 81 | 82 | VideoOSD* VideoEncoder::CreateOSD() 83 | { 84 | throw IpcamError(property_not_implemented); 85 | } 86 | 87 | void VideoEncoder::DeleteOSD(VideoOSD* osd) 88 | { 89 | throw IpcamError(property_not_implemented); 90 | } 91 | 92 | ////////////////////////////////////////////////////////////////////////////// 93 | // H264VideoEncoder 94 | ////////////////////////////////////////////////////////////////////////////// 95 | 96 | H264VideoEncoder::H264VideoEncoder() 97 | { 98 | } 99 | 100 | H264VideoEncoder::~H264VideoEncoder() 101 | { 102 | } 103 | 104 | H264Profile H264VideoEncoder::getH264Profile() 105 | { 106 | throw IpcamError(property_not_implemented); 107 | } 108 | 109 | void H264VideoEncoder::setH264Profile(H264Profile value) 110 | { 111 | throw IpcamError(property_not_implemented); 112 | } 113 | 114 | uint32_t H264VideoEncoder::getGovLength() 115 | { 116 | throw IpcamError(property_not_implemented); 117 | } 118 | 119 | void H264VideoEncoder::setGovLength(uint32_t value) 120 | { 121 | throw IpcamError(property_not_implemented); 122 | } 123 | 124 | void H264VideoEncoder::setMinQP(uint32_t value) 125 | { 126 | throw IpcamError(property_not_implemented); 127 | } 128 | 129 | uint32_t H264VideoEncoder::getMinQP() 130 | { 131 | throw IpcamError(property_not_implemented); 132 | } 133 | 134 | void H264VideoEncoder::setMaxQP(uint32_t value) 135 | { 136 | throw IpcamError(property_not_implemented); 137 | } 138 | 139 | uint32_t H264VideoEncoder::getMaxQP() 140 | { 141 | throw IpcamError(property_not_implemented); 142 | } 143 | 144 | void H264VideoEncoder::setFrameRefMode(FrameRefMode value) 145 | { 146 | throw IpcamError(property_not_implemented); 147 | } 148 | 149 | H264VideoEncoder::FrameRefMode H264VideoEncoder::getFrameRefMode() 150 | { 151 | throw IpcamError(property_not_implemented); 152 | } 153 | 154 | void H264VideoEncoder::setIntraRefresh(IntraRefreshParam value) 155 | { 156 | throw IpcamError(property_not_implemented); 157 | } 158 | 159 | H264VideoEncoder::IntraRefreshParam H264VideoEncoder::getIntraRefresh() 160 | { 161 | throw IpcamError(property_not_implemented); 162 | } 163 | 164 | ////////////////////////////////////////////////////////////////////////////// 165 | // JPEGVideoEncoder 166 | ////////////////////////////////////////////////////////////////////////////// 167 | 168 | JPEGVideoEncoder::JPEGVideoEncoder() 169 | { 170 | } 171 | 172 | JPEGVideoEncoder::~JPEGVideoEncoder() 173 | { 174 | } 175 | 176 | } // namespace Media 177 | } // namespace Ipcam 178 | -------------------------------------------------------------------------------- /m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-video-vpss.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-vpss-group.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VPSS_GROUP_H_ 21 | #define _HIMPP_VIDEO_VPSS_GROUP_H_ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | class HimppVpssGroup; 32 | class HimppVpssChan; 33 | 34 | #define HIMPP_VPSS_GROUP(o) dynamic_cast(o) 35 | #define HIMPP_VPSS_CHAN(o) dynamic_cast(o) 36 | 37 | class HimppVpssGroup : public HimppVideoElement, public DefaultVideoSource 38 | { 39 | public: 40 | class Imaging : public DefaultVideoSource::Imaging 41 | { 42 | public: 43 | // NoiseReduction 44 | class NoiseReduction : public DefaultVideoSource::Imaging::NoiseReduction 45 | { 46 | public: 47 | NoiseReduction(Imaging& imaging); 48 | ~NoiseReduction(); 49 | // implemention of Ipcam::Media::VideoSource::Imaging::NoiseReduction 50 | VNRMode getMode(); 51 | void setMode(VNRMode value); 52 | uint32_t getLevel(); 53 | void setLevel(uint32_t value); 54 | NrParamTable& getParamTable(); 55 | void setParamTable(NrParamTable& value); 56 | private: 57 | VNRMode _mode; 58 | uint32_t _level; 59 | NrParamTable _param_table; 60 | }; 61 | 62 | public: 63 | Imaging(HimppVpssGroup& group); 64 | ~Imaging(); 65 | 66 | // implementation of VideoSource::Imaging 67 | VideoSource::Imaging::NoiseReduction& noisereduction(); 68 | 69 | private: 70 | NoiseReduction _noisereduction; 71 | }; 72 | public: 73 | HimppVpssGroup(HimppVideoElement* source, VPSS_GRP grpid); 74 | ~HimppVpssGroup(); 75 | 76 | // implementation of VideoSource 77 | VideoSource::Imaging& imaging(); 78 | 79 | VPSS_GRP groupId() { return _grpid; }; 80 | 81 | protected: 82 | void doEnableElement(); 83 | void doDisableElement(); 84 | 85 | private: 86 | void timeout_handler(ev::timer& w, int revents); 87 | void enableNR(bool enable); 88 | void enableAutoNR(bool enable); 89 | void setNRStrength(int32_t YSFStr, int32_t YTFStr); 90 | 91 | private: 92 | Imaging _imaging; 93 | VPSS_GRP _grpid; 94 | ev::timer _timer; 95 | HimppVideoISP* _isp; 96 | }; 97 | 98 | class HimppVpssChan : public HimppVideoElement, public DefaultVideoSource 99 | { 100 | public: 101 | class Imaging : public DefaultVideoSource::Imaging 102 | { 103 | public: 104 | class LDC : public DefaultVideoSource::Imaging::LDC 105 | { 106 | public: 107 | LDC(Imaging& imaging); 108 | ~LDC(); 109 | 110 | // implementation of VideoSource::Imaging::LDC 111 | LDCMode getMode(); 112 | void setMode(LDCMode value); 113 | int32_t getRatio(); 114 | void setRatio(int32_t value); 115 | public: 116 | LDCMode _ldc_mode; 117 | int32_t _ldc_ratio; 118 | }; 119 | public: 120 | Imaging(HimppVpssChan& vpchan); 121 | ~Imaging(); 122 | 123 | // implementation of VideoSource::Imaging 124 | bool getMirror(); 125 | void setMirror(bool value); 126 | bool getFlip(); 127 | void setFlip(bool value); 128 | VideoSource::Imaging::LDC& ldc(); 129 | public: 130 | LDC _ldc; 131 | bool _mirror; 132 | bool _flip; 133 | }; 134 | public: 135 | HimppVpssChan(HimppVideoElement* source, VPSS_CHN chnid); 136 | ~HimppVpssChan(); 137 | 138 | // implementation of HimppVideoElement 139 | MPP_CHN_S* bindSource(); 140 | virtual Resolution resolution(); 141 | virtual uint32_t framerate(); 142 | 143 | // implementation of Ipcam::Media::VideoSource 144 | VideoSource::Imaging& imaging(); 145 | uint32_t getFrameRate(); 146 | void setFrameRate(uint32_t value); 147 | Resolution getResolution(); 148 | void setResolution(Resolution value); 149 | 150 | VPSS_GRP groupId() { return _grpid; } 151 | VPSS_CHN channelId() { return _chnid; } 152 | 153 | protected: 154 | void doEnableElement(); 155 | void doDisableElement(); 156 | 157 | private: 158 | enum VPSS_CHN_TYPE { 159 | VPSS_CHN_TYPE_PHY, 160 | VPSS_CHN_TYPE_BYPASS, 161 | VPSS_CHN_TYPE_EXT 162 | }; 163 | Imaging _imaging; 164 | VPSS_GRP _grpid; 165 | VPSS_CHN _chnid; 166 | VPSS_CHN_TYPE _type; 167 | MPP_CHN_S _mpp_chn; 168 | Resolution _resolution; 169 | uint32_t _framerate; 170 | }; 171 | 172 | #endif // _HIMPP_VIDEO_VPSS_GROUP_H_ 173 | -------------------------------------------------------------------------------- /src/platform/hi3516cv300/himpp-video-viu.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-viu.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VIU_H_ 21 | #define _HIMPP_VIDEO_VIU_H_ 22 | 23 | #include 24 | #include 25 | 26 | class HimppViDev; 27 | class HimppViChan; 28 | 29 | #define HIMPP_VI_DEV(o) dynamic_cast(o) 30 | #define HIMPP_VI_CHAN(o) dynamic_cast(o) 31 | 32 | class HimppViDev : public HimppVideoElement, public DefaultVideoSource 33 | { 34 | public: 35 | class Imaging : public DefaultVideoSource::Imaging 36 | { 37 | public: 38 | class IrCutFilter : public DefaultVideoSource::Imaging::IrCutFilter 39 | { 40 | public: 41 | IrCutFilter(Imaging& imaging); 42 | virtual ~IrCutFilter(); 43 | 44 | IrCutFilterMode getMode(); 45 | void setMode(IrCutFilterMode value); 46 | public: 47 | IrCutFilterMode _mode; 48 | }; 49 | public: 50 | Imaging(HimppViDev& videv); 51 | ~Imaging(); 52 | 53 | // implementation of VideoSource::Imaging 54 | uint32_t getBrightness(); 55 | void setBrightness(uint32_t value); 56 | uint32_t getContrast(); 57 | void setContrast(uint32_t value); 58 | uint32_t getChroma(); 59 | void setChroma(uint32_t value); 60 | uint32_t getSaturation(); 61 | void setSaturation(uint32_t value); 62 | 63 | VideoSource::Imaging::IrCutFilter& ircutfilter(); 64 | public: 65 | uint32_t _brightness; 66 | uint32_t _contrast; 67 | uint32_t _chroma; 68 | uint32_t _saturation; 69 | IrCutFilter _ircutfilter; 70 | }; 71 | 72 | public: 73 | HimppViDev(HimppVideoElement* source, VI_DEV devid); 74 | ~HimppViDev(); 75 | 76 | // implementation of HimppVideoElement 77 | //MPP_CHN_S* bindSource(); 78 | virtual Resolution resolution(); 79 | virtual uint32_t framerate(); 80 | 81 | // implementation of VideoSource 82 | virtual uint32_t getFrameRate(); 83 | virtual void setFrameRate(uint32_t value); 84 | virtual Resolution getResolution(); 85 | virtual void setResolution(Resolution value); 86 | VideoSource::Imaging& imaging(); 87 | 88 | virtual void setCropOffset(int32_t x, int32_t y); 89 | 90 | VI_DEV deviceId() { return _devid; } 91 | 92 | protected: 93 | void doEnableElement(); 94 | void doDisableElement(); 95 | 96 | private: 97 | Imaging _imaging; 98 | VI_DEV _devid; 99 | Resolution _resolution; 100 | uint32_t _framerate; 101 | int32_t _xoffset; 102 | int32_t _yoffset; 103 | }; 104 | 105 | class HimppViChan : public HimppVideoElement, public DefaultVideoSource 106 | { 107 | public: 108 | class Imaging : public DefaultVideoSource::Imaging 109 | { 110 | public: 111 | class LDC : public DefaultVideoSource::Imaging::LDC 112 | { 113 | public: 114 | LDC(Imaging& imaging); 115 | ~LDC(); 116 | 117 | // implementation of VideoSource::Imaging::LDC 118 | LDCMode getMode(); 119 | void setMode(LDCMode value); 120 | int32_t getRatio(); 121 | void setRatio(int32_t value); 122 | public: 123 | LDCMode _ldc_mode; 124 | int32_t _ldc_ratio; 125 | }; 126 | public: 127 | Imaging(HimppViChan& vichan); 128 | ~Imaging(); 129 | 130 | // implementation of VideoSource::Imaging 131 | bool getMirror(); 132 | void setMirror(bool value); 133 | bool getFlip(); 134 | void setFlip(bool value); 135 | uint32_t getRotateAngle(); 136 | void setRotateAngle(uint32_t value); 137 | 138 | VideoSource::Imaging::LDC& ldc(); 139 | public: 140 | LDC _ldc; 141 | bool _mirror; 142 | bool _flip; 143 | ROTATE_E _rotate; 144 | }; 145 | 146 | public: 147 | HimppViChan(HimppVideoElement* source, VI_CHN chnid); 148 | ~HimppViChan(); 149 | 150 | // implementation of HimppVideoElement 151 | MPP_CHN_S* bindSource(); 152 | virtual Resolution resolution(); 153 | virtual uint32_t framerate(); 154 | 155 | // implementation of VideoSource 156 | VideoSource::Imaging& imaging(); 157 | virtual uint32_t getFrameRate(); 158 | virtual void setFrameRate(uint32_t value); 159 | virtual Resolution getResolution(); 160 | virtual void setResolution(Resolution value); 161 | 162 | VI_CHN channelId() { return _chnid; } 163 | 164 | protected: 165 | void doEnableElement(); 166 | void doDisableElement(); 167 | 168 | private: 169 | Imaging _imaging; 170 | VI_CHN _chnid; 171 | MPP_CHN_S _mpp_chn; 172 | Resolution _resolution; 173 | uint32_t _framerate; 174 | }; 175 | 176 | #endif // _HIMPP_VIDEO_VIU_H_ 177 | -------------------------------------------------------------------------------- /src/platform/hi3518v200/himpp-video-viu.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * himpp-video-viu.h 4 | * Copyright (C) 2015 Watson Xu 5 | * 6 | * live-streamer is free software: you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * live-streamer is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | * See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program. If not, see . 18 | */ 19 | 20 | #ifndef _HIMPP_VIDEO_VIU_H_ 21 | #define _HIMPP_VIDEO_VIU_H_ 22 | 23 | #include 24 | #include 25 | 26 | class HimppViDev; 27 | class HimppViChan; 28 | 29 | #define HIMPP_VI_DEV(o) dynamic_cast(o) 30 | #define HIMPP_VI_CHAN(o) dynamic_cast(o) 31 | 32 | class HimppViDev : public HimppVideoElement, public DefaultVideoSource 33 | { 34 | public: 35 | class Imaging : public DefaultVideoSource::Imaging 36 | { 37 | public: 38 | class IrCutFilter : public DefaultVideoSource::Imaging::IrCutFilter 39 | { 40 | public: 41 | IrCutFilter(Imaging& imaging); 42 | virtual ~IrCutFilter(); 43 | 44 | IrCutFilterMode getMode(); 45 | void setMode(IrCutFilterMode value); 46 | public: 47 | IrCutFilterMode _mode; 48 | }; 49 | public: 50 | Imaging(HimppViDev& videv); 51 | ~Imaging(); 52 | 53 | // implementation of VideoSource::Imaging 54 | uint32_t getBrightness(); 55 | void setBrightness(uint32_t value); 56 | uint32_t getContrast(); 57 | void setContrast(uint32_t value); 58 | uint32_t getChroma(); 59 | void setChroma(uint32_t value); 60 | uint32_t getSaturation(); 61 | void setSaturation(uint32_t value); 62 | 63 | VideoSource::Imaging::IrCutFilter& ircutfilter(); 64 | public: 65 | uint32_t _brightness; 66 | uint32_t _contrast; 67 | uint32_t _chroma; 68 | uint32_t _saturation; 69 | IrCutFilter _ircutfilter; 70 | }; 71 | 72 | public: 73 | HimppViDev(HimppVideoElement* source, VI_DEV devid); 74 | ~HimppViDev(); 75 | 76 | // implementation of HimppVideoElement 77 | //MPP_CHN_S* bindSource(); 78 | virtual Resolution resolution(); 79 | virtual uint32_t framerate(); 80 | 81 | // implementation of VideoSource 82 | virtual uint32_t getFrameRate(); 83 | virtual void setFrameRate(uint32_t value); 84 | virtual Resolution getResolution(); 85 | virtual void setResolution(Resolution value); 86 | VideoSource::Imaging& imaging(); 87 | 88 | virtual void setCropOffset(int32_t x, int32_t y); 89 | 90 | VI_DEV deviceId() { return _devid; } 91 | 92 | protected: 93 | void doEnableElement(); 94 | void doDisableElement(); 95 | 96 | private: 97 | Imaging _imaging; 98 | VI_DEV _devid; 99 | Resolution _resolution; 100 | uint32_t _framerate; 101 | int32_t _xoffset; 102 | int32_t _yoffset; 103 | }; 104 | 105 | class HimppViChan : public HimppVideoElement, public DefaultVideoSource 106 | { 107 | public: 108 | class Imaging : public DefaultVideoSource::Imaging 109 | { 110 | public: 111 | class LDC : public DefaultVideoSource::Imaging::LDC 112 | { 113 | public: 114 | LDC(Imaging& imaging); 115 | ~LDC(); 116 | 117 | // implementation of VideoSource::Imaging::LDC 118 | LDCMode getMode(); 119 | void setMode(LDCMode value); 120 | int32_t getRatio(); 121 | void setRatio(int32_t value); 122 | public: 123 | LDCMode _ldc_mode; 124 | int32_t _ldc_ratio; 125 | }; 126 | public: 127 | Imaging(HimppViChan& vichan); 128 | ~Imaging(); 129 | 130 | // implementation of VideoSource::Imaging 131 | bool getMirror(); 132 | void setMirror(bool value); 133 | bool getFlip(); 134 | void setFlip(bool value); 135 | uint32_t getRotateAngle(); 136 | void setRotateAngle(uint32_t value); 137 | 138 | VideoSource::Imaging::LDC& ldc(); 139 | public: 140 | LDC _ldc; 141 | bool _mirror; 142 | bool _flip; 143 | ROTATE_E _rotate; 144 | }; 145 | 146 | public: 147 | HimppViChan(HimppVideoElement* source, VI_CHN chnid); 148 | ~HimppViChan(); 149 | 150 | // implementation of HimppVideoElement 151 | MPP_CHN_S* bindSource(); 152 | virtual Resolution resolution(); 153 | virtual uint32_t framerate(); 154 | 155 | // implementation of VideoSource 156 | VideoSource::Imaging& imaging(); 157 | virtual uint32_t getFrameRate(); 158 | virtual void setFrameRate(uint32_t value); 159 | virtual Resolution getResolution(); 160 | virtual void setResolution(Resolution value); 161 | 162 | VI_CHN channelId() { return _chnid; } 163 | 164 | protected: 165 | void doEnableElement(); 166 | void doDisableElement(); 167 | 168 | private: 169 | Imaging _imaging; 170 | VI_CHN _chnid; 171 | MPP_CHN_S _mpp_chn; 172 | Resolution _resolution; 173 | uint32_t _framerate; 174 | }; 175 | 176 | #endif // _HIMPP_VIDEO_VIU_H_ 177 | -------------------------------------------------------------------------------- /src/dbus/dbusxx-libev-integration.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 | /* 3 | * 4 | * D-Bus++ - C++ bindings for D-Bus 5 | * 6 | * Copyright (C) 2015 Watson Xu 7 | * 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | * 23 | */ 24 | 25 | #ifdef HAVE_CONFIG_H 26 | #include 27 | #endif 28 | #include "dbusxx-libev-integration.h" 29 | 30 | #include // for DBUS_WATCH_* 31 | 32 | using namespace DBus; 33 | 34 | Ev::BusTimeout::BusTimeout(Timeout::Internal *ti, ev::loop_ref &loop, int priority) 35 | : Timeout(ti), _loop(loop), _priority(priority), _timer(loop) 36 | { 37 | if (Timeout::enabled()) 38 | _enable(); 39 | } 40 | 41 | Ev::BusTimeout::~BusTimeout() 42 | { 43 | _disable(); 44 | } 45 | 46 | void Ev::BusTimeout::toggle() 47 | { 48 | debug_log("ev: timeout %p toggled (%s)", this, Timeout::enabled() ? "on" : "off"); 49 | 50 | if (Timeout::enabled()) 51 | _enable(); 52 | else 53 | _disable(); 54 | } 55 | 56 | void Ev::BusTimeout::timeout_handler(ev::timer &w, int revents) 57 | { 58 | handle(); 59 | } 60 | 61 | void Ev::BusTimeout::_enable() 62 | { 63 | if (_timer.is_active()) 64 | _disable(); // be sane 65 | 66 | ev_set_priority(static_cast(&_timer), _priority); 67 | _timer.set(Timeout::interval() / 1000.0, 0.0); 68 | _timer.set(this); 69 | _timer.start(); 70 | } 71 | 72 | void Ev::BusTimeout::_disable() 73 | { 74 | if (_timer.is_active()) 75 | { 76 | _timer.stop(); 77 | } 78 | } 79 | 80 | Ev::BusWatch::BusWatch(Watch::Internal *wi, ev::loop_ref &loop, int priority) 81 | : Watch(wi), _loop(loop), _priority(priority), _io(loop) 82 | { 83 | if (Watch::enabled()) 84 | _enable(); 85 | } 86 | 87 | Ev::BusWatch::~BusWatch() 88 | { 89 | _disable(); 90 | } 91 | 92 | void Ev::BusWatch::toggle() 93 | { 94 | debug_log("ev: watch %p toggled (%s)", this, Watch::enabled() ? "on" : "off"); 95 | 96 | if (Watch::enabled()) 97 | _enable(); 98 | else 99 | _disable(); 100 | } 101 | 102 | void Ev::BusWatch::watch_handler(ev::io &w, int revents) 103 | { 104 | int flags = 0; 105 | if (revents & ev::READ) 106 | flags |= DBUS_WATCH_READABLE; 107 | if (revents & ev::WRITE) 108 | flags |= DBUS_WATCH_WRITABLE; 109 | if (revents & ev::ERROR) 110 | flags |= DBUS_WATCH_ERROR; 111 | 112 | handle(flags); 113 | } 114 | 115 | void Ev::BusWatch::_enable() 116 | { 117 | if (_io.is_active()) 118 | _disable(); // be sane 119 | ev_set_priority(static_cast(&_io), _priority); 120 | _io.set(this); 121 | 122 | int flags = Watch::flags(); 123 | int condition = 0; 124 | 125 | if (flags & DBUS_WATCH_READABLE) 126 | condition |= ev::READ; 127 | if (flags & DBUS_WATCH_WRITABLE) 128 | condition |= ev::WRITE; 129 | if (flags & DBUS_WATCH_ERROR) 130 | condition |= ev::ERROR; 131 | if (flags & DBUS_WATCH_HANGUP) 132 | condition |= ev::ERROR; 133 | 134 | _io.set(Watch::descriptor(), condition); 135 | _io.start(); 136 | } 137 | 138 | void Ev::BusWatch::_disable() 139 | { 140 | if (!_io.is_active()) 141 | return; 142 | 143 | _io.stop(); 144 | } 145 | 146 | 147 | Ev::BusDispatcher::BusDispatcher() 148 | : _loop(NULL), _priority(0) 149 | { 150 | } 151 | 152 | Ev::BusDispatcher::~BusDispatcher() 153 | { 154 | if (_prepare.is_active()) 155 | _prepare.stop(); 156 | if (_check.is_active()) 157 | _check.stop(); 158 | } 159 | 160 | void Ev::BusDispatcher::prepare_handler(ev::prepare &w, int revents) 161 | { 162 | if (has_something_to_dispatch()) 163 | dispatch_pending(); 164 | } 165 | 166 | void Ev::BusDispatcher::check_handler(ev::check &w, int revents) 167 | { 168 | if (has_something_to_dispatch()) 169 | dispatch_pending(); 170 | } 171 | 172 | void Ev::BusDispatcher::attach(ev::loop_ref *loop) 173 | { 174 | _loop = loop ? *loop : ev::get_default_loop(); 175 | 176 | #if EV_MULTIPLICITY 177 | _prepare.set(_loop); 178 | _check.set(_loop); 179 | #endif 180 | _prepare.set(this); 181 | _check.set(this); 182 | _prepare.start(); 183 | _check.start(); 184 | } 185 | 186 | Timeout *Ev::BusDispatcher::add_timeout(Timeout::Internal *wi) 187 | { 188 | Timeout *t = new Ev::BusTimeout(wi, _loop, _priority); 189 | 190 | debug_log("ev: added timeout %p (%s)", t, t->enabled() ? "on" : "off"); 191 | 192 | return t; 193 | } 194 | 195 | void Ev::BusDispatcher::rem_timeout(Timeout *t) 196 | { 197 | debug_log("ev: removed timeout %p", t); 198 | 199 | delete t; 200 | } 201 | 202 | Watch *Ev::BusDispatcher::add_watch(Watch::Internal *wi) 203 | { 204 | Watch *w = new Ev::BusWatch(wi, _loop, _priority); 205 | 206 | debug_log("ev: added watch %p (%s) fd=%d flags=%d", 207 | w, w->enabled() ? "on" : "off", w->descriptor(), w->flags() 208 | ); 209 | return w; 210 | } 211 | 212 | void Ev::BusDispatcher::rem_watch(Watch *w) 213 | { 214 | debug_log("ev: removed watch %p", w); 215 | 216 | delete w; 217 | } 218 | 219 | void Ev::BusDispatcher::set_priority(int priority) 220 | { 221 | _priority = priority; 222 | } 223 | -------------------------------------------------------------------------------- /m4/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004. 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 5 lt~obsolete.m4 11 | 12 | # These exist entirely to fool aclocal when bootstrapping libtool. 13 | # 14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 | # which have later been changed to m4_define as they aren't part of the 16 | # exported API, or moved to Autoconf or Automake where they belong. 17 | # 18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 | # using a macro with the same name in our local m4/libtool.m4 it'll 21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 | # and doesn't know about Autoconf macros at all.) 23 | # 24 | # So we provide this file, which has a silly filename so it's always 25 | # included after everything else. This provides aclocal with the 26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 | # because those macros already exist, or will be overwritten later. 28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 | # 30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 | # Yes, that means every name once taken will need to remain here until 32 | # we give up compatibility with versions before 1.7, at which point 33 | # we need to keep only those names which we still refer to. 34 | 35 | # This is to help aclocal find these macros, as it can't see m4_define. 36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 | 38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 81 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 82 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 83 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 84 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 85 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 86 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 87 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 89 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 90 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 91 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 92 | m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) 93 | m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) 94 | m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) 95 | m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) 96 | m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) 97 | m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) 98 | m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) 99 | --------------------------------------------------------------------------------