#include <string.h>
-
static GstStaticPadTemplate static_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
-
static GstStaticPadTemplate static_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
"audio/x-mulaw, rate=(int)[1,MAX], channels=(int)[1,MAX]")
);
-
typedef enum
{
GST_AUDIO_PARSE_FORMAT_RAW,
return audio_parse_format_type;
}
-
#define gst_audio_parse_parent_class parent_class
G_DEFINE_TYPE (GstAudioParse, gst_audio_parse, GST_TYPE_BIN);
GstBinClass parent_class;
};
-
GType gst_audio_parse_get_type (void);
#endif /* __GST_AUDIO_PARSE_H__ */
#include "gstrawaudioparse.h"
#include "unalignedaudio.h"
-
GST_DEBUG_CATEGORY_STATIC (raw_audio_parse_debug);
#define GST_CAT_DEFAULT raw_audio_parse_debug
-
enum
{
PROP_0,
PROP_CHANNEL_POSITIONS
};
-
#define DEFAULT_FORMAT GST_RAW_AUDIO_PARSE_FORMAT_PCM
#define DEFAULT_PCM_FORMAT GST_AUDIO_FORMAT_S16
#define DEFAULT_SAMPLE_RATE 44100
#define DEFAULT_NUM_CHANNELS 2
#define DEFAULT_INTERLEAVED TRUE
-
#define GST_RAW_AUDIO_PARSE_CAPS \
GST_AUDIO_CAPS_MAKE(GST_AUDIO_FORMATS_ALL) \
", layout = (string) { interleaved, non-interleaved }; " \
"audio/x-alaw, rate = (int) [ 1, MAX ], channels = (int) [ 1, MAX ]; " \
"audio/x-mulaw, rate = (int) [ 1, MAX ], channels = (int) [ 1, MAX ]; "
-
static GstStaticPadTemplate static_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_STATIC_CAPS (GST_UNALIGNED_RAW_AUDIO_CAPS "; " GST_RAW_AUDIO_PARSE_CAPS)
);
-
static GstStaticPadTemplate static_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_STATIC_CAPS (GST_RAW_AUDIO_PARSE_CAPS)
);
-
#define gst_raw_audio_parse_parent_class parent_class
G_DEFINE_TYPE (GstRawAudioParse, gst_raw_audio_parse, GST_TYPE_RAW_BASE_PARSE);
-
static void gst_raw_audio_parse_set_property (GObject * object, guint prop_id,
GValue const *value, GParamSpec * pspec);
static void gst_raw_audio_parse_get_property (GObject * object, guint prop_id,
static gboolean gst_raw_audio_parse_config_to_caps (GstRawAudioParse *
raw_audio_parse, GstCaps ** caps, GstRawAudioParseConfig * config);
-
-
static void
gst_raw_audio_parse_class_init (GstRawAudioParseClass * klass)
{
"Carlos Rafael Giani <dv@pseudoterminal.org>");
}
-
static void
gst_raw_audio_parse_init (GstRawAudioParse * raw_audio_parse)
{
gst_raw_audio_parse_update_config_bpf (&(raw_audio_parse->properties_config));
}
-
static void
gst_raw_audio_parse_set_property (GObject * object, guint prop_id,
GValue const *value, GParamSpec * pspec)
}
}
-
static void
gst_raw_audio_parse_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
}
}
-
static gboolean
gst_raw_audio_parse_stop (GstBaseParse * parse)
{
return GST_BASE_PARSE_CLASS (parent_class)->stop (parse);
}
-
static gboolean
gst_raw_audio_parse_set_current_config (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
return TRUE;
}
-
static GstRawBaseParseConfig
gst_raw_audio_parse_get_current_config (GstRawBaseParse * raw_base_parse)
{
GST_RAW_BASE_PARSE_CONFIG_SINKCAPS : GST_RAW_BASE_PARSE_CONFIG_PROPERTIES;
}
-
static gboolean
gst_raw_audio_parse_set_config_from_caps (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config, GstCaps * caps)
gst_raw_audio_parse_get_config_ptr (raw_audio_parse, config));
}
-
static gboolean
gst_raw_audio_parse_get_caps_from_config (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config, GstCaps ** caps)
gst_raw_audio_parse_get_config_ptr (raw_audio_parse, config));
}
-
static gsize
gst_raw_audio_parse_get_config_frame_size (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
return gst_raw_audio_parse_get_config_ptr (raw_audio_parse, config)->bpf;
}
-
static gboolean
gst_raw_audio_parse_is_config_ready (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
return TRUE;
}
-
static gboolean
gst_raw_audio_parse_is_unit_format_supported (G_GNUC_UNUSED GstRawBaseParse *
raw_base_parse, GstFormat format)
}
}
-
static void
gst_raw_audio_parse_get_units_per_second (GstRawBaseParse * raw_base_parse,
GstFormat format, GstRawBaseParseConfig config, gsize * units_per_sec_n,
}
}
-
static gboolean
gst_raw_audio_parse_is_using_sink_caps (GstRawAudioParse * raw_audio_parse)
{
&(raw_audio_parse->sink_caps_config);
}
-
static GstRawAudioParseConfig *
gst_raw_audio_parse_get_config_ptr (GstRawAudioParse * raw_audio_parse,
GstRawBaseParseConfig config)
}
}
-
static void
gst_raw_audio_parse_init_config (GstRawAudioParseConfig * config)
{
TRUE);
}
-
static gboolean
gst_raw_audio_parse_set_config_channels (GstRawAudioParseConfig * config,
guint num_channels, guint64 channel_mask, gboolean set_positions)
}
}
-
static gboolean
gst_raw_audio_parse_update_channel_reordering_flag (GstRawAudioParseConfig *
config)
}
}
-
static void
gst_raw_audio_parse_update_config_bpf (GstRawAudioParseConfig * config)
{
}
}
-
static gboolean
gst_raw_audio_parse_caps_to_config (GstRawAudioParse * raw_audio_parse,
GstCaps * caps, GstRawAudioParseConfig * config)
return ret;
}
-
static gboolean
gst_raw_audio_parse_config_to_caps (GstRawAudioParse * raw_audio_parse,
GstCaps ** caps, GstRawAudioParseConfig * config)
return ret;
}
-
-
-
GType
gst_raw_audio_parse_format_get_type (void)
{
#define GST_IS_RAW_AUDIO_PARSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_RAW_AUDIO_PARSE))
-
typedef enum _GstRawAudioParseFormat GstRawAudioParseFormat;
typedef struct _GstRawAudioParseConfig GstRawAudioParseConfig;
typedef struct _GstRawAudioParse GstRawAudioParse;
typedef struct _GstRawAudioParseClass GstRawAudioParseClass;
-
enum _GstRawAudioParseFormat
{
GST_RAW_AUDIO_PARSE_FORMAT_PCM,
GST_RAW_AUDIO_PARSE_FORMAT_ALAW
};
-
/* Contains information about the sample rate, format, and channel count to use. */
struct _GstRawAudioParseConfig
{
gboolean needs_channel_reordering;
};
-
struct _GstRawAudioParse
{
GstRawBaseParse parent;
GstRawAudioParseConfig *current_config;
};
-
struct _GstRawAudioParseClass
{
GstRawBaseParseClass parent_class;
};
-
GType gst_raw_audio_parse_get_type (void);
GType gst_raw_audio_parse_format_get_type (void);
-
G_END_DECLS
#endif
#include <string.h>
#include "gstrawbaseparse.h"
-
GST_DEBUG_CATEGORY_STATIC (raw_base_parse_debug);
#define GST_CAT_DEFAULT raw_base_parse_debug
-
enum
{
PROP_0,
PROP_USE_SINK_CAPS
};
-
#define DEFAULT_USE_SINK_CAPS FALSE
#define INITIAL_PARSER_CONFIG \
((DEFAULT_USE_SINK_CAPS) ? GST_RAW_BASE_PARSE_CONFIG_SINKCAPS : \
GST_RAW_BASE_PARSE_CONFIG_PROPERTIES)
-
#define gst_raw_base_parse_parent_class parent_class
G_DEFINE_ABSTRACT_TYPE (GstRawBaseParse, gst_raw_base_parse,
GST_TYPE_BASE_PARSE);
-
static void gst_raw_base_parse_finalize (GObject * object);
static void gst_raw_base_parse_set_property (GObject * object, guint prop_id,
GValue const *value, GParamSpec * pspec);
static gboolean gst_raw_base_parse_is_gstformat_supported (GstRawBaseParse *
raw_base_parse, GstFormat format);
-
-
static void
gst_raw_base_parse_class_init (GstRawBaseParseClass * klass)
{
);
}
-
static void
gst_raw_base_parse_init (GstRawBaseParse * raw_base_parse)
{
g_mutex_init (&(raw_base_parse->config_mutex));
}
-
static void
gst_raw_base_parse_finalize (GObject * object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
gst_raw_base_parse_set_property (GObject * object, guint prop_id,
GValue const *value, GParamSpec * pspec)
}
}
-
static void
gst_raw_base_parse_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
}
}
-
static gboolean
gst_raw_base_parse_start (GstBaseParse * parse)
{
return TRUE;
}
-
static gboolean
gst_raw_base_parse_stop (GstBaseParse * parse)
{
return TRUE;
}
-
static gboolean
gst_raw_base_parse_set_sink_caps (GstBaseParse * parse, GstCaps * caps)
{
g_assert (klass->get_caps_from_config);
g_assert (klass->get_config_frame_size);
-
GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (raw_base_parse);
GST_DEBUG_OBJECT (parse, "getting config from new sink caps");
g_assert (klass->get_config_frame_size);
g_assert (klass->get_units_per_second);
-
/* We never skip any bytes this way. Instead, subclass takes care
* of skipping any overhead (necessary, since the way it needs to
* be skipped is completely subclass specific). */
*skipsize = 0;
-
/* The operations below access the current config. Protect
* against race conditions by using the object lock. */
GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (raw_base_parse);
-
/* If the source pad caps haven't been set yet, or need to be
* set again, do so now, BEFORE any buffers are pushed out */
if (G_UNLIKELY (!raw_base_parse->src_caps_set)) {
klass->get_config_frame_size (raw_base_parse,
GST_RAW_BASE_PARSE_CONFIG_CURRENT);
-
in_size = gst_buffer_get_size (frame->buffer);
/* gst_base_parse_set_min_frame_size() is called when the current
* operations, so the lock can be released */
GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (raw_base_parse);
-
/* If any new caps have to be pushed downstrean, do so
* *before* the frame is finished */
if (G_UNLIKELY (new_caps_event != NULL)) {
return flow_ret;
-
config_not_ready:
GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (raw_base_parse);
GST_ELEMENT_ERROR (parse, STREAM, FORMAT,
return flow_ret;
}
-
static gboolean
gst_raw_base_parse_convert (GstBaseParse * parse, GstFormat src_format,
gint64 src_value, GstFormat dest_format, gint64 * dest_value)
g_assert (klass->is_config_ready);
g_assert (klass->get_units_per_second);
-
/* The operations below access the current config. Protect
* against race conditions by using the object lock. */
GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (raw_base_parse);
-
if (!klass->is_config_ready (raw_base_parse,
GST_RAW_BASE_PARSE_CONFIG_CURRENT)) {
if (gst_raw_base_parse_is_using_sink_caps (raw_base_parse)) {
GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (raw_base_parse);
return ret;
-
config_not_ready:
GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (raw_base_parse);
GST_ELEMENT_ERROR (parse, STREAM, FORMAT,
return FALSE;
}
-
static gboolean
gst_raw_base_parse_is_using_sink_caps (GstRawBaseParse * raw_base_parse)
{
GST_RAW_BASE_PARSE_CONFIG_SINKCAPS;
}
-
static gboolean
gst_raw_base_parse_is_gstformat_supported (GstRawBaseParse * raw_base_parse,
GstFormat format)
return klass->is_unit_format_supported (raw_base_parse, format);
}
-
-
-
-
/**
* gst_raw_base_parse_invalidate_src_caps:
* @raw_base_parse: a #GstRawBaseParse instance
#define GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK(obj) g_mutex_lock(&(((GstRawBaseParse *)(obj))->config_mutex))
#define GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK(obj) g_mutex_unlock(&(((GstRawBaseParse *)(obj))->config_mutex))
-
typedef enum _GstRawBaseParseConfig GstRawBaseParseConfig;
typedef struct _GstRawBaseParse GstRawBaseParse;
typedef struct _GstRawBaseParseClass GstRawBaseParseClass;
-
/**
* GstRawBaseParseConfig:
* @GST_RAW_BASE_PARSE_CONFIG_CURRENT: configuration that is currently active
GST_RAW_BASE_PARSE_CONFIG_PROPERTIES
};
-
/**
* GstRawBaseParse:
*
GMutex config_mutex;
};
-
/**
* GstRawBaseParseClass:
* @parent_class: The parent class structure
GstRawBaseParseConfig config);
};
-
void gst_raw_base_parse_invalidate_src_caps (GstRawBaseParse * raw_base_parse);
-
GType gst_raw_base_parse_get_type (void);
-
G_END_DECLS
#endif
#include "gstrawvideoparse.h"
#include "unalignedvideo.h"
-
GST_DEBUG_CATEGORY_STATIC (raw_video_parse_debug);
#define GST_CAT_DEFAULT raw_video_parse_debug
-
enum
{
PROP_0,
PROP_FRAME_STRIDE
};
-
#define DEFAULT_WIDTH 320
#define DEFAULT_HEIGHT 240
#define DEFAULT_FORMAT GST_VIDEO_FORMAT_I420
#define DEFAULT_TOP_FIELD_FIRST FALSE
#define DEFAULT_FRAME_STRIDE 0
-
#define GST_RAW_VIDEO_PARSE_CAPS \
GST_VIDEO_CAPS_MAKE(GST_VIDEO_FORMATS_ALL) "; "
-
static GstStaticPadTemplate static_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_STATIC_CAPS (GST_UNALIGNED_RAW_VIDEO_CAPS "; " GST_RAW_VIDEO_PARSE_CAPS)
);
-
static GstStaticPadTemplate static_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_STATIC_CAPS (GST_RAW_VIDEO_PARSE_CAPS)
);
-
#define gst_raw_video_parse_parent_class parent_class
G_DEFINE_TYPE (GstRawVideoParse, gst_raw_video_parse, GST_TYPE_RAW_BASE_PARSE);
-
static void gst_raw_video_parse_set_property (GObject * object, guint prop_id,
GValue const *value, GParamSpec * pspec);
static void gst_raw_video_parse_get_property (GObject * object, guint prop_id,
"Carlos Rafael Giani <dv@pseudoterminal.org>");
}
-
static void
gst_raw_video_parse_init (GstRawVideoParse * raw_video_parse)
{
raw_video_parse->properties_config.frame_stride = DEFAULT_FRAME_STRIDE;
}
-
static void
gst_raw_video_parse_set_property (GObject * object, guint prop_id,
GValue const *value, GParamSpec * pspec)
}
}
-
static void
gst_raw_video_parse_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
}
}
-
static gboolean
gst_raw_video_parse_stop (GstBaseParse * parse)
{
return GST_BASE_PARSE_CLASS (parent_class)->stop (parse);
}
-
static gboolean
gst_raw_video_parse_set_current_config (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
return TRUE;
}
-
static GstRawBaseParseConfig
gst_raw_video_parse_get_current_config (GstRawBaseParse * raw_base_parse)
{
GST_RAW_BASE_PARSE_CONFIG_SINKCAPS : GST_RAW_BASE_PARSE_CONFIG_PROPERTIES;
}
-
static gboolean
gst_raw_video_parse_set_config_from_caps (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config, GstCaps * caps)
return config_ptr->ready;
}
-
static gboolean
gst_raw_video_parse_get_caps_from_config (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config, GstCaps ** caps)
return *caps != NULL;
}
-
static gsize
gst_raw_video_parse_get_config_frame_size (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
(gsize) (config_ptr->frame_stride));
}
-
static guint
gst_raw_video_parse_get_max_frames_per_buffer (G_GNUC_UNUSED GstRawBaseParse *
raw_base_parse, G_GNUC_UNUSED GstRawBaseParseConfig config)
return 1;
}
-
static gboolean
gst_raw_video_parse_is_config_ready (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
return TRUE;
}
-
static gboolean
gst_raw_video_parse_is_unit_format_supported (G_GNUC_UNUSED GstRawBaseParse *
raw_base_parse, GstFormat format)
}
}
-
static void
gst_raw_video_parse_get_units_per_second (GstRawBaseParse * raw_base_parse,
GstFormat format, GstRawBaseParseConfig config, gsize * units_per_sec_n,
}
}
-
static gint
gst_raw_video_parse_get_overhead_size (GstRawBaseParse * raw_base_parse,
GstRawBaseParseConfig config)
return (frame_size < frame_stride) ? (gint) (frame_stride - frame_size) : 0;
}
-
static gboolean
gst_raw_video_parse_is_using_sink_caps (GstRawVideoParse * raw_video_parse)
{
&(raw_video_parse->sink_caps_config);
}
-
static GstRawVideoParseConfig *
gst_raw_video_parse_get_config_ptr (GstRawVideoParse * raw_video_parse,
GstRawBaseParseConfig config)
}
}
-
static void
gst_raw_video_parse_init_config (GstRawVideoParseConfig * config)
{
}
}
-
static void
gst_raw_video_parse_update_info (GstRawVideoParseConfig * config)
{
#define GST_IS_RAW_VIDEO_PARSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_RAW_VIDEO_PARSE))
-
typedef struct _GstRawVideoParseConfig GstRawVideoParseConfig;
typedef struct _GstRawVideoParse GstRawVideoParse;
typedef struct _GstRawVideoParseClass GstRawVideoParseClass;
-
/* Contains information about the video frame format. */
struct _GstRawVideoParseConfig
{
gboolean custom_plane_strides;
};
-
struct _GstRawVideoParse
{
GstRawBaseParse parent;
GstRawVideoParseConfig *current_config;
};
-
struct _GstRawVideoParseClass
{
GstRawBaseParseClass parent_class;
};
-
GType gst_raw_video_parse_get_type (void);
-
G_END_DECLS
#endif
#include "gstunalignedaudioparse.h"
#include "unalignedaudio.h"
-
GST_DEBUG_CATEGORY (unaligned_audio_parse_debug);
#define GST_CAT_DEFAULT unaligned_audio_parse_debug
-
struct _GstUnalignedAudioParse
{
GstBin parent;
GstElement *inner_parser;
};
-
struct _GstUnalignedAudioParseClass
{
GstBinClass parent_class;
};
-
static GstStaticPadTemplate static_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_STATIC_CAPS (GST_UNALIGNED_RAW_AUDIO_CAPS)
);
-
static GstStaticPadTemplate static_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
", layout = (string) { interleaved, non-interleaved }")
);
-
-
-
G_DEFINE_TYPE (GstUnalignedAudioParse, gst_unaligned_audio_parse, GST_TYPE_BIN);
-
static void
gst_unaligned_audio_parse_class_init (GstUnalignedAudioParseClass * klass)
{
"Carlos Rafael Giani <dv@pseudoterminal.org>");
}
-
static void
gst_unaligned_audio_parse_init (GstUnalignedAudioParse * unaligned_audio_parse)
{
#include "gstunalignedvideoparse.h"
#include "unalignedvideo.h"
-
GST_DEBUG_CATEGORY (unaligned_video_parse_debug);
#define GST_CAT_DEFAULT unaligned_video_parse_debug
-
struct _GstUnalignedVideoParse
{
GstBin parent;
GstElement *inner_parser;
};
-
struct _GstUnalignedVideoParseClass
{
GstBinClass parent_class;
};
-
static GstStaticPadTemplate static_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_STATIC_CAPS (GST_UNALIGNED_RAW_VIDEO_CAPS)
);
-
static GstStaticPadTemplate static_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL))
);
-
-
-
G_DEFINE_TYPE (GstUnalignedVideoParse, gst_unaligned_video_parse, GST_TYPE_BIN);
-
static void
gst_unaligned_video_parse_class_init (GstUnalignedVideoParseClass * klass)
{
"Carlos Rafael Giani <dv@pseudoterminal.org>");
}
-
static void
gst_unaligned_video_parse_init (GstUnalignedVideoParse * unaligned_video_parse)
{
#include "gstvideoparse.h"
#include "gstrawvideoparse.h"
-
static GstStaticPadTemplate static_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
-
static GstStaticPadTemplate static_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_STATIC_CAPS ("video/x-raw")
);
-
static void gst_video_parse_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_video_parse_get_property (GObject * object, guint prop_id,
GstBinClass parent_class;
};
-
GType gst_video_parse_get_type (void);
#endif /* __GST_VIDEO_PARSE_H__ */