HLS input improvements:
- Added isOpen flag to the SegmentDownloader, so that we do not parse the data remaining from parseStreamHeader - In inputHLS::firstSegment, use streamIsLive to determine vod vs live, rather than the size of userSelect - Replaced check against 'smaller than zero', which always fails due to overflow of unsigned int - Added print before downloading main playlist
This commit is contained in:
parent
f8251cc115
commit
01f11dcfda
2 changed files with 9 additions and 2 deletions
|
@ -211,12 +211,14 @@ namespace Mist{
|
||||||
}
|
}
|
||||||
|
|
||||||
SegmentDownloader::SegmentDownloader(){
|
SegmentDownloader::SegmentDownloader(){
|
||||||
|
isOpen = false;
|
||||||
segDL.onProgress(callbackFunc);
|
segDL.onProgress(callbackFunc);
|
||||||
encrypted = false;
|
encrypted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if packetPtr is at the end of the current segment.
|
/// Returns true if packetPtr is at the end of the current segment.
|
||||||
bool SegmentDownloader::atEnd() const{
|
bool SegmentDownloader::atEnd() const{
|
||||||
|
if (!isOpen){return true;}
|
||||||
return segDL.isEOF();
|
return segDL.isEOF();
|
||||||
// return (packetPtr - segDL.const_data().data() + 188) > segDL.const_data().size();
|
// return (packetPtr - segDL.const_data().data() + 188) > segDL.const_data().size();
|
||||||
}
|
}
|
||||||
|
@ -295,6 +297,7 @@ namespace Mist{
|
||||||
/// Attempts to read a single TS packet from the current segment, setting packetPtr on success
|
/// Attempts to read a single TS packet from the current segment, setting packetPtr on success
|
||||||
void SegmentDownloader::close(){
|
void SegmentDownloader::close(){
|
||||||
packetPtr = 0;
|
packetPtr = 0;
|
||||||
|
isOpen = false;
|
||||||
segDL.close();
|
segDL.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,6 +332,7 @@ namespace Mist{
|
||||||
}
|
}
|
||||||
|
|
||||||
packetPtr = 0;
|
packetPtr = 0;
|
||||||
|
isOpen = true;
|
||||||
HIGH_MSG("Segment download complete and passed sanity checks");
|
HIGH_MSG("Segment download complete and passed sanity checks");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -892,7 +896,7 @@ namespace Mist{
|
||||||
}else{
|
}else{
|
||||||
currentPlaylist = firstSegment();
|
currentPlaylist = firstSegment();
|
||||||
}
|
}
|
||||||
if (currentPlaylist < 0){
|
if (currentPlaylist == 0){
|
||||||
VERYHIGH_MSG("Waiting for segments...");
|
VERYHIGH_MSG("Waiting for segments...");
|
||||||
keepAlive();
|
keepAlive();
|
||||||
Util::wait(500);
|
Util::wait(500);
|
||||||
|
@ -1032,6 +1036,7 @@ namespace Mist{
|
||||||
|
|
||||||
bool isUrl = (uri.find("://") != std::string::npos);
|
bool isUrl = (uri.find("://") != std::string::npos);
|
||||||
if (isUrl){
|
if (isUrl){
|
||||||
|
INFO_MSG("Downloading main playlist file from '%s'", uri.c_str());
|
||||||
HTTP::Downloader plsDL;
|
HTTP::Downloader plsDL;
|
||||||
plsDL.dataTimeout = 15;
|
plsDL.dataTimeout = 15;
|
||||||
plsDL.retryCount = 8;
|
plsDL.retryCount = 8;
|
||||||
|
@ -1228,7 +1233,7 @@ namespace Mist{
|
||||||
/// this will keep the playlists in sync while reading segments.
|
/// this will keep the playlists in sync while reading segments.
|
||||||
size_t inputHLS::firstSegment(){
|
size_t inputHLS::firstSegment(){
|
||||||
// Only one selected? Immediately return the right playlist.
|
// Only one selected? Immediately return the right playlist.
|
||||||
if (userSelect.size() == 1){return getMappedTrackPlaylist(M.getID(userSelect.begin()->first));}
|
if (!streamIsLive){return getMappedTrackPlaylist(M.getID(userSelect.begin()->first));}
|
||||||
uint64_t firstTimeStamp = 0;
|
uint64_t firstTimeStamp = 0;
|
||||||
int tmpId = -1;
|
int tmpId = -1;
|
||||||
int segCount = 0;
|
int segCount = 0;
|
||||||
|
@ -1238,6 +1243,7 @@ namespace Mist{
|
||||||
pListIt != listEntries.end(); pListIt++){
|
pListIt != listEntries.end(); pListIt++){
|
||||||
segCount += pListIt->second.size();
|
segCount += pListIt->second.size();
|
||||||
if (pListIt->second.size()){
|
if (pListIt->second.size()){
|
||||||
|
INSANE_MSG("Playlist %u contains %lu segments, with the earliest segment starting @%zu ms", pListIt->first, pListIt->second.size(), firstTimeStamp);
|
||||||
if (pListIt->second.front().timestamp < firstTimeStamp || tmpId < 0){
|
if (pListIt->second.front().timestamp < firstTimeStamp || tmpId < 0){
|
||||||
firstTimeStamp = pListIt->second.front().timestamp;
|
firstTimeStamp = pListIt->second.front().timestamp;
|
||||||
tmpId = pListIt->first;
|
tmpId = pListIt->first;
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace Mist{
|
||||||
size_t encOffset;
|
size_t encOffset;
|
||||||
unsigned char tmpIvec[16];
|
unsigned char tmpIvec[16];
|
||||||
mbedtls_aes_context aes;
|
mbedtls_aes_context aes;
|
||||||
|
bool isOpen;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Playlist{
|
class Playlist{
|
||||||
|
|
Loading…
Add table
Reference in a new issue