Commit graph

33 commits

Author SHA1 Message Date
Matthew Waters
1f7515100c rtmp2/connection: pass the parent cancellable down to the connection
Otherwise, when rtpm2src cancels an inflight operation that has a queued
message stored, then the rtmp connection operation is not stopped.

If the cancellation occurs during rtmp connection start up, then
rtpm2src does not have any way of accessing the connection object as it
has not been returned yet.  As a result, rtpm2src will cancel, the
connection will still be processing things and the
GMainContext/GMainLoop associated with the outstanding operation will be
destroyed.  All outstanding operations and the rtmpconnection object will
therefore be leaked in this case.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1425
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1862>
2020-12-08 23:43:02 +00:00
Jan Alexander Steffens (heftig)
16a07d303a rtmp2: Replace stats queue with stats lock
Making the thread receiving the stats wait on the loop to respond was
not a good idea, as the latter can get blocked on the streaming thread.

Have get_stats read the values directly, adding a lock to ensure we
don't read garbage.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1550>
2020-09-09 06:34:51 +00:00
Nazar Mokrynskyi
ebc057bb7a rtmp2sink: add docs section with since marker on new stop-commands property
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1256>
2020-09-09 05:53:08 +00:00
Jan Alexander Steffens (heftig)
30274dee52 rtmp2: Clean up (improve) GstRtmpStopCommands type
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1256>
2020-09-09 05:53:08 +00:00
Nazar Mokrynskyi
9a2828c216 rtmp2sink: handle EOS event and close stream
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1285

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1256>
2020-09-09 05:53:08 +00:00
Jan Alexander Steffens (heftig)
1e29c5d52a rtmp2: Set connect args like libavformat does
To improve our compatibility. Critically, a server might elide data for
codecs we don't advertise.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1384>
2020-07-01 18:33:42 +00:00
Jan Alexander Steffens (heftig)
2ad3aab1d4 rtmp2: Add support for AGGREGATE messages
They're multiple frames (tags) of FLV data wrapped into a message.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1384>
2020-07-01 18:33:42 +00:00
Jan Alexander Steffens (heftig)
30b1187108 rtmp2: Move FLV tag header parsing into rtmputils.c
To be shared with the AGGREGATE handling.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1384>
2020-07-01 18:33:42 +00:00
Jan Alexander Steffens (heftig)
368c038ef0 rtmp2: Mark our memory singleton as leakable
So it doesn't appear in the leaks tracer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1384>
2020-07-01 18:33:42 +00:00
Jan Alexander Steffens (heftig)
edd3c4fadf rtmp2: Remove GST_ERROR from rtmputils.c
This file does not have debug logging set up.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1384>
2020-07-01 18:33:42 +00:00
Jan Alexander Steffens (heftig)
91a033a85e
rtmp2: Allow setting flash-version
In case the application has to deal with fussy servers. User agent
sniffing is so last decade.

Adds a property to set the Flash version on both the sink and the src.
The default stays the same (IIRC, Flash plugin for Linux from 2009).
2020-02-25 15:10:28 +01:00
Jan Alexander Steffens (heftig)
f1a9a3146a
rtmp2: Add gst_rtmp_connection_get_stats and _get_null_stats
The former uses a thread-safe way of getting statistics from the
connection without having to protect the fields with a lock.

The latter produces a zeroed statistics structure for use when no
connection exists.
2020-02-21 19:26:35 +01:00
Jan Alexander Steffens (heftig)
5d720eb59e
rtmp2: Count outgoing bytes and acked bytes
For statistics.
2020-02-21 19:26:33 +01:00
Jan Alexander Steffens (heftig)
f7bb2cdeb7 rtmp2: Add gst_rtmp_connection_set_chunk_size 2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
63ec837824 rtmp2: Handle outgoing set chunk/window size properly
Apply outgoing sizes only after writing the chunk to the peer. This is
important particularly for the set chunk size and allows exposing it
without threading issues.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
a566461294 rtmp2: Chunk messages as buffers in loop thread
Move output chunking from gst_rtmp_connection_queue_message into
gst_rtmp_connection_start_write, which effectively moves it from the
streaming thread into the loop thread.

This allows us to handle the outgoing chunk-size message (which is
generated by changing the future chunk-size property) properly, which
could come from any other thread.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
9a13df9ba5 rtmp2: Consistently use GstBuffer for RTMP chunks 2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
b03780233e rtmp2: Add gst_rtmp_chunk_stream_serialize_all
Serializes an RTMP message into a series of chunks, all in one buffer.

Similar to what gst_rtmp_connection_queue_message does to serialize
into a GByteArray.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
cb7f0c4be7 rtmp2: Add gst_rtmp_output_stream_write_all_buffer_async
Similar to gst_rtmp_output_stream_write_all_bytes_async, but takes a
GstBuffer instead of a GBytes. It can also return the number of bytes
written, which might be lower in case of an error.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
286a3829b6 rtmp2: Improve handling incoming set chunk/window size
Reject out-of-spec sizes and warn about suspiciously small sizes.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
6583e00d50 rtmp2: Reject oversized messages
We only have 24 bits for the size, so reject anything larger.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
0044e7a1ba rtmp2: Count in_bytes_acked instead of in_bytes_unacked
This is nicer for statistics.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
11a1de0053 rtmp2: rtmpconnection: Use more appropriate size types
- guint32 for chunk size and window size
- guint64 for running counters
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
279e3c333c rtmp2: Add a g_return_val_if_fail 2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
03c3257f0f rtmp2: Replace explicit unref with g_main_context_invoke_full 2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
baad4fd91b rtmp2: rtmpconnection: Use GST_*_OBJECT logging
GstRtmpConnection isn't a GstObject with a name or path, but we still
get the GObject's type and address.
2020-02-21 15:20:41 +00:00
Jan Alexander Steffens (heftig)
042e439829
rtmp2: Add gst_rtmp_message_is_metadata
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878
2019-12-03 14:11:47 +01:00
Jan Alexander Steffens (heftig)
e07a1bb48f
rtmp2: Add gst_rtmp_connection_set_data_frame
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878
2019-12-03 14:11:47 +01:00
Jan Alexander Steffens (heftig)
8f1ae04ac5
rtmp2: Add single-value AMF0 parsing and serializing
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878
2019-12-03 14:11:47 +01:00
Jan Alexander Steffens (heftig)
f5b068b26c
rtmp2: Minor changes
- Remove an unneeded initialization to zero from AmfParser
- Add missing initialization to gst_amf_serialize_command_valist
- Add a g_return_if_fail to gst_rtmp_connection_request_window_size

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878
2019-12-03 14:11:46 +01:00
Jan Alexander Steffens (heftig)
346bca80af
rtmp2: Fix NULL check in gst_rtmp_meta_transform
Coverity rightly complains that checking a pointer for NULL after
dereferencing it is pointless.

Remove the check, and to be safe, assert that gst_buffer_add_meta
returns non-NULL.

CID 1455485
2019-11-12 12:20:34 +01:00
Jan Alexander Steffens (heftig)
f730f4a694
rtmp2: Check for missing GstRtmpMeta
The message buffers are created using `gst_rtmp_message_new` and thus
always contain a GstRtmpMeta. Add checks to appease Coverity's static
analysis.

CID 1455596
CID 1455384
2019-11-12 12:20:30 +01:00
Vivia Nikolaidou
2386858a91 Add files from gst-rtmp
For master, without autotools.
2019-11-05 13:52:55 +00:00