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
38664b80
Commit
38664b80
authored
Jun 08, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: dash: fix setting segment duration time/duration
parent
bfe02ea6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
43 deletions
+74
-43
modules/demux/adaptative/playlist/Segment.cpp
modules/demux/adaptative/playlist/Segment.cpp
+2
-2
modules/demux/adaptative/playlist/SegmentInfoCommon.cpp
modules/demux/adaptative/playlist/SegmentInfoCommon.cpp
+26
-0
modules/demux/adaptative/playlist/SegmentInfoCommon.h
modules/demux/adaptative/playlist/SegmentInfoCommon.h
+2
-0
modules/demux/adaptative/playlist/SegmentInformation.cpp
modules/demux/adaptative/playlist/SegmentInformation.cpp
+17
-20
modules/demux/adaptative/playlist/SegmentList.cpp
modules/demux/adaptative/playlist/SegmentList.cpp
+17
-9
modules/demux/adaptative/playlist/SegmentList.h
modules/demux/adaptative/playlist/SegmentList.h
+4
-3
modules/demux/dash/dash.cpp
modules/demux/dash/dash.cpp
+2
-2
modules/demux/dash/mpd/IsoffMainParser.cpp
modules/demux/dash/mpd/IsoffMainParser.cpp
+4
-7
No files found.
modules/demux/adaptative/playlist/Segment.cpp
View file @
38664b80
...
...
@@ -41,7 +41,7 @@ ISegment::ISegment(const ICanonicalUrl *parent):
{
debugName
=
"Segment"
;
classId
=
CLASSID_ISEGMENT
;
startTime
.
Set
(
VLC_TS_INVALID
);
startTime
.
Set
(
0
);
duration
.
Set
(
0
);
chunksuse
.
Set
(
0
);
}
...
...
@@ -114,7 +114,7 @@ bool ISegment::contains(size_t byte) const
int
ISegment
::
compare
(
ISegment
*
other
)
const
{
if
(
startTime
.
Get
()
!=
VLC_TS_INVALID
)
if
(
duration
.
Get
()
)
{
int64_t
diff
=
startTime
.
Get
()
-
other
->
startTime
.
Get
();
if
(
diff
)
...
...
modules/demux/adaptative/playlist/SegmentInfoCommon.cpp
View file @
38664b80
...
...
@@ -64,3 +64,29 @@ Url SegmentInfoCommon::getUrlSegment() const
ret
.
append
(
baseURLs
.
front
());
return
ret
;
}
bool
SegmentInfoCommon
::
getSegmentNumberByTime
(
const
std
::
vector
<
ISegment
*>
&
segments
,
mtime_t
time
,
uint64_t
*
ret
)
{
if
(
segments
.
empty
()
||
segments
.
front
()
->
duration
.
Get
()
==
0
)
return
false
;
std
::
vector
<
ISegment
*>::
const_iterator
it
=
segments
.
begin
();
while
(
it
!=
segments
.
end
())
{
const
ISegment
*
seg
=
*
it
;
if
(
seg
->
startTime
.
Get
()
>
time
)
{
if
(
it
==
segments
.
begin
())
return
false
;
else
break
;
}
(
*
ret
)
++
;
it
++
;
}
(
*
ret
)
--
;
return
true
;
}
modules/demux/adaptative/playlist/SegmentInfoCommon.h
View file @
38664b80
...
...
@@ -51,6 +51,8 @@ namespace adaptative
void
appendBaseURL
(
const
std
::
string
&
url
);
virtual
Url
getUrlSegment
()
const
;
/* impl */
Property
<
uint64_t
>
duration
;
static
bool
getSegmentNumberByTime
(
const
std
::
vector
<
ISegment
*>
&
,
mtime_t
,
uint64_t
*
);
private:
int
startIndex
;
...
...
modules/demux/adaptative/playlist/SegmentInformation.cpp
View file @
38664b80
...
...
@@ -101,7 +101,7 @@ std::size_t SegmentInformation::getSegments(SegmentInfoType type, vector<ISegmen
}
else
if
(
segmentList
&&
!
segmentList
->
getSegments
().
empty
()
)
{
std
::
vector
<
Segment
*>::
const_iterator
it
;
std
::
vector
<
I
Segment
*>::
const_iterator
it
;
for
(
it
=
segmentList
->
getSegments
().
begin
();
it
!=
segmentList
->
getSegments
().
end
();
++
it
)
{
...
...
@@ -187,35 +187,32 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
bool
SegmentInformation
::
getSegmentNumberByTime
(
mtime_t
time
,
uint64_t
*
ret
)
const
{
MediaSegmentTemplate
*
mediaTemplate
;
if
(
(
mediaTemplate
=
inheritSegmentTemplate
())
)
if
(
mediaSegmentTemplate
)
{
uint64_t
timescale
=
media
Template
->
inheritTimescale
();
mtime_t
duration
=
media
Template
->
duration
.
Get
();
const
uint64_t
timescale
=
mediaSegment
Template
->
inheritTimescale
();
const
mtime_t
duration
=
mediaSegment
Template
->
duration
.
Get
();
if
(
duration
)
{
*
ret
=
time
/
(
CLOCK_FREQ
*
duration
/
timescale
);
return
true
;
}
}
else
{
std
::
vector
<
ISegment
*>
segments
;
getSegments
(
INFOTYPE_MEDIA
,
segments
);
std
::
vector
<
ISegment
*>::
const_iterator
it
;
*
ret
=
0
;
for
(
it
=
segments
.
begin
();
it
!=
segments
.
end
();
++
it
)
{
if
((
*
it
)
->
startTime
.
Get
()
>
VLC_TS_INVALID
&&
(
*
it
)
->
startTime
.
Get
()
>
time
&&
it
!=
segments
.
begin
())
else
if
(
segmentList
&&
!
segmentList
->
getSegments
().
empty
()
)
{
return
true
;
}
(
*
ret
)
++
;
return
segmentList
->
getSegmentNumberByTime
(
time
,
ret
);
}
else
if
(
segmentBase
)
{
const
uint64_t
timescale
=
inheritTimescale
();
time
=
time
*
timescale
/
CLOCK_FREQ
;
*
ret
=
0
;
const
std
::
vector
<
ISegment
*>
list
=
segmentBase
->
subSegments
();
return
SegmentInfoCommon
::
getSegmentNumberByTime
(
list
,
time
,
ret
);
}
if
(
parent
)
return
parent
->
getSegmentNumberByTime
(
time
,
ret
);
else
return
false
;
}
...
...
modules/demux/adaptative/playlist/SegmentList.cpp
View file @
38664b80
...
...
@@ -35,17 +35,17 @@ SegmentList::SegmentList( SegmentInformation *parent ):
}
SegmentList
::~
SegmentList
()
{
std
::
vector
<
Segment
*>::
iterator
it
;
std
::
vector
<
I
Segment
*>::
iterator
it
;
for
(
it
=
segments
.
begin
();
it
!=
segments
.
end
();
++
it
)
delete
(
*
it
);
}
const
std
::
vector
<
Segment
*>&
SegmentList
::
getSegments
()
const
const
std
::
vector
<
I
Segment
*>&
SegmentList
::
getSegments
()
const
{
return
segments
;
}
void
SegmentList
::
addSegment
(
Segment
*
seg
)
void
SegmentList
::
addSegment
(
I
Segment
*
seg
)
{
seg
->
setParent
(
this
);
segments
.
push_back
(
seg
);
...
...
@@ -53,9 +53,9 @@ void SegmentList::addSegment(Segment *seg)
void
SegmentList
::
mergeWith
(
SegmentList
*
updated
)
{
const
Segment
*
lastSegment
=
(
segments
.
empty
())
?
NULL
:
segments
.
back
();
const
I
Segment
*
lastSegment
=
(
segments
.
empty
())
?
NULL
:
segments
.
back
();
std
::
vector
<
Segment
*>::
iterator
it
;
std
::
vector
<
I
Segment
*>::
iterator
it
;
for
(
it
=
updated
->
segments
.
begin
();
it
!=
updated
->
segments
.
end
();
++
it
)
{
if
(
!
lastSegment
||
lastSegment
->
compare
(
*
it
)
<
0
)
...
...
@@ -72,10 +72,10 @@ void SegmentList::pruneBySegmentNumber(uint64_t tobelownum)
return
;
uint64_t
current
=
pruned
;
std
::
vector
<
Segment
*>::
iterator
it
=
segments
.
begin
();
std
::
vector
<
I
Segment
*>::
iterator
it
=
segments
.
begin
();
while
(
it
!=
segments
.
end
()
&&
current
<
tobelownum
)
{
Segment
*
seg
=
*
it
;
I
Segment
*
seg
=
*
it
;
if
(
seg
->
chunksuse
.
Get
())
/* can't prune from here, still in use */
break
;
delete
*
it
;
...
...
@@ -86,10 +86,18 @@ void SegmentList::pruneBySegmentNumber(uint64_t tobelownum)
}
}
bool
SegmentList
::
getSegmentNumberByTime
(
mtime_t
time
,
uint64_t
*
ret
)
const
{
const
uint64_t
timescale
=
inheritTimescale
();
time
=
time
*
timescale
/
CLOCK_FREQ
;
*
ret
=
pruned
;
return
SegmentInfoCommon
::
getSegmentNumberByTime
(
segments
,
time
,
ret
);
}
mtime_t
SegmentList
::
getPlaybackTimeBySegmentNumber
(
uint64_t
number
)
{
if
(
number
<
pruned
||
segments
.
empty
())
return
0
;
return
VLC_TS_INVALID
;
uint64_t
timescale
=
inheritTimescale
();
mtime_t
time
=
segments
.
at
(
0
)
->
startTime
.
Get
();
...
...
@@ -106,7 +114,7 @@ mtime_t SegmentList::getPlaybackTimeBySegmentNumber(uint64_t number)
time
=
number
*
duration
.
Get
();
}
return
CLOCK_FREQ
*
time
/
timescale
;
return
VLC_TS_0
+
CLOCK_FREQ
*
time
/
timescale
;
}
std
::
size_t
SegmentList
::
getOffset
()
const
...
...
modules/demux/adaptative/playlist/SegmentList.h
View file @
38664b80
...
...
@@ -45,15 +45,16 @@ namespace adaptative
SegmentList
(
SegmentInformation
*
=
NULL
);
virtual
~
SegmentList
();
const
std
::
vector
<
Segment
*>&
getSegments
()
const
;
void
addSegment
(
Segment
*
seg
);
const
std
::
vector
<
I
Segment
*>&
getSegments
()
const
;
void
addSegment
(
I
Segment
*
seg
);
void
mergeWith
(
SegmentList
*
);
void
pruneBySegmentNumber
(
uint64_t
);
bool
getSegmentNumberByTime
(
mtime_t
,
uint64_t
*
)
const
;
mtime_t
getPlaybackTimeBySegmentNumber
(
uint64_t
);
std
::
size_t
getOffset
()
const
;
private:
std
::
vector
<
Segment
*>
segments
;
std
::
vector
<
I
Segment
*>
segments
;
std
::
size_t
pruned
;
};
}
...
...
modules/demux/dash/dash.cpp
View file @
38664b80
...
...
@@ -248,7 +248,7 @@ static int Control (demux_t *p_demux, int i_query, va_list args)
!
p_sys
->
p_dashManager
->
getDuration
()
||
!
p_sys
->
p_dashManager
->
setPosition
(
time
))
return
VLC_EGENERIC
;
p_sys
->
i_nzpcr
=
time
;
p_sys
->
i_nzpcr
=
VLC_TS_INVALID
;
break
;
}
...
...
@@ -258,7 +258,7 @@ static int Control (demux_t *p_demux, int i_query, va_list args)
if
(
p_sys
->
p_mpd
->
isLive
()
||
!
p_sys
->
p_dashManager
->
setPosition
(
time
))
return
VLC_EGENERIC
;
p_sys
->
i_nzpcr
=
time
;
p_sys
->
i_nzpcr
=
VLC_TS_INVALID
;
break
;
}
...
...
modules/demux/dash/mpd/IsoffMainParser.cpp
View file @
38664b80
...
...
@@ -301,7 +301,6 @@ size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformat
size_t
IsoffMainParser
::
parseSegmentList
(
Node
*
segListNode
,
SegmentInformation
*
info
)
{
size_t
total
=
0
;
mtime_t
totaltime
=
0
;
if
(
segListNode
)
{
std
::
vector
<
Node
*>
segments
=
DOMHelper
::
getElementByTagName
(
segListNode
,
"SegmentURL"
,
false
);
...
...
@@ -337,15 +336,13 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
seg
->
setByteRange
(
atoi
(
range
.
substr
(
0
,
pos
).
c_str
()),
atoi
(
range
.
substr
(
pos
+
1
,
range
.
size
()).
c_str
()));
}
if
(
totaltime
||
list
->
duration
.
Get
())
if
(
list
->
duration
.
Get
())
{
seg
->
startTime
.
Set
(
totaltime
);
totaltime
+=
list
->
duration
.
Get
();
seg
->
startTime
.
Set
(
nzStartTime
);
seg
->
duration
.
Set
(
list
->
duration
.
Get
());
nzStartTime
+=
list
->
duration
.
Get
();
}
seg
->
startTime
.
Set
(
VLC_TS_0
+
nzStartTime
);
nzStartTime
+=
CLOCK_FREQ
*
list
->
duration
.
Get
();
list
->
addSegment
(
seg
);
total
++
;
}
...
...
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