mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
audio: Add stream align API for getting timestamp at discont and number of samples since discont
https://bugzilla.gnome.org/show_bug.cgi?id=787560
This commit is contained in:
parent
d2fd740388
commit
bf68e74403
4 changed files with 79 additions and 23 deletions
|
@ -250,6 +250,8 @@ gst_audio_stream_align_copy
|
||||||
gst_audio_stream_align_free
|
gst_audio_stream_align_free
|
||||||
gst_audio_stream_align_mark_discont
|
gst_audio_stream_align_mark_discont
|
||||||
gst_audio_stream_align_process
|
gst_audio_stream_align_process
|
||||||
|
gst_audio_stream_align_get_samples_since_discont
|
||||||
|
gst_audio_stream_align_get_timestamp_at_discont
|
||||||
gst_audio_stream_align_get_alignment_threshold
|
gst_audio_stream_align_get_alignment_threshold
|
||||||
gst_audio_stream_align_set_alignment_threshold
|
gst_audio_stream_align_set_alignment_threshold
|
||||||
gst_audio_stream_align_get_discont_wait
|
gst_audio_stream_align_get_discont_wait
|
||||||
|
|
|
@ -50,6 +50,8 @@ struct _GstAudioStreamAlign
|
||||||
|
|
||||||
/* counter to keep track of timestamps */
|
/* counter to keep track of timestamps */
|
||||||
guint64 next_offset;
|
guint64 next_offset;
|
||||||
|
GstClockTime timestamp_at_discont;
|
||||||
|
guint64 samples_since_discont;
|
||||||
|
|
||||||
/* Last time we noticed a discont */
|
/* Last time we noticed a discont */
|
||||||
GstClockTime discont_time;
|
GstClockTime discont_time;
|
||||||
|
@ -90,6 +92,8 @@ gst_audio_stream_align_new (gint rate, GstClockTime alignment_threshold,
|
||||||
align->alignment_threshold = alignment_threshold;
|
align->alignment_threshold = alignment_threshold;
|
||||||
align->discont_wait = discont_wait;
|
align->discont_wait = discont_wait;
|
||||||
|
|
||||||
|
align->timestamp_at_discont = GST_CLOCK_TIME_NONE;
|
||||||
|
align->samples_since_discont = 0;
|
||||||
gst_audio_stream_align_mark_discont (align);
|
gst_audio_stream_align_mark_discont (align);
|
||||||
|
|
||||||
return align;
|
return align;
|
||||||
|
@ -264,6 +268,44 @@ gst_audio_stream_align_mark_discont (GstAudioStreamAlign * align)
|
||||||
align->discont_time = GST_CLOCK_TIME_NONE;
|
align->discont_time = GST_CLOCK_TIME_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_audio_stream_align_get_timestamp_at_discont:
|
||||||
|
* @align: a #GstAudioStreamAlign
|
||||||
|
*
|
||||||
|
* Timestamp that was passed when a discontinuity was detected, i.e. the first
|
||||||
|
* timestamp after the discontinuity.
|
||||||
|
*
|
||||||
|
* Returns: The last timestamp at when a discontinuity was detected
|
||||||
|
*
|
||||||
|
* Since: 1.14
|
||||||
|
*/
|
||||||
|
GstClockTime
|
||||||
|
gst_audio_stream_align_get_timestamp_at_discont (GstAudioStreamAlign * align)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (align != NULL, GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
|
return align->timestamp_at_discont;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_audio_stream_align_get_samples_since_discont:
|
||||||
|
* @align: a #GstAudioStreamAlign
|
||||||
|
*
|
||||||
|
* Returns the number of samples that were processed since the last
|
||||||
|
* discontinuity was detected.
|
||||||
|
*
|
||||||
|
* Returns: The number of samples processed since the last discontinuity.
|
||||||
|
*
|
||||||
|
* Since: 1.14
|
||||||
|
*/
|
||||||
|
guint64
|
||||||
|
gst_audio_stream_align_get_samples_since_discont (GstAudioStreamAlign * align)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (align != NULL, 0);
|
||||||
|
|
||||||
|
return align->samples_since_discont;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_audio_stream_align_process:
|
* gst_audio_stream_align_process:
|
||||||
* @align: a #GstAudioStreamAlign
|
* @align: a #GstAudioStreamAlign
|
||||||
|
@ -363,6 +405,8 @@ gst_audio_stream_align_process (GstAudioStreamAlign * align,
|
||||||
G_GUINT64_FORMAT ", got %" G_GUINT64_FORMAT,
|
G_GUINT64_FORMAT ", got %" G_GUINT64_FORMAT,
|
||||||
align->next_offset, start_offset);
|
align->next_offset, start_offset);
|
||||||
align->next_offset = align->rate > 0 ? end_offset : start_offset;
|
align->next_offset = align->rate > 0 ? end_offset : start_offset;
|
||||||
|
align->timestamp_at_discont = start_time;
|
||||||
|
align->samples_since_discont = 0;
|
||||||
|
|
||||||
/* Got a discont and adjusted, reset the discont_time marker */
|
/* Got a discont and adjusted, reset the discont_time marker */
|
||||||
align->discont_time = GST_CLOCK_TIME_NONE;
|
align->discont_time = GST_CLOCK_TIME_NONE;
|
||||||
|
@ -399,6 +443,8 @@ gst_audio_stream_align_process (GstAudioStreamAlign * align,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
align->samples_since_discont += n_samples;
|
||||||
|
|
||||||
if (out_timestamp)
|
if (out_timestamp)
|
||||||
*out_timestamp = timestamp;
|
*out_timestamp = timestamp;
|
||||||
if (out_duration)
|
if (out_duration)
|
||||||
|
|
|
@ -29,46 +29,52 @@
|
||||||
typedef struct _GstAudioStreamAlign GstAudioStreamAlign;
|
typedef struct _GstAudioStreamAlign GstAudioStreamAlign;
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
GType gst_audio_stream_align_get_type (void);
|
GType gst_audio_stream_align_get_type (void);
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
GstAudioStreamAlign * gst_audio_stream_align_new (gint rate,
|
GstAudioStreamAlign * gst_audio_stream_align_new (gint rate,
|
||||||
GstClockTime alignment_threshold,
|
GstClockTime alignment_threshold,
|
||||||
GstClockTime discont_wait);
|
GstClockTime discont_wait);
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
GstAudioStreamAlign * gst_audio_stream_align_copy (const GstAudioStreamAlign * align);
|
GstAudioStreamAlign * gst_audio_stream_align_copy (const GstAudioStreamAlign * align);
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
void gst_audio_stream_align_free (GstAudioStreamAlign * align);
|
void gst_audio_stream_align_free (GstAudioStreamAlign * align);
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
void gst_audio_stream_align_set_rate (GstAudioStreamAlign * align,
|
void gst_audio_stream_align_set_rate (GstAudioStreamAlign * align,
|
||||||
gint rate);
|
gint rate);
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
gint gst_audio_stream_align_get_rate (GstAudioStreamAlign * align);
|
gint gst_audio_stream_align_get_rate (GstAudioStreamAlign * align);
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
void gst_audio_stream_align_set_alignment_threshold (GstAudioStreamAlign * align,
|
void gst_audio_stream_align_set_alignment_threshold (GstAudioStreamAlign * align,
|
||||||
GstClockTime alignment_threshold);
|
GstClockTime alignment_threshold);
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
GstClockTime gst_audio_stream_align_get_alignment_threshold (GstAudioStreamAlign * align);
|
GstClockTime gst_audio_stream_align_get_alignment_threshold (GstAudioStreamAlign * align);
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
void gst_audio_stream_align_set_discont_wait (GstAudioStreamAlign * align,
|
void gst_audio_stream_align_set_discont_wait (GstAudioStreamAlign * align,
|
||||||
GstClockTime discont_wait);
|
GstClockTime discont_wait);
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
GstClockTime gst_audio_stream_align_get_discont_wait (GstAudioStreamAlign * align);
|
GstClockTime gst_audio_stream_align_get_discont_wait (GstAudioStreamAlign * align);
|
||||||
|
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
void gst_audio_stream_align_mark_discont (GstAudioStreamAlign * align);
|
void gst_audio_stream_align_mark_discont (GstAudioStreamAlign * align);
|
||||||
|
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
gboolean gst_audio_stream_align_process (GstAudioStreamAlign * align,
|
GstClockTime gst_audio_stream_align_get_timestamp_at_discont (GstAudioStreamAlign * align);
|
||||||
gboolean discont,
|
|
||||||
GstClockTime timestamp,
|
GST_EXPORT
|
||||||
guint n_samples,
|
guint64 gst_audio_stream_align_get_samples_since_discont (GstAudioStreamAlign * align);
|
||||||
GstClockTime *out_timestamp,
|
|
||||||
GstClockTime *out_duration,
|
GST_EXPORT
|
||||||
guint64 *out_sample_position);
|
gboolean gst_audio_stream_align_process (GstAudioStreamAlign * align,
|
||||||
|
gboolean discont,
|
||||||
|
GstClockTime timestamp,
|
||||||
|
guint n_samples,
|
||||||
|
GstClockTime *out_timestamp,
|
||||||
|
GstClockTime *out_duration,
|
||||||
|
guint64 *out_sample_position);
|
||||||
|
|
||||||
#endif /* __GST_AUDIO_STREAM_ALIGN_H__ */
|
#endif /* __GST_AUDIO_STREAM_ALIGN_H__ */
|
||||||
|
|
|
@ -214,6 +214,8 @@ EXPORTS
|
||||||
gst_audio_stream_align_get_alignment_threshold
|
gst_audio_stream_align_get_alignment_threshold
|
||||||
gst_audio_stream_align_get_discont_wait
|
gst_audio_stream_align_get_discont_wait
|
||||||
gst_audio_stream_align_get_rate
|
gst_audio_stream_align_get_rate
|
||||||
|
gst_audio_stream_align_get_samples_since_discont
|
||||||
|
gst_audio_stream_align_get_timestamp_at_discont
|
||||||
gst_audio_stream_align_get_type
|
gst_audio_stream_align_get_type
|
||||||
gst_audio_stream_align_mark_discont
|
gst_audio_stream_align_mark_discont
|
||||||
gst_audio_stream_align_new
|
gst_audio_stream_align_new
|
||||||
|
|
Loading…
Reference in a new issue