-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is done as an IPTV/Network recorder. To use it, start mythtv-setup and add a new capture card. Select "Network Recorder". Enter a URL to a m3u playlist like this one: http://www.avenard.org/files/media/playlist.m3u (has NASA TV, Al Jazeera and France 24, I intend to expand it). The playlist has the same format as your usual m3u playlist, except that it contains link to a HLS m3u8 URL. Known issue: Changing channel in LiveTV doesn't work for some reasons, I believe the issue comes from tuning taking too much time. This will be investigated later.
- Loading branch information
Showing
9 changed files
with
229 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// | ||
// iptvfeederhls.cpp | ||
// MythTV | ||
// | ||
// Created by Jean-Yves Avenard on 24/05/12. | ||
// Copyright (c) 2012 Bubblestuff Pty Ltd. All rights reserved. | ||
// | ||
|
||
#include "iptvfeederhls.h" | ||
|
||
// MythTV headers | ||
#include "mythlogging.h" | ||
#include "streamlisteners.h" | ||
|
||
#include "HLS/httplivestreambuffer.h" | ||
#define LOC QString("IPTVHLS: ") | ||
|
||
#define TS_SIZE 188 | ||
|
||
// BUFFER_SIZE must be a multiple of TS_SIZE, otherwise the IPTVRecorder will | ||
// choke on it | ||
#define BUFFER_SIZE (128 * TS_SIZE) | ||
|
||
IPTVFeederHLS::IPTVFeederHLS() : | ||
m_buffer(new uint8_t[BUFFER_SIZE]), m_hls(NULL), | ||
m_interrupted(false), m_running(false) | ||
{ | ||
} | ||
|
||
IPTVFeederHLS::~IPTVFeederHLS() | ||
{ | ||
Close(); | ||
delete[] m_buffer; | ||
} | ||
|
||
bool IPTVFeederHLS::IsHLS(const QString &url) | ||
{ | ||
QString turl = url; | ||
return HLSRingBuffer::TestForHTTPLiveStreaming(turl); | ||
} | ||
|
||
bool IPTVFeederHLS::IsOpen(void) const | ||
{ | ||
if (m_hls == NULL) | ||
return false; | ||
return m_hls->IsOpen(); | ||
} | ||
|
||
bool IPTVFeederHLS::Open(const QString &url) | ||
{ | ||
LOG(VB_RECORD, LOG_INFO, LOC + QString("Open(%1) -- begin").arg(url)); | ||
|
||
QMutexLocker locker(&_lock); | ||
|
||
if (m_hls) | ||
{ | ||
LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end 1"); | ||
return true; | ||
} | ||
|
||
m_hls = new HLSRingBuffer(url); | ||
|
||
LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end"); | ||
|
||
return true; | ||
} | ||
|
||
void IPTVFeederHLS::Run(void) | ||
{ | ||
m_lock.lock(); | ||
m_running = true; | ||
m_interrupted = false; | ||
m_lock.unlock(); | ||
|
||
while (!m_interrupted) | ||
{ | ||
if (m_hls == NULL) | ||
break; | ||
m_lock.lock(); | ||
uint size = m_hls->Read((void *)m_buffer, BUFFER_SIZE); | ||
if (m_buffer[0] != 0x47) | ||
{ | ||
LOG(VB_RECORD, LOG_INFO, LOC + | ||
QString("Packet not starting with SYNC Byte (got 0x%1)") | ||
.arg((char)m_buffer[0], 2, QLatin1Char('0'))); | ||
} | ||
|
||
_lock.lock(); | ||
vector<TSDataListener*>::iterator it = _listeners.begin(); | ||
for (; it != _listeners.end(); ++it) | ||
(*it)->AddData(m_buffer, size); | ||
_lock.unlock(); | ||
m_lock.unlock(); | ||
} | ||
|
||
m_running = false; | ||
m_lock.lock(); | ||
m_waitcond.wakeAll(); | ||
m_lock.unlock(); | ||
} | ||
|
||
void IPTVFeederHLS::Stop(void) | ||
{ | ||
LOG(VB_RECORD, LOG_INFO, LOC + "Stop() -- begin"); | ||
QMutexLocker locker(&m_lock); | ||
m_interrupted = true; | ||
|
||
while (m_running) | ||
m_waitcond.wait(&m_lock, 500); | ||
|
||
LOG(VB_RECORD, LOG_INFO, LOC + "Stop() -- end"); | ||
} | ||
|
||
void IPTVFeederHLS::Close(void) | ||
{ | ||
LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- begin"); | ||
Stop(); | ||
|
||
QMutexLocker lock(&m_lock); | ||
delete m_hls; | ||
m_hls = NULL; | ||
|
||
LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- end"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// iptvfeederhls.h | ||
// MythTV | ||
// | ||
// Created by Jean-Yves Avenard on 24/05/12. | ||
// Copyright (c) 2012 Bubblestuff Pty Ltd. All rights reserved. | ||
// | ||
|
||
#ifndef MythTV_iptvfeederhls_h | ||
#define MythTV_iptvfeederhls_h | ||
|
||
// MythTV headers | ||
#include "mythcorecontext.h" | ||
#include "iptvfeederlive.h" | ||
|
||
class TSDataListener; | ||
class HLSRingBuffer; | ||
|
||
class IPTVFeederHLS : public IPTVFeederLive | ||
{ | ||
public: | ||
IPTVFeederHLS(); | ||
virtual ~IPTVFeederHLS(); | ||
|
||
bool CanHandle(const QString &url) const { return IsHLS(url); } | ||
bool IsOpen(void) const; | ||
|
||
bool Open(const QString &url); | ||
void Stop(void); | ||
void Close(void); | ||
void Run(void); | ||
|
||
static bool IsHLS(const QString &url); | ||
|
||
private: | ||
uint8_t *m_buffer; | ||
HLSRingBuffer *m_hls; | ||
mutable QMutex m_lock; | ||
QWaitCondition m_waitcond; | ||
bool m_interrupted; | ||
bool m_running; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters