Commit 7b5e232a authored by Ognyan Tonchev's avatar Ognyan Tonchev Committed by Sebastian Dröge

onvif: encapsulate onvif part into a bin

...and thus do not let onvif affect pipelines latency

https://bugzilla.gnome.org/show_bug.cgi?id=797174
parent 982efec4
......@@ -31,6 +31,7 @@ c_sources = \
rtsp-params.c \
rtsp-sdp.c \
rtsp-thread-pool.c \
rtsp-latency-bin.c \
rtsp-media.c \
rtsp-media-factory.c \
rtsp-media-factory-uri.c \
......
......@@ -3,6 +3,7 @@ rtsp_server_sources = [
'rtsp-auth.c',
'rtsp-client.c',
'rtsp-context.c',
'rtsp-latency-bin.c',
'rtsp-media.c',
'rtsp-media-factory.c',
'rtsp-media-factory-uri.c',
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2018 Ognyan Tonchev <ognyan@axis.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_RTSP_LATENCY_BIN_H__
#define __GST_RTSP_LATENCY_BIN_H__
#include <gst/gst.h>
#include "rtsp-server-prelude.h"
G_BEGIN_DECLS
typedef struct _GstRTSPLatencyBin GstRTSPLatencyBin;
typedef struct _GstRTSPLatencyBinClass GstRTSPLatencyBinClass;
typedef struct _GstRTSPLatencyBinPrivate GstRTSPLatencyBinPrivate;
#define GST_RTSP_LATENCY_BIN_TYPE (gst_rtsp_latency_bin_get_type ())
#define IS_GST_RTSP_LATENCY_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_RTSP_LATENCY_BIN_TYPE))
#define IS_GST_RTSP_LATENCY_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_RTSP_LATENCY_BIN_TYPE))
#define GST_RTSP_LATENCY_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_RTSP_LATENCY_BIN_TYPE, GstRTSPLatencyBinClass))
#define GST_RTSP_LATENCY_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_RTSP_LATENCY_BIN_TYPE, GstRTSPLatencyBin))
#define GST_RTSP_LATENCY_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_RTSP_LATENCY_BIN_TYPE, GstRTSPLatencyBinClass))
#define GST_RTSP_LATENCY_BIN_CAST(obj) ((GstRTSPLatencyBin*)(obj))
#define GST_RTSP_LATENCY_BIN_CLASS_CAST(klass) ((GstRTSPLatencyBinClass*)(klass))
struct _GstRTSPLatencyBin {
GstBin parent;
GstRTSPLatencyBinPrivate *priv;
};
struct _GstRTSPLatencyBinClass {
GstBinClass parent_class;
};
GST_RTSP_SERVER_API
GType gst_rtsp_latency_bin_get_type (void);
GST_RTSP_SERVER_API
GstElement * gst_rtsp_latency_bin_new (GstElement * element);
G_END_DECLS
#endif /* __GST_RTSP_LATENCY_BIN_H__ */
......@@ -42,6 +42,7 @@
#endif
#include "rtsp-onvif-media.h"
#include "rtsp-latency-bin.h"
struct GstRTSPOnvifMediaPrivate
{
......@@ -251,6 +252,7 @@ gboolean
gst_rtsp_onvif_media_collect_backchannel (GstRTSPOnvifMedia * media)
{
GstElement *element, *backchannel_bin = NULL;
GstElement *latency_bin;
GstPad *pad = NULL;
gboolean ret = FALSE;
......@@ -265,11 +267,28 @@ gst_rtsp_onvif_media_collect_backchannel (GstRTSPOnvifMedia * media)
if (!backchannel_bin)
goto out;
pad = gst_element_get_static_pad (backchannel_bin, "sink");
/* We don't want the backchannel element, which is a receiver, to affect
* latency on the complete pipeline. That's why we remove it from the
* pipeline and add it to a @GstRTSPLatencyBin which will prevent it from
* messing up pipelines latency. The extra reference is needed so that it
* is not freed in case the pipeline holds the the only ref to it.
*
* TODO: a more generic solution should be implemented in
* gst_rtsp_media_collect_streams() where all receivers are encapsulated
* in a @GstRTSPLatencyBin in cases when there are senders too. */
gst_object_ref (backchannel_bin);
gst_bin_remove (GST_BIN (element), backchannel_bin);
latency_bin = gst_rtsp_latency_bin_new (backchannel_bin);
g_assert (latency_bin);
gst_bin_add (GST_BIN (element), latency_bin);
pad = gst_element_get_static_pad (latency_bin, "sink");
if (!pad)
goto out;
gst_rtsp_media_create_stream (GST_RTSP_MEDIA (media), backchannel_bin, pad);
gst_rtsp_media_create_stream (GST_RTSP_MEDIA (media), latency_bin, pad);
ret = TRUE;
out:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment