Skip to content

Commit

Permalink
Merge pull request #99 from margro/master
Browse files Browse the repository at this point in the history
Update the plugin to v3.5.14 (Fixes for v18)
  • Loading branch information
margro authored Dec 15, 2018
2 parents b17fdad + e873ca2 commit 25e3e7d
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 97 deletions.
2 changes: 1 addition & 1 deletion pvr.mediaportal.tvserver/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.mediaportal.tvserver"
version="3.5.13"
version="3.5.14"
name="MediaPortal PVR Client"
provider-name="Marcel Groothuis">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
16 changes: 16 additions & 0 deletions pvr.mediaportal.tvserver/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
v3.5.14:
- Fixed: Delete the tsreader when tuning to a new channel failed. This fixes the first re-tune to a working channel after a failure
- Updated: recommended TVServerKodi version to build 140
- Recording playback: update the end time if the recording is still ongoing
- Recording: Prevent setting a negative last played position. MediaPortal does not like this.
- Recording: mark in-progress recording as "real-time" also on non-Windows targets
- Fixed: various 64-bit compiler warnings
- Fixed: Increase the command buffer size to fit the full contents of strRecordingId in DeleteRecording() and GetRecordings()
- Fixed: tsreader: checking for < 0 on unsigned values is useless

v3.5.13:
- Translation update from Transifex

v3.5.12:
- Translation update from Transifex

v3.5.11:
- Fixed: GetAddonCapabilities() did not explicitly set all newly added capabilities
- Fixed: Error: "Couldn't get 'defaultrecordinglifetime' setting, falling back to '100' as default"
Expand Down
2 changes: 1 addition & 1 deletion src/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ bool Socket::connect ( const std::string& host, const unsigned short port )
continue;
}

int status = ::connect(_sd, address->ai_addr, address->ai_addrlen);
int status = ::connect(_sd, address->ai_addr, static_cast<int>(address->ai_addrlen));
if (status == SOCKET_ERROR)
{
close();
Expand Down
16 changes: 8 additions & 8 deletions src/lib/tsreader/DeMultiplexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,25 @@ namespace MPTV
/// and processes the raw data
/// When a TS packet has been discovered, OnTsPacket(byte* tsPacket) gets called
// which in its turn deals with the packet
int CDeMultiplexer::ReadFromFile()
size_t CDeMultiplexer::ReadFromFile()
{
if (m_filter.IsSeeking())
return 0; // Ambass : to check

P8PLATFORM::CLockObject lock(m_sectionRead);
if (NULL == m_reader)
return false;
return 0;

byte buffer[READ_SIZE];
unsigned long dwReadBytes = 0;
size_t dwReadBytes = 0;

// if we are playing a RTSP stream
if (m_reader->IsBuffer())
{
// and, the current buffer holds data
int nBytesToRead = m_reader->HasData();
size_t nBytesToRead = m_reader->HasData();

if (nBytesToRead > (int) sizeof(buffer))
if (nBytesToRead > sizeof(buffer))
{
nBytesToRead = sizeof(buffer);
}
Expand All @@ -130,13 +130,13 @@ namespace MPTV
if (nBytesToRead)
{
// then read raw data from the buffer
if (SUCCEEDED(m_reader->Read(buffer, nBytesToRead, (unsigned long*)&dwReadBytes)))
if (SUCCEEDED(m_reader->Read(buffer, nBytesToRead, &dwReadBytes)))
{
if (dwReadBytes > 0)
{
// yes, then process the raw data
//result=true;
OnRawData(buffer, (int)dwReadBytes);
OnRawData(buffer, dwReadBytes);
m_LastDataFromRtsp = GetTickCount64();
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ namespace MPTV
{
// playing a local file.
// read raw data from the file
if (SUCCEEDED(m_reader->Read(buffer, sizeof(buffer), (unsigned long*)&dwReadBytes)))
if (SUCCEEDED(m_reader->Read(buffer, sizeof(buffer), &dwReadBytes)))
{
if ((m_filter.IsTimeShifting()) && (dwReadBytes < sizeof(buffer)))
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tsreader/DeMultiplexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace MPTV
void OnNewChannel(CChannelInfo& info);
void SetFileReader(FileReader* reader);
void RequestNewPat(void);
int ReadFromFile();
size_t ReadFromFile();

private:
unsigned long long m_LastDataFromRtsp;
Expand Down
11 changes: 9 additions & 2 deletions src/lib/tsreader/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,16 @@ namespace MPTV
}


long FileReader::Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes)
long FileReader::Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes)
{
*dwReadBytes = KODI->ReadFile(m_hFile, (void*)pbData, lDataLength);//Read file data into buffer
ssize_t read_bytes = KODI->ReadFile(m_hFile, (void*)pbData, lDataLength);//Read file data into buffer
if (read_bytes < 0)
{
TSDEBUG(LOG_DEBUG, "%s: ReadFile function failed.", __FUNCTION__);
*dwReadBytes = 0;
return S_FALSE;
}
*dwReadBytes = static_cast<size_t>(read_bytes);
TSDEBUG(LOG_DEBUG, "%s: requested read length %d actually read %d.", __FUNCTION__, lDataLength, *dwReadBytes);

if (*dwReadBytes < lDataLength)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/tsreader/FileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ namespace MPTV
virtual long OpenFile(const std::string& fileName);
virtual long OpenFile();
virtual long CloseFile();
virtual long Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes);
virtual long Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes);
virtual bool IsFileInvalid();
virtual int64_t SetFilePointer(int64_t llDistanceToMove, unsigned long dwMoveMethod);
virtual int64_t GetFilePointer();
virtual int64_t GetFileSize();
virtual bool IsBuffer() { return false; };
virtual int64_t OnChannelChange(void);
virtual int HasData(){ return 0; };
virtual size_t HasData(){ return 0; };

protected:
void* m_hFile; // Handle to file for streaming
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tsreader/MemoryBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ size_t CMemoryBuffer::ReadFromBuffer(unsigned char *pbData, size_t lDataLength)

long CMemoryBuffer::PutBuffer(unsigned char *pbData, size_t lDataLength)
{
if (lDataLength <= 0 || pbData == NULL) return E_FAIL;
if (lDataLength == 0 || pbData == NULL) return E_FAIL;

BufferItem* item = new BufferItem();
item->nOffset = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/tsreader/MemoryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ namespace MPTV
{
}

long CMemoryReader::Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes)
long CMemoryReader::Read(unsigned char* pbData, unsigned long lDataLength, size_t *dwReadBytes)
{
*dwReadBytes = m_buffer.ReadFromBuffer(pbData,lDataLength);
if ((*dwReadBytes) <=0)
*dwReadBytes = m_buffer.ReadFromBuffer(pbData, lDataLength);
if ((*dwReadBytes) == 0)
return S_FALSE;
return S_OK;
}
Expand All @@ -55,7 +55,7 @@ namespace MPTV
return 0;
}

int CMemoryReader::HasData()
size_t CMemoryReader::HasData()
{
return (m_buffer.Size());
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/tsreader/MemoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ namespace MPTV
public:
CMemoryReader(CMemoryBuffer& buffer);
virtual ~CMemoryReader(void);
long Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes);
long Read(unsigned char* pbData, unsigned long lDataLength, size_t *dwReadBytes);
unsigned long setFilePointer(int64_t llDistanceToMove, unsigned long dwMoveMethod);
bool IsBuffer() { return true; };
long CloseFile() { return S_OK; };
int HasData();
size_t HasData();

private:
CMemoryBuffer& m_buffer;
Expand Down
14 changes: 7 additions & 7 deletions src/lib/tsreader/MultiFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace MPTV
return m_currentPosition;
}

long MultiFileReader::Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes)
long MultiFileReader::Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes)
{
// If the file has already been closed, don't continue
if (m_TSBufferFile.IsFileInvalid())
Expand Down Expand Up @@ -306,22 +306,22 @@ namespace MPTV
}
}

unsigned long bytesRead = 0;
size_t bytesRead = 0;
long hr;

int64_t bytesToRead = file->length - seekPosition;
if ((int64_t)lDataLength > bytesToRead)
{
// KODI->Log(LOG_DEBUG, "%s: datalength %lu bytesToRead %lli.", __FUNCTION__, lDataLength, bytesToRead);
hr = m_TSFile.Read(pbData, (unsigned long)bytesToRead, &bytesRead);
hr = m_TSFile.Read(pbData, (size_t)bytesToRead, &bytesRead);
if (FAILED(hr))
{
KODI->Log(LOG_ERROR, "READ FAILED1");
return S_FALSE;
}
m_currentPosition += bytesToRead;

hr = this->Read(pbData + bytesToRead, lDataLength - (unsigned long)bytesToRead, dwReadBytes);
hr = this->Read(pbData + bytesToRead, lDataLength - (size_t)bytesToRead, dwReadBytes);
if (FAILED(hr))
{
KODI->Log(LOG_ERROR, "READ FAILED2");
Expand Down Expand Up @@ -357,7 +357,7 @@ namespace MPTV
return S_FALSE;
}

unsigned long bytesRead;
size_t bytesRead;
MultiFileReaderFile *file;

int64_t currentPosition;
Expand Down Expand Up @@ -388,7 +388,7 @@ namespace MPTV

m_TSBufferFile.SetFilePointer(0, FILE_BEGIN);

uint32_t readLength = sizeof(currentPosition) + sizeof(filesAdded) + sizeof(filesRemoved);
size_t readLength = sizeof(currentPosition) + sizeof(filesAdded) + sizeof(filesRemoved);
unsigned char* readBuffer = new unsigned char[readLength];

long result = m_TSBufferFile.Read(readBuffer, readLength, &bytesRead);
Expand Down Expand Up @@ -519,7 +519,7 @@ namespace MPTV
std::vector<std::string> filenames;

Wchar_t* pwCurrFile = pBuffer; //Get a pointer to the first wchar filename string in pBuffer
long length = WcsLen(pwCurrFile);
size_t length = WcsLen(pwCurrFile);

//KODI->Log(LOG_DEBUG, "%s: WcsLen(%d), sizeof(Wchar_t) == %d sizeof(wchar_t) == %d.", __FUNCTION__, length, sizeof(Wchar_t), sizeof(wchar_t));

Expand Down
2 changes: 1 addition & 1 deletion src/lib/tsreader/MultiFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace MPTV
virtual long OpenFile();
virtual long OpenFile(const std::string& fileName);
virtual long CloseFile();
virtual long Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes);
virtual long Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes);

virtual bool IsFileInvalid();

Expand Down
4 changes: 2 additions & 2 deletions src/lib/tsreader/PacketSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ namespace MPTV

// Ambass : Now, need to have 2 consecutive TS_PACKET_SYNC to try avoiding bad synchronisation.
// In case of data flow change ( Seek, tv Zap .... ) Reset() should be called first to flush buffer.
void CPacketSync::OnRawData(byte* pData, int nDataLen)
void CPacketSync::OnRawData(byte* pData, size_t nDataLen)
{
int syncOffset = 0;
size_t syncOffset = 0;
if (m_tempBufferPos > 0)
{
if (pData[TS_PACKET_LEN - m_tempBufferPos] == TS_PACKET_SYNC)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/tsreader/PacketSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ namespace MPTV

public:
virtual ~CPacketSync(void);
void OnRawData(byte* pData, int nDataLen);
void OnRawData(byte* pData, size_t nDataLen);
virtual void OnTsPacket(byte* tsPacket);
void Reset(void);

private:
byte m_tempBuffer[200];
int m_tempBufferPos;
ssize_t m_tempBufferPos;
};
}
19 changes: 13 additions & 6 deletions src/lib/tsreader/TSReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace MPTV
Close();

// check file type
int length = m_fileName.length();
size_t length = m_fileName.length();

if ((length > 7) && (strnicmp(m_fileName.c_str(), "rtsp://", 7) == 0))
{
Expand Down Expand Up @@ -295,14 +295,14 @@ namespace MPTV
return S_OK;
}

long CTsReader::Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes)
long CTsReader::Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes)
{
if (m_fileReader)
{
return m_fileReader->Read(pbData, lDataLength, dwReadBytes);
}

dwReadBytes = 0;
*dwReadBytes = 0;
return S_FALSE;
}

Expand Down Expand Up @@ -365,12 +365,19 @@ namespace MPTV
}
else
{
if (timeShiftBufferPos < 0)
{
pos_after = m_fileReader->SetFilePointer(0LL, FILE_BEGIN);
}
else
{
pos_after = m_fileReader->SetFilePointer(0LL, FILE_END);
if ((timeShiftBufferPos > 0) && (pos_after > timeShiftBufferPos))
{
/* Move backward */
pos_after = fileReader->SetFilePointer((timeShiftBufferPos - pos_after), FILE_CURRENT);
/* Move backward */
pos_after = fileReader->SetFilePointer((timeShiftBufferPos - pos_after), FILE_CURRENT);
}
}
}

m_demultiplexer.RequestNewPat();
Expand All @@ -393,7 +400,7 @@ namespace MPTV
{
std::string tmp = directory;

#ifdef TARGET_WINDOWS
#ifdef TARGET_WINDOWS_DESKTOP
if (tmp.find("smb://") != string::npos)
{
// Convert XBMC smb share name back to a real windows network share...
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tsreader/TSReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace MPTV
CTsReader();
~CTsReader(void);
long Open(const char* pszFileName);
long Read(unsigned char* pbData, unsigned long lDataLength, unsigned long *dwReadBytes);
long Read(unsigned char* pbData, size_t lDataLength, size_t *dwReadBytes);
void Close();
int64_t SetFilePointer(int64_t llDistanceToMove, unsigned long dwMoveMethod);
int64_t GetFileSize();
Expand Down
Loading

0 comments on commit 25e3e7d

Please sign in to comment.