Skip to content

Commit

Permalink
update rtsp
Browse files Browse the repository at this point in the history
  • Loading branch information
SpookySkeletons committed Mar 27, 2024
1 parent d711782 commit ce59c51
Show file tree
Hide file tree
Showing 39 changed files with 790 additions and 536 deletions.
59 changes: 31 additions & 28 deletions patches/protonprep-valve-staging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,35 +288,38 @@
patch -Np1 < ../patches/proton/47-proton-fshack-AMD-FSR-complete.patch

echo "WINE: RTSP patch"
patch -Np1 < ../patches/wine-gst/0001-winegstreamer-Wait-for-samples-in-a-dedicated-work-q.patch
patch -Np1 < ../patches/wine-gst/0002-winegstreamer-Add-a-resampler-to-wg_parser-for-raw-a.patch
patch -Np1 < ../patches/wine-gst/0003-winegstreamer-Add-a-videoscale-element-to-wg_parser-.patch
patch -Np1 < ../patches/wine-gst/0004-winegstreamer-Do-away-with-the-per-stream-condvars-a.patch
patch -Np1 < ../patches/wine-gst/0005-winegstreamer-Implement-buffering-in-wg_parser.patch
patch -Np1 < ../patches/wine-gst/0006-winegstreamer-Add-more-RTSP-based-formats-to-GStream.patch
patch -Np1 < ../patches/wine-gst/0007-winegstreamer-Pass-all-uridecodebin-output-streams-t.patch
patch -Np1 < ../patches/wine-gst/0008-winegstreamer-Set-a-clock-for-the-wg_parser-pipeline.patch
patch -Np1 < ../patches/wine-gst/0009-winegstreamer-Set-base-time-on-wg_parser-bin-while-c.patch
patch -Np1 < ../patches/wine-gst/0010-winegstreamer-Reorder-parser-initialization-code-a-b.patch
patch -Np1 < ../patches/wine-gst/0011-winegstreamer-Temporarily-put-pipeline-into-PLAYING-.patch
patch -Np1 < ../patches/wine-gst/0012-winegstreamer-Convert-buffer-presentation-timestamps.patch
patch -Np1 < ../patches/wine-gst/0013-winegstreamer-Make-wg_parser-report-the-exact-suppor.patch
patch -Np1 < ../patches/wine-gst/0014-winegstreamer-Schedule-stored-timers-for-the-origina.patch
patch -Np1 < ../patches/wine-gst/0015-winegstreamer-Start-forwarding-samples-only-at-the-P.patch
patch -Np1 < ../patches/wine-gst/0016-winegstreamer-HACK-Pretend-that-we-have-a-discontinu.patch
patch -Np1 < ../patches/wine-gst/0017-mfmediaengine-Do-not-send-MF_MEDIA_ENGINE_EVENT_ERRO.patch
patch -Np1 < ../patches/wine-gst/0018-Revert-winegstreamer-HACK-Pretend-that-we-have-a-dis.patch
patch -Np1 < ../patches/wine-gst/0019-mf-In-the-media-session-pretend-that-we-have-a-disco.patch
patch -Np1 < ../patches/wine-gst/0020-winegstreamer-Do-not-put-pipeline-back-into-PAUSED-s.patch
patch -Np1 < ../patches/wine-gst/0021-winegstreamer-Use-pthread_cond_broadcast-instead-of-.patch
patch -Np1 < ../patches/wine-gst/0022-winegstreamer-Ignore-assert-in-wg_parser.patch
patch -Np1 < ../patches/wine-gst/0023-winegstreamer-Discard-buffers-with-negative-PTS.patch
patch -Np1 < ../patches/wine-gst/0024-SQUASH-mf-In-media-session-discard-samples-with-nega.patch
patch -Np1 < ../patches/wine-gst/0025-winegstreamer-Adjust-buffer-timestamps-after-seek.patch
patch -Np1 < ../patches/wine-gst/0026-SQUASH-winegstreamer-Factor-out-multiqueue-creation-.patch
patch -Np1 < ../patches/wine-gst/0027-winegstreamer-Do-not-fail-caps-negotiation-when-ther.patch
patch -Np1 < ../patches/wine-gst/0028-winegstreamer-Fixate-caps-in-autoplug_continue_cb.patch
patch -Np1 < ../patches/wine-gst/0001-winegstreamer-Do-not-create-a-read-thread-for-uridec.patch
patch -Np1 < ../patches/wine-gst/0002-winegstreamer-Ignore-an-assert-in-wg_parser.patch
patch -Np1 < ../patches/wine-gst/0003-winegstreamer-Fixate-caps-in-autoplug_continue_cb.patch
patch -Np1 < ../patches/wine-gst/0004-winegstreamer-Make-wg_parser-report-the-exact-suppor.patch
patch -Np1 < ../patches/wine-gst/0005-winegstreamer-Add-more-RTSP-based-URI-schemes-to-GSt.patch
patch -Np1 < ../patches/wine-gst/0006-winegstreamer-Set-a-clock-for-the-wg_parser-pipeline.patch
patch -Np1 < ../patches/wine-gst/0007-winegstreamer-Set-base-time-on-wg_parser-bin-while-c.patch
patch -Np1 < ../patches/wine-gst/0008-winegstreamer-Put-pipeline-into-PLAYING-state-before.patch
patch -Np1 < ../patches/wine-gst/0009-winegstreamer-Convert-buffer-presentation-timestamps.patch
patch -Np1 < ../patches/wine-gst/0010-winegstreamer-Adjust-buffer-timestamps-after-seek.patch
patch -Np1 < ../patches/wine-gst/0011-winegstreamer-Reorder-parser-initialization-code-a-b.patch
patch -Np1 < ../patches/wine-gst/0012-winegstreamer-Do-away-with-the-per-stream-condvars-a.patch
patch -Np1 < ../patches/wine-gst/0013-winegstreamer-Do-not-fail-caps-negotiation-when-ther.patch
patch -Np1 < ../patches/wine-gst/0014-HACK-mfmediaengine-Do-not-send-MF_MEDIA_ENGINE_EVENT.patch
patch -Np1 < ../patches/wine-gst/0015-Marker-commit-do-not-put-into-MR.patch
patch -Np1 < ../patches/wine-gst/0016-winegstreamer-Wait-for-samples-in-a-dedicated-work-q.patch
patch -Np1 < ../patches/wine-gst/0017-winegstreamer-Add-a-resampler-to-wg_parser-for-raw-a.patch
patch -Np1 < ../patches/wine-gst/0018-winegstreamer-Add-a-videoscale-element-to-wg_parser-.patch
patch -Np1 < ../patches/wine-gst/0019-winegstreamer-Implement-buffering-in-wg_parser.patch
patch -Np1 < ../patches/wine-gst/0020-winegstreamer-Pass-all-uridecodebin-output-streams-t.patch
patch -Np1 < ../patches/wine-gst/0021-winegstreamer-Schedule-stored-timers-for-the-origina.patch
patch -Np1 < ../patches/wine-gst/0022-mf-Start-forwarding-samples-only-at-the-PTS-of-the-f.patch
patch -Np1 < ../patches/wine-gst/0023-winegstreamer-HACK-Pretend-that-we-have-a-discontinu.patch
patch -Np1 < ../patches/wine-gst/0024-Revert-winegstreamer-HACK-Pretend-that-we-have-a-dis.patch
patch -Np1 < ../patches/wine-gst/0025-mf-In-the-media-session-pretend-that-we-have-a-disco.patch
patch -Np1 < ../patches/wine-gst/0026-winegstreamer-Use-pthread_cond_broadcast-instead-of-.patch
patch -Np1 < ../patches/wine-gst/0027-SQUASH-mf-In-media-session-discard-samples-with-nega.patch
patch -Np1 < ../patches/wine-gst/0028-SQUASH-winegstreamer-Factor-out-multiqueue-creation-.patch
patch -Np1 < ../patches/wine-gst/0029-winegstreamer-GST_LOG-GST_DEBUG.patch
patch -Np1 < ../patches/wine-gst/0030-winegstreamer-Signal-flow-error-when-parser-is-in-er.patch
patch -Np1 < ../patches/wine-gst/0031-Revert-winegstreamer-Implement-buffering-in-wg_parse.patch
patch -Np1 < ../patches/wine-gst/0032-SQUASH-winegstreamer-Tighten-buffering-limits-and-th.patch

#echo "WINE: -Nvidia Reflex- Support VK_NV_low_latency2"
#patch -Np1 < ../patches/proton/83-nv_low_latency_wine.patch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 294c85000c51d7562eef31175487a096ac87179a Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Mon, 25 Mar 2024 09:19:18 +0100
Subject: [PATCH 01/32] winegstreamer: Do not create a read thread for
uridecodebin-based media sources.

---
dlls/winegstreamer/media_source.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index 83ab880f8ef..6d58d51045a 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -1614,9 +1614,12 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)

wg_parser_disconnect(source->wg_parser);

- source->read_thread_shutdown = true;
- WaitForSingleObject(source->read_thread, INFINITE);
- CloseHandle(source->read_thread);
+ if (source->read_thread)
+ {
+ source->read_thread_shutdown = true;
+ WaitForSingleObject(source->read_thread, INFINITE);
+ CloseHandle(source->read_thread);
+ }

IMFMediaEventQueue_Shutdown(source->event_queue);
IMFByteStream_Close(source->byte_stream);
@@ -1711,7 +1714,8 @@ static HRESULT media_source_create(struct object_context *context, IMFMediaSourc
}
object->wg_parser = parser;

- object->read_thread = CreateThread(NULL, 0, read_thread, object, 0, NULL);
+ if (context->type != WG_PARSER_URIDECODEBIN)
+ object->read_thread = CreateThread(NULL, 0, read_thread, object, 0, NULL);

object->state = SOURCE_OPENING;

--
2.44.0

Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
From 566e91a7df1968c79786fb94d67ddd1b466f8640 Mon Sep 17 00:00:00 2001
From d7061741bdb93e8d06ba60102d33bd01cb797b27 Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Tue, 19 Mar 2024 04:06:37 +0100
Subject: [PATCH 22/29] winegstreamer: Ignore assert in wg_parser.
Subject: [PATCH 02/32] winegstreamer: Ignore an assert in wg_parser.

I don't know why this gets hit but it does.

EDIT: I think this gets hit when a wg_parser receives GST_EVENT_FLUSH_START between the wg_parser_stream_get_buffer
function return and the wg_parser_stream_release_buffer call. In this case the NULL buffer can be ignored, it does no
harm and there is no memory leak from this.
This gets hit when a wg_parser receives GST_EVENT_FLUSH_START between the wg_parser_stream_get_buffer function return
and the wg_parser_stream_release_buffer call. In this case the NULL buffer can be ignored, it does no harm and there
is no memory leak from this.
---
dlls/winegstreamer/wg_parser.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index c8f173df6ac..5c75776f523 100644
index 2d00f4247e0..8f45f49b012 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -422,11 +422,12 @@ static NTSTATUS wg_parser_stream_release_buffer(void *args)
@@ -409,11 +409,12 @@ static NTSTATUS wg_parser_stream_release_buffer(void *args)

pthread_mutex_lock(&parser->mutex);

Expand All @@ -32,8 +30,8 @@ index c8f173df6ac..5c75776f523 100644
+ stream->buffer = NULL;
+ }

if (stream->buffer_queue && stream->buffer_queue_length)
{
pthread_mutex_unlock(&parser->mutex);
pthread_cond_signal(&stream->event_empty_cond);
--
2.44.0

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
From 8352bf2c8624c3015d54169868b6df6ef6a87484 Mon Sep 17 00:00:00 2001
From dd85cdadb0ab69640e5d3116774ca9d7b090dbfd Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Tue, 19 Mar 2024 10:19:09 +0100
Subject: [PATCH 28/29] winegstreamer: Fixate caps in autoplug_continue_cb.
Subject: [PATCH 03/32] winegstreamer: Fixate caps in autoplug_continue_cb.

Not strictly necessary but avoids an assert in gstreamer code.
---
dlls/winegstreamer/wg_parser.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 4c4ee4bcc2a..3bee51ed518 100644
index 8f45f49b012..20009d6f269 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -577,7 +577,9 @@ static gboolean autoplug_continue_cb(GstElement * decodebin, GstPad *pad, GstCap
@@ -527,7 +527,9 @@ static gboolean autoplug_continue_cb(GstElement * decodebin, GstPad *pad, GstCap
{
struct wg_format format;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
From c61856ab6b81f6f654ec0fe2a194fa87c5b75f5f Mon Sep 17 00:00:00 2001
From e27afb77ed05d69fa8515a1e821e1341c1a04b42 Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Tue, 20 Feb 2024 23:17:28 +0100
Subject: [PATCH 13/29] winegstreamer: Make wg_parser report the exact
Subject: [PATCH 04/32] winegstreamer: Make wg_parser report the exact
supported formats to gstreamer instead of just ANY.

---
dlls/winegstreamer/wg_parser.c | 47 +++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
dlls/winegstreamer/wg_parser.c | 42 +++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 9cabc0d899b..962cc136173 100644
index 20009d6f269..1d3314c582e 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -935,6 +935,48 @@ static GstFlowReturn sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *bu
@@ -835,6 +835,43 @@ static GstFlowReturn sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *bu
return GST_FLOW_OK;
}

+static GstCaps *get_supported_formats(void)
+{
+ static const GstAudioChannelPosition dummy_positions[] =
+ {
+ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
+ };
+ GstCaps *caps = gst_caps_new_empty(), *temp;
+ GstAudioInfo ainfo;
+ GstVideoInfo vinfo;
+ gsize i;
+
+ /* video/x-raw */
+ gst_video_info_set_format(&vinfo, WG_VIDEO_FORMAT_BGRA, 1920, 1080);
+ gst_video_info_set_format(&vinfo, GST_VIDEO_FORMAT_BGRA, 1, 1);
+ temp = gst_video_info_to_caps(&vinfo);
+ for (i = 0; i < gst_caps_get_size(temp); ++i)
+ gst_structure_remove_fields(gst_caps_get_structure(temp, i),
+ "format", "width", "height", "framerate", NULL);
+ "format", "width", "height", "framerate", "colorimetry", NULL);
+ gst_caps_append(caps, temp);
+ /* other formats */
+ gst_caps_append(caps, gst_caps_new_empty_simple("video/x-cinepak"));
Expand All @@ -43,7 +38,7 @@ index 9cabc0d899b..962cc136173 100644
+ gst_caps_append(caps, gst_caps_new_empty_simple("video/x-indeo"));
+
+ /* audio/x-raw */
+ gst_audio_info_set_format(&ainfo, GST_AUDIO_FORMAT_S16LE, 48000, 2, dummy_positions);
+ gst_audio_info_set_format(&ainfo, GST_AUDIO_FORMAT_S16LE, 1, 1, NULL);
+ temp = gst_audio_info_to_caps(&ainfo);
+ for (i = 0; i < gst_caps_get_size(temp); ++i)
+ gst_structure_remove_fields(gst_caps_get_structure(temp, i),
Expand All @@ -61,7 +56,7 @@ index 9cabc0d899b..962cc136173 100644
static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query)
{
struct wg_parser_stream *stream = gst_pad_get_element_private(pad);
@@ -952,7 +994,10 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query)
@@ -852,7 +889,10 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query)
gst_query_parse_caps(query, &filter);

pthread_mutex_lock(&parser->mutex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
From d241727d56653caaa71b24243132ef8f21857e76 Mon Sep 17 00:00:00 2001
From 71789e7d80746468414cb14c18e9b885b11fc157 Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Wed, 31 Jan 2024 17:42:54 +0100
Subject: [PATCH 06/29] winegstreamer: Add more RTSP-based formats to GStreamer
scheme handler.
Subject: [PATCH 05/32] winegstreamer: Add more RTSP-based URI schemes to
GStreamer scheme handler.

---
dlls/winegstreamer/winegstreamer.rgs | 32 ++++++++++++++++++++++++++++
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3acfeb18e113122b20b6d6a7eb527a3037f01a72 Mon Sep 17 00:00:00 2001
From f674a8869be9b25f33d507a81fc13c85a6b38046 Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Wed, 31 Jan 2024 17:42:55 +0100
Subject: [PATCH 08/29] winegstreamer: Set a clock for the wg_parser pipeline.
Subject: [PATCH 06/32] winegstreamer: Set a clock for the wg_parser pipeline.

Some elements under uridecodebin (e.g. the RTSP demuxer) require a valid clock to function properly.
GstPipeline does this so let's do this too.
Expand All @@ -10,10 +10,10 @@ GstPipeline does this so let's do this too.
1 file changed, 2 insertions(+)

diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 854597c73eb..696c24d0059 100644
index 1d3314c582e..f4ec803f14f 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -2015,6 +2015,8 @@ static NTSTATUS wg_parser_connect(void *args)
@@ -1872,6 +1872,8 @@ static NTSTATUS wg_parser_connect(void *args)
gst_pad_set_event_function(parser->my_src, src_event_cb);
gst_pad_set_element_private(parser->my_src, parser);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
From 3aaef1bb825952738a1bc3b4b4dea77abd75c8b4 Mon Sep 17 00:00:00 2001
From 5126ef2fd83557b3a6a0886d577809607ebae4e9 Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Wed, 31 Jan 2024 17:42:55 +0100
Subject: [PATCH 09/29] winegstreamer: Set base time on wg_parser bin while
Subject: [PATCH 07/32] winegstreamer: Set base time on wg_parser bin while
connecting.

---
dlls/winegstreamer/wg_parser.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 696c24d0059..886f3420119 100644
index f4ec803f14f..f2570211ffd 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -1980,6 +1980,7 @@ static NTSTATUS wg_parser_connect(void *args)
@@ -1837,6 +1837,7 @@ static NTSTATUS wg_parser_connect(void *args)
const struct wg_parser_connect_params *params = args;
struct wg_parser *parser = get_parser(params->parser);
const WCHAR *uri = params->uri;
+ GstClock *clock;
unsigned int i;
int ret;

@@ -2015,7 +2016,8 @@ static NTSTATUS wg_parser_connect(void *args)
@@ -1872,7 +1873,8 @@ static NTSTATUS wg_parser_connect(void *args)
gst_pad_set_event_function(parser->my_src, src_event_cb);
gst_pad_set_element_private(parser->my_src, parser);

Expand All @@ -30,7 +30,7 @@ index 696c24d0059..886f3420119 100644

parser->start_offset = parser->next_offset = parser->stop_offset = 0;
parser->next_pull_offset = 0;
@@ -2024,6 +2026,7 @@ static NTSTATUS wg_parser_connect(void *args)
@@ -1881,6 +1883,7 @@ static NTSTATUS wg_parser_connect(void *args)
if (!parser->init_gst(parser))
goto out;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 4731071325d686ecf35913f071f74081803d082c Mon Sep 17 00:00:00 2001
From: Torge Matthies <[email protected]>
Date: Wed, 31 Jan 2024 17:42:55 +0100
Subject: [PATCH 08/32] winegstreamer: Put pipeline into PLAYING state before
waiting for the no-more-pads callback.

Some elements (e.g. uridecodebin with an RTSP URI) won't send no-more-pads in READY/PAUSED state.
---
dlls/winegstreamer/wg_parser.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index f2570211ffd..f77330a1410 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -1901,6 +1901,13 @@ static NTSTATUS wg_parser_connect(void *args)

pthread_mutex_lock(&parser->mutex);

+ if (parser->uri)
+ {
+ gst_element_set_state(parser->container, GST_STATE_PLAYING);
+ ret = gst_element_get_state(parser->container, NULL, NULL, -1);
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ goto out;
+ }
while (!parser_no_more_pads(parser) && !parser->error)
pthread_cond_wait(&parser->init_cond, &parser->mutex);
if (parser->error)
--
2.44.0

Loading

0 comments on commit ce59c51

Please sign in to comment.