Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
55cfe8ef
Commit
55cfe8ef
authored
Feb 09, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NTPtime64() returns an NTP timestamp
parent
3d33b851
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
include/vlc_mtime.h
include/vlc_mtime.h
+1
-0
src/misc/mtime.c
src/misc/mtime.c
+33
-0
No files found.
include/vlc_mtime.h
View file @
55cfe8ef
...
@@ -86,3 +86,4 @@ VLC_EXPORT( void, date_Set, ( date_t *, mtime_t ) );
...
@@ -86,3 +86,4 @@ VLC_EXPORT( void, date_Set, ( date_t *, mtime_t ) );
VLC_EXPORT
(
mtime_t
,
date_Get
,
(
const
date_t
*
)
);
VLC_EXPORT
(
mtime_t
,
date_Get
,
(
const
date_t
*
)
);
VLC_EXPORT
(
void
,
date_Move
,
(
date_t
*
,
mtime_t
)
);
VLC_EXPORT
(
void
,
date_Move
,
(
date_t
*
,
mtime_t
)
);
VLC_EXPORT
(
mtime_t
,
date_Increment
,
(
date_t
*
,
uint32_t
)
);
VLC_EXPORT
(
mtime_t
,
date_Increment
,
(
date_t
*
,
uint32_t
)
);
VLC_EXPORT
(
uint64_t
,
NTPtime64
,
(
void
)
);
src/misc/mtime.c
View file @
55cfe8ef
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
* Functions are prototyped in vlc_mtime.h.
* Functions are prototyped in vlc_mtime.h.
*****************************************************************************
*****************************************************************************
* Copyright (C) 1998-2004 the VideoLAN team
* Copyright (C) 1998-2004 the VideoLAN team
* Copyright © 2006-2007 Rémi Denis-Courmont
* $Id$
* $Id$
*
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Authors: Vincent Seguin <seguin@via.ecp.fr>
...
@@ -32,6 +33,7 @@
...
@@ -32,6 +33,7 @@
#include <stdio.h>
/* sprintf() */
#include <stdio.h>
/* sprintf() */
#include <time.h>
/* clock_gettime(), clock_nanosleep() */
#include <time.h>
/* clock_gettime(), clock_nanosleep() */
#include <stdlib.h>
/* lldiv() */
#include <stdlib.h>
/* lldiv() */
#include <assert.h>
#if defined( PTH_INIT_IN_PTH_H )
/* GNU Pth */
#if defined( PTH_INIT_IN_PTH_H )
/* GNU Pth */
...
@@ -386,3 +388,34 @@ mtime_t date_Increment( date_t *p_date, uint32_t i_nb_samples )
...
@@ -386,3 +388,34 @@ mtime_t date_Increment( date_t *p_date, uint32_t i_nb_samples )
return
p_date
->
date
;
return
p_date
->
date
;
}
}
/**
* @return NTP 64-bits timestamp in host byte order.
*/
uint64_t
NTPtime64
(
void
)
{
struct
timespec
ts
;
#if defined (CLOCK_REALTIME)
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
#else
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
ts
.
tv_sec
=
tv
.
tv_sec
;
ts
.
tv_nsec
=
tv
.
tv_usec
*
1000
;
}
#endif
/* Convert nanoseconds to 32-bits fraction (232 picosecond units) */
uint64_t
t
=
(
uint64_t
)(
ts
.
tv_nsec
)
<<
32
;
t
/=
1000000000
;
/* There is 70 years (incl. 17 leap ones) offset to the Unix Epoch.
* No leap seconds during that period since they were not invented yet.
*/
assert
(
t
<
0x100000000
);
t
|=
((
70LL
*
365
+
17
)
*
24
*
60
*
60
+
ts
.
tv_sec
)
<<
32
;
return
t
;
}
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