Skip to content

Commit

Permalink
[HLS] break segment refresh loop rep based
Browse files Browse the repository at this point in the history
  • Loading branch information
peak3d committed Aug 17, 2017
1 parent 9d91623 commit b405f99
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/common/AdaptiveStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,13 @@ bool AdaptiveStream::select_stream(bool force, bool justInit, unsigned int repId
return false;

uint32_t segid(current_rep_ ? current_rep_->get_segment_pos(current_seg_) : 0);
if (current_rep_)
const_cast<adaptive::AdaptiveTree::Representation*>(current_rep_)->flags_ &= ~adaptive::AdaptiveTree::Representation::ENABLED;

current_rep_ = new_rep;

const_cast<adaptive::AdaptiveTree::Representation*>(current_rep_)->flags_ |= adaptive::AdaptiveTree::Representation::ENABLED;

if (observer_)
observer_->OnStreamChange(this, segid);

Expand Down Expand Up @@ -485,6 +489,8 @@ void AdaptiveStream::info(std::ostream &s)
void AdaptiveStream::stop()
{
stopped_ = true;
if (current_rep_)
const_cast<adaptive::AdaptiveTree::Representation*>(current_rep_)->flags_ &= ~adaptive::AdaptiveTree::Representation::ENABLED;
if (thread_data_)
{
delete thread_data_;
Expand Down
20 changes: 10 additions & 10 deletions src/common/AdaptiveTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ namespace adaptive
uint32_t fpsRate_, fpsScale_;
float aspect_;
//Flags
static const unsigned int BYTERANGE = 0;
static const unsigned int INDEXRANGEEXACT = 1;
static const unsigned int TEMPLATE = 2;
static const unsigned int TIMELINE = 4;
static const unsigned int INITIALIZATION = 8;
static const unsigned int SEGMENTBASE = 16;
static const unsigned int SUBTITLESTREAM = 32;
static const unsigned int INCLUDEDSTREAM = 64;
static const unsigned int URLSEGMENTS = 128;
static const uint16_t BYTERANGE = 0;
static const uint16_t INDEXRANGEEXACT = 1;
static const uint16_t TEMPLATE = 2;
static const uint16_t TIMELINE = 4;
static const uint16_t INITIALIZATION = 8;
static const uint16_t SEGMENTBASE = 16;
static const uint16_t SUBTITLESTREAM = 32;
static const uint16_t INCLUDEDSTREAM = 64;
static const uint16_t URLSEGMENTS = 128;
static const uint16_t ENABLED = 256;

uint16_t flags_;
uint16_t hdcpVersion_;
Expand Down Expand Up @@ -290,7 +291,6 @@ namespace adaptive
virtual ~AdaptiveTree();

virtual bool open(const char *url) = 0;
virtual void close() {};
virtual bool prepareRepresentation(Representation *rep, uint64_t segmentId = 0) { return true; };
virtual void OnDataArrived(Representation *rep, const Segment *seg, const uint8_t *src, uint8_t *dst, size_t dstOffset, size_t dataSize);
virtual void OnSegmentDownloaded(Representation *rep, const Segment *seg) {};
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,6 @@ Session::Session(MANIFEST_TYPE manifestType, const char *strURL, const char *str
Session::~Session()
{
kodi::Log(ADDON_LOG_DEBUG, "Session::~Session()");
adaptiveTree_->close();
for (std::vector<STREAM*>::iterator b(streams_.begin()), e(streams_.end()); b != e; ++b)
SAFE_DELETE(*b);
streams_.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/parser/HLSTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool HLSTree::prepareRepresentation(Representation *rep, uint64_t segmentId)
for (unsigned int i(0); i < 20; ++i)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (!m_closing)
if (!(rep->flags_ & Representation::ENABLED))
return false;
}
numRetries -= 2;
Expand Down
2 changes: 0 additions & 2 deletions src/parser/HLSTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace adaptive
virtual ~HLSTree();

virtual bool open(const char *url) override;
virtual void close() override { m_closing = true; };
virtual bool prepareRepresentation(Representation *rep, uint64_t segmentId = 0) override;
virtual bool write_data(void *buffer, size_t buffer_size) override;
virtual void OnDataArrived(Representation *rep, const Segment *seg, const uint8_t *src, uint8_t *dst, size_t dstOffset, size_t dataSize) override;
Expand Down Expand Up @@ -62,7 +61,6 @@ namespace adaptive

std::map<std::string, EXTGROUP> m_extGroups;
bool m_refreshPlayList = true;
bool m_closing = false;
uint8_t m_segmentIntervalSec = 2;
AESDecrypter *m_decrypter;
uint8_t m_iv[16];
Expand Down

0 comments on commit b405f99

Please sign in to comment.