gstsample.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* GStreamer
  2. * Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
  3. * 2000 Wim Taymans <[email protected]>
  4. *
  5. * gstsample.h: Header for GstSample object
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301, USA.
  21. */
  22. #ifndef __GST_SAMPLE_H__
  23. #define __GST_SAMPLE_H__
  24. #include <gst/gstbuffer.h>
  25. #include <gst/gstcaps.h>
  26. #include <gst/gstsegment.h>
  27. G_BEGIN_DECLS
  28. GST_EXPORT GType _gst_sample_type;
  29. #define GST_TYPE_SAMPLE (_gst_sample_type)
  30. #define GST_IS_SAMPLE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_SAMPLE))
  31. #define GST_SAMPLE_CAST(obj) ((GstSample *)obj)
  32. #define GST_SAMPLE(obj) (GST_SAMPLE_CAST(obj))
  33. /**
  34. * GstSample:
  35. *
  36. * The opaque structure of a #GstSample. A sample contains a typed memory
  37. * block and the associated timing information. It is mainly used to
  38. * exchange buffers with an application.
  39. */
  40. typedef struct _GstSample GstSample;
  41. GType gst_sample_get_type (void);
  42. /* allocation */
  43. GstSample * gst_sample_new (GstBuffer *buffer,
  44. GstCaps *caps,
  45. const GstSegment *segment,
  46. GstStructure *info);
  47. GstBuffer * gst_sample_get_buffer (GstSample *sample);
  48. GstCaps * gst_sample_get_caps (GstSample *sample);
  49. GstSegment * gst_sample_get_segment (GstSample *sample);
  50. const GstStructure * gst_sample_get_info (GstSample *sample);
  51. /* refcounting */
  52. /**
  53. * gst_sample_ref:
  54. * @sample: a #GstSample
  55. *
  56. * Increases the refcount of the given sample by one.
  57. *
  58. * Returns: (transfer full): @sample
  59. */
  60. #ifdef _FOOL_GTK_DOC_
  61. G_INLINE_FUNC GstSample * gst_sample_ref (GstSample * sample);
  62. #endif
  63. static inline GstSample *
  64. gst_sample_ref (GstSample * sample)
  65. {
  66. return GST_SAMPLE_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (
  67. sample)));
  68. }
  69. /**
  70. * gst_sample_unref:
  71. * @sample: (transfer full): a #GstSample
  72. *
  73. * Decreases the refcount of the sample. If the refcount reaches 0, the
  74. * sample will be freed.
  75. */
  76. #ifdef _FOOL_GTK_DOC_
  77. G_INLINE_FUNC void gst_sample_unref (GstSample * sample);
  78. #endif
  79. static inline void
  80. gst_sample_unref (GstSample * sample)
  81. {
  82. gst_mini_object_unref (GST_MINI_OBJECT_CAST (sample));
  83. }
  84. /* copy sample */
  85. /**
  86. * gst_sample_copy:
  87. * @buf: a #GstSample.
  88. *
  89. * Create a copy of the given sample. This will also make a newly allocated
  90. * copy of the data the source sample contains.
  91. *
  92. * Returns: (transfer full): a new copy of @buf.
  93. *
  94. * Since: 1.2
  95. */
  96. #ifdef _FOOL_GTK_DOC_
  97. G_INLINE_FUNC GstSample * gst_sample_copy (const GstSample * buf);
  98. #endif
  99. static inline GstSample *
  100. gst_sample_copy (const GstSample * buf)
  101. {
  102. return GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (buf)));
  103. }
  104. /**
  105. * gst_value_set_sample:
  106. * @v: a #GValue to receive the data
  107. * @b: (transfer none): a #GstSample to assign to the GstValue
  108. *
  109. * Sets @b as the value of @v. Caller retains reference to sample.
  110. */
  111. #define gst_value_set_sample(v,b) g_value_set_boxed((v),(b))
  112. /**
  113. * gst_value_take_sample:
  114. * @v: a #GValue to receive the data
  115. * @b: (transfer full): a #GstSample to assign to the GstValue
  116. *
  117. * Sets @b as the value of @v. Caller gives away reference to sample.
  118. */
  119. #define gst_value_take_sample(v,b) g_value_take_boxed(v,(b))
  120. /**
  121. * gst_value_get_sample:
  122. * @v: a #GValue to query
  123. *
  124. * Receives a #GstSample as the value of @v. Does not return a reference to
  125. * the sample, so the pointer is only valid for as long as the caller owns
  126. * a reference to @v.
  127. *
  128. * Returns: (transfer none): sample
  129. */
  130. #define gst_value_get_sample(v) GST_SAMPLE_CAST (g_value_get_boxed(v))
  131. G_END_DECLS
  132. #endif /* __GST_SAMPLE_H__ */