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
e0ed2d06
Commit
e0ed2d06
authored
Oct 19, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: adaptative: move xml types conversion away from dash
parent
3a3e44f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
182 additions
and
128 deletions
+182
-128
modules/demux/Makefile.am
modules/demux/Makefile.am
+2
-0
modules/demux/adaptative/tools/Conversions.cpp
modules/demux/adaptative/tools/Conversions.cpp
+106
-0
modules/demux/adaptative/tools/Conversions.hpp
modules/demux/adaptative/tools/Conversions.hpp
+73
-0
modules/demux/dash/mpd/IsoffMainParser.cpp
modules/demux/dash/mpd/IsoffMainParser.cpp
+1
-84
modules/demux/dash/mpd/IsoffMainParser.h
modules/demux/dash/mpd/IsoffMainParser.h
+0
-44
No files found.
modules/demux/Makefile.am
View file @
e0ed2d06
...
...
@@ -320,6 +320,8 @@ libadaptative_plugin_la_SOURCES = \
demux/adaptative/Streams.cpp
\
demux/adaptative/Streams.hpp
\
demux/adaptative/Time.hpp
\
demux/adaptative/tools/Conversions.hpp
\
demux/adaptative/tools/Conversions.cpp
\
demux/adaptative/tools/Debug.hpp
\
demux/adaptative/tools/Helper.cpp
\
demux/adaptative/tools/Helper.h
\
...
...
modules/demux/adaptative/tools/Conversions.cpp
0 → 100644
View file @
e0ed2d06
/*
* Conversions.cpp
*****************************************************************************
* Copyright © 2015 - VideoLAN and VLC 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 "Conversions.hpp"
#include <vlc_strings.h>
#include <sstream>
IsoTime
::
IsoTime
(
const
std
::
string
&
str
)
{
time
=
str_duration
(
str
.
c_str
());
}
IsoTime
::
operator
time_t
()
const
{
return
time
;
}
/* i_year: year - 1900 i_month: 0-11 i_mday: 1-31 i_hour: 0-23 i_minute: 0-59 i_second: 0-59 */
static
int64_t
vlc_timegm
(
int
i_year
,
int
i_month
,
int
i_mday
,
int
i_hour
,
int
i_minute
,
int
i_second
)
{
static
const
int
pn_day
[
12
+
1
]
=
{
0
,
31
,
59
,
90
,
120
,
151
,
181
,
212
,
243
,
273
,
304
,
334
};
int64_t
i_day
;
if
(
i_year
<
70
||
i_month
<
0
||
i_month
>
11
||
i_mday
<
1
||
i_mday
>
31
||
i_hour
<
0
||
i_hour
>
23
||
i_minute
<
0
||
i_minute
>
59
||
i_second
<
0
||
i_second
>
59
)
return
-
1
;
/* Count the number of days */
i_day
=
(
int64_t
)
365
*
(
i_year
-
70
)
+
pn_day
[
i_month
]
+
i_mday
-
1
;
#define LEAP(y) ( ((y)%4) == 0 && (((y)%100) != 0 || ((y)%400) == 0) ? 1 : 0)
for
(
int
i
=
70
;
i
<
i_year
;
i
++
)
i_day
+=
LEAP
(
1900
+
i
);
if
(
i_month
>
1
)
i_day
+=
LEAP
(
1900
+
i_year
);
#undef LEAP
/**/
return
((
24
*
i_day
+
i_hour
)
*
60
+
i_minute
)
*
60
+
i_second
;
}
UTCTime
::
UTCTime
(
const
std
::
string
&
str
)
{
enum
{
YEAR
=
0
,
MON
,
DAY
,
HOUR
,
MIN
,
SEC
,
TZ
};
int
values
[
7
]
=
{
0
};
std
::
istringstream
in
(
str
);
try
{
/* Date */
for
(
int
i
=
YEAR
;
i
<=
DAY
&&
!
in
.
eof
();
i
++
)
{
if
(
i
!=
YEAR
)
in
.
ignore
(
1
);
in
>>
values
[
i
];
}
/* Time */
if
(
!
in
.
eof
()
&&
in
.
peek
()
==
'T'
)
{
for
(
int
i
=
HOUR
;
i
<=
SEC
&&
!
in
.
eof
();
i
++
)
{
in
.
ignore
(
1
);
in
>>
values
[
i
];
}
}
/* Timezone */
if
(
!
in
.
eof
()
&&
in
.
peek
()
==
'Z'
)
{
in
.
ignore
(
1
);
while
(
!
in
.
eof
())
{
if
(
in
.
peek
()
==
'+'
)
continue
;
in
>>
values
[
TZ
];
break
;
}
}
time
=
vlc_timegm
(
values
[
YEAR
]
-
1900
,
values
[
MON
]
-
1
,
values
[
DAY
],
values
[
HOUR
],
values
[
MIN
],
values
[
SEC
]
);
time
+=
values
[
TZ
]
*
3600
;
}
catch
(
int
)
{
time
=
0
;
}
}
UTCTime
::
operator
time_t
()
const
{
return
time
;
}
modules/demux/adaptative/tools/Conversions.hpp
0 → 100644
View file @
e0ed2d06
/*
* Conversions.hpp
*****************************************************************************
* Copyright © 2015 - VideoLAN and VLC 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 CONVERSIONS_HPP
#define CONVERSIONS_HPP
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <string>
class
IsoTime
{
public:
IsoTime
(
const
std
::
string
&
);
operator
time_t
()
const
;
private:
time_t
time
;
};
class
UTCTime
{
public:
UTCTime
(
const
std
::
string
&
);
operator
time_t
()
const
;
private:
time_t
time
;
};
template
<
typename
T
>
class
Integer
{
public:
Integer
(
const
std
::
string
&
str
)
{
try
{
std
::
istringstream
in
(
str
);
in
>>
value
;
}
catch
(
int
)
{
value
=
0
;
}
}
operator
T
()
const
{
return
value
;
}
private:
T
value
;
};
#endif // CONVERSIONS_HPP
modules/demux/dash/mpd/IsoffMainParser.cpp
View file @
e0ed2d06
...
...
@@ -42,7 +42,7 @@
#include "../adaptative/xml/DOMHelper.h"
#include "../adaptative/tools/Helper.h"
#include "../adaptative/tools/Debug.hpp"
#include
<vlc_strings.h>
#include
"../adaptative/tools/Conversions.hpp"
#include <vlc_stream.h>
#include <cstdio>
...
...
@@ -525,86 +525,3 @@ Profile IsoffMainParser::getProfile() const
return
res
;
}
IsoTime
::
IsoTime
(
const
std
::
string
&
str
)
{
time
=
str_duration
(
str
.
c_str
());
}
IsoTime
::
operator
time_t
()
const
{
return
time
;
}
/* i_year: year - 1900 i_month: 0-11 i_mday: 1-31 i_hour: 0-23 i_minute: 0-59 i_second: 0-59 */
static
int64_t
vlc_timegm
(
int
i_year
,
int
i_month
,
int
i_mday
,
int
i_hour
,
int
i_minute
,
int
i_second
)
{
static
const
int
pn_day
[
12
+
1
]
=
{
0
,
31
,
59
,
90
,
120
,
151
,
181
,
212
,
243
,
273
,
304
,
334
};
int64_t
i_day
;
if
(
i_year
<
70
||
i_month
<
0
||
i_month
>
11
||
i_mday
<
1
||
i_mday
>
31
||
i_hour
<
0
||
i_hour
>
23
||
i_minute
<
0
||
i_minute
>
59
||
i_second
<
0
||
i_second
>
59
)
return
-
1
;
/* Count the number of days */
i_day
=
(
int64_t
)
365
*
(
i_year
-
70
)
+
pn_day
[
i_month
]
+
i_mday
-
1
;
#define LEAP(y) ( ((y)%4) == 0 && (((y)%100) != 0 || ((y)%400) == 0) ? 1 : 0)
for
(
int
i
=
70
;
i
<
i_year
;
i
++
)
i_day
+=
LEAP
(
1900
+
i
);
if
(
i_month
>
1
)
i_day
+=
LEAP
(
1900
+
i_year
);
#undef LEAP
/**/
return
((
24
*
i_day
+
i_hour
)
*
60
+
i_minute
)
*
60
+
i_second
;
}
UTCTime
::
UTCTime
(
const
std
::
string
&
str
)
{
enum
{
YEAR
=
0
,
MON
,
DAY
,
HOUR
,
MIN
,
SEC
,
TZ
};
int
values
[
7
]
=
{
0
};
std
::
istringstream
in
(
str
);
try
{
/* Date */
for
(
int
i
=
YEAR
;
i
<=
DAY
&&
!
in
.
eof
();
i
++
)
{
if
(
i
!=
YEAR
)
in
.
ignore
(
1
);
in
>>
values
[
i
];
}
/* Time */
if
(
!
in
.
eof
()
&&
in
.
peek
()
==
'T'
)
{
for
(
int
i
=
HOUR
;
i
<=
SEC
&&
!
in
.
eof
();
i
++
)
{
in
.
ignore
(
1
);
in
>>
values
[
i
];
}
}
/* Timezone */
if
(
!
in
.
eof
()
&&
in
.
peek
()
==
'Z'
)
{
in
.
ignore
(
1
);
while
(
!
in
.
eof
())
{
if
(
in
.
peek
()
==
'+'
)
continue
;
in
>>
values
[
TZ
];
break
;
}
}
time
=
vlc_timegm
(
values
[
YEAR
]
-
1900
,
values
[
MON
]
-
1
,
values
[
DAY
],
values
[
HOUR
],
values
[
MIN
],
values
[
SEC
]
);
time
+=
values
[
TZ
]
*
3600
;
}
catch
(
int
)
{
time
=
0
;
}
}
UTCTime
::
operator
time_t
()
const
{
return
time
;
}
modules/demux/dash/mpd/IsoffMainParser.h
View file @
e0ed2d06
...
...
@@ -33,7 +33,6 @@
#include "Profile.hpp"
#include <cstdlib>
#include <sstream>
#include <vlc_common.h>
...
...
@@ -90,49 +89,6 @@ namespace dash
stream_t
*
p_stream
;
std
::
string
playlisturl
;
};
class
IsoTime
{
public:
IsoTime
(
const
std
::
string
&
);
operator
time_t
()
const
;
private:
time_t
time
;
};
class
UTCTime
{
public:
UTCTime
(
const
std
::
string
&
);
operator
time_t
()
const
;
private:
time_t
time
;
};
template
<
typename
T
>
class
Integer
{
public:
Integer
(
const
std
::
string
&
str
)
{
try
{
std
::
istringstream
in
(
str
);
in
>>
value
;
}
catch
(
int
)
{
value
=
0
;
}
}
operator
T
()
const
{
return
value
;
}
private:
T
value
;
};
}
}
...
...
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