1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

247 Commits

Author SHA1 Message Date
Zhao Zhili
30ca9980ff avformat/udp: fix check for pthread_cond_wait return value
POSIX errno is positive. We have strict_pthread_cond_wait to handle
error code during development.

Signed-off-by: zhilizhao <zhilizhao@tencent.com>
Reviewed-by: Jun Zhao <barryjzhao@tencent.com>
2021-07-10 15:35:06 +08:00
Limin Wang
5ef20244de avformat/udp: add memory alloc checks
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-01-16 08:51:31 +08:00
Limin Wang
f6eaa864f3 avformat/udp: return the error code instead of generic EIO
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-01-16 08:51:22 +08:00
Limin Wang
6fb2bdd1d0 avformat/udp: cosmetics
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-22 20:53:57 +08:00
Limin Wang
2676277b6d avformat/udp: clarify option description for timeout unit
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-22 20:53:56 +08:00
Zhao Zhili
15a74d21f3 avformat/udp: remove redundant setting of h->max_packet_size
h->max_packet_size is being reset in the following code.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-16 23:16:55 +02:00
Jun Zhao
3205ed31a7 lavf/udp: fix the comments for default UDP socket recvbuf size
15d160cc0b increased the UDP socket receiving buffer size
(64K ->384K), but missed to update this comments.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-07-12 08:13:00 +08:00
phunkyfish
0830e9116f avformat/udp: support w32pthreads compat
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-03-08 19:08:04 +01:00
Marton Balint
53aa76686e avformat/udp: cancel pending IO on win32 manually
recvfrom() is not a cancellation point in pthreads-win32, see
https://sourceware.org/pthreads-win32/manual/pthread_cancel.html

In order to be able to cancel the reader thread on Win32 properly we first
shutdown the socket then call CancelIoEx to abort pending IO. Subsequent
recvfrom() calls will fail with WSAESHUTDOWN causing the thread to exit.

Fixes ticket #5717.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-02-02 19:04:42 +01:00
Marton Balint
c2b6493bf7 avformat/udp: remove setting cancel state from the TX thread
Write mode does not use cancellation.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-02-02 19:04:42 +01:00
Marton Balint
15d160cc0b avformat/udp: increase the default buffer size of a receiving socket to 384K
It is a common mistake that people only increase fifo_size when they experience
drops, unfortunately this does not help for higher bitrate (> 100 Mbps) streams
when the reader thread simply might not receive the packets in time (especially
under high CPU load) if the default 64 KB of kernel buffer size is used.

New default is determined so that common linux systems can set this buffer size
without tuning kernel parameters.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-25 23:16:47 +01:00
Marton Balint
67f39b32db avformat/udp: properly use return value of pthread_cond_timedwait
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-25 23:16:47 +01:00
Marton Balint
f61e9f8aef avformat/udp: add newline after warning
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-25 23:16:47 +01:00
Xuchen Su
9faee5bc14 avformat/udp: modify the not write-only to read-only mode.
not write-only include read-write pseudo flag. so make the flag read-only

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-01-20 14:28:56 +08:00
Steven Liu
5db50dbf06 avformat/udp: add logging context to log
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-08 13:46:42 +08:00
Marton Balint
ab0812c1a8 avformat/udp: always use IP_ADD_SOURCE_MEMBERSHIP for subscribing to an UDP multicast source group in IPv4
That alone supports specifying the interface based on its address. Getting the
interface index from the local address seems quite a bit of work in a platform
independent way...

Obviously for IPv6 we still always use MCAST_JOIN_SOURCE_GROUP.

As a side effect this also fixes ticket #7459.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-03 22:03:29 +02:00
Marton Balint
d3bda871f0 avformat/udp: specify the local address for some source filtered multicast joins
We already use localaddr for the multicast joins without source filters, so we
should use them for source filters as well. This patch only fixes the
IP_ADD_SOURCE_MEMBERSHIP and the IP_BLOCK_SOURCE case.

Unless we do this, the kernel automatically selects an interface based on the
source address, and that interface might be different from the one set in
localaddr. For blocked sources this even casues EINVAL because we joined the
multicast group on a different interface.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-03 22:03:29 +02:00
Marton Balint
91a1363452 avformat/udp: add support for generic source filtering
This allows getting data only from a specific source IP. This is useful not
only for unicast but for multicast as well because multicast source
subscriptions do not act as source filters for the incoming packets.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-03 22:03:29 +02:00
Marton Balint
826972c9d8 avformat/udp: use factorized ip functions
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-03 22:03:29 +02:00
Jun Zhao
49efd41c47 lavf/udp: use ff_log_net_error to replace log_net_error
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-08-18 16:16:11 +08:00
Derek Buitenhuis
cce33ed10f Revert "udp: fix compilation when HAVE_PTHREAD_CANCEL isnt defined"
This was an mplayer-specific hack.

This reverts commit a4f94f24b4.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-11-23 14:20:32 +00:00
Carl Eugen Hoyos
3c821a1a7b lavf/udp: Do not use MCAST_* for multicast on tvOS.
Fixes ticket #5774.
2016-09-03 15:18:40 +02:00
Marton Balint
cc16229d91 avformat/udp: replace packet_gap with bitrate option
We haven't had a stable release since the packet_gap addition, so probably it
is worth reworking the option to something that makes more sense to the end
user. Also add burst_bits option to specify maximum length of bit bursts.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-19 22:55:57 +02:00
Marton Balint
0a06569487 avformat/udp: do not accumulate packet_gap delay errors
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-19 22:54:57 +02:00
Nicolas George
8b05a7ffe4 lavf/udp: fix dead code.
Since d607861, service can not be NULL, only "0".
An UDP address with neither local port nor address leaves both
service and node to their default value, and POSIX specifies
that they are not allowed to be both NULL; "0" is equivalent
to an unspecified port for all currently known protocols.

Fix CID 1341570.
2016-06-03 12:46:02 +02:00
Michael Niedermayer
4865252c08 avformat/udp: Protect write to circular_buffer_error by mutex
This isnt really needed on most platforms but
fixes CID1362183

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-02 13:41:04 +02:00
Michael Niedermayer
cbd19881f7 avformat/udp: Remove unused variable
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-29 12:35:14 +02:00
Michael Niedermayer
9591ca704b avformat/udp: Close the socket after destroying the thread using the socket
for send() this cannot work and even for recv() it feels very wrong and hackish

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-25 01:39:23 +02:00
Michael Niedermayer
9b7a8bddac avformat/udp: redesign threaded udp tx code
This fixes partially completed send()
Avoids holding the mutex during send()
fixes race conditions in error handling
removes copied non thread specific blocking code
Fixes deadlocks on closure
Fixes data loss on closure

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-25 01:39:23 +02:00
Pavel Nikiforov
413c842a69 avformat/udp: Add a delay between packets for streaming to clients with short buffer
This commit enables sending UDP packets in a background thread with specified delay.
When sending packets without a delay some devices with small RX buffer
( MAG200 STB, for example) will drop tail packets in bursts causing
decoding errors.

To use it specify "fifo_size" with "packet_gap" .

The output url will looks like udp://xxx:yyy?fifo_size=<output fifo
size>&packet_gap=<delay in usecs>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-25 01:39:22 +02:00
Derek Buitenhuis
9c75148e6e Merge commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d'
This commit also disables the async fate test, because it
used internal APIs in a non-kosher way, which no longer
exists.

* commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d':
  lavf: reorganize URLProtocols

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 16:51:10 +00:00
Anton Khirnov
2758cdedfb lavf: reorganize URLProtocols
Instead of a linked list constructed at av_register_all(), store them
in a constant array of pointers.

Since no registration is necessary now, this removes some global state
from lavf. This will also allow the urlprotocol layer caller to limit
the available protocols in a simple and flexible way in the following
commits.
2016-02-22 11:30:58 +01:00
Clément Bœsch
43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
Hendrik Leppkes
a6dac0b410 Merge commit '12b14382861fbf19378afcddaa19cd9a949a86a3'
* commit '12b14382861fbf19378afcddaa19cd9a949a86a3':
  udp: Provide additional information on getaddrinfo failure

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-29 16:12:38 +01:00
Hendrik Leppkes
bf54377001 Merge commit '34af7813f77e2b5b9dcb34f20bcf53bfcc0ba9c9'
* commit '34af7813f77e2b5b9dcb34f20bcf53bfcc0ba9c9':
  udp: Use the logging context

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-29 16:11:16 +01:00
Luca Barbato
12b1438286 udp: Provide additional information on getaddrinfo failure 2015-11-25 09:01:25 +01:00
Luca Barbato
34af7813f7 udp: Use the logging context 2015-11-25 09:01:25 +01:00
Ganesh Ajjanagadde
26e8895b73 all: add _DEFAULT_SOURCE locally wherever needed
Glibc 2.20 onwards generates a deprecation warning for usage of _BSD_SOURCE and _SVID_SOURCE.
The solution from man feature_test_macros is to define both _DEFAULT_SOURCE and the old macros.
This solution is on the lines of the one in commit af1818276e.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2015-10-04 12:15:16 -04:00
Luca Barbato
61dc9d647c udp: Fix local_port management
The default value for unset is -1, not 0.

Problem introduced in 66028b7ba6
2015-06-22 10:47:29 +03:00
Michael Niedermayer
d0059281e6 avformat/udp: Remove (harmless) duplicated pkt_size entry from AVOption table
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 22:10:05 +02:00
Michael Niedermayer
8344350509 Merge commit 'ff7adead0a667e606f5a41dca591f074f9ff2f32'
* commit 'ff7adead0a667e606f5a41dca591f074f9ff2f32':
  udp: Fix pkt_size management

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 22:06:44 +02:00
Luca Barbato
ff7adead0a udp: Fix pkt_size management
The default value for unset is -1, not 0.

Problem introduced in 66028b7ba6

Bug-Id: 835
2015-03-29 17:35:59 +02:00
Michael Niedermayer
4f8540ba40 Merge commit '8dc72eeaf647736c287b59a3856a11904bedd58b'
* commit '8dc72eeaf647736c287b59a3856a11904bedd58b':
  udp: Fix crashes after adding AVOptions

See: aefed6ca87
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-19 11:22:39 +01:00
Martin Storsjö
8dc72eeaf6 udp: Fix crashes after adding AVOptions
Add a missing AVClass member, check whether localaddr is null.
(Previously, localaddr was always a local stack buffer, while it
now also can be an avoption string which can be null.)

This fixes crashes when not passing any localaddr parameter, since
66028b7ba.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-03-19 10:25:22 +02:00
Michael Niedermayer
4f3f5ee1ac Merge commit '66028b7ba6b411ba12ef553e9c8f1f4a4fe27710'
* commit '66028b7ba6b411ba12ef553e9c8f1f4a4fe27710':
  udp: Use AVOptions

Conflicts:
	libavformat/udp.c

See: aefed6ca87
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-16 00:10:09 +01:00
Luca Barbato
66028b7ba6 udp: Use AVOptions
Add AVOptions for options currently available as url parameters.
2015-03-15 18:29:11 +01:00
Michael Niedermayer
a0fe1a25fa Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'
* commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e':
  avformat: Don't anonymously typedef structs

Conflicts:
	libavformat/adtsenc.c
	libavformat/aiffenc.c
	libavformat/avidec.c
	libavformat/gif.c
	libavformat/iff.c
	libavformat/img2dec.c
	libavformat/jvdec.c
	libavformat/matroskadec.c
	libavformat/udp.c
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 21:07:40 +01:00
Diego Biurrun
daf8cf358a avformat: Don't anonymously typedef structs 2015-02-14 10:13:47 -08:00
Vincent Bernat
5269cef408 avformat/udp: Allow to specify DSCP class
By appending `?dscp=26` to the URL, IP packets will be classified as
AF31 (assured forwarding for multimedia flows with low probability of
loss). On congested network, this allows a user to assign priorities to
flows.

Signed-off-by: Vincent Bernat <vincent@bernat.im>
2014-11-27 19:53:09 +01:00
Thomas Volkert
07c3a4f693 avformat/udp: UDP-Lite (RFC 3828) support added
(This fixes ticket #1501)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-05 11:16:05 +01:00