gstaudiobasesrc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* GStreamer
  2. * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
  3. * 2005 Wim Taymans <wim@fluendo.com>
  4. *
  5. * gstaudiobasesrc.h:
  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. /* a base class for audio sources.
  23. */
  24. #ifndef __GST_AUDIO_AUDIO_H__
  25. #include <gst/audio/audio.h>
  26. #endif
  27. #ifndef __GST_AUDIO_BASE_SRC_H__
  28. #define __GST_AUDIO_BASE_SRC_H__
  29. #include <gst/gst.h>
  30. #include <gst/base/gstpushsrc.h>
  31. G_BEGIN_DECLS
  32. #define GST_TYPE_AUDIO_BASE_SRC (gst_audio_base_src_get_type())
  33. #define GST_AUDIO_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_BASE_SRC,GstAudioBaseSrc))
  34. #define GST_AUDIO_BASE_SRC_CAST(obj) ((GstAudioBaseSrc*)obj)
  35. #define GST_AUDIO_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_BASE_SRC,GstAudioBaseSrcClass))
  36. #define GST_AUDIO_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_BASE_SRC, GstAudioBaseSrcClass))
  37. #define GST_IS_AUDIO_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_BASE_SRC))
  38. #define GST_IS_AUDIO_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_BASE_SRC))
  39. /**
  40. * GST_AUDIO_BASE_SRC_CLOCK:
  41. * @obj: a #GstAudioBaseSrc
  42. *
  43. * Get the #GstClock of @obj.
  44. */
  45. #define GST_AUDIO_BASE_SRC_CLOCK(obj) (GST_AUDIO_BASE_SRC (obj)->clock)
  46. /**
  47. * GST_AUDIO_BASE_SRC_PAD:
  48. * @obj: a #GstAudioBaseSrc
  49. *
  50. * Get the source #GstPad of @obj.
  51. */
  52. #define GST_AUDIO_BASE_SRC_PAD(obj) (GST_BASE_SRC (obj)->srcpad)
  53. typedef struct _GstAudioBaseSrc GstAudioBaseSrc;
  54. typedef struct _GstAudioBaseSrcClass GstAudioBaseSrcClass;
  55. typedef struct _GstAudioBaseSrcPrivate GstAudioBaseSrcPrivate;
  56. /**
  57. * GstAudioBaseSrcSlaveMethod:
  58. * @GST_AUDIO_BASE_SRC_SLAVE_RESAMPLE: Resample to match the master clock.
  59. * @GST_AUDIO_BASE_SRC_SLAVE_RETIMESTAMP: Retimestamp output buffers with master
  60. * clock time.
  61. * @GST_AUDIO_BASE_SRC_SLAVE_SKEW: Adjust capture pointer when master clock
  62. * drifts too much.
  63. * @GST_AUDIO_BASE_SRC_SLAVE_NONE: No adjustment is done.
  64. *
  65. * Different possible clock slaving algorithms when the internal audio clock was
  66. * not selected as the pipeline clock.
  67. */
  68. typedef enum
  69. {
  70. GST_AUDIO_BASE_SRC_SLAVE_RESAMPLE,
  71. GST_AUDIO_BASE_SRC_SLAVE_RETIMESTAMP,
  72. GST_AUDIO_BASE_SRC_SLAVE_SKEW,
  73. GST_AUDIO_BASE_SRC_SLAVE_NONE
  74. } GstAudioBaseSrcSlaveMethod;
  75. #define GST_TYPE_AUDIO_BASE_SRC_SLAVE_METHOD (gst_audio_base_src_slave_method_get_type ())
  76. /**
  77. * GstAudioBaseSrc:
  78. *
  79. * Opaque #GstAudioBaseSrc.
  80. */
  81. struct _GstAudioBaseSrc {
  82. GstPushSrc element;
  83. /*< protected >*/ /* with LOCK */
  84. /* our ringbuffer */
  85. GstAudioRingBuffer *ringbuffer;
  86. /* required buffer and latency */
  87. GstClockTime buffer_time;
  88. GstClockTime latency_time;
  89. /* the next sample to write */
  90. guint64 next_sample;
  91. /* clock */
  92. GstClock *clock;
  93. /*< private >*/
  94. GstAudioBaseSrcPrivate *priv;
  95. gpointer _gst_reserved[GST_PADDING];
  96. };
  97. /**
  98. * GstAudioBaseSrcClass:
  99. * @parent_class: the parent class.
  100. * @create_ringbuffer: create and return a #GstAudioRingBuffer to read from.
  101. *
  102. * #GstAudioBaseSrc class. Override the vmethod to implement
  103. * functionality.
  104. */
  105. struct _GstAudioBaseSrcClass {
  106. GstPushSrcClass parent_class;
  107. /* subclass ringbuffer allocation */
  108. GstAudioRingBuffer* (*create_ringbuffer) (GstAudioBaseSrc *src);
  109. /*< private >*/
  110. gpointer _gst_reserved[GST_PADDING];
  111. };
  112. GType gst_audio_base_src_get_type(void);
  113. GType gst_audio_base_src_slave_method_get_type (void);
  114. GstAudioRingBuffer *
  115. gst_audio_base_src_create_ringbuffer (GstAudioBaseSrc *src);
  116. void gst_audio_base_src_set_provide_clock (GstAudioBaseSrc *src, gboolean provide);
  117. gboolean gst_audio_base_src_get_provide_clock (GstAudioBaseSrc *src);
  118. void gst_audio_base_src_set_slave_method (GstAudioBaseSrc *src,
  119. GstAudioBaseSrcSlaveMethod method);
  120. GstAudioBaseSrcSlaveMethod
  121. gst_audio_base_src_get_slave_method (GstAudioBaseSrc *src);
  122. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  123. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioBaseSrc, gst_object_unref)
  124. #endif
  125. G_END_DECLS
  126. #endif /* __GST_AUDIO_BASE_SRC_H__ */