Add code to use waylandsrc as video source 67/49867/1 accepted/tizen/mobile/20151021.085705 accepted/tizen/tv/20151021.085710 accepted/tizen/wearable/20151021.085726 submit/tizen/20151021.080720
authorHyunjun Ko <zzoon.ko@samsung.com>
Wed, 21 Oct 2015 05:01:56 +0000 (14:01 +0900)
committerHyunjun Ko <zzoon.ko@samsung.com>
Wed, 21 Oct 2015 05:01:56 +0000 (14:01 +0900)
Change-Id: I9ea5c11281e7beaf2ab854fcb3fe1699c5e5a8cd

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

index e083fa6..3c1b34d 100644 (file)
@@ -614,6 +614,89 @@ create_error:
 }
 
 static gboolean
+_rtsp_media_factory_wfd_create_waylandsrc_bin (GstRTSPMediaFactoryWFD * factory,
+    GstBin * srcbin)
+{
+  GstElement *videosrc = NULL;
+  GstElement *vcaps = NULL;
+  gchar *vcodec = NULL;
+  GstElement *venc = NULL;
+  GstElement *vparse = NULL;
+  GstElement *vqueue = NULL;
+  GstRTSPMediaFactoryWFDPrivate *priv = NULL;
+
+  priv = factory->priv;
+
+  GST_INFO_OBJECT (factory, "picked waylandsrc as video source");
+
+  videosrc = gst_element_factory_make ("waylandsrc", "videosrc");
+  if (NULL == videosrc) {
+    GST_ERROR_OBJECT (factory, "failed to create ximagesrc element");
+    goto create_error;
+  }
+
+  /* create video caps element */
+  vcaps = gst_element_factory_make ("capsfilter", "videocaps");
+  if (NULL == vcaps) {
+    GST_ERROR_OBJECT (factory, "failed to create video capsilfter element");
+    goto create_error;
+  }
+
+  g_object_set (G_OBJECT (vcaps), "caps",
+      gst_caps_new_simple ("video/x-raw",
+          "format", G_TYPE_STRING, "SN12",
+          "width", G_TYPE_INT, priv->video_width,
+          "height", G_TYPE_INT, priv->video_height,
+          "framerate", GST_TYPE_FRACTION, priv->video_framerate, 1, NULL),
+      NULL);
+
+  if (priv->video_codec == GST_WFD_VIDEO_H264)
+    vcodec = g_strdup (priv->video_encoder);
+  else {
+    GST_ERROR_OBJECT (factory, "Yet to support other than H264 format");
+    goto create_error;
+  }
+
+  venc = gst_element_factory_make (vcodec, "videoenc");
+  if (vcodec) g_free (vcodec);
+
+  if (!venc) {
+    GST_ERROR_OBJECT (factory, "failed to create video encoder element");
+    goto create_error;
+  }
+
+  g_object_set (venc, "aud", 0, NULL);
+  g_object_set (venc, "byte-stream", 1, NULL);
+  g_object_set (venc, "bitrate", 512, NULL);
+
+  vparse = gst_element_factory_make ("h264parse", "videoparse");
+  if (NULL == vparse) {
+    GST_ERROR_OBJECT (factory, "failed to create h264 parse element");
+    goto create_error;
+  }
+  g_object_set (vparse, "config-interval", 1, NULL);
+
+  vqueue = gst_element_factory_make ("queue", "video-queue");
+  if (!vqueue) {
+    GST_ERROR_OBJECT (factory, "failed to create video queue element");
+    goto create_error;
+  }
+
+  gst_bin_add_many (srcbin, videosrc, vcaps, venc, vparse, vqueue, NULL);
+  if (!gst_element_link_many (videosrc, vcaps, venc, vparse, vqueue, NULL)) {
+    GST_ERROR_OBJECT (factory, "Failed to link video src elements...");
+    goto create_error;
+  }
+
+  priv->video_queue = vqueue;
+
+  return TRUE;
+
+create_error:
+  return FALSE;
+}
+
+static gboolean
 _rtsp_media_factory_wfd_create_camera_capture_bin (GstRTSPMediaFactoryWFD *
     factory, GstBin * srcbin)
 {
@@ -935,6 +1018,12 @@ _rtsp_media_factory_wfd_create_srcbin (GstRTSPMediaFactoryWFD * factory)
         goto create_error;
       }
       break;
+    case GST_WFD_VSRC_WAYLANDSRC:
+      if (!_rtsp_media_factory_wfd_create_waylandsrc_bin (factory, srcbin)) {
+        GST_ERROR_OBJECT (factory, "failed to create videotestsrc bin...");
+        goto create_error;
+      }
+      break;
     default:
       GST_ERROR_OBJECT (factory, "unknow mode selected...");
       goto create_error;
index 5320d63..9b8fc75 100644 (file)
@@ -39,7 +39,8 @@ G_BEGIN_DECLS
   GST_WFD_VSRC_XIMAGESRC,
   GST_WFD_VSRC_XVIMAGESRC,
   GST_WFD_VSRC_CAMERASRC,
-  GST_WFD_VSRC_VIDEOTESTSRC
+  GST_WFD_VSRC_VIDEOTESTSRC,
+  GST_WFD_VSRC_WAYLANDSRC
 };
 
 typedef struct _GstRTSPMediaFactoryWFD GstRTSPMediaFactoryWFD;