| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | /* GStreamer
 | 
					
						
							|  |  |  |  * Copyright (C) <2015> Wim Taymans <wim.taymans@gmail.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. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |  * SECTION:element-pinossrc | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * <refsect2> | 
					
						
							|  |  |  |  * <title>Example launch line</title> | 
					
						
							|  |  |  |  * |[ | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |  * gst-launch -v pinossrc ! videoconvert ! ximagesink | 
					
						
							|  |  |  |  * ]| Shows pinos output in an X window. | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |  * </refsect2> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef HAVE_CONFIG_H
 | 
					
						
							|  |  |  | #include "config.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  | #include "gstpinossrc.h"
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <fcntl.h>
 | 
					
						
							|  |  |  | #include <sys/socket.h>
 | 
					
						
							|  |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <gio/gunixfdmessage.h>
 | 
					
						
							|  |  |  | #include <gst/allocators/gstfdmemory.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  | static GQuark fdpayload_data_quark; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | GST_DEBUG_CATEGORY_STATIC (pinos_src_debug); | 
					
						
							|  |  |  | #define GST_CAT_DEFAULT pinos_src_debug
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PROP_0, | 
					
						
							| 
									
										
										
										
											2015-07-28 17:05:03 +02:00
										 |  |  |   PROP_PATH, | 
					
						
							|  |  |  |   PROP_CLIENT_NAME, | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  | #define PINOSS_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | static GstStaticPadTemplate gst_pinos_src_template = | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | GST_STATIC_PAD_TEMPLATE ("src", | 
					
						
							|  |  |  |     GST_PAD_SRC, | 
					
						
							|  |  |  |     GST_PAD_ALWAYS, | 
					
						
							| 
									
										
										
										
											2015-05-15 13:34:32 +02:00
										 |  |  |     GST_STATIC_CAPS_ANY | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | #define gst_pinos_src_parent_class parent_class
 | 
					
						
							|  |  |  | G_DEFINE_TYPE (GstPinosSrc, gst_pinos_src, GST_TYPE_PUSH_SRC); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static GstStateChangeReturn | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_change_state (GstElement * element, GstStateChange transition); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | static gboolean gst_pinos_src_negotiate (GstBaseSrc * basesrc); | 
					
						
							|  |  |  | static GstCaps *gst_pinos_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter); | 
					
						
							|  |  |  | static GstCaps *gst_pinos_src_src_fixate (GstBaseSrc * bsrc, | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |     GstCaps * caps); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | static GstFlowReturn gst_pinos_src_create (GstPushSrc * psrc, | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |     GstBuffer ** buffer); | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | static gboolean gst_pinos_src_start (GstBaseSrc * basesrc); | 
					
						
							|  |  |  | static gboolean gst_pinos_src_stop (GstBaseSrc * basesrc); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | static void | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_set_property (GObject * object, guint prop_id, | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |     const GValue * value, GParamSpec * pspec) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = GST_PINOS_SRC (object); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (prop_id) { | 
					
						
							| 
									
										
										
										
											2015-07-09 17:58:54 +02:00
										 |  |  |     case PROP_PATH: | 
					
						
							|  |  |  |       g_free (pinossrc->path); | 
					
						
							|  |  |  |       pinossrc->path = g_value_dup_string (value); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-28 17:05:03 +02:00
										 |  |  |     case PROP_CLIENT_NAME: | 
					
						
							|  |  |  |       g_free (pinossrc->client_name); | 
					
						
							|  |  |  |       pinossrc->client_name = g_value_dup_string (value); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |     default: | 
					
						
							|  |  |  |       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_get_property (GObject * object, guint prop_id, | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |     GValue * value, GParamSpec * pspec) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = GST_PINOS_SRC (object); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (prop_id) { | 
					
						
							| 
									
										
										
										
											2015-07-09 17:58:54 +02:00
										 |  |  |     case PROP_PATH: | 
					
						
							|  |  |  |       g_value_set_string (value, pinossrc->path); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-28 17:05:03 +02:00
										 |  |  |     case PROP_CLIENT_NAME: | 
					
						
							|  |  |  |       g_value_set_string (value, pinossrc->client_name); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |     default: | 
					
						
							|  |  |  |       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_finalize (GObject * object) | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = GST_PINOS_SRC (object); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   g_object_unref (pinossrc->fd_allocator); | 
					
						
							| 
									
										
										
										
											2015-07-09 17:58:54 +02:00
										 |  |  |   g_free (pinossrc->path); | 
					
						
							| 
									
										
										
										
											2015-07-28 17:05:03 +02:00
										 |  |  |   g_free (pinossrc->client_name); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   G_OBJECT_CLASS (parent_class)->finalize (object); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | static void | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_class_init (GstPinosSrcClass * klass) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   GObjectClass *gobject_class; | 
					
						
							|  |  |  |   GstElementClass *gstelement_class; | 
					
						
							|  |  |  |   GstBaseSrcClass *gstbasesrc_class; | 
					
						
							|  |  |  |   GstPushSrcClass *gstpushsrc_class; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   gobject_class = (GObjectClass *) klass; | 
					
						
							|  |  |  |   gstelement_class = (GstElementClass *) klass; | 
					
						
							|  |  |  |   gstbasesrc_class = (GstBaseSrcClass *) klass; | 
					
						
							|  |  |  |   gstpushsrc_class = (GstPushSrcClass *) klass; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |   gobject_class->finalize = gst_pinos_src_finalize; | 
					
						
							|  |  |  |   gobject_class->set_property = gst_pinos_src_set_property; | 
					
						
							|  |  |  |   gobject_class->get_property = gst_pinos_src_get_property; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |   g_object_class_install_property (gobject_class, | 
					
						
							| 
									
										
										
										
											2015-07-09 17:58:54 +02:00
										 |  |  |                                    PROP_PATH, | 
					
						
							|  |  |  |                                    g_param_spec_string ("path", | 
					
						
							|  |  |  |                                                         "Path", | 
					
						
							|  |  |  |                                                         "The source path to connect to (NULL = default)", | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  |                                                         NULL, | 
					
						
							|  |  |  |                                                         G_PARAM_READWRITE | | 
					
						
							|  |  |  |                                                         G_PARAM_STATIC_STRINGS)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-28 17:05:03 +02:00
										 |  |  |   g_object_class_install_property (gobject_class, | 
					
						
							|  |  |  |                                    PROP_CLIENT_NAME, | 
					
						
							|  |  |  |                                    g_param_spec_string ("client-name", | 
					
						
							|  |  |  |                                                         "Client Name", | 
					
						
							|  |  |  |                                                         "The client name to use (NULL = default)", | 
					
						
							|  |  |  |                                                         NULL, | 
					
						
							|  |  |  |                                                         G_PARAM_READWRITE | | 
					
						
							|  |  |  |                                                         G_PARAM_STATIC_STRINGS)); | 
					
						
							| 
									
										
										
										
											2015-05-20 12:01:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |   gstelement_class->change_state = gst_pinos_src_change_state; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   gst_element_class_set_static_metadata (gstelement_class, | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |       "Pinos source", "Source/Video", | 
					
						
							|  |  |  |       "Uses pinos to create video", "Wim Taymans <wim.taymans@gmail.com>"); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   gst_element_class_add_pad_template (gstelement_class, | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |       gst_static_pad_template_get (&gst_pinos_src_template)); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |   gstbasesrc_class->negotiate = gst_pinos_src_negotiate; | 
					
						
							|  |  |  |   gstbasesrc_class->get_caps = gst_pinos_src_getcaps; | 
					
						
							|  |  |  |   gstbasesrc_class->fixate = gst_pinos_src_src_fixate; | 
					
						
							|  |  |  |   gstbasesrc_class->start = gst_pinos_src_start; | 
					
						
							|  |  |  |   gstbasesrc_class->stop = gst_pinos_src_stop; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |   gstpushsrc_class->create = gst_pinos_src_create; | 
					
						
							| 
									
										
										
										
											2015-05-11 18:23:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |   GST_DEBUG_CATEGORY_INIT (pinos_src_debug, "pinossrc", 0, | 
					
						
							|  |  |  |       "Pinos Source"); | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   fdpayload_data_quark = g_quark_from_static_string ("GstPinosSrcFDPayloadQuark"); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_init (GstPinosSrc * src) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   /* we operate in time */ | 
					
						
							|  |  |  |   gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); | 
					
						
							|  |  |  |   gst_base_src_set_live (GST_BASE_SRC (src), TRUE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   src->fd_allocator = gst_fd_allocator_new (); | 
					
						
							| 
									
										
										
										
											2015-07-28 17:05:03 +02:00
										 |  |  |   src->client_name = pinos_client_name (); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static GstCaps * | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   GstStructure *structure; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   caps = gst_caps_make_writable (caps); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   structure = gst_caps_get_structure (caps, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:14:36 +02:00
										 |  |  |   if (gst_structure_has_name (structure, "video/x-raw")) { | 
					
						
							|  |  |  |     gst_structure_fixate_field_nearest_int (structure, "width", 320); | 
					
						
							|  |  |  |     gst_structure_fixate_field_nearest_int (structure, "height", 240); | 
					
						
							|  |  |  |     gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (gst_structure_has_field (structure, "pixel-aspect-ratio")) | 
					
						
							|  |  |  |       gst_structure_fixate_field_nearest_fraction (structure, | 
					
						
							|  |  |  |           "pixel-aspect-ratio", 1, 1); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, | 
					
						
							|  |  |  |           NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (gst_structure_has_field (structure, "colorimetry")) | 
					
						
							|  |  |  |       gst_structure_fixate_field_string (structure, "colorimetry", "bt601"); | 
					
						
							|  |  |  |     if (gst_structure_has_field (structure, "chroma-site")) | 
					
						
							|  |  |  |       gst_structure_fixate_field_string (structure, "chroma-site", "mpeg2"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (gst_structure_has_field (structure, "interlace-mode")) | 
					
						
							|  |  |  |       gst_structure_fixate_field_string (structure, "interlace-mode", | 
					
						
							|  |  |  |           "progressive"); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       gst_structure_set (structure, "interlace-mode", G_TYPE_STRING, | 
					
						
							|  |  |  |           "progressive", NULL); | 
					
						
							|  |  |  |   } else if (gst_structure_has_name (structure, "audio/x-raw")) { | 
					
						
							|  |  |  |     gst_structure_fixate_field_string (structure, "format", "S16LE"); | 
					
						
							|  |  |  |     gst_structure_fixate_field_nearest_int (structure, "channels", 2); | 
					
						
							|  |  |  |     gst_structure_fixate_field_nearest_int (structure, "rate", 44100); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return caps; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  |   GstPinosSrc *src; | 
					
						
							|  |  |  |   PinosPacketFDPayload p; | 
					
						
							|  |  |  | } FDPayloadData; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | fdpayload_data_destroy (gpointer user_data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   FDPayloadData *data = user_data; | 
					
						
							|  |  |  |   GstPinosSrc *pinossrc = data->src; | 
					
						
							|  |  |  |   PinosBufferBuilder b; | 
					
						
							|  |  |  |   PinosPacketReleaseFDPayload r; | 
					
						
							|  |  |  |   PinosBuffer pbuf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   r.id = data->p.id; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GST_DEBUG_OBJECT (pinossrc, "destroy %d", r.id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pinos_buffer_builder_init (&b); | 
					
						
							|  |  |  |   pinos_buffer_builder_add_release_fd_payload (&b, &r); | 
					
						
							|  |  |  |   pinos_buffer_builder_end (&b, &pbuf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GST_OBJECT_LOCK (pinossrc); | 
					
						
							|  |  |  |   if (pinossrc->stream) | 
					
						
							|  |  |  |     pinos_stream_send_buffer (pinossrc->stream, &pbuf); | 
					
						
							|  |  |  |   GST_OBJECT_UNLOCK (pinossrc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pinos_buffer_clear (&pbuf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   gst_object_unref (pinossrc); | 
					
						
							|  |  |  |   g_slice_free (FDPayloadData, data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | static void | 
					
						
							|  |  |  | on_new_buffer (GObject    *gobject, | 
					
						
							|  |  |  |                gpointer    user_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = user_data; | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |   PinosBuffer *pbuf; | 
					
						
							| 
									
										
										
										
											2015-08-26 12:46:28 +02:00
										 |  |  |   PinosBufferIter it; | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |   GstBuffer *buf; | 
					
						
							|  |  |  |   GError *error = NULL; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 15:46:25 +02:00
										 |  |  |   GST_LOG_OBJECT (pinossrc, "got new buffer"); | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |   if (!pinos_stream_peek_buffer (pinossrc->stream, &pbuf)) { | 
					
						
							| 
									
										
										
										
											2015-08-25 16:36:01 +02:00
										 |  |  |     g_warning ("failed to capture buffer"); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   buf = gst_buffer_new (); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |   pinos_buffer_iter_init (&it, pbuf); | 
					
						
							|  |  |  |   while (pinos_buffer_iter_next (&it)) { | 
					
						
							|  |  |  |     switch (pinos_buffer_iter_get_type (&it)) { | 
					
						
							|  |  |  |       case PINOS_PACKET_TYPE_HEADER: | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         PinosPacketHeader hdr; | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |         if (!pinos_buffer_iter_parse_header  (&it, &hdr)) | 
					
						
							|  |  |  |           goto no_fds; | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |         if (GST_CLOCK_TIME_IS_VALID (hdr.pts)) { | 
					
						
							|  |  |  |           if (hdr.pts > GST_ELEMENT_CAST (pinossrc)->base_time) | 
					
						
							|  |  |  |             GST_BUFFER_PTS (buf) = hdr.pts - GST_ELEMENT_CAST (pinossrc)->base_time; | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |           if (GST_BUFFER_PTS (buf) + hdr.dts_offset > 0) | 
					
						
							|  |  |  |             GST_BUFFER_DTS (buf) = GST_BUFFER_PTS (buf) + hdr.dts_offset; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         GST_BUFFER_OFFSET (buf) = hdr.seq; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |       case PINOS_PACKET_TYPE_FD_PAYLOAD: | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         GstMemory *fdmem = NULL; | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |         FDPayloadData data; | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |         int fd; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         GST_DEBUG ("got fd payload"); | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |         if (!pinos_buffer_iter_parse_fd_payload  (&it, &data.p)) | 
					
						
							|  |  |  |           goto no_fds; | 
					
						
							|  |  |  |         fd = pinos_buffer_get_fd (pbuf, data.p.fd_index, &error); | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |         if (fd == -1) | 
					
						
							|  |  |  |           goto no_fds; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         fdmem = gst_fd_allocator_alloc (pinossrc->fd_allocator, fd, | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |                   data.p.offset + data.p.size, GST_FD_MEMORY_FLAG_NONE); | 
					
						
							|  |  |  |         gst_memory_resize (fdmem, data.p.offset, data.p.size); | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |         gst_buffer_append_memory (buf, fdmem); | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         data.src = gst_object_ref (pinossrc); | 
					
						
							|  |  |  |         gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (fdmem), | 
					
						
							|  |  |  |                                    fdpayload_data_quark, | 
					
						
							|  |  |  |                                    g_slice_dup (FDPayloadData, &data), | 
					
						
							|  |  |  |                                    fdpayload_data_destroy); | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (pinossrc->current) | 
					
						
							|  |  |  |     gst_buffer_unref (pinossrc->current); | 
					
						
							|  |  |  |   pinossrc->current = buf; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinos_main_loop_signal (pinossrc->loop, FALSE); | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* ERRORS */ | 
					
						
							|  |  |  | no_fds: | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  |     gst_buffer_unref (buf); | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |     GST_ELEMENT_ERROR (pinossrc, RESOURCE, FAILED, | 
					
						
							|  |  |  |         ("buffer error: %s", error->message), (NULL)); | 
					
						
							|  |  |  |     pinos_main_loop_signal (pinossrc->loop, FALSE); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | on_stream_notify (GObject    *gobject, | 
					
						
							|  |  |  |                   GParamSpec *pspec, | 
					
						
							|  |  |  |                   gpointer    user_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = user_data; | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   PinosStreamState state = pinos_stream_get_state (pinossrc->stream); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 15:32:12 +02:00
										 |  |  |   GST_DEBUG ("got stream state %d", state); | 
					
						
							| 
									
										
										
										
											2015-06-12 12:10:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   switch (state) { | 
					
						
							|  |  |  |     case PINOS_STREAM_STATE_UNCONNECTED: | 
					
						
							|  |  |  |     case PINOS_STREAM_STATE_CONNECTING: | 
					
						
							|  |  |  |     case PINOS_STREAM_STATE_STARTING: | 
					
						
							|  |  |  |     case PINOS_STREAM_STATE_STREAMING: | 
					
						
							|  |  |  |     case PINOS_STREAM_STATE_READY: | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case PINOS_STREAM_STATE_ERROR: | 
					
						
							|  |  |  |       GST_ELEMENT_ERROR (pinossrc, RESOURCE, FAILED, | 
					
						
							|  |  |  |           ("stream error: %s", | 
					
						
							|  |  |  |             pinos_stream_get_error (pinossrc->stream)->message), (NULL)); | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinos_main_loop_signal (pinossrc->loop, FALSE); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 15:31:05 +02:00
										 |  |  | static gboolean | 
					
						
							|  |  |  | gst_pinos_src_stream_start (GstPinosSrc *pinossrc, GstCaps * caps) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   gchar *str; | 
					
						
							|  |  |  |   GBytes *format; | 
					
						
							|  |  |  |   gboolean res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   str = gst_caps_to_string (caps); | 
					
						
							|  |  |  |   format = g_bytes_new_take (str, strlen (str) + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pinos_main_loop_lock (pinossrc->loop); | 
					
						
							|  |  |  |   res = pinos_stream_start (pinossrc->stream, format, PINOS_STREAM_MODE_BUFFER); | 
					
						
							| 
									
										
										
										
											2015-07-14 15:47:18 +02:00
										 |  |  |   while (TRUE) { | 
					
						
							|  |  |  |     PinosStreamState state = pinos_stream_get_state (pinossrc->stream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (state == PINOS_STREAM_STATE_STREAMING) | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (state == PINOS_STREAM_STATE_ERROR) | 
					
						
							|  |  |  |       goto start_error; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pinos_main_loop_wait (pinossrc->loop); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-07-10 15:31:05 +02:00
										 |  |  |   pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return res; | 
					
						
							| 
									
										
										
										
											2015-07-14 15:47:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | start_error: | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     GST_DEBUG_OBJECT (pinossrc, "error starting stream"); | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-07-10 15:31:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | static gboolean | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_negotiate (GstBaseSrc * basesrc) | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = GST_PINOS_SRC (basesrc); | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |   GstCaps *thiscaps; | 
					
						
							|  |  |  |   GstCaps *caps = NULL; | 
					
						
							|  |  |  |   GstCaps *peercaps = NULL; | 
					
						
							|  |  |  |   gboolean result = FALSE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* first see what is possible on our source pad */ | 
					
						
							|  |  |  |   thiscaps = gst_pad_query_caps (GST_BASE_SRC_PAD (basesrc), NULL); | 
					
						
							|  |  |  |   GST_DEBUG_OBJECT (basesrc, "caps of src: %" GST_PTR_FORMAT, thiscaps); | 
					
						
							|  |  |  |   /* nothing or anything is allowed, we're done */ | 
					
						
							| 
									
										
										
										
											2015-05-15 13:34:32 +02:00
										 |  |  |   if (thiscaps == NULL) | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     goto no_nego_needed; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (G_UNLIKELY (gst_caps_is_empty (thiscaps))) | 
					
						
							|  |  |  |     goto no_caps; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* get the peer caps */ | 
					
						
							|  |  |  |   peercaps = gst_pad_peer_query_caps (GST_BASE_SRC_PAD (basesrc), thiscaps); | 
					
						
							|  |  |  |   GST_DEBUG_OBJECT (basesrc, "caps of peer: %" GST_PTR_FORMAT, peercaps); | 
					
						
							|  |  |  |   if (peercaps) { | 
					
						
							|  |  |  |     /* The result is already a subset of our caps */ | 
					
						
							|  |  |  |     caps = peercaps; | 
					
						
							|  |  |  |     gst_caps_unref (thiscaps); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     /* no peer, work with our own caps then */ | 
					
						
							|  |  |  |     caps = thiscaps; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |   if (caps && !gst_caps_is_empty (caps)) { | 
					
						
							|  |  |  |     GBytes *accepted, *possible; | 
					
						
							|  |  |  |     gchar *str; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     GST_DEBUG_OBJECT (basesrc, "have caps: %" GST_PTR_FORMAT, caps); | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     /* open a connection with these caps */ | 
					
						
							|  |  |  |     str = gst_caps_to_string (caps); | 
					
						
							|  |  |  |     accepted = g_bytes_new_take (str, strlen (str) + 1); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  |     /* first disconnect */ | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_lock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-08-25 16:36:01 +02:00
										 |  |  |     if (pinos_stream_get_state (pinossrc->stream) != PINOS_STREAM_STATE_UNCONNECTED) { | 
					
						
							|  |  |  |       GST_DEBUG_OBJECT (basesrc, "disconnect capture"); | 
					
						
							|  |  |  |       pinos_stream_disconnect (pinossrc->stream); | 
					
						
							|  |  |  |       while (TRUE) { | 
					
						
							|  |  |  |         PinosStreamState state = pinos_stream_get_state (pinossrc->stream); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (state == PINOS_STREAM_STATE_UNCONNECTED) | 
					
						
							|  |  |  |           break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  |         if (state == PINOS_STREAM_STATE_ERROR) { | 
					
						
							|  |  |  |           g_bytes_unref (accepted); | 
					
						
							| 
									
										
										
										
											2015-08-25 16:36:01 +02:00
										 |  |  |           goto connect_error; | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-08-25 16:36:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         pinos_main_loop_wait (pinossrc->loop); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 15:32:12 +02:00
										 |  |  |     GST_DEBUG_OBJECT (basesrc, "connect capture with path %s", pinossrc->path); | 
					
						
							| 
									
										
										
										
											2015-07-09 17:58:54 +02:00
										 |  |  |     pinos_stream_connect_capture (pinossrc->stream, pinossrc->path, 0, accepted); | 
					
						
							| 
									
										
										
										
											2015-06-12 12:10:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     while (TRUE) { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |       PinosStreamState state = pinos_stream_get_state (pinossrc->stream); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |       if (state == PINOS_STREAM_STATE_READY) | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |       if (state == PINOS_STREAM_STATE_ERROR) | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |         goto connect_error; | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |       pinos_main_loop_wait (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     g_object_get (pinossrc->stream, "possible-formats", &possible, NULL); | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     if (possible) { | 
					
						
							|  |  |  |       GstCaps *newcaps; | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |       newcaps = gst_caps_from_string (g_bytes_get_data (possible, NULL)); | 
					
						
							|  |  |  |       if (newcaps) | 
					
						
							|  |  |  |         caps = newcaps; | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       g_bytes_unref (possible); | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     /* now fixate */ | 
					
						
							|  |  |  |     GST_DEBUG_OBJECT (basesrc, "server fixated caps: %" GST_PTR_FORMAT, caps); | 
					
						
							|  |  |  |     if (gst_caps_is_any (caps)) { | 
					
						
							|  |  |  |       GST_DEBUG_OBJECT (basesrc, "any caps, we stop"); | 
					
						
							|  |  |  |       /* hmm, still anything, so element can do anything and
 | 
					
						
							|  |  |  |        * nego is not needed */ | 
					
						
							|  |  |  |       result = TRUE; | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |       caps = gst_pinos_src_src_fixate (basesrc, caps); | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |       GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps); | 
					
						
							|  |  |  |       if (gst_caps_is_fixed (caps)) { | 
					
						
							|  |  |  |         /* yay, fixed caps, use those then, it's possible that the subclass does
 | 
					
						
							|  |  |  |          * not accept this caps after all and we have to fail. */ | 
					
						
							|  |  |  |         result = gst_base_src_set_caps (basesrc, caps); | 
					
						
							| 
									
										
										
										
											2015-07-10 15:31:05 +02:00
										 |  |  |         if (result) { | 
					
						
							|  |  |  |           result = gst_pinos_src_stream_start (pinossrc, caps); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     gst_caps_unref (caps); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     if (caps) | 
					
						
							|  |  |  |       gst_caps_unref (caps); | 
					
						
							|  |  |  |     GST_DEBUG_OBJECT (basesrc, "no common caps"); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   pinossrc->negotiated = result; | 
					
						
							| 
									
										
										
										
											2015-07-14 15:47:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |   return result; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  | no_nego_needed: | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     GST_DEBUG_OBJECT (basesrc, "no negotiation needed"); | 
					
						
							|  |  |  |     if (thiscaps) | 
					
						
							|  |  |  |       gst_caps_unref (thiscaps); | 
					
						
							|  |  |  |     return TRUE; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  | no_caps: | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     GST_ELEMENT_ERROR (basesrc, STREAM, FORMAT, | 
					
						
							|  |  |  |         ("No supported formats found"), | 
					
						
							|  |  |  |         ("This element did not produce valid caps")); | 
					
						
							|  |  |  |     if (thiscaps) | 
					
						
							|  |  |  |       gst_caps_unref (thiscaps); | 
					
						
							|  |  |  |     return TRUE; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | connect_error: | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  | static GstCaps * | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   return GST_BASE_SRC_CLASS (parent_class)->get_caps (bsrc, filter); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | static GstFlowReturn | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_create (GstPushSrc * psrc, GstBuffer ** buffer) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   pinossrc = GST_PINOS_SRC (psrc); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   if (!pinossrc->negotiated) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |     goto not_negotiated; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinos_main_loop_lock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-05-15 15:58:13 +02:00
										 |  |  |   while (TRUE) { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     PinosStreamState state; | 
					
						
							| 
									
										
										
										
											2015-06-12 12:10:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_wait (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-05-15 15:58:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     state = pinos_stream_get_state (pinossrc->stream); | 
					
						
							|  |  |  |     if (state == PINOS_STREAM_STATE_ERROR) | 
					
						
							| 
									
										
										
										
											2015-06-12 12:10:27 +02:00
										 |  |  |       goto streaming_error; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     if (state != PINOS_STREAM_STATE_STREAMING) | 
					
						
							| 
									
										
										
										
											2015-05-15 15:58:13 +02:00
										 |  |  |       goto streaming_stopped; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-25 16:36:01 +02:00
										 |  |  |     if (pinossrc->current != NULL) | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2015-05-15 15:58:13 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-24 16:41:04 +02:00
										 |  |  |   *buffer = pinossrc->current; | 
					
						
							|  |  |  |   pinossrc->current = NULL; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return GST_FLOW_OK; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | not_negotiated: | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     return GST_FLOW_NOT_NEGOTIATED; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-06-12 12:10:27 +02:00
										 |  |  | streaming_error: | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-06-12 12:10:27 +02:00
										 |  |  |     return GST_FLOW_ERROR; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-05-15 15:58:13 +02:00
										 |  |  | streaming_stopped: | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-05-15 15:58:13 +02:00
										 |  |  |     return GST_FLOW_FLUSHING; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static gboolean | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_start (GstBaseSrc * basesrc) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static gboolean | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_stop (GstBaseSrc * basesrc) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-08-24 16:55:29 +02:00
										 |  |  |   GstPinosSrc *pinossrc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pinossrc = GST_PINOS_SRC (basesrc); | 
					
						
							|  |  |  |   if (pinossrc->current) | 
					
						
							|  |  |  |     gst_buffer_unref (pinossrc->current); | 
					
						
							|  |  |  |   pinossrc->current = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  | on_context_notify (GObject    *gobject, | 
					
						
							|  |  |  |                    GParamSpec *pspec, | 
					
						
							|  |  |  |                    gpointer    user_data) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   GstPinosSrc *pinossrc = user_data; | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   PinosContextState state = pinos_context_get_state (pinossrc->ctx); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 15:32:12 +02:00
										 |  |  |   GST_DEBUG ("got context state %d", state); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   switch (state) { | 
					
						
							|  |  |  |     case PINOS_CONTEXT_STATE_UNCONNECTED: | 
					
						
							|  |  |  |     case PINOS_CONTEXT_STATE_CONNECTING: | 
					
						
							|  |  |  |     case PINOS_CONTEXT_STATE_REGISTERING: | 
					
						
							|  |  |  |     case PINOS_CONTEXT_STATE_READY: | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case PINOS_CONTEXT_STATE_ERROR: | 
					
						
							|  |  |  |       GST_ELEMENT_ERROR (pinossrc, RESOURCE, FAILED, | 
					
						
							|  |  |  |           ("context error: %s", | 
					
						
							|  |  |  |             pinos_context_get_error (pinossrc->ctx)->message), (NULL)); | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinos_main_loop_signal (pinossrc->loop, FALSE); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static gboolean | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  | gst_pinos_src_open (GstPinosSrc * pinossrc) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   GError *error = NULL; | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinossrc->context = g_main_context_new (); | 
					
						
							| 
									
										
										
										
											2015-07-10 15:32:12 +02:00
										 |  |  |   GST_DEBUG ("context %p", pinossrc->context); | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   pinossrc->loop = pinos_main_loop_new (pinossrc->context, "pinos-main-loop"); | 
					
						
							|  |  |  |   if (!pinos_main_loop_start (pinossrc->loop, &error)) | 
					
						
							|  |  |  |     goto mainloop_failed; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   pinos_main_loop_lock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-08-25 13:06:05 +02:00
										 |  |  |   pinossrc->ctx = pinos_context_new (pinossrc->context, g_get_application_name (), NULL); | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   g_signal_connect (pinossrc->ctx, "notify::state", (GCallback) on_context_notify, pinossrc); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 17:40:37 +02:00
										 |  |  |   pinos_context_connect (pinossrc->ctx, PINOS_CONTEXT_FLAGS_NONE); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |   while (TRUE) { | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     PinosContextState state = pinos_context_get_state (pinossrc->ctx); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     if (state == PINOS_CONTEXT_STATE_READY) | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |       break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |     if (state == PINOS_CONTEXT_STATE_ERROR) | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |       goto connect_error; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_wait (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-07 16:46:23 +02:00
										 |  |  |   pinossrc->stream = pinos_stream_new (pinossrc->ctx, "test", NULL); | 
					
						
							|  |  |  |   g_signal_connect (pinossrc->stream, "notify::state", (GCallback) on_stream_notify, pinossrc); | 
					
						
							|  |  |  |   g_signal_connect (pinossrc->stream, "new-buffer", (GCallback) on_new_buffer, pinossrc); | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |   return TRUE; | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* ERRORS */ | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  | mainloop_failed: | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     GST_ELEMENT_ERROR (pinossrc, RESOURCE, FAILED, | 
					
						
							|  |  |  |         ("mainloop error: %s", error->message), (NULL)); | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  | connect_error: | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |     pinos_main_loop_unlock (pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-04-29 17:51:51 +02:00
										 |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  | static void | 
					
						
							|  |  |  | gst_pinos_src_close (GstPinosSrc * pinossrc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   pinos_main_loop_stop (pinossrc->loop); | 
					
						
							|  |  |  |   g_clear_object (&pinossrc->loop); | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  |   g_clear_object (&pinossrc->ctx); | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |   g_main_context_unref (pinossrc->context); | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |   GST_OBJECT_LOCK (pinossrc); | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  |   g_clear_object (&pinossrc->stream); | 
					
						
							| 
									
										
										
										
											2015-08-31 16:47:32 +02:00
										 |  |  |   GST_OBJECT_UNLOCK (pinossrc); | 
					
						
							| 
									
										
										
										
											2015-08-26 15:44:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (pinossrc->current) | 
					
						
							|  |  |  |     gst_buffer_unref (pinossrc->current); | 
					
						
							|  |  |  |   pinossrc->current = NULL; | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | static GstStateChangeReturn | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  | gst_pinos_src_change_state (GstElement * element, GstStateChange transition) | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   GstStateChangeReturn ret; | 
					
						
							| 
									
										
										
										
											2015-06-30 18:06:36 +02:00
										 |  |  |   GstPinosSrc *this = GST_PINOS_SRC_CAST (element); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (transition) { | 
					
						
							|  |  |  |     case GST_STATE_CHANGE_NULL_TO_READY: | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |       if (!gst_pinos_src_open (this)) | 
					
						
							|  |  |  |         goto open_failed; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |       break; | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |     case GST_STATE_CHANGE_READY_TO_PAUSED: | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |     case GST_STATE_CHANGE_PAUSED_TO_PLAYING: | 
					
						
							|  |  |  |       /* uncork and start recording */ | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case GST_STATE_CHANGE_PLAYING_TO_PAUSED: | 
					
						
							|  |  |  |       /* stop recording ASAP by corking */ | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (transition) { | 
					
						
							|  |  |  |     case GST_STATE_CHANGE_PLAYING_TO_PAUSED: | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case GST_STATE_CHANGE_PAUSED_TO_READY: | 
					
						
							| 
									
										
										
										
											2015-05-14 17:46:12 +02:00
										 |  |  |       this->negotiated = FALSE; | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |       break; | 
					
						
							|  |  |  |     case GST_STATE_CHANGE_READY_TO_NULL: | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  |       gst_pinos_src_close (this); | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return ret; | 
					
						
							| 
									
										
										
										
											2015-07-08 12:11:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* ERRORS */ | 
					
						
							|  |  |  | open_failed: | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     return GST_STATE_CHANGE_FAILURE; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 17:36:44 +02:00
										 |  |  | } |