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
0ed098b2
Commit
0ed098b2
authored
Oct 12, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: hls: hardcode formats depending on codecs/extension
parent
4bb4f670
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
70 additions
and
59 deletions
+70
-59
modules/demux/hls/HLSStreamFormat.hpp
modules/demux/hls/HLSStreamFormat.hpp
+2
-18
modules/demux/hls/HLSStreams.cpp
modules/demux/hls/HLSStreams.cpp
+5
-1
modules/demux/hls/playlist/HLSSegment.cpp
modules/demux/hls/playlist/HLSSegment.cpp
+1
-18
modules/demux/hls/playlist/HLSSegment.hpp
modules/demux/hls/playlist/HLSSegment.hpp
+0
-1
modules/demux/hls/playlist/Parser.cpp
modules/demux/hls/playlist/Parser.cpp
+56
-17
modules/demux/hls/playlist/Parser.hpp
modules/demux/hls/playlist/Parser.hpp
+2
-0
modules/demux/hls/playlist/Representation.cpp
modules/demux/hls/playlist/Representation.cpp
+2
-4
modules/demux/hls/playlist/Representation.hpp
modules/demux/hls/playlist/Representation.hpp
+2
-0
No files found.
modules/demux/hls/HLSStreamFormat.hpp
View file @
0ed098b2
...
...
@@ -31,24 +31,8 @@ namespace hls
{
public:
static
const
unsigned
UNKNOWN
=
StreamFormat
::
UNSUPPORTED
+
1
;
/* will probe */
static
const
unsigned
MPEG2TS
=
StreamFormat
::
UNSUPPORTED
+
1
;
static
const
unsigned
PACKEDAAC
=
StreamFormat
::
UNSUPPORTED
+
2
;
static
StreamFormat
mimeToFormat
(
const
std
::
string
&
mime
)
{
std
::
string
::
size_type
pos
=
mime
.
find
(
"/"
);
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
string
tail
=
mime
.
substr
(
pos
+
1
);
if
(
tail
==
"aac"
)
return
StreamFormat
(
HLSStreamFormat
::
PACKEDAAC
);
else
if
(
tail
==
"mp2t"
)
return
StreamFormat
(
HLSStreamFormat
::
MPEG2TS
);
else
if
(
tail
==
"binary"
)
return
StreamFormat
(
HLSStreamFormat
::
UNSUPPORTED
);
}
return
StreamFormat
();
}
static
const
unsigned
MPEG2TS
=
StreamFormat
::
UNSUPPORTED
+
2
;
static
const
unsigned
PACKEDAAC
=
StreamFormat
::
UNSUPPORTED
+
3
;
};
}
...
...
modules/demux/hls/HLSStreams.cpp
View file @
0ed098b2
...
...
@@ -55,10 +55,14 @@ AbstractDemuxer * HLSStream::createDemux(const StreamFormat &format)
AbstractDemuxer
*
ret
=
NULL
;
switch
((
unsigned
)
format
)
{
case
HLSStreamFormat
:
:
PACKEDAAC
:
case
HLSStreamFormat
:
:
UNKNOWN
:
ret
=
new
Demuxer
(
p_realdemux
,
"any"
,
fakeesout
->
getEsOut
(),
demuxersource
);
break
;
case
HLSStreamFormat
:
:
PACKEDAAC
:
ret
=
new
Demuxer
(
p_realdemux
,
"avformat"
,
fakeesout
->
getEsOut
(),
demuxersource
);
break
;
case
HLSStreamFormat
:
:
MPEG2TS
:
ret
=
new
Demuxer
(
p_realdemux
,
"ts"
,
fakeesout
->
getEsOut
(),
demuxersource
);
break
;
...
...
modules/demux/hls/playlist/HLSSegment.cpp
View file @
0ed098b2
...
...
@@ -52,27 +52,10 @@ HLSSegment::~HLSSegment()
#endif
}
void
HLSSegment
::
checkFormat
(
block_t
*
p_block
,
SegmentChunk
*
,
BaseRepresentation
*
rep
)
{
if
(
rep
->
getStreamFormat
()
==
StreamFormat
(
HLSStreamFormat
::
UNKNOWN
))
{
if
(
p_block
->
i_buffer
>
3
&&
!
memcmp
(
p_block
->
p_buffer
,
"ID3"
,
3
))
{
rep
->
setMimeType
(
"audio/aac"
);
}
else
{
rep
->
setMimeType
(
"video/mp2t"
);
}
}
}
void
HLSSegment
::
onChunkDownload
(
block_t
**
pp_block
,
SegmentChunk
*
chunk
,
BaseRepresentation
*
rep
)
void
HLSSegment
::
onChunkDownload
(
block_t
**
pp_block
,
SegmentChunk
*
chunk
,
BaseRepresentation
*
)
{
block_t
*
p_block
=
*
pp_block
;
checkFormat
(
p_block
,
chunk
,
rep
);
#ifdef HAVE_GCRYPT
if
(
encryption
.
method
==
SegmentEncryption
::
AES_128
)
{
...
...
modules/demux/hls/playlist/HLSSegment.hpp
View file @
0ed098b2
...
...
@@ -61,7 +61,6 @@ namespace hls
protected:
virtual
void
onChunkDownload
(
block_t
**
,
SegmentChunk
*
,
BaseRepresentation
*
);
/* reimpl */
void
checkFormat
(
block_t
*
,
SegmentChunk
*
,
BaseRepresentation
*
);
SegmentEncryption
encryption
;
#ifdef HAVE_GCRYPT
...
...
modules/demux/hls/playlist/Parser.cpp
View file @
0ed098b2
...
...
@@ -29,6 +29,7 @@
#include "../adaptative/playlist/SegmentList.h"
#include "../adaptative/tools/Retrieve.hpp"
#include "../adaptative/tools/Helper.h"
#include "../HLSStreamFormat.hpp"
#include "M3U8.hpp"
#include "Tags.hpp"
...
...
@@ -37,6 +38,8 @@
#include <cstdio>
#include <sstream>
#include <map>
#include <cctype>
#include <algorithm>
using
namespace
adaptative
;
using
namespace
adaptative
::
playlist
;
...
...
@@ -70,6 +73,55 @@ static void releaseTagsList(std::list<Tag *> &list)
list
.
clear
();
}
void
M3U8Parser
::
setFormatFromCodecs
(
Representation
*
rep
,
const
std
::
string
codecsstring
)
{
std
::
list
<
std
::
string
>
codecs
;
std
::
list
<
std
::
string
>
tokens
=
Helper
::
tokenize
(
codecsstring
,
','
);
std
::
list
<
std
::
string
>::
const_iterator
it
;
for
(
it
=
tokens
.
begin
();
it
!=
tokens
.
end
();
++
it
)
{
/* Truncate init data */
std
::
size_t
pos
=
(
*
it
).
find_first_of
(
'.'
,
0
);
if
(
pos
!=
std
::
string
::
npos
)
codecs
.
push_back
((
*
it
).
substr
(
0
,
pos
));
else
codecs
.
push_back
(
*
it
);
}
if
(
!
codecs
.
empty
())
{
if
(
codecs
.
size
()
==
1
)
{
std
::
string
codec
=
codecs
.
front
();
transform
(
codec
.
begin
(),
codec
.
end
(),
codec
.
begin
(),
(
int
(
*
)(
int
))
std
::
tolower
);
if
(
codec
==
"mp4a"
)
rep
->
streamFormat
=
StreamFormat
(
HLSStreamFormat
::
PACKEDAAC
);
}
else
{
rep
->
streamFormat
=
StreamFormat
(
HLSStreamFormat
::
MPEG2TS
);
}
}
}
void
M3U8Parser
::
setFormatFromExtension
(
Representation
*
rep
,
const
std
::
string
&
filename
)
{
std
::
size_t
pos
=
filename
.
find_last_of
(
'.'
);
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
string
extension
=
filename
.
substr
(
pos
+
1
);
transform
(
extension
.
begin
(),
extension
.
end
(),
extension
.
begin
(),
(
int
(
*
)(
int
))
std
::
tolower
);
if
(
extension
==
"aac"
)
{
rep
->
streamFormat
=
StreamFormat
(
HLSStreamFormat
::
PACKEDAAC
);
}
else
if
(
extension
==
"ts"
||
extension
==
"mp2t"
||
extension
==
"mpeg"
)
{
rep
->
streamFormat
=
StreamFormat
(
HLSStreamFormat
::
MPEG2TS
);
}
}
}
Representation
*
M3U8Parser
::
createRepresentation
(
BaseAdaptationSet
*
adaptSet
,
const
AttributesTag
*
tag
)
{
const
Attribute
*
uriAttr
=
tag
->
getAttributeByName
(
"URI"
);
...
...
@@ -105,22 +157,7 @@ Representation * M3U8Parser::createRepresentation(BaseAdaptationSet *adaptSet, c
rep
->
setBandwidth
(
bwAttr
->
decimal
());
if
(
codecsAttr
)
{
std
::
list
<
std
::
string
>
list
=
Helper
::
tokenize
(
codecsAttr
->
quotedString
(),
','
);
std
::
list
<
std
::
string
>::
const_iterator
it
;
for
(
it
=
list
.
begin
();
it
!=
list
.
end
();
++
it
)
{
std
::
size_t
pos
=
(
*
it
).
find_first_of
(
'.'
,
0
);
if
(
pos
!=
std
::
string
::
npos
)
rep
->
addCodec
((
*
it
).
substr
(
0
,
pos
));
else
rep
->
addCodec
(
*
it
);
}
}
/* if more than 1 codec, don't probe, can't be packed audio */
if
(
rep
->
getCodecs
().
size
()
>
1
)
rep
->
setMimeType
(
"video/mp2t"
);
setFormatFromCodecs
(
rep
,
codecsAttr
->
quotedString
());
if
(
resAttr
)
{
...
...
@@ -219,6 +256,8 @@ void M3U8Parser::parseSegments(vlc_object_t *p_obj, Representation *rep, const s
break
;
segment
->
setSourceUrl
(
uritag
->
getValue
().
value
);
if
((
unsigned
)
rep
->
getStreamFormat
()
==
HLSStreamFormat
::
UNKNOWN
)
setFormatFromExtension
(
rep
,
uritag
->
getValue
().
value
);
if
(
ctx_extinf
)
{
...
...
@@ -417,7 +456,7 @@ M3U8 * M3U8Parser::parse(stream_t *p_stream, const std::string &playlisturl)
if
(
pair
.
second
->
getAttributeByName
(
"TYPE"
)
->
value
!=
"AUDIO"
&&
pair
.
second
->
getAttributeByName
(
"TYPE"
)
->
value
!=
"VIDEO"
)
{
rep
->
s
etMimeType
(
"application/binary"
);
rep
->
s
treamFormat
=
StreamFormat
(
HLSStreamFormat
::
UNSUPPORTED
);
}
if
(
pair
.
second
->
getAttributeByName
(
"LANGUAGE"
))
...
...
modules/demux/hls/playlist/Parser.hpp
View file @
0ed098b2
...
...
@@ -67,6 +67,8 @@ namespace hls
void
createAndFillRepresentation
(
vlc_object_t
*
,
BaseAdaptationSet
*
,
const
AttributesTag
*
,
const
std
::
list
<
Tag
*>&
);
void
parseSegments
(
vlc_object_t
*
,
Representation
*
,
const
std
::
list
<
Tag
*>&
);
void
setFormatFromCodecs
(
Representation
*
,
const
std
::
string
);
void
setFormatFromExtension
(
Representation
*
rep
,
const
std
::
string
&
);
std
::
list
<
Tag
*>
parseEntries
(
stream_t
*
);
};
}
...
...
modules/demux/hls/playlist/Representation.cpp
View file @
0ed098b2
...
...
@@ -43,6 +43,7 @@ Representation::Representation ( BaseAdaptationSet *set ) :
b_loaded
=
false
;
switchpolicy
=
SegmentInformation
::
SWITCH_SEGMENT_ALIGNED
;
/* FIXME: based on streamformat */
nextPlaylistupdate
=
0
;
streamFormat
=
HLSStreamFormat
::
UNKNOWN
;
}
Representation
::~
Representation
()
...
...
@@ -51,10 +52,7 @@ Representation::~Representation ()
StreamFormat
Representation
::
getStreamFormat
()
const
{
if
(
getMimeType
().
empty
())
return
StreamFormat
(
HLSStreamFormat
::
UNKNOWN
);
else
return
HLSStreamFormat
::
mimeToFormat
(
getMimeType
());
return
streamFormat
;
}
bool
Representation
::
isLive
()
const
...
...
modules/demux/hls/playlist/Representation.hpp
View file @
0ed098b2
...
...
@@ -23,6 +23,7 @@
#include "../adaptative/playlist/BaseRepresentation.h"
#include "../adaptative/tools/Properties.hpp"
#include "../HLSStreamFormat.hpp"
namespace
hls
{
...
...
@@ -52,6 +53,7 @@ namespace hls
virtual
void
getDurationsRange
(
mtime_t
*
,
mtime_t
*
)
const
;
/* reimpl */
private:
StreamFormat
streamFormat
;
bool
b_live
;
bool
b_loaded
;
mtime_t
nextPlaylistupdate
;
...
...
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