From eed8f4c994d2ec5dc68a2f44fcf097dd499ebe58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Dom=C3=ADnguez=20Vega?= Date: Thu, 16 May 2019 16:03:30 -0400 Subject: [PATCH 1/4] Change the integer type to 64 bits on TimeLine. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Domínguez Vega --- libdash/libdash/include/ITimeline.h | 2 +- libdash/libdash/source/mpd/Timeline.cpp | 4 ++-- libdash/libdash/source/mpd/Timeline.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libdash/libdash/include/ITimeline.h b/libdash/libdash/include/ITimeline.h index e1f8e953..387c69db 100644 --- a/libdash/libdash/include/ITimeline.h +++ b/libdash/libdash/include/ITimeline.h @@ -43,7 +43,7 @@ namespace dash * \em StartTime corresponds to the \c \@t attribute. * @return an unsigned integer */ - virtual uint32_t GetStartTime () const = 0; + virtual uint64_t GetStartTime () const = 0; /** * Returns the integer that specifies the Segment duration, in units of the value of the \c \@timescale. \n\n diff --git a/libdash/libdash/source/mpd/Timeline.cpp b/libdash/libdash/source/mpd/Timeline.cpp index 624c6585..9eec3dde 100644 --- a/libdash/libdash/source/mpd/Timeline.cpp +++ b/libdash/libdash/source/mpd/Timeline.cpp @@ -23,11 +23,11 @@ Timeline::~Timeline () { } -uint32_t Timeline::GetStartTime () const +uint64_t Timeline::GetStartTime () const { return this->startTime; } -void Timeline::SetStartTime (uint32_t startTime) +void Timeline::SetStartTime (uint64_t startTime) { this->startTime = startTime; } diff --git a/libdash/libdash/source/mpd/Timeline.h b/libdash/libdash/source/mpd/Timeline.h index 3caa331f..b0fb440d 100644 --- a/libdash/libdash/source/mpd/Timeline.h +++ b/libdash/libdash/source/mpd/Timeline.h @@ -27,16 +27,16 @@ namespace dash Timeline (); virtual ~Timeline (); - uint32_t GetStartTime () const; + uint64_t GetStartTime () const; uint32_t GetDuration () const; uint32_t GetRepeatCount () const; - void SetStartTime (uint32_t startTime); + void SetStartTime (uint64_t startTime); void SetDuration (uint32_t duration); void SetRepeatCount (uint32_t repeatCount); private: - uint32_t startTime; + uint64_t startTime; uint32_t duration; uint32_t repeatCount; }; From 949be45ed26b3f6e12a4141ca48490d5ba282a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Dom=C3=ADnguez=20Vega?= Date: Fri, 17 May 2019 07:51:56 -0400 Subject: [PATCH 2/4] Create pthreads as detached so thread resources are freed automatically. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Domínguez Vega --- .gitignore | 1 + libdash/libdash/source/portable/MultiThreading.cpp | 7 ++++++- .../libdashframework/Portable/MultiThreading.cpp | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c59b67d1..aa3ffad6 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ .metadata build +.vscode diff --git a/libdash/libdash/source/portable/MultiThreading.cpp b/libdash/libdash/source/portable/MultiThreading.cpp index 89945ec5..c3e0ead4 100644 --- a/libdash/libdash/source/portable/MultiThreading.cpp +++ b/libdash/libdash/source/portable/MultiThreading.cpp @@ -13,7 +13,12 @@ THREAD_HANDLE CreateThreadPortable (void *(*start_routine) (void *), void * return NULL; } - if(int err = pthread_create(th, NULL, start_routine, arg)) + // Create pthread as detached so it'll free its resources at exit + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + if(int err = pthread_create(th, &attr, start_routine, arg)) { std::cerr << strerror(err) << std::endl; return NULL; diff --git a/libdash/qtsampleplayer/libdashframework/Portable/MultiThreading.cpp b/libdash/qtsampleplayer/libdashframework/Portable/MultiThreading.cpp index 75d831bd..41d8bd3f 100644 --- a/libdash/qtsampleplayer/libdashframework/Portable/MultiThreading.cpp +++ b/libdash/qtsampleplayer/libdashframework/Portable/MultiThreading.cpp @@ -13,7 +13,12 @@ THREAD_HANDLE CreateThreadPortable (void *(*start_routine) (void *), void * return NULL; } - if(int err = pthread_create(th, NULL, start_routine, arg)) + // Create pthread as detached so it'll free its resources at exit + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + if(int err = pthread_create(th, &attr, start_routine, arg)) { std::cerr << strerror(err) << std::endl; return NULL; From 983705d875f8b900e472005fff311358c43d91a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Dom=C3=ADnguez=20Vega?= Date: Fri, 17 May 2019 07:53:20 -0400 Subject: [PATCH 3/4] Fixed error with handling of number formatting in segment templates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Domínguez Vega --- libdash/libdash/source/mpd/SegmentTemplate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdash/libdash/source/mpd/SegmentTemplate.cpp b/libdash/libdash/source/mpd/SegmentTemplate.cpp index b92c4692..42580fc2 100644 --- a/libdash/libdash/source/mpd/SegmentTemplate.cpp +++ b/libdash/libdash/source/mpd/SegmentTemplate.cpp @@ -134,7 +134,7 @@ void SegmentTemplate::FormatChunk (std::string std::string formatTag = "%01d"; if ( (pos = uri.find("%0")) != std::string::npos) - formatTag = uri.substr(pos).append("d"); + formatTag = uri.substr(pos); sprintf(formattedNumber, formatTag.c_str(), number); uri = formattedNumber; From 6a340627fd731959a277d9a35dd44973ebfc2a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Felipe=20Dom=C3=ADnguez=20Vega?= Date: Fri, 17 May 2019 08:26:39 -0400 Subject: [PATCH 4/4] Fixed errors with time on 32 bits. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luis Felipe Domínguez Vega --- libdash/libdash/include/ISegmentTemplate.h | 4 ++-- .../libdash/source/mpd/SegmentTemplate.cpp | 22 +++++++++++++++---- libdash/libdash/source/mpd/SegmentTemplate.h | 9 ++++---- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libdash/libdash/include/ISegmentTemplate.h b/libdash/libdash/include/ISegmentTemplate.h index d7072956..c71fc60f 100644 --- a/libdash/libdash/include/ISegmentTemplate.h +++ b/libdash/libdash/include/ISegmentTemplate.h @@ -126,7 +126,7 @@ namespace dash * This integer will be formated according to a possibly contained format tag in the \em \$Time\$ identifier. * @return a pointer to a dash::mpd::ISegment object */ - virtual ISegment* GetMediaSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const = 0; + virtual ISegment* GetMediaSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const = 0; /** * Returns a pointer to a dash::mpd::ISegment object that represents a Index Segment and can be downloaded. @@ -140,7 +140,7 @@ namespace dash * This integer will be formated according to a possibly contained format tag in the \em \$Time\$ identifier. * @return a pointer to a dash::mpd::ISegment object */ - virtual ISegment* GetIndexSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const = 0; + virtual ISegment* GetIndexSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const = 0; }; } } diff --git a/libdash/libdash/source/mpd/SegmentTemplate.cpp b/libdash/libdash/source/mpd/SegmentTemplate.cpp index 42580fc2..86d3bd02 100644 --- a/libdash/libdash/source/mpd/SegmentTemplate.cpp +++ b/libdash/libdash/source/mpd/SegmentTemplate.cpp @@ -11,6 +11,8 @@ #include "SegmentTemplate.h" +#include + using namespace dash::mpd; using namespace dash::metrics; @@ -73,15 +75,15 @@ ISegment* SegmentTemplate::GetIndexSegmentFromNumber (const std:: { return ToSegment(this->index, baseurls, representationID, bandwidth, dash::metrics::IndexSegment, number); } -ISegment* SegmentTemplate::GetMediaSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const +ISegment* SegmentTemplate::GetMediaSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const { return ToSegment(this->media, baseurls, representationID, bandwidth, dash::metrics::MediaSegment, 0, time); } -ISegment* SegmentTemplate::GetIndexSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const +ISegment* SegmentTemplate::GetIndexSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const { return ToSegment(this->index, baseurls, representationID, bandwidth, dash::metrics::IndexSegment, 0, time); } -std::string SegmentTemplate::ReplaceParameters (const std::string& uri, const std::string& representationID, uint32_t bandwidth, uint32_t number, uint32_t time) const +std::string SegmentTemplate::ReplaceParameters (const std::string& uri, const std::string& representationID, uint32_t bandwidth, uint32_t number, uint64_t time) const { std::vector chunks; std::string replacedUri = ""; @@ -139,7 +141,19 @@ void SegmentTemplate::FormatChunk (std::string sprintf(formattedNumber, formatTag.c_str(), number); uri = formattedNumber; } -ISegment* SegmentTemplate::ToSegment (const std::string& uri, const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, HTTPTransactionType type, uint32_t number, uint32_t time) const +void SegmentTemplate::FormatChunk (std::string& uri, uint64_t number) const +{ + char formattedNumber [50]; + size_t pos = 0; + std::string formatTag = "%01" PRIu64 ""; + + if ( (pos = uri.find("%0")) != std::string::npos) + formatTag = uri.substr(pos); + + sprintf(formattedNumber, formatTag.c_str(), number); + uri = formattedNumber; +} +ISegment* SegmentTemplate::ToSegment (const std::string& uri, const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, HTTPTransactionType type, uint32_t number, uint64_t time) const { Segment *seg = new Segment(); diff --git a/libdash/libdash/source/mpd/SegmentTemplate.h b/libdash/libdash/source/mpd/SegmentTemplate.h index e5782a83..3e474c6b 100644 --- a/libdash/libdash/source/mpd/SegmentTemplate.h +++ b/libdash/libdash/source/mpd/SegmentTemplate.h @@ -36,8 +36,8 @@ namespace dash ISegment* ToBitstreamSwitchingSegment (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth) const; ISegment* GetMediaSegmentFromNumber (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const; ISegment* GetIndexSegmentFromNumber (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const; - ISegment* GetMediaSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const; - ISegment* GetIndexSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const; + ISegment* GetMediaSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const; + ISegment* GetIndexSegmentFromTime (const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const; void SetMedia (const std::string& media); void SetIndex (const std::string& index); @@ -45,10 +45,11 @@ namespace dash void SetBitstreamSwitching (const std::string& bitstreamSwichting); private: - std::string ReplaceParameters (const std::string& uri, const std::string& representationID, uint32_t bandwidth, uint32_t number, uint32_t time) const; + std::string ReplaceParameters (const std::string& uri, const std::string& representationID, uint32_t bandwidth, uint32_t number, uint64_t time) const; void FormatChunk (std::string& uri, uint32_t number) const; + void FormatChunk (std::string& uri, uint64_t number) const; ISegment* ToSegment (const std::string& uri, const std::vector& baseurls, const std::string& representationID, uint32_t bandwidth, - dash::metrics::HTTPTransactionType type, uint32_t number = 0, uint32_t time = 0) const; + dash::metrics::HTTPTransactionType type, uint32_t number = 0, uint64_t time = 0) const; std::string media; std::string index;