gstappsrc.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* GStreamer
  2. * Copyright (C) 2007 David Schleef <[email protected]>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef _GST_APP_SRC_H_
  20. #define _GST_APP_SRC_H_
  21. #include <gst/gst.h>
  22. #include <gst/base/gstpushsrc.h>
  23. G_BEGIN_DECLS
  24. #define GST_TYPE_APP_SRC \
  25. (gst_app_src_get_type())
  26. #define GST_APP_SRC(obj) \
  27. (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_APP_SRC,GstAppSrc))
  28. #define GST_APP_SRC_CLASS(klass) \
  29. (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_APP_SRC,GstAppSrcClass))
  30. #define GST_IS_APP_SRC(obj) \
  31. (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_APP_SRC))
  32. #define GST_IS_APP_SRC_CLASS(klass) \
  33. (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_APP_SRC))
  34. #define GST_APP_SRC_CAST(obj) \
  35. ((GstAppSrc*)(obj))
  36. typedef struct _GstAppSrc GstAppSrc;
  37. typedef struct _GstAppSrcClass GstAppSrcClass;
  38. typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
  39. /**
  40. * GstAppSrcCallbacks: (skip)
  41. * @need_data: Called when the appsrc needs more data. A buffer or EOS should be
  42. * pushed to appsrc from this thread or another thread. @length is just a hint
  43. * and when it is set to -1, any number of bytes can be pushed into @appsrc.
  44. * @enough_data: Called when appsrc has enough data. It is recommended that the
  45. * application stops calling push-buffer until the need_data callback is
  46. * emitted again to avoid excessive buffer queueing.
  47. * @seek_data: Called when a seek should be performed to the offset.
  48. * The next push-buffer should produce buffers from the new @offset.
  49. * This callback is only called for seekable stream types.
  50. *
  51. * A set of callbacks that can be installed on the appsrc with
  52. * gst_app_src_set_callbacks().
  53. */
  54. typedef struct {
  55. void (*need_data) (GstAppSrc *src, guint length, gpointer user_data);
  56. void (*enough_data) (GstAppSrc *src, gpointer user_data);
  57. gboolean (*seek_data) (GstAppSrc *src, guint64 offset, gpointer user_data);
  58. /*< private >*/
  59. gpointer _gst_reserved[GST_PADDING];
  60. } GstAppSrcCallbacks;
  61. /**
  62. * GstAppStreamType:
  63. * @GST_APP_STREAM_TYPE_STREAM: No seeking is supported in the stream, such as a
  64. * live stream.
  65. * @GST_APP_STREAM_TYPE_SEEKABLE: The stream is seekable but seeking might not
  66. * be very fast, such as data from a webserver.
  67. * @GST_APP_STREAM_TYPE_RANDOM_ACCESS: The stream is seekable and seeking is fast,
  68. * such as in a local file.
  69. *
  70. * The stream type.
  71. */
  72. typedef enum
  73. {
  74. GST_APP_STREAM_TYPE_STREAM,
  75. GST_APP_STREAM_TYPE_SEEKABLE,
  76. GST_APP_STREAM_TYPE_RANDOM_ACCESS
  77. } GstAppStreamType;
  78. struct _GstAppSrc
  79. {
  80. GstBaseSrc basesrc;
  81. /*< private >*/
  82. GstAppSrcPrivate *priv;
  83. /*< private >*/
  84. gpointer _gst_reserved[GST_PADDING];
  85. };
  86. struct _GstAppSrcClass
  87. {
  88. GstBaseSrcClass basesrc_class;
  89. /* signals */
  90. void (*need_data) (GstAppSrc *appsrc, guint length);
  91. void (*enough_data) (GstAppSrc *appsrc);
  92. gboolean (*seek_data) (GstAppSrc *appsrc, guint64 offset);
  93. /* actions */
  94. GstFlowReturn (*push_buffer) (GstAppSrc *appsrc, GstBuffer *buffer);
  95. GstFlowReturn (*end_of_stream) (GstAppSrc *appsrc);
  96. /*< private >*/
  97. gpointer _gst_reserved[GST_PADDING];
  98. };
  99. GType gst_app_src_get_type(void);
  100. /* GType getter for GstAppStreamType */
  101. #define GST_TYPE_APP_STREAM_TYPE (gst_app_stream_type_get_type ())
  102. GType gst_app_stream_type_get_type (void);
  103. void gst_app_src_set_caps (GstAppSrc *appsrc, const GstCaps *caps);
  104. GstCaps* gst_app_src_get_caps (GstAppSrc *appsrc);
  105. void gst_app_src_set_size (GstAppSrc *appsrc, gint64 size);
  106. gint64 gst_app_src_get_size (GstAppSrc *appsrc);
  107. void gst_app_src_set_stream_type (GstAppSrc *appsrc, GstAppStreamType type);
  108. GstAppStreamType gst_app_src_get_stream_type (GstAppSrc *appsrc);
  109. void gst_app_src_set_max_bytes (GstAppSrc *appsrc, guint64 max);
  110. guint64 gst_app_src_get_max_bytes (GstAppSrc *appsrc);
  111. guint64 gst_app_src_get_current_level_bytes (GstAppSrc *appsrc);
  112. void gst_app_src_set_latency (GstAppSrc *appsrc, guint64 min, guint64 max);
  113. void gst_app_src_get_latency (GstAppSrc *appsrc, guint64 *min, guint64 *max);
  114. void gst_app_src_set_emit_signals (GstAppSrc *appsrc, gboolean emit);
  115. gboolean gst_app_src_get_emit_signals (GstAppSrc *appsrc);
  116. GstFlowReturn gst_app_src_push_buffer (GstAppSrc *appsrc, GstBuffer *buffer);
  117. GstFlowReturn gst_app_src_end_of_stream (GstAppSrc *appsrc);
  118. void gst_app_src_set_callbacks (GstAppSrc * appsrc,
  119. GstAppSrcCallbacks *callbacks,
  120. gpointer user_data,
  121. GDestroyNotify notify);
  122. G_END_DECLS
  123. #endif