Commit Graph

9118 Commits

Author SHA1 Message Date
Martin Storsjö 4a4a7e138c rtpenc_chain: Use the original AVFormatContext for getting payload type
In ff_rtp_get_payload_type, the AVFormatContext is used for checking
whether the payload_type or rtpflags options are set. In rtpenc_chain,
the rtpctx struct is a newly initialized struct where no options have
been set yet, so no options can be fetched from there.

All muxers that internally chain rtp muxers have the "rtpflags" field
that allows passing such options on (which is how this worked before
8034130e06), so this works just as intended.

This makes it possible to produce H263 in RFC2190 format with chained
RTP muxers.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-24 11:31:36 +02:00
Martin Storsjö 932117171f rtp: Make sure the output format pointer is set
Not sure if this actually happens, but we do the same check when
checking payload_type further above in the function, so it might
be needed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-24 11:31:35 +02:00
Martin Storsjö e90820d4f8 rtp: Make sure priv_data is set before reading it
This fixes crashes with muxing H263 into RTSP.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-23 23:30:58 +02:00
Xi Wang cf29f49d8a rtpenc: fix overflow checking in avc_mp4_find_startcode()
The check `start + res < start' is broken since pointer overflow is
undefined behavior in C.  Many compilers such as gcc/clang optimize
away this check.

Use `res > end - start' instead.  Also change `res' to unsigned int
to avoid signed left-shift overflow.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-23 13:51:29 +02:00
Xi Wang ecb918e5f0 rtmp: fix buffer overflows in ff_amf_tag_contents()
A negative `size' will bypass FFMIN().  In the subsequent memcpy() call,
`size' will be considered as a large positive value, leading to a buffer
overflow.

Change the type of `size' to unsigned int to avoid buffer overflow, and
simplify overflow checks accordingly. Also change a literal buffer
size to use sizeof, and limit the amount of data copied in another
memcpy call as well.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-23 13:51:28 +02:00
Xi Wang 3cff53369a rtmp: fix multiple broken overflow checks
Sanity checks like `data + size >= data_end || data + size < data' are
broken, because `data + size < data' assumes pointer overflow, which is
undefined behavior in C.  Many compilers such as gcc/clang optimize such
checks away.

Use `size < 0 || size >= data_end - data' instead.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-23 13:51:27 +02:00
Martin Storsjö ab587f39b2 rtpenc: Start the sequence numbers from a random offset
Expose the current sequence number via an AVOption - this can
be used both for setting the initial sequence number, or for
querying the current number.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-22 00:25:38 +02:00
Jindrich Makovicka 570a4a0189 avidec: use sensible error codes instead of -1
Use AVERROR_INVALIDDATA on invalid inputs, and AVERROR_EOF when no more
frames are available in an interleaved AVI.

Signed-off-by: Jindrich Makovicka <makovick@gmail.com>
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2013-01-21 16:02:40 +01:00
Martin Storsjö c9311f3e46 srtp: Move a variable to a local scope
This simplifies the code slightly.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:17:00 +02:00
Martin Storsjö ae01e8d295 srtp: Add tests for the crypto suite with 32/80 bit HMAC
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:13:43 +02:00
Martin Storsjö 3ef6d22e1b srtp: cosmetics: Use fewer lines for the test vectors
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:13:43 +02:00
Martin Storsjö b4bb1d493c srtp: Don't require more input data than what actually is needed
The theoretical minimum for a (not totally well formed) RTCP packet
is 8 bytes, so we shouldn't require 12 bytes as minimum input.

Also return AVERROR_INVALIDDATA instead of 0 if something that is
not a proper packet is given.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:13:43 +02:00
Martin Storsjö a2a991b2dd srtp: Improve the minimum encryption buffer size check
This clarifies where the limit number comes from, and only
requires exactly as much padding space as will be needed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:13:43 +02:00
Martin Storsjö e1d0b3d875 srtp: Add support for a few DTLS-SRTP related crypto suites
The main difference to the existing suites from RFC 4568 is
that the version with a 32 bit HMAC still uses 80 bit HMAC
for RTCP packets.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:13:35 +02:00
Martin Storsjö f53490cc0c rtpdec/srtp: Handle CSRC fields being present
This is untested in practice, but follows the spec.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:10:47 +02:00
Martin Storsjö a76bc3bc44 rtpdec: Check the return value from av_new_packet
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-21 00:08:19 +02:00
Martin Storsjö c6f1dc8e4c rtpdec: Move setting the parsing flags to the actual depacketizers
This gets rid of almost all the codec specific details from the
generic rtpdec code.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:20:42 +02:00
Martin Storsjö a9c847c1ba rtpdec: Split handling of mpeg12 audio/video to a separate depacketizer
This also adds checking of mallocs.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:20:22 +02:00
Martin Storsjö 2326558d52 rtpdec: Split mpegts parsing to a normal depacketizer
This gets rid of a number of special cases from the common rtpdec
code.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:17:17 +02:00
Martin Storsjö d5bb8cc2dd rtpdec: Reorder payload handler registration alphabetically
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:16:04 +02:00
Martin Storsjö a717f99042 mpegts: Share the cleanup code between the demuxer and lavf-internal parser functions
The lavf-internal parser functions are used when receiving
mpegts over RTP. This fixes memory leaks in this setup.

The normal mpegts demuxer close function was updated in ec7d0d2e in
2004 to fix leaks, but the parsing function used for RTP wasn't
updated and has been leaking ever since.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:14:17 +02:00
Martin Storsjö 21f5c24b80 rtpdec_mpeg4: Return one AAC AU per AVPacket
This makes the returned data valid to stream copy into other
containers as well, not only for decoding straight away.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:12:38 +02:00
Luca Barbato 80ac87c13d lavc: support ZenoXVID custom tag
Looks like this kind of samples are produced by certain Russian
equipment.
2013-01-17 21:41:18 +01:00
Justin Ruggles b805c725a3 idcin: fix memleaks in idcin_read_packet()
Fixes fate-id-cin-video failures when running FATE with valgrind.
2013-01-16 12:21:35 -05:00
Martin Storsjö a7ba324413 rtpdec_mpeg4: Check the remaining amount of data before reading
This fixes possible buffer overreads.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-16 11:12:39 +02:00
Martin Storsjö 977d4a3b8a rtpdec_mpeg4: Check the return value from malloc
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 23:18:33 +02:00
Martin Storsjö 42364fcbca srtp: Mark a few variables as uninitialized
This squelches false positive warnings (with gcc) about them being
used uninitalized.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 23:18:08 +02:00
Martin Storsjö c2603aa25b lavf: Add a fate test for the SRTP functions
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 23:18:08 +02:00
Martin Storsjö 611bf39bde sdp: Include SRTP crypto params if using the srtp protocol
Also print port numbers for this protocol.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 11:55:29 +02:00
Martin Storsjö 2f3bada63e lavf: Add a protocol for SRTP encryption/decryption
This is mostly useful for encryption together with the RTP muxer,
but could also be set up as IO towards the peer with the SDP
demuxer with custom IO.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 11:55:10 +02:00
Martin Storsjö 424da30830 rtsp: Support decryption of SRTP signalled via RFC 4568 (SDES)
This only takes care of decrypting incoming packets; the outgoing
RTCP packets are not encrypted. This is enough for some use cases,
and signalling crypto keys for use with outgoing RTCP packets
doesn't fit as simply into the API. If the SDP demuxer is hooked
up with custom IO, the return packets can be encrypted e.g. via the
SRTP protocol.

If the SRTP keys aren't available within the SDP, the decryption
can be handled externally as well (when using custom IO).

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 11:54:40 +02:00
Martin Storsjö ab2ad8bd56 lavf: Add functions for SRTP decryption/encryption
This supports the AES_CM_128_HMAC_SHA1_80 and
AES_CM_128_HMAC_SHA1_32 cipher suites (from RFC 4568) at the
moment. The main missing features are replay protection (which can be
added later without changing the internal API), and the F8 and null
ciphers.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 11:54:34 +02:00
Diego Biurrun d8c772de53 nutdec: Always return a value from nut_read_timestamp()
The function is a callback that is called by ff_gen_search with
a constant stream index.

Avoid a false positive on older gcc version.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-01-15 02:15:09 +01:00
Giorgio Vazzana 39403c6c1b oggparsetheora: fix comment header parsing
Pass the correct header size to ff_vorbis_comment()

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 20:47:27 +02:00
Luca Barbato 23a610b9d6 nut: support vp9 tag 2013-01-14 19:20:47 +01:00
Tom Finegan 66aabd76a9 mkv: support vp9 tag 2013-01-14 19:20:47 +01:00
Martin Storsjö d596f2b322 rtpdec: Make variables that should wrap unsigned
This makes the behaviour defined when they wrap around. The value
assigned to expected_prior was a uint32_t already.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 20:09:42 +02:00
Martin Storsjö 30b50f79ae rtpdec: Handle more received packets than expected when sending RR
Without this, we'd signal a huge loss rate (due to unsigned
wraparound) if we had received one packet more than expected (that
is, one seq number sent twice). The code has a check for lost_interval
<= 0, but that doesn't do what was intended as long as the variable is
unsigned.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 17:52:02 +02:00
Martin Storsjö d0fe217e39 rtpdec: Simplify insertion into the linked list queue
By using a pointer-to-pointer, we avoid having to keep track
of the previous packet separately.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 17:51:48 +02:00
Martin Storsjö 62761934b0 rtpdec: Remove a woefully misplaced comment
The code below the comment does not at all relate to statistics,
and even if moved to the right place, the comment adds little
value.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 17:51:42 +02:00
Michael Niedermayer 6dc8505417 rtmpproto: Fix assignments in if()
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 13:13:00 +02:00
Michael Niedermayer d641ee94b5 lavf: Fix assignments in if()
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-14 13:12:55 +02:00
Martin Storsjö 22c436c85e rtpdec: Send a valid "delay since SR" value in the RTCP RR packets
Previously, we always signalled a zero time since the last RTCP
SR, which is dubious.

The code also suggested that this would be the difference in
RTP NTP time units (32.32 fixed point), while it actually is
in in 1/65536 second units. (RFC 3550 section 6.4.1)

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 19:55:49 +02:00
Martin Storsjö e568db4025 rtpdec: Calculate and report packet reception jitter
This brings back some code that was added originally in 4a6cc061
but never was used, and was removed as unused in 4cc843fa. The
code is updated to actually work and is tested to return sane
values.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 19:53:53 +02:00
Martin Storsjö abae27ed3a rtpdec: Fix the calculation of expected number of packets
The base_seq variable is set to first_seq - 1 (in
rtp_init_sequence), so no + 1 is needed here.

This avoids reporting 1 lost packet from the start.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 19:48:41 +02:00
Martin Storsjö f6804c3e1b rtpdec: Remove a useless todo comment
The question can be answered: No, we do not know the initial sequence
number from the SDP. In certain cases, it can be known from the
RTP-Info response header in RTSP though. (In that case, we use it as
timestamp origin, but not for rtp receiver statistics.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 00:02:17 +02:00
Martin Storsjö 54cb096ee4 rtsp: Remove an outdated comment
It is unclear what the bug exactly was and if it ever was fixed,
and we don't even support decoding via faad any longer. The
comment has been present since d0deedcb in 2006.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 00:02:11 +02:00
Martin Storsjö 3900d53fb1 rtsp: Remove references to weirdly named variables in other files
One of them is renamed now, but mentioning it by name serves
no purpose here.  The other table mentioned ceased to exist
under that name in 4934884a1 in 2006.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 00:02:04 +02:00
Martin Storsjö c44784c9bb rtp: Rename a static variable to normal naming conventions
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 00:01:51 +02:00
Martin Storsjö 58b5971881 rtp: Cosmetic cleanup
Remove leftover debug comments, fix brace placement and
add whitespace, remove unnecessary and weirdly placed braces.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-12 00:01:28 +02:00