Statistics
| Branch: | Revision:

ffmpeg / libavformat / os_support.c @ 71e445fc

History | View | Annotate | Download (2.57 KB)

1 f71869a4 Fabrice Bellard
/*
2
 * Various utilities for ffmpeg system
3
 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 54eb77c0 Diego Biurrun
 * copyright (c) 2002 Francois Revol
5 f71869a4 Fabrice Bellard
 *
6 b78e7197 Diego Biurrun
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9 f71869a4 Fabrice Bellard
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11 b78e7197 Diego Biurrun
 * version 2.1 of the License, or (at your option) any later version.
12 f71869a4 Fabrice Bellard
 *
13 b78e7197 Diego Biurrun
 * FFmpeg is distributed in the hope that it will be useful,
14 f71869a4 Fabrice Bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19 b78e7197 Diego Biurrun
 * License along with FFmpeg; if not, write to the Free Software
20 5509bffa Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 f71869a4 Fabrice Bellard
 */
22 17c22f57 Steven M. Schultz
#include "config.h"
23 f71869a4 Fabrice Bellard
#include "avformat.h"
24 fdc7b570 Diego Biurrun
#if defined(CONFIG_WINCE)
25
/* Skip includes on WinCE. */
26 2f30a81d Diego Biurrun
#elif defined(__MINGW32__)
27 f71869a4 Fabrice Bellard
#include <sys/types.h>
28
#include <sys/timeb.h>
29
#elif defined(CONFIG_OS2)
30
#include <string.h>
31
#include <sys/time.h>
32
#else
33
#include <unistd.h>
34
#include <fcntl.h>
35
#include <sys/time.h>
36
#endif
37
#include <time.h>
38
39 f6506a54 Michael Niedermayer
/**
40
 * gets the current time in micro seconds.
41
 */
42 f71869a4 Fabrice Bellard
int64_t av_gettime(void)
43
{
44 ac44871c Gildas Bazin
#if defined(CONFIG_WINCE)
45 8da9266c Måns Rullgård
    return timeGetTime() * INT64_C(1000);
46 2f30a81d Diego Biurrun
#elif defined(__MINGW32__)
47 2a86d50b Sascha Sommer
    struct timeb tb;
48 f71869a4 Fabrice Bellard
    _ftime(&tb);
49 8da9266c Måns Rullgård
    return ((int64_t)tb.time * INT64_C(1000) + (int64_t)tb.millitm) * INT64_C(1000);
50 f71869a4 Fabrice Bellard
#else
51
    struct timeval tv;
52
    gettimeofday(&tv,NULL);
53
    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
54
#endif
55
}
56
57 fa28bc16 Måns Rullgård
#if !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R)
58 f71869a4 Fabrice Bellard
struct tm *localtime_r(const time_t *t, struct tm *tp)
59
{
60
    struct tm *l;
61 115329f1 Diego Biurrun
62 f71869a4 Fabrice Bellard
    l = localtime(t);
63
    if (!l)
64
        return 0;
65
    *tp = *l;
66
    return tp;
67
}
68 fa28bc16 Måns Rullgård
#endif /* !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R) */
69 54eb77c0 Diego Biurrun
70 eaa53b95 Diego Biurrun
#if !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK)
71
#include <stdlib.h>
72
#include <strings.h>
73
#include "barpainet.h"
74
75 54eb77c0 Diego Biurrun
int inet_aton (const char * str, struct in_addr * add)
76
{
77
    const char * pch = str;
78
    unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
79
80
    add1 = atoi(pch);
81
    pch = strpbrk(pch,".");
82
    if (pch == 0 || ++pch == 0) goto done;
83
    add2 = atoi(pch);
84
    pch = strpbrk(pch,".");
85
    if (pch == 0 || ++pch == 0) goto done;
86
    add3 = atoi(pch);
87
    pch = strpbrk(pch,".");
88
    if (pch == 0 || ++pch == 0) goto done;
89
    add4 = atoi(pch);
90
91
done:
92
    add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
93
94
    return 1;
95
}
96 eaa53b95 Diego Biurrun
#endif /* !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK) */