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
84bff07d
Commit
84bff07d
authored
Nov 17, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stream_filter: dash: deduplicate code
parent
3a87d56e
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
214 additions
and
242 deletions
+214
-242
modules/stream_filter/Makefile.am
modules/stream_filter/Makefile.am
+2
-0
modules/stream_filter/dash/mpd/BasicCMManager.cpp
modules/stream_filter/dash/mpd/BasicCMManager.cpp
+4
-86
modules/stream_filter/dash/mpd/BasicCMManager.h
modules/stream_filter/dash/mpd/BasicCMManager.h
+1
-14
modules/stream_filter/dash/mpd/IMPDManager.cpp
modules/stream_filter/dash/mpd/IMPDManager.cpp
+90
-20
modules/stream_filter/dash/mpd/IMPDManager.h
modules/stream_filter/dash/mpd/IMPDManager.h
+11
-25
modules/stream_filter/dash/mpd/IsoffMainManager.cpp
modules/stream_filter/dash/mpd/IsoffMainManager.cpp
+4
-82
modules/stream_filter/dash/mpd/IsoffMainManager.h
modules/stream_filter/dash/mpd/IsoffMainManager.h
+1
-14
modules/stream_filter/dash/mpd/MPD.h
modules/stream_filter/dash/mpd/MPD.h
+1
-1
modules/stream_filter/dash/mpd/Profile.cpp
modules/stream_filter/dash/mpd/Profile.cpp
+54
-0
modules/stream_filter/dash/mpd/Profile.hpp
modules/stream_filter/dash/mpd/Profile.hpp
+46
-0
No files found.
modules/stream_filter/Makefile.am
View file @
84bff07d
...
...
@@ -57,6 +57,8 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/mpd/MPDManagerFactory.h
\
stream_filter/dash/mpd/Period.cpp
\
stream_filter/dash/mpd/Period.h
\
stream_filter/dash/mpd/Profile.cpp
\
stream_filter/dash/mpd/Profile.hpp
\
stream_filter/dash/mpd/ProgramInformation.cpp
\
stream_filter/dash/mpd/ProgramInformation.h
\
stream_filter/dash/mpd/Representation.cpp
\
...
...
modules/stream_filter/dash/mpd/BasicCMManager.cpp
View file @
84bff07d
...
...
@@ -27,17 +27,12 @@
#include "BasicCMManager.h"
#include <cassert>
using
namespace
dash
::
mpd
;
BasicCMManager
::
BasicCMManager
(
MPD
*
mpd
)
{
this
->
mpd
=
mpd
;
}
BasicCMManager
::~
BasicCMManager
()
BasicCMManager
::
BasicCMManager
(
MPD
*
mpd
)
:
IMPDManager
(
mpd
)
{
delete
this
->
mpd
;
}
std
::
vector
<
Segment
*>
BasicCMManager
::
getSegments
(
const
Representation
*
rep
)
...
...
@@ -52,85 +47,8 @@ std::vector<Segment*> BasicCMManager::getSegments( const Representation *rep )
info
->
getSegments
().
end
()
);
return
retSegments
;
}
const
std
::
vector
<
Period
*>&
BasicCMManager
::
getPeriods
()
const
{
return
this
->
mpd
->
getPeriods
();
}
Representation
*
BasicCMManager
::
getBestRepresentation
(
Period
*
period
)
{
std
::
vector
<
AdaptationSet
*>
adaptSet
=
period
->
getAdaptationSets
();
uint64_t
bitrate
=
0
;
Representation
*
best
=
NULL
;
for
(
size_t
i
=
0
;
i
<
adaptSet
.
size
();
i
++
)
{
std
::
vector
<
Representation
*>
reps
=
adaptSet
.
at
(
i
)
->
getRepresentations
();
for
(
size_t
j
=
0
;
j
<
reps
.
size
();
j
++
)
{
uint64_t
currentBitrate
=
reps
.
at
(
j
)
->
getBandwidth
();
if
(
currentBitrate
>
bitrate
)
{
bitrate
=
currentBitrate
;
best
=
reps
.
at
(
j
);
}
}
}
return
best
;
}
Period
*
BasicCMManager
::
getFirstPeriod
()
{
std
::
vector
<
Period
*>
periods
=
this
->
mpd
->
getPeriods
();
if
(
periods
.
size
()
==
0
)
return
NULL
;
return
periods
.
at
(
0
);
}
Representation
*
BasicCMManager
::
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
{
std
::
vector
<
AdaptationSet
*>
adaptSet
=
period
->
getAdaptationSets
();
Representation
*
best
=
NULL
;
for
(
size_t
i
=
0
;
i
<
adaptSet
.
size
();
i
++
)
{
std
::
vector
<
Representation
*>
reps
=
adaptSet
.
at
(
i
)
->
getRepresentations
();
for
(
size_t
j
=
0
;
j
<
reps
.
size
();
j
++
)
{
uint64_t
currentBitrate
=
reps
.
at
(
j
)
->
getBandwidth
();
if
(
best
==
NULL
||
(
currentBitrate
>
best
->
getBandwidth
()
&&
currentBitrate
<
bitrate
)
)
{
best
=
reps
.
at
(
j
);
}
}
}
return
best
;
}
Period
*
BasicCMManager
::
getNextPeriod
(
Period
*
period
)
{
std
::
vector
<
Period
*>
periods
=
this
->
mpd
->
getPeriods
();
for
(
size_t
i
=
0
;
i
<
periods
.
size
();
i
++
)
{
if
(
periods
.
at
(
i
)
==
period
&&
(
i
+
1
)
<
periods
.
size
())
return
periods
.
at
(
i
+
1
);
}
return
NULL
;
}
const
MPD
*
BasicCMManager
::
getMPD
()
const
{
return
this
->
mpd
;
}
Representation
*
BasicCMManager
::
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
,
int
,
int
)
const
{
return
this
->
getRepresentation
(
period
,
bitrate
);
return
IMPDManager
::
getRepresentation
(
period
,
bitrate
);
}
modules/stream_filter/dash/mpd/BasicCMManager.h
View file @
84bff07d
...
...
@@ -29,12 +29,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/IMPDManager.h"
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
#include "mpd/IMPDManager.h"
namespace
dash
{
...
...
@@ -44,20 +41,10 @@ namespace dash
{
public:
BasicCMManager
(
MPD
*
mpd
);
virtual
~
BasicCMManager
();
const
std
::
vector
<
Period
*>&
getPeriods
()
const
;
Period
*
getFirstPeriod
();
Period
*
getNextPeriod
(
Period
*
period
);
Representation
*
getBestRepresentation
(
Period
*
period
);
std
::
vector
<
Segment
*>
getSegments
(
const
Representation
*
rep
);
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
;
const
MPD
*
getMPD
()
const
;
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
,
int
width
,
int
height
)
const
;
private:
MPD
*
mpd
;
};
}
}
...
...
modules/stream_filter/dash/mpd/IMPDManager.cpp
View file @
84bff07d
...
...
@@ -25,30 +25,100 @@
using
namespace
dash
::
mpd
;
Profile
::
Name
Profile
::
getNameByURN
(
std
::
string
urn
)
IMPDManager
::
IMPDManager
(
MPD
*
mpd_
)
:
mpd
(
mpd_
)
{
struct
}
IMPDManager
::~
IMPDManager
()
{
delete
mpd
;
}
const
std
::
vector
<
Period
*>&
IMPDManager
::
getPeriods
()
const
{
return
mpd
->
getPeriods
();
}
Period
*
IMPDManager
::
getFirstPeriod
()
const
{
std
::
vector
<
Period
*>
periods
=
getPeriods
();
if
(
!
periods
.
empty
()
)
return
periods
.
front
();
else
return
NULL
;
}
Period
*
IMPDManager
::
getNextPeriod
(
Period
*
period
)
{
std
::
vector
<
Period
*>
periods
=
getPeriods
();
for
(
size_t
i
=
0
;
i
<
periods
.
size
();
i
++
)
{
if
(
periods
.
at
(
i
)
==
period
&&
(
i
+
1
)
<
periods
.
size
())
return
periods
.
at
(
i
+
1
);
}
return
NULL
;
}
const
MPD
*
IMPDManager
::
getMPD
()
const
{
return
mpd
;
}
Representation
*
IMPDManager
::
getBestRepresentation
(
Period
*
period
)
const
{
if
(
period
==
NULL
)
return
NULL
;
std
::
vector
<
AdaptationSet
*>
adaptSet
=
period
->
getAdaptationSets
();
uint64_t
bitrate
=
0
;
Representation
*
best
=
NULL
;
for
(
size_t
i
=
0
;
i
<
adaptSet
.
size
();
i
++
)
{
const
Name
name
;
const
char
*
urn
;
std
::
vector
<
Representation
*>
reps
=
adaptSet
.
at
(
i
)
->
getRepresentations
();
for
(
size_t
j
=
0
;
j
<
reps
.
size
();
j
++
)
{
uint64_t
currentBitrate
=
reps
.
at
(
j
)
->
getBandwidth
();
if
(
currentBitrate
>
bitrate
)
{
bitrate
=
currentBitrate
;
best
=
reps
.
at
(
j
);
}
}
}
urnmap
[]
=
return
best
;
}
Representation
*
IMPDManager
::
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
{
if
(
period
==
NULL
)
return
NULL
;
std
::
vector
<
AdaptationSet
*>
adaptSet
=
period
->
getAdaptationSets
();
Representation
*
best
=
NULL
;
for
(
size_t
i
=
0
;
i
<
adaptSet
.
size
();
i
++
)
{
std
::
vector
<
Representation
*>
reps
=
adaptSet
.
at
(
i
)
->
getRepresentations
();
for
(
size_t
j
=
0
;
j
<
reps
.
size
();
j
++
)
{
{
Full
,
"urn:mpeg:dash:profile:full:2011"
},
{
ISOOnDemand
,
"urn:mpeg:dash:profile:isoff-on-demand:2011"
},
{
ISOOnDemand
,
"urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm"
},
{
ISOOnDemand
,
"urn:mpeg:dash:profile:isoff-ondemand:2011"
},
{
ISOMain
,
"urn:mpeg:dash:profile:isoff-main:2011"
},
{
ISOLive
,
"urn:mpeg:dash:profile:isoff-live:2011"
},
{
MPEG2TSMain
,
"urn:mpeg:dash:profile:mp2t-main:2011"
},
{
MPEG2TSSimple
,
"urn:mpeg:dash:profile:mp2t-simple:2011"
},
{
Unknown
,
""
},
};
for
(
int
i
=
0
;
urnmap
[
i
].
name
!=
Unknown
;
i
++
)
uint64_t
currentBitrate
=
reps
.
at
(
j
)
->
getBandwidth
();
if
(
best
==
NULL
||
(
currentBitrate
>
best
->
getBandwidth
()
&&
currentBitrate
<
bitrate
)
)
{
if
(
urn
==
urnmap
[
i
].
urn
)
return
urnmap
[
i
].
name
;
best
=
reps
.
at
(
j
);
}
}
}
return
Unknown
;
return
best
;
}
modules/stream_filter/dash/mpd/IMPDManager.h
View file @
84bff07d
...
...
@@ -25,6 +25,7 @@
#ifndef IMPDMANAGER_H_
#define IMPDMANAGER_H_
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
...
...
@@ -32,38 +33,23 @@ namespace dash
{
namespace
mpd
{
class
MPD
;
class
Profile
{
public:
enum
Name
{
Unknown
,
Full
,
ISOOnDemand
,
ISOMain
,
ISOLive
,
MPEG2TSMain
,
MPEG2TSSimple
,
};
static
Name
getNameByURN
(
std
::
string
urn
);
};
class
IMPDManager
{
public:
virtual
~
IMPDManager
(){}
IMPDManager
(
MPD
*
mpd
);
virtual
~
IMPDManager
();
virtual
const
std
::
vector
<
Period
*>&
getPeriods
()
const
=
0
;
virtual
Period
*
getFirstPeriod
()
=
0
;
virtual
Period
*
getNextPeriod
(
Period
*
period
)
=
0
;
virtual
Representation
*
getBestRepresentation
(
Period
*
period
)
=
0
;
virtual
const
std
::
vector
<
Period
*>&
getPeriods
()
const
;
virtual
Period
*
getFirstPeriod
()
const
;
virtual
Period
*
getNextPeriod
(
Period
*
period
);
virtual
Representation
*
getBestRepresentation
(
Period
*
period
)
const
;
virtual
std
::
vector
<
Segment
*>
getSegments
(
const
Representation
*
rep
)
=
0
;
virtual
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
=
0
;
virtual
const
MPD
*
getMPD
()
const
=
0
;
virtual
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
;
virtual
const
MPD
*
getMPD
()
const
;
virtual
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
,
int
width
,
int
height
)
const
=
0
;
protected:
MPD
*
mpd
;
};
}
}
...
...
modules/stream_filter/dash/mpd/IsoffMainManager.cpp
View file @
84bff07d
...
...
@@ -30,13 +30,10 @@
using
namespace
dash
::
mpd
;
IsoffMainManager
::
IsoffMainManager
(
MPD
*
mpd
)
IsoffMainManager
::
IsoffMainManager
(
MPD
*
mpd
)
:
IMPDManager
(
mpd
)
{
this
->
mpd
=
mpd
;
}
IsoffMainManager
::~
IsoffMainManager
()
{
delete
this
->
mpd
;
}
std
::
vector
<
Segment
*>
IsoffMainManager
::
getSegments
(
const
Representation
*
rep
)
...
...
@@ -56,82 +53,7 @@ std::vector<Segment*> IsoffMainManager::getSegments (const Repre
retSegments
.
insert
(
retSegments
.
end
(),
list
->
getSegments
().
begin
(),
list
->
getSegments
().
end
());
return
retSegments
;
}
const
std
::
vector
<
Period
*>&
IsoffMainManager
::
getPeriods
()
const
{
return
this
->
mpd
->
getPeriods
();
}
Representation
*
IsoffMainManager
::
getBestRepresentation
(
Period
*
period
)
{
std
::
vector
<
AdaptationSet
*>
adaptationSets
=
period
->
getAdaptationSets
();
int
bitrate
=
0
;
Representation
*
best
=
NULL
;
for
(
size_t
i
=
0
;
i
<
adaptationSets
.
size
();
i
++
)
{
std
::
vector
<
Representation
*>
reps
=
adaptationSets
.
at
(
i
)
->
getRepresentations
();
for
(
size_t
j
=
0
;
j
<
reps
.
size
();
j
++
)
{
int
currentBitrate
=
reps
.
at
(
j
)
->
getBandwidth
();
if
(
currentBitrate
>
bitrate
)
{
bitrate
=
currentBitrate
;
best
=
reps
.
at
(
j
);
}
}
}
return
best
;
}
Period
*
IsoffMainManager
::
getFirstPeriod
()
{
std
::
vector
<
Period
*>
periods
=
this
->
mpd
->
getPeriods
();
if
(
periods
.
size
()
==
0
)
return
NULL
;
return
periods
.
at
(
0
);
}
Representation
*
IsoffMainManager
::
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
{
if
(
period
==
NULL
)
return
NULL
;
std
::
vector
<
AdaptationSet
*>
adaptationSets
=
period
->
getAdaptationSets
();
Representation
*
best
=
NULL
;
for
(
size_t
i
=
0
;
i
<
adaptationSets
.
size
();
i
++
)
{
std
::
vector
<
Representation
*>
reps
=
adaptationSets
.
at
(
i
)
->
getRepresentations
();
for
(
size_t
j
=
0
;
j
<
reps
.
size
();
j
++
)
{
uint64_t
currentBitrate
=
reps
.
at
(
j
)
->
getBandwidth
();
if
(
best
==
NULL
||
(
currentBitrate
>
best
->
getBandwidth
()
&&
currentBitrate
<
bitrate
))
{
best
=
reps
.
at
(
j
);
}
}
}
return
best
;
}
Period
*
IsoffMainManager
::
getNextPeriod
(
Period
*
period
)
{
std
::
vector
<
Period
*>
periods
=
this
->
mpd
->
getPeriods
();
for
(
size_t
i
=
0
;
i
<
periods
.
size
();
i
++
)
{
if
(
periods
.
at
(
i
)
==
period
&&
(
i
+
1
)
<
periods
.
size
())
return
periods
.
at
(
i
+
1
);
}
return
NULL
;
}
const
MPD
*
IsoffMainManager
::
getMPD
()
const
{
return
this
->
mpd
;
}
Representation
*
IsoffMainManager
::
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
,
int
width
,
int
height
)
const
{
if
(
period
==
NULL
)
...
...
@@ -151,7 +73,7 @@ Representation* IsoffMainManager::getRepresentation (Period *per
}
if
(
resMatchReps
.
size
()
==
0
)
return
this
->
getRepresentation
(
period
,
bitrate
);
return
IMPDManager
::
getRepresentation
(
period
,
bitrate
);
Representation
*
best
=
NULL
;
for
(
size_t
j
=
0
;
j
<
resMatchReps
.
size
();
j
++
)
...
...
modules/stream_filter/dash/mpd/IsoffMainManager.h
View file @
84bff07d
...
...
@@ -29,13 +29,10 @@
#include <stdio.h>
#include <stdlib.h>
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/IMPDManager.h"
#include "mpd/AdaptationSet.h"
#include "mpd/Representation.h"
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
#include "mpd/IMPDManager.h"
namespace
dash
{
...
...
@@ -45,20 +42,10 @@ namespace dash
{
public:
IsoffMainManager
(
MPD
*
mpd
);
virtual
~
IsoffMainManager
();
const
std
::
vector
<
Period
*>&
getPeriods
()
const
;
Period
*
getFirstPeriod
();
Period
*
getNextPeriod
(
Period
*
period
);
Representation
*
getBestRepresentation
(
Period
*
period
);
std
::
vector
<
Segment
*>
getSegments
(
const
Representation
*
rep
);
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
)
const
;
const
MPD
*
getMPD
()
const
;
Representation
*
getRepresentation
(
Period
*
period
,
uint64_t
bitrate
,
int
width
,
int
height
)
const
;
private:
MPD
*
mpd
;
};
}
}
...
...
modules/stream_filter/dash/mpd/MPD.h
View file @
84bff07d
...
...
@@ -32,7 +32,7 @@
#include "mpd/Period.h"
#include "mpd/BaseUrl.h"
#include "mpd/ProgramInformation.h"
#include "mpd/
IMPDManager.h
"
#include "mpd/
Profile.hpp
"
namespace
dash
{
...
...
modules/stream_filter/dash/mpd/Profile.cpp
0 → 100644
View file @
84bff07d
/*
* Profile.cpp
*****************************************************************************
* Copyright (C) 2010 - 2014 VideoLAN Authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "Profile.hpp"
using
namespace
dash
::
mpd
;
Profile
::
Name
Profile
::
getNameByURN
(
std
::
string
urn
)
{
struct
{
const
Name
name
;
const
char
*
urn
;
}
urnmap
[]
=
{
{
Full
,
"urn:mpeg:dash:profile:full:2011"
},
{
ISOOnDemand
,
"urn:mpeg:dash:profile:isoff-on-demand:2011"
},
{
ISOOnDemand
,
"urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm"
},
{
ISOOnDemand
,
"urn:mpeg:dash:profile:isoff-ondemand:2011"
},
{
ISOMain
,
"urn:mpeg:dash:profile:isoff-main:2011"
},
{
ISOLive
,
"urn:mpeg:dash:profile:isoff-live:2011"
},
{
MPEG2TSMain
,
"urn:mpeg:dash:profile:mp2t-main:2011"
},
{
MPEG2TSSimple
,
"urn:mpeg:dash:profile:mp2t-simple:2011"
},
{
Unknown
,
""
},
};
for
(
int
i
=
0
;
urnmap
[
i
].
name
!=
Unknown
;
i
++
)
{
if
(
urn
==
urnmap
[
i
].
urn
)
return
urnmap
[
i
].
name
;
}
return
Unknown
;
}
modules/stream_filter/dash/mpd/Profile.hpp
0 → 100644
View file @
84bff07d
/*
* Profile.hpp
*****************************************************************************
* Copyright (C) 2010 - 2014 VideoLAN Authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef PROFILE_HPP
#define PROFILE_HPP
#include <string>
namespace
dash
{
namespace
mpd
{
class
Profile
{
public:
enum
Name
{
Unknown
,
Full
,
ISOOnDemand
,
ISOMain
,
ISOLive
,
MPEG2TSMain
,
MPEG2TSSimple
,
};
static
Name
getNameByURN
(
std
::
string
urn
);
};
}
}
#endif // PROFILE_HPP
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