~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavformat/network.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2007 The Libav Project
 
3
 *
 
4
 * This file is part of Libav.
 
5
 *
 
6
 * Libav is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 *
 
11
 * Libav is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with Libav; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
19
 */
 
20
 
 
21
#include "network.h"
 
22
#include "libavcodec/internal.h"
 
23
 
 
24
#define THREADS (HAVE_PTHREADS || (defined(WIN32) && !defined(__MINGW32CE__)))
 
25
 
 
26
#if THREADS
 
27
#if HAVE_PTHREADS
 
28
#include <pthread.h>
 
29
#else
 
30
#include "libavcodec/w32pthreads.h"
 
31
#endif
 
32
#endif
 
33
 
 
34
#if CONFIG_OPENSSL
 
35
#include <openssl/ssl.h>
 
36
static int openssl_init;
 
37
#if THREADS
 
38
#include <openssl/crypto.h>
 
39
#include "libavutil/avutil.h"
 
40
pthread_mutex_t *openssl_mutexes;
 
41
static void openssl_lock(int mode, int type, const char *file, int line)
 
42
{
 
43
    if (mode & CRYPTO_LOCK)
 
44
        pthread_mutex_lock(&openssl_mutexes[type]);
 
45
    else
 
46
        pthread_mutex_unlock(&openssl_mutexes[type]);
 
47
}
 
48
#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
 
49
static unsigned long openssl_thread_id(void)
 
50
{
 
51
    return (intptr_t) pthread_self();
 
52
}
 
53
#endif
 
54
#endif
 
55
#endif
 
56
#if CONFIG_GNUTLS
 
57
#include <gnutls/gnutls.h>
 
58
#if THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
 
59
#include <gcrypt.h>
 
60
#include <errno.h>
 
61
#undef malloc
 
62
#undef free
 
63
GCRY_THREAD_OPTION_PTHREAD_IMPL;
 
64
#endif
 
65
#endif
 
66
 
 
67
void ff_tls_init(void)
 
68
{
 
69
    avpriv_lock_avformat();
 
70
#if CONFIG_OPENSSL
 
71
    if (!openssl_init) {
 
72
        SSL_library_init();
 
73
        SSL_load_error_strings();
 
74
#if THREADS
 
75
        if (!CRYPTO_get_locking_callback()) {
 
76
            int i;
 
77
            openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
 
78
            for (i = 0; i < CRYPTO_num_locks(); i++)
 
79
                pthread_mutex_init(&openssl_mutexes[i], NULL);
 
80
            CRYPTO_set_locking_callback(openssl_lock);
 
81
#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
 
82
            CRYPTO_set_id_callback(openssl_thread_id);
 
83
#endif
 
84
        }
 
85
#endif
 
86
    }
 
87
    openssl_init++;
 
88
#endif
 
89
#if CONFIG_GNUTLS
 
90
#if THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
 
91
    if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
 
92
        gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
 
93
#endif
 
94
    gnutls_global_init();
 
95
#endif
 
96
    avpriv_unlock_avformat();
 
97
}
 
98
 
 
99
void ff_tls_deinit(void)
 
100
{
 
101
    avpriv_lock_avformat();
 
102
#if CONFIG_OPENSSL
 
103
    openssl_init--;
 
104
    if (!openssl_init) {
 
105
#if THREADS
 
106
        if (CRYPTO_get_locking_callback() == openssl_lock) {
 
107
            int i;
 
108
            CRYPTO_set_locking_callback(NULL);
 
109
            for (i = 0; i < CRYPTO_num_locks(); i++)
 
110
                pthread_mutex_destroy(&openssl_mutexes[i]);
 
111
            av_free(openssl_mutexes);
 
112
        }
 
113
#endif
 
114
    }
 
115
#endif
 
116
#if CONFIG_GNUTLS
 
117
    gnutls_global_deinit();
 
118
#endif
 
119
    avpriv_unlock_avformat();
 
120
}
 
121
 
 
122
int ff_network_inited_globally;
 
123
 
 
124
int ff_network_init(void)
 
125
{
 
126
#if HAVE_WINSOCK2_H
 
127
    WSADATA wsaData;
 
128
#endif
 
129
 
 
130
    if (!ff_network_inited_globally)
 
131
        av_log(NULL, AV_LOG_WARNING, "Using network protocols without global "
 
132
                                     "network initialization. Please use "
 
133
                                     "avformat_network_init(), this will "
 
134
                                     "become mandatory later.\n");
 
135
#if HAVE_WINSOCK2_H
 
136
    if (WSAStartup(MAKEWORD(1,1), &wsaData))
 
137
        return 0;
 
138
#endif
 
139
    return 1;
 
140
}
 
141
 
 
142
int ff_network_wait_fd(int fd, int write)
 
143
{
 
144
    int ev = write ? POLLOUT : POLLIN;
 
145
    struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
 
146
    int ret;
 
147
    ret = poll(&p, 1, 100);
 
148
    return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN);
 
149
}
 
150
 
 
151
void ff_network_close(void)
 
152
{
 
153
#if HAVE_WINSOCK2_H
 
154
    WSACleanup();
 
155
#endif
 
156
}
 
157
 
 
158
#if HAVE_WINSOCK2_H
 
159
int ff_neterrno(void)
 
160
{
 
161
    int err = WSAGetLastError();
 
162
    switch (err) {
 
163
    case WSAEWOULDBLOCK:
 
164
        return AVERROR(EAGAIN);
 
165
    case WSAEINTR:
 
166
        return AVERROR(EINTR);
 
167
    }
 
168
    return -err;
 
169
}
 
170
#endif
 
171
 
 
172
int ff_is_multicast_address(struct sockaddr *addr)
 
173
{
 
174
    if (addr->sa_family == AF_INET) {
 
175
        return IN_MULTICAST(ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr));
 
176
    }
 
177
#if HAVE_STRUCT_SOCKADDR_IN6
 
178
    if (addr->sa_family == AF_INET6) {
 
179
        return IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *)addr)->sin6_addr);
 
180
    }
 
181
#endif
 
182
 
 
183
    return 0;
 
184
}
 
185