Port gtk-doc comments to their equivalent markdown syntax
[platform/upstream/gstreamer.git] / gst / gstsample.c
index 4c5681f..219db6b 100644 (file)
  *
  * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
  * SECTION:gstsample
+ * @title: GstSample
  * @short_description: A media sample
  * @see_also: #GstBuffer, #GstCaps, #GstSegment
  *
 
 #include "gstsample.h"
 
-/**
- * GstSample:
- *
- */
+GST_DEBUG_CATEGORY_STATIC (gst_sample_debug);
+#define GST_CAT_DEFAULT gst_sample_debug
+
 struct _GstSample
 {
   GstMiniObject mini_object;
@@ -43,6 +43,7 @@ struct _GstSample
   GstCaps *caps;
   GstSegment segment;
   GstStructure *info;
+  GstBufferList *buffer_list;
 };
 
 GType _gst_sample_type = 0;
@@ -53,6 +54,8 @@ void
 _priv_gst_sample_initialize (void)
 {
   _gst_sample_type = gst_sample_get_type ();
+
+  GST_DEBUG_CATEGORY_INIT (gst_sample_debug, "sample", 0, "GstSample debug");
 }
 
 static GstSample *
@@ -61,7 +64,11 @@ _gst_sample_copy (GstSample * sample)
   GstSample *copy;
 
   copy = gst_sample_new (sample->buffer, sample->caps, &sample->segment,
-      gst_structure_copy (sample->info));
+      (sample->info) ? gst_structure_copy (sample->info) : NULL);
+
+  if (sample->buffer_list)
+    copy->buffer_list = (GstBufferList *)
+        gst_mini_object_ref (GST_MINI_OBJECT_CAST (sample->buffer_list));
 
   return copy;
 }
@@ -75,16 +82,22 @@ _gst_sample_free (GstSample * sample)
     gst_buffer_unref (sample->buffer);
   if (sample->caps)
     gst_caps_unref (sample->caps);
+  if (sample->info) {
+    gst_structure_set_parent_refcount (sample->info, NULL);
+    gst_structure_free (sample->info);
+  }
+  if (sample->buffer_list)
+    gst_mini_object_unref (GST_MINI_OBJECT_CAST (sample->buffer_list));
 
-  g_slice_free1 (GST_MINI_OBJECT_SIZE (sample), sample);
+  g_slice_free1 (sizeof (GstSample), sample);
 }
 
 /**
  * gst_sample_new:
- * @buffer: a #GstBuffer
- * @caps: a #GstCaps
- * @segment: a #GstSegment
- * @info: a #GstStructure
+ * @buffer: (transfer none) (allow-none): a #GstBuffer, or %NULL
+ * @caps: (transfer none) (allow-none): a #GstCaps, or %NULL
+ * @segment: (transfer none) (allow-none): a #GstSegment, or %NULL
+ * @info: (transfer full) (allow-none): a #GstStructure, or %NULL
  *
  * Create a new #GstSample with the provided details.
  *
@@ -92,8 +105,6 @@ _gst_sample_free (GstSample * sample)
  *
  * Returns: (transfer full): the new #GstSample. gst_sample_unref()
  *     after usage.
- *
- * Since: 0.10.24
  */
 GstSample *
 gst_sample_new (GstBuffer * buffer, GstCaps * caps, const GstSegment * segment,
@@ -105,11 +116,9 @@ gst_sample_new (GstBuffer * buffer, GstCaps * caps, const GstSegment * segment,
 
   GST_LOG ("new %p", sample);
 
-  gst_mini_object_init (GST_MINI_OBJECT_CAST (sample), _gst_sample_type,
-      sizeof (GstSample));
-
-  sample->mini_object.copy = (GstMiniObjectCopyFunction) _gst_sample_copy;
-  sample->mini_object.free = (GstMiniObjectFreeFunction) _gst_sample_free;
+  gst_mini_object_init (GST_MINI_OBJECT_CAST (sample), 0, _gst_sample_type,
+      (GstMiniObjectCopyFunction) _gst_sample_copy, NULL,
+      (GstMiniObjectFreeFunction) _gst_sample_free);
 
   sample->buffer = buffer ? gst_buffer_ref (buffer) : NULL;
   sample->caps = caps ? gst_caps_ref (caps) : NULL;
@@ -143,8 +152,10 @@ had_parent:
  *
  * Get the buffer associated with @sample
  *
- * Returns: (transfer none): the buffer of @sample or NULL when there
- *  is no buffer. The buffer remains valid as long as @sample is valid.
+ * Returns: (transfer none) (nullable): the buffer of @sample or %NULL
+ *  when there is no buffer. The buffer remains valid as long as
+ *  @sample is valid.  If you need to hold on to it for longer than
+ *  that, take a ref to the buffer with gst_buffer_ref().
  */
 GstBuffer *
 gst_sample_get_buffer (GstSample * sample)
@@ -160,8 +171,10 @@ gst_sample_get_buffer (GstSample * sample)
  *
  * Get the caps associated with @sample
  *
- * Returns: (transfer none): the caps of @sample or NULL when there
- *  is no caps. The caps remain valid as long as @sample is valid.
+ * Returns: (transfer none) (nullable): the caps of @sample or %NULL
+ *  when there is no caps. The caps remain valid as long as @sample is
+ *  valid.  If you need to hold on to the caps for longer than that,
+ *  take a ref to the caps with gst_caps_ref().
  */
 GstCaps *
 gst_sample_get_caps (GstSample * sample)
@@ -204,3 +217,46 @@ gst_sample_get_info (GstSample * sample)
 
   return sample->info;
 }
+
+/**
+ * gst_sample_get_buffer_list:
+ * @sample: a #GstSample
+ *
+ * Get the buffer list associated with @sample
+ *
+ * Returns: (transfer none) (nullable): the buffer list of @sample or %NULL
+ *  when there is no buffer list. The buffer list remains valid as long as
+ *  @sample is valid.  If you need to hold on to it for longer than
+ *  that, take a ref to the buffer list with gst_mini_object_ref ().
+ *
+ * Since: 1.6
+ */
+GstBufferList *
+gst_sample_get_buffer_list (GstSample * sample)
+{
+  g_return_val_if_fail (GST_IS_SAMPLE (sample), NULL);
+
+  return sample->buffer_list;
+}
+
+/**
+ * gst_sample_set_buffer_list:
+ * @sample: a #GstSample
+ * @buffer_list: a #GstBufferList
+ *
+ * Set the buffer list associated with @sample
+ *
+ * Since: 1.6
+ */
+void
+gst_sample_set_buffer_list (GstSample * sample, GstBufferList * buffer_list)
+{
+  GstBufferList *old = NULL;
+  g_return_if_fail (GST_IS_SAMPLE (sample));
+  old = sample->buffer_list;
+  sample->buffer_list = (GstBufferList *)
+      gst_mini_object_ref (GST_MINI_OBJECT_CAST (buffer_list));
+
+  if (old)
+    gst_mini_object_unref (GST_MINI_OBJECT_CAST (old));
+}