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
d8f1184e
Commit
d8f1184e
authored
Jul 22, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: hls: handle alternative audio/groups
parent
23d44ceb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
15 deletions
+80
-15
modules/demux/hls/playlist/Parser.cpp
modules/demux/hls/playlist/Parser.cpp
+80
-15
No files found.
modules/demux/hls/playlist/Parser.cpp
View file @
d8f1184e
...
...
@@ -35,6 +35,7 @@
#include <vlc_stream.h>
#include <cstdio>
#include <sstream>
#include <map>
using
namespace
adaptative
;
using
namespace
adaptative
::
playlist
;
...
...
@@ -78,12 +79,21 @@ void Parser::parseAdaptationSet(BasePeriod *period, const AttributesTag *)
}
}
void
Parser
::
parseRepresentation
(
BaseAdaptationSet
*
adaptSet
,
const
AttributesTag
*
streaminf
tag
)
void
Parser
::
parseRepresentation
(
BaseAdaptationSet
*
adaptSet
,
const
AttributesTag
*
tag
)
{
if
(
!
streaminf
tag
->
getAttributeByName
(
"URI"
))
if
(
!
tag
->
getAttributeByName
(
"URI"
))
return
;
Url
url
=
Url
(
streaminftag
->
getAttributeByName
(
"URI"
)
->
value
);
Url
url
;
if
(
tag
->
getType
()
==
AttributesTag
::
EXTXMEDIA
)
{
url
=
Url
(
tag
->
getAttributeByName
(
"URI"
)
->
quotedString
());
}
else
{
url
=
Url
(
tag
->
getAttributeByName
(
"URI"
)
->
value
);
}
if
(
!
url
.
hasScheme
())
url
=
url
.
prepend
(
adaptSet
->
getUrlSegment
());
...
...
@@ -97,28 +107,37 @@ void Parser::parseRepresentation(BaseAdaptationSet *adaptSet, const AttributesTa
std
::
list
<
Tag
*>
tagslist
=
parseEntries
(
substream
);
stream_Delete
(
substream
);
parseRepresentation
(
adaptSet
,
streaminf
tag
,
tagslist
);
parseRepresentation
(
adaptSet
,
tag
,
tagslist
);
releaseTagsList
(
tagslist
);
}
}
}
void
Parser
::
parseRepresentation
(
BaseAdaptationSet
*
adaptSet
,
const
AttributesTag
*
streaminf
tag
,
void
Parser
::
parseRepresentation
(
BaseAdaptationSet
*
adaptSet
,
const
AttributesTag
*
tag
,
const
std
::
list
<
Tag
*>
&
tagslist
)
{
const
Attribute
*
uriAttr
=
streaminf
tag
->
getAttributeByName
(
"URI"
);
const
Attribute
*
bwAttr
=
streaminf
tag
->
getAttributeByName
(
"BANDWIDTH"
);
const
Attribute
*
codecsAttr
=
streaminf
tag
->
getAttributeByName
(
"CODECS"
);
const
Attribute
*
uriAttr
=
tag
->
getAttributeByName
(
"URI"
);
const
Attribute
*
bwAttr
=
tag
->
getAttributeByName
(
"BANDWIDTH"
);
const
Attribute
*
codecsAttr
=
tag
->
getAttributeByName
(
"CODECS"
);
Representation
*
rep
=
new
(
std
::
nothrow
)
Representation
(
adaptSet
);
if
(
rep
)
{
if
(
uriAttr
)
{
size_t
pos
=
uriAttr
->
value
.
find_last_of
(
'/'
);
std
::
string
uri
;
if
(
tag
->
getType
()
==
AttributesTag
::
EXTXMEDIA
)
{
uri
=
uriAttr
->
quotedString
();
}
else
{
uri
=
uriAttr
->
value
;
}
size_t
pos
=
uri
.
find_last_of
(
'/'
);
if
(
pos
!=
std
::
string
::
npos
)
rep
->
baseUrl
.
Set
(
new
Url
(
uri
Attr
->
value
.
substr
(
0
,
pos
+
1
)));
rep
->
baseUrl
.
Set
(
new
Url
(
uri
.
substr
(
0
,
pos
+
1
)));
}
if
(
bwAttr
)
...
...
@@ -287,15 +306,61 @@ M3U8 * Parser::parse(const std::string &playlisturl)
bool
b_masterplaylist
=
!
getTagsFromList
(
tagslist
,
AttributesTag
::
EXTXSTREAMINF
).
empty
();
if
(
b_masterplaylist
)
{
std
::
list
<
Tag
*>::
const_iterator
it
;
std
::
map
<
std
::
string
,
AttributesTag
*>
groupsmap
;
/* We'll need to create an adaptation set for each media group / alternative rendering
* we create a list of playlist being and alternative/group */
std
::
list
<
Tag
*>
mediainfotags
=
getTagsFromList
(
tagslist
,
AttributesTag
::
EXTXMEDIA
);
for
(
it
=
mediainfotags
.
begin
();
it
!=
mediainfotags
.
end
();
++
it
)
{
AttributesTag
*
tag
=
dynamic_cast
<
AttributesTag
*>
(
*
it
);
if
(
tag
&&
tag
->
getAttributeByName
(
"URI"
))
{
std
::
pair
<
std
::
string
,
AttributesTag
*>
pair
(
tag
->
getAttributeByName
(
"URI"
)
->
quotedString
(),
tag
);
groupsmap
.
insert
(
pair
);
}
}
/* Then we parse all playlists uri and add them, except when alternative */
BaseAdaptationSet
*
adaptSet
=
new
(
std
::
nothrow
)
BaseAdaptationSet
(
period
);
if
(
adaptSet
)
{
std
::
list
<
Tag
*>
mediainfotags
=
getTagsFromList
(
tagslist
,
AttributesTag
::
EXTXSTREAMINF
);
std
::
list
<
Tag
*>::
const_iterator
it
;
for
(
it
=
mediainfotags
.
begin
();
it
!=
mediainfotags
.
end
();
++
it
)
parseRepresentation
(
adaptSet
,
dynamic_cast
<
AttributesTag
*>
(
*
it
));
period
->
addAdaptationSet
(
adaptSet
);
std
::
list
<
Tag
*>
streaminfotags
=
getTagsFromList
(
tagslist
,
AttributesTag
::
EXTXSTREAMINF
);
for
(
it
=
streaminfotags
.
begin
();
it
!=
streaminfotags
.
end
();
++
it
)
{
AttributesTag
*
tag
=
dynamic_cast
<
AttributesTag
*>
(
*
it
);
if
(
tag
&&
tag
->
getAttributeByName
(
"URI"
))
{
if
(
groupsmap
.
find
(
tag
->
getAttributeByName
(
"URI"
)
->
value
)
==
groupsmap
.
end
())
{
/* not a group, belong to default adaptation set */
parseRepresentation
(
adaptSet
,
tag
);
}
}
}
if
(
!
adaptSet
->
getRepresentations
().
empty
())
period
->
addAdaptationSet
(
adaptSet
);
else
delete
adaptSet
;
}
/* Finally add all groups */
std
::
map
<
std
::
string
,
AttributesTag
*>::
const_iterator
groupsit
;
for
(
groupsit
=
groupsmap
.
begin
();
groupsit
!=
groupsmap
.
end
();
++
groupsit
)
{
BaseAdaptationSet
*
altAdaptSet
=
new
(
std
::
nothrow
)
BaseAdaptationSet
(
period
);
if
(
altAdaptSet
)
{
std
::
pair
<
std
::
string
,
AttributesTag
*>
pair
=
*
groupsit
;
parseRepresentation
(
altAdaptSet
,
pair
.
second
);
if
(
!
altAdaptSet
->
getRepresentations
().
empty
())
period
->
addAdaptationSet
(
altAdaptSet
);
else
delete
altAdaptSet
;
}
}
}
else
{
...
...
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