diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-06-20 20:47:46 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-06-20 20:47:46 +0200 |
commit | 4da42ebe4486f2960d64135395b1a9ef705d9429 (patch) | |
tree | 5e405819aa070d6313851ea324ffaf475523d02f /libavformat | |
parent | e632a430fe03dace7380c11e2bd62ea418e63abc (diff) | |
parent | 005c80b645cc6ab5f30cbc3e10ab66a15dfd107e (diff) | |
download | ffmpeg-streaming-4da42ebe4486f2960d64135395b1a9ef705d9429.zip ffmpeg-streaming-4da42ebe4486f2960d64135395b1a9ef705d9429.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
MS Screen 1 decoder
aacdec: Fix popping channel layouts.
av_gettime: support Win32 without gettimeofday()
Use av_gettime() in various places
Move av_gettime() to libavutil
dct-test: use emms_c() from libavutil instead of duplicating it
mov: fix operator precedence bug
mathematics.h: remove a couple of math defines
Remove unnecessary inclusions of [sys/]time.h
lavf: remove unnecessary inclusions of unistd.h
bfin: libswscale: add const where appropriate to fix warnings
bfin: libswscale: remove unnecessary #includes
udp: Properly check for invalid sockets
tcp: Check the return value from getsockopt
network: Use av_strerror for getting error messages
udp: Properly print error from getnameinfo
mmst: Use AVUNERROR() to convert error codes to the right range for strerror
network: Pass pointers of the right type to get/setsockopt/ioctlsocket on windows
rtmp: Reduce the number of idle posts sent by sleeping 50ms
Conflicts:
Changelog
configure
libavcodec/aacdec.c
libavcodec/allcodecs.c
libavcodec/avcodec.h
libavcodec/dct-test.c
libavcodec/version.h
libavformat/riff.c
libavformat/udp.c
libavutil/Makefile
libswscale/bfin/yuv2rgb_bfin.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avformat.h | 5 | ||||
-rw-r--r-- | libavformat/http.c | 1 | ||||
-rw-r--r-- | libavformat/mmst.c | 10 | ||||
-rw-r--r-- | libavformat/mov.c | 2 | ||||
-rw-r--r-- | libavformat/network.h | 2 | ||||
-rw-r--r-- | libavformat/os_support.c | 4 | ||||
-rw-r--r-- | libavformat/riff.c | 1 | ||||
-rw-r--r-- | libavformat/rtmphttp.c | 13 | ||||
-rw-r--r-- | libavformat/rtpdec_h264.c | 1 | ||||
-rw-r--r-- | libavformat/rtpproto.c | 2 | ||||
-rw-r--r-- | libavformat/rtsp.c | 1 | ||||
-rw-r--r-- | libavformat/rtspenc.c | 1 | ||||
-rw-r--r-- | libavformat/sapdec.c | 1 | ||||
-rw-r--r-- | libavformat/sctp.c | 1 | ||||
-rw-r--r-- | libavformat/tcp.c | 10 | ||||
-rw-r--r-- | libavformat/udp.c | 40 | ||||
-rw-r--r-- | libavformat/utils.c | 10 | ||||
-rw-r--r-- | libavformat/version.h | 3 |
18 files changed, 62 insertions, 46 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8650b08..df684ca 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1854,10 +1854,9 @@ void av_dump_format(AVFormatContext *ic, const char *url, int is_output); -/** - * Get the current time in microseconds. - */ +#if FF_API_AV_GETTIME int64_t av_gettime(void); +#endif /** * Return in 'buf' the path with '%d' replaced by a number. diff --git a/libavformat/http.c b/libavformat/http.c index 96a7eed..0314557 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -21,7 +21,6 @@ #include "libavutil/avstring.h" #include "avformat.h" -#include <unistd.h> #include "internal.h" #include "network.h" #include "http.h" diff --git a/libavformat/mmst.c b/libavformat/mmst.c index e3515b6..c3d2ebb 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -144,7 +144,7 @@ static int send_command_packet(MMSTContext *mmst) av_log(NULL, AV_LOG_ERROR, "Failed to write data of length %d: %d (%s)\n", exact_length, write_result, - write_result < 0 ? strerror(write_result) : + write_result < 0 ? strerror(AVUNERROR(write_result)) : "The server closed the connection"); return AVERROR(EIO); } @@ -246,7 +246,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) if(read_result < 0) { av_log(NULL, AV_LOG_ERROR, "Error reading packet header: %d (%s)\n", - read_result, strerror(read_result)); + read_result, strerror(AVUNERROR(read_result))); packet_type = SC_PKT_CANCEL; } else { av_log(NULL, AV_LOG_ERROR, @@ -266,7 +266,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) av_log(NULL, AV_LOG_ERROR, "Reading command packet length failed: %d (%s)\n", read_result, - read_result < 0 ? strerror(read_result) : + read_result < 0 ? strerror(AVUNERROR(read_result)) : "The server closed the connection"); return read_result < 0 ? read_result : AVERROR(EIO); } @@ -287,7 +287,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) av_log(NULL, AV_LOG_ERROR, "Reading pkt data (length=%d) failed: %d (%s)\n", length_remaining, read_result, - read_result < 0 ? strerror(read_result) : + read_result < 0 ? strerror(AVUNERROR(read_result)) : "The server closed the connection"); return read_result < 0 ? read_result : AVERROR(EIO); } @@ -324,7 +324,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) av_log(NULL, AV_LOG_ERROR, "Failed to read packet data of size %d: %d (%s)\n", length_remaining, read_result, - read_result < 0 ? strerror(read_result) : + read_result < 0 ? strerror(AVUNERROR(read_result)) : "The server closed the connection"); return read_result < 0 ? read_result : AVERROR(EIO); } diff --git a/libavformat/mov.c b/libavformat/mov.c index 3aab48f..d686be6 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1087,7 +1087,7 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_INVALIDDATA; profile_level = avio_r8(pb); - if (profile_level & 0xf0 != 0xc0) + if ((profile_level & 0xf0) != 0xc0) return 0; av_free(st->codec->extradata); diff --git a/libavformat/network.h b/libavformat/network.h index 191c008..d890e7c 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -47,6 +47,8 @@ # undef EINPROGRESS #endif #define EINPROGRESS WSAEINPROGRESS +#define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e) +#define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e) int ff_neterrno(void); #else diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 913ca53..e187044 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -58,7 +58,6 @@ int ff_win32_open(const char *filename_utf8, int oflag, int pmode) #if CONFIG_NETWORK #include <fcntl.h> -#include <unistd.h> #if !HAVE_POLL_H #include <sys/time.h> #if HAVE_WINSOCK2_H @@ -253,7 +252,8 @@ const char *ff_gai_strerror(int ecode) int ff_socket_nonblock(int socket, int enable) { #if HAVE_WINSOCK2_H - return ioctlsocket(socket, FIONBIO, &enable); + u_long param = enable; + return ioctlsocket(socket, FIONBIO, ¶m); #else if (enable) return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK); diff --git a/libavformat/riff.c b/libavformat/riff.c index b03257b..3fc4fb2 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -307,6 +307,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_Y41P, MKTAG('Y', '4', '1', 'P') }, { CODEC_ID_FLIC, MKTAG('A', 'F', 'L', 'C') }, { CODEC_ID_EXR, MKTAG('e', 'x', 'r', ' ') }, + { CODEC_ID_MSS1, MKTAG('M', 'S', 'S', '1') }, { CODEC_ID_NONE, 0 } }; diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c index c431d28..5eb5007 100644 --- a/libavformat/rtmphttp.c +++ b/libavformat/rtmphttp.c @@ -24,6 +24,8 @@ * RTMP HTTP protocol */ +#include <unistd.h> + #include "libavutil/avstring.h" #include "libavutil/intfloat.h" #include "libavutil/opt.h" @@ -44,6 +46,7 @@ typedef struct RTMP_HTTPContext { int out_capacity; ///< current output buffer capacity int initialized; ///< flag indicating when the http context is initialized int finishing; ///< flag indicating when the client closes the connection + int nb_bytes_read; ///< number of bytes read since the last request } RTMP_HTTPContext; static int rtmp_http_send_cmd(URLContext *h, const char *cmd) @@ -70,6 +73,9 @@ static int rtmp_http_send_cmd(URLContext *h, const char *cmd) if ((ret = ffurl_read(rt->stream, &c, 1)) < 0) return ret; + /* re-init the number of bytes read */ + rt->nb_bytes_read = 0; + return ret; } @@ -117,6 +123,12 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size) if ((ret = rtmp_http_send_cmd(h, "send")) < 0) return ret; } else { + if (rt->nb_bytes_read == 0) { + /* Wait 50ms before retrying to read a server reply in + * order to reduce the number of idle requets. */ + usleep(50000); + } + if ((ret = rtmp_http_write(h, "", 1)) < 0) return ret; @@ -131,6 +143,7 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size) } else { off += ret; size -= ret; + rt->nb_bytes_read += ret; } } while (off <= 0); diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c index 096b35f..063836a 100644 --- a/libavformat/rtpdec_h264.c +++ b/libavformat/rtpdec_h264.c @@ -39,7 +39,6 @@ #include "avformat.h" #include "mpegts.h" -#include <unistd.h> #include "network.h" #include <assert.h> diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index de7a401..f140580 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -31,7 +31,6 @@ #include "rtpdec.h" #include "url.h" -#include <unistd.h> #include <stdarg.h> #include "internal.h" #include "network.h" @@ -40,7 +39,6 @@ #if HAVE_POLL_H #include <sys/poll.h> #endif -#include <sys/time.h> #define RTP_TX_BUF_SIZE (64 * 1024) #define RTP_RX_BUF_SIZE (128 * 1024) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 68ca247..c3b40aa 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -30,7 +30,6 @@ #include "avformat.h" #include "avio_internal.h" -#include <sys/time.h> #if HAVE_POLL_H #include <poll.h> #endif diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index 58cd807..ece879e 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -21,7 +21,6 @@ #include "avformat.h" -#include <sys/time.h> #if HAVE_POLL_H #include <poll.h> #endif diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 0ee5110..4626af7 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -30,7 +30,6 @@ #if HAVE_POLL_H #include <poll.h> #endif -#include <sys/time.h> struct SAPState { URLContext *ann_fd; diff --git a/libavformat/sctp.c b/libavformat/sctp.c index 817b004..07de498 100644 --- a/libavformat/sctp.c +++ b/libavformat/sctp.c @@ -39,7 +39,6 @@ #include <netinet/in.h> #include <netinet/sctp.h> -#include <sys/time.h> #include <unistd.h> #include "config.h" diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 1cc7e0a..c42c1ed 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -28,7 +28,6 @@ #if HAVE_POLL_H #include <poll.h> #endif -#include <sys/time.h> typedef struct TCPContext { int fd; @@ -139,12 +138,15 @@ static int tcp_open(URLContext *h, const char *uri, int flags) } /* test error */ optlen = sizeof(ret); - getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); + if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) + ret = AVUNERROR(ff_neterrno()); if (ret != 0) { + char errbuf[100]; + ret = AVERROR(ret); + av_strerror(ret, errbuf, sizeof(errbuf)); av_log(h, AV_LOG_ERROR, "TCP connection to %s:%d failed: %s\n", - hostname, port, strerror(ret)); - ret = AVERROR(ret); + hostname, port, errbuf); goto fail; } } diff --git a/libavformat/udp.c b/libavformat/udp.c index 51d7ed0..9ed8f95 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -42,8 +42,6 @@ #include <pthread.h> #endif -#include <sys/time.h> - #ifndef IPV6_ADD_MEMBERSHIP #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP @@ -78,13 +76,20 @@ typedef struct { int remaining_in_dg; } UDPContext; +static void log_net_error(void *ctx, int level, const char* prefix) +{ + char errbuf[100]; + av_strerror(ff_neterrno(), errbuf, sizeof(errbuf)); + av_log(ctx, level, "%s: %s\n", prefix, errbuf); +} + static int udp_set_multicast_ttl(int sockfd, int mcastTTL, struct sockaddr *addr) { #ifdef IP_MULTICAST_TTL if (addr->sa_family == AF_INET) { if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL): %s\n", strerror(errno)); + log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); return -1; } } @@ -92,7 +97,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, #if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS) if (addr->sa_family == AF_INET6) { if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS): %s\n", strerror(errno)); + log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)"); return -1; } } @@ -109,7 +114,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr) mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; mreq.imr_interface.s_addr= INADDR_ANY; if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP): %s\n", strerror(errno)); + log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)"); return -1; } } @@ -121,7 +126,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr) memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); mreq6.ipv6mr_interface= 0; if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP): %s\n", strerror(errno)); + log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)"); return -1; } } @@ -138,7 +143,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr) mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; mreq.imr_interface.s_addr= INADDR_ANY; if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP): %s\n", strerror(errno)); + log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP)"); return -1; } } @@ -150,7 +155,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr) memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); mreq6.ipv6mr_interface= 0; if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP): %s\n", strerror(errno)); + log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP)"); return -1; } } @@ -214,8 +219,8 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr, goto fail; for (res = res0; res; res=res->ai_next) { udp_fd = socket(res->ai_family, SOCK_DGRAM, 0); - if (udp_fd > 0) break; - av_log(NULL, AV_LOG_ERROR, "socket: %s\n", strerror(errno)); + if (udp_fd != -1) break; + log_net_error(NULL, AV_LOG_ERROR, "socket"); } if (udp_fd < 0) @@ -239,9 +244,10 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr, static int udp_port(struct sockaddr_storage *addr, int addr_len) { char sbuf[sizeof(int)*3+1]; + int error; - if (getnameinfo((struct sockaddr *)addr, addr_len, NULL, 0, sbuf, sizeof(sbuf), NI_NUMERICSERV) != 0) { - av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", strerror(errno)); + if ((error = getnameinfo((struct sockaddr *)addr, addr_len, NULL, 0, sbuf, sizeof(sbuf), NI_NUMERICSERV)) != 0) { + av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(error)); return -1; } @@ -289,7 +295,7 @@ int ff_udp_set_remote_url(URLContext *h, const char *uri) if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) { s->is_connected = 0; - av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); + log_net_error(h, AV_LOG_ERROR, "connect"); return AVERROR(EIO); } } @@ -479,7 +485,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) * bind failed */ /* the bind is needed to give a port to the socket now */ if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) { - av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno)); + log_net_error(h, AV_LOG_ERROR, "bind failed"); goto fail; } @@ -504,7 +510,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* limit the tx buf size to limit latency */ tmp = s->buffer_size; if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) { - av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno)); + log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)"); goto fail; } } else { @@ -512,14 +518,14 @@ static int udp_open(URLContext *h, const char *uri, int flags) * avoid losing data on OSes that set this too low by default. */ tmp = s->buffer_size; if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) { - av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno)); + log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)"); } /* make the socket non-blocking */ ff_socket_nonblock(udp_fd, 1); } if (s->is_connected) { if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) { - av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); + log_net_error(h, AV_LOG_ERROR, "connect"); goto fail; } } diff --git a/libavformat/utils.c b/libavformat/utils.c index 284cb9f..deac84a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -41,8 +41,6 @@ #include "riff.h" #include "audiointerleave.h" #include "url.h" -#include <sys/time.h> -#include <time.h> #include <stdarg.h> #if CONFIG_NETWORK #include "network.h" @@ -3875,12 +3873,12 @@ void av_dump_format(AVFormatContext *ic, av_free(printed); } -int64_t av_gettime(void) +#if FF_API_AV_GETTIME && CONFIG_SHARED && HAVE_SYMVER +FF_SYMVER(int64_t, av_gettime, (void), "LIBAVFORMAT_54") { - struct timeval tv; - gettimeofday(&tv,NULL); - return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; + return av_gettime(); } +#endif uint64_t ff_ntp_time(void) { diff --git a/libavformat/version.h b/libavformat/version.h index 3b61ea3..8d567d9 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -77,5 +77,8 @@ #ifndef FF_API_INTERLEAVE_PACKET #define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55) #endif +#ifndef FF_API_AV_GETTIME +#define FF_API_AV_GETTIME (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif #endif /* AVFORMAT_VERSION_H */ |