Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Martin Finkel
VLC
Commits
7fd99fbf
Commit
7fd99fbf
authored
Jun 01, 2021
by
François Cartegnie
🤞
Committed by
Jean-Baptiste Kempf
Jun 02, 2021
Browse files
demux: adaptive: use enum class for format
parent
c68d89c4
Changes
11
Hide whitespace changes
Inline
Side-by-side
modules/demux/adaptive/SegmentTracker.cpp
View file @
7fd99fbf
...
...
@@ -119,7 +119,7 @@ SegmentTracker::SegmentTracker(SharedResources *res,
bufferingLogic
=
bl
;
setAdaptationLogic
(
logic_
);
adaptationSet
=
adaptSet
;
format
=
StreamFormat
::
UNKNOWN
;
format
=
StreamFormat
::
Type
::
Unknown
;
}
SegmentTracker
::~
SegmentTracker
()
...
...
@@ -220,7 +220,7 @@ void SegmentTracker::reset()
next
=
Position
();
resetChunksSequence
();
initializing
=
true
;
format
=
StreamFormat
::
UNKNOWN
;
format
=
StreamFormat
::
Type
::
Unknown
;
}
SegmentTracker
::
ChunkEntry
::
ChunkEntry
()
...
...
@@ -363,7 +363,7 @@ ChunkInterface * SegmentTracker::getNextChunk(bool switch_allowed,
/* advance or don't trigger duplicate events */
next
=
current
=
chunk
.
pos
;
if
(
format
==
StreamFormat
(
StreamFormat
::
UNSUPPORTED
))
if
(
format
==
StreamFormat
(
StreamFormat
::
Type
::
Unsupported
))
return
nullptr
;
/* Can't return chunk because no demux will be created */
/* From this point chunk must be returned */
...
...
@@ -371,14 +371,14 @@ ChunkInterface * SegmentTracker::getNextChunk(bool switch_allowed,
StreamFormat
chunkformat
=
chunk
.
chunk
->
getStreamFormat
();
/* Wrap and probe format */
if
(
chunkformat
==
StreamFormat
(
StreamFormat
::
UNKNOWN
))
if
(
chunkformat
==
StreamFormat
(
StreamFormat
::
Type
::
Unknown
))
{
ProbeableChunk
*
wrappedck
=
new
ProbeableChunk
(
chunk
.
chunk
);
const
uint8_t
*
p_peek
;
size_t
i_peek
=
wrappedck
->
peek
(
&
p_peek
);
chunkformat
=
StreamFormat
(
p_peek
,
i_peek
);
/* fallback on Mime type */
if
(
chunkformat
==
StreamFormat
(
StreamFormat
::
UNKNOWN
))
if
(
chunkformat
==
StreamFormat
(
StreamFormat
::
Type
::
Unknown
))
format
=
StreamFormat
(
chunk
.
chunk
->
getContentType
());
chunk
.
chunk
->
setStreamFormat
(
chunkformat
);
returnedChunk
=
wrappedck
;
...
...
@@ -386,7 +386,7 @@ ChunkInterface * SegmentTracker::getNextChunk(bool switch_allowed,
else
returnedChunk
=
chunk
.
chunk
;
if
(
chunkformat
!=
format
&&
chunkformat
!=
StreamFormat
(
StreamFormat
::
UNKNOWN
))
chunkformat
!=
StreamFormat
(
StreamFormat
::
Type
::
Unknown
))
{
format
=
chunkformat
;
notify
(
FormatChangedEvent
(
&
format
));
...
...
modules/demux/adaptive/StreamFormat.cpp
View file @
7fd99fbf
...
...
@@ -35,38 +35,38 @@ extern "C"
using
namespace
adaptive
;
StreamFormat
::
operator
unsigned
()
const
StreamFormat
::
operator
StreamFormat
::
Type
()
const
{
return
formatid
;
return
type
;
}
std
::
string
StreamFormat
::
str
()
const
{
switch
(
formatid
)
switch
(
type
)
{
case
MPEG2TS
:
case
Type
::
MPEG2TS
:
return
"TS"
;
case
MP4
:
case
Type
::
MP4
:
return
"MP4"
;
case
WEB
VTT
:
case
Type
::
Web
VTT
:
return
"WebVTT"
;
case
TTML
:
case
Type
::
TTML
:
return
"Timed Text"
;
case
PACKED
AAC
:
case
Type
::
Packed
AAC
:
return
"Packed AAC"
;
case
WEB
M
:
case
Type
::
Web
M
:
return
"WebM"
;
case
UNSUPPORTED
:
case
Type
::
Unsupported
:
return
"Unsupported"
;
default:
case
UNKNOWN
:
case
Type
::
Unknown
:
return
"Unknown"
;
}
}
StreamFormat
::
StreamFormat
(
unsigned
formatid
_
)
StreamFormat
::
StreamFormat
(
Type
type
_
)
{
formatid
=
formatid
_
;
type
=
type
_
;
}
StreamFormat
::
StreamFormat
(
const
std
::
string
&
mimetype
)
...
...
@@ -74,22 +74,22 @@ StreamFormat::StreamFormat( const std::string &mimetype )
std
::
string
mime
=
mimetype
;
std
::
transform
(
mime
.
begin
(),
mime
.
end
(),
mime
.
begin
(),
::
tolower
);
std
::
string
::
size_type
pos
=
mime
.
find
(
"/"
);
formatid
=
UNKNOWN
;
type
=
Type
::
Unknown
;
if
(
pos
!=
std
::
string
::
npos
)
{
std
::
string
tail
=
mime
.
substr
(
pos
+
1
);
if
(
tail
==
"mp4"
)
formatid
=
StreamFormat
::
MP4
;
type
=
StreamFormat
::
Type
::
MP4
;
else
if
(
tail
==
"aac"
)
formatid
=
StreamFormat
::
PACKED
AAC
;
type
=
StreamFormat
::
Type
::
Packed
AAC
;
else
if
(
tail
==
"mp2t"
)
formatid
=
StreamFormat
::
MPEG2TS
;
type
=
StreamFormat
::
Type
::
MPEG2TS
;
else
if
(
tail
==
"vtt"
)
formatid
=
StreamFormat
::
WEB
VTT
;
type
=
StreamFormat
::
Type
::
Web
VTT
;
else
if
(
tail
==
"ttml+xml"
)
formatid
=
StreamFormat
::
TTML
;
type
=
StreamFormat
::
Type
::
TTML
;
else
if
(
tail
==
"webm"
)
formatid
=
StreamFormat
::
WEB
M
;
type
=
StreamFormat
::
Type
::
Web
M
;
}
}
...
...
@@ -101,20 +101,20 @@ static int ID3Callback(uint32_t, const uint8_t *, size_t, void *)
StreamFormat
::
StreamFormat
(
const
void
*
data_
,
size_t
sz
)
{
const
uint8_t
*
data
=
reinterpret_cast
<
const
uint8_t
*>
(
data_
);
formatid
=
UNKNOWN
;
type
=
Type
::
Unknown
;
const
char
moov
[]
=
"ftypmoovmoof"
;
if
(
sz
>
188
&&
data
[
0
]
==
0x47
&&
data
[
188
]
==
0x47
)
formatid
=
StreamFormat
::
MPEG2TS
;
type
=
StreamFormat
::
Type
::
MPEG2TS
;
else
if
(
sz
>
8
&&
(
!
memcmp
(
&
moov
,
&
data
[
4
],
4
)
||
!
memcmp
(
&
moov
[
4
],
&
data
[
4
],
4
)
||
!
memcmp
(
&
moov
[
8
],
&
data
[
4
],
4
)))
formatid
=
StreamFormat
::
MP4
;
type
=
StreamFormat
::
Type
::
MP4
;
else
if
(
sz
>
7
&&
!
memcmp
(
"WEBVTT"
,
data
,
6
)
&&
std
::
isspace
(
static_cast
<
unsigned
char
>
(
data
[
7
])))
formatid
=
StreamFormat
::
WEB
VTT
;
type
=
StreamFormat
::
Type
::
Web
VTT
;
else
if
(
sz
>
4
&&
!
memcmp
(
"
\x1A\x45\xDF\xA3
"
,
data
,
4
))
formatid
=
StreamFormat
::
WEB
M
;
type
=
StreamFormat
::
Type
::
Web
M
;
else
/* Check Packet Audio formats */
{
/* It MUST have ID3 header, but HLS spec is an oxymoron */
...
...
@@ -130,7 +130,7 @@ StreamFormat::StreamFormat(const void *data_, size_t sz)
if
(
sz
>
3
&&
(
!
memcmp
(
"
\xFF\xF1
"
,
data
,
2
)
||
!
memcmp
(
"
\xFF\xF9
"
,
data
,
2
)))
{
formatid
=
StreamFormat
::
PACKED
AAC
;
type
=
StreamFormat
::
Type
::
Packed
AAC
;
}
}
}
...
...
@@ -140,12 +140,22 @@ StreamFormat::~StreamFormat()
}
bool
StreamFormat
::
operator
==
(
Type
t
)
const
{
return
type
==
t
;
}
bool
StreamFormat
::
operator
!=
(
Type
t
)
const
{
return
type
!=
t
;
}
bool
StreamFormat
::
operator
==
(
const
StreamFormat
&
other
)
const
{
return
formatid
==
other
.
formatid
;
return
type
==
other
.
type
;
}
bool
StreamFormat
::
operator
!=
(
const
StreamFormat
&
other
)
const
{
return
formatid
!=
other
.
formatid
;
return
type
!=
other
.
type
;
}
modules/demux/adaptive/StreamFormat.hpp
View file @
7fd99fbf
...
...
@@ -28,27 +28,32 @@ namespace adaptive
class
StreamFormat
{
public:
static
const
unsigned
UNSUPPORTED
=
0
;
static
const
unsigned
MPEG2TS
=
1
;
static
const
unsigned
MP4
=
2
;
static
const
unsigned
WEBVTT
=
3
;
static
const
unsigned
TTML
=
4
;
static
const
unsigned
PACKEDAAC
=
5
;
static
const
unsigned
WEBM
=
6
;
static
const
unsigned
UNKNOWN
=
0xFF
;
/* will probe */
enum
class
Type
{
Unsupported
,
MPEG2TS
,
MP4
,
WebM
,
WebVTT
,
TTML
,
PackedAAC
,
Unknown
,
};
static
const
unsigned
PEEK_SIZE
=
4096
;
StreamFormat
(
unsigned
=
UNSUPPORTED
);
StreamFormat
(
Type
=
Type
::
Unsupported
);
explicit
StreamFormat
(
const
std
::
string
&
mime
);
StreamFormat
(
const
void
*
,
size_t
);
~
StreamFormat
();
operator
unsigned
()
const
;
operator
Type
()
const
;
std
::
string
str
()
const
;
bool
operator
==
(
Type
)
const
;
bool
operator
!=
(
Type
)
const
;
bool
operator
==
(
const
StreamFormat
&
)
const
;
bool
operator
!=
(
const
StreamFormat
&
)
const
;
private:
unsigned
formatid
;
Type
type
;
};
}
...
...
modules/demux/adaptive/Streams.cpp
View file @
7fd99fbf
...
...
@@ -42,7 +42,7 @@ using namespace adaptive::http;
AbstractStream
::
AbstractStream
(
demux_t
*
demux_
)
{
p_realdemux
=
demux_
;
format
=
StreamFormat
::
UNKNOWN
;
format
=
StreamFormat
::
Type
::
Unknown
;
currentChunk
=
nullptr
;
eof
=
false
;
valid
=
true
;
...
...
@@ -63,7 +63,7 @@ AbstractStream::AbstractStream(demux_t * demux_)
bool
AbstractStream
::
init
(
const
StreamFormat
&
format_
,
SegmentTracker
*
tracker
,
AbstractConnectionManager
*
conn
)
{
/* Don't even try if not supported or already init */
if
(
(
unsigned
)
format_
==
StreamFormat
::
UNSUPPORTED
||
demuxersource
)
if
(
format_
==
StreamFormat
::
Type
::
Unsupported
||
demuxersource
)
return
false
;
demuxersource
=
new
(
std
::
nothrow
)
BufferedChunksSourceStream
(
VLC_OBJECT
(
p_realdemux
),
this
);
...
...
@@ -613,18 +613,18 @@ AbstractDemuxer *AbstractStream::newDemux(vlc_object_t *p_obj, const StreamForma
es_out_t
*
out
,
AbstractSourceStream
*
source
)
const
{
AbstractDemuxer
*
ret
=
nullptr
;
switch
(
(
unsigned
)
format
)
switch
(
format
)
{
case
StreamFormat
::
MP4
:
case
StreamFormat
::
Type
::
MP4
:
ret
=
new
Demuxer
(
p_obj
,
"mp4"
,
out
,
source
);
break
;
case
StreamFormat
::
MPEG2TS
:
case
StreamFormat
::
Type
::
MPEG2TS
:
ret
=
new
Demuxer
(
p_obj
,
"ts"
,
out
,
source
);
break
;
default:
case
StreamFormat
::
UNSUPPORTED
:
case
StreamFormat
::
Type
::
Unsupported
:
break
;
}
return
ret
;
...
...
@@ -662,7 +662,7 @@ void AbstractStream::trackerEvent(const TrackerEvent &ev)
{
if
(
!
demuxer
->
bitstreamSwitchCompatible
()
||
/* HLS variants can move from TS to Raw AAC */
format
==
StreamFormat
(
StreamFormat
::
UNKNOWN
)
||
format
==
StreamFormat
(
StreamFormat
::
Type
::
Unknown
)
||
(
event
.
next
&&
!
event
.
next
->
getAdaptationSet
()
->
isBitSwitchable
()))
needrestart
=
true
;
...
...
modules/demux/adaptive/playlist/BaseRepresentation.cpp
View file @
7fd99fbf
...
...
@@ -96,10 +96,10 @@ void BaseRepresentation::getCodecsDesc(CodecDescriptionList *desc) const
const
StreamFormat
format
=
getStreamFormat
();
switch
(
format
)
{
case
StreamFormat
::
TTML
:
case
StreamFormat
::
Type
::
TTML
:
codecs
.
push_front
(
"stpp"
);
break
;
case
StreamFormat
::
WEB
VTT
:
case
StreamFormat
::
Type
::
Web
VTT
:
codecs
.
push_front
(
"wvtt"
);
break
;
default:
...
...
modules/demux/dash/DASHStream.cpp
View file @
7fd99fbf
...
...
@@ -39,27 +39,27 @@ AbstractDemuxer *DASHStream::newDemux(vlc_object_t *p_obj, const StreamFormat &f
es_out_t
*
out
,
AbstractSourceStream
*
source
)
const
{
AbstractDemuxer
*
ret
=
nullptr
;
switch
(
(
unsigned
)
format
)
switch
(
format
)
{
case
StreamFormat
::
MP4
:
case
StreamFormat
::
MPEG2TS
:
case
StreamFormat
::
Type
::
MP4
:
case
StreamFormat
::
Type
::
MPEG2TS
:
ret
=
AbstractStream
::
newDemux
(
p_obj
,
format
,
out
,
source
);
break
;
case
StreamFormat
::
WEB
M
:
case
StreamFormat
::
Type
::
Web
M
:
ret
=
new
Demuxer
(
p_obj
,
"mkv_trusted"
,
out
,
source
);
break
;
case
StreamFormat
::
WEB
VTT
:
case
StreamFormat
::
Type
::
Web
VTT
:
ret
=
new
SlaveDemuxer
(
p_obj
,
"webvtt"
,
out
,
source
);
break
;
case
StreamFormat
::
TTML
:
case
StreamFormat
::
Type
::
TTML
:
ret
=
new
SlaveDemuxer
(
p_obj
,
"ttml"
,
out
,
source
);
break
;
default:
case
StreamFormat
::
UNSUPPORTED
:
case
StreamFormat
::
Type
::
Unsupported
:
break
;
}
...
...
modules/demux/hls/HLSStreams.cpp
View file @
7fd99fbf
...
...
@@ -128,24 +128,24 @@ AbstractDemuxer *HLSStream::newDemux(vlc_object_t *p_obj, const StreamFormat &fo
es_out_t
*
out
,
AbstractSourceStream
*
source
)
const
{
AbstractDemuxer
*
ret
=
nullptr
;
switch
(
(
unsigned
)
format
)
switch
(
format
)
{
case
StreamFormat
::
PACKED
AAC
:
ret
=
new
Demuxer
(
p_obj
,
"
aac
"
,
out
,
source
);
case
StreamFormat
::
Type
::
Packed
AAC
:
ret
=
new
Demuxer
(
p_obj
,
"
es
"
,
out
,
source
);
break
;
case
StreamFormat
::
MPEG2TS
:
case
StreamFormat
::
Type
::
MPEG2TS
:
ret
=
new
Demuxer
(
p_obj
,
"ts"
,
out
,
source
);
if
(
ret
)
ret
->
setBitstreamSwitchCompatible
(
false
);
/* HLS and unique PAT/PMT versions */
break
;
case
StreamFormat
::
MP4
:
case
StreamFormat
::
Type
::
MP4
:
ret
=
AbstractStream
::
newDemux
(
p_obj
,
format
,
out
,
source
);
break
;
/* Disabled until we can handle empty segments/cue and absolute time
case StreamFormat::
WEB
VTT:
case StreamFormat::
Type::Web
VTT:
ret = new Demuxer(p_obj, "webvttstream", out, source);
if(ret)
ret->setRestartsOnEachSegment(true);
...
...
@@ -153,8 +153,8 @@ AbstractDemuxer *HLSStream::newDemux(vlc_object_t *p_obj, const StreamFormat &fo
*/
default:
case
StreamFormat
::
UNKNOWN
:
case
StreamFormat
::
UNSUPPORTED
:
case
StreamFormat
::
Type
::
Unknown
:
case
StreamFormat
::
Type
::
Unsupported
:
break
;
}
return
ret
;
...
...
modules/demux/hls/playlist/HLSRepresentation.cpp
View file @
7fd99fbf
...
...
@@ -47,7 +47,7 @@ HLSRepresentation::HLSRepresentation ( BaseAdaptationSet *set ) :
b_failed
=
false
;
lastUpdateTime
=
0
;
targetDuration
=
0
;
streamFormat
=
StreamFormat
::
UNKNOWN
;
streamFormat
=
StreamFormat
::
Type
::
Unknown
;
}
HLSRepresentation
::~
HLSRepresentation
()
...
...
modules/demux/hls/playlist/Parser.cpp
View file @
7fd99fbf
...
...
@@ -556,11 +556,11 @@ M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::
if
(
typeattr
->
value
==
"SUBTITLES"
)
{
altAdaptSet
->
setRole
(
Role
(
Role
::
ROLE_SUBTITLE
));
rep
->
streamFormat
=
StreamFormat
(
StreamFormat
::
UNSUPPORTED
);
rep
->
streamFormat
=
StreamFormat
(
StreamFormat
::
Type
::
Unsupported
);
}
else
if
(
typeattr
->
value
!=
"AUDIO"
&&
typeattr
->
value
!=
"VIDEO"
)
{
rep
->
streamFormat
=
StreamFormat
(
StreamFormat
::
UNSUPPORTED
);
rep
->
streamFormat
=
StreamFormat
(
StreamFormat
::
Type
::
Unsupported
);
}
if
(
pair
.
second
->
getAttributeByName
(
"LANGUAGE"
))
...
...
modules/demux/smooth/SmoothStream.cpp
View file @
7fd99fbf
...
...
@@ -34,7 +34,7 @@ SmoothStream::SmoothStream(demux_t *demux)
AbstractDemuxer
*
SmoothStream
::
newDemux
(
vlc_object_t
*
p_obj
,
const
StreamFormat
&
format
,
es_out_t
*
out
,
AbstractSourceStream
*
source
)
const
{
if
(
(
unsigned
)
format
!=
StreamFormat
::
MP4
)
if
(
format
!=
StreamFormat
::
Type
::
MP4
)
return
nullptr
;
return
AbstractStream
::
newDemux
(
p_obj
,
format
,
out
,
source
);
}
...
...
modules/demux/smooth/playlist/QualityLevel.cpp
View file @
7fd99fbf
...
...
@@ -50,7 +50,7 @@ QualityLevel::~QualityLevel ()
StreamFormat
QualityLevel
::
getStreamFormat
()
const
{
return
StreamFormat
(
StreamFormat
::
MP4
);
return
StreamFormat
(
StreamFormat
::
Type
::
MP4
);
}
CodecDescription
*
QualityLevel
::
makeCodecDescription
(
const
std
::
string
&
)
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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