1.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c Tue Jun 26 15:00:45 2007 +0100
1.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Fri Jun 29 14:40:01 2007 +0100
1.3 @@ -15,6 +15,8 @@
1.4 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), G_TYPE_MENCODER, GMencoderPrivate))
1.5
1.6 // #define SUPPORT_MULT_INPUT 0
1.7 +#define USE_MANUAL_SINK
1.8 +#define BUFFER_SIZE 512
1.9
1.10 typedef struct _GMencoderPrivate GMencoderPrivate;
1.11 typedef struct _SetupInfo SetupInfo;
1.12 @@ -96,13 +98,21 @@
1.13 const gchar * audio_encode,
1.14 gchar ** audio_encode_prop,
1.15 guint audio_rate);
1.16 +#ifdef USE_MANUAL_SINK
1.17 +static void _buffer_arrive_cb (GstElement* object,
1.18 + GstBuffer* buff,
1.19 + GstPad* pad,
1.20 + gpointer user_data);
1.21 +#endif
1.22 +
1.23
1.24 static gboolean _tick_cb(gpointer data);
1.25
1.26 static guint g_mencoder_signals[LAST_SIGNAL] = { 0 };
1.27
1.28 G_DEFINE_TYPE(GMencoder, g_mencoder, G_TYPE_OBJECT)
1.29 - static void g_mencoder_class_init(GMencoderClass * klass)
1.30 +
1.31 +static void g_mencoder_class_init(GMencoderClass * klass)
1.32 {
1.33 GObjectClass *object_class;
1.34 object_class = (GObjectClass *) klass;
1.35 @@ -666,11 +676,19 @@
1.36 queue = gst_element_factory_make("queue", "queueu_sink");
1.37
1.38
1.39 +#ifdef USE_MANUAL_SINK
1.40 + sink = gst_element_factory_make("fakesink", "sink");
1.41 + g_signal_connect (G_OBJECT (sink),
1.42 + "handoff",
1.43 + G_CALLBACK (_buffer_arrive_cb),
1.44 + GINT_TO_POINTER (priv->fd));
1.45 +#else
1.46 sink = gst_element_factory_make("fdsink", "sink");
1.47 if (sink == NULL)
1.48 goto error;
1.49
1.50 g_object_set(G_OBJECT(sink), "fd", priv->fd, "sync", FALSE, NULL);
1.51 +#endif
1.52
1.53 abin = _create_audio_bin(audio_encode, audio_encode_prop, audio_rate);
1.54 if (abin == NULL)
1.55 @@ -1033,3 +1051,26 @@
1.56
1.57 return TRUE;
1.58 }
1.59 +
1.60 +
1.61 +#ifdef USE_MANUAL_SINK
1.62 +static void
1.63 +_buffer_arrive_cb (GstElement* object,
1.64 + GstBuffer* buff,
1.65 + GstPad* pad,
1.66 + gpointer user_data)
1.67 +{
1.68 + static GByteArray *queue = NULL;
1.69 + static guint offset = 0;
1.70 +
1.71 + gint fd = GPOINTER_TO_INT (user_data);
1.72 +
1.73 + queue = g_byte_array_append (queue, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff));
1.74 +
1.75 + if (queue->len >= BUFFER_SIZE) {
1.76 + write (fd, queue->data, BUFFER_SIZE);
1.77 + queue = g_byte_array_remove_range (queue, 0, BUFFER_SIZE);
1.78 + }
1.79 +}
1.80 +#endif
1.81 +