Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the integer type to 64 bits on ITimeLine. #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@

.metadata
build
.vscode
4 changes: 2 additions & 2 deletions libdash/libdash/include/ISegmentTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const = 0;
virtual ISegment* GetMediaSegmentFromTime (const std::vector<IBaseUrl *>& 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.
Expand All @@ -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<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const = 0;
virtual ISegment* GetIndexSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const = 0;
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion libdash/libdash/include/ITimeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 19 additions & 5 deletions libdash/libdash/source/mpd/SegmentTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "SegmentTemplate.h"

#include <inttypes.h>

using namespace dash::mpd;
using namespace dash::metrics;

Expand Down Expand Up @@ -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<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const
ISegment* SegmentTemplate::GetMediaSegmentFromTime (const std::vector<IBaseUrl *>& 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<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const
ISegment* SegmentTemplate::GetIndexSegmentFromTime (const std::vector<IBaseUrl *>& 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<std::string> chunks;
std::string replacedUri = "";
Expand Down Expand Up @@ -134,12 +136,24 @@ 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;
}
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<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, HTTPTransactionType type, uint32_t number, uint32_t time) const
ISegment* SegmentTemplate::ToSegment (const std::string& uri, const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, HTTPTransactionType type, uint32_t number, uint64_t time) const
{
Segment *seg = new Segment();

Expand Down
9 changes: 5 additions & 4 deletions libdash/libdash/source/mpd/SegmentTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@ namespace dash
ISegment* ToBitstreamSwitchingSegment (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth) const;
ISegment* GetMediaSegmentFromNumber (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const;
ISegment* GetIndexSegmentFromNumber (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t number) const;
ISegment* GetMediaSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const;
ISegment* GetIndexSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint32_t time) const;
ISegment* GetMediaSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const;
ISegment* GetIndexSegmentFromTime (const std::vector<IBaseUrl *>& baseurls, const std::string& representationID, uint32_t bandwidth, uint64_t time) const;

void SetMedia (const std::string& media);
void SetIndex (const std::string& index);
void SetInitialization (const std::string& initialization);
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<IBaseUrl *>& 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;
Expand Down
4 changes: 2 additions & 2 deletions libdash/libdash/source/mpd/Timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions libdash/libdash/source/mpd/Timeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
7 changes: 6 additions & 1 deletion libdash/libdash/source/portable/MultiThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down