~ubuntu-branches/ubuntu/raring/gst-plugins-good0.10/raring-proposed

« back to all changes in this revision

Viewing changes to debian/patches/05_move_shm_to_good.patch

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-02-09 16:44:53 UTC
  • mfrom: (40.2.38 experimental)
  • Revision ID: package-import@ubuntu.com-20120209164453-6hjokwrvdn42zopb
Tags: 0.10.30.3-1ubuntu1
* Merge from Debian experimental, remaining changes:
  - 04_move_farsight_plugins_to_good.patch
    Import autoconvert, dtmf, liveadder, rptmux from -plugins-bad
  - 05_move_shm_to_good.patch
    Import shm from -plugins-bad.
  - 07_move-camerabin.patch
    Import camerabin, camerabin2, jpegformat and basecamerabinsrc
    from -plugins-bad.
  - control*:
    * Drop dependency from gstreamer0.10-plugins-good on
      gstreamer0.10-gconf. It pulls gconf and gtk3 onto the Kubuntu cd.
    * Use Breaks instead of Conflicts.
    * Add a 'Pre-Depends: ${misc:Pre-Depends}' to the plugin package,
      since we're shipping shared libraries in the package that Debian
      isn't.
* Update the patches by pulling new version of the code from
  -plugins-bad 0.10.22.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
Index: gst-plugins-good0.10/sys/Makefile.am
8
8
===================================================================
9
 
--- gst-plugins-good0.10.orig/sys/Makefile.am   2011-03-18 12:15:30.154893503 -0400
10
 
+++ gst-plugins-good0.10/sys/Makefile.am        2011-03-18 12:22:38.195521299 -0400
 
9
--- gst-plugins-good0.10.orig/sys/Makefile.am   2012-02-09 13:53:18.304916162 +0200
 
10
+++ gst-plugins-good0.10/sys/Makefile.am        2012-02-09 13:57:02.791633689 +0200
11
11
@@ -77,8 +77,14 @@
12
12
 XIMAGE_DIR=
13
13
 endif
28
28
Index: gst-plugins-good0.10/sys/shm/Makefile.am
29
29
===================================================================
30
30
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
31
 
+++ gst-plugins-good0.10/sys/shm/Makefile.am    2011-03-18 12:22:38.195521299 -0400
 
31
+++ gst-plugins-good0.10/sys/shm/Makefile.am    2012-02-09 13:57:29.572435080 +0200
32
32
@@ -0,0 +1,13 @@
33
33
+glib_enum_prefix = gst_shm
34
34
+
46
46
Index: gst-plugins-good0.10/sys/shm/gstshm.c
47
47
===================================================================
48
48
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
49
 
+++ gst-plugins-good0.10/sys/shm/gstshm.c       2011-03-18 12:22:38.195521299 -0400
 
49
+++ gst-plugins-good0.10/sys/shm/gstshm.c       2012-02-09 13:57:29.572435080 +0200
50
50
@@ -0,0 +1,42 @@
51
51
+/* GStreamer
52
52
+ * Copyright (C) <2009> Collabora Ltd
93
93
Index: gst-plugins-good0.10/sys/shm/gstshmsink.c
94
94
===================================================================
95
95
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
96
 
+++ gst-plugins-good0.10/sys/shm/gstshmsink.c   2011-03-18 12:22:38.195521299 -0400
97
 
@@ -0,0 +1,601 @@
 
96
+++ gst-plugins-good0.10/sys/shm/gstshmsink.c   2012-02-09 13:57:29.572435080 +0200
 
97
@@ -0,0 +1,659 @@
98
98
+/* GStreamer
99
99
+ * Copyright (C) <2009> Collabora Ltd
100
100
+ *  @author: Olivier Crete <olivier.crete@collabora.co.uk
142
142
+  PROP_SOCKET_PATH,
143
143
+  PROP_PERMS,
144
144
+  PROP_SHM_SIZE,
145
 
+  PROP_WAIT_FOR_CONNECTION
 
145
+  PROP_WAIT_FOR_CONNECTION,
 
146
+  PROP_BUFFER_TIME
146
147
+};
147
148
+
148
149
+struct GstShmClient
153
154
+
154
155
+#define DEFAULT_SIZE ( 256 * 1024 )
155
156
+#define DEFAULT_WAIT_FOR_CONNECTION (TRUE)
156
 
+#define DEFAULT_PERMS (S_IRWXU | S_IRWXG)
 
157
+/* Default is user read/write, group read */
 
158
+#define DEFAULT_PERMS ( S_IRUSR | S_IWUSR | S_IRGRP )
157
159
+
158
160
+
159
161
+GST_DEBUG_CATEGORY_STATIC (shmsink_debug);
191
193
+{
192
194
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
193
195
+
194
 
+  gst_element_class_add_pad_template (element_class,
195
 
+      gst_static_pad_template_get (&sinktemplate));
 
196
+  gst_element_class_add_static_pad_template (element_class, &sinktemplate);
196
197
+
197
198
+  gst_element_class_set_details_simple (element_class,
198
199
+      "Shared Memory Sink",
214
215
+gst_shm_sink_class_init (GstShmSinkClass * klass)
215
216
+{
216
217
+  GObjectClass *gobject_class;
217
 
+  GstElementClass *gstelement_class;
218
218
+  GstBaseSinkClass *gstbasesink_class;
219
219
+
220
220
+  gobject_class = (GObjectClass *) klass;
221
 
+  gstelement_class = (GstElementClass *) klass;
222
221
+  gstbasesink_class = (GstBaseSinkClass *) klass;
223
222
+
224
223
+  gobject_class->finalize = gst_shm_sink_finalize;
260
259
+          DEFAULT_WAIT_FOR_CONNECTION,
261
260
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
262
261
+
 
262
+  g_object_class_install_property (gobject_class, PROP_BUFFER_TIME,
 
263
+      g_param_spec_uint64 ("buffer-time",
 
264
+          "Buffer Time of the shm buffer",
 
265
+          "Maximum Size of the shm buffer in nanoseconds (-1 to disable)",
 
266
+          0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
 
267
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
268
+
263
269
+  signals[SIGNAL_CLIENT_CONNECTED] = g_signal_new ("client-connected",
264
270
+      GST_TYPE_SHM_SINK, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
265
271
+      g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
327
333
+      GST_OBJECT_UNLOCK (object);
328
334
+      g_cond_broadcast (self->cond);
329
335
+      break;
 
336
+    case PROP_BUFFER_TIME:
 
337
+      GST_OBJECT_LOCK (object);
 
338
+      self->buffer_time = g_value_get_uint64 (value);
 
339
+      GST_OBJECT_UNLOCK (object);
 
340
+      g_cond_broadcast (self->cond);
 
341
+      break;
330
342
+    default:
331
343
+      break;
332
344
+  }
361
373
+    case PROP_WAIT_FOR_CONNECTION:
362
374
+      g_value_set_boolean (value, self->wait_for_connection);
363
375
+      break;
 
376
+    case PROP_BUFFER_TIME:
 
377
+      g_value_set_uint64 (value, self->buffer_time);
 
378
+      break;
364
379
+    default:
365
380
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
366
381
+      break;
395
410
+    return FALSE;
396
411
+  }
397
412
+
 
413
+  sp_set_data (self->pipe, self);
398
414
+  g_free (self->socket_path);
399
415
+  self->socket_path = g_strdup (sp_writer_get_path (self->pipe));
400
416
+
455
471
+  return TRUE;
456
472
+}
457
473
+
 
474
+static gboolean
 
475
+gst_shm_sink_can_render (GstShmSink * self, GstClockTime time)
 
476
+{
 
477
+  ShmBuffer *b;
 
478
+
 
479
+  if (time == GST_CLOCK_TIME_NONE || self->buffer_time == GST_CLOCK_TIME_NONE)
 
480
+    return TRUE;
 
481
+
 
482
+  b = sp_writer_get_pending_buffers (self->pipe);
 
483
+  for (; b != NULL; b = sp_writer_get_next_buffer (b)) {
 
484
+    GstClockTime t = sp_writer_buf_get_tag (b);
 
485
+    if (GST_CLOCK_DIFF (time, t) > self->buffer_time)
 
486
+      return FALSE;
 
487
+  }
 
488
+
 
489
+  return TRUE;
 
490
+}
 
491
+
458
492
+static GstFlowReturn
459
493
+gst_shm_sink_render (GstBaseSink * bsink, GstBuffer * buf)
460
494
+{
470
504
+    }
471
505
+  }
472
506
+
 
507
+  while (!gst_shm_sink_can_render (self, GST_BUFFER_TIMESTAMP (buf))) {
 
508
+    g_cond_wait (self->cond, GST_OBJECT_GET_LOCK (self));
 
509
+    if (self->unlock) {
 
510
+      GST_OBJECT_UNLOCK (self);
 
511
+      return GST_FLOW_WRONG_STATE;
 
512
+    }
 
513
+  }
 
514
+
473
515
+  rv = sp_writer_send_buf (self->pipe, (char *) GST_BUFFER_DATA (buf),
474
 
+      GST_BUFFER_SIZE (buf));
 
516
+      GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
475
517
+
476
518
+  if (rv == -1) {
477
519
+    ShmBlock *block = NULL;
493
535
+      }
494
536
+    }
495
537
+
496
 
+
497
538
+    shmbuf = sp_writer_block_get_buf (block);
498
539
+    memcpy (shmbuf, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
499
 
+    sp_writer_send_buf (self->pipe, shmbuf, GST_BUFFER_SIZE (buf));
 
540
+    sp_writer_send_buf (self->pipe, shmbuf, GST_BUFFER_SIZE (buf),
 
541
+        GST_BUFFER_TIMESTAMP (buf));
500
542
+    sp_writer_free_block (block);
501
543
+  }
502
544
+
508
550
+static void
509
551
+gst_shm_sink_free_buffer (gpointer data)
510
552
+{
 
553
+  ShmPipe *pipe;
511
554
+  ShmBlock *block = data;
 
555
+  GstShmSink *self;
 
556
+
 
557
+  pipe = sp_writer_block_get_pipe (block);
 
558
+  self = sp_get_data (pipe);
 
559
+
 
560
+  GST_OBJECT_LOCK (self);
512
561
+  sp_writer_free_block (block);
 
562
+  GST_OBJECT_UNLOCK (self);
 
563
+  g_object_unref (self);
513
564
+}
514
565
+
515
566
+static GstFlowReturn
523
574
+
524
575
+  GST_OBJECT_LOCK (self);
525
576
+  block = sp_writer_alloc_block (self->pipe, size);
526
 
+  if (block)
 
577
+  if (block) {
527
578
+    buf = sp_writer_block_get_buf (block);
 
579
+    g_object_ref (self);
 
580
+  }
528
581
+  GST_OBJECT_UNLOCK (self);
529
582
+
530
583
+  if (block) {
600
653
+      self->clients = g_list_prepend (self->clients, gclient);
601
654
+      g_signal_emit (self, signals[SIGNAL_CLIENT_CONNECTED], 0,
602
655
+          gclient->pollfd.fd);
 
656
+      /* we need to call gst_poll_wait before calling gst_poll_* status
 
657
+         functions on that new descriptor, so restart the loop, so _wait
 
658
+         will have been called on all elements of self->poll, whether
 
659
+         they have just been added or not. */
 
660
+      continue;
603
661
+    }
604
662
+
605
663
+  again:
699
757
Index: gst-plugins-good0.10/sys/shm/gstshmsink.h
700
758
===================================================================
701
759
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
702
 
+++ gst-plugins-good0.10/sys/shm/gstshmsink.h   2011-03-18 12:22:38.195521299 -0400
703
 
@@ -0,0 +1,76 @@
 
760
+++ gst-plugins-good0.10/sys/shm/gstshmsink.h   2012-02-09 13:57:29.572435080 +0200
 
761
@@ -0,0 +1,77 @@
704
762
+/* GStreamer
705
763
+ * Copyright (C) <2009> Collabora Ltd
706
764
+ *  @author: Olivier Crete <olivier.crete@collabora.co.uk
764
822
+  gboolean wait_for_connection;
765
823
+  gboolean stop;
766
824
+  gboolean unlock;
 
825
+  GstClockTime buffer_time;
767
826
+
768
827
+  GCond *cond;
769
828
+};
780
839
Index: gst-plugins-good0.10/sys/shm/gstshmsrc.c
781
840
===================================================================
782
841
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
783
 
+++ gst-plugins-good0.10/sys/shm/gstshmsrc.c    2011-03-18 12:22:38.195521299 -0400
784
 
@@ -0,0 +1,384 @@
 
842
+++ gst-plugins-good0.10/sys/shm/gstshmsrc.c    2012-02-09 13:57:29.572435080 +0200
 
843
@@ -0,0 +1,445 @@
785
844
+/* GStreamer
786
845
+ * Copyright (C) <2009> Collabora Ltd
787
846
+ *  @author: Olivier Crete <olivier.crete@collabora.co.uk
848
907
+    const GValue * value, GParamSpec * pspec);
849
908
+static void gst_shm_src_get_property (GObject * object, guint prop_id,
850
909
+    GValue * value, GParamSpec * pspec);
 
910
+static void gst_shm_src_finalize (GObject * object);
851
911
+static gboolean gst_shm_src_start (GstBaseSrc * bsrc);
852
912
+static gboolean gst_shm_src_stop (GstBaseSrc * bsrc);
853
913
+static GstFlowReturn gst_shm_src_create (GstPushSrc * psrc,
854
914
+    GstBuffer ** outbuf);
855
915
+static gboolean gst_shm_src_unlock (GstBaseSrc * bsrc);
856
916
+static gboolean gst_shm_src_unlock_stop (GstBaseSrc * bsrc);
 
917
+static GstStateChangeReturn gst_shm_src_change_state (GstElement * element,
 
918
+    GstStateChange transition);
857
919
+
858
920
+static void gst_shm_pipe_inc (GstShmPipe * pipe);
859
921
+static void gst_shm_pipe_dec (GstShmPipe * pipe);
866
928
+{
867
929
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
868
930
+
869
 
+  gst_element_class_add_pad_template (element_class,
870
 
+      gst_static_pad_template_get (&srctemplate));
 
931
+  gst_element_class_add_static_pad_template (element_class, &srctemplate);
871
932
+
872
933
+  gst_element_class_set_details_simple (element_class,
873
934
+      "Shared Memory Source",
874
935
+      "Source",
875
936
+      "Receive data from the sharem memory sink",
876
 
+      "Olivier Crete <olivier.crete@collabora.co.uk");
 
937
+      "Olivier Crete <olivier.crete@collabora.co.uk>");
877
938
+}
878
939
+
879
940
+static void
880
941
+gst_shm_src_class_init (GstShmSrcClass * klass)
881
942
+{
882
943
+  GObjectClass *gobject_class;
 
944
+  GstElementClass *gstelement_class;
883
945
+  GstBaseSrcClass *gstbasesrc_class;
884
946
+  GstPushSrcClass *gstpush_src_class;
885
947
+
886
948
+  gobject_class = (GObjectClass *) klass;
 
949
+  gstelement_class = (GstElementClass *) klass;
887
950
+  gstbasesrc_class = (GstBaseSrcClass *) klass;
888
951
+  gstpush_src_class = (GstPushSrcClass *) klass;
889
952
+
890
953
+  gobject_class->set_property = gst_shm_src_set_property;
891
954
+  gobject_class->get_property = gst_shm_src_get_property;
 
955
+  gobject_class->finalize = gst_shm_src_finalize;
 
956
+
 
957
+  gstelement_class->change_state = gst_shm_src_change_state;
892
958
+
893
959
+  gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_shm_src_start);
894
960
+  gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_shm_src_stop);
914
980
+static void
915
981
+gst_shm_src_init (GstShmSrc * self, GstShmSrcClass * g_class)
916
982
+{
 
983
+  self->poll = gst_poll_new (TRUE);
 
984
+  gst_poll_fd_init (&self->pollfd);
 
985
+}
 
986
+
 
987
+static void
 
988
+gst_shm_src_finalize (GObject * object)
 
989
+{
 
990
+  GstShmSrc *self = GST_SHM_SRC (object);
 
991
+
 
992
+  gst_poll_free (self->poll);
 
993
+
 
994
+  G_OBJECT_CLASS (parent_class)->finalize (object);
917
995
+}
918
996
+
919
997
+
967
1045
+}
968
1046
+
969
1047
+static gboolean
970
 
+gst_shm_src_start (GstBaseSrc * bsrc)
 
1048
+gst_shm_src_start_reading (GstShmSrc * self)
971
1049
+{
972
 
+  GstShmSrc *self = GST_SHM_SRC (bsrc);
973
1050
+  GstShmPipe *gstpipe = g_slice_new0 (GstShmPipe);
974
1051
+
975
1052
+  gstpipe->use_count = 1;
976
1053
+  gstpipe->src = gst_object_ref (self);
977
1054
+
978
1055
+  if (!self->socket_path) {
979
 
+    GST_ELEMENT_ERROR (bsrc, RESOURCE, NOT_FOUND,
 
1056
+    GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
980
1057
+        ("No path specified for socket."), (NULL));
981
1058
+    return FALSE;
982
1059
+  }
983
1060
+
984
 
+  GST_DEBUG ("Opening socket %s", self->socket_path);
 
1061
+  GST_DEBUG_OBJECT (self, "Opening socket %s", self->socket_path);
985
1062
+
986
1063
+  GST_OBJECT_LOCK (self);
987
1064
+  gstpipe->pipe = sp_client_open (self->socket_path);
988
1065
+  GST_OBJECT_UNLOCK (self);
989
1066
+
990
1067
+  if (!gstpipe->pipe) {
991
 
+    GST_ELEMENT_ERROR (bsrc, RESOURCE, OPEN_READ_WRITE,
 
1068
+    GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ_WRITE,
992
1069
+        ("Could not open socket %s: %d %s", self->socket_path, errno,
993
1070
+            strerror (errno)), (NULL));
994
1071
+    gst_shm_pipe_dec (gstpipe);
997
1074
+
998
1075
+  self->pipe = gstpipe;
999
1076
+
1000
 
+  self->poll = gst_poll_new (TRUE);
 
1077
+  gst_poll_set_flushing (self->poll, FALSE);
 
1078
+
1001
1079
+  gst_poll_fd_init (&self->pollfd);
1002
1080
+  self->pollfd.fd = sp_get_fd (self->pipe->pipe);
1003
1081
+  gst_poll_add_fd (self->poll, &self->pollfd);
1006
1084
+  return TRUE;
1007
1085
+}
1008
1086
+
1009
 
+static gboolean
1010
 
+gst_shm_src_stop (GstBaseSrc * bsrc)
 
1087
+static void
 
1088
+gst_shm_src_stop_reading (GstShmSrc * self)
1011
1089
+{
1012
 
+  GstShmSrc *self = GST_SHM_SRC (bsrc);
1013
 
+
1014
1090
+  GST_DEBUG_OBJECT (self, "Stopping %p", self);
1015
1091
+
1016
1092
+  if (self->pipe) {
1018
1094
+    self->pipe = NULL;
1019
1095
+  }
1020
1096
+
1021
 
+  gst_poll_free (self->poll);
1022
 
+  self->poll = NULL;
 
1097
+  gst_poll_remove_fd (self->poll, &self->pollfd);
 
1098
+  gst_poll_fd_init (&self->pollfd);
 
1099
+
 
1100
+  gst_poll_set_flushing (self->poll, TRUE);
 
1101
+}
 
1102
+
 
1103
+static gboolean
 
1104
+gst_shm_src_start (GstBaseSrc * bsrc)
 
1105
+{
 
1106
+  if (gst_base_src_is_live (bsrc))
 
1107
+    return TRUE;
 
1108
+  else
 
1109
+    return gst_shm_src_start_reading (GST_SHM_SRC (bsrc));
 
1110
+}
 
1111
+
 
1112
+static gboolean
 
1113
+gst_shm_src_stop (GstBaseSrc * bsrc)
 
1114
+{
 
1115
+  if (!gst_base_src_is_live (bsrc))
 
1116
+    gst_shm_src_stop_reading (GST_SHM_SRC (bsrc));
1023
1117
+
1024
1118
+  return TRUE;
1025
1119
+}
1106
1200
+  return GST_FLOW_OK;
1107
1201
+}
1108
1202
+
 
1203
+static GstStateChangeReturn
 
1204
+gst_shm_src_change_state (GstElement * element, GstStateChange transition)
 
1205
+{
 
1206
+  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
 
1207
+  GstShmSrc *self = GST_SHM_SRC (element);
 
1208
+
 
1209
+  switch (transition) {
 
1210
+    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
 
1211
+      if (gst_base_src_is_live (GST_BASE_SRC (element)))
 
1212
+        if (!gst_shm_src_start_reading (self))
 
1213
+          return GST_STATE_CHANGE_FAILURE;
 
1214
+    default:
 
1215
+      break;
 
1216
+  }
 
1217
+
 
1218
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
 
1219
+  if (ret == GST_STATE_CHANGE_FAILURE)
 
1220
+    return ret;
 
1221
+
 
1222
+  switch (transition) {
 
1223
+    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
 
1224
+      if (gst_base_src_is_live (GST_BASE_SRC (element)))
 
1225
+        gst_shm_src_stop_reading (self);
 
1226
+    default:
 
1227
+      break;
 
1228
+  }
 
1229
+
 
1230
+  return ret;
 
1231
+}
 
1232
+
1109
1233
+static gboolean
1110
1234
+gst_shm_src_unlock (GstBaseSrc * bsrc)
1111
1235
+{
1112
1236
+  GstShmSrc *self = GST_SHM_SRC (bsrc);
1113
1237
+
1114
1238
+  self->unlocked = TRUE;
1115
 
+
1116
 
+  if (self->poll)
1117
 
+    gst_poll_set_flushing (self->poll, TRUE);
 
1239
+  gst_poll_set_flushing (self->poll, TRUE);
1118
1240
+
1119
1241
+  return TRUE;
1120
1242
+}
1125
1247
+  GstShmSrc *self = GST_SHM_SRC (bsrc);
1126
1248
+
1127
1249
+  self->unlocked = FALSE;
1128
 
+
1129
 
+  if (self->poll)
1130
 
+    gst_poll_set_flushing (self->poll, FALSE);
 
1250
+  gst_poll_set_flushing (self->poll, FALSE);
1131
1251
+
1132
1252
+  return TRUE;
1133
1253
+}
1169
1289
Index: gst-plugins-good0.10/sys/shm/gstshmsrc.h
1170
1290
===================================================================
1171
1291
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
1172
 
+++ gst-plugins-good0.10/sys/shm/gstshmsrc.h    2011-03-18 12:22:38.195521299 -0400
 
1292
+++ gst-plugins-good0.10/sys/shm/gstshmsrc.h    2012-02-09 13:57:29.572435080 +0200
1173
1293
@@ -0,0 +1,76 @@
1174
1294
+/* GStreamer
1175
1295
+ * Copyright (C) <2009> Collabora Ltd
1250
1370
Index: gst-plugins-good0.10/sys/shm/shmalloc.c
1251
1371
===================================================================
1252
1372
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
1253
 
+++ gst-plugins-good0.10/sys/shm/shmalloc.c     2011-03-18 12:22:38.195521299 -0400
 
1373
+++ gst-plugins-good0.10/sys/shm/shmalloc.c     2012-02-09 13:57:29.572435080 +0200
1254
1374
@@ -0,0 +1,184 @@
1255
1375
+/* GStreamer
1256
1376
+ * Copyright (C) <2009> Collabora Ltd
1439
1559
Index: gst-plugins-good0.10/sys/shm/shmalloc.h
1440
1560
===================================================================
1441
1561
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
1442
 
+++ gst-plugins-good0.10/sys/shm/shmalloc.h     2011-03-18 12:22:38.195521299 -0400
 
1562
+++ gst-plugins-good0.10/sys/shm/shmalloc.h     2012-02-09 13:57:29.572435080 +0200
1443
1563
@@ -0,0 +1,74 @@
1444
1564
+/* GStreamer
1445
1565
+ * Copyright (C) <2009> Collabora Ltd
1518
1638
Index: gst-plugins-good0.10/sys/shm/shmpipe.c
1519
1639
===================================================================
1520
1640
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
1521
 
+++ gst-plugins-good0.10/sys/shm/shmpipe.c      2011-03-18 12:22:38.195521299 -0400
1522
 
@@ -0,0 +1,857 @@
 
1641
+++ gst-plugins-good0.10/sys/shm/shmpipe.c      2012-02-09 13:57:29.572435080 +0200
 
1642
@@ -0,0 +1,914 @@
1523
1643
+/* GStreamer
1524
1644
+ * Copyright (C) <2009> Collabora Ltd
1525
1645
+ *  @author: Olivier Crete <olivier.crete@collabora.co.uk
1600
1720
+};
1601
1721
+
1602
1722
+typedef struct _ShmArea ShmArea;
1603
 
+typedef struct _ShmBuffer ShmBuffer;
1604
1723
+
1605
1724
+struct _ShmArea
1606
1725
+{
1634
1753
+
1635
1754
+  int num_clients;
1636
1755
+  int clients[0];
 
1756
+
 
1757
+  uint64_t tag;
1637
1758
+};
1638
1759
+
1639
1760
+
1641
1762
+{
1642
1763
+  int main_socket;
1643
1764
+  char *socket_path;
 
1765
+  int use_count;
 
1766
+  void *data;
1644
1767
+
1645
1768
+  ShmArea *shm_area;
1646
1769
+
1712
1835
+{
1713
1836
+  ShmPipe *self = spalloc_new (ShmPipe);
1714
1837
+  int flags;
1715
 
+  struct sockaddr_un sun;
 
1838
+  struct sockaddr_un sock_un;
1716
1839
+  int i = 0;
1717
1840
+
1718
1841
+  memset (self, 0, sizeof (ShmPipe));
1719
1842
+
1720
1843
+  self->main_socket = socket (PF_UNIX, SOCK_STREAM, 0);
 
1844
+  self->use_count = 1;
1721
1845
+
1722
1846
+  if (self->main_socket < 0)
1723
1847
+    RETURN_ERROR ("Could not create socket (%d): %s\n", errno,
1730
1854
+  if (fcntl (self->main_socket, F_SETFL, flags | O_NONBLOCK | FD_CLOEXEC) < 0)
1731
1855
+    RETURN_ERROR ("fcntl(F_SETFL) failed (%d): %s\n", errno, strerror (errno));
1732
1856
+
1733
 
+  sun.sun_family = AF_UNIX;
1734
 
+  strncpy (sun.sun_path, path, sizeof (sun.sun_path) - 1);
 
1857
+  sock_un.sun_family = AF_UNIX;
 
1858
+  strncpy (sock_un.sun_path, path, sizeof (sock_un.sun_path) - 1);
1735
1859
+
1736
 
+  while (bind (self->main_socket, (struct sockaddr *) &sun,
 
1860
+  while (bind (self->main_socket, (struct sockaddr *) &sock_un,
1737
1861
+          sizeof (struct sockaddr_un)) < 0) {
1738
1862
+    if (errno != EADDRINUSE)
1739
1863
+      RETURN_ERROR ("bind() failed (%d): %s\n", errno, strerror (errno));
1741
1865
+    if (i > 256)
1742
1866
+      RETURN_ERROR ("Could not find a free socket name for %s", path);
1743
1867
+
1744
 
+    snprintf (sun.sun_path, sizeof (sun.sun_path), "%s.%d", path, i);
 
1868
+    snprintf (sock_un.sun_path, sizeof (sock_un.sun_path), "%s.%d", path, i);
1745
1869
+    i++;
1746
1870
+  }
1747
1871
+
1748
 
+  self->socket_path = strdup (sun.sun_path);
 
1872
+  self->socket_path = strdup (sock_un.sun_path);
1749
1873
+
1750
1874
+  if (listen (self->main_socket, LISTEN_BACKLOG) < 0)
1751
1875
+    RETURN_ERROR ("listen() failed (%d): %s\n", errno, strerror (errno));
1781
1905
+sp_open_shm (char *path, int id, mode_t perms, size_t size)
1782
1906
+{
1783
1907
+  ShmArea *area = spalloc_new (ShmArea);
1784
 
+  char tmppath[PATH_MAX];
 
1908
+  char tmppath[32];
1785
1909
+  int flags;
1786
1910
+  int prot;
1787
1911
+  int i = 0;
1804
1928
+    area->shm_fd = shm_open (path, flags, perms);
1805
1929
+  } else {
1806
1930
+    do {
1807
 
+      snprintf (tmppath, PATH_MAX, "/shmpipe.5%d.%5d", getpid (), i++);
 
1931
+      snprintf (tmppath, sizeof (tmppath), "/shmpipe.%5d.%5d", getpid (), i++);
1808
1932
+      area->shm_fd = shm_open (tmppath, flags, perms);
1809
1933
+    } while (area->shm_fd < 0 && errno == EEXIST);
1810
1934
+  }
1894
2018
+  }
1895
2019
+}
1896
2020
+
 
2021
+void *
 
2022
+sp_get_data (ShmPipe * self)
 
2023
+{
 
2024
+  return self->data;
 
2025
+}
 
2026
+
 
2027
+void
 
2028
+sp_set_data (ShmPipe * self, void *data)
 
2029
+{
 
2030
+  self->data = data;
 
2031
+}
 
2032
+
 
2033
+static void
 
2034
+sp_inc (ShmPipe * self)
 
2035
+{
 
2036
+  self->use_count++;
 
2037
+}
 
2038
+
 
2039
+static void
 
2040
+sp_dec (ShmPipe * self)
 
2041
+{
 
2042
+  self->use_count--;
 
2043
+
 
2044
+  if (self->use_count > 0)
 
2045
+    return;
 
2046
+
 
2047
+  while (self->shm_area)
 
2048
+    sp_shm_area_dec (self, self->shm_area);
 
2049
+
 
2050
+  spalloc_free (ShmPipe, self);
 
2051
+}
 
2052
+
1897
2053
+void
1898
2054
+sp_close (ShmPipe * self)
1899
2055
+{
1908
2064
+  while (self->clients)
1909
2065
+    sp_writer_close_client (self, self->clients);
1910
2066
+
1911
 
+  while (self->shm_area)
1912
 
+    sp_shm_area_dec (self, self->shm_area);
1913
 
+
1914
 
+  spalloc_free (ShmPipe, self);
 
2067
+  sp_dec (self);
1915
2068
+}
1916
2069
+
1917
2070
+int
2003
2156
+  block->pipe = self;
2004
2157
+  block->area = self->shm_area;
2005
2158
+  block->ablock = ablock;
 
2159
+  sp_inc (self);
2006
2160
+  return block;
2007
2161
+}
2008
2162
+
2013
2167
+      shm_alloc_space_alloc_block_get_offset (block->ablock);
2014
2168
+}
2015
2169
+
 
2170
+ShmPipe *
 
2171
+sp_writer_block_get_pipe (ShmBlock * block)
 
2172
+{
 
2173
+  return block->pipe;
 
2174
+}
 
2175
+
2016
2176
+void
2017
2177
+sp_writer_free_block (ShmBlock * block)
2018
2178
+{
2019
2179
+  shm_alloc_space_block_dec (block->ablock);
2020
2180
+  sp_shm_area_dec (block->pipe, block->area);
 
2181
+  sp_dec (block->pipe);
2021
2182
+  spalloc_free (ShmBlock, block);
2022
2183
+}
2023
2184
+
2024
2185
+/* Returns the number of client this has successfully been sent to */
2025
2186
+
2026
2187
+int
2027
 
+sp_writer_send_buf (ShmPipe * self, char *buf, size_t size)
 
2188
+sp_writer_send_buf (ShmPipe * self, char *buf, size_t size, uint64_t tag)
2028
2189
+{
2029
2190
+  ShmArea *area = NULL;
2030
2191
+  unsigned long offset = 0;
2059
2220
+  sb->size = size;
2060
2221
+  sb->num_clients = self->num_clients;
2061
2222
+  sb->ablock = ablock;
 
2223
+  sb->tag = tag;
2062
2224
+
2063
2225
+  for (client = self->clients; client; client = client->next) {
2064
2226
+    struct CommandBuffer cb = { 0 };
2103
2265
+sp_client_recv (ShmPipe * self, char **buf)
2104
2266
+{
2105
2267
+  char *area_name = NULL;
2106
 
+  ShmArea *newarea, *oldarea;
 
2268
+  ShmArea *newarea;
2107
2269
+  ShmArea *area;
2108
2270
+  struct CommandBuffer cb;
2109
2271
+  int retval;
2130
2292
+      if (!newarea)
2131
2293
+        return -4;
2132
2294
+
2133
 
+      oldarea = self->shm_area;
2134
2295
+      newarea->next = self->shm_area;
2135
2296
+      self->shm_area = newarea;
2136
 
+      /*
2137
 
+         if (oldarea)
2138
 
+         sp_shm_area_dec (self, oldarea);
2139
 
+       */
2140
2297
+      break;
2141
2298
+
2142
2299
+    case COMMAND_CLOSE_SHM_AREA:
2226
2383
+sp_client_open (const char *path)
2227
2384
+{
2228
2385
+  ShmPipe *self = spalloc_new (ShmPipe);
2229
 
+  struct sockaddr_un sun;
 
2386
+  struct sockaddr_un sock_un;
2230
2387
+
2231
2388
+  memset (self, 0, sizeof (ShmPipe));
2232
2389
+
2233
2390
+  self->main_socket = socket (PF_UNIX, SOCK_STREAM, 0);
 
2391
+  self->use_count = 1;
 
2392
+
2234
2393
+  if (self->main_socket < 0)
2235
2394
+    goto error;
2236
2395
+
2237
 
+  sun.sun_family = AF_UNIX;
2238
 
+  strncpy (sun.sun_path, path, sizeof (sun.sun_path) - 1);
 
2396
+  sock_un.sun_family = AF_UNIX;
 
2397
+  strncpy (sock_un.sun_path, path, sizeof (sock_un.sun_path) - 1);
2239
2398
+
2240
 
+  if (connect (self->main_socket, (struct sockaddr *) &sun,
 
2399
+  if (connect (self->main_socket, (struct sockaddr *) &sock_un,
2241
2400
+          sizeof (struct sockaddr_un)) < 0)
2242
2401
+    goto error;
2243
2402
+
2377
2536
+{
2378
2537
+  return pipe->socket_path;
2379
2538
+}
 
2539
+
 
2540
+ShmBuffer *
 
2541
+sp_writer_get_pending_buffers (ShmPipe * self)
 
2542
+{
 
2543
+  return self->buffers;
 
2544
+}
 
2545
+
 
2546
+ShmBuffer *
 
2547
+sp_writer_get_next_buffer (ShmBuffer * buffer)
 
2548
+{
 
2549
+  return buffer->next;
 
2550
+}
 
2551
+
 
2552
+uint64_t
 
2553
+sp_writer_buf_get_tag (ShmBuffer * buffer)
 
2554
+{
 
2555
+  return buffer->tag;
 
2556
+}
2380
2557
Index: gst-plugins-good0.10/sys/shm/shmpipe.h
2381
2558
===================================================================
2382
2559
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
2383
 
+++ gst-plugins-good0.10/sys/shm/shmpipe.h      2011-03-18 12:22:38.195521299 -0400
2384
 
@@ -0,0 +1,104 @@
 
2560
+++ gst-plugins-good0.10/sys/shm/shmpipe.h      2012-02-09 13:57:29.572435080 +0200
 
2561
@@ -0,0 +1,117 @@
2385
2562
+/* GStreamer
2386
2563
+ * Copyright (C) <2009> Collabora Ltd
2387
2564
+ *  @author: Olivier Crete <olivier.crete@collabora.co.uk
2407
2584
+ */
2408
2585
+
2409
2586
+/*
2410
 
+ * None of this code is thread safe, if you want to use it in a multi-threaded
2411
 
+ * context, please protect it with a mutex.
2412
 
+ *
2413
 
+ * First, create a writer with sp_writer_create()
2414
 
+ * And selectes() on the socket from sp_get_fd()
2415
 
+ * If the socket is closed or there are errors from any function, the app
2416
 
+ * should call sp_close() and assume the writer is dead
2417
 
+ * The server calls sp_writer_accept_client() when there is something to read
2418
 
+ * from the server fd
2419
 
+ * It then needs to select() on the socket from sp_writer_get_client_fd()
2420
 
+ * If it gets an error on that socket, it call sp_writer_close_client().
2421
 
+ * If there is something to read, it calls sp_writer_recv().
2422
 
+ *
2423
 
+ * The writer allocates buffers with sp_writer_alloc_block(),
2424
 
+ * writes something in the buffer (retrieved with sp_writer_block_get_buf(),
2425
 
+ * then calls  sp_writer_send_buf() to send the buffer or a subsection to
2426
 
+ * the other side. When it is done with the block, it calls
2427
 
+ * sp_writer_free_block().
2428
 
+ * If alloc fails, then the server must wait for events from the clients before
2429
 
+ * trying again.
2430
 
+ *
2431
 
+ *
2432
 
+ * The clients connect with sp_client_open()
2433
 
+ * And select() on the fd from sp_get_fd() until there is something to read.
2434
 
+ * Then they must read using sp_client_recv() which will return > 0 if there
2435
 
+ * is a valid buffer (which is read only). It will return 0 if it is an internal
2436
 
+ * message and <0 if there was an error. If there was an error, one must close
2437
 
+ * it with sp_close(). If was valid buffer was received, the client must release
2438
 
+ * it with sp_client_recv_finish() when it is done reading from it.
 
2587
+ * None of this code is thread safe, if you want to use it in a
 
2588
+ * multi-threaded context, please protect it with a mutex.
 
2589
+ *
 
2590
+ * First, create a writer with sp_writer_create(), then select() on
 
2591
+ * the socket returned by sp_get_fd(). If the socket is closed or any
 
2592
+ * function returns an error, the app should call sp_close() and
 
2593
+ * assume the other side is dead. The writer calls
 
2594
+ * sp_writer_accept_client() when there is something to read from the
 
2595
+ * main server fd. This returns a new ShmClient (representing a client
 
2596
+ * connection), the writer needs to do a select() on the socket
 
2597
+ * returned by sp_writer_get_client_fd(). If it gets an error on that
 
2598
+ * socket, it calls sp_writer_close_client(). If there is something to
 
2599
+ * read, it calls sp_writer_recv().
 
2600
+ *
 
2601
+ * The writer allocates a block containing a free buffer with
 
2602
+ * sp_writer_alloc_block(), then writes something in the buffer
 
2603
+ * (retrieved with sp_writer_block_get_buf(), then calls
 
2604
+ * sp_writer_send_buf() to send the buffer or a subsection to the
 
2605
+ * other side. When it is done with the block, it calls
 
2606
+ * sp_writer_free_block().  If alloc fails, then the server must wait
 
2607
+ * for events on the client fd (the ones where sp_writer_recv() is
 
2608
+ * called), and then try to re-alloc.
 
2609
+ *
 
2610
+ * The reader (client) connect to the writer with sp_client_open() And
 
2611
+ * select()s on the fd from sp_get_fd() until there is something to
 
2612
+ * read.  Then they must read using sp_client_recv() which will return
 
2613
+ * the size of the buffer (positive) if there is a valid buffer (which
 
2614
+ * is read only).  It will return 0 if it is an internal message and a
 
2615
+ * negative number if there was an error.  If there was an error, the
 
2616
+ * application must close the pipe with sp_close() and assume that all
 
2617
+ * buffers are no longer valid. If was valid buffer was received, the
 
2618
+ * client must release it with sp_client_recv_finish() when it is done
 
2619
+ * reading from it.
2439
2620
+ */
2440
2621
+
2441
2622
+
2443
2624
+#define __SHMPIPE_H__
2444
2625
+
2445
2626
+#include <stdlib.h>
 
2627
+#include <stdint.h>
2446
2628
+#include <sys/types.h>
2447
2629
+#include <sys/stat.h>
2448
2630
+#include <fcntl.h>
2455
2637
+typedef struct _ShmClient ShmClient;
2456
2638
+typedef struct _ShmPipe ShmPipe;
2457
2639
+typedef struct _ShmBlock ShmBlock;
 
2640
+typedef struct _ShmBuffer ShmBuffer;
2458
2641
+
2459
2642
+ShmPipe *sp_writer_create (const char *path, size_t size, mode_t perms);
2460
2643
+const char *sp_writer_get_path (ShmPipe *pipe);
2461
2644
+void sp_close (ShmPipe * self);
 
2645
+void *sp_get_data (ShmPipe * self);
 
2646
+void sp_set_data (ShmPipe * self, void *data);
2462
2647
+
2463
2648
+int sp_writer_setperms_shm (ShmPipe * self, mode_t perms);
2464
2649
+int sp_writer_resize (ShmPipe * self, size_t size);
2468
2653
+
2469
2654
+ShmBlock *sp_writer_alloc_block (ShmPipe * self, size_t size);
2470
2655
+void sp_writer_free_block (ShmBlock *block);
2471
 
+int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size);
 
2656
+int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size, uint64_t tag);
2472
2657
+char *sp_writer_block_get_buf (ShmBlock *block);
 
2658
+ShmPipe *sp_writer_block_get_pipe (ShmBlock *block);
2473
2659
+
2474
2660
+ShmClient * sp_writer_accept_client (ShmPipe * self);
2475
2661
+void sp_writer_close_client (ShmPipe *self, ShmClient * client);
2481
2667
+long int sp_client_recv (ShmPipe * self, char **buf);
2482
2668
+int sp_client_recv_finish (ShmPipe * self, char *buf);
2483
2669
+
 
2670
+ShmBuffer *sp_writer_get_pending_buffers (ShmPipe * self);
 
2671
+ShmBuffer *sp_writer_get_next_buffer (ShmBuffer * buffer);
 
2672
+uint64_t sp_writer_buf_get_tag (ShmBuffer * buffer);
 
2673
+
2484
2674
+#ifdef __cplusplus
2485
2675
+}
2486
2676
+#endif
2488
2678
+#endif /* __SHMPIPE_H__ */
2489
2679
Index: gst-plugins-good0.10/configure.ac
2490
2680
===================================================================
2491
 
--- gst-plugins-good0.10.orig/configure.ac      2011-03-18 12:19:11.895218731 -0400
2492
 
+++ gst-plugins-good0.10/configure.ac   2011-03-18 12:22:38.195521299 -0400
2493
 
@@ -685,6 +685,13 @@
 
2681
--- gst-plugins-good0.10.orig/configure.ac      2012-02-09 13:57:01.663599934 +0200
 
2682
+++ gst-plugins-good0.10/configure.ac   2012-02-09 13:57:02.791633689 +0200
 
2683
@@ -702,6 +702,13 @@
2494
2684
   AG_GST_CHECK_XV
2495
2685
 ])
2496
2686
 
2504
2694
 dnl *** ext plug-ins ***
2505
2695
 dnl keep this list sorted alphabetically !
2506
2696
 
2507
 
@@ -1184,6 +1191,7 @@
 
2697
@@ -1187,6 +1194,7 @@
2508
2698
 sys/v4l2/Makefile
2509
2699
 sys/waveform/Makefile
2510
2700
 sys/ximage/Makefile