├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── SatPI.plantuml ├── SatPI.png ├── SatPI.svg ├── SatPI.uncrustify ├── backports └── 173.diff ├── checks ├── atomic.cpp ├── backtrace.cpp ├── npfunc.cpp ├── string_view.cpp └── sysdvb2sx.cpp ├── data └── satpi.service ├── debian └── control ├── doxygen ├── envARM.sh ├── envMIPS.sh ├── envMIPSEL.sh ├── gprof-helper └── gprof-helper.c ├── mapping.m3u ├── scripts ├── childpipe-example.sh └── childpipe-hdhomerun-example.sh ├── src ├── Defs.h ├── FileDescriptor.h ├── FwDecl.h ├── HeaderVector.cpp ├── HeaderVector.h ├── HttpServer.cpp ├── HttpServer.h ├── HttpcServer.cpp ├── HttpcServer.h ├── InterfaceAttr.cpp ├── InterfaceAttr.h ├── Log.cpp ├── Log.h ├── Properties.cpp ├── Properties.h ├── RtspServer.cpp ├── RtspServer.h ├── Satpi.cpp ├── Satpi.h ├── Stream.cpp ├── Stream.h ├── StreamManager.cpp ├── StreamManager.h ├── StringConverter.cpp ├── StringConverter.h ├── TransportParamVector.cpp ├── TransportParamVector.h ├── Unused.h ├── Utils.cpp ├── Utils.h ├── base │ ├── CharPointerArray.h │ ├── ChildPIPEReader.h │ ├── Functor1.h │ ├── Functor1Ret.h │ ├── Functor2.h │ ├── Functor3.h │ ├── FunctorBase.h │ ├── JSONSerializer.h │ ├── M3UParser.cpp │ ├── M3UParser.h │ ├── Mutex.h │ ├── StopWatch.h │ ├── Thread.cpp │ ├── Thread.h │ ├── ThreadBase.cpp │ ├── ThreadBase.h │ ├── TimeCounter.cpp │ ├── TimeCounter.h │ ├── Tokenizer.h │ ├── XMLSaveSupport.cpp │ ├── XMLSaveSupport.h │ ├── XMLSupport.cpp │ └── XMLSupport.h ├── decrypt │ ├── dvbapi │ │ ├── Client.cpp │ │ ├── Client.h │ │ ├── ClientProperties.cpp │ │ ├── ClientProperties.h │ │ ├── Filter.h │ │ ├── FilterData.h │ │ ├── Keys.cpp │ │ └── Keys.h │ └── dvbca │ │ ├── DVBCA.cpp │ │ └── DVBCA.h ├── input │ ├── Device.h │ ├── DeviceData.cpp │ ├── DeviceData.h │ ├── InputSystem.h │ ├── Transformation.cpp │ ├── Transformation.h │ ├── childpipe │ │ ├── TSReader.cpp │ │ ├── TSReader.h │ │ ├── TSReaderData.cpp │ │ └── TSReaderData.h │ ├── dvb │ │ ├── Frontend.cpp │ │ ├── Frontend.h │ │ ├── FrontendData.cpp │ │ ├── FrontendData.h │ │ ├── FrontendDecryptInterface.h │ │ ├── Frontend_DecryptInterface.cpp │ │ ├── delivery │ │ │ ├── DVBC.cpp │ │ │ ├── DVBC.h │ │ │ ├── DVBS.cpp │ │ │ ├── DVBS.h │ │ │ ├── DVBT.cpp │ │ │ ├── DVBT.h │ │ │ ├── DiSEqc.cpp │ │ │ ├── DiSEqc.h │ │ │ ├── DiSEqcEN50494.cpp │ │ │ ├── DiSEqcEN50494.h │ │ │ ├── DiSEqcEN50607.cpp │ │ │ ├── DiSEqcEN50607.h │ │ │ ├── DiSEqcLnb.cpp │ │ │ ├── DiSEqcLnb.h │ │ │ ├── DiSEqcSwitch.cpp │ │ │ ├── DiSEqcSwitch.h │ │ │ ├── FBC.cpp │ │ │ ├── FBC.h │ │ │ ├── Lnb.cpp │ │ │ ├── Lnb.h │ │ │ └── System.h │ │ └── dvbfix.h │ ├── file │ │ ├── TSReader.cpp │ │ ├── TSReader.h │ │ ├── TSReaderData.cpp │ │ └── TSReaderData.h │ └── stream │ │ ├── Streamer.cpp │ │ ├── Streamer.h │ │ ├── StreamerData.cpp │ │ └── StreamerData.h ├── main.cpp ├── mpegts │ ├── Filter.cpp │ ├── Filter.h │ ├── Generator.cpp │ ├── Generator.h │ ├── NIT.cpp │ ├── NIT.h │ ├── PAT.cpp │ ├── PAT.h │ ├── PCR.cpp │ ├── PCR.h │ ├── PMT.cpp │ ├── PMT.h │ ├── PacketBuffer.cpp │ ├── PacketBuffer.h │ ├── PidTable.cpp │ ├── PidTable.h │ ├── SDT.cpp │ ├── SDT.h │ ├── TableData.cpp │ └── TableData.h ├── output │ ├── StreamClient.cpp │ ├── StreamClient.h │ ├── StreamClientOutputHttp.cpp │ ├── StreamClientOutputHttp.h │ ├── StreamClientOutputRtp.cpp │ ├── StreamClientOutputRtp.h │ ├── StreamClientOutputRtpTcp.cpp │ └── StreamClientOutputRtpTcp.h ├── socket │ ├── HttpcSocket.cpp │ ├── HttpcSocket.h │ ├── SocketAttr.cpp │ ├── SocketAttr.h │ ├── SocketClient.h │ ├── TcpSocket.cpp │ ├── TcpSocket.h │ ├── UdpSocket.cpp │ └── UdpSocket.h └── upnp │ └── ssdp │ ├── Server.cpp │ └── Server.h └── web ├── 404.html ├── about.html ├── assets ├── css │ ├── bootstrap.min.css │ ├── fontawesome.min.css │ └── stylesheet.css ├── images │ ├── bg-grain.png │ ├── grid_noise.png │ └── icons │ │ ├── lr.png │ │ └── sm.png ├── js │ ├── addtableentry.js │ ├── bootstrap.min.js │ ├── cookies.js │ ├── jquery.min.js │ ├── loadxmldoc.js │ ├── menu.js │ ├── popper.min.js │ ├── postxmldoc.js │ └── utils.js └── webfonts │ └── fa-solid-900.woff2 ├── channellist.m3u ├── channellist_de.m3u ├── config.html ├── contact.html ├── desc.xml ├── favicon.ico ├── frontend.html ├── frontendoverview.html ├── index.html └── log.html /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | [*.{cpp,h}] 12 | charset = utf-8 13 | indent_style = tab 14 | indent_size = 2 15 | tab_width = 2 16 | trim_trailing_whitespace = true 17 | 18 | # Matches multiple files with brace expansion notation 19 | [*.{js,html,py}] 20 | charset = utf-8 21 | indent_style = tab 22 | indent_size = 2 23 | tab_width = 2 24 | trim_trailing_whitespace = true 25 | 26 | # Tab indentation (no size specified) 27 | [Makefile] 28 | indent_style = tab 29 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | custom: ["https://www.paypal.com/donate/?business=H9AX9N7HWSWXE&no_recurring=0&item_name=If+you+use+and+like+SatPI%2C+please+consider+making+a+donation+for+my+effort+in+creating+it+and+make+it+beter.+Thanks%21¤cy_code=EUR"] 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /src/Version.cpp 2 | /obj 3 | /html 4 | /latex 5 | /*.xml 6 | *.*~ 7 | *~ 8 | satpi 9 | /src/*.*~ 10 | /web/*.*~ 11 | /web/Thumbs.db 12 | /src/*~ 13 | bootID 14 | plantuml.jar 15 | cppcheck.log 16 | test.ts 17 | .DS_Store 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | dist: bionic 3 | language: cpp 4 | compiler: 5 | - g++ 6 | 7 | addons: 8 | apt: 9 | sources: 10 | - ubuntu-toolchain-r-test 11 | packages: 12 | - gcc-4.8 13 | - g++-4.8 14 | 15 | install: 16 | - g++-4.8 --version 17 | - g++ --version 18 | # - export CXXSUFFIX=-4.8 19 | 20 | script: 21 | - make 22 | - make clean 23 | - make debug 24 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | CONTRIBUTING 2 | ------------ 3 | 4 | Help in any way is appreciated: 5 | - coding 6 | - web design 7 | - ideas / feature requests 8 | - test reports 9 | - questions 10 | - spread the word! 11 | -------------------------------------------------------------------------------- /SatPI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/SatPI.png -------------------------------------------------------------------------------- /checks/atomic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void) { 3 | std::atomic tmpDouble(0.0); 4 | std::atomic_bool tmpBool; 5 | const double d = tmpDouble.load(); 6 | tmpBool = false; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /checks/backtrace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | // DO NOT alloc memory on heap!! 5 | void *array[25]; 6 | const size_t size = backtrace(array, 25); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /checks/npfunc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef _GNU_SOURCE 3 | #define _GNU_SOURCE _GNU_SOURCE 4 | #endif 5 | #include 6 | int main(void) { 7 | pthread_t _thread; 8 | pthread_setname_np(_thread, "Hello"); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /checks/string_view.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(void) { 4 | std::string foo("hello"); 5 | std::string_view sv{foo}; 6 | return foo == sv; 7 | } 8 | -------------------------------------------------------------------------------- /checks/sysdvb2sx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | int main(void) { 6 | fe_delivery_system delSys = SYS_DVBS2X; 7 | return delSys != 21; 8 | } 9 | -------------------------------------------------------------------------------- /data/satpi.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description="SATIP server SATPI." 3 | After=network-online.target 4 | Wants=network-online.target 5 | 6 | [Service] 7 | ExecStart=/usr/bin/satpi --no-daemon --app-data-path /var/lib/satpi --http-path /usr/share/satpi/web 8 | Restart=always 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: satpi 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Marc Postema 5 | Build-Depends: debhelper-compat (= 13) 6 | Standards-Version: 4.5.0 7 | Homepage: https://github.com/Barracuda09/SATPI 8 | Rules-Requires-Root: no 9 | 10 | Package: satpi 11 | Architecture: any 12 | Depends: ${shlibs:Depends}, ${misc:Depends} 13 | Description: An SAT>IP server for linux, suitable for running on an Raspberry Pi, VU+, BeagleBone or any other linux box. 14 | -------------------------------------------------------------------------------- /envARM.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use: 4 | # source ./env.sh [gcc12] 5 | # 6 | # CFLAGS as used for Vu+ uno 4K 7 | 8 | # ARM based Chips 9 | export CPU_FLAGS="-march=armv7-a -mtune=cortex-a15 -mfpu=neon-vfpv4" 10 | 11 | if [[ -n $1 && $1 = "gcc12" ]] ; then 12 | export CXXPREFIX=arm-linux-gnueabihf- 13 | export CXXSUFFIX=-12 14 | export CXX=$CXXPREFIX"g++"$CXXSUFFIX 15 | elif [[ -n $1 && $1 = "gcc4" ]] ; then 16 | export CXXPREFIX=~/vu/opt/toolchains/stbgcc-4.8-1.7/bin/arm-linux-gnueabihf- 17 | export CXXSUFFIX= 18 | export CXX=$CXXPREFIX"c++"$CXXSUFFIX 19 | else 20 | export CXXPREFIX=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/arm-linux-gnueabihf- 21 | export CXXSUFFIX= 22 | export CXX=$CXXPREFIX"c++"$CXXSUFFIX 23 | fi 24 | echo Using: $CXX 25 | $CXX --version 26 | -------------------------------------------------------------------------------- /envMIPS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use: 4 | # source ./env.sh 5 | # 6 | # CFLAGS as used for 7 | 8 | ############################################################################### 9 | # MIPS based BroadCom Chips 10 | export CPU_FLAGS="" 11 | 12 | #export CXXPREFIX=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mips-linux- 13 | #export CXXSUFFIX= 14 | #export CXX=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mips-linux-c++ 15 | #export CPP=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mips-linux-cpp 16 | #export CC=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mips-linux-gcc 17 | #export PYTHON_CPPFLAGS=~/vu/opt/toolchains/stbgcc-6.3-1.8/python-runtime/include/python2.7 18 | 19 | export CXXPREFIX=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mips-linux- 20 | export CXXSUFFIX= 21 | export CXX=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mips-linux-c++ 22 | export CPP=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mips-linux-cpp 23 | export CC=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mips-linux-gcc 24 | export PYTHON_CPPFLAGS=~/vu/opt/toolchains/stbgcc-8.3-0.4/python-runtime/include/python2.7 25 | ############################################################################### 26 | -------------------------------------------------------------------------------- /envMIPSEL.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use: 4 | # source ./env.sh 5 | # 6 | # CFLAGS as used for 7 | 8 | ############################################################################### 9 | # MIPSEL based BroadCom Chips 10 | export CPU_FLAGS="" 11 | 12 | #export CXXPREFIX=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mipsel-linux- 13 | #export CXXSUFFIX= 14 | #export CXX=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mipsel-linux-c++ 15 | #export CPP=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mipsel-linux-cpp 16 | #export CC=~/vu/opt/toolchains/stbgcc-6.3-1.8/bin/mipsel-linux-gcc 17 | #export PYTHON_CPPFLAGS=~/vu/opt/toolchains/stbgcc-6.3-1.8/python-runtime/include/python2.7 18 | 19 | export CXXPREFIX=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mipsel-linux- 20 | export CXXSUFFIX= 21 | export CXX=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mipsel-linux-c++ 22 | export CPP=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mipsel-linux-cpp 23 | export CC=~/vu/opt/toolchains/stbgcc-8.3-0.4/bin/mipsel-linux-gcc 24 | export PYTHON_CPPFLAGS=~/vu/opt/toolchains/stbgcc-8.3-0.4/python-runtime/include/python2.7 25 | ############################################################################### 26 | -------------------------------------------------------------------------------- /mapping.m3u: -------------------------------------------------------------------------------- 1 | #EXTM3U 2 | 3 | # To use Translation you need to set in the web interface 4 | # - 'Advertise as' to exp. 'DVB-S2' 5 | # - 'Transformation enable' should be checked 6 | # - and a valid m3u file like this 7 | 8 | #EXTINF:-1 satip-freq="200" satip-src="3", Translation to: File uri="/usr/satpi/test.ts" 9 | rtsp://@#1/?msys=file&uri="%2Fusr%2Fsatpi%2Ftest.ts" 10 | 11 | #EXTINF:-1 satip-freq="201" satip-src="3", Translation to: ChildPIPE exec="cat /usr/satpi/test.ts" 12 | rtsp://@#1/?msys=childpipe&exec="cat%20%2Fusr%2Fsatpi%2Ftest.ts" 13 | 14 | #EXTINF:-1 satip-freq="202" satip-src="4", Translation to: Streamer - Multicast UDP input 224.0.1.3:15001 15 | rtsp://@#1/?msys=streamer&uri="udp@224.0.1.3:15001" 16 | 17 | #EXTINF:-1 satip-freq="203" satip-src="5", Translation to: ChildPIPE exec="wget -qO- http://192.168.0.104:8875/?src=2%26fe=2%26freq=11052.75%26sr=22000%26msys=dvbs2%26mtype=8psk%26pol=h%26fec=23%26pids=0,1,16,17,18,1039,5420,5421,5424" 18 | rtsp://@#1/?msys=childpipe&exec="wget%20-qO-%20http:%2F%2F192.168.0.104:8875%2F%3Fsrc=2%%26fe=2%%26freq=11052.75%%26sr=22000%%26msys=dvbs2%%26mtype=8psk%%26pol=h%%26fec=23%%26pids=0,1,16,17,18,1039,5420,5421,5424" 19 | 20 | #EXTINF:-1 satip-freq="204", Translation to: ChildPIPE exec="wget -qO- http://192.168.0.112:8875/?freq=418%26sr=6900%26msys=dvbc%26mtype=256qam%26fec=35%26pids=0,1,16,17,18,2600,2601,2611" 21 | rtsp://@#1/?msys=childpipe&exec="wget%20-qO-%20http:%2F%2F192.168.0.112:8875%2F%3Ffreq=418%%26sr=6900%%26msys=dvbc%%26mtype=256qam%%26fec=35%%26pids=0,1,16,17,18,2600,2601,2611" 22 | 23 | #EXTINF:-1 satip-freq="205", Translation to: ChildPIPE exec="childpipe-hdhomerun-example.sh 192.168.0.115 0 auto:386000000 0,1,16,17,18,3200,3201,3211" 24 | rtsp://%1/?msys=childpipe&exec="childpipe-hdhomerun-example.sh%20192.168.0.115%200%20auto:386000000%200,1,16,17,18,2000,2001,2011,2100,2101,2111,3200,3201,3211" 25 | 26 | #EXTINF:-1 satip-freq="10123", Translation to: File uri="test.ts" 27 | rtsp://@#1/?msys=file&uri="test.ts" 28 | 29 | #EXTINF:-1 satip-freq="10744", Translation to: DVB-C 386MHz 30 | rtsp://@#1/?freq=386&sr=6900&msys=dvbc&mtype=256qam&fec=35 31 | 32 | #EXTINF:-1 satip-freq="10773", Translation to: DVB-C 458MHz 33 | rtsp://@#1/?freq=458&sr=6900&msys=dvbc&mtype=256qam&fec=35 34 | -------------------------------------------------------------------------------- /scripts/childpipe-example.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | trap cleanup TERM INT KILL EXIT HUP QUIT STOP ABRT; 4 | 5 | ## Set here your variables 6 | CHANNEL=$1 7 | ## End Set 8 | pid=0 9 | 10 | preexec() { 11 | ## Execute here your initialization commands 12 | tool_config select $CHANNEL && \ 13 | tool_config filter all 14 | ## End Execute 15 | } 16 | 17 | runcmd() { 18 | ## Execute here your your running command (with PIPEs) in background 19 | tool_config stream - & 20 | ## End Execute 21 | pid=$! 22 | } 23 | 24 | cleanup() { 25 | if [ -z $pid ] || [ "$pid" -eq 0 ] ; then 26 | exit 1 27 | else 28 | kill -9 $pid 29 | ## Execute here your cleanup commands 30 | tool_config stop 31 | ## End Execute 32 | fi 33 | exit 0 34 | } 35 | 36 | preexec 37 | runcmd 38 | if [ -z $pid ] || [ "$pid" -eq 0 ] ; then 39 | exit 1 40 | else 41 | wait $pid 42 | fi 43 | -------------------------------------------------------------------------------- /scripts/childpipe-hdhomerun-example.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## example: 4 | ## ./run 192.168.0.121 0 auto:386000000 0,1,16,17,18,2000,2001,2011 | vlc - 5 | ## | | | | | 6 | ## | | | | +-- PIDs 7 | ## +-- IP | | +-- freq in hz 8 | ## | +-- modulation 9 | ## +-- tuner ID 10 | 11 | ## Execute cleanup() when these signals are trapped 12 | trap cleanup TERM INT KILL EXIT HUP QUIT STOP ABRT 13 | 14 | ## Set here your variables 15 | IP=$1 16 | TUNE_ID=$2 17 | CHANNEL=$3 18 | PIDSTR=$4 19 | pid=0 20 | ## End Set 21 | 22 | preexec() { 23 | hexstr=" " 24 | 25 | ## Input Field Separator 26 | IFS="," 27 | for row in ${PIDSTR} 28 | do 29 | cols=$row 30 | for col in ${cols} 31 | do 32 | hexstr=$(printf "%s 0x%.4X" $hexstr $col) 33 | done 34 | done 35 | 36 | ## Execute here your initialization commands 37 | hdhomerun_config $IP set /tuner$TUNE_ID/channel $CHANNEL 38 | hdhomerun_config $IP set /tuner$TUNE_ID/filter "$hexstr" 39 | ## End Execute 40 | } 41 | 42 | runcmd() { 43 | ## Execute here your your running command (with PIPEs -) in background with & 44 | ## and save pid of tool 45 | hdhomerun_config $IP save /tuner$TUNE_ID - & 46 | pid=$! 47 | ## End Execute 48 | } 49 | 50 | cleanup() { 51 | if [ -d /proc/$pid ] ; then 52 | kill -9 $pid 53 | fi 54 | ## Execute here your cleanup commands 55 | hdhomerun_config $IP set /tuner$TUNE_ID/channel none 56 | ## End Execute 57 | ## trap EXIT 58 | if [ -z $pid ] || [ "$pid" -eq 0 ] ; then 59 | exit 1 60 | else 61 | exit 0 62 | fi 63 | } 64 | 65 | ## main 66 | 67 | preexec 68 | runcmd 69 | if [ -z $pid ] || [ "$pid" -eq 0 ] ; then 70 | cleanup 71 | else 72 | wait $pid 73 | cleanup 74 | fi 75 | -------------------------------------------------------------------------------- /src/Defs.h: -------------------------------------------------------------------------------- 1 | /* Defs.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef DEFS_H_INCLUDE 21 | #define DEFS_H_INCLUDE DEFS_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using StringVector = std::vector; 29 | 30 | using PacketPtr = std::unique_ptr; 31 | 32 | class TypeID { 33 | public: 34 | TypeID(int id) : _id(id) {} 35 | TypeID &operator=(int id) { 36 | _id = id; 37 | return *this; 38 | } 39 | 40 | int getID() const { 41 | return _id; 42 | } 43 | 44 | operator int() const { 45 | return _id; 46 | } 47 | 48 | bool operator>=(const int id) const { 49 | return _id >= id; 50 | } 51 | 52 | bool operator<=(const int id) const { 53 | return _id <= id; 54 | } 55 | 56 | bool operator==(const int id) const { 57 | return _id == id; 58 | } 59 | 60 | bool operator!=(const int id) const { 61 | return _id != id; 62 | } 63 | 64 | bool operator==(const TypeID& rhs) const { 65 | return _id == rhs._id; 66 | } 67 | 68 | private: 69 | int _id; 70 | }; 71 | 72 | class FeID : public TypeID { 73 | public: 74 | FeID(int id=-1) : TypeID(id) {} 75 | }; 76 | 77 | class FeIndex : public TypeID { 78 | public: 79 | FeIndex(int index=-1) : TypeID(index) {} 80 | }; 81 | 82 | class StreamID : public TypeID { 83 | public: 84 | StreamID(int id=-1) : TypeID(id) {} 85 | }; 86 | 87 | #endif // DEFS_H_INCLUDE 88 | -------------------------------------------------------------------------------- /src/FileDescriptor.h: -------------------------------------------------------------------------------- 1 | /* FileDescriptor.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef FILE_DESCRIPTOR_H_INCLUDE 21 | #define FILE_DESCRIPTOR_H_INCLUDE 22 | 23 | #include 24 | 25 | /// The class @c FileDescriptor can be used to make handling file descriptors 26 | /// easier 27 | class FileDescriptor { 28 | // ======================================================================= 29 | // -- Constructors and destructor --------------------------------------- 30 | // ======================================================================= 31 | public: 32 | 33 | FileDescriptor(int fd = -1) : _fd(fd) {} 34 | 35 | virtual ~FileDescriptor() { 36 | close(); 37 | } 38 | 39 | /// Conversion operator to int 40 | // operator int() const { return _fd; } 41 | 42 | /// Assignment with a file descriptor (int) 43 | FileDescriptor & operator=(int rhs_fd) { 44 | if (_fd > 0) { 45 | close(); 46 | } 47 | _fd = rhs_fd; 48 | return *this; 49 | } 50 | 51 | /// Equality operator 52 | bool operator==(int rhs_fd) const { 53 | return _fd == rhs_fd; 54 | } 55 | 56 | // ======================================================================= 57 | // -- Other member functions --------------------------------------------- 58 | // ======================================================================= 59 | public: 60 | 61 | /// Is File descriptor opened 62 | bool isOpen() const { 63 | return _fd > 0; 64 | } 65 | 66 | /// Get File descriptor 67 | int get() const { 68 | return _fd; 69 | } 70 | 71 | /// close the file descriptor 72 | void close() { 73 | ::close(_fd); 74 | } 75 | 76 | // ======================================================================= 77 | // -- Data members ------------------------------------------------------- 78 | // ======================================================================= 79 | private: 80 | 81 | int _fd; 82 | }; 83 | 84 | #endif // FILE_DESCRIPTOR_H_INCLUDE 85 | -------------------------------------------------------------------------------- /src/HeaderVector.cpp: -------------------------------------------------------------------------------- 1 | /* HeaderVector.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | 24 | // ============================================================================= 25 | // -- Other member functions --------------------------------------------------- 26 | // ============================================================================= 27 | 28 | std::string HeaderVector::getFieldParameter(const std::string_view reqHeader) const { 29 | for (const std::string& header : _vector) { 30 | const auto b = header.find(reqHeader, 0); 31 | const auto e = header.find_first_not_of(reqHeader, b); 32 | if (b != std::string::npos && reqHeader.size() == e && header[e] == ':') { 33 | return StringConverter::trimWhitespace(header.substr(e + 1)); 34 | } 35 | } 36 | return std::string(); 37 | } 38 | 39 | std::string HeaderVector::getStringFieldParameter(std::string_view header, 40 | std::string_view parameter) const { 41 | const std::string field = getFieldParameter(header); 42 | if (field.empty()) { 43 | return std::string(); 44 | } 45 | StringVector params = StringConverter::split(field, ";\r\n"); 46 | for (const std::string& param : params) { 47 | const auto p = param.find(parameter, 0); 48 | if (p != std::string::npos) { 49 | StringVector r = StringConverter::split(param, "="); 50 | return r.size() == 2 ? StringConverter::trimWhitespace(r[1]) : std::string(); 51 | } 52 | } 53 | return std::string(); 54 | } 55 | 56 | int HeaderVector::getIntFieldParameter(std::string_view header, 57 | std::string_view parameter) const { 58 | const std::string val = getStringFieldParameter(header, parameter); 59 | if (val.empty()) { 60 | return -1; 61 | } 62 | return std::isdigit(val[0]) ? std::stoi(val) : -1; 63 | } 64 | -------------------------------------------------------------------------------- /src/HeaderVector.h: -------------------------------------------------------------------------------- 1 | /* HeaderVector.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef HEADERVECTORS_H_INCLUDE 21 | #define HEADERVECTORS_H_INCLUDE HEADERVECTORS_H_INCLUDE 22 | 23 | #include 24 | 25 | #include 26 | 27 | class HeaderVector { 28 | // ========================================================================= 29 | // -- Constructors and destructor ------------------------------------------ 30 | // ========================================================================= 31 | public: 32 | 33 | explicit HeaderVector(StringVector&& vector) : _vector(std::move(vector)) {} 34 | virtual ~HeaderVector() = default; 35 | 36 | // ========================================================================= 37 | // -- Other member functions ---------------------------------------------- 38 | // ========================================================================= 39 | public: 40 | 41 | template< class... Args > 42 | StringVector::reference emplace_back( Args&&... args ) { 43 | return _vector.emplace_back(std::forward(args)...); 44 | } 45 | StringVector::size_type size() const noexcept { 46 | return _vector.size(); 47 | } 48 | StringVector::reference operator[]( StringVector::size_type pos ) { 49 | return _vector[pos]; 50 | } 51 | StringVector::const_reference operator[](StringVector::size_type pos ) const { 52 | return _vector[pos]; 53 | } 54 | StringVector::iterator begin() noexcept { 55 | return _vector.begin(); 56 | } 57 | StringVector::const_iterator begin() const noexcept { 58 | return _vector.begin(); 59 | } 60 | StringVector::const_iterator cbegin() const noexcept { 61 | return _vector.cbegin(); 62 | } 63 | StringVector::iterator end() noexcept { 64 | return _vector.end(); 65 | } 66 | StringVector::const_iterator end() const noexcept { 67 | return _vector.end(); 68 | } 69 | StringVector::const_iterator cend() const noexcept { 70 | return _vector.cend(); 71 | } 72 | const StringVector& asStringVector() const { 73 | return _vector; 74 | } 75 | 76 | /// 77 | std::string getFieldParameter(std::string_view reqHeader) const; 78 | 79 | /// 80 | std::string getStringFieldParameter(std::string_view header, 81 | std::string_view parameter) const; 82 | 83 | /// 84 | int getIntFieldParameter(std::string_view header, 85 | std::string_view parameter) const; 86 | 87 | // ========================================================================= 88 | // -- Data members --------------------------------------------------------- 89 | // ========================================================================= 90 | private: 91 | 92 | StringVector _vector; 93 | }; 94 | 95 | #endif // HEADERVECTORS_H_INCLUDE 96 | -------------------------------------------------------------------------------- /src/HttpServer.h: -------------------------------------------------------------------------------- 1 | /* HttpServer.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef HTTP_SERVER_H_INCLUDE 21 | #define HTTP_SERVER_H_INCLUDE HTTP_SERVER_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | FW_DECL_NS0(Properties); 28 | FW_DECL_NS0(StreamManager); 29 | FW_DECL_NS1(base, XMLSupport); 30 | 31 | /// HTTP Server 32 | class HttpServer : 33 | public base::ThreadBase, 34 | public HttpcServer { 35 | // ======================================================================= 36 | // Constructors and destructor 37 | // ======================================================================= 38 | public: 39 | 40 | HttpServer( 41 | base::XMLSupport& xml, 42 | StreamManager& streamManager, 43 | const Properties& properties); 44 | 45 | virtual ~HttpServer(); 46 | 47 | // ======================================================================= 48 | // -- Other member functions --------------------------------------------- 49 | // ======================================================================= 50 | public: 51 | 52 | /// Call this to initialize, setup and start this server 53 | virtual void initialize( 54 | int port, 55 | bool nonblock); 56 | 57 | protected: 58 | 59 | /// Thread function 60 | virtual void threadEntry() final; 61 | 62 | /// Method for getting the required files 63 | virtual bool methodGet(SocketClient &client, bool headOnly) final; 64 | 65 | /// Method for getting the required files 66 | virtual bool methodPost(SocketClient &client) final; 67 | 68 | /// 69 | std::size_t readFile(const char *filePath, std::string &data) const; 70 | 71 | // ======================================================================= 72 | // Data members 73 | // ======================================================================= 74 | private: 75 | 76 | base::XMLSupport &_xml; 77 | 78 | }; 79 | 80 | #endif // HTTP_SERVER_H_INCLUDE 81 | -------------------------------------------------------------------------------- /src/InterfaceAttr.h: -------------------------------------------------------------------------------- 1 | /* InterfaceAttr.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INTERFACEATTR_H_INCLUDE 21 | #define INTERFACEATTR_H_INCLUDE INTERFACEATTR_H_INCLUDE 22 | 23 | #include 24 | 25 | /// Interface attributes 26 | class InterfaceAttr { 27 | public: 28 | // ===================================================================== 29 | // -- Constructors and destructor ------------------------------------- 30 | // ===================================================================== 31 | 32 | /// 33 | /// @param bindInterfaceName specifies the network interface name to bind to 34 | explicit InterfaceAttr(const std::string &bindInterfaceName); 35 | 36 | virtual ~InterfaceAttr() = default; 37 | 38 | // ===================================================================== 39 | // -- Other member functions ------------------------------------------ 40 | // ===================================================================== 41 | 42 | public: 43 | 44 | /// Get the IP address of the used interface 45 | const std::string &getIPAddress() const { 46 | return _ipAddr; 47 | } 48 | 49 | /// Get the IP address to bind the servers to (The requesed or first one that is UP) 50 | const std::string &getBindIPAddress() const { 51 | return _bindIPAddress; 52 | } 53 | 54 | /// Get the UUID of this device 55 | std::string getUUID() const; 56 | 57 | protected: 58 | 59 | /// Find the MAC and IP address of the first adapters that is UP, or requested ifaceName (i.e. eth0) 60 | bool getAdapterProperties(const std::string &ifaceName); 61 | 62 | // ===================================================================== 63 | // -- Data members ---------------------------------------------------- 64 | // ===================================================================== 65 | 66 | protected: 67 | 68 | std::string _ipAddr; /// ip address of the used interface 69 | std::string _bindIPAddress; /// bind ip address of the servers 70 | std::string _macAddrDecorated; /// mac address of the used interface 71 | std::string _macAddr; /// mac address of the used interface 72 | std::string _ifaceName; /// used interface name i.e. eth0 73 | }; 74 | 75 | #endif // INTERFACEATTR_H_INCLUDE 76 | -------------------------------------------------------------------------------- /src/Log.cpp: -------------------------------------------------------------------------------- 1 | /* Log.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #define LOG_SIZE 550 35 | 36 | namespace { 37 | base::Mutex globalLogMutex; 38 | } 39 | 40 | bool Log::_syslogOn = false; 41 | bool Log::_coutLog = true; 42 | bool Log::_logDebug = true; 43 | 44 | Log::LogBuffer Log::_appLogBuffer; 45 | 46 | void Log::openAppLog(const char *deamonName, const bool daemonize) { 47 | // initialize the logging interface 48 | openlog(deamonName, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); 49 | if (daemonize) { 50 | _coutLog = false; 51 | } 52 | } 53 | 54 | void Log::closeAppLog() { 55 | // close logging interface 56 | closelog(); 57 | } 58 | 59 | void Log::startSysLog(bool start) { 60 | _syslogOn = start; 61 | } 62 | 63 | bool Log::getSysLogState() { 64 | return _syslogOn; 65 | } 66 | 67 | void Log::log(const int priority, const std::string &msg) { 68 | if ((priority & MPEGTS_TABLES) == MPEGTS_TABLES) { 69 | return; 70 | } 71 | if (priority == LOG_DEBUG && !_logDebug) { 72 | return; 73 | } 74 | // set timestamp 75 | struct timespec timeStamp; 76 | struct tm result; 77 | char asciiTime[100]; 78 | clock_gettime(CLOCK_REALTIME, &timeStamp); 79 | localtime_r(&timeStamp.tv_sec, &result); 80 | std::strftime(asciiTime, sizeof(asciiTime), "%c", &result); 81 | 82 | // cut line to insert nsec '.000000000' 83 | asciiTime[19] = 0; 84 | const std::string time = StringConverter::stringFormat("@#1.@#2 @#3", 85 | &asciiTime[0], DIGIT(timeStamp.tv_nsec/100000, 4), &asciiTime[20]); 86 | 87 | std::string::size_type index = 0; 88 | base::MutexLock lock(globalLogMutex); 89 | for (;;) { 90 | std::string line = StringConverter::getline(msg, index, "\r\n"); 91 | if (line.empty()) { 92 | return; 93 | } 94 | 95 | // log to syslog 96 | if (_syslogOn) { 97 | syslog(priority, "%s", line.data()); 98 | } 99 | 100 | #ifdef DEBUG 101 | if (_coutLog) { 102 | std::cout << time << " " << line << std::endl; 103 | } 104 | #endif 105 | 106 | // save to deque as last, because of std::move 107 | if (_appLogBuffer.size() == LOG_SIZE) { 108 | _appLogBuffer.pop_front(); 109 | } 110 | _appLogBuffer.emplace_back(priority, std::move(line), time); 111 | } 112 | } 113 | 114 | std::string Log::makeJSON() { 115 | base::JSONSerializer json; 116 | json.startObject(); 117 | 118 | json.startArrayWithName("log"); 119 | { 120 | base::MutexLock lock(globalLogMutex); 121 | if (!_appLogBuffer.empty()) { 122 | for (const LogElem& elem : _appLogBuffer) { 123 | json.startObject(); 124 | json.addValueString("timestamp", elem.timestamp); 125 | json.addValueString("msg", elem.msg); 126 | json.addValueNumber("prio", StringConverter::stringFormat("@#1", elem.priority)); 127 | json.endObject(); 128 | } 129 | } 130 | } 131 | json.endArray(); 132 | 133 | json.endObject(); 134 | return json.getString(); 135 | } 136 | -------------------------------------------------------------------------------- /src/RtspServer.cpp: -------------------------------------------------------------------------------- 1 | /* RtspServer.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | extern const char* const satpi_version; 31 | 32 | RtspServer::RtspServer(StreamManager& streamManager, const Properties& properties) : 33 | ThreadBase("RtspServer"), 34 | HttpcServer(20, "RTSP", streamManager, properties) {} 35 | 36 | RtspServer::~RtspServer() { 37 | cancelThread(); 38 | joinThread(); 39 | } 40 | 41 | void RtspServer::initialize( 42 | int port, 43 | bool nonblock) { 44 | HttpcServer::initialize(port, nonblock); 45 | startThread(); 46 | } 47 | 48 | void RtspServer::threadEntry() { 49 | SI_LOG_INFO("Setting up RTSP server"); 50 | 51 | for (;;) { 52 | // call poll with a timeout of 500 ms 53 | poll(500); 54 | 55 | _streamManager.checkForSessionTimeout(); 56 | } 57 | } 58 | 59 | void RtspServer::methodDescribe( 60 | const std::string& sessionID, const int cseq, const FeIndex feIndex, std::string& htmlBody) { 61 | static const char* RTSP_DESCRIBE = 62 | "@#1" \ 63 | "Server: satpi/@#2\r\n" \ 64 | "CSeq: @#3\r\n" \ 65 | "Content-Type: application/sdp\r\n" \ 66 | "Content-Base: rtsp://@#4/\r\n" \ 67 | "Content-Length: @#5\r\n" \ 68 | "@#6" \ 69 | "\r\n" \ 70 | "@#7"; 71 | 72 | std::string desc = _streamManager.getSDPSessionLevelString( 73 | _properties.getIpAddress(), sessionID); 74 | std::size_t streamsSetup = 0; 75 | 76 | // Lambda Expression 'setupDescribeMediaLevelString' 77 | const auto setupDescribeMediaLevelString = [&](const FeIndex feIdx) { 78 | const std::string mediaLevel = _streamManager.getSDPMediaLevelString(feIdx); 79 | if (mediaLevel.size() > 5) { 80 | ++streamsSetup; 81 | desc += mediaLevel; 82 | } 83 | }; 84 | // Check if there is a specific Frontend ID index requested 85 | if (feIndex == -1) { 86 | for (std::size_t i = 0; i < _streamManager.getMaxStreams(); ++i) { 87 | setupDescribeMediaLevelString(i); 88 | } 89 | } else { 90 | setupDescribeMediaLevelString(feIndex); 91 | } 92 | 93 | // check if we are in session, then we need to send the Session ID 94 | const std::string sessionIDHeaderField = (sessionID.size() > 2) ? 95 | StringConverter::stringFormat("Session: @#1\r\n", sessionID) : ""; 96 | 97 | // Are there any streams setup already 98 | if (streamsSetup != 0) { 99 | htmlBody = StringConverter::stringFormat(RTSP_DESCRIBE, "RTSP/1.0 200 OK\r\n", satpi_version, 100 | cseq, _properties.getIpAddress(), desc.size(), sessionIDHeaderField, desc); 101 | } else { 102 | htmlBody = StringConverter::stringFormat(RTSP_DESCRIBE, "RTSP/1.0 404 Not Found\r\n", satpi_version, 103 | cseq, _properties.getIpAddress(), 0, sessionIDHeaderField, ""); 104 | } 105 | } 106 | 107 | -------------------------------------------------------------------------------- /src/RtspServer.h: -------------------------------------------------------------------------------- 1 | /* RtspServer.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef RTSP_SERVER_H_INCLUDE 21 | #define RTSP_SERVER_H_INCLUDE RTSP_SERVER_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | FW_DECL_NS0(SocketClient); 29 | FW_DECL_NS0(Stream); 30 | FW_DECL_NS0(StreamManager); 31 | 32 | /// RTSP Server 33 | class RtspServer : 34 | public base::ThreadBase, 35 | public HttpcServer { 36 | // ========================================================================= 37 | // -- Constructors and destructor ------------------------------------------ 38 | // ========================================================================= 39 | public: 40 | 41 | RtspServer(StreamManager& streamManager, const Properties& properties); 42 | 43 | virtual ~RtspServer(); 44 | 45 | /// Call this to initialize, setup and start this server 46 | virtual void initialize(int port, bool nonblock); 47 | 48 | protected: 49 | /// Thread function 50 | virtual void threadEntry() final; 51 | 52 | private: 53 | 54 | /// 55 | virtual void methodDescribe(const std::string& sessionID, int cseq, FeIndex index, std::string& htmlBody) final; 56 | 57 | // ===================================================================== 58 | // -- Data members ----------------------------------------------------- 59 | // ===================================================================== 60 | }; 61 | 62 | #endif // RTSP_SERVER_H_INCLUDE 63 | -------------------------------------------------------------------------------- /src/Satpi.h: -------------------------------------------------------------------------------- 1 | /* Satpi.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef SATPI_H_INCLUDE 21 | #define SATPI_H_INCLUDE SATPI_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | class SatPI : 35 | public base::XMLSaveSupport, 36 | public base::XMLSupport { 37 | // ===================================================================== 38 | // -- Object Data ------------------------------------------------------ 39 | // ===================================================================== 40 | public: 41 | 42 | struct Params { 43 | bool ssdp = true; 44 | std::string ifaceName; 45 | std::string currentPath; 46 | std::string appdataPath; 47 | std::string webPath; 48 | std::string dvbPath; 49 | unsigned int httpPort = 0; 50 | unsigned int rtspPort = 0; 51 | int numberOfChildPIPE = 0; 52 | bool enableUnsecureFrontends = false; 53 | int ssdpTTL = 1; 54 | }; 55 | 56 | // ===================================================================== 57 | // -- Constructors and destructor ------------------------------------- 58 | // ===================================================================== 59 | public: 60 | 61 | SatPI(const SatPI::Params ¶ms); 62 | 63 | virtual ~SatPI() = default; 64 | 65 | // ===================================================================== 66 | // -- base::XMLSupport ------------------------------------------------- 67 | // ===================================================================== 68 | public: 69 | 70 | virtual void doAddToXML(std::string &xml) const final; 71 | 72 | virtual void doFromXML(const std::string &xml) final; 73 | 74 | // ======================================================================= 75 | // -- base::XMLSaveSupport ----------------------------------------------- 76 | // ======================================================================= 77 | public: 78 | 79 | virtual bool saveXML() const; 80 | 81 | // ===================================================================== 82 | // -- Other member functions ------------------------------------------- 83 | // ===================================================================== 84 | public: 85 | 86 | bool exitApplication() const; 87 | 88 | bool restartApplication() const; 89 | 90 | // ======================================================================= 91 | // -- Data members ------------------------------------------------------- 92 | // ======================================================================= 93 | private: 94 | 95 | InterfaceAttr _interface; 96 | StreamManager _streamManager; 97 | Properties _properties; 98 | HttpServer _httpServer; 99 | RtspServer _rtspServer; 100 | upnp::ssdp::Server _ssdpServer; 101 | }; 102 | 103 | #endif // SATPI_H_INCLUDE 104 | -------------------------------------------------------------------------------- /src/TransportParamVector.h: -------------------------------------------------------------------------------- 1 | /* TransportParamVector.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef TRANSPORTPARAMVECTORS_H_INCLUDE 21 | #define TRANSPORTPARAMVECTORS_H_INCLUDE TRANSPORTPARAMVECTORS_H_INCLUDE 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | class TransportParamVector { 29 | // ========================================================================= 30 | // -- Constructors and destructor ------------------------------------------ 31 | // ========================================================================= 32 | public: 33 | 34 | explicit TransportParamVector(StringVector&& vector) : _vector(std::move(vector)) {} 35 | virtual ~TransportParamVector() = default; 36 | 37 | // ========================================================================= 38 | // -- Other member functions ---------------------------------------------- 39 | // ========================================================================= 40 | public: 41 | 42 | template< class... Args > 43 | StringVector::reference emplace_back( Args&&... args ) { 44 | return _vector.emplace_back(std::forward(args)...); 45 | } 46 | StringVector::size_type size() const noexcept { 47 | return _vector.size(); 48 | } 49 | StringVector::reference operator[]( StringVector::size_type pos ) { 50 | return _vector[pos]; 51 | } 52 | StringVector::const_reference operator[](StringVector::size_type pos ) const { 53 | return _vector[pos]; 54 | } 55 | StringVector::iterator begin() noexcept { 56 | return _vector.begin(); 57 | } 58 | StringVector::const_iterator begin() const noexcept { 59 | return _vector.begin(); 60 | } 61 | StringVector::const_iterator cbegin() const noexcept { 62 | return _vector.cbegin(); 63 | } 64 | StringVector::iterator end() noexcept { 65 | return _vector.end(); 66 | } 67 | StringVector::const_iterator end() const noexcept { 68 | return _vector.end(); 69 | } 70 | StringVector::const_iterator cend() const noexcept { 71 | return _vector.cend(); 72 | } 73 | const StringVector& asStringVector() const { 74 | return _vector; 75 | } 76 | 77 | /// 78 | std::string getParameter(std::string_view parameter) const; 79 | 80 | /// 81 | void replaceParameter(const std::string_view parameter, const std::string_view value); 82 | 83 | /// 84 | double getDoubleParameter(std::string_view parameter) const; 85 | 86 | /// 87 | int getIntParameter(std::string_view parameter) const; 88 | 89 | /// 90 | input::InputSystem getMSYSParameter() const; 91 | 92 | /// 93 | std::string getURIParameter(const std::string_view parameter) const; 94 | 95 | // ========================================================================= 96 | // -- Data members --------------------------------------------------------- 97 | // ========================================================================= 98 | private: 99 | 100 | StringVector _vector; 101 | }; 102 | 103 | #endif // TRANSPORTPARAMVECTORS_H_INCLUDE 104 | -------------------------------------------------------------------------------- /src/Unused.h: -------------------------------------------------------------------------------- 1 | /* Unused.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef UNUSED_H_INCLUDE 21 | #define UNUSED_H_INCLUDE UNUSED_H_INCLUDE 22 | 23 | #define UNUSED(x) 24 | 25 | #endif // UNUSED_H_INCLUDE 26 | -------------------------------------------------------------------------------- /src/Utils.cpp: -------------------------------------------------------------------------------- 1 | /* Utils.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef HAS_NO_BACKTRACE_FUNCTIONS 33 | void Utils::createBackTrace(const char *) { 34 | #warning Compiling with no backtrace! 35 | #else 36 | void Utils::createBackTrace(const char *file) { 37 | // DO NOT alloc memory on heap!! 38 | void *array[25]; 39 | const size_t size = backtrace(array, 25); 40 | 41 | // Log all the frames to Backtrace File 42 | char path[256]; 43 | snprintf(path, sizeof(path), "/tmp/%s.bt", file); 44 | int backtraceFile = ::open(path, O_CREAT|O_WRONLY|O_TRUNC, 0664); 45 | if (backtraceFile > 0) { 46 | backtrace_symbols_fd(array, size, backtraceFile); 47 | ::close(backtraceFile); 48 | } else { 49 | backtrace_symbols_fd(array, size, STDOUT_FILENO); 50 | } 51 | #endif 52 | } 53 | 54 | void Utils::annotateBackTrace(const char *app, const char *file) { 55 | std::ifstream bt(file, std::ios::in); 56 | int i = 0; 57 | for (std::string line; std::getline(bt, line); ++i) { 58 | const auto begin = line.find('['); 59 | const auto end = line.find(']'); 60 | if (begin != std::string::npos && end != std::string::npos) { 61 | const std::string addr = line.substr(begin + 1, end - begin - 1); 62 | 63 | char addr2line[256]; 64 | snprintf(addr2line, sizeof(addr2line),"addr2line %s -e %s", addr.data(), app); 65 | 66 | base::ChildPIPEReader exec; 67 | exec.open(addr2line); 68 | std::string code; 69 | char buffer[256]; 70 | std::size_t s; 71 | while ((s = exec.read(reinterpret_cast(buffer), 255)) > 0) { 72 | code.append(buffer, s); 73 | code.erase(std::find(code.begin(), code.end(), '\n')); 74 | } 75 | 76 | std::cout << "[bt] #" << i << " " << code << " -- " << line << std::endl; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Utils.h: -------------------------------------------------------------------------------- 1 | /* Utils.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef UTILS_H_INCLUDE 21 | #define UTILS_H_INCLUDE UTILS_H_INCLUDE 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | /// Convert an enum class to integer 30 | template 31 | static constexpr int asInteger(Enumeration value) { 32 | return static_cast::type>(value); 33 | } 34 | 35 | /// Convert an integer to enum class 36 | template 37 | constexpr Enumeration integerToEnum(From value) { 38 | return static_cast(value); 39 | } 40 | 41 | /// The class @c Utils has some utility functions 42 | class Utils { 43 | public: 44 | 45 | /// Create a Backtrace (Stacktrace) and write it to 'file' in /tmp 46 | /// @param file specifies the file name for the Backtrace 47 | static void createBackTrace(const char *file); 48 | 49 | /// 50 | /// @param app specifies this current application name to use for addr2line 51 | /// @param file specifies the Backtrace file to annotate 52 | static void annotateBackTrace(const char *app, const char *file); 53 | }; 54 | 55 | #define ASSERT(EXPRESSION) assert(EXPRESSION) 56 | 57 | #define N_ELEMENTS(array) (sizeof(array) / sizeof(array[0])) 58 | 59 | #define CLOSE_FD(x) \ 60 | if (x != -1) { \ 61 | if (::close(x) == -1) { \ 62 | SI_LOG_PERROR("close error fd @#1", x); \ 63 | } \ 64 | x = -1; \ 65 | } 66 | 67 | #define FREE_PTR(x) \ 68 | { \ 69 | if (x != nullptr) { \ 70 | ::free(x); \ 71 | x = nullptr; \ 72 | } \ 73 | } 74 | 75 | /// If @a pointer is not nullptr, delete it and set it to nullptr. 76 | #define DELETE(pointer) \ 77 | { \ 78 | if (pointer != nullptr) { \ 79 | delete pointer; \ 80 | pointer = nullptr; \ 81 | } \ 82 | } 83 | 84 | /// If @a arrayPointer is not nullptr, delete[] it and set it to nullptr. 85 | #define DELETE_ARRAY(arrayPointer) \ 86 | { \ 87 | if (arrayPointer != nullptr) { \ 88 | delete[] arrayPointer; \ 89 | arrayPointer = nullptr; \ 90 | } \ 91 | } 92 | 93 | #endif // UTILS_H_INCLUDE 94 | -------------------------------------------------------------------------------- /src/base/CharPointerArray.h: -------------------------------------------------------------------------------- 1 | /* CharPointerArray.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_CHAR_POINTER_ARRAY 21 | #define BASE_CHAR_POINTER_ARRAY BASE_CHAR_POINTER_ARRAY 22 | 23 | #include 24 | #include 25 | 26 | namespace base { 27 | 28 | class CharPointerArray { 29 | public: 30 | // ========================================================================= 31 | // -- Constructors and destructor ----------------------------------------- 32 | // ========================================================================= 33 | template 34 | CharPointerArray(const Container &container) { 35 | // Allocate Size of container + null terminator (and nullptr it) 36 | _data = new char *[container.size() + 1]{nullptr}; 37 | int counter = 0; 38 | for (const std::string& str : container) { 39 | // Allocate Size of str + null terminator (and zero it) 40 | _data[counter] = new char [str.size() + 1]{0}; 41 | // Copy str 42 | std::memcpy(_data[counter], str.data(), str.size()); 43 | ++counter; 44 | } 45 | } 46 | 47 | virtual ~CharPointerArray() { 48 | for (int i = 0; _data[i] != nullptr; ++i) { 49 | delete _data[i]; 50 | } 51 | delete [] _data; 52 | } 53 | 54 | // ========================================================================= 55 | // -- Other member functions ---------------------------------------------- 56 | // ========================================================================= 57 | public: 58 | 59 | char **getData() const { 60 | return _data; 61 | } 62 | 63 | // ========================================================================= 64 | // -- Data members --------------------------------------------------------- 65 | // ========================================================================= 66 | private: 67 | char **_data; 68 | }; 69 | 70 | } // namespace base 71 | 72 | #endif // BASE_CHAR_POINTER_ARRAY 73 | -------------------------------------------------------------------------------- /src/base/ChildPIPEReader.h: -------------------------------------------------------------------------------- 1 | /* ChildPIPEReader.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_CHILD_PIPE_READER 21 | #define BASE_CHILD_PIPE_READER BASE_CHILD_PIPE_READER 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace base { 34 | 35 | class ChildPIPEReader { 36 | // ===================================================================== 37 | // -- Constructors and destructor ------------------------------------- 38 | // ===================================================================== 39 | public: 40 | 41 | ChildPIPEReader() {} 42 | 43 | virtual ~ChildPIPEReader() { 44 | close(); 45 | } 46 | 47 | // ===================================================================== 48 | // -- Other member functions ------------------------------------------ 49 | // ===================================================================== 50 | public: 51 | 52 | void open(const std::string &cmd) { 53 | popen2(cmd); 54 | } 55 | 56 | void close() { 57 | if (_open) { 58 | CLOSE_FD(_stdout); 59 | ::kill(_pid, SIGKILL); 60 | _open = false; 61 | } 62 | } 63 | 64 | bool isOpen() const { 65 | return _open; 66 | } 67 | 68 | std::size_t read(unsigned char *buffer, std::size_t size) { 69 | return ::read(_stdout, buffer, size); 70 | } 71 | 72 | private: 73 | 74 | void popen2(const std::string &cmd) { 75 | int pipefd[2] = { -1, -1 }; 76 | if (::pipe2(pipefd, 0) != 0) { 77 | return; 78 | } 79 | StringVector argumentVector = StringConverter::parseCommandArgumentString(cmd); 80 | const CharPointerArray charPtrArray(argumentVector); 81 | char * const* argv = charPtrArray.getData(); 82 | 83 | // Prevent children going into 'zombie' mode 84 | signal(SIGCHLD, SIG_IGN); 85 | 86 | _pid = ::fork(); 87 | 88 | if (_pid < 0) { 89 | // Something wrong here 90 | return; 91 | } else if (_pid == 0) { 92 | // This is the child process 93 | CLOSE_FD(pipefd[READ]); 94 | ::dup2(pipefd[WRITE], WRITE); 95 | 96 | ::execvp(argv[0], argv); 97 | SI_LOG_PERROR("execvp"); 98 | exit(1); 99 | } 100 | // This is the parent process 101 | CLOSE_FD(pipefd[WRITE]); 102 | _stdout = pipefd[READ]; 103 | _open = true; 104 | } 105 | 106 | // ===================================================================== 107 | // -- Data members ----------------------------------------------------- 108 | // ===================================================================== 109 | private: 110 | 111 | static constexpr int READ = 0; 112 | static constexpr int WRITE = 1; 113 | int _stdout = -1; 114 | pid_t _pid = -1; 115 | bool _open = false; 116 | }; 117 | 118 | } // namespace base 119 | 120 | #endif // BASE_CHILD_PIPE_READER 121 | -------------------------------------------------------------------------------- /src/base/Functor1.h: -------------------------------------------------------------------------------- 1 | /* Functor1.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_FUNCTOR1_H_INCLUDE 21 | #define BASE_FUNCTOR1_H_INCLUDE BASE_FUNCTOR1_H_INCLUDE 22 | 23 | #include 24 | 25 | namespace base { 26 | 27 | /// The class @c Functor1 is functor with 1 argument with no return 28 | template 29 | class Functor1 : protected FunctorBase { 30 | public: 31 | 32 | void operator() (P1 p1) const { 33 | _functionFunctor(*this, p1); 34 | } 35 | 36 | protected: 37 | typedef void (*FunctionFunctor)(const FunctorBase &, P1); 38 | 39 | // ======================================================================= 40 | // -- Constructors and destructor ---------------------------------------- 41 | // ======================================================================= 42 | Functor1(FunctionFunctor ff, const void *callee, const void *callback, size_t sz) : 43 | FunctorBase(callee, callback, sz), 44 | _functionFunctor(ff) {} 45 | 46 | public: 47 | virtual ~Functor1() {} 48 | 49 | private: 50 | FunctionFunctor _functionFunctor; 51 | }; 52 | 53 | template 54 | class FunctionWrapper1 : public Functor1 { 55 | public: 56 | FunctionWrapper1(FUNC func) : 57 | Functor1(functionFunctor, nullptr, (void *)func, 0) {} 58 | 59 | static void functionFunctor(const FunctorBase &ftor, P1 p1) { 60 | (FUNC(ftor._callback))(p1); 61 | } 62 | }; 63 | 64 | template 65 | class MemberFunctionWrapper1 : public Functor1 { 66 | public: 67 | MemberFunctionWrapper1(CALLEE &callee, const FUNC &func) : 68 | Functor1(functionFunctor, &callee, &func, sizeof(FUNC)) {} 69 | 70 | static void functionFunctor(const FunctorBase &ftor, P1 p1) { 71 | CALLEE *callee = (CALLEE *)ftor._callee; 72 | FUNC &callback(*(FUNC*)(void *)(ftor._callbackMember)); 73 | (callee->*callback)(p1); 74 | } 75 | }; 76 | 77 | template 78 | inline FunctionWrapper1 79 | makeFunctor(Functor1*, RETURN (*f)(TP1)) { 80 | return FunctionWrapper1(f); 81 | } 82 | 83 | template 84 | inline MemberFunctionWrapper1 85 | makeFunctor(Functor1*, CALLEE &callee, RETURN (CALL_TYPE::* const &func)(TP1)) { 86 | typedef RETURN (CALL_TYPE::*FUNC)(TP1); 87 | return MemberFunctionWrapper1(callee, func); 88 | } 89 | 90 | template 91 | inline MemberFunctionWrapper1 92 | makeFunctor(Functor1*, const CALLEE &callee, RETURN (CALL_TYPE::* const &func)(TP1) const) { 93 | typedef RETURN (CALL_TYPE::*FUNC)(TP1) const; 94 | return MemberFunctionWrapper1(callee, func); 95 | } 96 | 97 | } // namespace base 98 | #endif // BASE_FUNCTOR1_H_INCLUDE 99 | -------------------------------------------------------------------------------- /src/base/Functor1Ret.h: -------------------------------------------------------------------------------- 1 | /* Functor1.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_FUNCTOR1RET_H_INCLUDE 21 | #define BASE_FUNCTOR1RET_H_INCLUDE BASE_FUNCTOR1RET_H_INCLUDE 22 | 23 | #include 24 | 25 | namespace base { 26 | 27 | /// The class @c Functor1 is functor with 1 argument with an return 28 | template 29 | class Functor1Ret : protected FunctorBase { 30 | public: 31 | 32 | RETURN operator() (P1 p1) const { 33 | return _functionFunctor(*this, p1); 34 | } 35 | 36 | protected: 37 | typedef RETURN (*FunctionFunctor)(const FunctorBase &, P1); 38 | 39 | // ======================================================================= 40 | // -- Constructors and destructor ---------------------------------------- 41 | // ======================================================================= 42 | Functor1Ret(FunctionFunctor ff, const void *callee, const void *callback, size_t sz) : 43 | FunctorBase(callee, callback, sz), 44 | _functionFunctor(ff) {} 45 | 46 | public: 47 | virtual ~Functor1Ret() {} 48 | 49 | private: 50 | FunctionFunctor _functionFunctor; 51 | }; 52 | 53 | template 54 | class FunctionWrapper1 : public Functor1Ret { 55 | public: 56 | explicit FunctionWrapper1(FUNC func) : 57 | Functor1Ret(functionFunctor, nullptr, (void *)func, 0) {} 58 | 59 | static RETURN functionFunctor(const FunctorBase &ftor, P1 p1) { 60 | return (FUNC(ftor._callback))(p1); 61 | } 62 | }; 63 | 64 | template 65 | class MemberFunctionWrapper1 : public Functor1Ret { 66 | public: 67 | MemberFunctionWrapper1(CALLEE &callee, const FUNC &func) : 68 | Functor1Ret(functionFunctor, &callee, &func, sizeof(FUNC)) {} 69 | 70 | static RETURN functionFunctor(const FunctorBase &ftor, P1 p1) { 71 | CALLEE *callee = (CALLEE *)ftor._callee; 72 | FUNC &callback(*(FUNC*)(void *)(ftor._callbackMember)); 73 | return (callee->*callback)(p1); 74 | } 75 | }; 76 | 77 | template 78 | inline FunctionWrapper1 79 | makeFunctor(Functor1Ret*, RETURN (*f)(TP1)) { 80 | return FunctionWrapper1(f); 81 | } 82 | 83 | template 84 | inline MemberFunctionWrapper1 85 | makeFunctor(Functor1Ret*, CALLEE &callee, RETURN (CALL_TYPE::* const &func)(TP1)) { 86 | typedef RETURN (CALL_TYPE::*FUNC)(TP1); 87 | return MemberFunctionWrapper1(callee, func); 88 | } 89 | 90 | template 91 | inline MemberFunctionWrapper1 92 | makeFunctor(Functor1Ret*, const CALLEE &callee, RETURN (CALL_TYPE::* const &func)(TP1) const) { 93 | typedef RETURN (CALL_TYPE::*FUNC)(TP1) const; 94 | return MemberFunctionWrapper1(callee, func); 95 | } 96 | 97 | } // namespace base 98 | 99 | #endif // BASE_FUNCTOR1RET_H_INCLUDE 100 | -------------------------------------------------------------------------------- /src/base/FunctorBase.h: -------------------------------------------------------------------------------- 1 | /* Functor2.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_FUNCTORBASE_H_INCLUDE 21 | #define BASE_FUNCTORBASE_H_INCLUDE BASE_FUNCTORBASE_H_INCLUDE 22 | 23 | #include 24 | 25 | namespace base { 26 | 27 | /// The class @c FunctorBase 28 | class FunctorBase { 29 | public: 30 | typedef void (FunctorBase::*MemberFunction) (); 31 | 32 | // ======================================================================= 33 | // -- Constructors and destructor ---------------------------------------- 34 | // ======================================================================= 35 | FunctorBase() : _callback(nullptr), _callee(nullptr) {} 36 | 37 | FunctorBase(const void *callee, const void *callback, size_t Size) { 38 | if (callee) { 39 | // callback must be a member function 40 | _callee = (void*)callee; 41 | memcpy(_callbackMember, callback, Size); 42 | } else { 43 | // Ok must be a regular pointer to a function 44 | _callback = callback; 45 | } 46 | } 47 | 48 | virtual ~FunctorBase() {} 49 | 50 | union { 51 | const void *_callback; 52 | char _callbackMember[sizeof(MemberFunction)]; 53 | }; 54 | void *_callee; 55 | }; 56 | 57 | } // namespace base 58 | 59 | #endif // BASE_FUNCTORBASE_H_INCLUDE 60 | -------------------------------------------------------------------------------- /src/base/M3UParser.h: -------------------------------------------------------------------------------- 1 | /* M3UParser.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_M3UPARSER_H_INCLUDE 21 | #define BASE_M3UPARSER_H_INCLUDE BASE_M3UPARSER_H_INCLUDE 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | namespace base { 30 | 31 | /// The class @c M3UParser can be used to parse M3U files with 32 | /// 'satip-freq' and 'satip-src' extensions. 33 | class M3UParser { 34 | public: 35 | struct TransformationElement { 36 | std::string uri; 37 | double freq = -1.0; 38 | int src = -1; 39 | }; 40 | using TransformationMap = std::map; 41 | 42 | // ======================================================================= 43 | // -- Constructors and destructor --------------------------------------- 44 | // ======================================================================= 45 | M3UParser(); 46 | 47 | virtual ~M3UParser(); 48 | 49 | // ======================================================================= 50 | // -- Other member functions -------------------------------------------- 51 | // ======================================================================= 52 | 53 | public: 54 | 55 | /// Pars the M3U mapping file 56 | /// @param filePath 57 | /// @retval true specifies the file is mapped false means something 58 | /// is wrong with the file 59 | bool parse(const std::string &filePath); 60 | 61 | /// Get the uri for the requested frequency 62 | /// @param freq requested frequency to transform 63 | /// @retval the Transformation Element of this freq if available 64 | TransformationElement findTransformationElementFor(double freq) const; 65 | 66 | /// Check if the requested frequency can be transformed 67 | /// @retval true means the frequency can be used for 68 | /// transformation 69 | bool exist(const double freq) const; 70 | 71 | /// This will return a copy of the M3U map 72 | TransformationMap getTransformationMap() const { 73 | return _transformationMap; 74 | } 75 | 76 | // ======================================================================= 77 | // -- Data members ------------------------------------------------------- 78 | // ======================================================================= 79 | 80 | private: 81 | 82 | TransformationMap _transformationMap; 83 | }; 84 | 85 | } // namespace base 86 | 87 | #endif // BASE_M3UPARSER_H_INCLUDE 88 | -------------------------------------------------------------------------------- /src/base/StopWatch.h: -------------------------------------------------------------------------------- 1 | /* StopWatch.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_STOP_WATCH 21 | #define BASE_STOP_WATCH BASE_STOP_WATCH 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace base { 28 | 29 | class StopWatch { 30 | // ========================================================================= 31 | // -- Constructors and destructor ----------------------------------------- 32 | // ========================================================================= 33 | public: 34 | 35 | StopWatch() { 36 | start(); 37 | } 38 | 39 | ~StopWatch() = default; 40 | 41 | // ========================================================================= 42 | // -- Other member functions ---------------------------------------------- 43 | // ========================================================================= 44 | public: 45 | 46 | void start() { 47 | _t1 = std::chrono::steady_clock::now(); 48 | } 49 | void stop() { 50 | _t2 = std::chrono::steady_clock::now(); 51 | } 52 | 53 | unsigned long getIntervalMS() const { 54 | const auto t = std::chrono::steady_clock::now(); 55 | return std::chrono::duration_cast(t - _t1).count(); 56 | } 57 | 58 | unsigned long getIntervalUS() const { 59 | const auto t = std::chrono::steady_clock::now(); 60 | return std::chrono::duration_cast(t - _t1).count(); 61 | } 62 | 63 | // ========================================================================= 64 | // -- Data members --------------------------------------------------------- 65 | // ========================================================================= 66 | private: 67 | 68 | std::chrono::steady_clock::time_point _t1; 69 | std::chrono::steady_clock::time_point _t2; 70 | 71 | }; 72 | 73 | #define SW_DECL(name) base::StopWatch name 74 | #define SW_LOG_INTERVAL_US(name, msg) SI_LOG_DEBUG(msg, name.getIntervalUS()); 75 | #define SW_LOG_INTERVAL_US_NOT_ZERO(name, msg) { const auto t = name.getIntervalUS(); if (t > 0) { SI_LOG_DEBUG(msg, t); } }; 76 | #define SW_LOG_INTERVAL_MS(name, msg) SI_LOG_DEBUG(msg, name.getIntervalMS()); 77 | #define SW_LOG_INTERVAL_MS_NOT_ZERO(name, msg) { const auto t = name.getIntervalMS(); if (t > 0) { SI_LOG_DEBUG(msg, t); } }; 78 | 79 | } // namespace base 80 | 81 | #endif // BASE_STOP_WATCH 82 | -------------------------------------------------------------------------------- /src/base/TimeCounter.cpp: -------------------------------------------------------------------------------- 1 | /* TimeCounter.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | 24 | namespace base { 25 | 26 | long TimeCounter::getTicks() { 27 | struct timeval tv; 28 | gettimeofday(&tv, nullptr); 29 | return ((tv.tv_sec * 1000) + (tv.tv_usec / 1000)); 30 | } 31 | 32 | } // namespace base 33 | -------------------------------------------------------------------------------- /src/base/TimeCounter.h: -------------------------------------------------------------------------------- 1 | /* TimeCounter.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_TIMECOUNTER_H_INCLUDE 21 | #define BASE_TIMECOUNTER_H_INCLUDE BASE_TIMECOUNTER_H_INCLUDE 22 | 23 | namespace base { 24 | 25 | /// 26 | class TimeCounter { 27 | public: 28 | /// returns the ticks 29 | static long getTicks(); 30 | }; 31 | 32 | } // namespace base 33 | 34 | #endif // BASE_TIMECOUNTER_H_INCLUDE 35 | -------------------------------------------------------------------------------- /src/base/XMLSaveSupport.cpp: -------------------------------------------------------------------------------- 1 | /* XMLSaveSupport.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace base { 32 | 33 | // ============================================================================= 34 | // -- Constructors and destructor ---------------------------------------------- 35 | // ============================================================================= 36 | 37 | XMLSaveSupport::XMLSaveSupport(const std::string &filePath) : 38 | _filePath(filePath) {} 39 | 40 | XMLSaveSupport::~XMLSaveSupport() {} 41 | 42 | // ============================================================================= 43 | // -- Other member functions --------------------------------------------------- 44 | // ============================================================================= 45 | 46 | std::string XMLSaveSupport::getFileName() const { 47 | std::string file(""); 48 | if (!_filePath.empty()) { 49 | std::string path; 50 | StringConverter::splitPath(_filePath, path, file); 51 | } 52 | return file; 53 | } 54 | 55 | bool XMLSaveSupport::saveXML(const std::string &xml) const { 56 | if (!_filePath.empty()) { 57 | std::ofstream file; 58 | file.open(_filePath); 59 | if (file.is_open()) { 60 | file << xml; 61 | file.close(); 62 | return false; 63 | } 64 | } 65 | return false; 66 | } 67 | 68 | bool XMLSaveSupport::restoreXML(std::string &xml) { 69 | if (!_filePath.empty()) { 70 | std::ifstream file; 71 | file.open(_filePath); 72 | if (file.is_open()) { 73 | xml = std::string((std::istreambuf_iterator(file)), std::istreambuf_iterator()); 74 | file.close(); 75 | return true; 76 | } 77 | } 78 | return false; 79 | } 80 | 81 | } // namespace base 82 | -------------------------------------------------------------------------------- /src/base/XMLSaveSupport.h: -------------------------------------------------------------------------------- 1 | /* XMLSaveSupport.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef BASE_XML_SAVE_SUPPORT_H_INCLUDE 21 | #define BASE_XML_SAVE_SUPPORT_H_INCLUDE BASE_XML_SAVE_SUPPORT_H_INCLUDE 22 | 23 | #include 24 | 25 | namespace base { 26 | 27 | /// The class @c XMLSaveSupport has some basic functions to handle XML files 28 | class XMLSaveSupport { 29 | // ===================================================================== 30 | // -- Constructors and destructor -------------------------------------- 31 | // ===================================================================== 32 | public: 33 | 34 | explicit XMLSaveSupport(const std::string &filePath = ""); 35 | virtual ~XMLSaveSupport(); 36 | 37 | // ===================================================================== 38 | // -- Other member functions ------------------------------------------- 39 | // ===================================================================== 40 | public: 41 | 42 | virtual bool notifyChanges() const { 43 | return saveXML(); 44 | } 45 | 46 | virtual bool saveXML() const = 0; 47 | 48 | protected: 49 | 50 | /// Get the file name for this XML 51 | std::string getFileName() const; 52 | 53 | /// Save XML file 54 | bool saveXML(const std::string &xml) const; 55 | 56 | /// Loads XML file 57 | bool restoreXML(std::string &xml); 58 | 59 | // ===================================================================== 60 | // -- Data members ----------------------------------------------------- 61 | // ===================================================================== 62 | 63 | private: 64 | 65 | std::string _filePath; 66 | }; 67 | 68 | } // namespace base 69 | 70 | #endif // BASE_XML_SAVE_SUPPORT_H_INCLUDE 71 | -------------------------------------------------------------------------------- /src/decrypt/dvbapi/Keys.cpp: -------------------------------------------------------------------------------- 1 | /* Keys.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | 24 | extern "C" { 25 | #include 26 | void dvbcsa_bs_key_set_ecm(unsigned char ecm, const dvbcsa_cw_t cw, struct dvbcsa_bs_key_s *key) __attribute__((weak)); 27 | } 28 | 29 | namespace decrypt::dvbapi { 30 | 31 | // ============================================================================= 32 | // -- Other member functions -------------------------------------------------- 33 | // ============================================================================= 34 | 35 | void Keys::set(const unsigned char* cw, unsigned int parity, int UNUSED(index), const bool icamEnabled) { 36 | dvbcsa_bs_key_s* k = dvbcsa_bs_key_alloc(); 37 | const unsigned char icamECM = (_icam[parity].size() > 0) ? _icam[parity].back() : 0; 38 | if (icamEnabled) { 39 | dvbcsa_bs_key_set_ecm(icamECM, cw, k); 40 | } else { 41 | dvbcsa_bs_key_set(cw, k); 42 | } 43 | _key[parity].push(std::make_tuple(base::TimeCounter::getTicks(), k)); 44 | while (_key[parity].size() > 1) { 45 | remove(parity); 46 | } 47 | } 48 | 49 | void Keys::setICAM(const unsigned char ecm, unsigned int parity) { 50 | _icam[parity].push(ecm); 51 | while (_icam[parity].size() > 1) { 52 | _icam[parity].pop(); 53 | } 54 | } 55 | 56 | const dvbcsa_bs_key_s* Keys::get(unsigned int parity) const { 57 | if (!_key[parity].empty()) { 58 | const KeyTuple tup = _key[parity].back(); 59 | // const long duration = base::TimeCounter::getTicks() - pair.first; 60 | return std::get<1>(tup); 61 | } else { 62 | return nullptr; 63 | } 64 | } 65 | 66 | void Keys::freeKeys() { 67 | while (!_key[0].empty()) { 68 | remove(0); 69 | } 70 | while (!_key[1].empty()) { 71 | remove(1); 72 | } 73 | while (_icam[0].size() > 1) { 74 | _icam[0].pop(); 75 | } 76 | while (_icam[1].size() > 1) { 77 | _icam[1].pop(); 78 | } 79 | } 80 | 81 | void Keys::remove(unsigned int parity) { 82 | const KeyTuple tup = _key[parity].front(); 83 | dvbcsa_bs_key_free(std::get<1>(tup)); 84 | _key[parity].pop(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/decrypt/dvbapi/Keys.h: -------------------------------------------------------------------------------- 1 | /* Keys.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef DECRYPT_DVBAPI_KEYS_H_INCLUDE 21 | #define DECRYPT_DVBAPI_KEYS_H_INCLUDE DECRYPT_DVBAPI_KEYS_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | FW_DECL_NS0(dvbcsa_bs_key_s); 32 | 33 | namespace decrypt::dvbapi { 34 | 35 | /// 36 | class Keys { 37 | public: 38 | using KeyTuple = std::tuple; 39 | using KeyQueue = std::queue; 40 | using ICAMQueue = std::queue; 41 | 42 | // ========================================================================= 43 | // -- Constructors and destructor ----------------------------------------- 44 | // ========================================================================= 45 | public: 46 | 47 | Keys() = default; 48 | 49 | virtual ~Keys() = default; 50 | 51 | // ========================================================================= 52 | // -- Other member functions ---------------------------------------------- 53 | // ========================================================================= 54 | public: 55 | 56 | void set(const unsigned char* cw, unsigned int parity, int index, bool icamEnabled); 57 | 58 | void setICAM(const unsigned char ecm, unsigned int parity); 59 | 60 | const dvbcsa_bs_key_s *get(unsigned int parity) const; 61 | 62 | void freeKeys(); 63 | 64 | private: 65 | 66 | void remove(unsigned int parity); 67 | 68 | // ===================================================================== 69 | // -- Data members ---------------------------------------------------- 70 | // ===================================================================== 71 | private: 72 | 73 | KeyQueue _key[2]; 74 | ICAMQueue _icam[2]; 75 | }; 76 | 77 | } 78 | 79 | #endif // DECRYPT_DVBAPI_KEYS_H_INCLUDE 80 | -------------------------------------------------------------------------------- /src/input/InputSystem.h: -------------------------------------------------------------------------------- 1 | /* InputSystem.h 2 | 3 | Copyright (C) 2014 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_INPUTSYSTEM_H_INCLUDE 21 | #define INPUT_INPUTSYSTEM_H_INCLUDE INPUT_INPUTSYSTEM_H_INCLUDE 22 | 23 | namespace input { 24 | 25 | enum class InputSystem { 26 | UNDEFINED, 27 | DVBT, 28 | DVBS, 29 | DVBS2, 30 | DVBS2X, 31 | DVBT2, 32 | DVBC, 33 | FILE_SRC, 34 | STREAMER, 35 | CHILDPIPE, 36 | IPTV 37 | }; 38 | 39 | } // namespace input 40 | 41 | #endif // INPUT_INPUTSYSTEM_H_INCLUDE 42 | -------------------------------------------------------------------------------- /src/input/childpipe/TSReaderData.h: -------------------------------------------------------------------------------- 1 | /* TSReaderData.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_CHILD_PIPE_TSREADER_DATA_H_INCLUDE 21 | #define INPUT_CHILD_PIPE_TSREADER_DATA_H_INCLUDE INPUT_CHILD_PIPE_TSREADER_DATA_H_INCLUDE 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace input::childpipe { 28 | 29 | /// The class @c TSReaderData carries all the data/information for Reading 30 | /// from an Child PIPE 31 | class TSReaderData : 32 | public DeviceData { 33 | // ========================================================================= 34 | // -- Constructors and destructor ------------------------------------------ 35 | // ========================================================================= 36 | public: 37 | 38 | TSReaderData(); 39 | virtual ~TSReaderData() = default; 40 | 41 | // ========================================================================= 42 | // -- input::DeviceData ---------------------------------------------------- 43 | // ========================================================================= 44 | private: 45 | 46 | /// @see DeviceData 47 | virtual void doNextAddToXML(std::string &xml) const final; 48 | 49 | /// @see DeviceData 50 | virtual void doNextFromXML(const std::string &xml) final; 51 | 52 | /// @see DeviceData 53 | virtual void doInitialize() final; 54 | 55 | /// @see DeviceData 56 | virtual void doParseStreamString(FeID id, const TransportParamVector& params) final; 57 | 58 | /// @see DeviceData 59 | virtual std::string doAttributeDescribeString(FeID id) const final; 60 | 61 | /// @see DeviceData 62 | virtual bool capableOfInternalFiltering() const final { 63 | return true; 64 | } 65 | 66 | // ========================================================================= 67 | // -- Other member functions ---------------------------------------------- 68 | // ========================================================================= 69 | public: 70 | 71 | /// 72 | std::string getFilePath() const; 73 | 74 | bool hasFilePath() const; 75 | 76 | int getPCRTimer() const; 77 | 78 | bool generatePSI() const { 79 | return _genPSI; 80 | } 81 | 82 | // ========================================================================= 83 | // -- Data members --------------------------------------------------------- 84 | // ========================================================================= 85 | private: 86 | 87 | std::string _filePath; 88 | int _pcrTimer; 89 | bool _genPSI; 90 | 91 | }; 92 | 93 | } 94 | 95 | #endif // INPUT_CHILD_PIPE_TSREADER_DATA_H_INCLUDE 96 | -------------------------------------------------------------------------------- /src/input/dvb/Frontend_DecryptInterface.cpp: -------------------------------------------------------------------------------- 1 | /* Frontend_DecryptInterface.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | 24 | namespace input::dvb { 25 | 26 | void Frontend::startOSCamFilterData(const int pid, const unsigned int demux, const unsigned int filter, 27 | const unsigned char* filterData, const unsigned char* filterMask) { 28 | SI_LOG_INFO("Frontend: @#1, Start filter PID: @#2 demux: @#3 filter: @#4 (data @#5 @#6 @#7 mask @#8 @#9 @#10 @#11)", 29 | _feID, PID(pid), demux, filter, 30 | HEX2(filterData[0]), HEX2(filterData[1]), HEX2(filterData[2]), 31 | HEX2(filterMask[0]), HEX2(filterMask[1]), HEX2(filterMask[2]), HEX2(filterMask[3])); 32 | _dvbapiData.startOSCamFilterData(_feID, pid, demux, filter, filterData, filterMask); 33 | _frontendData.getFilter().setPID(pid, true); 34 | // now update frontend, PID list has changed 35 | updatePIDFilters(); 36 | } 37 | 38 | void Frontend::stopOSCamFilterData(const int pid, const unsigned int demux, const unsigned int filter) { 39 | SI_LOG_INFO("Frontend: @#1, Stop filter PID: @#2 demux: @#3 filter: @#4", 40 | _feID, PID(pid), demux, filter); 41 | _dvbapiData.stopOSCamFilterData(demux, filter); 42 | // Do not update frontend or remove the PID! 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DVBC.h: -------------------------------------------------------------------------------- 1 | /* DVBC.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DVBC_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DVBC_H_INCLUDE INPUT_DVB_DELIVERY_DVBC_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | FW_DECL_NS2(input, dvb, FrontendData); 29 | 30 | namespace input::dvb::delivery { 31 | 32 | /// The class @c DVBC specifies DVB-C/C2 delivery system 33 | class DVBC : 34 | public input::dvb::delivery::System { 35 | // ========================================================================= 36 | // -- Constructors and destructor ----------------------------------------- 37 | // ========================================================================= 38 | public: 39 | 40 | explicit DVBC(FeIndex index, FeID id, const std::string &fePath, unsigned int dvbVersion); 41 | virtual ~DVBC() = default; 42 | 43 | // ========================================================================= 44 | // -- base::XMLSupport ----------------------------------------------------- 45 | // ========================================================================= 46 | public: 47 | 48 | /// @see XMLSupport 49 | virtual void doAddToXML(std::string &xml) const final; 50 | 51 | /// @see XMLSupport 52 | virtual void doFromXML(const std::string &xml) final; 53 | 54 | // ========================================================================= 55 | // -- input::dvb::delivery::System ----------------------------------------- 56 | // ========================================================================= 57 | public: 58 | 59 | virtual bool tune( 60 | int feFD, 61 | const input::dvb::FrontendData &frontendData) final; 62 | 63 | virtual bool isCapableOf(input::InputSystem system) const final; 64 | 65 | // ========================================================================= 66 | // -- Other member functions ----------------------------------------------- 67 | // ========================================================================= 68 | private: 69 | 70 | /// 71 | bool setProperties(int feFD, const input::dvb::FrontendData &frontendData); 72 | 73 | // ========================================================================= 74 | // -- Data members --------------------------------------------------------- 75 | // ========================================================================= 76 | private: 77 | 78 | FBC _fbc; 79 | 80 | }; 81 | 82 | } 83 | 84 | #endif // INPUT_DVB_DELIVERY_DVBC_H_INCLUDE 85 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DVBS.h: -------------------------------------------------------------------------------- 1 | /* DVBS.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DVBS_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DVBS_H_INCLUDE INPUT_DVB_DELIVERY_DVBS_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | FW_DECL_UP_NS3(input, dvb, delivery, DiSEqc); 33 | 34 | namespace input::dvb::delivery { 35 | 36 | /// The class @c DVBS specifies DVB-S/S2 delivery system 37 | class DVBS : 38 | public input::dvb::delivery::System { 39 | // ========================================================================= 40 | // -- Constructors and destructor ----------------------------------------- 41 | // ========================================================================= 42 | public: 43 | 44 | explicit DVBS(FeIndex index, FeID id, const std::string &fePath, unsigned int dvbVersion); 45 | virtual ~DVBS() = default; 46 | 47 | // ========================================================================= 48 | // -- base::XMLSupport ----------------------------------------------------- 49 | // ========================================================================= 50 | private: 51 | 52 | /// @see XMLSupport 53 | virtual void doAddToXML(std::string &xml) const final; 54 | 55 | /// @see XMLSupport 56 | virtual void doFromXML(const std::string &xml) final; 57 | 58 | // ========================================================================= 59 | // -- input::dvb::delivery::System ----------------------------------------- 60 | // ========================================================================= 61 | public: 62 | 63 | virtual bool tune( 64 | int feFD, 65 | const input::dvb::FrontendData &frontendData) final; 66 | 67 | virtual bool isCapableOf(input::InputSystem system) const final { 68 | return system == input::InputSystem::DVBS2X || 69 | system == input::InputSystem::DVBS2 || 70 | system == input::InputSystem::DVBS; 71 | } 72 | 73 | /// 74 | virtual void teardown(int feFD) const; 75 | 76 | // ========================================================================= 77 | // -- Other member functions ----------------------------------------------- 78 | // ========================================================================= 79 | private: 80 | 81 | /// 82 | bool setProperties(int feFD, uint32_t freq, const input::dvb::FrontendData &frontendData); 83 | 84 | // ========================================================================= 85 | // -- Data members --------------------------------------------------------- 86 | // ========================================================================= 87 | private: 88 | 89 | enum class DiseqcType { 90 | Switch, 91 | EN50494, 92 | EN50607, 93 | Lnb 94 | }; 95 | FBC _fbc; 96 | DiseqcType _diseqcType; 97 | UpDiSEqc _diseqc; 98 | bool _turnoffLnbVoltage; 99 | bool _higherLnbVoltage; 100 | 101 | }; 102 | 103 | } 104 | 105 | #endif // INPUT_DVB_DELIVERY_DVBS_H_INCLUDE 106 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DVBT.h: -------------------------------------------------------------------------------- 1 | /* DVBT.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DVBT_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DVBT_H_INCLUDE INPUT_DVB_DELIVERY_DVBT_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | FW_DECL_NS2(input, dvb, FrontendData); 28 | 29 | namespace input { 30 | namespace dvb { 31 | namespace delivery { 32 | 33 | /// The class @c DVBT specifies DVB-T/T2 delivery system 34 | class DVBT : 35 | public input::dvb::delivery::System { 36 | // ======================================================================= 37 | // -- Constructors and destructor --------------------------------------- 38 | // ======================================================================= 39 | public: 40 | 41 | explicit DVBT(FeIndex index, FeID id, const std::string &fePath, unsigned int dvbVersion); 42 | virtual ~DVBT(); 43 | 44 | // ======================================================================= 45 | // -- base::XMLSupport --------------------------------------------------- 46 | // ======================================================================= 47 | public: 48 | 49 | /// @see XMLSupport 50 | virtual void doAddToXML(std::string &xml) const final; 51 | 52 | /// @see XMLSupport 53 | virtual void doFromXML(const std::string &xml) final; 54 | 55 | // ======================================================================= 56 | // -- input::dvb::delivery::System --------------------------------------- 57 | // ======================================================================= 58 | public: 59 | 60 | virtual bool tune( 61 | int feFD, 62 | const input::dvb::FrontendData &frontendData) final; 63 | 64 | virtual bool isCapableOf(input::InputSystem system) const final { 65 | return system == input::InputSystem::DVBT2 || 66 | system == input::InputSystem::DVBT; 67 | } 68 | 69 | // ======================================================================= 70 | // -- Other member functions --------------------------------------------- 71 | // ======================================================================= 72 | private: 73 | 74 | /// 75 | bool setProperties(int feFD, const input::dvb::FrontendData &frontendData); 76 | 77 | // ======================================================================= 78 | // -- Data members ------------------------------------------------------- 79 | // ======================================================================= 80 | private: 81 | 82 | unsigned int _lna; /// 83 | 84 | }; 85 | 86 | } // namespace delivery 87 | } // namespace dvb 88 | } // namespace input 89 | 90 | #endif // INPUT_DVB_DELIVERY_DVBT_H_INCLUDE 91 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DiSEqcEN50494.h: -------------------------------------------------------------------------------- 1 | /* DiSEqcEN50494.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DISEQCEN50494_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DISEQCEN50494_H_INCLUDE INPUT_DVB_DELIVERY_DISEQCEN50494_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace input::dvb::delivery { 30 | 31 | /// The class @c DiSEqcEN50494 specifies which type of DiSEqc switch is connected 32 | class DiSEqcEN50494 : 33 | public DiSEqc { 34 | // ======================================================================= 35 | // -- Constructors and destructor --------------------------------------- 36 | // ======================================================================= 37 | public: 38 | 39 | DiSEqcEN50494(); 40 | virtual ~DiSEqcEN50494() = default; 41 | 42 | // ======================================================================= 43 | // -- input::dvb::delivery::DiSEqc --------------------------------------- 44 | // ======================================================================= 45 | public: 46 | 47 | /// @see DiSEqc 48 | virtual bool sendDiseqc(int feFD, FeID id, uint32_t &freq, 49 | int src, Lnb::Polarization pol) final; 50 | 51 | private: 52 | 53 | /// @see DiSEqc 54 | virtual void doNextAddToXML(std::string &xml) const final; 55 | 56 | /// @see DiSEqc 57 | virtual void doNextFromXML(const std::string &xml) final; 58 | 59 | // ======================================================================= 60 | // -- Data members ------------------------------------------------------- 61 | // ======================================================================= 62 | private: 63 | 64 | int _pin; 65 | int _chSlot; 66 | uint32_t _chFreq; 67 | Lnb _lnb; 68 | }; 69 | 70 | } 71 | 72 | #endif // INPUT_DVB_DELIVERY_DISEQCEN50494_H_INCLUDE 73 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DiSEqcEN50607.h: -------------------------------------------------------------------------------- 1 | /* DiSEqcEN50607.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DISEQCEN50607_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DISEQCEN50607_H_INCLUDE INPUT_DVB_DELIVERY_DISEQCEN50607_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace input::dvb::delivery { 30 | 31 | /// The class @c DiSEqcEN50607 specifies which type of DiSEqc switch is connected 32 | class DiSEqcEN50607 : 33 | public DiSEqc { 34 | // ======================================================================= 35 | // -- Constructors and destructor --------------------------------------- 36 | // ======================================================================= 37 | public: 38 | 39 | DiSEqcEN50607(); 40 | virtual ~DiSEqcEN50607() = default; 41 | 42 | // ======================================================================= 43 | // -- input::dvb::delivery::DiSEqc --------------------------------------- 44 | // ======================================================================= 45 | public: 46 | 47 | /// @see DiSEqc 48 | virtual bool sendDiseqc(int feFD, FeID id, uint32_t &freq, 49 | int src, Lnb::Polarization pol) final; 50 | 51 | private: 52 | 53 | /// @see DiSEqc 54 | virtual void doNextAddToXML(std::string &xml) const final; 55 | 56 | /// @see DiSEqc 57 | virtual void doNextFromXML(const std::string &xml) final; 58 | 59 | // ======================================================================= 60 | // -- Data members ------------------------------------------------------- 61 | // ======================================================================= 62 | private: 63 | 64 | int _pin; 65 | int _chSlot; 66 | uint32_t _chFreq; 67 | Lnb _lnb; 68 | }; 69 | 70 | } 71 | 72 | #endif // INPUT_DVB_DELIVERY_DISEQCEN50607_H_INCLUDE 73 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DiSEqcLnb.cpp: -------------------------------------------------------------------------------- 1 | /* DiSEqcLnb.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace input::dvb::delivery { 33 | 34 | // ======================================================================= 35 | // -- input::dvb::delivery::DiSEqc --------------------------------------- 36 | // ======================================================================= 37 | 38 | bool DiSEqcLnb::sendDiseqc(const int feFD, const FeID id, uint32_t &freq, 39 | const int src, const Lnb::Polarization pol) { 40 | bool hiband = false; 41 | _lnb.getIntermediateFrequency(id, freq, hiband, pol); 42 | 43 | SI_LOG_INFO("Frontend: @#1, Sending LNB: Mini-Switch Src: @#2", id, src); 44 | 45 | if (ioctl(feFD, FE_SET_VOLTAGE, SEC_VOLTAGE_18) == -1) { 46 | SI_LOG_PERROR("FE_SET_VOLTAGE failed"); 47 | return false; 48 | } 49 | if (ioctl(feFD, FE_SET_TONE, SEC_TONE_OFF) == -1) { 50 | SI_LOG_PERROR("FE_SET_TONE failed"); 51 | return false; 52 | } 53 | std::this_thread::sleep_for(std::chrono::milliseconds(_delayBeforeWrite)); 54 | 55 | const auto b = (src % 2) ? SEC_MINI_B : SEC_MINI_A; 56 | if (ioctl(feFD, FE_DISEQC_SEND_BURST, b) == -1) { 57 | SI_LOG_PERROR("FE_DISEQC_SEND_BURST failed"); 58 | return false; 59 | } 60 | std::this_thread::sleep_for(std::chrono::milliseconds(_delayAfterWrite)); 61 | 62 | if (ioctl(feFD, FE_SET_VOLTAGE, SEC_VOLTAGE_13) == -1) { 63 | SI_LOG_PERROR("FE_SET_VOLTAGE failed to 13V"); 64 | } 65 | std::this_thread::sleep_for(std::chrono::milliseconds(5)); 66 | 67 | // Set LNB 68 | const auto v = (pol == Lnb::Polarization::Vertical || pol == Lnb::Polarization::CircularRight) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18; 69 | if (ioctl(feFD, FE_SET_VOLTAGE, v) == -1) { 70 | SI_LOG_PERROR("FE_SET_VOLTAGE failed"); 71 | return false; 72 | } 73 | 74 | const auto tone = hiband ? SEC_TONE_ON : SEC_TONE_OFF; 75 | if (ioctl(feFD, FE_SET_TONE, tone) == -1) { 76 | SI_LOG_PERROR("FE_SET_TONE failed"); 77 | return false; 78 | } 79 | return true; 80 | } 81 | 82 | void DiSEqcLnb::doNextAddToXML(std::string &xml) const { 83 | ADD_XML_N_ELEMENT(xml, "lnb", 1, _lnb.toXML()); 84 | } 85 | 86 | void DiSEqcLnb::doNextFromXML(const std::string &xml) { 87 | std::string element; 88 | if (findXMLElement(xml, "lnb1", element)) { 89 | _lnb.fromXML(element); 90 | } 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DiSEqcLnb.h: -------------------------------------------------------------------------------- 1 | /* DiSEqcLnb.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DISEQCLNB_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DISEQCLNB_H_INCLUDE INPUT_DVB_DELIVERY_DISEQCLNB_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | namespace input::dvb::delivery { 31 | 32 | /// The class @c DiSEqcLnb specifies which type of DiSEqc LNB is connected 33 | class DiSEqcLnb : 34 | public DiSEqc { 35 | // ======================================================================= 36 | // -- Constructors and destructor --------------------------------------- 37 | // ======================================================================= 38 | public: 39 | 40 | DiSEqcLnb() = default; 41 | virtual ~DiSEqcLnb() = default; 42 | 43 | // ======================================================================= 44 | // -- input::dvb::delivery::DiSEqc --------------------------------------- 45 | // ======================================================================= 46 | public: 47 | 48 | /// @see DiSEqc 49 | virtual bool sendDiseqc(int feFD, FeID id, uint32_t &freq, 50 | int src, Lnb::Polarization pol) final; 51 | 52 | private: 53 | 54 | /// @see DiSEqc 55 | virtual void doNextAddToXML(std::string &xml) const final; 56 | 57 | /// @see DiSEqc 58 | virtual void doNextFromXML(const std::string &xml) final; 59 | 60 | // ======================================================================= 61 | // -- Data members ------------------------------------------------------- 62 | // ======================================================================= 63 | 64 | private: 65 | Lnb _lnb; 66 | }; 67 | 68 | } 69 | 70 | #endif // INPUT_DVB_DELIVERY_DISEQCLNB_H_INCLUDE 71 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/DiSEqcSwitch.h: -------------------------------------------------------------------------------- 1 | /* DiSEqcSwitch.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_DISEQCSWITCH_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_DISEQCSWITCH_H_INCLUDE INPUT_DVB_DELIVERY_DISEQCSWITCH_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | namespace input::dvb::delivery { 32 | 33 | /// The class @c DiSEqcSwitch specifies which type of DiSEqc switch is connected 34 | class DiSEqcSwitch : 35 | public DiSEqc { 36 | // ======================================================================= 37 | // -- Constructors and destructor --------------------------------------- 38 | // ======================================================================= 39 | public: 40 | 41 | DiSEqcSwitch() = default; 42 | virtual ~DiSEqcSwitch() = default; 43 | 44 | // ======================================================================= 45 | // -- input::dvb::delivery::DiSEqc --------------------------------------- 46 | // ======================================================================= 47 | public: 48 | 49 | /// @see DiSEqc 50 | virtual bool sendDiseqc(int feFD, FeID id, uint32_t &freq, 51 | int src, Lnb::Polarization pol) final; 52 | 53 | private: 54 | 55 | /// @see DiSEqc 56 | virtual void doNextAddToXML(std::string &xml) const final; 57 | 58 | /// @see DiSEqc 59 | virtual void doNextFromXML(const std::string &xml) final; 60 | 61 | // ======================================================================= 62 | // -- Other member functions --------------------------------------------- 63 | // ======================================================================= 64 | private: 65 | 66 | bool sendDiseqcCommand(int feFD, FeID id, dvb_diseqc_master_cmd &cmd, 67 | MiniDiSEqCSwitch sw, int src, unsigned int repeatCmd); 68 | 69 | // ======================================================================= 70 | // -- Data members ------------------------------------------------------- 71 | // ======================================================================= 72 | private: 73 | enum class SwitchType { 74 | COMMITTED, 75 | UNCOMMITTED, 76 | CASCADE 77 | }; 78 | std::vector _lnb{1}; 79 | int _numberOfInputs = 1; 80 | uint8_t _addressByte = 0x10; 81 | uint8_t _commandByte = 0x38; 82 | SwitchType _switchType = SwitchType::COMMITTED; 83 | bool _enableMiniDiSEqCSwitch = false; 84 | }; 85 | 86 | } 87 | 88 | #endif // INPUT_DVB_DELIVERY_DISEQCSWITCH_H_INCLUDE 89 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/FBC.h: -------------------------------------------------------------------------------- 1 | /* FBC.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_FBC_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_FBC_H_INCLUDE INPUT_DVB_DELIVERY_FBC_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | namespace input::dvb::delivery { 32 | 33 | /// The class @c FBC specifies tuners that support FBC delivery system 34 | class FBC : 35 | public base::XMLSupport { 36 | // ========================================================================= 37 | // -- Constructors and destructor ----------------------------------------- 38 | // ========================================================================= 39 | public: 40 | 41 | FBC(const FeIndex index, const FeID id, const std::string& name, bool satTuner); 42 | virtual ~FBC() = default; 43 | 44 | // ========================================================================= 45 | // -- base::XMLSupport ----------------------------------------------------- 46 | // ========================================================================= 47 | private: 48 | 49 | /// @see XMLSupport 50 | virtual void doAddToXML(std::string &xml) const final; 51 | 52 | /// @see XMLSupport 53 | virtual void doFromXML(const std::string &xml) final; 54 | 55 | // ========================================================================= 56 | // -- Other member functions ----------------------------------------------- 57 | // ========================================================================= 58 | public: 59 | 60 | bool isFBCTuner() const noexcept { 61 | return _fbcTuner; 62 | } 63 | 64 | bool doSendDiSEqcViaRootTuner() const noexcept { 65 | return _fbcTuner && _fbcLinked && _satTuner && _sendDiSEqcViaRootTuner; 66 | } 67 | 68 | int getFileDescriptorOfRootTuner(std::string& fePath) const; 69 | 70 | private: 71 | 72 | /// 73 | int readProcData(FeIndex index, const std::string& procEntry) const; 74 | 75 | /// 76 | void writeProcData(FeIndex index, const std::string& procEntry, int value); 77 | 78 | /// 79 | void readConnectionChoices(FeIndex index, int offset); 80 | 81 | // ========================================================================= 82 | // -- Data members --------------------------------------------------------- 83 | // ========================================================================= 84 | private: 85 | 86 | FeIndex _index; 87 | FeID _id; 88 | std::string _name; 89 | bool _satTuner; 90 | using ConnectionChoices = std::map; 91 | ConnectionChoices _choices; 92 | bool _fbcTuner; 93 | bool _fbcRoot; 94 | int _fbcSetID; 95 | int _fbcConnect; 96 | int _offset; 97 | char _tunerLetter; 98 | bool _fbcLinked; 99 | bool _sendDiSEqcViaRootTuner; 100 | 101 | }; 102 | 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/Lnb.h: -------------------------------------------------------------------------------- 1 | /* Lnb.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_LNB_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_LNB_H_INCLUDE INPUT_DVB_DELIVERY_LNB_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | namespace input::dvb::delivery { 30 | 31 | /// The class @c Lnb specifies which type of LNB is connected 32 | class Lnb : 33 | public base::XMLSupport { 34 | public: 35 | 36 | enum class Polarization { 37 | Horizontal = 0, 38 | Vertical = 1, 39 | CircularLeft = 2, 40 | CircularRight = 3 41 | }; 42 | 43 | // ======================================================================= 44 | // -- Constructors and destructor --------------------------------------- 45 | // ======================================================================= 46 | public: 47 | 48 | Lnb(); 49 | virtual ~Lnb(); 50 | 51 | // ======================================================================= 52 | // -- base::XMLSupport --------------------------------------------------- 53 | // ======================================================================= 54 | private: 55 | 56 | /// @see XMLSupport 57 | virtual void doAddToXML(std::string &xml) const final; 58 | 59 | /// @see XMLSupport 60 | virtual void doFromXML(const std::string &xml) final; 61 | 62 | // ======================================================================= 63 | // -- Static member functions -------------------------------------------- 64 | // ======================================================================= 65 | public: 66 | 67 | static char translatePolarizationToChar(Polarization pol); 68 | 69 | // ======================================================================= 70 | // -- Other member functions --------------------------------------------- 71 | // ======================================================================= 72 | public: 73 | 74 | void getIntermediateFrequency(FeID id, uint32_t &freq, 75 | bool &hiband, Polarization pol) const; 76 | 77 | // ======================================================================= 78 | // -- Data members ------------------------------------------------------- 79 | // ======================================================================= 80 | private: 81 | 82 | enum class LNBType { 83 | Universal, 84 | Standard, 85 | UserDefined 86 | }; 87 | 88 | LNBType _type; 89 | uint32_t _switchlof; 90 | uint32_t _lofLow; 91 | uint32_t _lofHigh; 92 | }; 93 | 94 | } 95 | 96 | #endif // INPUT_DVB_DELIVERY_LNB_H_INCLUDE 97 | -------------------------------------------------------------------------------- /src/input/dvb/delivery/System.h: -------------------------------------------------------------------------------- 1 | /* System.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_DVB_DELIVERY_SYSTEM_H_INCLUDE 21 | #define INPUT_DVB_DELIVERY_SYSTEM_H_INCLUDE INPUT_DVB_DELIVERY_SYSTEM_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | FW_DECL_NS2(input, dvb, FrontendData); 31 | 32 | FW_DECL_VECTOR_OF_UP_NS3(input, dvb, delivery, System); 33 | 34 | namespace input::dvb::delivery { 35 | 36 | /// The class @c System specifies the interface to an specific delivery system 37 | class System : 38 | public base::XMLSupport { 39 | // ======================================================================= 40 | // -- Constructors and destructor --------------------------------------- 41 | // ======================================================================= 42 | public: 43 | 44 | explicit System(FeIndex index, FeID id, const std::string &fePath, unsigned int dvbVersion) : 45 | _index(index), 46 | _feID(id), 47 | _fePath(fePath), 48 | _dvbVersion(dvbVersion) {} 49 | 50 | virtual ~System() = default; 51 | 52 | // ======================================================================= 53 | // -- Other member functions --------------------------------------------- 54 | // ======================================================================= 55 | public: 56 | 57 | /// 58 | virtual bool tune( 59 | int feFD, 60 | const input::dvb::FrontendData &frontendData) = 0; 61 | 62 | /// 63 | virtual bool isCapableOf(input::InputSystem system) const = 0; 64 | 65 | /// 66 | virtual void teardown(int UNUSED(feFD)) const {} 67 | 68 | // ======================================================================= 69 | // -- Data members ------------------------------------------------------- 70 | // ======================================================================= 71 | protected: 72 | 73 | FeIndex _index; 74 | FeID _feID; 75 | std::string _fePath; 76 | unsigned int _dvbVersion; 77 | }; 78 | 79 | } 80 | 81 | #endif // INPUT_DVB_DELIVERY_SYSTEM_H_INCLUDE 82 | -------------------------------------------------------------------------------- /src/input/dvb/dvbfix.h: -------------------------------------------------------------------------------- 1 | /* dvbfix.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef DVB_FIX_H_INCLUDE 21 | #define DVB_FIX_H_INCLUDE DVB_FIX_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #define FULL_DVB_API_VERSION ((DVB_API_VERSION << 8) | DVB_API_VERSION_MINOR) 28 | 29 | #if FULL_DVB_API_VERSION < 0x0500 30 | #error Not correct DVB_API_VERSION should be >= 5.0 31 | #endif 32 | 33 | #if FULL_DVB_API_VERSION < 0x0505 34 | #define DTV_ENUM_DELSYS 44 35 | #define NOT_PREFERRED_DVB_API 1 36 | #endif 37 | 38 | #ifdef DEFINE_SYS_DVBS2X 39 | #define SYS_DVBS2X static_cast(21) 40 | #endif 41 | 42 | #ifndef DTV_STREAM_ID 43 | #define DTV_STREAM_ID 42 44 | #endif 45 | 46 | #ifndef DTV_SCRAMBLING_SEQUENCE_INDEX 47 | #define DTV_SCRAMBLING_SEQUENCE_INDEX 70 48 | #endif 49 | 50 | // DMX_SET_SOURCE ioclt and dmx_source enum are removed from Kernel 4.14 and onwards 51 | // Check commit 13adefbe9e566c6db91579e4ce17f1e5193d6f2c 52 | #ifndef DMX_SET_SOURCE 53 | enum dmx_source { 54 | DMX_SOURCE_FRONT0 = 0, 55 | DMX_SOURCE_FRONT1, 56 | DMX_SOURCE_FRONT2, 57 | DMX_SOURCE_FRONT3, 58 | DMX_SOURCE_DVR0 = 16, 59 | DMX_SOURCE_DVR1, 60 | DMX_SOURCE_DVR2, 61 | DMX_SOURCE_DVR3 62 | }; 63 | #define DMX_SET_SOURCE _IOW('o', 49, enum dmx_source) 64 | #endif 65 | 66 | #endif // DVB_FIX_H_INCLUDE 67 | -------------------------------------------------------------------------------- /src/input/file/TSReaderData.cpp: -------------------------------------------------------------------------------- 1 | /* TSReaderData.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace input::file { 28 | 29 | // ============================================================================= 30 | // -- Constructors and destructor ---------------------------------------------- 31 | // ============================================================================= 32 | 33 | TSReaderData::TSReaderData() { 34 | doInitialize(); 35 | } 36 | 37 | TSReaderData::~TSReaderData() {} 38 | 39 | // ============================================================================= 40 | // -- input::DeviceData -------------------------------------------------------- 41 | // ============================================================================= 42 | 43 | void TSReaderData::doNextAddToXML(std::string &xml) const { 44 | ADD_XML_ELEMENT(xml, "pathname", _filePath); 45 | } 46 | 47 | void TSReaderData::doNextFromXML(const std::string &UNUSED(xml)) {} 48 | 49 | void TSReaderData::doInitialize() { 50 | _filePath = "None"; 51 | } 52 | 53 | void TSReaderData::doParseStreamString(const FeID UNUSED(id), const TransportParamVector& params) { 54 | const std::string filePath = params.getURIParameter("uri"); 55 | if (filePath.empty() || (hasFilePath() && filePath == _filePath)) { 56 | return; 57 | } 58 | initialize(); 59 | _frequencyChanged = true; 60 | _filePath = filePath; 61 | } 62 | 63 | std::string TSReaderData::doAttributeDescribeString(const FeID id) const { 64 | std::string desc; 65 | // ver=1.5;tuner=,,,;uri= 66 | return StringConverter::stringFormat("ver=1.5;tuner=@#1,@#2,@#3,@#4;uri=@#5", 67 | id, getSignalStrength(), hasLock(), 68 | getSignalToNoiseRatio(), _filePath); 69 | return desc; 70 | } 71 | 72 | // ============================================================================= 73 | // -- Other member functions -------------------------------------------------- 74 | // ============================================================================= 75 | 76 | std::string TSReaderData::getFilePath() const { 77 | base::MutexLock lock(_mutex); 78 | return _filePath; 79 | } 80 | 81 | bool TSReaderData::hasFilePath() const { 82 | base::MutexLock lock(_mutex); 83 | return _filePath != "None"; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/input/file/TSReaderData.h: -------------------------------------------------------------------------------- 1 | /* TSReaderData.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_FILE_TSREADER_DATA_H_INCLUDE 21 | #define INPUT_FILE_TSREADER_DATA_H_INCLUDE INPUT_FILE_TSREADER_DATA_H_INCLUDE 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace input::file { 28 | 29 | /// The class @c TSReaderData carries all the data/information for Reading 30 | /// from an file 31 | class TSReaderData : 32 | public DeviceData { 33 | // ========================================================================= 34 | // Constructors and destructor --------------------------------------------- 35 | // ========================================================================= 36 | public: 37 | 38 | TSReaderData(); 39 | 40 | virtual ~TSReaderData(); 41 | 42 | // ========================================================================= 43 | // -- input::DeviceData ---------------------------------------------------- 44 | // ========================================================================= 45 | private: 46 | 47 | /// @see DeviceData 48 | virtual void doNextAddToXML(std::string &xml) const final; 49 | 50 | /// @see DeviceData 51 | virtual void doNextFromXML(const std::string &xml) final; 52 | 53 | /// @see DeviceData 54 | virtual void doInitialize() final; 55 | 56 | /// @see DeviceData 57 | virtual void doParseStreamString(FeID id, const TransportParamVector& params) final; 58 | 59 | /// @see DeviceData 60 | virtual std::string doAttributeDescribeString(FeID id) const final; 61 | 62 | // ========================================================================= 63 | // -- Other member functions ---------------------------------------------- 64 | // ========================================================================= 65 | public: 66 | 67 | /// 68 | std::string getFilePath() const; 69 | 70 | bool hasFilePath() const; 71 | 72 | // ========================================================================= 73 | // -- Data members --------------------------------------------------------- 74 | // ========================================================================= 75 | private: 76 | 77 | std::string _filePath; 78 | 79 | }; 80 | 81 | } 82 | 83 | #endif // INPUT_FILE_TSREADER_DATA_H_INCLUDE 84 | -------------------------------------------------------------------------------- /src/input/stream/StreamerData.cpp: -------------------------------------------------------------------------------- 1 | /* StreamerData.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace input::stream { 28 | 29 | // ============================================================================= 30 | // -- Constructors and destructor ---------------------------------------------- 31 | // ============================================================================= 32 | 33 | StreamerData::StreamerData() { 34 | doInitialize(); 35 | } 36 | 37 | StreamerData::~StreamerData() {} 38 | 39 | // ============================================================================= 40 | // -- input::DeviceData -------------------------------------------------------- 41 | // ============================================================================= 42 | 43 | void StreamerData::doNextAddToXML(std::string &xml) const { 44 | ADD_XML_ELEMENT(xml, "pathname", _uri); 45 | } 46 | 47 | void StreamerData::doNextFromXML(const std::string &UNUSED(xml)) {} 48 | 49 | void StreamerData::doInitialize() { 50 | _uri = "None"; 51 | _multiAddr = "0.0.0.0"; 52 | _port = 0; 53 | _udp = false; 54 | } 55 | 56 | void StreamerData::doParseStreamString(const FeID id, const TransportParamVector& params) { 57 | const std::string uri = params.getURIParameter("uri"); 58 | if (uri.empty() || (hasFilePath() && uri == _uri)) { 59 | parseAndUpdatePidsTable(id, params); 60 | return; 61 | } 62 | initialize(); 63 | _frequencyChanged = true; 64 | _uri = uri; 65 | 66 | // Parse uri ex. udp@224.0.1.3:1234 67 | _udp = _uri.find("udp") != std::string::npos; 68 | std::string::size_type begin = _uri.find("@"); 69 | if (begin != std::string::npos) { 70 | std::string::size_type end = _uri.find_first_of(":", begin); 71 | if (end != std::string::npos) { 72 | begin += 1; 73 | _multiAddr = _uri.substr(begin, end - begin); 74 | begin = end + 1; 75 | end = _uri.size(); 76 | _port = std::stoi(_uri.substr(begin, end - begin)); 77 | } 78 | } 79 | parseAndUpdatePidsTable(id, params); 80 | } 81 | 82 | std::string StreamerData::doAttributeDescribeString(const FeID id) const { 83 | std::string desc; 84 | // ver=1.5;tuner=,,,;uri= 85 | return StringConverter::stringFormat("ver=1.5;tuner=@#1,@#2,@#3,@#4;uri=@#5", 86 | id, getSignalStrength(), hasLock(), 87 | getSignalToNoiseRatio(), _uri); 88 | return desc; 89 | } 90 | 91 | // ============================================================================= 92 | // -- Other member functions -------------------------------------------------- 93 | // ============================================================================= 94 | 95 | std::string StreamerData::getMultiAddr() const { 96 | base::MutexLock lock(_mutex); 97 | return _multiAddr; 98 | } 99 | 100 | int StreamerData::getPort() const { 101 | base::MutexLock lock(_mutex); 102 | return _port; 103 | } 104 | 105 | bool StreamerData::hasFilePath() const { 106 | base::MutexLock lock(_mutex); 107 | return _uri != "None"; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/input/stream/StreamerData.h: -------------------------------------------------------------------------------- 1 | /* StreamerData.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef INPUT_STREAM_STREAMER_DATA_H_INCLUDE 21 | #define INPUT_STREAM_STREAMER_DATA_H_INCLUDE INPUT_STREAM_STREAMER_DATA_H_INCLUDE 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace input::stream { 28 | 29 | /// The class @c StreamerData carries all the data/information for Reading 30 | /// from an Child PIPE 31 | class StreamerData : 32 | public DeviceData { 33 | // ========================================================================= 34 | // Constructors and destructor --------------------------------------------- 35 | // ========================================================================= 36 | public: 37 | 38 | StreamerData(); 39 | 40 | virtual ~StreamerData(); 41 | 42 | // ========================================================================= 43 | // -- input::DeviceData ---------------------------------------------------- 44 | // ========================================================================= 45 | private: 46 | 47 | /// @see DeviceData 48 | virtual void doNextAddToXML(std::string &xml) const final; 49 | 50 | /// @see DeviceData 51 | virtual void doNextFromXML(const std::string &xml) final; 52 | 53 | /// @see DeviceData 54 | virtual void doInitialize() final; 55 | 56 | /// @see DeviceData 57 | virtual void doParseStreamString(FeID id, const TransportParamVector& params) final; 58 | 59 | /// @see DeviceData 60 | virtual std::string doAttributeDescribeString(FeID id) const final; 61 | 62 | /// @see DeviceData 63 | virtual bool capableOfInternalFiltering() const final { 64 | return true; 65 | } 66 | 67 | // ========================================================================= 68 | // -- Other member functions ---------------------------------------------- 69 | // ========================================================================= 70 | public: 71 | 72 | /// 73 | std::string getMultiAddr() const; 74 | 75 | int getPort() const; 76 | 77 | bool hasFilePath() const; 78 | 79 | // ========================================================================= 80 | // -- Data members --------------------------------------------------------- 81 | // ========================================================================= 82 | 83 | private: 84 | 85 | std::string _uri; 86 | std::string _multiAddr; 87 | int _port; 88 | bool _udp; 89 | 90 | }; 91 | 92 | } 93 | 94 | #endif // INPUT_STREAM_STREAMER_DATA_H_INCLUDE 95 | -------------------------------------------------------------------------------- /src/mpegts/Generator.cpp: -------------------------------------------------------------------------------- 1 | /* Generator.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace mpegts { 32 | 33 | // ============================================================================= 34 | // -- Constructors and destructor ---------------------------------------------- 35 | // ============================================================================= 36 | 37 | Generator::Generator() { 38 | _pat = std::make_shared(); 39 | _pcr = std::make_shared(); 40 | _pmt = std::make_shared(); 41 | _sdt = std::make_shared(); 42 | } 43 | 44 | // ============================================================================= 45 | // -- Other member functions -------------------------------------------------- 46 | // ============================================================================= 47 | 48 | TSData Generator::generatePSIFrom( 49 | FeID id, const base::M3UParser::TransformationMap &info) { 50 | TSData pat = _pat->generateFrom(id, info); 51 | 52 | 53 | return pat; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/mpegts/Generator.h: -------------------------------------------------------------------------------- 1 | /* Generator.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef MPEGTS_GENERATOR_H_INCLUDE 21 | #define MPEGTS_GENERATOR_H_INCLUDE MPEGTS_GENERATOR_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | FW_DECL_NS1(mpegts, PacketBuffer); 35 | 36 | namespace mpegts { 37 | 38 | /// The class @c Generator will generate PSI metadata for a given TransformationMap 39 | class Generator { 40 | // ========================================================================= 41 | // -- Constructors and destructor ----------------------------------------- 42 | // ========================================================================= 43 | public: 44 | 45 | Generator(); 46 | 47 | virtual ~Generator() = default; 48 | 49 | // ========================================================================= 50 | // -- Other member functions ---------------------------------------------- 51 | // ========================================================================= 52 | public: 53 | 54 | /// This will generate PSI metadata for the given TransformationMap 55 | /// @param feID specifies the frontend ID 56 | /// @param info specifies the info for generating the PSI metadata 57 | TSData generatePSIFrom( 58 | FeID id, const base::M3UParser::TransformationMap &info); 59 | 60 | // ========================================================================= 61 | // -- Data members -------------------------------------------------------- 62 | // ========================================================================= 63 | private: 64 | 65 | mutable base::Mutex _mutex; 66 | 67 | mutable mpegts::SpNIT _nit; 68 | mutable mpegts::SpPAT _pat; 69 | mutable mpegts::SpPCR _pcr; 70 | mutable mpegts::SpPMT _pmt; 71 | mutable mpegts::SpSDT _sdt; 72 | }; 73 | 74 | } 75 | 76 | #endif // MPEGTS_GENERATOR_H_INCLUDE 77 | -------------------------------------------------------------------------------- /src/mpegts/NIT.h: -------------------------------------------------------------------------------- 1 | /* NIT.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef MPEGTS_NIT_DATA_H_INCLUDE 21 | #define MPEGTS_NIT_DATA_H_INCLUDE MPEGTS_NIT_DATA_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | FW_DECL_SP_NS1(mpegts, NIT); 32 | 33 | namespace mpegts { 34 | 35 | class NIT : 36 | public TableData, 37 | public base::XMLSupport { 38 | // ========================================================================= 39 | // -- Constructors and destructor ------------------------------------------ 40 | // ========================================================================= 41 | public: 42 | 43 | NIT() = default; 44 | 45 | virtual ~NIT() = default; 46 | 47 | // ========================================================================= 48 | // -- mpegts::TableData ---------------------------------------------------- 49 | // ========================================================================= 50 | public: 51 | 52 | virtual void clear() noexcept final; 53 | 54 | // ========================================================================= 55 | // -- base::XMLSupport ----------------------------------------------------- 56 | // ========================================================================= 57 | private: 58 | 59 | /// @see XMLSupport 60 | virtual void doAddToXML(std::string &xml) const final; 61 | 62 | /// @see XMLSupport 63 | virtual void doFromXML(const std::string &xml) final; 64 | 65 | // ========================================================================= 66 | // -- Other member functions ---------------------------------------------- 67 | // ========================================================================= 68 | public: 69 | 70 | void parse(FeID id); 71 | 72 | TSData generateFrom( 73 | FeID id, const base::M3UParser::TransformationMap &info); 74 | 75 | // ========================================================================= 76 | // -- Data members -------------------------------------------------------- 77 | // ========================================================================= 78 | private: 79 | 80 | uint16_t _nid = 0; 81 | std::string _networkName; 82 | struct Data { 83 | uint16_t transportStreamID; 84 | uint16_t originalNetworkID; 85 | std::string freq; 86 | std::string mtype; 87 | std::string msys; 88 | std::string srate; 89 | std::string fec; 90 | std::string fecOut; 91 | std::string rolloff; 92 | std::string inversion; 93 | std::string pilot; 94 | std::string pol; 95 | }; 96 | std::vector _table; 97 | 98 | }; 99 | 100 | } 101 | 102 | #endif // MPEGTS_NIT_DATA_H_INCLUDE 103 | -------------------------------------------------------------------------------- /src/mpegts/PAT.h: -------------------------------------------------------------------------------- 1 | /* PAT.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef MPEGTS_PAT_DATA_H_INCLUDE 21 | #define MPEGTS_PAT_DATA_H_INCLUDE MPEGTS_PAT_DATA_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | FW_DECL_SP_NS1(mpegts, PAT); 32 | 33 | namespace mpegts { 34 | 35 | class PAT : 36 | public TableData, 37 | public base::XMLSupport { 38 | // ========================================================================= 39 | // -- Constructors and destructor ------------------------------------------ 40 | // ========================================================================= 41 | public: 42 | 43 | PAT() = default; 44 | 45 | virtual ~PAT() = default; 46 | 47 | // ========================================================================= 48 | // -- mpegts::TableData ---------------------------------------------------- 49 | // ========================================================================= 50 | public: 51 | 52 | virtual void clear() noexcept final; 53 | 54 | // ========================================================================= 55 | // -- base::XMLSupport ----------------------------------------------------- 56 | // ========================================================================= 57 | private: 58 | 59 | /// @see XMLSupport 60 | virtual void doAddToXML(std::string &xml) const final; 61 | 62 | /// @see XMLSupport 63 | virtual void doFromXML(const std::string &xml) final; 64 | 65 | // ========================================================================= 66 | // -- Other member functions ---------------------------------------------- 67 | // ========================================================================= 68 | public: 69 | 70 | void parse(FeID id); 71 | 72 | bool isMarkedAsPMT(const int pid) const noexcept { 73 | const auto s = _pmtPidTable.find(pid); 74 | if (s != _pmtPidTable.end()) { 75 | return s->second; 76 | } 77 | return false; 78 | } 79 | 80 | TSData generateFrom( 81 | FeID id, const base::M3UParser::TransformationMap &info); 82 | 83 | // ========================================================================= 84 | // -- Data members ------------------------------------------------------- 85 | // ========================================================================= 86 | private: 87 | 88 | uint16_t _tid = 0; 89 | std::unordered_map _pmtPidTable; 90 | }; 91 | 92 | } 93 | 94 | #endif // MPEGTS_PAT_DATA_H_INCLUDE 95 | -------------------------------------------------------------------------------- /src/mpegts/PCR.cpp: -------------------------------------------------------------------------------- 1 | /* PCR.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace mpegts { 26 | 27 | // ============================================================================= 28 | // -- Other member functions -------------------------------------------------- 29 | // ============================================================================= 30 | 31 | void PCR::collectData(const FeID UNUSED(id), const unsigned char* data) { 32 | if (isPCRTableData(data)) { 33 | // 4 3 2 1 0 34 | // 76543210 98765432 10987654 32109876 54321098 76543210 35 | // xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xRRRRRRx xxxxxxxx 36 | // 21098765 43210987 65432109 87654321 0 8 76543210 37 | // 3 2 1 0 0 38 | // b6 b7 b8 b9 b10 b11 39 | // PCR Base runs with 90KHz and PCR Ext runs with 27MHz 40 | #define PCR_BASE(DATA) static_cast(DATA[6] << 24 | DATA[7] << 16 | DATA[8] << 8 | DATA[9]) << 1 41 | #define PCR_EXT(DATA) static_cast((DATA[10] & 0x01 << 8) | DATA[11]) 42 | 43 | const uint64_t pcrCur = PCR_BASE(data); 44 | 45 | _pcrDelta = pcrCur - _pcrPrev; 46 | _pcrPrev = pcrCur; 47 | if (_pcrDelta < 0) { 48 | _pcrDelta = 1; 49 | } 50 | if (_pcrDelta > 75000) { 51 | _pcrDelta = 75000; 52 | } 53 | _pcrDelta *= 11; // 11 -> PCR_Base runs with 90KHz 54 | #undef PCR_BASE 55 | #undef PCR_EXT 56 | } 57 | } 58 | 59 | std::int64_t PCR::getPCRDelta() const { 60 | return _pcrDelta; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/mpegts/PCR.h: -------------------------------------------------------------------------------- 1 | /* PCR.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef MPEGTS_PCR_DATA_H_INCLUDE 21 | #define MPEGTS_PCR_DATA_H_INCLUDE MPEGTS_PCR_DATA_H_INCLUDE 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | FW_DECL_SP_NS1(mpegts, PCR); 29 | 30 | namespace mpegts { 31 | 32 | class PCR { 33 | // ========================================================================= 34 | // -- Constructors and destructor ------------------------------------------ 35 | // ========================================================================= 36 | public: 37 | 38 | PCR() = default; 39 | 40 | virtual ~PCR() = default; 41 | 42 | // ========================================================================= 43 | // -- Static member functions --------------------------------------------- 44 | // ========================================================================= 45 | public: 46 | 47 | /// This will check for 'adaptation field flag' and 'PCR field present' to 48 | /// indicate this is an PCR table 49 | static bool isPCRTableData(const unsigned char* data) { 50 | return ((data[3] & 0x20) == 0x20 && (data[5] & 0x10) == 0x10); 51 | } 52 | 53 | // ========================================================================= 54 | // -- Other member functions ---------------------------------------------- 55 | // ========================================================================= 56 | public: 57 | 58 | /// Collect Table data for tableID 59 | void collectData(FeID id, const unsigned char* data); 60 | 61 | std::int64_t getPCRDelta() const; 62 | 63 | void clearPCRDelta() { 64 | _pcrDelta = 0; 65 | } 66 | 67 | // ========================================================================= 68 | // -- Data members -------------------------------------------------------- 69 | // ========================================================================= 70 | private: 71 | 72 | std::uint64_t _pcrPrev = 0; 73 | std::int64_t _pcrDelta = 0; 74 | }; 75 | 76 | } 77 | 78 | #endif // MPEGTS_PCR_DATA_H_INCLUDE 79 | -------------------------------------------------------------------------------- /src/mpegts/PidTable.cpp: -------------------------------------------------------------------------------- 1 | /* PidTable.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace mpegts { 27 | 28 | // ============================================================================= 29 | // -- Constructors and destructor ---------------------------------------------- 30 | // ============================================================================= 31 | PidTable::PidTable() noexcept { 32 | for (size_t i = 0; i < MAX_PIDS; ++i) { 33 | resetPidData(i); 34 | } 35 | _changed = false; 36 | _totalCCErrors = 0; 37 | _totalCCErrorsBegin = 0; 38 | _totalCCErrorsBeginSet = false; 39 | } 40 | 41 | // ============================================================================= 42 | // -- Other member functions -------------------------------------------------- 43 | // ============================================================================= 44 | void PidTable::clear() noexcept { 45 | _changed = false; 46 | _totalCCErrorsBegin = 0; 47 | _totalCCErrorsBeginSet = false; 48 | for (size_t i = 0; i < MAX_PIDS; ++i) { 49 | // Check PID still open. 50 | // Then set PID not used, to handle and close them later 51 | if (_data[i].state != State::Closed && _data[i].state != State::ShouldOpen) { 52 | setPID(i, false); 53 | } else { 54 | resetPidData(i); 55 | } 56 | } 57 | } 58 | 59 | void PidTable::resetPidData(const int pid) noexcept { 60 | _data[pid].state = State::Closed; 61 | _data[pid].cc = 0x80; 62 | _data[pid].cc_error = 0; 63 | _data[pid].count = 0; 64 | } 65 | 66 | std::string PidTable::getPidCSV() const { 67 | if (_data[ALL_PIDS].state == State::Opened) { 68 | return "all"; 69 | } 70 | std::string csv; 71 | for (size_t i = 0; i < MAX_PIDS; ++i) { 72 | if (_data[i].state == State::Opened) { 73 | csv += StringConverter::stringFormat("@#1,", i); 74 | } 75 | } 76 | if (csv.size() > 1) { 77 | csv.erase(csv.end() - 1); 78 | return csv; 79 | } 80 | return ""; 81 | } 82 | 83 | void PidTable::setPID(const int pid, const bool use) noexcept { 84 | switch (_data[pid].state) { 85 | case State::Closed: 86 | if (use) { 87 | _data[pid].state = State::ShouldOpen; 88 | _changed = true; 89 | } 90 | break; 91 | case State::ShouldClose: 92 | if (use) { 93 | _data[pid].state = State::ShouldCloseReopen; 94 | _changed = true; 95 | } 96 | break; 97 | case State::Opened: 98 | if (!use) { 99 | _data[pid].state = State::ShouldClose; 100 | _changed = true; 101 | } 102 | break; 103 | default: 104 | // Nothing to do here 105 | break; 106 | } 107 | } 108 | 109 | void PidTable::setPIDClosed(const int pid) noexcept { 110 | switch (_data[pid].state) { 111 | case State::ShouldCloseReopen: 112 | _data[pid].state = State::ShouldOpen; 113 | _changed = true; 114 | break; 115 | default: 116 | _data[pid].state = State::Closed; 117 | break; 118 | } 119 | _data[pid].cc = 0x80; 120 | _data[pid].cc_error = 0; 121 | _data[pid].count = 0; 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /src/mpegts/SDT.h: -------------------------------------------------------------------------------- 1 | /* SDT.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef MPEGTS_SDT_DATA_H_INCLUDE 21 | #define MPEGTS_SDT_DATA_H_INCLUDE MPEGTS_SDT_DATA_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | FW_DECL_SP_NS1(mpegts, SDT); 31 | 32 | namespace mpegts { 33 | 34 | class SDT : 35 | public TableData, 36 | public base::XMLSupport { 37 | // ========================================================================= 38 | // -- Forward declaration -------------------------------------------------- 39 | // ========================================================================= 40 | public: 41 | 42 | struct Data; 43 | 44 | // ========================================================================= 45 | // -- Constructors and destructor ------------------------------------------ 46 | // ========================================================================= 47 | public: 48 | 49 | SDT() = default; 50 | 51 | virtual ~SDT() = default; 52 | 53 | // ========================================================================= 54 | // -- mpegts::TableData ---------------------------------------------------- 55 | // ========================================================================= 56 | public: 57 | 58 | virtual void clear() noexcept final; 59 | 60 | // ========================================================================= 61 | // -- base::XMLSupport ----------------------------------------------------- 62 | // ========================================================================= 63 | private: 64 | 65 | /// @see XMLSupport 66 | virtual void doAddToXML(std::string &xml) const final; 67 | 68 | /// @see XMLSupport 69 | virtual void doFromXML(const std::string &xml) final; 70 | 71 | // ========================================================================= 72 | // -- Other member functions ---------------------------------------------- 73 | // ========================================================================= 74 | public: 75 | 76 | void parse(FeID id); 77 | 78 | int getTransportStreamID() const noexcept { 79 | return _transportStreamID; 80 | } 81 | 82 | int getNetworkID() const noexcept { 83 | return _networkID; 84 | } 85 | 86 | SDT::Data getSDTDataFor(int progID) const; 87 | 88 | protected: 89 | 90 | void copyToUTF8(std::string& str, const unsigned char* ptr, std::size_t len); 91 | 92 | // ========================================================================= 93 | // -- Data members -------------------------------------------------------- 94 | // ========================================================================= 95 | public: 96 | 97 | struct Data { 98 | std::string networkNameUTF8; 99 | std::string channelNameUTF8; 100 | }; 101 | 102 | private: 103 | 104 | int _transportStreamID = 0; 105 | int _networkID = 0; 106 | std::map _sdtTable; 107 | 108 | }; 109 | 110 | } 111 | 112 | #endif // MPEGTS_SDT_DATA_H_INCLUDE 113 | -------------------------------------------------------------------------------- /src/output/StreamClientOutputHttp.cpp: -------------------------------------------------------------------------------- 1 | /* StreamClientOutputHttp.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | namespace output { 23 | 24 | // ============================================================================= 25 | // -- StreamClient ------------------------------------------------------------- 26 | // ============================================================================= 27 | 28 | bool StreamClientOutputHttp::doProcessStreamingRequest(const SocketClient& client) { 29 | _sessionTimeoutCheck = StreamClient::SessionTimeoutCheck::FILE_DESCRIPTOR; 30 | _ipAddressOfStream = client.getIPAddressOfSocket(); 31 | return true; 32 | } 33 | 34 | void StreamClientOutputHttp::doStartStreaming() { 35 | // Get default buffer size and set it x times as big 36 | const int bufferSize = getHttpNetworkSendBufferSize() * 2; 37 | setHttpNetworkSendBufferSize(bufferSize); 38 | SI_LOG_INFO("Frontend: @#1, HTTP set network buffer size: @#2 KBytes", _feID, 39 | bufferSize / 1024); 40 | SI_LOG_INFO("Frontend: @#1, Start HTTP stream to @#2:@#3", _feID, 41 | _ipAddressOfStream, getHttpSocketPort()); 42 | } 43 | 44 | void StreamClientOutputHttp::doTeardown() { 45 | SI_LOG_INFO("Frontend: @#1, Stop HTTP stream to @#2:@#3", _feID, 46 | _ipAddressOfStream, getHttpSocketPort()); 47 | } 48 | 49 | bool StreamClientOutputHttp::doWriteData(mpegts::PacketBuffer& buffer) { 50 | const size_t dataSize = buffer.getCurrentBufferSize(); 51 | iovec iovHTTP[1]; 52 | iovHTTP[0].iov_base = buffer.getTSReadBufferPtr(); 53 | iovHTTP[0].iov_len = dataSize; 54 | // send the HTTP packet 55 | if (!writeHttpData(iovHTTP, 1)) { 56 | if (!isSelfDestructing()) { 57 | SI_LOG_ERROR("Frontend: @#1, Error sending HTTP Stream Data to @#2:@#3", _feID, 58 | _ipAddressOfStream, getHttpSocketPort()); 59 | selfDestruct(); 60 | } 61 | } 62 | return true; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/output/StreamClientOutputHttp.h: -------------------------------------------------------------------------------- 1 | /* StreamClientOutputHttp.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef STREAM_CLIENT_OUTPUT_HTTP_H_INCLUDE 21 | #define STREAM_CLIENT_OUTPUT_HTTP_H_INCLUDE STREAM_CLIENT_OUTPUT_HTTP_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | FW_DECL_SP_NS1(output, StreamClientOutputHttp); 28 | 29 | namespace output { 30 | 31 | /// StreamClient defines the owner/participants of an stream 32 | class StreamClientOutputHttp : public output::StreamClient { 33 | public: 34 | 35 | // ========================================================================= 36 | // -- Constructors and destructor ------------------------------------------ 37 | // ========================================================================= 38 | public: 39 | 40 | StreamClientOutputHttp(FeID feID) : StreamClient(feID) {}; 41 | 42 | virtual ~StreamClientOutputHttp() = default; 43 | 44 | // ========================================================================= 45 | // -- static member functions ---------------------------------------------- 46 | // ========================================================================= 47 | public: 48 | 49 | static SpStreamClientOutputHttp makeSP(); 50 | template 51 | static SpStreamClient makeSP(ARGS&&... args) { 52 | return std::make_shared(std::forward(args)...); 53 | } 54 | 55 | // ========================================================================= 56 | // -- StreamClient --------------------------------------------------------- 57 | // ========================================================================= 58 | private: 59 | 60 | /// Specialization for @see processStreamingRequest 61 | virtual bool doProcessStreamingRequest(const SocketClient& client) final; 62 | 63 | /// Specialization for @see startStreaming 64 | virtual void doStartStreaming() final; 65 | 66 | /// Specialization for @see teardown 67 | virtual void doTeardown() final; 68 | 69 | /// Specialization for @see writeData 70 | virtual bool doWriteData(mpegts::PacketBuffer& buffer) final; 71 | 72 | // ========================================================================= 73 | // -- Data members --------------------------------------------------------- 74 | // ========================================================================= 75 | private: 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/output/StreamClientOutputRtp.h: -------------------------------------------------------------------------------- 1 | /* StreamClientOutputRtp.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef STREAM_CLIENT_OUTPUT_RTP_H_INCLUDE 21 | #define STREAM_CLIENT_OUTPUT_RTP_H_INCLUDE STREAM_CLIENT_OUTPUT_RTPs_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | FW_DECL_SP_NS1(output, StreamClientOutputRtp); 28 | 29 | namespace output { 30 | 31 | /// StreamClient defines the owner/participants of an stream 32 | class StreamClientOutputRtp : public output::StreamClient { 33 | public: 34 | 35 | // ========================================================================= 36 | // -- Constructors and destructor ------------------------------------------ 37 | // ========================================================================= 38 | public: 39 | 40 | StreamClientOutputRtp(FeID feID, bool multicast) : StreamClient(feID), _multicast(multicast) {} 41 | 42 | virtual ~StreamClientOutputRtp() = default; 43 | 44 | // ========================================================================= 45 | // -- static member functions ---------------------------------------------- 46 | // ========================================================================= 47 | public: 48 | 49 | template 50 | static SpStreamClient makeSP(ARGS&&... args) { 51 | return std::make_shared(std::forward(args)...); 52 | } 53 | 54 | // ========================================================================= 55 | // -- StreamClient --------------------------------------------------------- 56 | // ========================================================================= 57 | public: 58 | 59 | /// 60 | virtual std::string getSetupMethodReply(StreamID streamID) final; 61 | 62 | /// 63 | /// @param fmtp specifies the specific Media Format description Parameter 64 | virtual std::string getSDPMediaLevelString( 65 | StreamID streamID, 66 | const std::string& fmtp) const final; 67 | 68 | private: 69 | 70 | /// Specialization for @see processStreamingRequest 71 | virtual bool doProcessStreamingRequest(const SocketClient& client) final; 72 | 73 | /// Specialization for @see startStreaming 74 | virtual void doStartStreaming() final; 75 | 76 | /// Specialization for @see teardown 77 | virtual void doTeardown() final; 78 | 79 | /// Specialization for @see writeData 80 | virtual bool doWriteData(mpegts::PacketBuffer& buffer) final; 81 | 82 | /// Specialization for @see writeRTCPData 83 | virtual void doWriteRTCPData( 84 | const PacketPtr& sr, int srlen, 85 | const PacketPtr& sdes, int sdeslen, 86 | const PacketPtr& app, int applen); 87 | 88 | // ========================================================================= 89 | // -- Data members --------------------------------------------------------- 90 | // ========================================================================= 91 | private: 92 | 93 | bool _multicast; 94 | 95 | }; 96 | 97 | } 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/output/StreamClientOutputRtpTcp.h: -------------------------------------------------------------------------------- 1 | /* StreamClientOutputRtpTcp.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef STREAM_CLIENT_OUTPUT_RTP_TCP_H_INCLUDE 21 | #define STREAM_CLIENT_OUTPUT_RTP_TCP_H_INCLUDE STREAM_CLIENT_OUTPUT_RTP_TCP_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | FW_DECL_SP_NS1(output, StreamClientOutputRtpTcp); 28 | 29 | namespace output { 30 | 31 | /// StreamClient defines the owner/participants of an stream 32 | class StreamClientOutputRtpTcp : public output::StreamClient { 33 | public: 34 | 35 | // ========================================================================= 36 | // -- Constructors and destructor ------------------------------------------ 37 | // ========================================================================= 38 | public: 39 | 40 | StreamClientOutputRtpTcp(FeID feID) : StreamClient(feID) {}; 41 | 42 | virtual ~StreamClientOutputRtpTcp() = default; 43 | 44 | // ========================================================================= 45 | // -- static member functions ---------------------------------------------- 46 | // ========================================================================= 47 | public: 48 | 49 | template 50 | static SpStreamClient makeSP(ARGS&&... args) { 51 | return std::make_shared(std::forward(args)...); 52 | } 53 | 54 | // ========================================================================= 55 | // -- StreamClient --------------------------------------------------------- 56 | // ========================================================================= 57 | public: 58 | 59 | /// 60 | virtual std::string getSetupMethodReply(StreamID streamID) final; 61 | 62 | private: 63 | 64 | /// Specialization for @see processStreamingRequest 65 | virtual bool doProcessStreamingRequest(const SocketClient& client) final; 66 | 67 | /// Specialization for @see startStreaming 68 | virtual void doStartStreaming() final; 69 | 70 | /// Specialization for @see teardown 71 | virtual void doTeardown() final; 72 | 73 | /// Specialization for @see writeData 74 | virtual bool doWriteData(mpegts::PacketBuffer& buffer) final; 75 | 76 | /// Specialization for @see writeRTCPData 77 | virtual void doWriteRTCPData( 78 | const PacketPtr& sr, int srlen, 79 | const PacketPtr& sdes, int sdeslen, 80 | const PacketPtr& app, int applen); 81 | 82 | // ========================================================================= 83 | // -- Data members --------------------------------------------------------- 84 | // ========================================================================= 85 | private: 86 | 87 | }; 88 | 89 | } 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/socket/HttpcSocket.h: -------------------------------------------------------------------------------- 1 | /* HttpcSocket.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef HTTPC_SOCKET_H_INCLUDE 21 | #define HTTPC_SOCKET_H_INCLUDE HTTPC_SOCKET_H_INCLUDE 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | FW_DECL_NS0(SocketClient); 29 | 30 | /// HTTPC Socket related functions 31 | class HttpcSocket { 32 | public: 33 | 34 | static const int HTTPC_TIMEOUT; 35 | 36 | // ===================================================================== 37 | // -- Constructors and destructor ------------------------------------- 38 | // ===================================================================== 39 | HttpcSocket(); 40 | 41 | virtual ~HttpcSocket(); 42 | 43 | // ===================================================================== 44 | // -- Other member functions ------------------------------------------ 45 | // ===================================================================== 46 | 47 | protected: 48 | 49 | /// Receive an HTTP message from client 50 | /// @param client 51 | /// @param recv_flags 52 | /// @return the amount of bytes red 53 | ssize_t recvHttpcMessage(SocketClient &client, int recv_flags); 54 | 55 | /// Receive an HTTP message from client 56 | /// @param client 57 | /// @param recv_flags 58 | /// @param si_other 59 | /// @param addrlen 60 | /// @return the amount of bytes red 61 | ssize_t recvfromHttpcMessage(SocketClient &client, int recv_flags, 62 | struct sockaddr_in *si_other, socklen_t *addrlen); 63 | 64 | private: 65 | /// Main receive HTTP message from client 66 | ssize_t recv_recvfrom_httpc_message(SocketClient &client, int recv_flags, 67 | struct sockaddr_in *si_other, socklen_t *addrlen); 68 | 69 | }; 70 | 71 | #endif // HTTPC_SOCKET_H_INCLUDE 72 | -------------------------------------------------------------------------------- /src/socket/TcpSocket.h: -------------------------------------------------------------------------------- 1 | /* TcpSocket.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef SOCKET_TCPSOCKET_H_INCLUDE 21 | #define SOCKET_TCPSOCKET_H_INCLUDE SOCKET_TCPSOCKET_H_INCLUDE 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | FW_DECL_NS0(SocketClient); 30 | 31 | /// TCP Socket 32 | class TcpSocket : 33 | public HttpcSocket { 34 | // ===================================================================== 35 | // -- Constructors and destructor -------------------------------------- 36 | // ===================================================================== 37 | 38 | public: 39 | 40 | TcpSocket(int maxClients, const std::string &protocol); 41 | 42 | virtual ~TcpSocket(); 43 | 44 | // ===================================================================== 45 | // -- Other member functions ------------------------------------------ 46 | // ===================================================================== 47 | 48 | public: 49 | 50 | /// Call this function periodically to check for messages 51 | /// @param timeout specifies the timeout 'poll' should use 52 | int poll(int timeout); 53 | 54 | protected: 55 | 56 | /// Call this to initialize and setup this socket(s) 57 | virtual void initialize(const std::string &ipAddr, int port, bool nonblock); 58 | 59 | /// Callback function if an messages was received 60 | /// @param client specifies the client that sended the message etc. 61 | virtual bool process(SocketClient &client) = 0; 62 | 63 | /// Get the protocol string 64 | const std::string &getProtocolString() const { 65 | return _protocolString; 66 | } 67 | 68 | private: 69 | 70 | /// 71 | bool initServerSocket( 72 | const std::string &ipAddr, 73 | int port, 74 | int maxClients, 75 | bool nonblock); 76 | 77 | /// Accept an connection and save client IP address etc. 78 | bool acceptConnection(SocketClient &client, bool showLogInfo); 79 | 80 | // ===================================================================== 81 | // -- Data members ----------------------------------------------------- 82 | // ===================================================================== 83 | 84 | private: 85 | 86 | std::size_t _MAX_CLIENTS; // 87 | std::size_t _MAX_POLL; // 88 | struct pollfd *_pfd; // 89 | SocketAttr _server; // 90 | SocketClient *_client; // 91 | const std::string _protocolString;// 92 | 93 | }; 94 | 95 | #endif // SOCKET_TCPSOCKET_H_INCLUDE 96 | -------------------------------------------------------------------------------- /src/socket/UdpSocket.cpp: -------------------------------------------------------------------------------- 1 | /* UdpSocket.cpp 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | bool UdpSocket::initUDPSocket( 32 | SocketClient& server, 33 | const std::string_view ipAddr, 34 | int port, 35 | int ttl) { 36 | // fill in the socket structure with host information 37 | server.setupSocketStructure(ipAddr, port, ttl); 38 | 39 | if (!server.setupSocketHandle(SOCK_DGRAM, IPPROTO_UDP)) { 40 | SI_LOG_ERROR("UDP Server handle failed"); 41 | return false; 42 | } 43 | return true; 44 | } 45 | 46 | bool UdpSocket::initMutlicastUDPSocket( 47 | SocketClient &server, 48 | const std::string &multicastIPAddr, 49 | const std::string &interfaceIPaddr, 50 | const int port, 51 | const int ttl) { 52 | // fill in the socket structure with host information 53 | server.setupSocketStructureWithAnyAddress(port, ttl); 54 | 55 | if (!server.setupSocketHandle(SOCK_DGRAM, IPPROTO_UDP)) { 56 | SI_LOG_ERROR("UDP Multicast Server handle failed"); 57 | return false; 58 | } 59 | 60 | // bind the socket to the port number 61 | if (!server.bind()) { 62 | SI_LOG_ERROR("UDP Multicast Bind failed"); 63 | return false; 64 | } 65 | 66 | // request that the kernel joins a multicast group 67 | struct ip_mreq mreq; 68 | mreq.imr_multiaddr.s_addr = inet_addr(multicastIPAddr.data()); 69 | mreq.imr_interface.s_addr = inet_addr(interfaceIPaddr.data()); 70 | if (setsockopt(server.getFD(), IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) == -1) { 71 | SI_LOG_PERROR("IP_ADD_MEMBERSHIP"); 72 | return false; 73 | } 74 | return true; 75 | } 76 | -------------------------------------------------------------------------------- /src/socket/UdpSocket.h: -------------------------------------------------------------------------------- 1 | /* UdpSocket.h 2 | 3 | Copyright (C) 2014 - 2023 Marc Postema (mpostema09 -at- gmail.com) 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | Or, point your browser to http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | #ifndef SOCKET_UDPSOCKET_H_INCLUDE 21 | #define SOCKET_UDPSOCKET_H_INCLUDE SOCKET_UDPSOCKET_H_INCLUDE 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | FW_DECL_NS0(SocketClient); 29 | 30 | /// UDP Socket 31 | class UdpSocket : 32 | public HttpcSocket { 33 | // ===================================================================== 34 | // -- Constructors and destructor -------------------------------------- 35 | // ===================================================================== 36 | public: 37 | 38 | UdpSocket() = default; 39 | 40 | virtual ~UdpSocket() = default; 41 | 42 | // ===================================================================== 43 | // -- Other member functions ------------------------------------------ 44 | // ===================================================================== 45 | public: 46 | 47 | /// Initialize an UDP socket 48 | /// @param server 49 | /// @param ipAddr 50 | /// @param port 51 | /// @param ttl 52 | bool initUDPSocket( 53 | SocketClient& server, 54 | std::string_view ipAddr, 55 | int port, 56 | int ttl); 57 | 58 | /// Initialize an Multicast UDP socket 59 | /// @param server 60 | /// @param multicastIPAddr 61 | /// @param port 62 | /// @param interfaceIPaddr 63 | /// @param ttl 64 | bool initMutlicastUDPSocket( 65 | SocketClient &server, 66 | const std::string &multicastIPAddr, 67 | const std::string &interfaceIPaddr, 68 | int port, 69 | int ttl); 70 | 71 | // ===================================================================== 72 | // -- Data members ----------------------------------------------------- 73 | // ===================================================================== 74 | private: 75 | 76 | }; 77 | 78 | #endif // SOCKET_UDPSOCKET_H_INCLUDE 79 | -------------------------------------------------------------------------------- /web/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 404 Not Found 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 |
22 |

404 Not Found

23 | 24 |
25 | 26 | 31 | 32 |
33 |
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /web/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | SAT>IP About Page 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 |
22 |

About

23 |
24 |
25 |

SatPI is an SAT>IP server which supports:
26 | DVB-C DVB-T/T2 and DVB-S/S2

27 | ==============================================

28 | Thanks go out to:

29 | Baris Altuncay for his contributions
30 | Axel Hartmann for kindly suppling hardware
31 | APfutura for kindly suppling hardware
32 | Impex-Sat GmbH & Co. KG for kindly suppling hardware
33 | All who have donated via the 'Sponsor' button on my github
34 | All who have tested this Software and gave feedback

35 |
36 | 37 | 42 |
43 |
44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /web/assets/css/stylesheet.css: -------------------------------------------------------------------------------- 1 | @import "bootstrap.min.css"; 2 | 3 | body { 4 | margin-top: 60px; 5 | margin-bottom: 60px; 6 | } 7 | 8 | .tab-content { 9 | height: 60vh; 10 | # padding: 0px; 11 | overflow: scroll; 12 | } 13 | 14 | .container-log { 15 | height: 500px; 16 | font-size: 10px; 17 | } 18 | 19 | textarea.logtext { 20 | background-image: url("../images/bg-grain.png"); 21 | font-size: 9px; 22 | height: 100%; 23 | overflow: scroll; 24 | resize: none; 25 | } 26 | 27 | .small-text-size { 28 | padding: 0px; 29 | font-size: 10px; 30 | } 31 | 32 | .table-text-size { 33 | font-size: 10px; 34 | } 35 | 36 | .window-start { 37 | text-align: center; 38 | padding: 0px; 39 | } 40 | 41 | .window-name { 42 | background-color: lightblue; 43 | text-align: center; 44 | padding: 0px; 45 | border: 2px solid #000; 46 | font-size: 15px; 47 | } 48 | 49 | .window-name > p { 50 | margin: 0; 51 | } 52 | -------------------------------------------------------------------------------- /web/assets/images/bg-grain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/assets/images/bg-grain.png -------------------------------------------------------------------------------- /web/assets/images/grid_noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/assets/images/grid_noise.png -------------------------------------------------------------------------------- /web/assets/images/icons/lr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/assets/images/icons/lr.png -------------------------------------------------------------------------------- /web/assets/images/icons/sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/assets/images/icons/sm.png -------------------------------------------------------------------------------- /web/assets/js/cookies.js: -------------------------------------------------------------------------------- 1 | function setCookie(cookieName, cookieValue, expireDays) { 2 | var date = new Date(); 3 | date.setTime(date.getTime() + (expireDays * 24 * 3600 * 1000)); 4 | var expireString = "expires=" + date.toUTCString(); 5 | document.cookie = cookieName + "=" + cookieValue + ";" + expireString + ";path=/"; 6 | } 7 | 8 | function getCookie(cookieName) { 9 | var searchCookieTag = cookieName + "="; 10 | var decodedCookie = decodeURIComponent(document.cookie); 11 | var cookieTagArray = decodedCookie.split(";"); 12 | for(var i = 0; i < cookieTagArray.length; ++i) { 13 | var cookieTag = cookieTagArray[i]; 14 | while (cookieTag.charAt(0) == ' ') { 15 | cookieTag = cookieTag.substring(1); 16 | } 17 | if (cookieTag.indexOf(searchCookieTag) == 0) { 18 | return cookieTag.substring(searchCookieTag.length, cookieTag.length); 19 | } 20 | } 21 | return ""; 22 | } 23 | -------------------------------------------------------------------------------- /web/assets/js/loadxmldoc.js: -------------------------------------------------------------------------------- 1 | var xmlLoaded; 2 | var filename; 3 | function loadXMLDoc(file) { 4 | if (window.XMLHttpRequest) { 5 | xmlhttp = new XMLHttpRequest(); 6 | } else if (window.ActiveXObject) { 7 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 8 | } else { 9 | throw new Error("Ajax is not supported by this browser"); 10 | } 11 | 12 | // callback function 13 | xmlhttp.onreadystatechange = function() { 14 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 15 | filename = file; 16 | xmlLoaded = xmlhttp.responseXML; 17 | xmlloaded(xmlhttp.responseXML); 18 | } 19 | } 20 | 21 | xmlhttp.open("GET", file, true); 22 | xmlhttp.send(); 23 | } 24 | 25 | function loadJSONDoc(filename) { 26 | if (window.XMLHttpRequest) { 27 | jsonhttp = new XMLHttpRequest(); 28 | } else if (window.ActiveXObject) { 29 | jsonhttp = new ActiveXObject("Microsoft.XMLHTTP"); 30 | } else { 31 | throw new Error("Ajax is not supported by this browser"); 32 | } 33 | 34 | // callback function 35 | jsonhttp.onreadystatechange = function() { 36 | if (jsonhttp.readyState == 4 && jsonhttp.status == 200) { 37 | jsonloaded(jsonhttp.responseText); 38 | } 39 | } 40 | 41 | jsonhttp.open("GET", filename, true); 42 | jsonhttp.send(); 43 | } 44 | -------------------------------------------------------------------------------- /web/assets/js/menu.js: -------------------------------------------------------------------------------- 1 | function buildmenu() { 2 | var menu = ""; 3 | menu += ""; 24 | return menu; 25 | } 26 | 27 | function setMenuItemActive(param) { 28 | var obj = document.getElementById(param); 29 | obj.className = "active"; 30 | } 31 | -------------------------------------------------------------------------------- /web/assets/js/postxmldoc.js: -------------------------------------------------------------------------------- 1 | function postData(filename, data) { 2 | //refresh_time = 2000; 3 | if (window.XMLHttpRequest) { 4 | xmlhttp_post = new XMLHttpRequest(); 5 | } else if (window.ActiveXObject) { 6 | xmlhttp_post = new ActiveXObject("Microsoft.XMLHTTP"); 7 | } else { 8 | throw new Error("Ajax is not supported by this browser"); 9 | } 10 | 11 | // callback function 12 | xmlhttp_post.onreadystatechange = function () { 13 | if (xmlhttp_post.readyState === 4) { 14 | if (xmlhttp_post.status == 200 && xmlhttp_post.status < 300) { 15 | alert("This is strange, should not happen"); 16 | } 17 | } 18 | } 19 | 20 | // specify our action, location and send to the server 21 | xmlhttp_post.open("POST", filename); 22 | xmlhttp_post.setRequestHeader("Content-Type", "text/xml"); 23 | xmlhttp_post.send(data); 24 | } 25 | -------------------------------------------------------------------------------- /web/assets/js/utils.js: -------------------------------------------------------------------------------- 1 | function buildStreamURL(xmlDoc, streamID) { 2 | var data = xmlDoc.querySelector(streamID + "delsys"); 3 | if (!data) { 4 | return ""; 5 | } 6 | var delsys = data.innerHTML; 7 | if (delsys == "UNKNOWN DELSYS") { 8 | return ""; 9 | } 10 | var url = "http://"; 11 | url += xmlDoc.querySelector("ipaddress").querySelector("value").innerHTML; 12 | url += ":"; 13 | url += xmlDoc.querySelector("httpport").querySelector("value").innerHTML; 14 | url += "/?"; 15 | url += "freq="; 16 | url += (xmlDoc.querySelector(streamID + "tunefreq").innerHTML / 1000); 17 | url += "&sr="; 18 | url += (xmlDoc.querySelector(streamID + "tunesymbol").innerHTML / 1000); 19 | url += "&msys="; 20 | url += delsys; 21 | url += "&mtype="; 22 | url += xmlDoc.querySelector(streamID + "modulation").innerHTML; 23 | url += "&fec="; 24 | url += xmlDoc.querySelector(streamID + "fec").innerHTML; 25 | if (delsys == "dvbc") { 26 | } else if (delsys == "dvbs" || delsys == "dvbs2") { 27 | url += "&pol="; 28 | url += xmlDoc.querySelector(streamID + "pol").innerHTML; 29 | url += "&src="; 30 | url += xmlDoc.querySelector(streamID + "src").innerHTML; 31 | } 32 | url += "&pids="; 33 | url += xmlDoc.querySelector(streamID + "pidcsv").innerHTML; 34 | return url; 35 | } 36 | -------------------------------------------------------------------------------- /web/assets/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/assets/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /web/channellist.m3u: -------------------------------------------------------------------------------- 1 | #EXTM3U 2 | 3 | #EXTINF:0,1. RTL4 HD 4 | rtsp://@#1/?src=2&fe=2&freq=11856&sr=27500&msys=dvbs2&mtype=8psk&pol=v&fec=23&pids=0,1,16,17,18,34,84,514,2520 5 | 6 | #EXTINF:0,2. RTL5 HD 7 | rtsp://@#1/?src=2&fe=2&freq=11856&sr=27500&msys=dvbs2&mtype=8psk&pol=v&fec=23&pids=0,1,16,17,18,33,83,523,2523 8 | 9 | #EXTINF:0,3. Veronica HD 10 | rtsp://@#1/?src=2&fe=2&freq=12187&sr=27500&msys=dvbs2&mtype=8psk&pol=h&fec=23&pids=0,1,16,17,18,37,105,517,2735 11 | 12 | #EXTINF:0,4. TV Noord 13 | rtsp://@#1/?src=2&fe=2&freq=11914&sr=29900&msys=dvbs2&mtype=8psk&pol=h&fec=23&pids=0,1,16,17,18,40,88,516,2310,8190 14 | 15 | #EXTINF:0,5. Animal Planet 16 | rtsp://@#1/?src=2&fe=2&freq=12109&sr=27500&msys=dvbs2&mtype=8psk&pol=h&fec=34&pids=0,1,16,17,18,57,3500,3510,3550,3660 17 | 18 | #EXTINF:0,6. Astra 23.5E NPO3 19 | rtsp://@#1/?src=2&freq=12187.50&sr=29900&msys=dvbs2&mtype=8psk&pol=h&fec=23&pids=0,1,16,17,18,38,52,106,518,2740 20 | 21 | #EXTINF:0,7. Astra 19.2E ARD-alpha HD 22 | rtsp://@#1/?src=1&freq=11052.75&sr=22000&msys=dvbs2&mtype=8psk&pol=h&fec=23&pids=0,1,16,17,18,1039,5420,5421,5424 23 | 24 | #EXTINF:0,8. Astra 19.2E CNBC Europe HD 25 | rtsp://@#1/?src=1&&freq=11170.75&sr=22000&msys=dvbs2&mtype=8psk&pol=h&fec=34&pids=0,1,16,17,18,103,2047,2051,2047 26 | 27 | #EXTINF:0,9. Astra 19.2E ZDF HD 28 | rtsp://@#1/?src=1&freq=11361.75&sr=22000&msys=dvbs2&mtype=8psk&pol=h&fec=23&pids=0,1,16,17,18,6100,6110,6122,6130 29 | 30 | #EXTINF:0,10. Astra 23.5E TV8 HD Slovakia 31 | rtsp://@#1/?src=2&freq=12363&sr=29500&msys=dvbs2&mtype=8psk&pol=v&fec=34&pids=0,1,16,17,18,3234,5504,5514,5524 32 | 33 | #EXTINF:0,11. Astra 23.5E Canal Digitaal Infokanal 34 | rtsp://@#1/?src=2&freq=11739&sr=29900&msys=dvbs2&mtype=8psk&pol=v&fec=23&pids=0,1,16,17,18,82,562,2462 35 | 36 | #EXTINF:0,12. Astra 23.5E SES UHD Demo 37 | rtsp://@#1/?src=2&freq=11778&sr=27500&msys=dvbs2&mtype=8psk&pol=v&fec=23&pids=0,1,16,17,18,511,512,1200 38 | 39 | #EXTINF:0,13. RTL 4 HD (DVB-C) 40 | rtsp://@#1/?fe=1&freq=458&sr=6900&msys=dvbc&mtype=256qam&fec=35&pids=0,1,16,17,18,103,2000,2001,2011,2012,2051,2101,2102,2103,8187 41 | 42 | #EXTINF:0,14. National Geographic HD (DVB-C) 43 | rtsp://@#1/?fe=1&freq=378&sr=6900&msys=dvbc&mtype=256qam&fec=35&pids=0,1,16,17,18,103,2000,2001,2011,2012,2051,8187 44 | 45 | #EXTINF:0,15. TV Noord (DVB-C) 46 | rtsp://@#1/?freq=418.00&sr=6900&msys=dvbc&mtype=256qam&fec=35&specinv=0&pids=0,1,16,17,18,103,2600,2601,2611 47 | 48 | #EXTINF:0,16. Astra 23.5E NPO1 49 | rtsp://@#1/?src=2&freq=12187.5&sr=29900&msys=dvbs2&mtype=8psk&fec=23&pol=h&pids=0,1,16,17,18,20,99,119,519,1809,2729 50 | -------------------------------------------------------------------------------- /web/channellist_de.m3u: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/channellist_de.m3u -------------------------------------------------------------------------------- /web/contact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | SAT>IP Contact Page 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 |
22 |

Contact

23 |
24 |
25 |

If you like to contact me, you can do so by sending an email to:

26 | mpostema09 -at- gmail.com

27 |
28 | 29 | 34 |
35 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /web/desc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 1 6 | 7 | 8 | urn:ses-com:device:SatIPServer:1 9 | 10 | @#1 11 | 12 | Marc Postema 13 | https://github.com/Barracuda09/SATPI 14 | SatPI is a SAT>IP Server for Linux 15 | 16 | @#1 17 | 18 | @#2 19 | 20 | https://github.com/Barracuda09/SATPI 21 | 1S81A31231000007 22 | 23 | uuid:@#3 24 | 25 | 123456789012 26 | 27 | 28 | image/png 29 | 48 30 | 48 31 | 24 32 | /assets/images/icons/sm.png 33 | 34 | 35 | image/png 36 | 120 37 | 120 38 | 24 39 | /assets/images/icons/lr.png 40 | 41 | 42 | image/jpeg 43 | 48 44 | 48 45 | 24 46 | /assets/images/icons/sm.jpg 47 | 48 | 49 | image/jpeg 50 | 120 51 | 120 52 | 24 53 | /assets/images/icons/lr.jpg 54 | 55 | 56 | 57 | @#4 58 | 59 | 60 | @#5 61 | 62 | 63 | @#6 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Barracuda09/SATPI/fe180a5269d0c7b66707bc9e4b3b1da291ca40f2/web/favicon.ico -------------------------------------------------------------------------------- /web/log.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | SAT>IP Log Page 10 | 11 | 12 | 13 | 14 | 15 | 16 | 79 | 80 | 81 | 82 | 83 | 84 |
85 |
86 |
87 |

Main Log

88 |
89 |
90 | 91 | 92 |
93 |
94 | 95 |
96 | 106 |
107 |
108 | 109 | 110 | --------------------------------------------------------------------------------