Statistics
| Branch: | Revision:

ffmpeg / libavformat / os_support.c @ ac44871c

History | View | Annotate | Download (1.81 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
#if defined(CONFIG_WIN32) && !defined(CONFIG_WINCE)
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
#if defined(CONFIG_WINCE)
40
    return timeGetTime() * int64_t_C(1000);
41
#elif defined(CONFIG_WIN32)
42
    struct timeb tb;
43
    _ftime(&tb);
44
    return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
45
#else
46
    struct timeval tv;
47
    gettimeofday(&tv,NULL);
48
    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
49
#endif
50
}
51

    
52
#if !defined(CONFIG_WINCE)
53
#if !defined(HAVE_LOCALTIME_R)
54
struct tm *localtime_r(const time_t *t, struct tm *tp)
55
{
56
    struct tm *l;
57

    
58
    l = localtime(t);
59
    if (!l)
60
        return 0;
61
    *tp = *l;
62
    return tp;
63
}
64
#endif /* !defined(HAVE_LOCALTIME_R) */
65
#endif /* !defined(CONFIG_WINCE) */