mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Added preliminary RTP protocol support.
This commit is contained in:
parent
c03e69a64f
commit
0177f03089
5
Makefile
5
Makefile
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile for a Video Disk Recorder plugin
|
||||
#
|
||||
# $Id: Makefile,v 1.8 2007/09/24 13:03:38 ajhseppa Exp $
|
||||
# $Id: Makefile,v 1.9 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
|
||||
# Debugging on/off
|
||||
#IPTV_DEBUG = 1
|
||||
@ -57,7 +57,8 @@ endif
|
||||
|
||||
### The object files (add further files here):
|
||||
|
||||
OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o protocolhttp.o protocolfile.o sectionfilter.o
|
||||
OBJS = $(PLUGIN).o config.o setup.o device.o streamer.o protocoludp.o protocolrtp.o \
|
||||
protocolhttp.o protocolfile.o sectionfilter.o
|
||||
|
||||
### The main target:
|
||||
|
||||
|
3
README
3
README
@ -38,11 +38,12 @@ make plugins
|
||||
Channels.conf examples:
|
||||
|
||||
TV1;IPTV:1:IPTV|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
|
||||
TV1;IPTV:1:IPTV|RTP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0
|
||||
^ ^ ^ ^ ^ ^
|
||||
| | | | | Source type ("P")
|
||||
| | | | IP Port Number
|
||||
| | | IP Address or File Location
|
||||
| | Protocol ("UDP", "HTTP", "FILE")
|
||||
| | Protocol ("UDP", "RTP", "HTTP", "FILE")
|
||||
| Plugin ID ("IPTV")
|
||||
Unique enumeration
|
||||
|
||||
|
3
config.c
3
config.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: config.c,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: config.c,v 1.5 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -15,6 +15,7 @@ cIptvConfig::cIptvConfig(void)
|
||||
: tsBufferSize(8),
|
||||
tsBufferPrefillRatio(0),
|
||||
udpBufferSize(7),
|
||||
rtpBufferSize(7),
|
||||
httpBufferSize(7),
|
||||
fileBufferSize(20),
|
||||
maxBufferSize(40) // must be bigger than protocol buffer sizes!
|
||||
|
5
config.h
5
config.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: config.h,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: config.h,v 1.5 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_CONFIG_H
|
||||
@ -18,6 +18,7 @@ protected:
|
||||
unsigned int tsBufferSize;
|
||||
unsigned int tsBufferPrefillRatio;
|
||||
unsigned int udpBufferSize;
|
||||
unsigned int rtpBufferSize;
|
||||
unsigned int httpBufferSize;
|
||||
unsigned int fileBufferSize;
|
||||
unsigned int maxBufferSize;
|
||||
@ -26,12 +27,14 @@ public:
|
||||
unsigned int GetTsBufferSize(void) { return tsBufferSize; }
|
||||
unsigned int GetTsBufferPrefillRatio(void) { return tsBufferPrefillRatio; }
|
||||
unsigned int GetUdpBufferSize(void) { return udpBufferSize; }
|
||||
unsigned int GetRtpBufferSize(void) { return rtpBufferSize; }
|
||||
unsigned int GetHttpBufferSize(void) { return httpBufferSize; }
|
||||
unsigned int GetFileBufferSize(void) { return fileBufferSize; }
|
||||
unsigned int GetMaxBufferSize(void) { return maxBufferSize; }
|
||||
void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; }
|
||||
void SetTsBufferPrefillRatio(unsigned int Ratio) { tsBufferPrefillRatio = Ratio; }
|
||||
void SetUdpBufferSize(unsigned int Size) { udpBufferSize = Size; }
|
||||
void SetRtpBufferSize(unsigned int Size) { rtpBufferSize = Size; }
|
||||
void SetHttpBufferSize(unsigned int Size) { httpBufferSize = Size; }
|
||||
void SetFileBufferSize(unsigned int Size) { fileBufferSize = Size; }
|
||||
};
|
||||
|
8
device.c
8
device.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.c,v 1.40 2007/09/24 21:25:53 rahrenbe Exp $
|
||||
* $Id: device.c,v 1.41 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -29,6 +29,7 @@ cIptvDevice::cIptvDevice(unsigned int Index)
|
||||
tsBuffer->SetTimeouts(100, 100);
|
||||
ResetBuffering();
|
||||
pUdpProtocol = new cIptvProtocolUdp();
|
||||
pRtpProtocol = new cIptvProtocolRtp();
|
||||
pHttpProtocol = new cIptvProtocolHttp();
|
||||
pFileProtocol = new cIptvProtocolFile();
|
||||
pIptvStreamer = new cIptvStreamer(tsBuffer, &mutex);
|
||||
@ -86,6 +87,11 @@ cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvPro
|
||||
*Protocol = pUdpProtocol;
|
||||
return addr;
|
||||
}
|
||||
else if (sscanf(Param, "IPTV|RTP|%a[^|]|%u", &loc, IpPort) == 2) {
|
||||
cString addr(loc, true);
|
||||
*Protocol = pRtpProtocol;
|
||||
return addr;
|
||||
}
|
||||
else if (sscanf(Param, "IPTV|HTTP|%a[^|]|%u", &loc, IpPort) == 2) {
|
||||
cString addr(loc, true);
|
||||
*Protocol = pHttpProtocol;
|
||||
|
4
device.h
4
device.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.h,v 1.17 2007/09/24 17:20:58 rahrenbe Exp $
|
||||
* $Id: device.h,v 1.18 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_DEVICE_H
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
#include <vdr/device.h>
|
||||
#include "protocoludp.h"
|
||||
#include "protocolrtp.h"
|
||||
#include "protocolhttp.h"
|
||||
#include "protocolfile.h"
|
||||
#include "streamer.h"
|
||||
@ -35,6 +36,7 @@ private:
|
||||
cRingBufferLinear *tsBuffer;
|
||||
int tsBufferPrefill;
|
||||
cIptvProtocolUdp *pUdpProtocol;
|
||||
cIptvProtocolRtp *pRtpProtocol;
|
||||
cIptvProtocolHttp *pHttpProtocol;
|
||||
cIptvProtocolFile *pFileProtocol;
|
||||
cIptvStreamer *pIptvStreamer;
|
||||
|
34
po/fi_FI.po
34
po/fi_FI.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: VDR 1.5.7\n"
|
||||
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
|
||||
"POT-Creation-Date: 2007-09-19 19:49+0300\n"
|
||||
"POT-Creation-Date: 2007-09-26 20:00+0300\n"
|
||||
"PO-Revision-Date: 2007-08-12 23:22+0300\n"
|
||||
"Last-Translator: Rolf Ahrenberg\n"
|
||||
"Language-Team: <vdr@linuxtv.org>\n"
|
||||
@ -19,50 +19,58 @@ msgstr ""
|
||||
msgid "Experiment the IPTV"
|
||||
msgstr "Koe IPTV:n ihmeellinen maailma"
|
||||
|
||||
#: setup.c:53
|
||||
#: setup.c:54
|
||||
msgid "UDP"
|
||||
msgstr "UDP"
|
||||
|
||||
#: setup.c:54
|
||||
#: setup.c:55
|
||||
msgid "RTP"
|
||||
msgstr "RTP"
|
||||
|
||||
#: setup.c:56
|
||||
msgid "HTTP"
|
||||
msgstr "HTTP"
|
||||
|
||||
#: setup.c:55
|
||||
#: setup.c:57
|
||||
msgid "FILE"
|
||||
msgstr "FILE"
|
||||
|
||||
#: setup.c:170
|
||||
#: setup.c:180
|
||||
msgid "Protocol"
|
||||
msgstr "Protokolla"
|
||||
|
||||
#: setup.c:178
|
||||
#: setup.c:188
|
||||
msgid "Address"
|
||||
msgstr "Osoite"
|
||||
|
||||
#: setup.c:179
|
||||
#: setup.c:189
|
||||
msgid "Port"
|
||||
msgstr "Portti"
|
||||
|
||||
#: setup.c:296
|
||||
#: setup.c:307
|
||||
msgid "IPTV Channels"
|
||||
msgstr "IPTV-kanavat"
|
||||
|
||||
#: setup.c:432
|
||||
#: setup.c:444
|
||||
msgid "TS buffer size [MB]"
|
||||
msgstr "TS-puskurin koko [MB]"
|
||||
|
||||
#: setup.c:433
|
||||
#: setup.c:445
|
||||
msgid "TS buffer prefill ratio [%]"
|
||||
msgstr "TS-puskurin esitäyttöaste [%]"
|
||||
|
||||
#: setup.c:434
|
||||
#: setup.c:446
|
||||
msgid "UDP buffer size [packets]"
|
||||
msgstr "UDP-puskurin koko [pakettia]"
|
||||
|
||||
#: setup.c:435
|
||||
#: setup.c:447
|
||||
msgid "RTP buffer size [packets]"
|
||||
msgstr "RTP-puskurin koko [pakettia]"
|
||||
|
||||
#: setup.c:448
|
||||
msgid "HTTP buffer size [packets]"
|
||||
msgstr "HTTP-puskurin koko [pakettia]"
|
||||
|
||||
#: setup.c:436
|
||||
#: setup.c:449
|
||||
msgid "FILE buffer size [packets]"
|
||||
msgstr "FILE-puskurin koko [pakettia]"
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolhttp.c,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: protocolhttp.c,v 1.5 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -20,9 +20,9 @@
|
||||
#include "protocolhttp.h"
|
||||
|
||||
cIptvProtocolHttp::cIptvProtocolHttp()
|
||||
: streamPort(1234),
|
||||
: streamPort(3000),
|
||||
socketDesc(-1),
|
||||
unicastActive(false)
|
||||
isActive(false)
|
||||
{
|
||||
debug("cIptvProtocolHttp::cIptvProtocolHttp(): %d/%d packets\n",
|
||||
IptvConfig.GetHttpBufferSize(), IptvConfig.GetMaxBufferSize());
|
||||
@ -108,7 +108,7 @@ bool cIptvProtocolHttp::Connect(void)
|
||||
{
|
||||
debug("cIptvProtocolHttp::Connect()\n");
|
||||
// Check that stream address is valid
|
||||
if (!unicastActive && !isempty(streamAddr) && !isempty(streamPath)) {
|
||||
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
|
||||
// Ensure that socket is valid
|
||||
OpenSocket(streamPort);
|
||||
|
||||
@ -195,7 +195,7 @@ bool cIptvProtocolHttp::Connect(void)
|
||||
// connection should be re-located etc.
|
||||
|
||||
// Update active flag
|
||||
unicastActive = true;
|
||||
isActive = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -204,11 +204,11 @@ bool cIptvProtocolHttp::Disconnect(void)
|
||||
{
|
||||
debug("cIptvProtocolHttp::Disconnect()\n");
|
||||
// Check that stream address is valid
|
||||
if (unicastActive) {
|
||||
if (isActive) {
|
||||
// Close the socket
|
||||
CloseSocket();
|
||||
// Update active flag
|
||||
unicastActive = false;
|
||||
isActive = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolhttp.h,v 1.3 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: protocolhttp.h,v 1.4 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_PROTOCOLHTTP_H
|
||||
@ -20,7 +20,7 @@ private:
|
||||
int socketDesc;
|
||||
unsigned char* readBuffer;
|
||||
struct sockaddr_in sockAddr;
|
||||
bool unicastActive;
|
||||
bool isActive;
|
||||
|
||||
private:
|
||||
bool OpenSocket(const int Port);
|
||||
|
225
protocolrtp.c
Normal file
225
protocolrtp.c
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* protocolrtp.c: IPTV plugin for the Video Disk Recorder
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolrtp.c,v 1.1 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <vdr/device.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "protocolrtp.h"
|
||||
|
||||
cIptvProtocolRtp::cIptvProtocolRtp()
|
||||
: streamPort(1234),
|
||||
socketDesc(-1),
|
||||
isActive(false)
|
||||
{
|
||||
debug("cIptvProtocolRtp::cIptvProtocolRtp(): %d/%d packets\n",
|
||||
IptvConfig.GetRtpBufferSize(), IptvConfig.GetMaxBufferSize());
|
||||
streamAddr = strdup("");
|
||||
// Allocate receive buffer
|
||||
readBuffer = MALLOC(unsigned char, (TS_SIZE * IptvConfig.GetMaxBufferSize()));
|
||||
if (!readBuffer)
|
||||
error("ERROR: MALLOC() failed in ProtocolRtp()");
|
||||
}
|
||||
|
||||
cIptvProtocolRtp::~cIptvProtocolRtp()
|
||||
{
|
||||
debug("cIptvProtocolRtp::~cIptvProtocolRtp()\n");
|
||||
// Drop the multicast group and close the socket
|
||||
Close();
|
||||
// Free allocated memory
|
||||
free(streamAddr);
|
||||
free(readBuffer);
|
||||
}
|
||||
|
||||
bool cIptvProtocolRtp::OpenSocket(const int Port)
|
||||
{
|
||||
debug("cIptvProtocolRtp::OpenSocket()\n");
|
||||
// If socket is there already and it is bound to a different port, it must
|
||||
// be closed first
|
||||
if (Port != streamPort) {
|
||||
debug("cIptvProtocolRtp::OpenSocket(): Socket tear-down\n");
|
||||
CloseSocket();
|
||||
}
|
||||
// Bind to the socket if it is not active already
|
||||
if (socketDesc < 0) {
|
||||
int yes = 1;
|
||||
// Create socket
|
||||
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (socketDesc < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: socket(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
return false;
|
||||
}
|
||||
// Make it use non-blocking I/O to avoid stuck read calls
|
||||
if (fcntl(socketDesc, F_SETFL, O_NONBLOCK)) {
|
||||
char tmp[64];
|
||||
error("ERROR: fcntl(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
CloseSocket();
|
||||
return false;
|
||||
}
|
||||
// Allow multiple sockets to use the same PORT number
|
||||
if (setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes,
|
||||
sizeof(yes)) < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
CloseSocket();
|
||||
return false;
|
||||
}
|
||||
// Bind socket
|
||||
memset(&sockAddr, '\0', sizeof(sockAddr));
|
||||
sockAddr.sin_family = AF_INET;
|
||||
sockAddr.sin_port = htons(Port);
|
||||
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
|
||||
if (err < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: bind(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
CloseSocket();
|
||||
return false;
|
||||
}
|
||||
// Update stream port
|
||||
streamPort = Port;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void cIptvProtocolRtp::CloseSocket(void)
|
||||
{
|
||||
debug("cIptvProtocolRtp::CloseSocket()\n");
|
||||
// Check if socket exists
|
||||
if (socketDesc >= 0) {
|
||||
close(socketDesc);
|
||||
socketDesc = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool cIptvProtocolRtp::JoinMulticast(void)
|
||||
{
|
||||
debug("cIptvProtocolRtp::JoinMulticast()\n");
|
||||
// Check that stream address is valid
|
||||
if (!isActive && !isempty(streamAddr)) {
|
||||
// Ensure that socket is valid
|
||||
OpenSocket(streamPort);
|
||||
// Join a new multicast group
|
||||
struct ip_mreq mreq;
|
||||
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
|
||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||
int err = setsockopt(socketDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
|
||||
sizeof(mreq));
|
||||
if (err < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
return false;
|
||||
}
|
||||
// Update multicasting flag
|
||||
isActive = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cIptvProtocolRtp::DropMulticast(void)
|
||||
{
|
||||
debug("cIptvProtocolRtp::DropMulticast()\n");
|
||||
// Check that stream address is valid
|
||||
if (isActive && !isempty(streamAddr)) {
|
||||
// Ensure that socket is valid
|
||||
OpenSocket(streamPort);
|
||||
// Drop the multicast group
|
||||
struct ip_mreq mreq;
|
||||
mreq.imr_multiaddr.s_addr = inet_addr(streamAddr);
|
||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||
int err = setsockopt(socketDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq,
|
||||
sizeof(mreq));
|
||||
if (err < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: setsockopt(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
return false;
|
||||
}
|
||||
// Update multicasting flag
|
||||
isActive = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int cIptvProtocolRtp::Read(unsigned char* *BufferAddr)
|
||||
{
|
||||
//debug("cIptvProtocolRtp::Read()\n");
|
||||
socklen_t addrlen = sizeof(sockAddr);
|
||||
// Wait for data
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 500000;
|
||||
// Use select
|
||||
fd_set rfds;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(socketDesc, &rfds);
|
||||
int retval = select(socketDesc + 1, &rfds, NULL, NULL, &tv);
|
||||
// Check if error
|
||||
if (retval < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
return -1;
|
||||
}
|
||||
// Check if data available
|
||||
else if (retval) {
|
||||
// Read data from socket
|
||||
int len = recvfrom(socketDesc, readBuffer, (TS_SIZE * IptvConfig.GetRtpBufferSize()),
|
||||
MSG_DONTWAIT, (struct sockaddr *)&sockAddr, &addrlen);
|
||||
if (len > 0) {
|
||||
// http://www.networksorcery.com/enp/rfc/rfc2250.txt
|
||||
const unsigned int headerlen = 4 * sizeof(uint32_t);
|
||||
uint8_t *header = readBuffer + sizeof(uint8_t);
|
||||
// Check if payload type is MPEG2 TS and payload contains multiple of TS packet data
|
||||
if (((*header & 0x7F) == 33) && (((len - headerlen) % TS_SIZE) == 0)) {
|
||||
// Set argument point to payload in read buffer
|
||||
*BufferAddr = readBuffer + headerlen;
|
||||
return (len - headerlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cIptvProtocolRtp::Open(void)
|
||||
{
|
||||
debug("cIptvProtocolRtp::Open(): streamAddr=%s\n", streamAddr);
|
||||
// Join a new multicast group
|
||||
JoinMulticast();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cIptvProtocolRtp::Close(void)
|
||||
{
|
||||
debug("cIptvProtocolRtp::Close(): streamAddr=%s\n", streamAddr);
|
||||
// Drop the multicast group
|
||||
DropMulticast();
|
||||
// Close the socket
|
||||
CloseSocket();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cIptvProtocolRtp::Set(const char* Address, const int Port)
|
||||
{
|
||||
debug("cIptvProtocolRtp::Set(): %s:%d\n", Address, Port);
|
||||
if (!isempty(Address)) {
|
||||
// Drop the multicast group
|
||||
DropMulticast();
|
||||
// Update stream address and port
|
||||
streamAddr = strcpyrealloc(streamAddr, Address);
|
||||
streamPort = Port;
|
||||
// Join a new multicast group
|
||||
JoinMulticast();
|
||||
}
|
||||
return true;
|
||||
}
|
40
protocolrtp.h
Normal file
40
protocolrtp.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* protocolrtp.h: IPTV plugin for the Video Disk Recorder
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocolrtp.h,v 1.1 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_PROTOCOLRTP_H
|
||||
#define __IPTV_PROTOCOLRTP_H
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include "protocolif.h"
|
||||
|
||||
class cIptvProtocolRtp : public cIptvProtocolIf {
|
||||
private:
|
||||
char* streamAddr;
|
||||
int streamPort;
|
||||
int socketDesc;
|
||||
unsigned char* readBuffer;
|
||||
struct sockaddr_in sockAddr;
|
||||
bool isActive;
|
||||
|
||||
private:
|
||||
bool OpenSocket(const int Port);
|
||||
void CloseSocket(void);
|
||||
bool JoinMulticast(void);
|
||||
bool DropMulticast(void);
|
||||
|
||||
public:
|
||||
cIptvProtocolRtp();
|
||||
virtual ~cIptvProtocolRtp();
|
||||
virtual int Read(unsigned char* *BufferAddr);
|
||||
virtual bool Set(const char* Address, const int Port);
|
||||
virtual bool Open(void);
|
||||
virtual bool Close(void);
|
||||
};
|
||||
|
||||
#endif // __IPTV_PROTOCOLRTP_H
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* streamer.c: IPTV plugin for the Video Disk Recorder
|
||||
* protocoludp.c: IPTV plugin for the Video Disk Recorder
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocoludp.c,v 1.6 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: protocoludp.c,v 1.7 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -21,7 +21,7 @@
|
||||
cIptvProtocolUdp::cIptvProtocolUdp()
|
||||
: streamPort(1234),
|
||||
socketDesc(-1),
|
||||
mcastActive(false)
|
||||
isActive(false)
|
||||
{
|
||||
debug("cIptvProtocolUdp::cIptvProtocolUdp(): %d/%d packets\n",
|
||||
IptvConfig.GetUdpBufferSize(), IptvConfig.GetMaxBufferSize());
|
||||
@ -108,7 +108,7 @@ bool cIptvProtocolUdp::JoinMulticast(void)
|
||||
{
|
||||
debug("cIptvProtocolUdp::JoinMulticast()\n");
|
||||
// Check that stream address is valid
|
||||
if (!mcastActive && !isempty(streamAddr)) {
|
||||
if (!isActive && !isempty(streamAddr)) {
|
||||
// Ensure that socket is valid
|
||||
OpenSocket(streamPort);
|
||||
// Join a new multicast group
|
||||
@ -123,7 +123,7 @@ bool cIptvProtocolUdp::JoinMulticast(void)
|
||||
return false;
|
||||
}
|
||||
// Update multicasting flag
|
||||
mcastActive = true;
|
||||
isActive = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -132,7 +132,7 @@ bool cIptvProtocolUdp::DropMulticast(void)
|
||||
{
|
||||
debug("cIptvProtocolUdp::DropMulticast()\n");
|
||||
// Check that stream address is valid
|
||||
if (mcastActive && !isempty(streamAddr)) {
|
||||
if (isActive && !isempty(streamAddr)) {
|
||||
// Ensure that socket is valid
|
||||
OpenSocket(streamPort);
|
||||
// Drop the multicast group
|
||||
@ -147,7 +147,7 @@ bool cIptvProtocolUdp::DropMulticast(void)
|
||||
return false;
|
||||
}
|
||||
// Update multicasting flag
|
||||
mcastActive = false;
|
||||
isActive = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: protocoludp.h,v 1.4 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: protocoludp.h,v 1.5 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_PROTOCOLUDP_H
|
||||
@ -19,7 +19,7 @@ private:
|
||||
int socketDesc;
|
||||
unsigned char* readBuffer;
|
||||
struct sockaddr_in sockAddr;
|
||||
bool mcastActive;
|
||||
bool isActive;
|
||||
|
||||
private:
|
||||
bool OpenSocket(const int Port);
|
||||
|
17
setup.c
17
setup.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: setup.c,v 1.8 2007/09/20 21:45:51 rahrenbe Exp $
|
||||
* $Id: setup.c,v 1.9 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@ -26,6 +26,7 @@ class cIptvMenuEditChannel : public cOsdMenu
|
||||
private:
|
||||
enum {
|
||||
eProtocolUDP,
|
||||
eProtocolRTP,
|
||||
eProtocolHTTP,
|
||||
eProtocolFILE,
|
||||
eProtocolCount
|
||||
@ -51,6 +52,7 @@ cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
|
||||
:cOsdMenu(trVDR("Edit channel"), 16)
|
||||
{
|
||||
protocols[eProtocolUDP] = tr("UDP");
|
||||
protocols[eProtocolRTP] = tr("RTP");
|
||||
protocols[eProtocolHTTP] = tr("HTTP");
|
||||
protocols[eProtocolFILE] = tr("FILE");
|
||||
channel = Channel;
|
||||
@ -72,6 +74,11 @@ cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Port, int
|
||||
*Protocol = eProtocolUDP;
|
||||
return addr;
|
||||
}
|
||||
else if (sscanf(Param, "IPTV|RTP|%a[^|]|%u", &loc, Port) == 2) {
|
||||
cString addr(loc, true);
|
||||
*Protocol = eProtocolRTP;
|
||||
return addr;
|
||||
}
|
||||
else if (sscanf(Param, "IPTV|HTTP|%a[^|]|%u", &loc, Port) == 2) {
|
||||
cString addr(loc, true);
|
||||
*Protocol = eProtocolHTTP;
|
||||
@ -149,6 +156,9 @@ void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
|
||||
case eProtocolHTTP:
|
||||
param = cString::sprintf("IPTV|HTTP|%s|%d", data.location, data.port);
|
||||
break;
|
||||
case eProtocolRTP:
|
||||
param = cString::sprintf("IPTV|RTP|%s|%d", data.location, data.port);
|
||||
break;
|
||||
default:
|
||||
case eProtocolUDP:
|
||||
param = cString::sprintf("IPTV|UDP|%s|%d", data.location, data.port);
|
||||
@ -236,6 +246,7 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
|
||||
data.port = 3000;
|
||||
break;
|
||||
default:
|
||||
case eProtocolRTP:
|
||||
case eProtocolUDP:
|
||||
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
|
||||
data.port = 1234;
|
||||
@ -419,6 +430,7 @@ cIptvPluginSetup::cIptvPluginSetup()
|
||||
tsBufferSize = IptvConfig.GetTsBufferSize();
|
||||
tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
|
||||
udpBufferSize = IptvConfig.GetUdpBufferSize();
|
||||
rtpBufferSize = IptvConfig.GetRtpBufferSize();
|
||||
httpBufferSize = IptvConfig.GetHttpBufferSize();
|
||||
fileBufferSize = IptvConfig.GetFileBufferSize();
|
||||
Setup();
|
||||
@ -432,6 +444,7 @@ void cIptvPluginSetup::Setup(void)
|
||||
Add(new cMenuEditIntItem(tr("TS buffer size [MB]"), &tsBufferSize, 2, 16));
|
||||
Add(new cMenuEditIntItem(tr("TS buffer prefill ratio [%]"), &tsBufferPrefill, 0, 40));
|
||||
Add(new cMenuEditIntItem(tr("UDP buffer size [packets]"), &udpBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
Add(new cMenuEditIntItem(tr("RTP buffer size [packets]"), &rtpBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
Add(new cMenuEditIntItem(tr("HTTP buffer size [packets]"), &httpBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
Add(new cMenuEditIntItem(tr("FILE buffer size [packets]"), &fileBufferSize, 1, IptvConfig.GetMaxBufferSize()));
|
||||
SetCurrent(Get(current));
|
||||
@ -463,12 +476,14 @@ void cIptvPluginSetup::Store(void)
|
||||
SetupStore("TsBufferSize", tsBufferSize);
|
||||
SetupStore("TsBufferPrefill", tsBufferPrefill);
|
||||
SetupStore("UdpBufferSize", udpBufferSize);
|
||||
SetupStore("RtpBufferSize", rtpBufferSize);
|
||||
SetupStore("HttpBufferSize", httpBufferSize);
|
||||
SetupStore("FileBufferSize", fileBufferSize);
|
||||
// Update global config
|
||||
IptvConfig.SetTsBufferSize(tsBufferSize);
|
||||
IptvConfig.SetTsBufferPrefillRatio(tsBufferPrefill);
|
||||
IptvConfig.SetUdpBufferSize(udpBufferSize);
|
||||
IptvConfig.SetUdpBufferSize(rtpBufferSize);
|
||||
IptvConfig.SetHttpBufferSize(httpBufferSize);
|
||||
IptvConfig.SetFileBufferSize(fileBufferSize);
|
||||
}
|
||||
|
3
setup.h
3
setup.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: setup.h,v 1.4 2007/09/18 18:48:11 rahrenbe Exp $
|
||||
* $Id: setup.h,v 1.5 2007/09/26 19:49:35 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_SETUP_H
|
||||
@ -17,6 +17,7 @@ private:
|
||||
int tsBufferSize;
|
||||
int tsBufferPrefill;
|
||||
int udpBufferSize;
|
||||
int rtpBufferSize;
|
||||
int httpBufferSize;
|
||||
int fileBufferSize;
|
||||
eOSState EditChannel(void);
|
||||
|
Loading…
Reference in New Issue
Block a user