Commit graph

55 commits

Author SHA1 Message Date
Doug Nazar
81d4ccdc44 rtmp2: Use correct size of write macro for param2.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2146>
2021-04-07 07:48:57 -04:00
Jan Alexander Steffens (heftig)
0b916e7cec rtmp2/connection: Separate inner from outer cancelling
The connection cancels itself when it is closed. To avoid the
cancellable passed to `gst_rtmp_connection_new` from being unexpectedly
cancelled, separate inner from outer cancellation by holding two
cancellables.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1558

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2111>
2021-03-28 11:07:33 +00:00
Matthew Waters
640a65bf96 gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics
should be used instead.  GCC 11 has started warning about using volatile
with atomic operations.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2098>
2021-03-22 14:34:36 +11:00
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
Seungha Yang
639fb6ac15 rtmp2src: Set buffer timestamp on output buffer
This timestamp information would be useful for queue2 element
when calculating time level and also it makes buffering decision
more reliable.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1727>
2020-10-28 16:32:32 +00:00
Tim-Philipp Müller
1ed969d276 rtmp2sink: fix since marker on new "stop-commands" property
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1687>
2020-10-12 11:55:46 +01: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
Nazar Mokrynskyi
8c37eea410 rtmp2: fix code style, update documentation cache
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
Nirbheek Chauhan
ce18a344f4 rtmp2: Need to unescape the userinfo before setting
This regressed in 827afa206d. The same
fix was also committed to the webrtc element, but rtmp2 was missed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1547>
2020-08-30 09:53:42 +00:00
Nirbheek Chauhan
d4ca8820e7 webrtc, rtmp2: Warn if the user or password aren't escaped
If the user/pass aren't escaped, the userinfo will be ambiguous and we
won't know where to split. We will accidentally get it right if the :
belongs in the password.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1481>
2020-08-03 18:12:50 +00:00
Nirbheek Chauhan
827afa206d webrtc, rtmp2: Fix parsing of userinfo in URI strings
While parsing the string, `gst_uri_from_string()` also unescapes the
userinfo. This is bad if your username contains a `:` character, since
we will then split the userinfo at the wrong location when parsing it.

To fix this, we can use the new `gst_uri_from_string_escaped()` API
that was added in
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/583

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/831

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1481>
2020-08-03 18:12:50 +00:00
Tim-Philipp Müller
510e8ef8cb docs: fix element names in section headers
Hopefully that'll make hotdoc pick up the docs for these elements.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1428>
2020-07-10 19:22:29 +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
Mathieu Duponchelle
6baffc2931 docs: mark more types as plugin API 2020-06-23 12:10:17 -04:00
Mathieu Duponchelle
a048ce81d4 plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:40:42 +02:00
Sebastian Dröge
74f2f733be plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-04 13:33:16 -04:00
Edward Hervey
f3d6026ad2 rtmp2src: Answer scheduling query
Just like for rtmpsrc, we must inform downstream that we are a
sequential (i.e. don't do random access efficiently) and
bandwith-limited (i.e. might need buffering downstream) element

Fixes buffering issues with playbin3

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1282>
2020-05-20 10:55:55 +02:00
Jan Alexander Steffens (heftig)
6680b70781
rtmp2: Avoid a deadlock when getting stats
We need to do this without holding the lock as the `g_async_queue_pop`
waits on the loop thread to deliver the stats. The loop thread might
attempt to take the lock as well, leading to a deadlock.

Taking a reference to the connection should be enough to keep this
safe.
2020-04-08 18:41:01 +02:00
Seungha Yang
7f5347a664 rtmp2src: Add idle-timeout property
Add new property to signalling that there is no incoming data
from peer. This can be useful if users want to stop the streaming
when the connection is alive but no packet is arriving.
2020-03-27 10:25:37 +00:00
Jan Alexander Steffens (heftig)
e83888302d rtmp2: Only grab stats on close when connection exists
If the connection attempt failed, self->connection is NULL.
2020-03-03 10:27:31 +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)
02a6a794ec
rtmp2: Expose connection stats as property
Save the stats before we destroy the connection, so we can still
retrieve them afterwards.
2020-02-21 19:26:35 +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)
0c344a7efb rtmp2sink: Add a property for the outgoing chunk size 2020-02-21 15:20:41 +00: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)
14fd7e0884 rtmp2: Lock self->lock before OBJECT_LOCK
OBJECT_LOCK is used to protect property access only. self->lock is
used to access the RtmpConnection, mostly between the streaming thread
and the loop thread.

To avoid deadlocks involving these two locks, we obey a lock order:
If both self->lock and OBJECT_LOCK are needed, self->lock must be locked
first. Clarify this.
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)
fd6c51b2e7
rtmp2sink: Only apply @setDataFrame to onMetaData messages
Only the metadata needs to be made "sticky". Custom data messages should
be passed on unmodified.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878
2019-12-03 14:11:47 +01: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