ffmpeg / libavformat / os_support.c @ 5509bffa
History | View | Annotate | Download (1.64 KB)
1 |
/*
|
---|---|
2 |
* Various utilities for ffmpeg system
|
3 |
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
4 |
*
|
5 |
* This library is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU Lesser General Public
|
7 |
* License as published by the Free Software Foundation; either
|
8 |
* version 2 of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This library is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
* Lesser General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU Lesser General Public
|
16 |
* License along with this library; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
*/
|
19 |
#include "config.h" |
20 |
#include "avformat.h" |
21 |
#ifdef CONFIG_WIN32
|
22 |
#include <sys/types.h> |
23 |
#include <sys/timeb.h> |
24 |
#elif defined(CONFIG_OS2)
|
25 |
#include <string.h> |
26 |
#include <sys/time.h> |
27 |
#else
|
28 |
#include <unistd.h> |
29 |
#include <fcntl.h> |
30 |
#include <sys/time.h> |
31 |
#endif
|
32 |
#include <time.h> |
33 |
|
34 |
/**
|
35 |
* gets the current time in micro seconds.
|
36 |
*/
|
37 |
int64_t av_gettime(void)
|
38 |
{ |
39 |
#ifdef CONFIG_WIN32
|
40 |
struct timeb tb;
|
41 |
_ftime(&tb); |
42 |
return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000); |
43 |
#else
|
44 |
struct timeval tv;
|
45 |
gettimeofday(&tv,NULL);
|
46 |
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
47 |
#endif
|
48 |
} |
49 |
|
50 |
#if !defined(HAVE_LOCALTIME_R)
|
51 |
struct tm *localtime_r(const time_t *t, struct tm *tp) |
52 |
{ |
53 |
struct tm *l;
|
54 |
|
55 |
l = localtime(t); |
56 |
if (!l)
|
57 |
return 0; |
58 |
*tp = *l; |
59 |
return tp;
|
60 |
} |
61 |
#endif /* !defined(HAVE_LOCALTIME_R) */ |