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
4e6acd5b
Commit
4e6acd5b
authored
Dec 30, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: dash: track segment/periods outside of adaptation logic
Allows switching logic, and fixes startSegment handling.
parent
11008861
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
332 additions
and
138 deletions
+332
-138
modules/demux/Makefile.am
modules/demux/Makefile.am
+2
-1
modules/demux/dash/DASHManager.cpp
modules/demux/dash/DASHManager.cpp
+20
-5
modules/demux/dash/DASHManager.h
modules/demux/dash/DASHManager.h
+3
-3
modules/demux/dash/SegmentTracker.cpp
modules/demux/dash/SegmentTracker.cpp
+99
-0
modules/demux/dash/SegmentTracker.hpp
modules/demux/dash/SegmentTracker.hpp
+70
-0
modules/demux/dash/Streams.cpp
modules/demux/dash/Streams.cpp
+8
-4
modules/demux/dash/Streams.hpp
modules/demux/dash/Streams.hpp
+6
-3
modules/demux/dash/adaptationlogic/AbstractAdaptationLogic.cpp
...es/demux/dash/adaptationlogic/AbstractAdaptationLogic.cpp
+1
-63
modules/demux/dash/adaptationlogic/AbstractAdaptationLogic.h
modules/demux/dash/adaptationlogic/AbstractAdaptationLogic.h
+21
-13
modules/demux/dash/adaptationlogic/AdaptationLogicFactory.cpp
...les/demux/dash/adaptationlogic/AdaptationLogicFactory.cpp
+13
-7
modules/demux/dash/adaptationlogic/AdaptationLogicFactory.h
modules/demux/dash/adaptationlogic/AdaptationLogicFactory.h
+8
-2
modules/demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp
.../demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp
+2
-2
modules/demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
...es/demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
+1
-1
modules/demux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
...emux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
+2
-2
modules/demux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
...emux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
+1
-1
modules/demux/dash/adaptationlogic/IDownloadRateObserver.h
modules/demux/dash/adaptationlogic/IDownloadRateObserver.h
+5
-1
modules/demux/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
...s/demux/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
+9
-8
modules/demux/dash/adaptationlogic/RateBasedAdaptationLogic.h
...les/demux/dash/adaptationlogic/RateBasedAdaptationLogic.h
+2
-2
modules/demux/dash/dash.cpp
modules/demux/dash/dash.cpp
+6
-6
modules/demux/dash/mpd/SegmentInformation.cpp
modules/demux/dash/mpd/SegmentInformation.cpp
+49
-13
modules/demux/dash/mpd/SegmentInformation.hpp
modules/demux/dash/mpd/SegmentInformation.hpp
+2
-0
modules/demux/dash/mpd/Url.cpp
modules/demux/dash/mpd/Url.cpp
+2
-1
No files found.
modules/demux/Makefile.am
View file @
4e6acd5b
...
...
@@ -246,7 +246,6 @@ libdash_plugin_la_SOURCES = \
demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
\
demux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
\
demux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
\
demux/dash/adaptationlogic/IAdaptationLogic.h
\
demux/dash/adaptationlogic/IDownloadRateObserver.h
\
demux/dash/adaptationlogic/RateBasedAdaptationLogic.h
\
demux/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
\
...
...
@@ -326,6 +325,8 @@ libdash_plugin_la_SOURCES = \
demux/dash/Helper.cpp
\
demux/dash/Helper.h
\
demux/dash/Properties.hpp
\
demux/dash/SegmentTracker.cpp
\
demux/dash/SegmentTracker.hpp
\
demux/dash/StreamsType.hpp
\
demux/dash/Streams.cpp
\
demux/dash/Streams.hpp
...
...
modules/demux/dash/DASHManager.cpp
View file @
4e6acd5b
...
...
@@ -29,15 +29,15 @@
#include "DASHManager.h"
#include "adaptationlogic/AdaptationLogicFactory.h"
#include "SegmentTracker.hpp"
using
namespace
dash
;
using
namespace
dash
::
http
;
using
namespace
dash
::
logic
;
using
namespace
dash
::
mpd
;
using
namespace
dash
::
buffer
;
DASHManager
::
DASHManager
(
MPD
*
mpd
,
I
AdaptationLogic
::
LogicType
type
,
stream_t
*
stream
)
:
Abstract
AdaptationLogic
::
LogicType
type
,
stream_t
*
stream
)
:
conManager
(
NULL
),
logicType
(
type
),
mpd
(
mpd
),
...
...
@@ -66,18 +66,33 @@ bool DASHManager::start(demux_t *demux)
const
AdaptationSet
*
set
=
period
->
getAdaptationSet
(
type
);
if
(
set
)
{
streams
[
type
]
=
new
Streams
::
Stream
(
set
->
getMimeType
());
streams
[
type
]
=
new
(
std
::
nothrow
)
Streams
::
Stream
(
set
->
getMimeType
());
if
(
!
streams
[
type
])
continue
;
AbstractAdaptationLogic
*
logic
=
AdaptationLogicFactory
::
create
(
logicType
,
mpd
);
if
(
!
logic
)
{
delete
streams
[
type
];
streams
[
type
]
=
NULL
;
continue
;
}
SegmentTracker
*
tracker
=
new
(
std
::
nothrow
)
SegmentTracker
(
logic
,
mpd
);
try
{
streams
[
type
]
->
create
(
demux
,
AdaptationLogicFactory
::
create
(
logicType
,
mpd
)
);
if
(
!
tracker
)
throw
VLC_ENOMEM
;
streams
[
type
]
->
create
(
demux
,
logic
,
tracker
);
}
catch
(
int
)
{
delete
streams
[
type
];
delete
logic
;
delete
tracker
;
streams
[
type
]
=
NULL
;
}
}
}
conManager
=
new
HTTPConnectionManager
(
stream
);
conManager
=
new
(
std
::
nothrow
)
HTTPConnectionManager
(
stream
);
if
(
!
conManager
)
return
false
;
...
...
modules/demux/dash/DASHManager.h
View file @
4e6acd5b
...
...
@@ -26,7 +26,7 @@
#define DASHMANAGER_H_
#include "http/HTTPConnectionManager.h"
#include "adaptationlogic/
I
AdaptationLogic.h"
#include "adaptationlogic/
Abstract
AdaptationLogic.h"
#include "mpd/MPD.h"
namespace
dash
...
...
@@ -35,7 +35,7 @@ namespace dash
{
public:
DASHManager
(
mpd
::
MPD
*
mpd
,
logic
::
I
AdaptationLogic
::
LogicType
type
,
stream_t
*
stream
);
logic
::
Abstract
AdaptationLogic
::
LogicType
type
,
stream_t
*
stream
);
virtual
~
DASHManager
();
bool
start
(
demux_t
*
);
...
...
@@ -47,7 +47,7 @@ namespace dash
private:
http
::
HTTPConnectionManager
*
conManager
;
logic
::
I
AdaptationLogic
::
LogicType
logicType
;
logic
::
Abstract
AdaptationLogic
::
LogicType
logicType
;
mpd
::
MPD
*
mpd
;
stream_t
*
stream
;
Streams
::
Stream
*
streams
[
Streams
::
count
];
...
...
modules/demux/dash/SegmentTracker.cpp
0 → 100644
View file @
4e6acd5b
/*
* SegmentTracker.cpp
*****************************************************************************
* Copyright (C) 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.
*****************************************************************************/
#include "SegmentTracker.hpp"
#include "mpd/MPD.h"
using
namespace
dash
;
using
namespace
dash
::
logic
;
using
namespace
dash
::
http
;
using
namespace
dash
::
mpd
;
SegmentTracker
::
SegmentTracker
(
AbstractAdaptationLogic
*
logic_
,
mpd
::
MPD
*
mpd_
)
{
count
=
0
;
initializing
=
true
;
prevRepresentation
=
NULL
;
currentPeriod
=
mpd_
->
getFirstPeriod
();
setAdaptationLogic
(
logic_
);
mpd
=
mpd_
;
}
SegmentTracker
::~
SegmentTracker
()
{
}
void
SegmentTracker
::
setAdaptationLogic
(
AbstractAdaptationLogic
*
logic_
)
{
logic
=
logic_
;
}
void
SegmentTracker
::
resetCounter
()
{
count
=
0
;
prevRepresentation
=
NULL
;
}
Chunk
*
SegmentTracker
::
getNextChunk
(
Streams
::
Type
type
)
{
Representation
*
rep
;
ISegment
*
segment
;
if
(
!
currentPeriod
)
return
NULL
;
if
(
prevRepresentation
&&
!
prevRepresentation
->
canBitswitch
())
rep
=
prevRepresentation
;
else
rep
=
logic
->
getCurrentRepresentation
(
type
,
currentPeriod
);
if
(
rep
==
NULL
)
return
NULL
;
if
(
rep
!=
prevRepresentation
)
{
prevRepresentation
=
rep
;
initializing
=
true
;
}
if
(
initializing
)
{
initializing
=
false
;
segment
=
rep
->
getSegment
(
Representation
::
INFOTYPE_INIT
);
if
(
segment
)
return
segment
->
toChunk
(
count
,
rep
);
}
segment
=
rep
->
getSegment
(
Representation
::
INFOTYPE_MEDIA
,
count
);
if
(
!
segment
)
{
currentPeriod
=
mpd
->
getNextPeriod
(
currentPeriod
);
resetCounter
();
return
getNextChunk
(
type
);
}
Chunk
*
chunk
=
segment
->
toChunk
(
count
,
rep
);
if
(
chunk
)
{
segment
->
done
();
count
++
;
}
return
chunk
;
}
modules/demux/dash/
adaptationlogic/IAdaptationLogic.h
→
modules/demux/dash/
SegmentTracker.hpp
View file @
4e6acd5b
/*
*
IAdaptationLogic.h
*
SegmentTracker.hpp
*****************************************************************************
* Copyright (C) 2010 - 2011 Klagenfurt University
*
* Created on: Aug 10, 2010
* Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
* Christian Timmerer <christian.timmerer@itec.uni-klu.ac.at>
* Copyright (C) 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
...
...
@@ -21,37 +17,54 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef SEGMENTTRACKER_HPP
#define SEGMENTTRACKER_HPP
#ifndef IADAPTATIONLOGIC_H_
#define IADAPTATIONLOGIC_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <http/Chunk.h>
#include <adaptationlogic/IDownloadRateObserver.h>
#include "mpd/Representation.h"
#include "buffer/IBufferObserver.h"
#include "StreamsType.hpp"
#include <vlc_common.h>
namespace
dash
{
namespace
mpd
{
class
MPD
;
class
Period
;
class
Representation
;
class
Segment
;
}
namespace
logic
{
class
IAdaptationLogic
:
public
IDownloadRateObserver
{
public:
enum
LogicType
{
Default
,
AlwaysBest
,
AlwaysLowest
,
RateBased
,
FixedRate
};
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
)
=
0
;
virtual
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
=
0
;
};
class
AbstractAdaptationLogic
;
}
namespace
http
{
class
Chunk
;
}
class
SegmentTracker
{
public:
SegmentTracker
(
logic
::
AbstractAdaptationLogic
*
,
mpd
::
MPD
*
);
~
SegmentTracker
();
void
setAdaptationLogic
(
logic
::
AbstractAdaptationLogic
*
);
void
resetCounter
();
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
private:
bool
initializing
;
uint64_t
count
;
logic
::
AbstractAdaptationLogic
*
logic
;
mpd
::
MPD
*
mpd
;
mpd
::
Period
*
currentPeriod
;
mpd
::
Representation
*
prevRepresentation
;
};
}
#endif
/
* IADAPTATIONLOGIC_H_ */
#endif /
/ SEGMENTTRACKER_HPP
modules/demux/dash/Streams.cpp
View file @
4e6acd5b
...
...
@@ -19,8 +19,9 @@
*****************************************************************************/
#define __STDC_CONSTANT_MACROS
#include "Streams.hpp"
#include "adaptationlogic/
I
AdaptationLogic.h"
#include "adaptationlogic/
Abstract
AdaptationLogic.h"
#include "adaptationlogic/AdaptationLogicFactory.h"
#include "SegmentTracker.hpp"
#include <vlc_stream.h>
#include <vlc_demux.h>
...
...
@@ -46,6 +47,7 @@ void Stream::init(const Type type_, const Format format_)
adaptationLogic
=
NULL
;
currentChunk
=
NULL
;
eof
=
false
;
segmentTracker
=
NULL
;
}
Stream
::~
Stream
()
...
...
@@ -53,6 +55,7 @@ Stream::~Stream()
delete
currentChunk
;
delete
adaptationLogic
;
delete
output
;
delete
segmentTracker
;
}
Type
Stream
::
mimeToType
(
const
std
::
string
&
mime
)
...
...
@@ -84,9 +87,8 @@ Format Stream::mimeToFormat(const std::string &mime)
return
format
;
}
void
Stream
::
create
(
demux_t
*
demux
,
IAdaptationLogic
*
logic
)
void
Stream
::
create
(
demux_t
*
demux
,
AbstractAdaptationLogic
*
logic
,
SegmentTracker
*
tracker
)
{
adaptationLogic
=
logic
;
switch
(
format
)
{
case
Streams
:
:
MP4
:
...
...
@@ -99,6 +101,8 @@ void Stream::create(demux_t *demux, IAdaptationLogic *logic)
throw
VLC_EBADVAR
;
break
;
}
adaptationLogic
=
logic
;
segmentTracker
=
tracker
;
}
bool
Stream
::
isEOF
()
const
...
...
@@ -130,7 +134,7 @@ Chunk * Stream::getChunk()
{
if
(
currentChunk
==
NULL
)
{
currentChunk
=
adaptationLogic
->
getNextChunk
(
type
);
currentChunk
=
segmentTracker
->
getNextChunk
(
type
);
if
(
currentChunk
==
NULL
)
eof
=
true
;
}
...
...
modules/demux/dash/Streams.hpp
View file @
4e6acd5b
...
...
@@ -27,12 +27,14 @@
#include <string>
#include <vlc_common.h>
#include "StreamsType.hpp"
#include "adaptationlogic/
I
AdaptationLogic.h"
#include "adaptationlogic/
Abstract
AdaptationLogic.h"
#include "http/HTTPConnectionManager.h"
#include "http/Chunk.h"
namespace
dash
{
class
SegmentTracker
;
namespace
Streams
{
class
AbstractStreamOutput
;
...
...
@@ -46,7 +48,7 @@ namespace dash
bool
operator
==
(
const
Stream
&
)
const
;
static
Type
mimeToType
(
const
std
::
string
&
mime
);
static
Format
mimeToFormat
(
const
std
::
string
&
mime
);
void
create
(
demux_t
*
,
logic
::
IAdaptationLogic
*
);
void
create
(
demux_t
*
,
logic
::
AbstractAdaptationLogic
*
,
SegmentTracker
*
);
bool
isEOF
()
const
;
mtime_t
getPCR
()
const
;
int
getGroup
()
const
;
...
...
@@ -59,7 +61,8 @@ namespace dash
Type
type
;
Format
format
;
AbstractStreamOutput
*
output
;
logic
::
IAdaptationLogic
*
adaptationLogic
;
logic
::
AbstractAdaptationLogic
*
adaptationLogic
;
SegmentTracker
*
segmentTracker
;
http
::
Chunk
*
currentChunk
;
bool
eof
;
};
...
...
modules/demux/dash/adaptationlogic/AbstractAdaptationLogic.cpp
View file @
4e6acd5b
...
...
@@ -29,78 +29,16 @@
using
namespace
dash
::
logic
;
using
namespace
dash
::
mpd
;
using
namespace
dash
::
http
;
AbstractAdaptationLogic
::
AbstractAdaptationLogic
(
MPD
*
mpd_
)
:
mpd
(
mpd_
),
currentPeriod
(
mpd
->
getFirstPeriod
())
mpd
(
mpd_
)
{
reset
();
}
AbstractAdaptationLogic
::~
AbstractAdaptationLogic
()
{
}
void
AbstractAdaptationLogic
::
reset
()
{
count
=
0
;
prevRepresentation
=
NULL
;
}
Chunk
*
AbstractAdaptationLogic
::
getNextChunk
(
Streams
::
Type
type
)
{
if
(
!
currentPeriod
)
return
NULL
;
Representation
*
rep
;
if
(
prevRepresentation
&&
!
prevRepresentation
->
canBitswitch
())
rep
=
prevRepresentation
;
else
rep
=
getCurrentRepresentation
(
type
);
if
(
rep
==
NULL
)
return
NULL
;
bool
reinit
=
count
&&
(
rep
!=
prevRepresentation
);
prevRepresentation
=
rep
;
std
::
vector
<
ISegment
*>
segments
=
rep
->
getSegments
();
ISegment
*
first
=
segments
.
empty
()
?
NULL
:
segments
.
front
();
if
(
reinit
&&
first
&&
first
->
getClassId
()
==
InitSegment
::
CLASSID_INITSEGMENT
)
return
first
->
toChunk
(
count
,
rep
);
bool
b_templated
=
(
first
&&
!
first
->
isSingleShot
());
if
(
count
==
segments
.
size
()
&&
!
b_templated
)
{
currentPeriod
=
mpd
->
getNextPeriod
(
currentPeriod
);
reset
();
return
getNextChunk
(
type
);
}
ISegment
*
seg
=
NULL
;
if
(
segments
.
size
()
>
count
)
{
seg
=
segments
.
at
(
count
);
}
else
if
(
b_templated
)
{
seg
=
segments
.
back
();
}
if
(
seg
)
{
Chunk
*
chunk
=
seg
->
toChunk
(
count
,
rep
);
count
++
;
seg
->
done
();
return
chunk
;
}
return
NULL
;
}
void
AbstractAdaptationLogic
::
updateDownloadRate
(
size_t
,
mtime_t
)
{
}
modules/demux/dash/adaptationlogic/AbstractAdaptationLogic.h
View file @
4e6acd5b
...
...
@@ -25,34 +25,42 @@
#ifndef ABSTRACTADAPTATIONLOGIC_H_
#define ABSTRACTADAPTATIONLOGIC_H_
#include "adaptationlogic/IAdaptationLogic.h"
#include "http/Chunk.h"
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include <adaptationlogic/IDownloadRateObserver.h>
#include "StreamsType.hpp"
struct
stream_t
;
//
struct stream_t;
namespace
dash
{
namespace
mpd
{
class
MPD
;
class
Period
;
class
Representation
;
}
namespace
logic
{
class
AbstractAdaptationLogic
:
public
I
AdaptationLogic
class
AbstractAdaptationLogic
:
public
I
DownloadRateObserver
{
public:
AbstractAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
~
AbstractAdaptationLogic
();
virtual
void
reset
();
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
virtual
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
,
mpd
::
Period
*
)
const
=
0
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
enum
LogicType
{
Default
,
AlwaysBest
,
AlwaysLowest
,
RateBased
,
FixedRate
};
protected:
dash
::
mpd
::
MPD
*
mpd
;
dash
::
mpd
::
Period
*
currentPeriod
;
size_t
count
;
mpd
::
Representation
*
prevRepresentation
;
};
}
}
...
...
modules/demux/dash/adaptationlogic/AdaptationLogicFactory.cpp
View file @
4e6acd5b
...
...
@@ -30,19 +30,25 @@
#include "adaptationlogic/RateBasedAdaptationLogic.h"
#include "adaptationlogic/AlwaysLowestAdaptationLogic.hpp"
#include <new>
using
namespace
dash
::
logic
;
using
namespace
dash
::
mpd
;
IAdaptationLogic
*
AdaptationLogicFactory
::
create
(
IAdaptationLogic
::
LogicType
logic
,
MPD
*
mpd
)
AbstractAdaptationLogic
*
AdaptationLogicFactory
::
create
(
AbstractAdaptationLogic
::
LogicType
logic
,
MPD
*
mpd
)
{
switch
(
logic
)
{
case
IAdaptationLogic
:
:
AlwaysBest
:
return
new
AlwaysBestAdaptationLogic
(
mpd
);
case
IAdaptationLogic
:
:
AlwaysLowest
:
return
new
AlwaysLowestAdaptationLogic
(
mpd
);
case
IAdaptationLogic
:
:
FixedRate
:
return
new
FixedRateAdaptationLogic
(
mpd
);
case
IAdaptationLogic
:
:
Default
:
case
IAdaptationLogic
:
:
RateBased
:
return
new
RateBasedAdaptationLogic
(
mpd
);
case
AbstractAdaptationLogic
:
:
AlwaysBest
:
return
new
(
std
::
nothrow
)
AlwaysBestAdaptationLogic
(
mpd
);
case
AbstractAdaptationLogic
:
:
AlwaysLowest
:
return
new
(
std
::
nothrow
)
AlwaysLowestAdaptationLogic
(
mpd
);
case
AbstractAdaptationLogic
:
:
FixedRate
:
return
new
(
std
::
nothrow
)
FixedRateAdaptationLogic
(
mpd
);
case
AbstractAdaptationLogic
:
:
Default
:
case
AbstractAdaptationLogic
:
:
RateBased
:
return
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
mpd
);
default:
return
NULL
;
}
...
...
modules/demux/dash/adaptationlogic/AdaptationLogicFactory.h
View file @
4e6acd5b
...
...
@@ -25,18 +25,24 @@
#ifndef ADAPTATIONLOGICFACTORY_H_
#define ADAPTATIONLOGICFACTORY_H_
#include "adaptationlogic/
I
AdaptationLogic.h"
#include "adaptationlogic/
Abstract
AdaptationLogic.h"
struct
stream_t
;
namespace
dash
{
namespace
mpd
{
class
MPD
;
}
namespace
logic
{
class
AdaptationLogicFactory
{
public:
static
IAdaptationLogic
*
create
(
IAdaptationLogic
::
LogicType
logic
,
mpd
::
MPD
*
mpd
);
static
AbstractAdaptationLogic
*
create
(
AbstractAdaptationLogic
::
LogicType
logic
,
mpd
::
MPD
*
mpd
);
};
}
}
...
...
modules/demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp
View file @
4e6acd5b
...
...
@@ -36,8 +36,8 @@ AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic (MPD *mpd) :
{
}
Representation
*
AlwaysBestAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
Representation
*
AlwaysBestAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
,
mpd
::
Period
*
period
)
const
{
RepresentationSelector
selector
;
return
selector
.
select
(
currentP
eriod
,
type
);
return
selector
.
select
(
p
eriod
,
type
);
}
modules/demux/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
View file @
4e6acd5b
...
...
@@ -36,7 +36,7 @@ namespace dash
public:
AlwaysBestAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
virtual
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
,
mpd
::
Period
*
)
const
;
};
}
}
...
...
modules/demux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
View file @
4e6acd5b
...
...
@@ -28,8 +28,8 @@ AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic(mpd::MPD *mpd):
{
}
Representation
*
AlwaysLowestAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
Representation
*
AlwaysLowestAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
,
mpd
::
Period
*
period
)
const
{
RepresentationSelector
selector
;
return
selector
.
select
(
currentP
eriod
,
type
,
0
);
return
selector
.
select
(
p
eriod
,
type
,
0
);
}
modules/demux/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
View file @
4e6acd5b
...
...
@@ -31,7 +31,7 @@ namespace dash
public:
AlwaysLowestAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
virtual
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
,
mpd
::
Period
*
)
const
;
};
}
}
...
...
modules/demux/dash/adaptationlogic/IDownloadRateObserver.h
View file @
4e6acd5b
...
...
@@ -25,7 +25,11 @@
#ifndef IDOWNLOADRATEOBSERVER_H_
#define IDOWNLOADRATEOBSERVER_H_
#include <stdint.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
namespace
dash
{
...
...
modules/demux/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
View file @
4e6acd5b
...
...
@@ -27,6 +27,7 @@
#include "RateBasedAdaptationLogic.h"
#include "Representationselectors.hpp"
#include "mpd/MPD.h"
#include <vlc_common.h>
#include <vlc_variables.h>
...
...
@@ -43,16 +44,16 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (MPD *mpd) :
height
=
var_InheritInteger
(
mpd
->
getVLCObject
(),
"dash-prefheight"
);
}
Representation
*
RateBasedAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
Representation
*
RateBasedAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
,
mpd
::
Period
*
period
)
const
{
if
(
currentP
eriod
==
NULL
)
if
(
p
eriod
==
NULL
)
return
NULL
;
RepresentationSelector
selector
;
Representation
*
rep
=
selector
.
select
(
currentP
eriod
,
type
,
currentBps
,
width
,
height
);
Representation
*
rep
=
selector
.
select
(
p
eriod
,
type
,
currentBps
,
width
,
height
);
if
(
rep
==
NULL
)
{
rep
=
selector
.
select
(
currentP
eriod
,
type
);
rep
=
selector
.
select
(
p
eriod
,
type
);
if
(
rep
==
NULL
)
return
NULL
;
}
...
...
@@ -83,16 +84,16 @@ FixedRateAdaptationLogic::FixedRateAdaptationLogic(mpd::MPD *mpd) :
currentBps
=
var_InheritInteger
(
mpd
->
getVLCObject
(),
"dash-prefbw"
)
*
8192
;
}
Representation
*
FixedRateAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
Representation
*
FixedRateAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
,
mpd
::
Period
*
period
)
const
{
if
(
currentP
eriod
==
NULL
)
if
(
p
eriod
==
NULL
)
return
NULL
;
RepresentationSelector
selector
;
Representation
*
rep
=
selector
.
select
(
currentP
eriod
,
type
,
currentBps
);
Representation
*
rep
=
selector
.
select
(
p
eriod
,
type
,
currentBps
);
if
(
rep
==
NULL
)
{
rep
=
selector
.
select
(
currentP
eriod
,
type
);
rep
=
selector
.
select
(
p
eriod
,
type
);
if
(
rep
==
NULL
)
return
NULL
;
}
...
...
modules/demux/dash/adaptationlogic/RateBasedAdaptationLogic.h
View file @
4e6acd5b
...
...
@@ -38,7 +38,7 @@ namespace dash
public:
RateBasedAdaptationLogic
(
mpd
::
MPD
*
mpd
);
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
,
mpd
::
Period
*
)
const
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
private:
...
...
@@ -54,7 +54,7 @@ namespace dash
public:
FixedRateAdaptationLogic
(
mpd
::
MPD
*
mpd
);
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
,
mpd
::
Period
*
)
const
;
private:
size_t
currentBps
;
...
...
modules/demux/dash/dash.cpp
View file @
4e6acd5b
...
...
@@ -61,10 +61,10 @@ static void Close (vlc_object_t *);
#define DASH_LOGIC_TEXT N_("Adaptation Logic")
static
const
int
pi_logics
[]
=
{
dash
::
logic
::
I
AdaptationLogic
::
RateBased
,
dash
::
logic
::
I
AdaptationLogic
::
FixedRate
,
dash
::
logic
::
I
AdaptationLogic
::
AlwaysLowest
,
dash
::
logic
::
I
AdaptationLogic
::
AlwaysBest
};
static
const
int
pi_logics
[]
=
{
dash
::
logic
::
Abstract
AdaptationLogic
::
RateBased
,
dash
::
logic
::
Abstract
AdaptationLogic
::
FixedRate
,
dash
::
logic
::
Abstract
AdaptationLogic
::
AlwaysLowest
,
dash
::
logic
::
Abstract
AdaptationLogic
::
AlwaysBest
};
static
const
char
*
const
ppsz_logics
[]
=
{
N_
(
"Bandwidth Adaptive"
),
N_
(
"Fixed Bandwidth"
),
...
...
@@ -77,7 +77,7 @@ vlc_module_begin ()
set_capability
(
"demux"
,
10
)
set_category
(
CAT_INPUT
)
set_subcategory
(
SUBCAT_INPUT_DEMUX
)
add_integer
(
"dash-logic"
,
dash
::
logic
::
I
AdaptationLogic
::
Default
,
add_integer
(
"dash-logic"
,
dash
::
logic
::
Abstract
AdaptationLogic
::
Default
,
DASH_LOGIC_TEXT
,
NULL
,
false
)
change_integer_list
(
pi_logics
,
ppsz_logics
)
add_integer
(
"dash-prefwidth"
,
480
,
DASH_WIDTH_TEXT
,
DASH_WIDTH_LONGTEXT
,
true
)
...
...
@@ -134,7 +134,7 @@ static int Open(vlc_object_t *p_obj)
p_sys
->
p_mpd
=
mpd
;
int
logic
=
var_InheritInteger
(
p_obj
,
"dash-logic"
);
dash
::
DASHManager
*
p_dashManager
=
new
dash
::
DASHManager
(
p_sys
->
p_mpd
,
static_cast
<
dash
::
logic
::
I
AdaptationLogic
::
LogicType
>
(
logic
),
static_cast
<
dash
::
logic
::
Abstract
AdaptationLogic
::
LogicType
>
(
logic
),
p_demux
->
s
);
dash
::
mpd
::
Period
*
period
=
mpd
->
getFirstPeriod
();
...
...
modules/demux/dash/mpd/SegmentInformation.cpp
View file @
4e6acd5b
...
...
@@ -63,22 +63,12 @@ vector<ISegment *> SegmentInformation::getSegments() const
{
vector
<
ISegment
*>
retSegments
;
SegmentBase
*
segBase
=
inheritSegmentBase
();
SegmentList
*
segList
=
inheritSegmentList
();
/* init segments are always single segment */
if
(
segBase
&&
segBase
->
getInitSegment
()
)
{
retSegments
.
push_back
(
segBase
->
getInitSegment
()
);
}
else
if
(
segList
&&
segList
->
getInitialisationSegment
()
)
{
retSegments
.
push_back
(
segList
->
getInitialisationSegment
()
);
}
else
if
(
inheritSegmentTemplate
(
INFOTYPE_INIT
)
)
{
retSegments
.
push_back
(
inheritSegmentTemplate
(
INFOTYPE_INIT
)
);
}
ISegment
*
segment
=
getSegment
(
INFOTYPE_INIT
);
if
(
segment
)
retSegments
.
push_back
(
segment
);
if
(
inheritSegmentTemplate
(
INFOTYPE_MEDIA
)
)
{
...
...
@@ -98,6 +88,52 @@ vector<ISegment *> SegmentInformation::getSegments() const
return
retSegments
;
}
ISegment
*
SegmentInformation
::
getSegment
(
SegmentInfoType
type
,
uint64_t
pos
)
const
{
SegmentBase
*
segBase
=
inheritSegmentBase
();
SegmentList
*
segList
=
inheritSegmentList
();
ISegment
*
segment
=
NULL
;
switch
(
type
)
{
case
INFOTYPE_INIT
:
if
(
segBase
&&
segBase
->
getInitSegment
()
)
{
segment
=
segBase
->
getInitSegment
();
}
else
if
(
segList
&&
segList
->
getInitialisationSegment
()
)
{
segment
=
segList
->
getInitialisationSegment
();
}
else
if
(
inheritSegmentTemplate
(
INFOTYPE_INIT
)
)
{
segment
=
inheritSegmentTemplate
(
INFOTYPE_INIT
);
}
break
;
case
INFOTYPE_MEDIA
:
if
(
inheritSegmentTemplate
(
INFOTYPE_MEDIA
)
)
{
segment
=
inheritSegmentTemplate
(
INFOTYPE_MEDIA
);
}
else
if
(
segList
&&
!
segList
->
getSegments
().
empty
()
)
{
std
::
vector
<
Segment
*>
list
=
segList
->
getSegments
();
if
(
pos
<
list
.
size
())
segment
=
list
.
at
(
pos
);
}
break
;
case
INFOTYPE_INDEX
:
//returned with media for now;
default:
break
;
}
return
segment
;
}
bool
SegmentInformation
::
canBitswitch
()
const
{
if
(
bitswitch_policy
==
BITSWITCH_INHERIT
)
...
...
modules/demux/dash/mpd/SegmentInformation.hpp
View file @
4e6acd5b
...
...
@@ -69,6 +69,8 @@ namespace dash
};
static
const
int
InfoTypeCount
=
INFOTYPE_INDEX
+
1
;
ISegment
*
getSegment
(
SegmentInfoType
,
uint64_t
=
0
)
const
;
private:
void
setSegmentList
(
SegmentList
*
);
void
setSegmentBase
(
SegmentBase
*
);
...
...
modules/demux/dash/mpd/Url.cpp
View file @
4e6acd5b
...
...
@@ -104,9 +104,10 @@ std::string Url::Component::contextualize(size_t index, const Representation *re
pos
=
ret
.
find
(
"$Number$"
);
if
(
pos
!=
std
::
string
::
npos
)
{
index
+=
templ
->
getStartIndex
();
std
::
stringstream
ss
;
/* live streams / templated */
if
(
templ
&&
rep
->
getMPD
()
->
isLive
()
&&
templ
->
duration
.
Get
())
if
(
rep
->
getMPD
()
->
isLive
()
&&
templ
->
duration
.
Get
())
{
mtime_t
playbackstart
=
rep
->
getMPD
()
->
playbackStart
.
Get
();
mtime_t
streamstart
=
rep
->
getMPD
()
->
getAvailabilityStartTime
();
...
...
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