2002-06-01 10:50:03 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-06-01 10:50:03 +00:00
|
|
|
#include <fame.h>
|
|
|
|
#include <string.h>
|
2003-07-06 20:49:52 +00:00
|
|
|
#include <math.h>
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
#include "gstlibfame.h"
|
2003-07-06 20:49:52 +00:00
|
|
|
#include <gst/video/video.h>
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
#define FAMEENC_BUFFER_SIZE (300 * 1024)
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* elementfactory information */
|
2002-06-02 10:48:24 +00:00
|
|
|
static GstElementDetails gst_fameenc_details = {
|
2002-06-03 10:51:39 +00:00
|
|
|
"MPEG1 and MPEG4 video encoder using the libfame library",
|
2004-05-09 14:37:16 +00:00
|
|
|
"Codec/Encoder/Video",
|
2002-06-02 10:48:24 +00:00
|
|
|
"Uses fameenc to encode MPEG video streams",
|
2003-11-02 20:44:56 +00:00
|
|
|
"Thomas Vander Stichele <thomas@apestaart.org>"
|
2002-06-01 10:50:03 +00:00
|
|
|
};
|
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
static GQuark fame_object_name;
|
|
|
|
|
|
|
|
|
|
|
|
/* FameEnc signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-06-01 10:50:03 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-06-01 10:50:03 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_VERSION,
|
2002-06-02 10:48:24 +00:00
|
|
|
ARG_BITRATE,
|
2002-06-01 10:50:03 +00:00
|
|
|
ARG_QUALITY,
|
2002-06-01 12:28:28 +00:00
|
|
|
ARG_PATTERN,
|
2002-06-02 10:48:24 +00:00
|
|
|
ARG_FAME_VERBOSE,
|
|
|
|
ARG_BUFFER_SIZE,
|
|
|
|
ARG_FRAMES_PER_SEQUENCE,
|
|
|
|
/* dynamically generated properties start here */
|
|
|
|
ARG_FAME_PROPS_START
|
2004-03-14 22:34:33 +00:00
|
|
|
/* FILL ME */
|
2002-06-01 10:50:03 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-raw-yuv, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"format = (fourcc) I420, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2005-01-14 12:27:22 +00:00
|
|
|
"framerate = (double) { 23.976023976, 24.0, 25.0, 29.97002997, 30.0, "
|
|
|
|
" 50.0, 59.94005994, 60.0 }")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/mpeg, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"mpegversion = (int) { 1, 4 }, "
|
|
|
|
"systemstream = (boolean) FALSE, "
|
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2005-01-14 12:27:22 +00:00
|
|
|
"framerate = (double) { 23.976023976, 24.0, 25.0, 29.97002997, 30.0, "
|
|
|
|
" 50.0, 59.94005994, 60.0 }")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
#define MAX_FRAME_RATES 9
|
2002-06-02 10:48:24 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint num;
|
|
|
|
gint den;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
|
|
|
frame_rate_entry;
|
2002-06-02 10:48:24 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static const frame_rate_entry frame_rates[] = {
|
|
|
|
{0, 0},
|
|
|
|
{24000, 1001},
|
|
|
|
{24, 1},
|
|
|
|
{25, 1},
|
|
|
|
{30000, 1001},
|
|
|
|
{30, 1},
|
|
|
|
{50, 1},
|
|
|
|
{60000, 1001},
|
|
|
|
{60, 1},
|
2002-06-02 10:48:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static gint
|
2003-07-06 20:49:52 +00:00
|
|
|
framerate_to_index (gfloat fps)
|
2002-06-02 10:48:24 +00:00
|
|
|
{
|
|
|
|
gint i;
|
2003-07-06 20:49:52 +00:00
|
|
|
gint idx = -1;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
for (i = 1; i < MAX_FRAME_RATES; i++) {
|
|
|
|
if (idx == -1) {
|
|
|
|
idx = i;
|
|
|
|
} else {
|
2004-03-14 22:34:33 +00:00
|
|
|
gfloat old_diff = fabs ((1. * frame_rates[idx].num /
|
2004-03-15 19:32:27 +00:00
|
|
|
frame_rates[idx].den) - fps),
|
|
|
|
new_diff = fabs ((1. * frame_rates[i].num /
|
|
|
|
frame_rates[i].den) - fps);
|
2003-07-06 20:49:52 +00:00
|
|
|
|
|
|
|
if (new_diff < old_diff) {
|
2004-03-15 19:32:27 +00:00
|
|
|
idx = i;
|
2003-07-06 20:49:52 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-02 10:48:24 +00:00
|
|
|
}
|
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
return idx;
|
2002-06-02 10:48:24 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_fameenc_class_init (GstFameEncClass * klass);
|
|
|
|
static void gst_fameenc_base_init (GstFameEncClass * klass);
|
|
|
|
static void gst_fameenc_init (GstFameEnc * fameenc);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
static void gst_fameenc_finalize (GObject * object);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_fameenc_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_fameenc_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_fameenc_chain (GstPad * pad, GstData * _data);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
/*static guint gst_fameenc_signals[LAST_SIGNAL] = { 0 };*/
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
GType
|
2002-06-02 10:48:24 +00:00
|
|
|
gst_fameenc_get_type (void)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2002-06-02 10:48:24 +00:00
|
|
|
static GType fameenc_type = 0;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
if (!fameenc_type) {
|
|
|
|
static const GTypeInfo fameenc_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstFameEncClass),
|
2003-11-02 20:44:56 +00:00
|
|
|
(GBaseInitFunc) gst_fameenc_base_init,
|
2002-06-01 10:50:03 +00:00
|
|
|
NULL,
|
2002-06-02 10:48:24 +00:00
|
|
|
(GClassInitFunc) gst_fameenc_class_init,
|
2002-06-01 10:50:03 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2002-06-02 10:48:24 +00:00
|
|
|
sizeof (GstFameEnc),
|
2002-06-01 10:50:03 +00:00
|
|
|
0,
|
2002-06-02 10:48:24 +00:00
|
|
|
(GInstanceInitFunc) gst_fameenc_init,
|
2002-06-01 10:50:03 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
fameenc_type = g_type_register_static (GST_TYPE_ELEMENT,
|
2004-03-15 19:32:27 +00:00
|
|
|
"GstFameEnc", &fameenc_info, 0);
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
2002-06-02 10:48:24 +00:00
|
|
|
return fameenc_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_item_compare (fame_list_t * item1, fame_list_t * item2)
|
2002-06-02 10:48:24 +00:00
|
|
|
{
|
|
|
|
return strcmp (item1->type, item2->type);
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 20:44:56 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_base_init (GstFameEncClass * klass)
|
2003-11-02 20:44:56 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&sink_template));
|
2003-11-02 20:44:56 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_static_pad_template_get (&src_template));
|
2003-11-02 20:44:56 +00:00
|
|
|
|
|
|
|
gst_element_class_set_details (element_class, &gst_fameenc_details);
|
|
|
|
}
|
|
|
|
|
2002-06-01 10:50:03 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_class_init (GstFameEncClass * klass)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = NULL;
|
|
|
|
GstElementClass *gstelement_class = NULL;
|
2002-06-02 10:48:24 +00:00
|
|
|
fame_context_t *context;
|
|
|
|
fame_list_t *walk;
|
|
|
|
GList *props = NULL, *props_walk;
|
|
|
|
gint current_prop = ARG_FAME_PROPS_START;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
gobject_class->set_property = gst_fameenc_set_property;
|
|
|
|
gobject_class->get_property = gst_fameenc_get_property;
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
gobject_class->finalize = gst_fameenc_finalize;
|
2002-06-02 10:48:24 +00:00
|
|
|
|
|
|
|
fame_object_name = g_quark_from_string ("GstFameObjectName");
|
|
|
|
|
|
|
|
context = fame_open ();
|
|
|
|
g_assert (context);
|
|
|
|
|
|
|
|
/* first sort the list */
|
|
|
|
walk = context->type_list;
|
|
|
|
while (walk) {
|
2004-03-14 22:34:33 +00:00
|
|
|
props =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_list_insert_sorted (props, walk,
|
|
|
|
(GCompareFunc) gst_fameenc_item_compare);
|
2002-06-02 10:48:24 +00:00
|
|
|
walk = walk->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
props_walk = props;
|
|
|
|
while (props_walk) {
|
|
|
|
GArray *array;
|
|
|
|
const gchar *current_type;
|
|
|
|
gint current_len;
|
|
|
|
gint current_value;
|
|
|
|
fame_object_t *current_default;
|
|
|
|
gint default_index;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
walk = (fame_list_t *) props_walk->data;
|
2002-06-02 10:48:24 +00:00
|
|
|
array = g_array_new (TRUE, FALSE, sizeof (GEnumValue));
|
|
|
|
|
|
|
|
current_type = walk->type;
|
|
|
|
current_value = 0;
|
|
|
|
current_len = strlen (walk->type);
|
|
|
|
current_default = fame_get_object (context, current_type);
|
|
|
|
default_index = 1;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (strstr (walk->type, "/")) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GEnumValue value;
|
2002-06-02 10:48:24 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (current_default == walk->item)
|
|
|
|
default_index = current_value;
|
2002-06-02 10:48:24 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
value.value = current_value++;
|
|
|
|
value.value_name = g_strdup (walk->type);
|
|
|
|
value.value_nick = g_strdup (walk->item->name);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_array_append_val (array, value);
|
2002-06-02 10:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
props_walk = g_list_next (props_walk);
|
|
|
|
if (props_walk)
|
2004-03-15 19:32:27 +00:00
|
|
|
walk = (fame_list_t *) props_walk->data;
|
2002-06-02 10:48:24 +00:00
|
|
|
|
|
|
|
} while (props_walk && !strncmp (walk->type, current_type, current_len));
|
|
|
|
|
|
|
|
if (array->len > 0) {
|
|
|
|
GType type;
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_enum_register_static (g_strdup_printf ("GstFameEnc_%s",
|
|
|
|
current_type), (GEnumValue *) array->data);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
pspec =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_param_spec_enum (current_type, current_type,
|
|
|
|
g_strdup_printf ("The FAME \"%s\" object", current_type), type,
|
|
|
|
default_index, G_PARAM_READWRITE);
|
2002-06-02 10:48:24 +00:00
|
|
|
|
|
|
|
g_param_spec_set_qdata (pspec, fame_object_name, (gpointer) current_type);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), current_prop++,
|
2004-03-15 19:32:27 +00:00
|
|
|
pspec);
|
2002-06-02 10:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, ARG_BITRATE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)",
|
2004-03-15 19:32:27 +00:00
|
|
|
0, 5000000, 0, G_PARAM_READWRITE));
|
2002-06-01 10:50:03 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_QUALITY,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("quality", "Quality",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Percentage of quality of compression (versus size)", 0, 100, 75,
|
|
|
|
G_PARAM_READWRITE));
|
2002-06-01 12:28:28 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_PATTERN,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_string ("pattern", "Pattern",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Encoding pattern of I, P, and B frames", "IPPPPPPPPPPP",
|
|
|
|
G_PARAM_READWRITE));
|
2002-06-02 10:48:24 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_FRAMES_PER_SEQUENCE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("frames_per_sequence", "Frames Per Sequence",
|
2004-03-15 19:32:27 +00:00
|
|
|
"The number of frames in one sequence", 1, G_MAXINT, 12,
|
|
|
|
G_PARAM_READWRITE));
|
2002-06-02 10:48:24 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_FAME_VERBOSE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_boolean ("fame_verbose", "Fame Verbose",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Make FAME produce verbose output", FALSE, G_PARAM_READWRITE));
|
2002-06-02 10:48:24 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_BUFFER_SIZE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("buffer_size", "Buffer Size",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Set the decoding output buffer size", 0, 1024 * 1024,
|
|
|
|
FAMEENC_BUFFER_SIZE, G_PARAM_READWRITE));
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_sink_link (GstPad * pad, const GstCaps * caps)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2003-07-06 20:49:52 +00:00
|
|
|
gint width, height, fps_idx;
|
2003-12-22 01:47:09 +00:00
|
|
|
gdouble fps;
|
2002-06-02 10:48:24 +00:00
|
|
|
GstFameEnc *fameenc;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc = GST_FAMEENC (gst_pad_get_parent (pad));
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
if (fameenc->initialized) {
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("error: fameenc encoder already initialized !");
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
gst_structure_get_int (structure, "width", &width);
|
|
|
|
gst_structure_get_int (structure, "height", &height);
|
|
|
|
gst_structure_get_double (structure, "framerate", &fps);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
/* fameenc requires width and height to be multiples of 16 */
|
|
|
|
if (width % 16 != 0 || height % 16 != 0)
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
fps_idx = framerate_to_index (fps);
|
|
|
|
fameenc->fp.frame_rate_num = frame_rates[fps_idx].num;
|
|
|
|
fameenc->fp.frame_rate_den = frame_rates[fps_idx].den;
|
|
|
|
fameenc->time_interval = 0;
|
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fp.width = width;
|
|
|
|
fameenc->fp.height = height;
|
|
|
|
fameenc->fp.coding = (const char *) fameenc->pattern;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* FIXME: choose good parameters */
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fp.slices_per_frame = 1;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* FIXME: handle these properly */
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fp.shape_quality = 75;
|
|
|
|
fameenc->fp.search_range = 0;
|
|
|
|
fameenc->fp.total_frames = 0;
|
|
|
|
fameenc->fp.retrieve_cb = NULL;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fame_init (fameenc->fc, &fameenc->fp, fameenc->buffer, fameenc->buffer_size);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->initialized = TRUE;
|
2002-12-20 22:06:18 +00:00
|
|
|
fameenc->time_interval = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_init (GstFameEnc * fameenc)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2002-06-02 10:48:24 +00:00
|
|
|
g_assert (fameenc != NULL);
|
|
|
|
g_assert (GST_IS_FAMEENC (fameenc));
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
/* open fameenc */
|
|
|
|
fameenc->fc = fame_open ();
|
|
|
|
g_assert (fameenc->fc != NULL);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* create the sink and src pads */
|
2004-03-14 22:34:33 +00:00
|
|
|
fameenc->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
|
|
|
|
"sink");
|
2002-06-02 10:48:24 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->sinkpad);
|
|
|
|
gst_pad_set_chain_function (fameenc->sinkpad, gst_fameenc_chain);
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sink_link);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
fameenc->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
|
|
|
|
"src");
|
2002-06-02 10:48:24 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->srcpad);
|
2002-06-01 10:50:03 +00:00
|
|
|
/* FIXME: set some more handler functions here */
|
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->verbose = FALSE;
|
|
|
|
|
2002-06-01 10:50:03 +00:00
|
|
|
/* reset the initial video state */
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fp.width = -1;
|
|
|
|
fameenc->fp.height = -1;
|
|
|
|
fameenc->initialized = FALSE;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* defaults */
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fp.bitrate = 0;
|
|
|
|
fameenc->fp.quality = 75;
|
|
|
|
fameenc->fp.frame_rate_num = 25;
|
2004-03-15 19:32:27 +00:00
|
|
|
fameenc->fp.frame_rate_den = 1; /* avoid floating point exceptions */
|
2004-03-14 22:34:33 +00:00
|
|
|
fameenc->fp.frames_per_sequence = 12;
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->pattern = g_strdup ("IPPPPPPPPPP");
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* allocate space for the buffer */
|
2004-03-15 19:32:27 +00:00
|
|
|
fameenc->buffer_size = FAMEENC_BUFFER_SIZE; /* FIXME */
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->buffer = (unsigned char *) g_malloc (fameenc->buffer_size);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
fameenc->next_time = 0;
|
2002-12-20 22:06:18 +00:00
|
|
|
fameenc->time_interval = 0;
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
gst_fameenc_finalize (GObject * object)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2002-06-02 10:48:24 +00:00
|
|
|
GstFameEnc *fameenc = GST_FAMEENC (object);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
g_free (fameenc->buffer);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_chain (GstPad * pad, GstData * _data)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2003-10-08 16:08:19 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2002-06-02 10:48:24 +00:00
|
|
|
GstFameEnc *fameenc;
|
2002-06-01 12:47:21 +00:00
|
|
|
guchar *data;
|
2002-06-01 10:50:03 +00:00
|
|
|
gulong size;
|
2002-06-01 12:47:21 +00:00
|
|
|
gint frame_size;
|
|
|
|
gint length;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
|
|
|
g_return_if_fail (GST_IS_BUFFER (buf));
|
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc = GST_FAMEENC (gst_pad_get_parent (pad));
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
data = (guchar *) GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("gst_fameenc_chain: got buffer of %ld bytes in '%s'",
|
|
|
|
size, GST_OBJECT_NAME (fameenc));
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
/* the data contains the three planes side by side, with size w * h, w * h /4,
|
|
|
|
* w * h / 4 */
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fy.w = fameenc->fp.width;
|
|
|
|
fameenc->fy.h = fameenc->fp.height;
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
frame_size = fameenc->fp.width * fameenc->fp.height;
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
fameenc->fy.p = 0;
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fy.y = data;
|
|
|
|
fameenc->fy.u = data + frame_size;
|
|
|
|
fameenc->fy.v = fameenc->fy.u + (frame_size >> 2);
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
fame_start_frame (fameenc->fc, &fameenc->fy, NULL);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
while ((length = fame_encode_slice (fameenc->fc)) != 0) {
|
2002-06-01 12:47:21 +00:00
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
2002-06-01 10:50:03 +00:00
|
|
|
outbuf = gst_buffer_new ();
|
|
|
|
|
|
|
|
/* FIXME: safeguard, remove me when a better way is found */
|
2002-06-02 10:48:24 +00:00
|
|
|
if (length > FAMEENC_BUFFER_SIZE)
|
2004-03-14 22:34:33 +00:00
|
|
|
g_warning
|
2004-03-15 19:32:27 +00:00
|
|
|
("FAMEENC_BUFFER_SIZE is defined too low, encoded slice has size %d !\n",
|
|
|
|
length);
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2002-12-20 22:06:18 +00:00
|
|
|
if (!fameenc->time_interval) {
|
2004-03-14 22:34:33 +00:00
|
|
|
fameenc->time_interval =
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_SECOND * fameenc->fp.frame_rate_den / fameenc->fp.frame_rate_num;
|
2002-12-20 22:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fameenc->next_time += fameenc->time_interval;
|
|
|
|
|
2002-06-01 10:50:03 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = length;
|
2002-12-20 22:06:18 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = fameenc->next_time;
|
2002-06-01 10:50:03 +00:00
|
|
|
GST_BUFFER_DATA (outbuf) = g_malloc (length);
|
2004-03-14 22:34:33 +00:00
|
|
|
memcpy (GST_BUFFER_DATA (outbuf), fameenc->buffer, length);
|
2002-12-20 20:01:17 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("gst_fameenc_chain: pushing buffer of size %d",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf));
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2003-10-08 16:08:19 +00:00
|
|
|
gst_pad_push (fameenc->srcpad, GST_DATA (outbuf));
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
fame_end_frame (fameenc->fc, NULL);
|
2002-06-01 12:47:21 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (buf);
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2002-06-02 10:48:24 +00:00
|
|
|
GstFameEnc *fameenc;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
g_return_if_fail (GST_IS_FAMEENC (object));
|
|
|
|
fameenc = GST_FAMEENC (object);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
if (fameenc->initialized) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG
|
2004-03-15 19:32:27 +00:00
|
|
|
("error: fameenc encoder already initialized, cannot set properties !");
|
2002-06-01 12:47:21 +00:00
|
|
|
return;
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2002-06-02 10:48:24 +00:00
|
|
|
case ARG_BITRATE:
|
|
|
|
fameenc->fp.bitrate = g_value_get_int (value);
|
2002-06-01 12:47:21 +00:00
|
|
|
break;
|
2002-06-01 10:50:03 +00:00
|
|
|
case ARG_QUALITY:
|
2002-06-02 10:48:24 +00:00
|
|
|
fameenc->fp.quality = CLAMP (g_value_get_int (value), 0, 100);
|
2002-06-01 10:50:03 +00:00
|
|
|
break;
|
2002-06-01 12:28:28 +00:00
|
|
|
case ARG_PATTERN:
|
2002-06-02 10:48:24 +00:00
|
|
|
g_free (fameenc->pattern);
|
|
|
|
fameenc->pattern = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case ARG_FAME_VERBOSE:
|
|
|
|
fameenc->verbose = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_BUFFER_SIZE:
|
|
|
|
fameenc->buffer_size = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_FRAMES_PER_SEQUENCE:
|
|
|
|
fameenc->fp.frames_per_sequence = g_value_get_int (value);
|
2002-06-01 12:28:28 +00:00
|
|
|
break;
|
2002-06-01 10:50:03 +00:00
|
|
|
default:
|
2002-06-02 10:48:24 +00:00
|
|
|
if (prop_id >= ARG_FAME_PROPS_START) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gchar *name;
|
|
|
|
gint index = g_value_get_enum (value);
|
|
|
|
GEnumValue *values;
|
2002-06-02 10:48:24 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
values = G_ENUM_CLASS (g_type_class_ref (pspec->value_type))->values;
|
|
|
|
name = (gchar *) g_param_spec_get_qdata (pspec, fame_object_name);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
fame_register (fameenc->fc, name, fame_get_object (fameenc->fc,
|
|
|
|
values[index].value_name));
|
2004-03-14 22:34:33 +00:00
|
|
|
} else
|
2004-03-15 19:32:27 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2002-06-01 10:50:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_fameenc_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2002-06-02 10:48:24 +00:00
|
|
|
GstFameEnc *fameenc;
|
2002-06-01 10:50:03 +00:00
|
|
|
|
2002-06-02 10:48:24 +00:00
|
|
|
g_return_if_fail (GST_IS_FAMEENC (object));
|
|
|
|
fameenc = GST_FAMEENC (object);
|
2002-06-01 10:50:03 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2002-06-02 10:48:24 +00:00
|
|
|
case ARG_BITRATE:
|
|
|
|
g_value_set_int (value, fameenc->fp.bitrate);
|
2002-06-01 10:50:03 +00:00
|
|
|
break;
|
|
|
|
case ARG_QUALITY:
|
2002-06-02 10:48:24 +00:00
|
|
|
g_value_set_int (value, fameenc->fp.quality);
|
2002-06-01 10:50:03 +00:00
|
|
|
break;
|
2002-06-01 12:28:28 +00:00
|
|
|
case ARG_PATTERN:
|
2002-06-02 10:48:24 +00:00
|
|
|
g_value_set_string (value, g_strdup (fameenc->pattern));
|
|
|
|
break;
|
|
|
|
case ARG_FAME_VERBOSE:
|
|
|
|
g_value_set_boolean (value, fameenc->verbose);
|
|
|
|
break;
|
|
|
|
case ARG_BUFFER_SIZE:
|
|
|
|
g_value_set_int (value, fameenc->buffer_size);
|
|
|
|
break;
|
|
|
|
case ARG_FRAMES_PER_SEQUENCE:
|
|
|
|
g_value_set_int (value, fameenc->fp.frames_per_sequence);
|
2002-06-01 12:28:28 +00:00
|
|
|
break;
|
2002-06-01 10:50:03 +00:00
|
|
|
default:
|
2002-06-02 10:48:24 +00:00
|
|
|
if (prop_id >= ARG_FAME_PROPS_START) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gchar *name;
|
|
|
|
gint index = 0;
|
|
|
|
GEnumValue *values;
|
|
|
|
fame_object_t *f_object;
|
|
|
|
|
|
|
|
values = G_ENUM_CLASS (g_type_class_ref (pspec->value_type))->values;
|
|
|
|
name = (gchar *) g_param_spec_get_qdata (pspec, fame_object_name);
|
|
|
|
|
|
|
|
f_object = fame_get_object (fameenc->fc, name);
|
|
|
|
|
|
|
|
while (values[index].value_name) {
|
|
|
|
if (!strcmp (values[index].value_nick, f_object->name)) {
|
|
|
|
g_value_set_enum (value, index);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
2002-06-02 10:48:24 +00:00
|
|
|
}
|
2002-06-01 10:50:03 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2002-06-01 10:50:03 +00:00
|
|
|
{
|
2003-11-02 20:44:56 +00:00
|
|
|
return gst_element_register (plugin, "fameenc",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_RANK_NONE, GST_TYPE_FAMEENC);
|
2002-06-01 10:50:03 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"fameenc",
|
|
|
|
"Fast Assembly MPEG Encoder",
|
|
|
|
plugin_init,
|
|
|
|
LIBFAME_VERSION, "LGPL", "libfame", "http://fame.sourceforge.net/")
|