mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Fixed prebuffering.
This commit is contained in:
parent
6d0f27e710
commit
067ba7c505
45
device.c
45
device.c
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.c,v 1.29 2007/09/20 22:01:42 rahrenbe Exp $
|
||||
* $Id: device.c,v 1.30 2007/09/21 21:50:52 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@ -26,13 +26,9 @@ cIptvDevice::cIptvDevice(unsigned int Index)
|
||||
{
|
||||
debug("cIptvDevice::cIptvDevice(%d)\n", deviceIndex);
|
||||
tsBuffer = new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
|
||||
(TS_SIZE * 2), false, "IPTV");
|
||||
(TS_SIZE * 10), false, "IPTV");
|
||||
tsBuffer->SetTimeouts(100, 100);
|
||||
// pad prefill to multiple of TS_SIZE
|
||||
tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
||||
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
||||
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
|
||||
//debug("Buffer=%d Prefill=%d\n", MEGABYTE(IptvConfig.GetTsBufferSize()), tsBufferPrefill);
|
||||
ResetBuffering();
|
||||
pUdpProtocol = new cIptvProtocolUdp();
|
||||
pHttpProtocol = new cIptvProtocolHttp();
|
||||
pFileProtocol = new cIptvProtocolFile();
|
||||
@ -166,10 +162,6 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
|
||||
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam());
|
||||
return false;
|
||||
}
|
||||
// pad prefill to multiple of TS_SIZE
|
||||
tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
||||
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
||||
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
|
||||
pIptvStreamer->Set(addr, port, protocol);
|
||||
return true;
|
||||
}
|
||||
@ -225,6 +217,7 @@ bool cIptvDevice::OpenDvr(void)
|
||||
isPacketDelivered = false;
|
||||
tsBuffer->Clear();
|
||||
mutex.Unlock();
|
||||
ResetBuffering();
|
||||
pIptvStreamer->Open();
|
||||
isOpenDvr = true;
|
||||
return true;
|
||||
@ -250,17 +243,34 @@ void cIptvDevice::CloseDvr(void)
|
||||
|
||||
bool cIptvDevice::HasLock(int TimeoutMs)
|
||||
{
|
||||
debug("cIptvDevice::HasLock(%d): %d\n", deviceIndex, TimeoutMs);
|
||||
//debug("cIptvDevice::HasLock(%d): %d\n", deviceIndex, TimeoutMs);
|
||||
return (!IsBuffering());
|
||||
}
|
||||
|
||||
void cIptvDevice::ResetBuffering(void)
|
||||
{
|
||||
debug("cIptvDevice::ResetBuffering(%d)\n", deviceIndex);
|
||||
// pad prefill to multiple of TS_SIZE
|
||||
tsBufferPrefill = MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
||||
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
||||
tsBufferPrefill -= (tsBufferPrefill % TS_SIZE);
|
||||
}
|
||||
|
||||
bool cIptvDevice::IsBuffering(void)
|
||||
{
|
||||
//debug("cIptvDevice::IsBuffering(%d): %d\n", deviceIndex);
|
||||
if (tsBufferPrefill && tsBuffer->Available() < tsBufferPrefill)
|
||||
return false;
|
||||
tsBufferPrefill = 0;
|
||||
return true;
|
||||
else
|
||||
tsBufferPrefill = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
{
|
||||
int Count = 0;
|
||||
//debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndex);
|
||||
if (!IsBuffering()) {
|
||||
if (isPacketDelivered) {
|
||||
tsBuffer->Del(TS_SIZE);
|
||||
isPacketDelivered = false;
|
||||
@ -286,8 +296,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
if (filters[i].active) {
|
||||
section *filtered = get_filt_sec(&filter, i);
|
||||
if (filtered->found) {
|
||||
// Select on the fifo emptyness. Using null timeout to return
|
||||
// immediately
|
||||
// Select on the fifo emptyness. Using null timeout to return immediately
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
@ -299,8 +308,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
if (retval < 0) {
|
||||
char tmp[64];
|
||||
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
|
||||
// VDR has probably closed the filter file descriptor, so clear
|
||||
// the filter
|
||||
// VDR has probably closed the filter file descriptor, so clear the filter
|
||||
close(filters[i].fifoDesc);
|
||||
unlink(filters[i].pipeName);
|
||||
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
|
||||
@ -321,6 +329,7 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Data = NULL;
|
||||
return true;
|
||||
}
|
||||
|
6
device.h
6
device.h
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: device.h,v 1.13 2007/09/20 22:01:42 rahrenbe Exp $
|
||||
* $Id: device.h,v 1.14 2007/09/21 21:50:52 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#ifndef __IPTV_DEVICE_H
|
||||
@ -57,10 +57,12 @@ public:
|
||||
cIptvDevice(unsigned int DeviceIndex);
|
||||
virtual ~cIptvDevice();
|
||||
|
||||
// for channel parsing
|
||||
// for channel parsing & buffering
|
||||
private:
|
||||
cString GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol);
|
||||
bool ProvidesIptv(const char *Param) const;
|
||||
void ResetBuffering(void);
|
||||
bool IsBuffering(void);
|
||||
|
||||
// for channel selection
|
||||
public:
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: streamer.c,v 1.13 2007/09/15 21:27:00 rahrenbe Exp $
|
||||
* $Id: streamer.c,v 1.14 2007/09/21 21:50:52 rahrenbe Exp $
|
||||
*/
|
||||
|
||||
#include <vdr/thread.h>
|
||||
@ -33,7 +33,7 @@ void cIptvStreamer::Action(void)
|
||||
debug("cIptvStreamer::Action(): Entering\n");
|
||||
// Do the thread loop
|
||||
while (Running()) {
|
||||
if (ringBuffer && mutex && protocol) {
|
||||
if (ringBuffer && mutex && protocol && ringBuffer->Free()) {
|
||||
unsigned char *buffer = NULL;
|
||||
int length = protocol->Read(&buffer);
|
||||
if (length >= 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user