mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
gst-indent c++ files
Original commit message from CVS: gst-indent c++ files
This commit is contained in:
parent
7a778ee4b7
commit
87960e43ea
11 changed files with 886 additions and 949 deletions
|
@ -14,21 +14,22 @@
|
|||
|
||||
using namespace Arts;
|
||||
|
||||
namespace Gst {
|
||||
|
||||
class ArtsStereoSink_impl : virtual public ArtsStereoSink_skel,
|
||||
virtual public StdSynthModule
|
||||
namespace Gst
|
||||
{
|
||||
|
||||
class ArtsStereoSink_impl:virtual public ArtsStereoSink_skel,
|
||||
virtual public StdSynthModule
|
||||
{
|
||||
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
unsigned long remainingsamples;
|
||||
GstData *inbuf;
|
||||
unsigned char *dataptr;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
ArtsStereoSink_impl()
|
||||
ArtsStereoSink_impl ()
|
||||
{
|
||||
remainingsamples = 0;
|
||||
inbuf = NULL;
|
||||
|
@ -41,16 +42,17 @@ public:
|
|||
//gint16 *s;
|
||||
//fprintf(stderr,"StereoSink: getting %d samples\n",samples);
|
||||
|
||||
while (fulfilled < samples) {
|
||||
while (fulfilled < samples)
|
||||
{
|
||||
if (remainingsamples == 0) {
|
||||
//fprintf(stderr,"need to get a buffer\n");
|
||||
if (inbuf) {
|
||||
gst_data_unref(inbuf);
|
||||
gst_data_unref (inbuf);
|
||||
inbuf = NULL;
|
||||
}
|
||||
|
||||
// start by pulling a buffer from GStreamer
|
||||
inbuf = gst_pad_pull (sinkpad);
|
||||
|
||||
while (GST_IS_EVENT (inbuf)) {
|
||||
switch (GST_EVENT_TYPE (inbuf)) {
|
||||
case GST_EVENT_EOS:
|
||||
|
@ -58,18 +60,19 @@ public:
|
|||
default:
|
||||
break;
|
||||
}
|
||||
gst_pad_event_default (srcpad, GST_EVENT(inbuf));
|
||||
gst_pad_event_default (srcpad, GST_EVENT (inbuf));
|
||||
inbuf = gst_pad_pull (sinkpad);
|
||||
}
|
||||
|
||||
dataptr = GST_BUFFER_DATA(GST_BUFFER(inbuf));
|
||||
remainingsamples = GST_BUFFER_SIZE(GST_BUFFER(inbuf)) / 4;
|
||||
dataptr = GST_BUFFER_DATA (GST_BUFFER (inbuf));
|
||||
remainingsamples = GST_BUFFER_SIZE (GST_BUFFER (inbuf)) / 4;
|
||||
//fprintf(stderr,"got a buffer with %d samples\n",remainingsamples);
|
||||
}
|
||||
|
||||
unsigned long count = MIN(remainingsamples,samples-fulfilled);
|
||||
unsigned long count = MIN (remainingsamples, samples - fulfilled);
|
||||
|
||||
//fprintf(stderr,"have %d samples left, can fill %d\n",remainingsamples,count);
|
||||
convert_stereo_i16le_2float(count,dataptr,outleft,outright);
|
||||
convert_stereo_i16le_2float (count, dataptr, outleft, outright);
|
||||
//s = (gint16 *)dataptr;
|
||||
//fprintf(stderr,"samples in are %d and %d, out are %f and %f\n",s[0],s[1],outleft[0],outright[0]);
|
||||
remainingsamples -= count;
|
||||
|
@ -79,101 +82,105 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void setPad(GstPad *pad)
|
||||
void setPad (GstPad * pad)
|
||||
{
|
||||
sinkpad = pad;
|
||||
}
|
||||
void setSrcPad(GstPad *pad)
|
||||
void setSrcPad (GstPad * pad)
|
||||
{
|
||||
srcpad = pad;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class ArtsStereoSrc_impl : virtual public ArtsStereoSrc_skel,
|
||||
class ArtsStereoSrc_impl:virtual public ArtsStereoSrc_skel,
|
||||
virtual public StdSynthModule
|
||||
{
|
||||
{
|
||||
|
||||
GstPad *srcpad;
|
||||
GstBuffer *outbuf;
|
||||
unsigned char *dataptr;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
void calculateBlock (unsigned long samples)
|
||||
{
|
||||
//gint16 *s;
|
||||
//fprintf(stderr,"StereoSrc: handed %d samples\n",samples);
|
||||
outbuf = gst_buffer_new();
|
||||
GST_BUFFER_DATA(outbuf) = (guchar *)g_malloc(samples*4);
|
||||
GST_BUFFER_SIZE(outbuf) = samples*4;
|
||||
memset(GST_BUFFER_DATA(outbuf),0,samples*4);
|
||||
convert_stereo_2float_i16le(samples,inleft,inright,GST_BUFFER_DATA(outbuf));
|
||||
outbuf = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (outbuf) = (guchar *) g_malloc (samples * 4);
|
||||
GST_BUFFER_SIZE (outbuf) = samples * 4;
|
||||
memset (GST_BUFFER_DATA (outbuf), 0, samples * 4);
|
||||
convert_stereo_2float_i16le (samples, inleft, inright,
|
||||
GST_BUFFER_DATA (outbuf));
|
||||
//s = (gint16 *)GST_BUFFER_DATA(outbuf);
|
||||
//fprintf(stderr,"samples in are %f and %f, out are %d and %d\n",inleft[0],inright[0],s[0],s[1]);
|
||||
gst_pad_push(srcpad,GST_DATA(outbuf));
|
||||
gst_pad_push (srcpad, GST_DATA (outbuf));
|
||||
outbuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
void setPad(GstPad *pad)
|
||||
void setPad (GstPad * pad)
|
||||
{
|
||||
srcpad = pad;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class GstArtsWrapper {
|
||||
class GstArtsWrapper
|
||||
{
|
||||
Dispatcher *dispatcher;
|
||||
ArtsStereoSink sink;
|
||||
ArtsStereoSrc source;
|
||||
StereoVolumeControl effect;
|
||||
|
||||
public:
|
||||
GstArtsWrapper(GstPad *sinkpad, GstPad *sourcepad) {
|
||||
dispatcher = new Arts::Dispatcher();
|
||||
ArtsStereoSink_impl *sink_impl = new ArtsStereoSink_impl();
|
||||
ArtsStereoSrc_impl *source_impl = new ArtsStereoSrc_impl();
|
||||
sink_impl->setPad(sinkpad);
|
||||
sink_impl->setSrcPad(sourcepad);
|
||||
source_impl->setPad(sourcepad);
|
||||
sink = ArtsStereoSink::_from_base(sink_impl);
|
||||
source = ArtsStereoSrc::_from_base(source_impl);
|
||||
sink.start();
|
||||
effect.start();
|
||||
source.start();
|
||||
effect.scaleFactor(0.5);
|
||||
connect(sink, effect);
|
||||
connect(effect, source);
|
||||
public:
|
||||
GstArtsWrapper (GstPad * sinkpad, GstPad * sourcepad)
|
||||
{
|
||||
dispatcher = new Arts::Dispatcher ();
|
||||
ArtsStereoSink_impl *sink_impl = new ArtsStereoSink_impl ();
|
||||
ArtsStereoSrc_impl *source_impl = new ArtsStereoSrc_impl ();
|
||||
sink_impl->setPad (sinkpad);
|
||||
sink_impl->setSrcPad (sourcepad);
|
||||
source_impl->setPad (sourcepad);
|
||||
sink = ArtsStereoSink::_from_base (sink_impl);
|
||||
source = ArtsStereoSrc::_from_base (source_impl);
|
||||
sink.start ();
|
||||
effect.start ();
|
||||
source.start ();
|
||||
effect.scaleFactor (0.5);
|
||||
connect (sink, effect);
|
||||
connect (effect, source);
|
||||
// connect(sink,source);
|
||||
}
|
||||
void iterate()
|
||||
void iterate ()
|
||||
{
|
||||
source._node()->requireFlow();
|
||||
source._node ()->requireFlow ();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void *gst_arts_wrapper_new(GstPad *sinkpad, GstPad *sourcepad)
|
||||
extern "C"
|
||||
{
|
||||
return new Gst::GstArtsWrapper(sinkpad, sourcepad);
|
||||
}
|
||||
|
||||
void gst_arts_wrapper_free(void *wrapper)
|
||||
{
|
||||
Gst::GstArtsWrapper *w = (Gst::GstArtsWrapper *)wrapper;
|
||||
void *gst_arts_wrapper_new (GstPad * sinkpad, GstPad * sourcepad)
|
||||
{
|
||||
return new Gst::GstArtsWrapper (sinkpad, sourcepad);
|
||||
}
|
||||
|
||||
void gst_arts_wrapper_free (void *wrapper)
|
||||
{
|
||||
Gst::GstArtsWrapper * w = (Gst::GstArtsWrapper *) wrapper;
|
||||
delete w;
|
||||
}
|
||||
}
|
||||
|
||||
void gst_arts_wrapper_do(void *wrapper)
|
||||
{
|
||||
Gst::GstArtsWrapper *w = (Gst::GstArtsWrapper *)wrapper;
|
||||
w->iterate();
|
||||
}
|
||||
void gst_arts_wrapper_do (void *wrapper)
|
||||
{
|
||||
Gst::GstArtsWrapper * w = (Gst::GstArtsWrapper *) wrapper;
|
||||
w->iterate ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -30,13 +30,15 @@
|
|||
* we do something manual...
|
||||
*/
|
||||
static void
|
||||
add_fps (GstCaps *caps)
|
||||
add_fps (GstCaps * caps)
|
||||
{
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
GValue list = { 0 }, fps = { 0 };
|
||||
gdouble fpss[] = { 24.0/1.001, 24.0, 25.0,
|
||||
30.0/1.001, 30.0, 50.0,
|
||||
60.0/1.001, 60.0, 0 };
|
||||
GValue list = { 0 }, fps = {
|
||||
0};
|
||||
gdouble fpss[] = { 24.0 / 1.001, 24.0, 25.0,
|
||||
30.0 / 1.001, 30.0, 50.0,
|
||||
60.0 / 1.001, 60.0, 0
|
||||
};
|
||||
guint n;
|
||||
|
||||
g_value_init (&list, GST_TYPE_LIST);
|
||||
|
@ -60,14 +62,12 @@ sink_templ (void)
|
|||
|
||||
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||
"format", GST_TYPE_FOURCC,
|
||||
GST_MAKE_FOURCC ('I','4','2','0'),
|
||||
GST_MAKE_FOURCC ('I', '4', '2', '0'),
|
||||
"width", GST_TYPE_INT_RANGE, 16, 4096,
|
||||
"height", GST_TYPE_INT_RANGE, 16, 4096,
|
||||
NULL);
|
||||
"height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
|
||||
add_fps (caps);
|
||||
|
||||
templ = gst_pad_template_new ("sink", GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS, caps);
|
||||
templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
||||
}
|
||||
|
||||
return templ;
|
||||
|
@ -85,39 +85,31 @@ src_templ (void)
|
|||
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
||||
"mpegversion", GST_TYPE_INT_RANGE, 1, 2,
|
||||
"width", GST_TYPE_INT_RANGE, 16, 4096,
|
||||
"height", GST_TYPE_INT_RANGE, 16, 4096,
|
||||
NULL);
|
||||
"height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
|
||||
add_fps (caps);
|
||||
|
||||
templ = gst_pad_template_new ("src", GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS, caps);
|
||||
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
||||
}
|
||||
|
||||
return templ;
|
||||
}
|
||||
|
||||
static void gst_mpeg2enc_base_init (GstMpeg2encClass *klass);
|
||||
static void gst_mpeg2enc_class_init (GstMpeg2encClass *klass);
|
||||
static void gst_mpeg2enc_init (GstMpeg2enc *enc);
|
||||
static void gst_mpeg2enc_dispose (GObject *object);
|
||||
static void gst_mpeg2enc_base_init (GstMpeg2encClass * klass);
|
||||
static void gst_mpeg2enc_class_init (GstMpeg2encClass * klass);
|
||||
static void gst_mpeg2enc_init (GstMpeg2enc * enc);
|
||||
static void gst_mpeg2enc_dispose (GObject * object);
|
||||
|
||||
static void gst_mpeg2enc_loop (GstElement *element);
|
||||
static void gst_mpeg2enc_loop (GstElement * element);
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_mpeg2enc_sink_link (GstPad *pad,
|
||||
const GstCaps *caps);
|
||||
gst_mpeg2enc_sink_link (GstPad * pad, const GstCaps * caps);
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_mpeg2enc_change_state (GstElement *element);
|
||||
static GstElementStateReturn gst_mpeg2enc_change_state (GstElement * element);
|
||||
|
||||
static void gst_mpeg2enc_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gst_mpeg2enc_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gst_mpeg2enc_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
static void gst_mpeg2enc_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
|
@ -141,16 +133,14 @@ gst_mpeg2enc_get_type (void)
|
|||
|
||||
gst_mpeg2enc_type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT,
|
||||
"GstMpeg2enc",
|
||||
&gst_mpeg2enc_info,
|
||||
(GTypeFlags) 0);
|
||||
"GstMpeg2enc", &gst_mpeg2enc_info, (GTypeFlags) 0);
|
||||
}
|
||||
|
||||
return gst_mpeg2enc_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_base_init (GstMpeg2encClass *klass)
|
||||
gst_mpeg2enc_base_init (GstMpeg2encClass * klass)
|
||||
{
|
||||
static GstElementDetails gst_mpeg2enc_details = {
|
||||
"mpeg2enc video encoder",
|
||||
|
@ -163,12 +153,11 @@ gst_mpeg2enc_base_init (GstMpeg2encClass *klass)
|
|||
|
||||
gst_element_class_add_pad_template (element_class, src_templ ());
|
||||
gst_element_class_add_pad_template (element_class, sink_templ ());
|
||||
gst_element_class_set_details (element_class,
|
||||
&gst_mpeg2enc_details);
|
||||
gst_element_class_set_details (element_class, &gst_mpeg2enc_details);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_class_init (GstMpeg2encClass *klass)
|
||||
gst_mpeg2enc_class_init (GstMpeg2encClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
@ -188,32 +177,35 @@ gst_mpeg2enc_class_init (GstMpeg2encClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_dispose (GObject *object)
|
||||
gst_mpeg2enc_dispose (GObject * object)
|
||||
{
|
||||
GstMpeg2enc *enc = GST_MPEG2ENC (object);
|
||||
|
||||
if (enc->encoder) {
|
||||
delete enc->encoder;
|
||||
|
||||
enc->encoder = NULL;
|
||||
}
|
||||
delete enc->options;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_init (GstMpeg2enc *enc)
|
||||
gst_mpeg2enc_init (GstMpeg2enc * enc)
|
||||
{
|
||||
GstElement *element = GST_ELEMENT (enc);
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
||||
|
||||
GST_FLAG_SET (element, GST_ELEMENT_EVENT_AWARE);
|
||||
|
||||
enc->sinkpad = gst_pad_new_from_template (
|
||||
gst_element_class_get_pad_template (klass, "sink"), "sink");
|
||||
enc->sinkpad =
|
||||
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
||||
"sink"), "sink");
|
||||
gst_pad_set_link_function (enc->sinkpad, gst_mpeg2enc_sink_link);
|
||||
gst_element_add_pad (element, enc->sinkpad);
|
||||
|
||||
enc->srcpad = gst_pad_new_from_template (
|
||||
gst_element_class_get_pad_template (klass, "src"), "src");
|
||||
enc->srcpad =
|
||||
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
||||
"src"), "src");
|
||||
gst_pad_use_explicit_caps (enc->srcpad);
|
||||
gst_element_add_pad (element, enc->srcpad);
|
||||
|
||||
|
@ -225,7 +217,7 @@ gst_mpeg2enc_init (GstMpeg2enc *enc)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_loop (GstElement *element)
|
||||
gst_mpeg2enc_loop (GstElement * element)
|
||||
{
|
||||
GstMpeg2enc *enc = GST_MPEG2ENC (element);
|
||||
|
||||
|
@ -253,6 +245,7 @@ gst_mpeg2enc_loop (GstElement *element)
|
|||
if (gst_pad_set_explicit_caps (enc->srcpad, othercaps) <= 0) {
|
||||
GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL), (NULL));
|
||||
delete enc->encoder;
|
||||
|
||||
enc->encoder = NULL;
|
||||
return;
|
||||
}
|
||||
|
@ -263,8 +256,7 @@ gst_mpeg2enc_loop (GstElement *element)
|
|||
}
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_mpeg2enc_sink_link (GstPad *pad,
|
||||
const GstCaps *caps)
|
||||
gst_mpeg2enc_sink_link (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
GstMpeg2enc *enc = GST_MPEG2ENC (gst_pad_get_parent (pad));
|
||||
|
||||
|
@ -273,6 +265,7 @@ gst_mpeg2enc_sink_link (GstPad *pad,
|
|||
|
||||
if (enc->encoder) {
|
||||
delete enc->encoder;
|
||||
|
||||
enc->encoder = NULL;
|
||||
}
|
||||
|
||||
|
@ -280,25 +273,21 @@ gst_mpeg2enc_sink_link (GstPad *pad,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gst_mpeg2enc_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GST_MPEG2ENC (object)->options->getProperty (prop_id, value);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mpeg2enc_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gst_mpeg2enc_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GST_MPEG2ENC (object)->options->setProperty (prop_id, value);
|
||||
}
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_mpeg2enc_change_state (GstElement *element)
|
||||
gst_mpeg2enc_change_state (GstElement * element)
|
||||
{
|
||||
GstMpeg2enc *enc = GST_MPEG2ENC (element);
|
||||
|
||||
|
@ -318,21 +307,14 @@ gst_mpeg2enc_change_state (GstElement *element)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin *plugin)
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
return gst_element_register (plugin, "mpeg2enc",
|
||||
GST_RANK_NONE,
|
||||
GST_TYPE_MPEG2ENC);
|
||||
GST_RANK_NONE, GST_TYPE_MPEG2ENC);
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (
|
||||
GST_VERSION_MAJOR,
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"mpeg2enc",
|
||||
"High-quality MPEG-1/2 video encoder",
|
||||
plugin_init,
|
||||
VERSION,
|
||||
"GPL",
|
||||
GST_PACKAGE,
|
||||
GST_ORIGIN
|
||||
)
|
||||
plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
|
||||
|
|
|
@ -35,11 +35,9 @@
|
|||
* Class init stuff.
|
||||
*/
|
||||
|
||||
GstMpeg2Encoder::GstMpeg2Encoder (GstMpeg2EncOptions *options,
|
||||
GstPad *sinkpad,
|
||||
const GstCaps *caps,
|
||||
GstPad *srcpad) :
|
||||
MPEG2Encoder (*options)
|
||||
GstMpeg2Encoder::GstMpeg2Encoder (GstMpeg2EncOptions * options,
|
||||
GstPad * sinkpad, const GstCaps * caps, GstPad * srcpad):
|
||||
MPEG2Encoder (*options)
|
||||
{
|
||||
MPEG2EncInVidParams strm;
|
||||
|
||||
|
@ -90,6 +88,5 @@ GstMpeg2Encoder::getFormat ()
|
|||
"mpegversion", G_TYPE_INT, options.mpeg,
|
||||
"width", G_TYPE_INT, options.in_img_width,
|
||||
"height", G_TYPE_INT, options.in_img_height,
|
||||
"framerate", G_TYPE_DOUBLE, fps,
|
||||
NULL);
|
||||
"framerate", G_TYPE_DOUBLE, fps, NULL);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
* Property enumeration.
|
||||
*/
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ARG_0,
|
||||
ARG_FORMAT,
|
||||
ARG_FRAMERATE,
|
||||
|
@ -81,22 +82,21 @@ gst_mpeg2enc_format_get_type (void)
|
|||
|
||||
if (!mpeg2enc_format_type) {
|
||||
static const GEnumValue mpeg2enc_formats[] = {
|
||||
{ 0, "0", "Generic MPEG-1" },
|
||||
{ 1, "1", "Standard VCD" },
|
||||
{ 2, "2", "User VCD" },
|
||||
{ 3, "3", "Generic MPEG-2" },
|
||||
{ 4, "4", "Standard SVCD" },
|
||||
{ 5, "5", "User SVCD" },
|
||||
{ 6, "6", "VCD Stills sequences" },
|
||||
{ 7, "7", "SVCD Stills sequences" },
|
||||
{ 8, "8", "DVD MPEG-2 for dvdauthor" },
|
||||
{ 9, "9", "DVD MPEG-2" },
|
||||
{ 0, NULL, NULL },
|
||||
{0, "0", "Generic MPEG-1"},
|
||||
{1, "1", "Standard VCD"},
|
||||
{2, "2", "User VCD"},
|
||||
{3, "3", "Generic MPEG-2"},
|
||||
{4, "4", "Standard SVCD"},
|
||||
{5, "5", "User SVCD"},
|
||||
{6, "6", "VCD Stills sequences"},
|
||||
{7, "7", "SVCD Stills sequences"},
|
||||
{8, "8", "DVD MPEG-2 for dvdauthor"},
|
||||
{9, "9", "DVD MPEG-2"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_format_type =
|
||||
g_enum_register_static ("GstMpeg2encFormat",
|
||||
mpeg2enc_formats);
|
||||
g_enum_register_static ("GstMpeg2encFormat", mpeg2enc_formats);
|
||||
}
|
||||
|
||||
return mpeg2enc_format_type;
|
||||
|
@ -112,21 +112,20 @@ gst_mpeg2enc_framerate_get_type (void)
|
|||
|
||||
if (!mpeg2enc_framerate_type) {
|
||||
static const GEnumValue mpeg2enc_framerates[] = {
|
||||
{ 0, "0", "Same as input" },
|
||||
{ 1, "1", "24/1.001 (NTSC 3:2 pulldown converted film)" },
|
||||
{ 2, "2", "24 (native film)" },
|
||||
{ 3, "3", "25 (PAL/SECAM video)" },
|
||||
{ 4, "4", "30/1.001 (NTSC video)" },
|
||||
{ 5, "5", "30" },
|
||||
{ 6, "6", "50 (PAL/SECAM fields)" },
|
||||
{ 7, "7", "60/1.001 (NTSC fields)" },
|
||||
{ 8, "8", "60" },
|
||||
{ 0, NULL, NULL },
|
||||
{0, "0", "Same as input"},
|
||||
{1, "1", "24/1.001 (NTSC 3:2 pulldown converted film)"},
|
||||
{2, "2", "24 (native film)"},
|
||||
{3, "3", "25 (PAL/SECAM video)"},
|
||||
{4, "4", "30/1.001 (NTSC video)"},
|
||||
{5, "5", "30"},
|
||||
{6, "6", "50 (PAL/SECAM fields)"},
|
||||
{7, "7", "60/1.001 (NTSC fields)"},
|
||||
{8, "8", "60"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_framerate_type =
|
||||
g_enum_register_static ("GstMpeg2encFramerate",
|
||||
mpeg2enc_framerates);
|
||||
g_enum_register_static ("GstMpeg2encFramerate", mpeg2enc_framerates);
|
||||
}
|
||||
|
||||
return mpeg2enc_framerate_type;
|
||||
|
@ -142,17 +141,16 @@ gst_mpeg2enc_aspect_get_type (void)
|
|||
|
||||
if (!mpeg2enc_aspect_type) {
|
||||
static const GEnumValue mpeg2enc_aspects[] = {
|
||||
{ 0, "0", "Deduce from input" },
|
||||
{ 1, "1", "1:1" },
|
||||
{ 2, "2", "4:3" },
|
||||
{ 3, "3", "16:9" },
|
||||
{ 4, "4", "2.21:1" },
|
||||
{ 0, NULL, NULL },
|
||||
{0, "0", "Deduce from input"},
|
||||
{1, "1", "1:1"},
|
||||
{2, "2", "4:3"},
|
||||
{3, "3", "16:9"},
|
||||
{4, "4", "2.21:1"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_aspect_type =
|
||||
g_enum_register_static ("GstMpeg2encAspect",
|
||||
mpeg2enc_aspects);
|
||||
g_enum_register_static ("GstMpeg2encAspect", mpeg2enc_aspects);
|
||||
}
|
||||
|
||||
return mpeg2enc_aspect_type;
|
||||
|
@ -168,11 +166,11 @@ gst_mpeg2enc_interlace_mode_get_type (void)
|
|||
|
||||
if (!mpeg2enc_interlace_mode_type) {
|
||||
static const GEnumValue mpeg2enc_interlace_modes[] = {
|
||||
{ -1, "-1", "Format default mode" },
|
||||
{ 0, "0", "Progressive" },
|
||||
{ 1, "1", "Interlaced, per-frame encoding" },
|
||||
{ 2, "2", "Interlaced, per-field-encoding" },
|
||||
{ 0, NULL, NULL },
|
||||
{-1, "-1", "Format default mode"},
|
||||
{0, "0", "Progressive"},
|
||||
{1, "1", "Interlaced, per-frame encoding"},
|
||||
{2, "2", "Interlaced, per-field-encoding"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_interlace_mode_type =
|
||||
|
@ -198,15 +196,15 @@ gst_mpeg2enc_quantisation_matrix_get_type (void)
|
|||
|
||||
if (!mpeg2enc_quantisation_matrix_type) {
|
||||
static const GEnumValue mpeg2enc_quantisation_matrixes[] = {
|
||||
{ GST_MPEG2ENC_QUANTISATION_MATRIX_DEFAULT,
|
||||
"0", "Default" },
|
||||
{ GST_MPEG2ENC_QUANTISATION_MATRIX_HI_RES,
|
||||
"1", "High resolution" },
|
||||
{ GST_MPEG2ENC_QUANTISATION_MATRIX_KVCD,
|
||||
"2", "KVCD" },
|
||||
{ GST_MPEG2ENC_QUANTISATION_MATRIX_TMPGENC,
|
||||
"3", "TMPGEnc" },
|
||||
{ 0, NULL, NULL },
|
||||
{GST_MPEG2ENC_QUANTISATION_MATRIX_DEFAULT,
|
||||
"0", "Default"},
|
||||
{GST_MPEG2ENC_QUANTISATION_MATRIX_HI_RES,
|
||||
"1", "High resolution"},
|
||||
{GST_MPEG2ENC_QUANTISATION_MATRIX_KVCD,
|
||||
"2", "KVCD"},
|
||||
{GST_MPEG2ENC_QUANTISATION_MATRIX_TMPGENC,
|
||||
"3", "TMPGEnc"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_quantisation_matrix_type =
|
||||
|
@ -227,16 +225,15 @@ gst_mpeg2enc_video_norm_get_type (void)
|
|||
|
||||
if (!mpeg2enc_video_norm_type) {
|
||||
static const GEnumValue mpeg2enc_video_norms[] = {
|
||||
{ 0, "0", "Unspecified" },
|
||||
{ 'p', "p", "PAL" },
|
||||
{ 'n', "n", "NTSC" },
|
||||
{ 's', "s", "SECAM" },
|
||||
{ 0, NULL, NULL },
|
||||
{0, "0", "Unspecified"},
|
||||
{'p', "p", "PAL"},
|
||||
{'n', "n", "NTSC"},
|
||||
{'s', "s", "SECAM"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_video_norm_type =
|
||||
g_enum_register_static ("GstMpeg2encVideoNorm",
|
||||
mpeg2enc_video_norms);
|
||||
g_enum_register_static ("GstMpeg2encVideoNorm", mpeg2enc_video_norms);
|
||||
}
|
||||
|
||||
return mpeg2enc_video_norm_type;
|
||||
|
@ -252,10 +249,10 @@ gst_mpeg2enc_playback_field_order_get_type (void)
|
|||
|
||||
if (!mpeg2enc_playback_field_order_type) {
|
||||
static const GEnumValue mpeg2enc_playback_field_orders[] = {
|
||||
{ Y4M_UNKNOWN, "0", "Unspecified" },
|
||||
{ Y4M_ILACE_TOP_FIRST, "1", "Top-field first" },
|
||||
{ Y4M_ILACE_BOTTOM_FIRST, "2", "Bottom-field first" },
|
||||
{ 0, NULL, NULL },
|
||||
{Y4M_UNKNOWN, "0", "Unspecified"},
|
||||
{Y4M_ILACE_TOP_FIRST, "1", "Top-field first"},
|
||||
{Y4M_ILACE_BOTTOM_FIRST, "2", "Bottom-field first"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mpeg2enc_playback_field_order_type =
|
||||
|
@ -270,8 +267,8 @@ gst_mpeg2enc_playback_field_order_get_type (void)
|
|||
* Class init stuff.
|
||||
*/
|
||||
|
||||
GstMpeg2EncOptions::GstMpeg2EncOptions () :
|
||||
MPEG2EncOptions ()
|
||||
GstMpeg2EncOptions::GstMpeg2EncOptions ():
|
||||
MPEG2EncOptions ()
|
||||
{
|
||||
/* autodetect number of CPUs */
|
||||
num_cpus = sysconf (_SC_NPROCESSORS_ONLN);
|
||||
|
@ -286,23 +283,20 @@ GstMpeg2EncOptions::GstMpeg2EncOptions () :
|
|||
*/
|
||||
|
||||
void
|
||||
GstMpeg2EncOptions::initProperties (GObjectClass *klass)
|
||||
GstMpeg2EncOptions::initProperties (GObjectClass * klass)
|
||||
{
|
||||
/* encoding profile */
|
||||
g_object_class_install_property (klass, ARG_FORMAT,
|
||||
g_param_spec_enum ("format", "Format", "Encoding profile format",
|
||||
GST_TYPE_MPEG2ENC_FORMAT, 0,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
GST_TYPE_MPEG2ENC_FORMAT, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
/* input/output stream overrides */
|
||||
g_object_class_install_property (klass, ARG_FRAMERATE,
|
||||
g_param_spec_enum ("framerate", "Framerate", "Output framerate",
|
||||
GST_TYPE_MPEG2ENC_FRAMERATE, 0,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
GST_TYPE_MPEG2ENC_FRAMERATE, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_ASPECT,
|
||||
g_param_spec_enum ("aspect", "Aspect", "Display aspect ratio",
|
||||
GST_TYPE_MPEG2ENC_ASPECT, 0,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
GST_TYPE_MPEG2ENC_ASPECT, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_INTERLACE_MODE,
|
||||
g_param_spec_enum ("interlace-mode", "Interlace mode",
|
||||
"MPEG-2 motion estimation and encoding modes",
|
||||
|
@ -312,11 +306,11 @@ GstMpeg2EncOptions::initProperties (GObjectClass *klass)
|
|||
/* general encoding stream options */
|
||||
g_object_class_install_property (klass, ARG_BITRATE,
|
||||
g_param_spec_int ("bitrate", "Bitrate", "Compressed video bitrate (kbps)",
|
||||
0, 10*1024, 1125, (GParamFlags) G_PARAM_READWRITE));
|
||||
0, 10 * 1024, 1125, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_NONVIDEO_BITRATE,
|
||||
g_param_spec_int ("non-video-bitrate", "Non-video bitrate",
|
||||
"Assumed bitrate of non-video for sequence splitting (kbps)",
|
||||
0, 10*1024, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
0, 10 * 1024, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_QUANTISATION,
|
||||
g_param_spec_int ("quantisation", "Quantisation",
|
||||
"Quantisation factor (0=default, 1=best, 31=worst)",
|
||||
|
@ -376,13 +370,14 @@ GstMpeg2EncOptions::initProperties (GObjectClass *klass)
|
|||
"Max. quantisation reduction for highly active blocks",
|
||||
-4., 10., 0., (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_QUANT_REDUCTION_MAX_VAR,
|
||||
g_param_spec_float ("quant-reduction-max-var", "Max. quant. reduction variance",
|
||||
"Maximal luma variance below which quantisation boost is used",
|
||||
0., 2500., 0., (GParamFlags) G_PARAM_READWRITE));
|
||||
g_param_spec_float ("quant-reduction-max-var",
|
||||
"Max. quant. reduction variance",
|
||||
"Maximal luma variance below which quantisation boost is used", 0.,
|
||||
2500., 0., (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_INTRA_DC_PRECISION,
|
||||
g_param_spec_int ("intra-dc-prec", "Intra. DC precision",
|
||||
"Number of bits precision for DC (base colour) in MPEG-2 blocks",
|
||||
8, 11, 9, (GParamFlags) G_PARAM_READWRITE));
|
||||
"Number of bits precision for DC (base colour) in MPEG-2 blocks", 8,
|
||||
11, 9, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_REDUCE_HF,
|
||||
g_param_spec_float ("reduce-hf", "Reduce HF",
|
||||
"How much to reduce high-frequency resolution (by increasing quantisation)",
|
||||
|
@ -407,12 +402,11 @@ GstMpeg2EncOptions::initProperties (GObjectClass *klass)
|
|||
g_object_class_install_property (klass, ARG_VIDEO_NORM,
|
||||
g_param_spec_enum ("norm", "Norm",
|
||||
"Tag output for specific video norm",
|
||||
GST_TYPE_MPEG2ENC_VIDEO_NORM, 0,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
GST_TYPE_MPEG2ENC_VIDEO_NORM, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_SEQUENCE_LENGTH,
|
||||
g_param_spec_int ("sequence-length", "Sequence length",
|
||||
"Place a sequence boundary after each <num> MB (0=disable)",
|
||||
0, 10*1024, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
0, 10 * 1024, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
g_object_class_install_property (klass, ARG_3_2_PULLDOWN,
|
||||
g_param_spec_boolean ("pulldown-3-2", "3-2 pull down",
|
||||
"Generate header flags for 3-2 pull down 24fps movies",
|
||||
|
@ -441,9 +435,8 @@ GstMpeg2EncOptions::initProperties (GObjectClass *klass)
|
|||
"make buggy players play SVCD streams",
|
||||
TRUE, (GParamFlags) G_PARAM_READWRITE));
|
||||
#if 0
|
||||
"--dxr2-hack"
|
||||
"--dxr2-hack"
|
||||
#endif
|
||||
|
||||
/* dangerous/experimental stuff */
|
||||
g_object_class_install_property (klass, ARG_CONSTRAINTS,
|
||||
g_param_spec_boolean ("constraints", "Constraints",
|
||||
|
@ -456,8 +449,7 @@ GstMpeg2EncOptions::initProperties (GObjectClass *klass)
|
|||
*/
|
||||
|
||||
void
|
||||
GstMpeg2EncOptions::getProperty (guint prop_id,
|
||||
GValue *value)
|
||||
GstMpeg2EncOptions::getProperty (guint prop_id, GValue * value)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case ARG_FORMAT:
|
||||
|
@ -473,10 +465,10 @@ GstMpeg2EncOptions::getProperty (guint prop_id,
|
|||
g_value_set_enum (value, fieldenc);
|
||||
break;
|
||||
case ARG_BITRATE:
|
||||
g_value_set_int (value, bitrate/1024);
|
||||
g_value_set_int (value, bitrate / 1024);
|
||||
break;
|
||||
case ARG_NONVIDEO_BITRATE:
|
||||
g_value_set_int (value, nonvid_bitrate/1024);
|
||||
g_value_set_int (value, nonvid_bitrate / 1024);
|
||||
break;
|
||||
case ARG_QUANTISATION:
|
||||
g_value_set_int (value, quant);
|
||||
|
@ -578,8 +570,7 @@ GstMpeg2EncOptions::getProperty (guint prop_id,
|
|||
}
|
||||
|
||||
void
|
||||
GstMpeg2EncOptions::setProperty (guint prop_id,
|
||||
const GValue *value)
|
||||
GstMpeg2EncOptions::setProperty (guint prop_id, const GValue * value)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case ARG_FORMAT:
|
||||
|
|
|
@ -31,10 +31,9 @@
|
|||
* Class init stuff.
|
||||
*/
|
||||
|
||||
GstMpeg2EncPictureReader::GstMpeg2EncPictureReader (GstPad *in_pad,
|
||||
const GstCaps *in_caps,
|
||||
EncoderParams *params) :
|
||||
PictureReader (*params)
|
||||
GstMpeg2EncPictureReader::GstMpeg2EncPictureReader (GstPad * in_pad,
|
||||
const GstCaps * in_caps, EncoderParams * params):
|
||||
PictureReader (*params)
|
||||
{
|
||||
pad = in_pad;
|
||||
caps = gst_caps_copy (in_caps);
|
||||
|
@ -50,7 +49,7 @@ GstMpeg2EncPictureReader::~GstMpeg2EncPictureReader ()
|
|||
*/
|
||||
|
||||
void
|
||||
GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams &strm)
|
||||
GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams & strm)
|
||||
{
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
gint width, height;
|
||||
|
@ -65,8 +64,7 @@ GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams &strm)
|
|||
strm.frame_rate_code = mpeg_framerate_code (mpeg_conform_framerate (fps));
|
||||
strm.interlacing_code = Y4M_ILACE_NONE;
|
||||
strm.aspect_ratio_code = mpeg_guess_mpeg_aspect_code (2, y4m_sar_SQUARE,
|
||||
strm.horizontal_size,
|
||||
strm.vertical_size);
|
||||
strm.horizontal_size, strm.vertical_size);
|
||||
|
||||
/* FIXME:
|
||||
* strm.interlacing_code = y4m_si_get_interlace(&si);
|
||||
|
@ -82,15 +80,24 @@ GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams &strm)
|
|||
* Read a frame. Return true means EOS or error.
|
||||
*/
|
||||
|
||||
bool
|
||||
GstMpeg2EncPictureReader::LoadFrame ()
|
||||
bool GstMpeg2EncPictureReader::LoadFrame ()
|
||||
{
|
||||
GstData *data;
|
||||
GstBuffer *buf = NULL;
|
||||
gint i, x, y, n;
|
||||
guint8 *frame;
|
||||
GstFormat fmt = GST_FORMAT_DEFAULT;
|
||||
gint64 pos = 0, tot = 0;
|
||||
GstData *
|
||||
data;
|
||||
GstBuffer *
|
||||
buf = NULL;
|
||||
gint
|
||||
i,
|
||||
x,
|
||||
y,
|
||||
n;
|
||||
guint8 *
|
||||
frame;
|
||||
GstFormat
|
||||
fmt = GST_FORMAT_DEFAULT;
|
||||
gint64
|
||||
pos = 0, tot = 0;
|
||||
|
||||
gst_pad_query (GST_PAD_PEER (pad), GST_QUERY_POSITION, &fmt, &pos);
|
||||
gst_pad_query (GST_PAD_PEER (pad), GST_QUERY_TOTAL, &fmt, &tot);
|
||||
|
||||
|
@ -121,18 +128,18 @@ GstMpeg2EncPictureReader::LoadFrame ()
|
|||
y = encparams.vertical_size;
|
||||
|
||||
for (i = 0; i < y; i++) {
|
||||
memcpy (input_imgs_buf[n][0]+i*encparams.phy_width, frame, x);
|
||||
memcpy (input_imgs_buf[n][0] + i * encparams.phy_width, frame, x);
|
||||
frame += x;
|
||||
}
|
||||
lum_mean[n] = LumMean (input_imgs_buf[n][0]);
|
||||
x >>= 1;
|
||||
y >>= 1;
|
||||
for (i = 0; i < y; i++) {
|
||||
memcpy (input_imgs_buf[n][1]+i*encparams.phy_chrom_width, frame, x);
|
||||
memcpy (input_imgs_buf[n][1] + i * encparams.phy_chrom_width, frame, x);
|
||||
frame += x;
|
||||
}
|
||||
for (i = 0; i < y; i++) {
|
||||
memcpy (input_imgs_buf[n][2]+i*encparams.phy_chrom_width, frame, x);
|
||||
memcpy (input_imgs_buf[n][2] + i * encparams.phy_chrom_width, frame, x);
|
||||
frame += x;
|
||||
}
|
||||
gst_buffer_unref (buf);
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
* Class init stuff.
|
||||
*/
|
||||
|
||||
GstMpeg2EncStreamWriter::GstMpeg2EncStreamWriter (GstPad *in_pad,
|
||||
EncoderParams *params) :
|
||||
ElemStrmWriter (*params)
|
||||
GstMpeg2EncStreamWriter::GstMpeg2EncStreamWriter (GstPad * in_pad, EncoderParams * params):
|
||||
ElemStrmWriter (*params)
|
||||
{
|
||||
pad = in_pad;
|
||||
buf = NULL;
|
||||
|
@ -44,8 +43,7 @@ GstMpeg2EncStreamWriter::GstMpeg2EncStreamWriter (GstPad *in_pad,
|
|||
*/
|
||||
|
||||
void
|
||||
GstMpeg2EncStreamWriter::PutBits (guint32 val,
|
||||
gint n)
|
||||
GstMpeg2EncStreamWriter::PutBits (guint32 val, gint n)
|
||||
{
|
||||
/* only relevant bits. Note that (according to Andrew),
|
||||
* some CPUs do bitshifts modulo wordsize (32), which
|
||||
|
@ -62,7 +60,7 @@ GstMpeg2EncStreamWriter::PutBits (guint32 val,
|
|||
GST_BUFFER_SIZE (buf) = 0;
|
||||
}
|
||||
|
||||
outbfr = (outbfr << outcnt ) | (val >> (n - outcnt));
|
||||
outbfr = (outbfr << outcnt) | (val >> (n - outcnt));
|
||||
GST_BUFFER_DATA (buf)[GST_BUFFER_SIZE (buf)++] = outbfr;
|
||||
n -= outcnt;
|
||||
outcnt = 8;
|
||||
|
|
|
@ -28,36 +28,25 @@
|
|||
#include "gstmplexibitstream.hh"
|
||||
#include "gstmplexjob.hh"
|
||||
|
||||
static GstStaticPadTemplate src_templ =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"src",
|
||||
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
"video/mpeg, "
|
||||
"systemstream = (boolean) true"
|
||||
)
|
||||
);
|
||||
GST_STATIC_CAPS ("video/mpeg, " "systemstream = (boolean) true")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate video_sink_templ =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"video_%d",
|
||||
GST_STATIC_PAD_TEMPLATE ("video_%d",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_REQUEST,
|
||||
GST_STATIC_CAPS (
|
||||
"video/mpeg, "
|
||||
"mpegversion = (int) [ 1, 2 ], "
|
||||
"systemstream = (boolean) false"
|
||||
)
|
||||
);
|
||||
GST_STATIC_CAPS ("video/mpeg, "
|
||||
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate audio_sink_templ =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"audio_%d",
|
||||
GST_STATIC_PAD_TEMPLATE ("audio_%d",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_REQUEST,
|
||||
GST_STATIC_CAPS (
|
||||
"audio/mpeg, "
|
||||
GST_STATIC_CAPS ("audio/mpeg, "
|
||||
"mpegversion = (int) 1, "
|
||||
"layer = (int) [ 1, 2 ]; "
|
||||
"audio/x-ac3; "
|
||||
|
@ -67,35 +56,27 @@ GST_STATIC_PAD_TEMPLATE (
|
|||
"signed = (boolean) TRUE, "
|
||||
"width = (int) { 16, 20, 24 }, "
|
||||
"depth = (int) { 16, 20, 24 }, "
|
||||
"rate = (int) { 48000, 96000 }, "
|
||||
"channels = (int) [ 1, 6 ]"
|
||||
)
|
||||
);
|
||||
"rate = (int) { 48000, 96000 }, " "channels = (int) [ 1, 6 ]")
|
||||
);
|
||||
|
||||
/* FIXME: subtitles */
|
||||
|
||||
static void gst_mplex_base_init (GstMplexClass *klass);
|
||||
static void gst_mplex_class_init (GstMplexClass *klass);
|
||||
static void gst_mplex_init (GstMplex *enc);
|
||||
static void gst_mplex_dispose (GObject *object);
|
||||
static void gst_mplex_base_init (GstMplexClass * klass);
|
||||
static void gst_mplex_class_init (GstMplexClass * klass);
|
||||
static void gst_mplex_init (GstMplex * enc);
|
||||
static void gst_mplex_dispose (GObject * object);
|
||||
|
||||
static void gst_mplex_loop (GstElement *element);
|
||||
static void gst_mplex_loop (GstElement * element);
|
||||
|
||||
static GstPad *gst_mplex_request_new_pad (GstElement *element,
|
||||
GstPadTemplate *templ,
|
||||
const gchar *name);
|
||||
static GstPad *gst_mplex_request_new_pad (GstElement * element,
|
||||
GstPadTemplate * templ, const gchar * name);
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_mplex_change_state (GstElement *element);
|
||||
static GstElementStateReturn gst_mplex_change_state (GstElement * element);
|
||||
|
||||
static void gst_mplex_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gst_mplex_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gst_mplex_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
static void gst_mplex_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
|
@ -119,16 +100,14 @@ gst_mplex_get_type (void)
|
|||
|
||||
gst_mplex_type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT,
|
||||
"GstMplex",
|
||||
&gst_mplex_info,
|
||||
(GTypeFlags) 0);
|
||||
"GstMplex", &gst_mplex_info, (GTypeFlags) 0);
|
||||
}
|
||||
|
||||
return gst_mplex_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mplex_base_init (GstMplexClass *klass)
|
||||
gst_mplex_base_init (GstMplexClass * klass)
|
||||
{
|
||||
static GstElementDetails gst_mplex_details = {
|
||||
"mplex video multiplexer",
|
||||
|
@ -145,12 +124,11 @@ gst_mplex_base_init (GstMplexClass *klass)
|
|||
gst_static_pad_template_get (&video_sink_templ));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&audio_sink_templ));
|
||||
gst_element_class_set_details (element_class,
|
||||
&gst_mplex_details);
|
||||
gst_element_class_set_details (element_class, &gst_mplex_details);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mplex_class_init (GstMplexClass *klass)
|
||||
gst_mplex_class_init (GstMplexClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
@ -171,26 +149,28 @@ gst_mplex_class_init (GstMplexClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_mplex_dispose (GObject *object)
|
||||
gst_mplex_dispose (GObject * object)
|
||||
{
|
||||
GstMplex *mplex = GST_MPLEX (object);
|
||||
|
||||
if (mplex->mux) {
|
||||
delete mplex->mux;
|
||||
|
||||
mplex->mux = NULL;
|
||||
}
|
||||
delete mplex->job;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mplex_init (GstMplex *mplex)
|
||||
gst_mplex_init (GstMplex * mplex)
|
||||
{
|
||||
GstElement *element = GST_ELEMENT (mplex);
|
||||
|
||||
GST_FLAG_SET (element, GST_ELEMENT_EVENT_AWARE);
|
||||
|
||||
mplex->srcpad = gst_pad_new_from_template (
|
||||
gst_element_get_pad_template (element, "src"), "src");
|
||||
mplex->srcpad =
|
||||
gst_pad_new_from_template (gst_element_get_pad_template (element, "src"),
|
||||
"src");
|
||||
gst_element_add_pad (element, mplex->srcpad);
|
||||
|
||||
mplex->job = new GstMplexJob ();
|
||||
|
@ -202,7 +182,7 @@ gst_mplex_init (GstMplex *mplex)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_mplex_loop (GstElement *element)
|
||||
gst_mplex_loop (GstElement * element)
|
||||
{
|
||||
GstMplex *mplex = GST_MPLEX (element);
|
||||
|
||||
|
@ -230,6 +210,7 @@ gst_mplex_loop (GstElement *element)
|
|||
/* skip unnegotiated pads */
|
||||
if (!(caps = GST_PAD_CAPS (pad))) {
|
||||
delete inputstream;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -271,6 +252,7 @@ gst_mplex_loop (GstElement *element)
|
|||
mplex->job->lpcm_tracks++;
|
||||
} else {
|
||||
delete inputstream;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -293,8 +275,7 @@ gst_mplex_loop (GstElement *element)
|
|||
}
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_mplex_sink_link (GstPad *pad,
|
||||
const GstCaps *caps)
|
||||
gst_mplex_sink_link (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
const gchar *mime = gst_structure_get_name (structure);
|
||||
|
@ -318,9 +299,8 @@ gst_mplex_sink_link (GstPad *pad,
|
|||
}
|
||||
|
||||
static GstPad *
|
||||
gst_mplex_request_new_pad (GstElement *element,
|
||||
GstPadTemplate *templ,
|
||||
const gchar *name)
|
||||
gst_mplex_request_new_pad (GstElement * element,
|
||||
GstPadTemplate * templ, const gchar * name)
|
||||
{
|
||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
||||
GstMplex *mplex = GST_MPLEX (element);
|
||||
|
@ -345,25 +325,21 @@ gst_mplex_request_new_pad (GstElement *element,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_mplex_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gst_mplex_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GST_MPLEX (object)->job->getProperty (prop_id, value);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mplex_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gst_mplex_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GST_MPLEX (object)->job->setProperty (prop_id, value);
|
||||
}
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_mplex_change_state (GstElement *element)
|
||||
gst_mplex_change_state (GstElement * element)
|
||||
{
|
||||
GstMplex *mplex = GST_MPLEX (element);
|
||||
|
||||
|
@ -385,24 +361,16 @@ gst_mplex_change_state (GstElement *element)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin *plugin)
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
if (!gst_library_load ("gstbytestream"))
|
||||
return FALSE;
|
||||
|
||||
return gst_element_register (plugin, "mplex",
|
||||
GST_RANK_NONE,
|
||||
GST_TYPE_MPLEX);
|
||||
return gst_element_register (plugin, "mplex", GST_RANK_NONE, GST_TYPE_MPLEX);
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (
|
||||
GST_VERSION_MAJOR,
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"mplex",
|
||||
"High-quality MPEG/DVD/SVCD/VCD video/audio multiplexer",
|
||||
plugin_init,
|
||||
VERSION,
|
||||
"GPL",
|
||||
GST_PACKAGE,
|
||||
GST_ORIGIN
|
||||
)
|
||||
plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
* Class init/exit functions.
|
||||
*/
|
||||
|
||||
GstMplexIBitStream::GstMplexIBitStream (GstPad *_pad,
|
||||
guint buf_size) :
|
||||
IBitStream ()
|
||||
GstMplexIBitStream::GstMplexIBitStream (GstPad * _pad, guint buf_size):
|
||||
IBitStream ()
|
||||
{
|
||||
guint8 *data;
|
||||
|
||||
|
@ -54,8 +53,7 @@ GstMplexIBitStream::GstMplexIBitStream (GstPad *_pad,
|
|||
|
||||
if (!ReadIntoBuffer () && buffered == 0) {
|
||||
GST_ELEMENT_ERROR (gst_pad_get_parent (_pad), RESOURCE, READ, (NULL),
|
||||
("Failed to read from input pad %s",
|
||||
gst_pad_get_name (pad)));
|
||||
("Failed to read from input pad %s", gst_pad_get_name (pad)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,19 +66,21 @@ GstMplexIBitStream::~GstMplexIBitStream (void)
|
|||
* Read data.
|
||||
*/
|
||||
|
||||
size_t
|
||||
GstMplexIBitStream::ReadStreamBytes (uint8_t *buf,
|
||||
size_t size)
|
||||
size_t GstMplexIBitStream::ReadStreamBytes (uint8_t * buf, size_t size)
|
||||
{
|
||||
guint8 *data;
|
||||
guint read;
|
||||
guint8 *
|
||||
data;
|
||||
guint
|
||||
read;
|
||||
|
||||
if (eos)
|
||||
return 0;
|
||||
|
||||
if ((read = gst_bytestream_peek_bytes (bs, &data, size)) != size) {
|
||||
GstEvent *event;
|
||||
guint pending;
|
||||
GstEvent *
|
||||
event;
|
||||
guint
|
||||
pending;
|
||||
|
||||
gst_bytestream_get_status (bs, &pending, &event);
|
||||
if (event) {
|
||||
|
@ -105,8 +105,7 @@ GstMplexIBitStream::ReadStreamBytes (uint8_t *buf,
|
|||
* Are we at EOS?
|
||||
*/
|
||||
|
||||
bool
|
||||
GstMplexIBitStream::EndOfStream (void)
|
||||
bool GstMplexIBitStream::EndOfStream (void)
|
||||
{
|
||||
return eos;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#include "gstmplexjob.hh"
|
||||
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ARG_0,
|
||||
ARG_FORMAT,
|
||||
ARG_MUX_BITRATE,
|
||||
|
@ -53,22 +54,21 @@ gst_mplex_format_get_type (void)
|
|||
|
||||
if (!mplex_format_type) {
|
||||
static const GEnumValue mplex_formats[] = {
|
||||
{ 0, "0", "Generic MPEG-1" },
|
||||
{ 1, "1", "Standard VCD" },
|
||||
{ 2, "2", "User VCD" },
|
||||
{ 3, "3", "Generic MPEG-2" },
|
||||
{ 4, "4", "Standard SVCD" },
|
||||
{ 5, "5", "User SVCD" },
|
||||
{ 6, "6", "VCD Stills sequences" },
|
||||
{ 7, "7", "SVCD Stills sequences" },
|
||||
{ 8, "8", "DVD MPEG-2 for dvdauthor" },
|
||||
{ 9, "9", "DVD MPEG-2" },
|
||||
{ 0, NULL, NULL },
|
||||
{0, "0", "Generic MPEG-1"},
|
||||
{1, "1", "Standard VCD"},
|
||||
{2, "2", "User VCD"},
|
||||
{3, "3", "Generic MPEG-2"},
|
||||
{4, "4", "Standard SVCD"},
|
||||
{5, "5", "User SVCD"},
|
||||
{6, "6", "VCD Stills sequences"},
|
||||
{7, "7", "SVCD Stills sequences"},
|
||||
{8, "8", "DVD MPEG-2 for dvdauthor"},
|
||||
{9, "9", "DVD MPEG-2"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
mplex_format_type =
|
||||
g_enum_register_static ("GstMplexFormat",
|
||||
mplex_formats);
|
||||
g_enum_register_static ("GstMplexFormat", mplex_formats);
|
||||
}
|
||||
|
||||
return mplex_format_type;
|
||||
|
@ -78,8 +78,8 @@ gst_mplex_format_get_type (void)
|
|||
* Class init functions.
|
||||
*/
|
||||
|
||||
GstMplexJob::GstMplexJob (void) :
|
||||
MultiplexJob ()
|
||||
GstMplexJob::GstMplexJob (void):
|
||||
MultiplexJob ()
|
||||
{
|
||||
/* blabla */
|
||||
}
|
||||
|
@ -89,13 +89,12 @@ GstMplexJob::GstMplexJob (void) :
|
|||
*/
|
||||
|
||||
void
|
||||
GstMplexJob::initProperties (GObjectClass *klass)
|
||||
GstMplexJob::initProperties (GObjectClass * klass)
|
||||
{
|
||||
/* encoding profile */
|
||||
g_object_class_install_property (klass, ARG_FORMAT,
|
||||
g_param_spec_enum ("format", "Format", "Encoding profile format",
|
||||
GST_TYPE_MPLEX_FORMAT, 0,
|
||||
(GParamFlags) G_PARAM_READWRITE));
|
||||
GST_TYPE_MPLEX_FORMAT, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
/* total stream datarate. Normally, this shouldn't be needed, but
|
||||
* some DVD/VCD/SVCD players really need strict values to handle
|
||||
|
@ -106,9 +105,9 @@ GstMplexJob::initProperties (GObjectClass *klass)
|
|||
0, 15 * 1024, 0, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
#if 0
|
||||
{ "video-buffer", 1, 0, 'b' },
|
||||
{
|
||||
"video-buffer", 1, 0, 'b'},
|
||||
#endif
|
||||
|
||||
/* some boolean stuff for headers */
|
||||
g_object_class_install_property (klass, ARG_VBR,
|
||||
g_param_spec_boolean ("vbr", "VBR",
|
||||
|
@ -148,8 +147,7 @@ GstMplexJob::initProperties (GObjectClass *klass)
|
|||
*/
|
||||
|
||||
void
|
||||
GstMplexJob::getProperty (guint prop_id,
|
||||
GValue *value)
|
||||
GstMplexJob::getProperty (guint prop_id, GValue * value)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case ARG_FORMAT:
|
||||
|
@ -182,8 +180,7 @@ GstMplexJob::getProperty (guint prop_id,
|
|||
}
|
||||
|
||||
void
|
||||
GstMplexJob::setProperty (guint prop_id,
|
||||
const GValue *value)
|
||||
GstMplexJob::setProperty (guint prop_id, const GValue * value)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case ARG_FORMAT:
|
||||
|
@ -193,7 +190,7 @@ GstMplexJob::setProperty (guint prop_id,
|
|||
/* data_rate expects bytes (don't ask me why the property itself is
|
||||
* in bits, I'm just staying compatible to mjpegtools options), and
|
||||
* rounded up to 50-bytes. */
|
||||
data_rate = ((g_value_get_int (value) * 1000 / 8 + 49) / 50 ) * 50;
|
||||
data_rate = ((g_value_get_int (value) * 1000 / 8 + 49) / 50) * 50;
|
||||
break;
|
||||
case ARG_VBR:
|
||||
VBR = g_value_get_boolean (value);
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
* Class init functions.
|
||||
*/
|
||||
|
||||
GstMplexOutputStream::GstMplexOutputStream (GstElement *_element,
|
||||
GstPad *_pad) :
|
||||
OutputStream ()
|
||||
GstMplexOutputStream::GstMplexOutputStream (GstElement * _element, GstPad * _pad):
|
||||
OutputStream ()
|
||||
{
|
||||
element = _element;
|
||||
pad = _pad;
|
||||
|
@ -63,8 +62,7 @@ GstMplexOutputStream::Close (void)
|
|||
* Get size of current segment.
|
||||
*/
|
||||
|
||||
off_t
|
||||
GstMplexOutputStream::SegmentSize (void)
|
||||
off_t GstMplexOutputStream::SegmentSize (void)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
@ -88,8 +86,7 @@ GstMplexOutputStream::NextSegment (void)
|
|||
*/
|
||||
|
||||
void
|
||||
GstMplexOutputStream::Write (guint8 *data,
|
||||
guint len)
|
||||
GstMplexOutputStream::Write (guint8 * data, guint len)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
|
||||
|
|
|
@ -48,12 +48,14 @@ GstElementDetails modplug_details = {
|
|||
|
||||
|
||||
/* Filter signals and args */
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ARG_0,
|
||||
ARG_SONGNAME,
|
||||
ARG_REVERB,
|
||||
|
@ -70,95 +72,76 @@ enum {
|
|||
};
|
||||
|
||||
static GstStaticPadTemplate modplug_src_template_factory =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"src",
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
"audio/x-raw-int, "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"signed = (boolean) TRUE, "
|
||||
"width = (int) 16, "
|
||||
"depth = (int) 16, "
|
||||
"rate = (int) { 8000, 11025, 22050, 44100 }, " /* FIXME? */
|
||||
"channels = (int) [ 1, 2 ]; "
|
||||
"audio/x-raw-int, "
|
||||
"signed = (boolean) FALSE, "
|
||||
"width = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
"rate = (int) { 8000, 11025, 22050, 44100 }, " /* FIXME? */
|
||||
"channels = (int) [ 1, 2 ]"
|
||||
)
|
||||
);
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16, " "rate = (int) { 8000, 11025, 22050, 44100 }, " /* FIXME? */
|
||||
"channels = (int) [ 1, 2 ]; " "audio/x-raw-int, " "signed = (boolean) FALSE, " "width = (int) 8, " "depth = (int) 8, " "rate = (int) { 8000, 11025, 22050, 44100 }, " /* FIXME? */
|
||||
"channels = (int) [ 1, 2 ]")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate modplug_sink_template_factory =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"sink",
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-mod")
|
||||
);
|
||||
);
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
MODPLUG_STATE_NEED_TUNE = 1,
|
||||
MODPLUG_STATE_LOAD_TUNE = 2,
|
||||
MODPLUG_STATE_PLAY_TUNE = 3,
|
||||
};
|
||||
|
||||
static void gst_modplug_base_init (GstModPlugClass *klass);
|
||||
static void gst_modplug_class_init (GstModPlugClass *klass);
|
||||
static void gst_modplug_init (GstModPlug *filter);
|
||||
static void gst_modplug_set_property (GObject *object,
|
||||
guint id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec );
|
||||
static void gst_modplug_get_property (GObject *object,
|
||||
guint id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec );
|
||||
static void gst_modplug_base_init (GstModPlugClass * klass);
|
||||
static void gst_modplug_class_init (GstModPlugClass * klass);
|
||||
static void gst_modplug_init (GstModPlug * filter);
|
||||
static void gst_modplug_set_property (GObject * object,
|
||||
guint id, const GValue * value, GParamSpec * pspec);
|
||||
static void gst_modplug_get_property (GObject * object,
|
||||
guint id, GValue * value, GParamSpec * pspec);
|
||||
static GstPadLinkReturn
|
||||
gst_modplug_srclink (GstPad *pad, const GstCaps *caps);
|
||||
static GstCaps *gst_modplug_fixate (GstPad *pad, const GstCaps *caps);
|
||||
static void gst_modplug_loop (GstElement *element);
|
||||
static void gst_modplug_setup (GstModPlug *modplug);
|
||||
static const GstFormat *
|
||||
gst_modplug_get_formats (GstPad *pad);
|
||||
static const GstQueryType *
|
||||
gst_modplug_get_query_types (GstPad *pad);
|
||||
static gboolean gst_modplug_src_event (GstPad *pad, GstEvent *event);
|
||||
static gboolean gst_modplug_src_query (GstPad *pad,
|
||||
GstQueryType type,
|
||||
GstFormat *format,
|
||||
gint64 *value);
|
||||
static GstElementStateReturn
|
||||
gst_modplug_change_state (GstElement *element);
|
||||
gst_modplug_srclink (GstPad * pad, const GstCaps * caps);
|
||||
static GstCaps *gst_modplug_fixate (GstPad * pad, const GstCaps * caps);
|
||||
static void gst_modplug_loop (GstElement * element);
|
||||
static void gst_modplug_setup (GstModPlug * modplug);
|
||||
static const GstFormat *gst_modplug_get_formats (GstPad * pad);
|
||||
static const GstQueryType *gst_modplug_get_query_types (GstPad * pad);
|
||||
static gboolean gst_modplug_src_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_modplug_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * format, gint64 * value);
|
||||
static GstElementStateReturn gst_modplug_change_state (GstElement * element);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gst_modplug_get_type(void) {
|
||||
gst_modplug_get_type (void)
|
||||
{
|
||||
static GType modplug_type = 0;
|
||||
|
||||
if (!modplug_type) {
|
||||
static const GTypeInfo modplug_info = {
|
||||
sizeof(GstModPlugClass),
|
||||
(GBaseInitFunc)gst_modplug_base_init,
|
||||
sizeof (GstModPlugClass),
|
||||
(GBaseInitFunc) gst_modplug_base_init,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_modplug_class_init,
|
||||
(GClassInitFunc) gst_modplug_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstModPlug),
|
||||
sizeof (GstModPlug),
|
||||
0,
|
||||
(GInstanceInitFunc)gst_modplug_init,
|
||||
(GInstanceInitFunc) gst_modplug_init,
|
||||
NULL
|
||||
};
|
||||
modplug_type = g_type_register_static(GST_TYPE_ELEMENT, "GstModPlug", &modplug_info, (GTypeFlags)0);
|
||||
modplug_type =
|
||||
g_type_register_static (GST_TYPE_ELEMENT, "GstModPlug", &modplug_info,
|
||||
(GTypeFlags) 0);
|
||||
}
|
||||
return modplug_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_modplug_base_init (GstModPlugClass *klass)
|
||||
gst_modplug_base_init (GstModPlugClass * klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
|
@ -170,63 +153,63 @@ gst_modplug_base_init (GstModPlugClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_class_init (GstModPlugClass *klass)
|
||||
gst_modplug_class_init (GstModPlugClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
|
||||
parent_class = GST_ELEMENT_CLASS( g_type_class_ref(GST_TYPE_ELEMENT));
|
||||
parent_class = GST_ELEMENT_CLASS (g_type_class_ref (GST_TYPE_ELEMENT));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SONGNAME,
|
||||
g_param_spec_string("songname","Songname","The song name",
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SONGNAME,
|
||||
g_param_spec_string ("songname", "Songname", "The song name",
|
||||
"", G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_REVERB,
|
||||
g_param_spec_boolean("reverb", "reverb", "reverb",
|
||||
FALSE, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_REVERB,
|
||||
g_param_spec_boolean ("reverb", "reverb", "reverb",
|
||||
FALSE, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_REVERB_DEPTH,
|
||||
g_param_spec_int("reverb_depth", "reverb_depth", "reverb_depth",
|
||||
0, 100, 30, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_REVERB_DEPTH,
|
||||
g_param_spec_int ("reverb_depth", "reverb_depth", "reverb_depth",
|
||||
0, 100, 30, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_REVERB_DELAY,
|
||||
g_param_spec_int("reverb_delay", "reverb_delay", "reverb_delay",
|
||||
0, 200, 100, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_REVERB_DELAY,
|
||||
g_param_spec_int ("reverb_delay", "reverb_delay", "reverb_delay",
|
||||
0, 200, 100, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MEGABASS,
|
||||
g_param_spec_boolean("megabass", "megabass", "megabass",
|
||||
FALSE, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEGABASS,
|
||||
g_param_spec_boolean ("megabass", "megabass", "megabass",
|
||||
FALSE, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MEGABASS_AMOUNT,
|
||||
g_param_spec_int("megabass_amount", "megabass_amount", "megabass_amount",
|
||||
0, 100, 40, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEGABASS_AMOUNT,
|
||||
g_param_spec_int ("megabass_amount", "megabass_amount", "megabass_amount",
|
||||
0, 100, 40, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MEGABASS_RANGE,
|
||||
g_param_spec_int("megabass_range", "megabass_range", "megabass_range",
|
||||
0, 100, 30, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEGABASS_RANGE,
|
||||
g_param_spec_int ("megabass_range", "megabass_range", "megabass_range",
|
||||
0, 100, 30, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SURROUND,
|
||||
g_param_spec_boolean("surround", "surround", "surround",
|
||||
TRUE, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SURROUND,
|
||||
g_param_spec_boolean ("surround", "surround", "surround",
|
||||
TRUE, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SURROUND_DEPTH,
|
||||
g_param_spec_int("surround_depth", "surround_depth", "surround_depth",
|
||||
0, 100, 20, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SURROUND_DEPTH,
|
||||
g_param_spec_int ("surround_depth", "surround_depth", "surround_depth",
|
||||
0, 100, 20, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SURROUND_DELAY,
|
||||
g_param_spec_int("surround_delay", "surround_delay", "surround_delay",
|
||||
0, 40, 20, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SURROUND_DELAY,
|
||||
g_param_spec_int ("surround_delay", "surround_delay", "surround_delay",
|
||||
0, 40, 20, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OVERSAMP,
|
||||
g_param_spec_boolean("oversamp", "oversamp", "oversamp",
|
||||
TRUE, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OVERSAMP,
|
||||
g_param_spec_boolean ("oversamp", "oversamp", "oversamp",
|
||||
TRUE, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NOISE_REDUCTION,
|
||||
g_param_spec_boolean("noise_reduction", "noise_reduction", "noise_reduction",
|
||||
TRUE, (GParamFlags)G_PARAM_READWRITE ));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NOISE_REDUCTION,
|
||||
g_param_spec_boolean ("noise_reduction", "noise_reduction",
|
||||
"noise_reduction", TRUE, (GParamFlags) G_PARAM_READWRITE));
|
||||
|
||||
gobject_class->set_property = gst_modplug_set_property;
|
||||
gobject_class->get_property = gst_modplug_get_property;
|
||||
|
@ -235,19 +218,27 @@ gst_modplug_class_init (GstModPlugClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_init (GstModPlug *modplug)
|
||||
gst_modplug_init (GstModPlug * modplug)
|
||||
{
|
||||
modplug->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&modplug_sink_template_factory), "sink");
|
||||
gst_element_add_pad (GST_ELEMENT(modplug), modplug->sinkpad);
|
||||
modplug->sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get
|
||||
(&modplug_sink_template_factory), "sink");
|
||||
gst_element_add_pad (GST_ELEMENT (modplug), modplug->sinkpad);
|
||||
|
||||
modplug->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&modplug_src_template_factory), "src");
|
||||
modplug->srcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get
|
||||
(&modplug_src_template_factory), "src");
|
||||
gst_pad_set_link_function (modplug->srcpad, gst_modplug_srclink);
|
||||
gst_pad_set_fixate_function (modplug->srcpad, gst_modplug_fixate);
|
||||
gst_pad_set_event_function (modplug->srcpad, (GstPadEventFunction)GST_DEBUG_FUNCPTR(gst_modplug_src_event));
|
||||
gst_pad_set_event_function (modplug->srcpad,
|
||||
(GstPadEventFunction) GST_DEBUG_FUNCPTR (gst_modplug_src_event));
|
||||
gst_pad_set_query_function (modplug->srcpad, gst_modplug_src_query);
|
||||
gst_pad_set_query_type_function (modplug->srcpad, (GstPadQueryTypeFunction) GST_DEBUG_FUNCPTR (gst_modplug_get_query_types));
|
||||
gst_pad_set_formats_function (modplug->srcpad, (GstPadFormatsFunction)GST_DEBUG_FUNCPTR (gst_modplug_get_formats));
|
||||
gst_element_add_pad (GST_ELEMENT(modplug), modplug->srcpad);
|
||||
gst_pad_set_query_type_function (modplug->srcpad,
|
||||
(GstPadQueryTypeFunction)
|
||||
GST_DEBUG_FUNCPTR (gst_modplug_get_query_types));
|
||||
gst_pad_set_formats_function (modplug->srcpad,
|
||||
(GstPadFormatsFunction) GST_DEBUG_FUNCPTR (gst_modplug_get_formats));
|
||||
gst_element_add_pad (GST_ELEMENT (modplug), modplug->srcpad);
|
||||
|
||||
gst_element_set_loop_function (GST_ELEMENT (modplug), gst_modplug_loop);
|
||||
|
||||
|
@ -274,52 +265,58 @@ gst_modplug_init (GstModPlug *modplug)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_setup (GstModPlug *modplug)
|
||||
gst_modplug_setup (GstModPlug * modplug)
|
||||
{
|
||||
if (modplug->_16bit)
|
||||
modplug->mSoundFile->SetWaveConfig (modplug->frequency, 16, modplug->channel);
|
||||
modplug->mSoundFile->SetWaveConfig (modplug->frequency, 16,
|
||||
modplug->channel);
|
||||
else
|
||||
modplug->mSoundFile->SetWaveConfig (modplug->frequency, 8, modplug->channel);
|
||||
modplug->mSoundFile->SetWaveConfig (modplug->frequency, 8,
|
||||
modplug->channel);
|
||||
|
||||
modplug->mSoundFile->SetWaveConfigEx (modplug->surround, !modplug->oversamp, modplug->reverb, true, modplug->megabass, modplug->noise_reduction, true);
|
||||
modplug->mSoundFile->SetWaveConfigEx (modplug->surround, !modplug->oversamp,
|
||||
modplug->reverb, true, modplug->megabass, modplug->noise_reduction, true);
|
||||
modplug->mSoundFile->SetResamplingMode (SRCMODE_POLYPHASE);
|
||||
|
||||
if (modplug->surround)
|
||||
modplug->mSoundFile->SetSurroundParameters (modplug->surround_depth, modplug->surround_delay);
|
||||
modplug->mSoundFile->SetSurroundParameters (modplug->surround_depth,
|
||||
modplug->surround_delay);
|
||||
|
||||
if (modplug->megabass)
|
||||
modplug->mSoundFile->SetXBassParameters (modplug->megabass_amount, modplug->megabass_range);
|
||||
modplug->mSoundFile->SetXBassParameters (modplug->megabass_amount,
|
||||
modplug->megabass_range);
|
||||
|
||||
if (modplug->reverb)
|
||||
modplug->mSoundFile->SetReverbParameters (modplug->reverb_depth, modplug->reverb_delay);
|
||||
modplug->mSoundFile->SetReverbParameters (modplug->reverb_depth,
|
||||
modplug->reverb_delay);
|
||||
|
||||
}
|
||||
|
||||
static const GstFormat*
|
||||
gst_modplug_get_formats (GstPad *pad)
|
||||
static const GstFormat *
|
||||
gst_modplug_get_formats (GstPad * pad)
|
||||
{
|
||||
static const GstFormat src_formats[] = {
|
||||
/* GST_FORMAT_BYTES,
|
||||
GST_FORMAT_DEFAULT,*/
|
||||
GST_FORMAT_TIME,
|
||||
(GstFormat)0
|
||||
(GstFormat) 0
|
||||
};
|
||||
static const GstFormat sink_formats[] = {
|
||||
/*GST_FORMAT_BYTES,*/
|
||||
/*GST_FORMAT_BYTES, */
|
||||
GST_FORMAT_TIME,
|
||||
(GstFormat)0
|
||||
(GstFormat) 0
|
||||
};
|
||||
|
||||
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
|
||||
}
|
||||
|
||||
static const GstQueryType*
|
||||
gst_modplug_get_query_types (GstPad *pad)
|
||||
static const GstQueryType *
|
||||
gst_modplug_get_query_types (GstPad * pad)
|
||||
{
|
||||
static const GstQueryType gst_modplug_src_query_types[] = {
|
||||
GST_QUERY_TOTAL,
|
||||
GST_QUERY_POSITION,
|
||||
(GstQueryType)0
|
||||
(GstQueryType) 0
|
||||
};
|
||||
|
||||
return gst_modplug_src_query_types;
|
||||
|
@ -327,8 +324,8 @@ gst_modplug_get_query_types (GstPad *pad)
|
|||
|
||||
|
||||
static gboolean
|
||||
gst_modplug_src_query (GstPad *pad, GstQueryType type,
|
||||
GstFormat *format, gint64 *value)
|
||||
gst_modplug_src_query (GstPad * pad, GstQueryType type,
|
||||
GstFormat * format, gint64 * value)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
GstModPlug *modplug;
|
||||
|
@ -340,7 +337,7 @@ gst_modplug_src_query (GstPad *pad, GstQueryType type,
|
|||
case GST_QUERY_TOTAL:
|
||||
switch (*format) {
|
||||
case GST_FORMAT_TIME:
|
||||
*value=(gint64)modplug->mSoundFile->GetSongTime() * GST_SECOND;
|
||||
*value = (gint64) modplug->mSoundFile->GetSongTime () * GST_SECOND;
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
|
@ -350,8 +347,11 @@ gst_modplug_src_query (GstPad *pad, GstQueryType type,
|
|||
case GST_QUERY_POSITION:
|
||||
switch (*format) {
|
||||
default:
|
||||
tmp = ((float)( modplug->mSoundFile->GetSongTime() * modplug->mSoundFile->GetCurrentPos() ) / (float)modplug->mSoundFile->GetMaxPosition() );
|
||||
*value=(gint64)(tmp * GST_SECOND);
|
||||
tmp =
|
||||
((float) (modplug->mSoundFile->GetSongTime () *
|
||||
modplug->mSoundFile->GetCurrentPos ()) /
|
||||
(float) modplug->mSoundFile->GetMaxPosition ());
|
||||
*value = (gint64) (tmp * GST_SECOND);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -363,7 +363,7 @@ gst_modplug_src_query (GstPad *pad, GstQueryType type,
|
|||
|
||||
|
||||
static gboolean
|
||||
gst_modplug_src_event (GstPad *pad, GstEvent *event)
|
||||
gst_modplug_src_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
GstModPlug *modplug;
|
||||
|
@ -396,14 +396,16 @@ gst_modplug_src_event (GstPad *pad, GstEvent *event)
|
|||
}
|
||||
|
||||
#if 0
|
||||
static GstCaps*
|
||||
gst_modplug_get_streaminfo (GstModPlug *modplug)
|
||||
static GstCaps *
|
||||
gst_modplug_get_streaminfo (GstModPlug * modplug)
|
||||
{
|
||||
GstCaps *caps;
|
||||
|
||||
props = gst_props_empty_new ();
|
||||
|
||||
entry = gst_props_entry_new ("Patterns", G_TYPE_INT ((gint)modplug->mSoundFile->GetNumPatterns()));
|
||||
entry =
|
||||
gst_props_entry_new ("Patterns",
|
||||
G_TYPE_INT ((gint) modplug->mSoundFile->GetNumPatterns ()));
|
||||
gst_props_add_entry (props, (GstPropsEntry *) entry);
|
||||
|
||||
caps = gst_caps_new_simple ("application/x-gst-streaminfo", NULL);
|
||||
|
@ -412,7 +414,7 @@ gst_modplug_get_streaminfo (GstModPlug *modplug)
|
|||
|
||||
|
||||
static void
|
||||
gst_modplug_update_info (GstModPlug *modplug)
|
||||
gst_modplug_update_info (GstModPlug * modplug)
|
||||
{
|
||||
if (modplug->streaminfo) {
|
||||
gst_caps_unref (modplug->streaminfo);
|
||||
|
@ -423,7 +425,7 @@ gst_modplug_update_info (GstModPlug *modplug)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_update_metadata (GstModPlug *modplug)
|
||||
gst_modplug_update_metadata (GstModPlug * modplug)
|
||||
{
|
||||
GstProps *props;
|
||||
GstPropsEntry *entry;
|
||||
|
@ -431,19 +433,18 @@ gst_modplug_update_metadata (GstModPlug *modplug)
|
|||
|
||||
props = gst_props_empty_new ();
|
||||
|
||||
title = modplug->mSoundFile->GetTitle();
|
||||
title = modplug->mSoundFile->GetTitle ();
|
||||
entry = gst_props_entry_new ("Title", G_TYPE_STRING (title));
|
||||
gst_props_add_entry (props, entry);
|
||||
|
||||
modplug->metadata = gst_caps_new_simple ("application/x-gst-metadata",
|
||||
NULL);
|
||||
modplug->metadata = gst_caps_new_simple ("application/x-gst-metadata", NULL);
|
||||
|
||||
g_object_notify (G_OBJECT (modplug), "metadata");
|
||||
}
|
||||
#endif
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_modplug_srclink (GstPad *pad, const GstCaps *caps)
|
||||
gst_modplug_srclink (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
GstModPlug *modplug;
|
||||
GstStructure *structure;
|
||||
|
@ -465,7 +466,7 @@ gst_modplug_srclink (GstPad *pad, const GstCaps *caps)
|
|||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_modplug_fixate (GstPad *pad, const GstCaps *caps)
|
||||
gst_modplug_fixate (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
if (gst_caps_is_simple (caps)) {
|
||||
GstCaps *copy;
|
||||
|
@ -483,7 +484,7 @@ gst_modplug_fixate (GstPad *pad, const GstCaps *caps)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_handle_event (GstModPlug *modplug)
|
||||
gst_modplug_handle_event (GstModPlug * modplug)
|
||||
{
|
||||
gint64 value;
|
||||
guint32 remaining;
|
||||
|
@ -515,7 +516,7 @@ gst_modplug_handle_event (GstModPlug *modplug)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_loop (GstElement *element)
|
||||
gst_modplug_loop (GstElement * element)
|
||||
{
|
||||
GstModPlug *modplug;
|
||||
GstEvent *event;
|
||||
|
@ -525,8 +526,7 @@ gst_modplug_loop (GstElement *element)
|
|||
|
||||
modplug = GST_MODPLUG (element);
|
||||
|
||||
if (modplug->state == MODPLUG_STATE_NEED_TUNE)
|
||||
{
|
||||
if (modplug->state == MODPLUG_STATE_NEED_TUNE) {
|
||||
/* GstBuffer *buf;*/
|
||||
|
||||
modplug->seek_at = -1;
|
||||
|
@ -562,16 +562,16 @@ gst_modplug_loop (GstElement *element)
|
|||
}
|
||||
*/
|
||||
|
||||
if (modplug->bs)
|
||||
{
|
||||
if (modplug->bs) {
|
||||
guint64 got;
|
||||
|
||||
modplug->song_size = gst_bytestream_length (modplug->bs);
|
||||
|
||||
got = gst_bytestream_peek_bytes (modplug->bs, &modplug->buffer_in, modplug->song_size);
|
||||
got =
|
||||
gst_bytestream_peek_bytes (modplug->bs, &modplug->buffer_in,
|
||||
modplug->song_size);
|
||||
|
||||
if ( got < modplug->song_size )
|
||||
{
|
||||
if (got < modplug->song_size) {
|
||||
gst_modplug_handle_event (modplug);
|
||||
return;
|
||||
}
|
||||
|
@ -579,8 +579,7 @@ gst_modplug_loop (GstElement *element)
|
|||
}
|
||||
}
|
||||
|
||||
if (modplug->state == MODPLUG_STATE_LOAD_TUNE)
|
||||
{
|
||||
if (modplug->state == MODPLUG_STATE_LOAD_TUNE) {
|
||||
modplug->mSoundFile = new CSoundFile;
|
||||
|
||||
if (!GST_PAD_CAPS (modplug->srcpad) &&
|
||||
|
@ -603,10 +602,8 @@ gst_modplug_loop (GstElement *element)
|
|||
modplug->state = MODPLUG_STATE_PLAY_TUNE;
|
||||
}
|
||||
|
||||
if (modplug->state == MODPLUG_STATE_PLAY_TUNE && !modplug->eos)
|
||||
{
|
||||
if (modplug->seek_at != -1)
|
||||
{
|
||||
if (modplug->state == MODPLUG_STATE_PLAY_TUNE && !modplug->eos) {
|
||||
if (modplug->seek_at != -1) {
|
||||
gint seek_to_pos;
|
||||
gint64 total;
|
||||
gfloat temp;
|
||||
|
@ -621,43 +618,44 @@ gst_modplug_loop (GstElement *element)
|
|||
modplug->seek_at = -1;
|
||||
}
|
||||
|
||||
if (modplug->need_discont && GST_PAD_IS_USABLE (modplug->srcpad))
|
||||
{
|
||||
if (modplug->need_discont && GST_PAD_IS_USABLE (modplug->srcpad)) {
|
||||
GstEvent *discont;
|
||||
gint64 value;
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
|
||||
if (gst_modplug_src_query (modplug->srcpad, GST_QUERY_POSITION, &format, &value)) {
|
||||
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, value, GST_FORMAT_UNDEFINED);
|
||||
if (gst_modplug_src_query (modplug->srcpad, GST_QUERY_POSITION, &format,
|
||||
&value)) {
|
||||
discont =
|
||||
gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, value,
|
||||
GST_FORMAT_UNDEFINED);
|
||||
modplug->timestamp = value;
|
||||
} else {
|
||||
modplug->timestamp = GST_CLOCK_TIME_NONE;
|
||||
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_UNDEFINED);
|
||||
}
|
||||
gst_pad_push (modplug->srcpad, GST_DATA (discont));
|
||||
modplug->need_discont= FALSE;
|
||||
modplug->need_discont = FALSE;
|
||||
}
|
||||
|
||||
if (modplug->mSoundFile->Read (modplug->audiobuffer, modplug->length) != 0)
|
||||
{
|
||||
if (modplug->mSoundFile->Read (modplug->audiobuffer, modplug->length) != 0) {
|
||||
GstBuffer *buffer_out;
|
||||
|
||||
buffer_out = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (buffer_out) = (guchar *) g_memdup (modplug->audiobuffer, modplug->length);
|
||||
GST_BUFFER_DATA (buffer_out) =
|
||||
(guchar *) g_memdup (modplug->audiobuffer, modplug->length);
|
||||
GST_BUFFER_SIZE (buffer_out) = modplug->length;
|
||||
GST_BUFFER_TIMESTAMP (buffer_out) = modplug->timestamp;
|
||||
|
||||
if (GST_CLOCK_TIME_IS_VALID (modplug->timestamp)) {
|
||||
GST_BUFFER_DURATION (buffer_out) = modplug->length * GST_SECOND / modplug->frequency / modplug->channel / (modplug->_16bit ? 2 : 1) ;
|
||||
GST_BUFFER_DURATION (buffer_out) =
|
||||
modplug->length * GST_SECOND / modplug->frequency /
|
||||
modplug->channel / (modplug->_16bit ? 2 : 1);
|
||||
modplug->timestamp += GST_BUFFER_DURATION (buffer_out);
|
||||
}
|
||||
|
||||
if (GST_PAD_IS_USABLE (modplug->srcpad))
|
||||
gst_pad_push (modplug->srcpad, GST_DATA (buffer_out));
|
||||
}
|
||||
else
|
||||
if (GST_PAD_IS_LINKED (modplug->srcpad))
|
||||
{
|
||||
} else if (GST_PAD_IS_LINKED (modplug->srcpad)) {
|
||||
/* FIXME, hack, pull final EOS from peer */
|
||||
gst_bytestream_flush (modplug->bs, 1);
|
||||
|
||||
|
@ -671,7 +669,7 @@ gst_modplug_loop (GstElement *element)
|
|||
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_modplug_change_state (GstElement *element)
|
||||
gst_modplug_change_state (GstElement * element)
|
||||
{
|
||||
GstModPlug *modplug;
|
||||
|
||||
|
@ -692,12 +690,12 @@ gst_modplug_change_state (GstElement *element)
|
|||
case GST_STATE_PAUSED_TO_READY:
|
||||
gst_bytestream_destroy (modplug->bs);
|
||||
modplug->bs = NULL;
|
||||
if (modplug->opened)
|
||||
{
|
||||
if (modplug->opened) {
|
||||
modplug->mSoundFile->Destroy ();
|
||||
modplug->opened = FALSE;
|
||||
}
|
||||
if (modplug->audiobuffer) g_free (modplug->audiobuffer);
|
||||
if (modplug->audiobuffer)
|
||||
g_free (modplug->audiobuffer);
|
||||
modplug->buffer_in = NULL;
|
||||
modplug->audiobuffer = NULL;
|
||||
modplug->state = MODPLUG_STATE_NEED_TUNE;
|
||||
|
@ -716,12 +714,13 @@ gst_modplug_change_state (GstElement *element)
|
|||
|
||||
|
||||
static void
|
||||
gst_modplug_set_property (GObject *object, guint id, const GValue *value, GParamSpec *pspec )
|
||||
gst_modplug_set_property (GObject * object, guint id, const GValue * value,
|
||||
GParamSpec * pspec)
|
||||
{
|
||||
GstModPlug *modplug;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail (GST_IS_MODPLUG(object));
|
||||
g_return_if_fail (GST_IS_MODPLUG (object));
|
||||
modplug = GST_MODPLUG (object);
|
||||
|
||||
switch (id) {
|
||||
|
@ -761,12 +760,13 @@ gst_modplug_set_property (GObject *object, guint id, const GValue *value, GParam
|
|||
}
|
||||
|
||||
static void
|
||||
gst_modplug_get_property (GObject *object, guint id, GValue *value, GParamSpec *pspec )
|
||||
gst_modplug_get_property (GObject * object, guint id, GValue * value,
|
||||
GParamSpec * pspec)
|
||||
{
|
||||
GstModPlug *modplug;
|
||||
|
||||
/* it's not null if we got it, but it might not be ours */
|
||||
g_return_if_fail (GST_IS_MODPLUG(object));
|
||||
g_return_if_fail (GST_IS_MODPLUG (object));
|
||||
modplug = GST_MODPLUG (object);
|
||||
|
||||
switch (id) {
|
||||
|
@ -806,7 +806,7 @@ gst_modplug_get_property (GObject *object, guint id, GValue *value, GParamSpec *
|
|||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin *plugin)
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
/* this filter needs the bytestream package */
|
||||
if (!gst_library_load ("gstbytestream"))
|
||||
|
@ -816,14 +816,8 @@ plugin_init (GstPlugin *plugin)
|
|||
GST_RANK_PRIMARY, GST_TYPE_MODPLUG);
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (
|
||||
GST_VERSION_MAJOR,
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"modplug",
|
||||
".MOD audio decoding",
|
||||
plugin_init,
|
||||
VERSION,
|
||||
"LGPL",
|
||||
GST_PACKAGE,
|
||||
GST_ORIGIN
|
||||
)
|
||||
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
|
||||
|
|
Loading…
Reference in a new issue