~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavformat/os_support.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 */
22
22
#include "config.h"
23
23
#include "avformat.h"
24
 
#if defined(CONFIG_WINCE)
25
 
/* Skip includes on WinCE. */
26
 
#elif defined(__MINGW32__)
27
 
#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
24
#include <unistd.h>
34
25
#include <fcntl.h>
35
 
#include <sys/time.h>
36
 
#endif
37
 
#include <time.h>
 
26
#include "os_support.h"
38
27
 
39
 
#ifndef HAVE_SYS_POLL_H
40
 
#if defined(__MINGW32__)
 
28
#ifdef CONFIG_NETWORK
 
29
#ifndef HAVE_POLL_H
 
30
#ifdef HAVE_WINSOCK2_H
41
31
#include <winsock2.h>
42
 
#else
 
32
#elif defined (HAVE_SYS_SELECT_H)
43
33
#include <sys/select.h>
44
34
#endif
45
35
#endif
46
36
 
47
 
/**
48
 
 * gets the current time in micro seconds.
49
 
 */
50
 
int64_t av_gettime(void)
51
 
{
52
 
#if defined(CONFIG_WINCE)
53
 
    return timeGetTime() * INT64_C(1000);
54
 
#elif defined(__MINGW32__)
55
 
    struct timeb tb;
56
 
    _ftime(&tb);
57
 
    return ((int64_t)tb.time * INT64_C(1000) + (int64_t)tb.millitm) * INT64_C(1000);
58
 
#else
59
 
    struct timeval tv;
60
 
    gettimeofday(&tv,NULL);
61
 
    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
62
 
#endif
63
 
}
64
 
 
65
 
#if !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R)
66
 
struct tm *localtime_r(const time_t *t, struct tm *tp)
67
 
{
68
 
    struct tm *l;
69
 
 
70
 
    l = localtime(t);
71
 
    if (!l)
72
 
        return 0;
73
 
    *tp = *l;
74
 
    return tp;
75
 
}
76
 
#endif /* !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R) */
77
 
 
78
 
#if !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK)
 
37
#include "network.h"
 
38
 
 
39
#if !defined(HAVE_INET_ATON)
79
40
#include <stdlib.h>
80
41
#include <strings.h>
81
 
#include "barpainet.h"
82
42
 
83
43
int inet_aton (const char * str, struct in_addr * add)
84
44
{
85
 
    const char * pch = str;
86
45
    unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
87
46
 
88
 
    add1 = atoi(pch);
89
 
    pch = strpbrk(pch,".");
90
 
    if (pch == 0 || ++pch == 0) goto done;
91
 
    add2 = atoi(pch);
92
 
    pch = strpbrk(pch,".");
93
 
    if (pch == 0 || ++pch == 0) goto done;
94
 
    add3 = atoi(pch);
95
 
    pch = strpbrk(pch,".");
96
 
    if (pch == 0 || ++pch == 0) goto done;
97
 
    add4 = atoi(pch);
98
 
 
99
 
done:
 
47
    if (sscanf(str, "%d.%d.%d.%d", &add1, &add2, &add3, &add4) != 4)
 
48
        return 0;
 
49
 
 
50
    if (!add1 || (add1|add2|add3|add4) > 255) return 0;
 
51
 
100
52
    add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
101
53
 
102
54
    return 1;
103
55
}
104
 
#endif /* !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK) */
 
56
#endif /* !defined(HAVE_INET_ATON) */
 
57
 
 
58
/* resolve host with also IP address parsing */
 
59
int resolve_host(struct in_addr *sin_addr, const char *hostname)
 
60
{
 
61
    struct hostent *hp;
 
62
 
 
63
    if (!inet_aton(hostname, sin_addr)) {
 
64
        hp = gethostbyname(hostname);
 
65
        if (!hp)
 
66
            return -1;
 
67
        memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr));
 
68
    }
 
69
    return 0;
 
70
}
 
71
 
 
72
int ff_socket_nonblock(int socket, int enable)
 
73
{
 
74
#ifdef HAVE_WINSOCK2_H
 
75
   return ioctlsocket(socket, FIONBIO, &enable);
 
76
#else
 
77
   if (enable)
 
78
      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
 
79
   else
 
80
      return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
 
81
#endif
 
82
}
 
83
#endif /* CONFIG_NETWORK */
105
84
 
106
85
#ifdef CONFIG_FFSERVER
107
 
#ifndef HAVE_SYS_POLL_H
 
86
#ifndef HAVE_POLL_H
108
87
int poll(struct pollfd *fds, nfds_t numfds, int timeout)
109
88
{
110
89
    fd_set read_set;
114
93
    int n;
115
94
    int rc;
116
95
 
 
96
#ifdef HAVE_WINSOCK2_H
 
97
    if (numfds >= FD_SETSIZE) {
 
98
        errno = EINVAL;
 
99
        return -1;
 
100
    }
 
101
#endif
 
102
 
117
103
    FD_ZERO(&read_set);
118
104
    FD_ZERO(&write_set);
119
105
    FD_ZERO(&exception_set);
122
108
    for(i = 0; i < numfds; i++) {
123
109
        if (fds[i].fd < 0)
124
110
            continue;
 
111
#ifndef HAVE_WINSOCK2_H
125
112
        if (fds[i].fd >= FD_SETSIZE) {
126
113
            errno = EINVAL;
127
114
            return -1;
128
115
        }
 
116
#endif
129
117
 
130
118
        if (fds[i].events & POLLIN)  FD_SET(fds[i].fd, &read_set);
131
119
        if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &write_set);
162
150
 
163
151
    return rc;
164
152
}
165
 
#endif /* HAVE_SYS_POLL_H */
 
153
#endif /* HAVE_POLL_H */
166
154
#endif /* CONFIG_FFSERVER */
167
155