#include "config.h"
#endif
-#include <gst/audio/audio.h>
-
#include "alaw-decode.h"
extern GstStaticPadTemplate alaw_dec_src_factory;
int rate, channels;
gboolean ret;
GstCaps *outcaps;
+ GstAudioInfo info;
structure = gst_caps_get_structure (caps, 0);
if (!ret)
return FALSE;
- outcaps = gst_caps_new_simple ("audio/x-raw",
- "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
- "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
+ gst_audio_info_init (&info);
+ gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S16, rate, channels, NULL);
+ outcaps = gst_audio_info_to_caps (&info);
ret = gst_pad_set_caps (alawdec->srcpad, outcaps);
gst_caps_unref (outcaps);
if (ret) {
GST_DEBUG_OBJECT (alawdec, "rate=%d, channels=%d", rate, channels);
- alawdec->rate = rate;
- alawdec->channels = channels;
+ alawdec->info = info;
}
return ret;
}
GstMapInfo inmap, outmap;
gint16 *linear_data;
guint8 *alaw_data;
- gsize alaw_size;
+ gsize alaw_size, linear_size;
GstBuffer *outbuf;
gint i;
GstFlowReturn ret;
alawdec = GST_ALAW_DEC (parent);
- if (G_UNLIKELY (alawdec->rate == 0))
+ if (G_UNLIKELY (!GST_AUDIO_INFO_IS_VALID (&alawdec->info)))
goto not_negotiated;
GST_LOG_OBJECT (alawdec, "buffer with ts=%" GST_TIME_FORMAT,
alaw_data = inmap.data;
alaw_size = inmap.size;
- outbuf = gst_buffer_new_allocate (NULL, alaw_size * 2, 0);
+ linear_size = alaw_size * 2;
+
+ outbuf = gst_buffer_new_allocate (NULL, linear_size, 0);
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
linear_data = (gint16 *) outmap.data;
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
- GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
+ if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
+ } else {
+ GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
+ linear_size, GST_AUDIO_INFO_RATE (&alawdec->info) *
+ GST_AUDIO_INFO_BPF (&alawdec->info));
+ }
for (i = 0; i < alaw_size; i++) {
linear_data[i] = alaw_to_s16 (alaw_data[i]);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
- dec->rate = 0;
- dec->channels = 0;
+ gst_audio_info_init (&dec->info);
break;
default:
break;
#include "config.h"
#endif
#include <gst/gst.h>
-#include <gst/audio/audio.h>
#include "mulaw-decode.h"
#include "mulaw-conversion.h"
int rate, channels;
gboolean ret;
GstCaps *outcaps;
+ GstAudioInfo info;
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "rate", &rate);
if (!ret)
return FALSE;
- outcaps = gst_caps_new_simple ("audio/x-raw",
- "format", G_TYPE_STRING, GST_AUDIO_NE (S16),
- "rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, channels, NULL);
+ gst_audio_info_init (&info);
+ gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S16, rate, channels, NULL);
+
+ outcaps = gst_audio_info_to_caps (&info);
ret = gst_pad_set_caps (mulawdec->srcpad, outcaps);
gst_caps_unref (outcaps);
if (ret) {
GST_DEBUG_OBJECT (mulawdec, "rate=%d, channels=%d", rate, channels);
- mulawdec->rate = rate;
- mulawdec->channels = channels;
+ mulawdec->info = info;
}
return ret;
}
mulawdec = GST_MULAWDEC (parent);
- if (G_UNLIKELY (mulawdec->rate == 0))
+ if (G_UNLIKELY (!GST_AUDIO_INFO_IS_VALID (&mulawdec->info)))
goto not_negotiated;
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
- if (GST_BUFFER_DURATION (outbuf) == GST_CLOCK_TIME_NONE)
- GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
- linear_size, 2 * mulawdec->rate * mulawdec->channels);
- else
+ if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
+ } else {
+ GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
+ linear_size, GST_AUDIO_INFO_RATE (&mulawdec->info) *
+ GST_AUDIO_INFO_BPF (&mulawdec->info));
+ }
mulaw_decode (mulaw_data, linear_data, mulaw_size);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
- dec->rate = 0;
- dec->channels = 0;
+ gst_audio_info_init (&dec->info);
break;
default:
break;