Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2860a192
Commit
2860a192
authored
Dec 22, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: dash: handle live stream numbered template
($Number$ must be calculated from streaming start time)
parent
6ee46f4b
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
194 additions
and
49 deletions
+194
-49
modules/stream_filter/dash/DASHManager.cpp
modules/stream_filter/dash/DASHManager.cpp
+2
-0
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
...m_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
+9
-5
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
...eam_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
+1
-0
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
+99
-1
modules/stream_filter/dash/mpd/IsoffMainParser.h
modules/stream_filter/dash/mpd/IsoffMainParser.h
+10
-0
modules/stream_filter/dash/mpd/MPD.cpp
modules/stream_filter/dash/mpd/MPD.cpp
+6
-5
modules/stream_filter/dash/mpd/MPD.h
modules/stream_filter/dash/mpd/MPD.h
+3
-0
modules/stream_filter/dash/mpd/Period.cpp
modules/stream_filter/dash/mpd/Period.cpp
+7
-0
modules/stream_filter/dash/mpd/Period.h
modules/stream_filter/dash/mpd/Period.h
+5
-0
modules/stream_filter/dash/mpd/Segment.cpp
modules/stream_filter/dash/mpd/Segment.cpp
+3
-23
modules/stream_filter/dash/mpd/Segment.h
modules/stream_filter/dash/mpd/Segment.h
+3
-6
modules/stream_filter/dash/mpd/SegmentInformation.cpp
modules/stream_filter/dash/mpd/SegmentInformation.cpp
+21
-1
modules/stream_filter/dash/mpd/SegmentInformation.hpp
modules/stream_filter/dash/mpd/SegmentInformation.hpp
+5
-0
modules/stream_filter/dash/mpd/SegmentTemplate.cpp
modules/stream_filter/dash/mpd/SegmentTemplate.cpp
+2
-0
modules/stream_filter/dash/mpd/SegmentTemplate.h
modules/stream_filter/dash/mpd/SegmentTemplate.h
+3
-0
modules/stream_filter/dash/mpd/Url.cpp
modules/stream_filter/dash/mpd/Url.cpp
+15
-8
No files found.
modules/stream_filter/dash/DASHManager.cpp
View file @
2860a192
...
...
@@ -81,6 +81,8 @@ bool DASHManager::start(demux_t *demux)
if
(
!
conManager
)
return
false
;
mpd
->
playbackStart
.
Set
(
time
(
NULL
));
return
true
;
}
...
...
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
View file @
2860a192
...
...
@@ -33,16 +33,21 @@ using namespace dash::http;
AbstractAdaptationLogic
::
AbstractAdaptationLogic
(
MPD
*
mpd_
)
:
mpd
(
mpd_
),
currentPeriod
(
mpd
->
getFirstPeriod
()),
count
(
0
),
prevRepresentation
(
NULL
)
currentPeriod
(
mpd
->
getFirstPeriod
())
{
reset
();
}
AbstractAdaptationLogic
::~
AbstractAdaptationLogic
()
{
}
void
AbstractAdaptationLogic
::
reset
()
{
count
=
0
;
prevRepresentation
=
NULL
;
}
Chunk
*
AbstractAdaptationLogic
::
getNextChunk
(
Streams
::
Type
type
)
{
if
(
!
currentPeriod
)
...
...
@@ -72,8 +77,7 @@ Chunk* AbstractAdaptationLogic::getNextChunk(Streams::Type type)
if
(
count
==
segments
.
size
()
&&
!
b_templated
)
{
currentPeriod
=
mpd
->
getNextPeriod
(
currentPeriod
);
prevRepresentation
=
NULL
;
count
=
0
;
reset
();
return
getNextChunk
(
type
);
}
...
...
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
View file @
2860a192
...
...
@@ -42,6 +42,7 @@ namespace dash
public:
AbstractAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
~
AbstractAdaptationLogic
();
virtual
void
reset
();
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
...
...
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
View file @
2860a192
...
...
@@ -74,6 +74,14 @@ void IsoffMainParser::setMPDAttributes ()
it
=
attr
.
find
(
"type"
);
if
(
it
!=
attr
.
end
())
mpd
->
setType
(
it
->
second
);
it
=
attr
.
find
(
"availabilityStartTime"
);
if
(
it
!=
attr
.
end
())
mpd
->
setAvailabilityStartTime
(
UTCTime
(
it
->
second
));
it
=
attr
.
find
(
"timeShiftBufferDepth"
);
if
(
it
!=
attr
.
end
())
mpd
->
setTimeShiftBufferDepth
(
IsoTime
(
it
->
second
));
}
void
IsoffMainParser
::
parsePeriods
(
Node
*
root
)
...
...
@@ -87,6 +95,8 @@ void IsoffMainParser::parsePeriods(Node *root)
if
(
!
period
)
continue
;
parseSegmentInformation
(
*
it
,
period
);
if
((
*
it
)
->
hasAttribute
(
"start"
))
period
->
startTime
.
Set
(
IsoTime
((
*
it
)
->
getAttributeValue
(
"start"
)));
setAdaptationSets
(
*
it
,
period
);
mpd
->
addPeriod
(
period
);
}
...
...
@@ -117,7 +127,15 @@ size_t IsoffMainParser::parseSegmentTemplate(Node *templateNode, SegmentInformat
std
::
istringstream
in
(
templateNode
->
getAttributeValue
(
"duration"
));
size_t
i
;
in
>>
i
;
mediaTemplate
->
setDuration
(
i
);
mediaTemplate
->
duration
.
Set
(
i
);
}
if
(
templateNode
->
hasAttribute
(
"timescale"
))
{
std
::
istringstream
in
(
templateNode
->
getAttributeValue
(
"timescale"
));
size_t
i
;
in
>>
i
;
mediaTemplate
->
timescale
.
Set
(
i
);
}
InitSegmentTemplate
*
initTemplate
=
NULL
;
...
...
@@ -145,6 +163,13 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation *
total
+=
parseSegmentTemplate
(
DOMHelper
::
getFirstChildElementByName
(
node
,
"SegmentTemplate"
),
info
);
if
(
node
->
hasAttribute
(
"bitstreamSwitching"
))
info
->
setBitstreamSwitching
(
node
->
getAttributeValue
(
"bitstreamSwitching"
)
==
"true"
);
if
(
node
->
hasAttribute
(
"timescale"
))
{
std
::
istringstream
in
(
node
->
getAttributeValue
(
"timescale"
));
uint64_t
i
;
in
>>
i
;
info
->
timescale
.
Set
(
i
);
}
return
total
;
}
...
...
@@ -356,3 +381,76 @@ IsoTime::operator mtime_t () const
{
return
time
;
}
/* i_year: year - 1900 i_month: 0-11 i_mday: 1-31 i_hour: 0-23 i_minute: 0-59 i_second: 0-59 */
static
int64_t
vlc_timegm
(
int
i_year
,
int
i_month
,
int
i_mday
,
int
i_hour
,
int
i_minute
,
int
i_second
)
{
static
const
int
pn_day
[
12
+
1
]
=
{
0
,
31
,
59
,
90
,
120
,
151
,
181
,
212
,
243
,
273
,
304
,
334
};
int64_t
i_day
;
if
(
i_year
<
70
||
i_month
<
0
||
i_month
>
11
||
i_mday
<
1
||
i_mday
>
31
||
i_hour
<
0
||
i_hour
>
23
||
i_minute
<
0
||
i_minute
>
59
||
i_second
<
0
||
i_second
>
59
)
return
-
1
;
/* Count the number of days */
i_day
=
365
*
(
i_year
-
70
)
+
pn_day
[
i_month
]
+
i_mday
-
1
;
#define LEAP(y) ( ((y)%4) == 0 && (((y)%100) != 0 || ((y)%400) == 0) ? 1 : 0)
for
(
int
i
=
70
;
i
<
i_year
;
i
++
)
i_day
+=
LEAP
(
1900
+
i
);
if
(
i_month
>
1
)
i_day
+=
LEAP
(
1900
+
i_year
);
#undef LEAP
/**/
return
((
24
*
i_day
+
i_hour
)
*
60
+
i_minute
)
*
60
+
i_second
;
}
UTCTime
::
UTCTime
(
const
std
::
string
&
str
)
{
enum
{
YEAR
=
0
,
MON
,
DAY
,
HOUR
,
MIN
,
SEC
,
TZ
};
int
values
[
7
]
=
{
0
};
std
::
istringstream
in
(
str
);
try
{
/* Date */
for
(
int
i
=
YEAR
;
i
<=
DAY
&&
!
in
.
eof
();
i
++
)
{
if
(
i
!=
YEAR
)
in
.
ignore
(
1
);
in
>>
values
[
i
];
}
/* Time */
if
(
!
in
.
eof
()
&&
in
.
peek
()
==
'T'
)
{
for
(
int
i
=
HOUR
;
i
<=
SEC
&&
!
in
.
eof
();
i
++
)
{
in
.
ignore
(
1
);
in
>>
values
[
i
];
}
}
/* Timezone */
if
(
!
in
.
eof
()
&&
in
.
peek
()
==
'Z'
)
{
in
.
ignore
(
1
);
while
(
!
in
.
eof
())
{
if
(
in
.
peek
()
==
'+'
)
continue
;
in
>>
values
[
TZ
];
break
;
}
}
time
=
vlc_timegm
(
values
[
YEAR
]
-
1900
,
values
[
MON
]
-
1
,
values
[
DAY
],
values
[
HOUR
],
values
[
MIN
],
values
[
SEC
]
);
time
+=
values
[
TZ
]
*
3600
;
}
catch
(
int
)
{
time
=
0
;
}
}
UTCTime
::
operator
mtime_t
()
const
{
return
time
;
}
modules/stream_filter/dash/mpd/IsoffMainParser.h
View file @
2860a192
...
...
@@ -70,6 +70,16 @@ namespace dash
private:
mtime_t
time
;
};
class
UTCTime
{
public:
UTCTime
(
const
std
::
string
&
);
operator
mtime_t
()
const
;
private:
mtime_t
time
;
};
}
}
...
...
modules/stream_filter/dash/mpd/MPD.cpp
View file @
2860a192
...
...
@@ -37,14 +37,15 @@ MPD::MPD (stream_t *stream_, Profile profile_) :
ICanonicalUrl
(),
stream
(
stream_
),
profile
(
profile_
),
availabilityStartTime
(
-
1
),
availabilityEndTime
(
-
1
),
duration
(
-
1
),
availabilityStartTime
(
0
),
availabilityEndTime
(
0
),
duration
(
0
),
minUpdatePeriod
(
-
1
),
minBufferTime
(
-
1
),
timeShiftBufferDepth
(
-
1
),
minBufferTime
(
0
),
timeShiftBufferDepth
(
0
),
programInfo
(
NULL
)
{
playbackStart
.
Set
(
0
);
}
MPD
::~
MPD
()
...
...
modules/stream_filter/dash/mpd/MPD.h
View file @
2860a192
...
...
@@ -34,6 +34,7 @@
#include "mpd/ICanonicalUrl.hpp"
#include "mpd/ProgramInformation.h"
#include "mpd/Profile.hpp"
#include "Properties.hpp"
namespace
dash
{
...
...
@@ -73,6 +74,8 @@ namespace dash
virtual
Period
*
getFirstPeriod
()
const
;
virtual
Period
*
getNextPeriod
(
Period
*
period
);
Property
<
time_t
>
playbackStart
;
private:
stream_t
*
stream
;
Profile
profile
;
...
...
modules/stream_filter/dash/mpd/Period.cpp
View file @
2860a192
...
...
@@ -37,6 +37,8 @@ using namespace dash::mpd;
Period
::
Period
(
MPD
*
mpd
)
:
SegmentInformation
(
mpd
)
{
duration
.
Set
(
0
);
startTime
.
Set
(
0
);
}
Period
::~
Period
()
...
...
@@ -97,3 +99,8 @@ std::vector<std::string> Period::toString(int indent) const
}
return
ret
;
}
mtime_t
Period
::
getPeriodStart
()
const
{
return
startTime
.
Get
();
}
modules/stream_filter/dash/mpd/Period.h
View file @
2860a192
...
...
@@ -30,6 +30,7 @@
#include "mpd/AdaptationSet.h"
#include "mpd/ICanonicalUrl.hpp"
#include "mpd/SegmentInformation.hpp"
#include "Properties.hpp"
#include "Streams.hpp"
namespace
dash
...
...
@@ -51,6 +52,10 @@ namespace dash
std
::
vector
<
std
::
string
>
toString
(
int
=
0
)
const
;
virtual
Url
getUrlSegment
()
const
;
/* reimpl */
virtual
mtime_t
getPeriodStart
()
const
;
/* reimpl */
Property
<
mtime_t
>
duration
;
Property
<
mtime_t
>
startTime
;
private:
std
::
vector
<
AdaptationSet
*>
adaptationSets
;
...
...
modules/stream_filter/dash/mpd/Segment.cpp
View file @
2860a192
...
...
@@ -40,12 +40,12 @@ using namespace dash::http;
ISegment
::
ISegment
(
const
ICanonicalUrl
*
parent
)
:
ICanonicalUrl
(
parent
),
startByte
(
0
),
endByte
(
0
),
startTime
(
VLC_TS_INVALID
),
duration
(
0
)
endByte
(
0
)
{
debugName
=
"Segment"
;
classId
=
CLASSID_ISEGMENT
;
startTime
.
Set
(
VLC_TS_INVALID
);
duration
.
Set
(
0
);
}
dash
::
http
::
Chunk
*
ISegment
::
getChunk
(
const
std
::
string
&
url
)
...
...
@@ -91,26 +91,6 @@ void ISegment::setByteRange(size_t start, size_t end)
endByte
=
end
;
}
void
ISegment
::
setStartTime
(
mtime_t
ztime
)
{
startTime
=
ztime
;
}
mtime_t
ISegment
::
getStartTime
()
const
{
return
startTime
;
}
mtime_t
ISegment
::
getDuration
()
const
{
return
duration
;
}
void
ISegment
::
setDuration
(
mtime_t
d
)
{
duration
=
d
;
}
size_t
ISegment
::
getOffset
()
const
{
return
startByte
;
...
...
modules/stream_filter/dash/mpd/Segment.h
View file @
2860a192
...
...
@@ -31,6 +31,7 @@
#include "mpd/BaseUrl.h"
#include "mpd/ICanonicalUrl.hpp"
#include "http/Chunk.h"
#include "Properties.hpp"
namespace
dash
{
...
...
@@ -54,25 +55,21 @@ namespace dash
virtual
void
done
();
virtual
dash
::
http
::
Chunk
*
toChunk
(
size_t
,
Representation
*
=
NULL
);
virtual
void
setByteRange
(
size_t
start
,
size_t
end
);
virtual
void
setStartTime
(
mtime_t
ztime
);
virtual
mtime_t
getStartTime
()
const
;
virtual
mtime_t
getDuration
()
const
;
virtual
void
setDuration
(
mtime_t
);
virtual
size_t
getOffset
()
const
;
virtual
std
::
vector
<
ISegment
*>
subSegments
()
=
0
;
virtual
std
::
string
toString
(
int
=
0
)
const
;
virtual
bool
contains
(
size_t
byte
)
const
;
int
getClassId
()
const
;
Property
<
mtime_t
>
startTime
;
Property
<
mtime_t
>
duration
;
static
const
int
CLASSID_ISEGMENT
=
0
;
protected:
size_t
startByte
;
size_t
endByte
;
mtime_t
startTime
;
std
::
string
debugName
;
int
classId
;
mtime_t
duration
;
class
SegmentChunk
:
public
dash
::
http
::
Chunk
{
...
...
modules/stream_filter/dash/mpd/SegmentInformation.cpp
View file @
2860a192
...
...
@@ -36,6 +36,7 @@ SegmentInformation::SegmentInformation(SegmentInformation *parent_) :
for
(
int
i
=
0
;
i
<
InfoTypeCount
;
i
++
)
segmentTemplate
[
i
]
=
NULL
;
bitswitch_policy
=
BITSWITCH_INHERIT
;
timescale
.
Set
(
0
);
}
SegmentInformation
::
SegmentInformation
(
ICanonicalUrl
*
parent_
)
:
...
...
@@ -47,6 +48,7 @@ SegmentInformation::SegmentInformation(ICanonicalUrl * parent_) :
for
(
int
i
=
0
;
i
<
InfoTypeCount
;
i
++
)
segmentTemplate
[
i
]
=
NULL
;
bitswitch_policy
=
BITSWITCH_INHERIT
;
timescale
.
Set
(
0
);
}
SegmentInformation
::~
SegmentInformation
()
...
...
@@ -104,6 +106,24 @@ bool SegmentInformation::canBitswitch() const
return
(
bitswitch_policy
==
BITSWITCH_YES
);
}
uint64_t
SegmentInformation
::
getTimescale
()
const
{
if
(
timescale
.
Get
())
return
timescale
.
Get
();
else
if
(
parent
)
return
parent
->
getTimescale
();
else
return
1
;
}
mtime_t
SegmentInformation
::
getPeriodStart
()
const
{
if
(
parent
)
return
parent
->
getPeriodStart
();
else
return
0
;
}
void
SegmentInformation
::
setSegmentList
(
SegmentList
*
list
)
{
segmentList
=
list
;
...
...
@@ -133,7 +153,7 @@ static void insertIntoSegment(std::vector<Segment *> &seglist, size_t start,
start
+
segment
->
getOffset
(),
end
+
segment
->
getOffset
());
segment
->
addSubSegment
(
subsegment
);
segment
->
s
etStartTime
(
time
);
segment
->
s
tartTime
.
Set
(
time
);
break
;
}
}
...
...
modules/stream_filter/dash/mpd/SegmentInformation.hpp
View file @
2860a192
...
...
@@ -25,6 +25,7 @@
#endif
#include "ICanonicalUrl.hpp"
#include "Properties.hpp"
#include <vlc_common.h>
#include <vector>
...
...
@@ -49,6 +50,8 @@ namespace dash
virtual
~
SegmentInformation
();
std
::
vector
<
ISegment
*>
getSegments
()
const
;
bool
canBitswitch
()
const
;
uint64_t
getTimescale
()
const
;
virtual
mtime_t
getPeriodStart
()
const
;
class
SplitPoint
{
...
...
@@ -87,6 +90,8 @@ namespace dash
BITSWITCH_YES
,
BITSWITCH_NO
}
bitswitch_policy
;
Property
<
uint64_t
>
timescale
;
};
}
}
...
...
modules/stream_filter/dash/mpd/SegmentTemplate.cpp
View file @
2860a192
...
...
@@ -38,6 +38,8 @@ SegmentTemplate::SegmentTemplate( ICanonicalUrl *parent ) :
{
debugName
=
"SegmentTemplate"
;
classId
=
Segment
::
CLASSID_SEGMENT
;
duration
.
Set
(
0
);
timescale
.
Set
(
0
);
}
Url
SegmentTemplate
::
getUrlSegment
()
const
...
...
modules/stream_filter/dash/mpd/SegmentTemplate.h
View file @
2860a192
...
...
@@ -25,6 +25,7 @@
#define SEGMENTTEMPLATE_H
#include "mpd/Segment.h"
#include "Properties.hpp"
namespace
dash
{
...
...
@@ -40,6 +41,8 @@ namespace dash
virtual
bool
isSingleShot
()
const
;
size_t
getStartIndex
()
const
;
void
setStartIndex
(
size_t
);
Property
<
mtime_t
>
duration
;
Property
<
uint64_t
>
timescale
;
private:
size_t
startIndex
;
...
...
modules/stream_filter/dash/mpd/Url.cpp
View file @
2860a192
...
...
@@ -20,6 +20,7 @@
#include "Url.hpp"
#include "Representation.h"
#include "SegmentTemplate.h"
#include "MPD.h"
#include <sstream>
using
namespace
dash
::
mpd
;
...
...
@@ -95,22 +96,28 @@ std::string Url::Component::contextualize(size_t index, const Representation *re
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
stringstream
ss
;
ss
<<
(
templ
->
getDuration
()
*
index
);
ss
<<
(
templ
->
duration
.
Get
()
*
index
);
ret
.
replace
(
pos
,
std
::
string
(
"$Time$"
).
length
(),
ss
.
str
());
}
pos
=
ret
.
find
(
"$Index$"
);
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
stringstream
ss
;
ss
<<
index
;
ret
.
replace
(
pos
,
std
::
string
(
"$Index$"
).
length
(),
ss
.
str
());
}
pos
=
ret
.
find
(
"$Number$"
);
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
stringstream
ss
;
/* live streams / templated */
if
(
templ
&&
rep
->
getMPD
()
->
isLive
()
&&
templ
->
duration
.
Get
())
{
mtime_t
playbackstart
=
rep
->
getMPD
()
->
playbackStart
.
Get
();
mtime_t
streamstart
=
rep
->
getMPD
()
->
getAvailabilityStartTime
();
streamstart
+=
rep
->
getPeriodStart
();
mtime_t
duration
=
templ
->
duration
.
Get
();
uint64_t
timescale
=
templ
->
timescale
.
Get
()
?
templ
->
timescale
.
Get
()
:
rep
->
getTimescale
();
if
(
duration
&&
timescale
)
index
+=
(
playbackstart
-
streamstart
)
*
timescale
/
duration
;
}
ss
<<
index
;
ret
.
replace
(
pos
,
std
::
string
(
"$Number$"
).
length
(),
ss
.
str
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment