X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstsample.h;h=268119ccc43155eb94ee16d51a634f3d701a61b8;hb=a143d9cb0caee85bbe0c5e8b86e9f05918153c9d;hp=45cd7ee661bd224f1996fe07e57d07e8941619d0;hpb=ebf502d1c6296f774fbbdca1849cf5bff61bb5ad;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstsample.h b/gst/gstsample.h index 45cd7ee..268119c 100644 --- a/gst/gstsample.h +++ b/gst/gstsample.h @@ -16,8 +16,8 @@ * * 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. */ @@ -25,12 +25,13 @@ #define __GST_SAMPLE_H__ #include +#include #include #include G_BEGIN_DECLS -GST_EXPORT GType _gst_sample_type; +GST_API GType _gst_sample_type; #define GST_TYPE_SAMPLE (_gst_sample_type) #define GST_IS_SAMPLE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_SAMPLE)) @@ -42,23 +43,50 @@ GST_EXPORT GType _gst_sample_type; * * The opaque structure of a #GstSample. A sample contains a typed memory * block and the associated timing information. It is mainly used to - * exchange buffers with and application. + * exchange buffers with an application. */ typedef struct _GstSample GstSample; -GType gst_sample_get_type (void); +GST_API +GType gst_sample_get_type (void); /* allocation */ + +GST_API GstSample * gst_sample_new (GstBuffer *buffer, GstCaps *caps, const GstSegment *segment, GstStructure *info); - +GST_API GstBuffer * gst_sample_get_buffer (GstSample *sample); + +GST_API GstCaps * gst_sample_get_caps (GstSample *sample); + +GST_API GstSegment * gst_sample_get_segment (GstSample *sample); + +GST_API const GstStructure * gst_sample_get_info (GstSample *sample); +GST_API +GstBufferList * gst_sample_get_buffer_list (GstSample *sample); + +GST_API +void gst_sample_set_buffer_list (GstSample *sample, GstBufferList *buffer_list); + +GST_API +void gst_sample_set_buffer (GstSample *sample, GstBuffer *buffer); + +GST_API +void gst_sample_set_caps (GstSample *sample, GstCaps *caps); + +GST_API +void gst_sample_set_segment (GstSample * sample, const GstSegment *segment); + +GST_API +gboolean gst_sample_set_info (GstSample *sample, GstStructure *info); + /* refcounting */ /** * gst_sample_ref: @@ -68,10 +96,6 @@ const GstStructure * gst_sample_get_info (GstSample *sample); * * Returns: (transfer full): @sample */ -#ifdef _FOOL_GTK_DOC_ -G_INLINE_FUNC GstSample * gst_sample_ref (GstSample * sample); -#endif - static inline GstSample * gst_sample_ref (GstSample * sample) { @@ -86,10 +110,6 @@ gst_sample_ref (GstSample * sample) * Decreases the refcount of the sample. If the refcount reaches 0, the * sample will be freed. */ -#ifdef _FOOL_GTK_DOC_ -G_INLINE_FUNC void gst_sample_unref (GstSample * sample); -#endif - static inline void gst_sample_unref (GstSample * sample) { @@ -97,6 +117,63 @@ gst_sample_unref (GstSample * sample) } /** + * gst_sample_is_writable: + * @sample: A #GstSample + * + * Tests if you can safely set the buffer and / or buffer list of @sample. + * + * Since: 1.16 + */ +#define gst_sample_is_writable(sample) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (sample)) + +/** + * gst_sample_make_writable: + * @sample: (transfer full): A #GstSample + * + * Returns a writable copy of @sample. If the source sample is + * already writable, this will simply return the same sample. + * + * Use this function to ensure that a sample can be safely modified before + * making changes to it, for example before calling gst_sample_set_buffer() + * + * If the reference count of the source sample @sample is exactly one, the caller + * is the sole owner and this function will return the sample object unchanged. + * + * If there is more than one reference on the object, a copy will be made using + * gst_sample_copy(). The passed-in @sample will be unreffed in that case, and the + * caller will now own a reference to the new returned sample object. + * + * In short, this function unrefs the sample in the argument and refs the sample + * that it returns. Don't access the argument after calling this function unless + * you have an additional reference to it. + * + * Returns: (transfer full): a writable sample which may or may not be the + * same as @sample + * + * Since: 1.16 + */ +#define gst_sample_make_writable(sample) GST_SAMPLE_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (sample))) + + +/* copy sample */ +/** + * gst_sample_copy: + * @buf: a #GstSample. + * + * Create a copy of the given sample. This will also make a newly allocated + * copy of the data the source sample contains. + * + * Returns: (transfer full): a new copy of @buf. + * + * Since: 1.2 + */ +static inline GstSample * +gst_sample_copy (const GstSample * buf) +{ + return GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (buf))); +} + +/** * gst_value_set_sample: * @v: a #GValue to receive the data * @b: (transfer none): a #GstSample to assign to the GstValue @@ -124,6 +201,10 @@ gst_sample_unref (GstSample * sample) */ #define gst_value_get_sample(v) GST_SAMPLE_CAST (g_value_get_boxed(v)) +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSample, gst_sample_unref) +#endif + G_END_DECLS #endif /* __GST_SAMPLE_H__ */