onvif: Make requires_backchannel() public
authorOgnyan Tonchev <ognyan@axis.com>
Sat, 21 Oct 2017 12:06:30 +0000 (14:06 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 16 Feb 2018 09:04:53 +0000 (11:04 +0200)
...in order to let subclasses building the onvif part of the pipeline
check whether backchannel shall be included or not.

gst/rtsp-server/rtsp-onvif-media-factory.c
gst/rtsp-server/rtsp-onvif-media-factory.h

index a200f1d..f242608 100644 (file)
@@ -55,13 +55,27 @@ struct GstRTSPOnvifMediaFactoryPrivate
 G_DEFINE_TYPE_WITH_PRIVATE (GstRTSPOnvifMediaFactory,
     gst_rtsp_onvif_media_factory, GST_TYPE_RTSP_MEDIA_FACTORY);
 
-static gboolean
-requires_backchannel (GstRTSPMessage * msg)
+/**
+ * gst_rtsp_onvif_media_factory_requires_backchannel:
+ * @factory: a #GstRTSPMediaFactory
+ *
+ * Checks whether the client request requires backchannel.
+ *
+ * Returns: %TRUE if the client request requires backchannel.
+ *
+ * Since: 1.14
+ */
+gboolean
+gst_rtsp_onvif_media_factory_requires_backchannel (GstRTSPMediaFactory *
+    factory, GstRTSPContext * ctx)
 {
+  GstRTSPMessage *msg = ctx->request;
   GstRTSPResult res;
   gint i;
   gchar *reqs = NULL;
 
+  g_return_val_if_fail (GST_IS_RTSP_ONVIF_MEDIA_FACTORY (factory), FALSE);
+
   i = 0;
   do {
     res = gst_rtsp_message_get_header (msg, GST_RTSP_HDR_REQUIRE, &reqs, i++);
@@ -81,10 +95,9 @@ gst_rtsp_onvif_media_factory_gen_key (GstRTSPMediaFactory * factory,
     const GstRTSPUrl * url)
 {
   GstRTSPContext *ctx = gst_rtsp_context_get_current ();
-  GstRTSPMessage *msg = ctx->request;
 
   /* Only medias where no backchannel was requested can be shared */
-  if (requires_backchannel (msg))
+  if (gst_rtsp_onvif_media_factory_requires_backchannel (factory, ctx))
     return NULL;
 
   return
@@ -139,7 +152,8 @@ gst_rtsp_onvif_media_factory_construct (GstRTSPMediaFactory * factory,
   got_backchannel_stream =
       gst_rtsp_onvif_media_collect_backchannel (GST_RTSP_ONVIF_MEDIA (media));
   /* FIXME: This should not happen! We checked for that before */
-  if (requires_backchannel (ctx->request) && !got_backchannel_stream) {
+  if (gst_rtsp_onvif_media_factory_requires_backchannel (factory, ctx) &&
+      !got_backchannel_stream) {
     g_object_unref (media);
     return NULL;
   }
@@ -206,7 +220,7 @@ gst_rtsp_onvif_media_factory_create_element (GstRTSPMediaFactory * factory,
   }
 
   /* add backchannel pipeline part, if requested */
-  if (requires_backchannel (ctx->request)) {
+  if (gst_rtsp_onvif_media_factory_requires_backchannel (factory, ctx)) {
     GstRTSPOnvifMediaFactory *onvif_factory =
         GST_RTSP_ONVIF_MEDIA_FACTORY (factory);
     GstElement *backchannel_bin;
index 5468748..09e9d4b 100644 (file)
@@ -74,4 +74,6 @@ void gst_rtsp_onvif_media_factory_set_backchannel_bandwidth (GstRTSPOnvifMediaFa
 GST_EXPORT
 guint gst_rtsp_onvif_media_factory_get_backchannel_bandwidth (GstRTSPOnvifMediaFactory * factory);
 
+gboolean gst_rtsp_onvif_media_factory_requires_backchannel (GstRTSPMediaFactory * factory, GstRTSPContext * ctx);
+
 #endif /* __GST_RTSP_ONVIF_MEDIA_FACTORY_H__ */