Added the code for the bonobo media component. It doesn't really work yet because...
authorWim Taymans <wim.taymans@gmail.com>
Sun, 20 May 2001 10:31:23 +0000 (10:31 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Sun, 20 May 2001 10:31:23 +0000 (10:31 +0000)
Original commit message from CVS:
Added the code for the bonobo media component. It doesn't really
work yet because bonobo-media doesn't show video.

components/bonobo-media/Makefile.am [new file with mode: 0644]
components/bonobo-media/bonobo-media-gstreamer-factory.c [new file with mode: 0644]
components/bonobo-media/bonobo-media-gstreamer.gob [new file with mode: 0644]
components/bonobo-media/bonobo-media-gstreamer.oafinfo [new file with mode: 0644]
components/bonobo-media/bonobo-media-gstreamervideo.gob [new file with mode: 0644]

diff --git a/components/bonobo-media/Makefile.am b/components/bonobo-media/Makefile.am
new file mode 100644 (file)
index 0000000..f70e4f2
--- /dev/null
@@ -0,0 +1,44 @@
+GOB_FILES      = \
+               bonobo-media-gstreamer.gob bonobo-media-gstreamervideo.gob
+
+GOB_SOURCE     = \
+               bonobo-media-gstreamer.h bonobo-media-gstreamer-private.h bonobo-media-gstreamer.c \
+               bonobo-media-gstreamervideo.h bonobo-media-gstreamervideo.c bonobo-media-gstreamervideo-private.h
+
+OAF_FILES      = bonobo-media-gstreamer.oafinfo
+
+INCLUDES       = \
+               -I. \
+               -I$(srcdir) -I$(top_srcdir) -I$(top_builddir) \
+               -I$(top_srcdir)/bonobo-media \
+               -I$(includedir) \
+               -I$(GNOME_CFLAGS) $(GNOME_INCLUDEDIR) \
+               -I$(EXTRA_BONOBO_CFLAGS) $(EXTRA_WARNING_CFLAGS) \
+               $(GSTREAMER_CFLAGS) 
+
+if STREAM_PROVIDERS_GSTREAMER
+bin_PROGRAMS   = bonobo-media-gstreamer
+endif
+
+bonobo_media_gstreamer_SOURCES = \
+                       $(GOB_FILES) $(GOB_SOURCE) \
+                       bonobo-media-gstreamer-factory.c
+
+bonobo_media_gstreamer_LDADD = \
+                       $(EXTRA_GNOME_LIBS) $(EXTRA_BONOBO_LIBS) \
+                       -lpthread \
+                       -lgstmediaplay -lgst\
+                       $(top_builddir)/bonobo-media/libbonobo-media.la
+
+.c %.h %-private.h: $(srcdir)/%.gob
+       @GOB@ $<
+
+oafdir                 = $(datadir)/oaf
+oaf_DATA               = $(OAF_FILES)
+
+
+
+BUILT_SOURCES           = $(GOB_SOURCE)
+CLEANFILES              += $(BUILT_SOURCES)
+
+EXTRA_DIST             = $(OAF_FILES)
diff --git a/components/bonobo-media/bonobo-media-gstreamer-factory.c b/components/bonobo-media/bonobo-media-gstreamer-factory.c
new file mode 100644 (file)
index 0000000..e2eb3db
--- /dev/null
@@ -0,0 +1,74 @@
+/* bonobo-media-gstreamer-factry: Factory for GStreamer player using the
+ * Bonobo:Media interfaces
+ *
+ * Copyright (C) 2001 Ali Abdin <aliabdin@aucegypt.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gnome.h>
+#include <glib.h>
+#include <bonobo.h>
+#include <liboaf/liboaf.h>
+#include "bonobo-media-gstreamer.h"
+
+#include <gst/gst.h>
+#include <config.h>
+
+static BonoboObject* gstreamer_factory (BonoboGenericFactory *factory,
+                                    gpointer user_data)
+{
+       return BONOBO_OBJECT (bonobo_media_gstreamer_new ());
+}
+
+static void init_bonobo (int argc, char **argv)
+{
+       CORBA_ORB orb;
+
+       gnome_init_with_popt_table ("bonobo-media-gstreamer", VERSION,
+                                   argc, argv,
+                                   oaf_popt_options, 0, NULL);
+
+       orb = oaf_init (argc, argv);
+
+       if (bonobo_init (orb, NULL, NULL) == FALSE)
+               g_error ("Could not initialize Bonobo");
+}
+
+static void last_unref_cb (BonoboObject *bonobo_object,
+                          BonoboGenericFactory *factory)
+{
+       bonobo_object_unref (BONOBO_OBJECT (factory));
+       gtk_main_quit ();
+}
+
+int main (int argc, char **argv)
+{
+       BonoboGenericFactory *factory;
+
+       gst_init (&argc, &argv);
+       init_bonobo (argc, argv);
+
+       factory = bonobo_generic_factory_new (
+                       "OAFIID:Bonobo_Media_GStreamer_Factory",
+                       gstreamer_factory, NULL);
+
+       gtk_signal_connect (GTK_OBJECT (bonobo_context_running_get ()), "last_unref",
+                           GTK_SIGNAL_FUNC (last_unref_cb), factory);
+
+       bonobo_main ();
+
+       return 0;
+}
diff --git a/components/bonobo-media/bonobo-media-gstreamer.gob b/components/bonobo-media/bonobo-media-gstreamer.gob
new file mode 100644 (file)
index 0000000..c7b3ccc
--- /dev/null
@@ -0,0 +1,251 @@
+/* vim: set syntax=c: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+*/
+%at{
+ /* bonobo-media-gstreamer: GStreamer player using the Bonobo:Meida interfaces
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (c) 2001  Ali Abdin   <aliabdin@aucegypt.edu> and
+ *                     ÉRDI Gergõ  <cactus@cactus.rulez.org>
+ *                     Wim Taymans <wim.taymans@chello.be>
+ */
+%}
+
+%header{
+#include <bonobo/bonobo-persist-file.h>
+#include "bonobo-media/bonobo-media-stream.h"
+%}
+
+%privateheader{
+#include "bonobo-media-gstreamervideo.h"
+#include "bonobo-media/bonobo-media-video.h"
+#include <gstplay/gstplay.h>
+%}
+
+%{
+#include <bonobo/bonobo-exception.h>
+
+#include <bonobo-media/bonobo-media-stream-private.h>
+
+%}
+
+class Bonobo:Media:GStreamer from Bonobo:Media:Stream
+{
+       private gint              length;
+       private gint              current_pos;
+       private GstPlay           *play;
+       //private GtkWidget               *play;
+
+       private guint timeout_id
+               destroy
+               {
+                       if (VAR)
+                               gtk_timeout_remove (VAR);
+               } = 0;
+
+       private gboolean update_position (self)
+               {
+                       gint current_time = 0;
+
+                       bonobo_media_stream_send_pos_notification (
+                               BONOBO_MEDIA_STREAM (self),
+                               current_time);
+                               
+                       if (current_time == self->_priv->length)
+                               bonobo_media_stream_send_end_notification (
+                                       BONOBO_MEDIA_STREAM (self));
+
+                       return TRUE;
+               }
+       
+       override (Bonobo:Media:Stream)
+               gfloat get_pos_per_sec (BonoboMediaStream *media_stream,
+                                      CORBA_Environment *ev)
+               {
+                       gfloat ratio = 0;
+
+                       /* Since position is in decoded values (to
+                          avoid problems with variable bit-rate
+                          streams), ratio is effectively the same as
+                          the output sampling rate */
+
+                       return ratio;
+               }
+
+       override (Bonobo:Media:Stream)
+               gint get_length (BonoboMediaStream *media_stream,
+                                CORBA_Environment *ev)
+               {
+                       return SELF (media_stream)->_priv->length;
+               }
+               
+       override (Bonobo:Media:Stream)
+               void seek (BonoboMediaStream *media_stream,
+                          gint pos,
+                          CORBA_Environment *ev)
+               {
+                       gint seek_success = TRUE;
+                       BonoboMediaGStreamer *self = SELF (media_stream);
+
+                       if (pos < 0 || pos > self->_priv->length) {
+                               CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+                                                    ex_Bonobo_Media_Stream_InvalidPosition,
+                                                    NULL);
+                               return;
+                       }
+
+                       if (!seek_success) {
+                               CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+                                                    ex_Bonobo_Media_Stream_InvalidPosition,
+                                                    NULL);
+                               return;
+                       }
+                       update_position (self);
+               }
+
+       private gboolean         playing = FALSE;
+
+       private void audio_init (self)
+               {
+               }
+       
+       private void* player_func (self)
+               {
+                  return NULL;
+               }
+       
+       private void audio_cleanup (self)
+               {
+               }
+       
+       override (Bonobo:Media:Stream)
+               void play (BonoboMediaStream *media_stream,
+                          CORBA_Environment *ev)
+               {
+                       BonoboMediaGStreamer *self = SELF (media_stream);
+                       
+                       gst_play_play (self->_priv->play);
+
+                       self->_priv->playing = TRUE;
+                        
+                       if (!self->_priv->timeout_id)
+                               self->_priv->timeout_id = 
+                                       gtk_timeout_add (100, (GtkFunction)update_position, self);
+               }
+
+       override (Bonobo:Media:Stream)
+               void stop (BonoboMediaStream *media_stream,
+                          CORBA_Environment *ev)
+               {
+                       BonoboMediaGStreamer *self = SELF (media_stream);
+                       
+                       self->_priv->playing = FALSE;
+                       
+                       if (self->_priv->timeout_id)
+                               gtk_timeout_remove (self->_priv->timeout_id);
+                               
+                       self->_priv->timeout_id = 0;
+               }
+               
+       private void volume_cb (GtkObject *obj, gfloat vol,
+                               Bonobo:Media:GStreamer *self (check null type))
+               {
+                       g_print ("Volume changed to %f\n", vol);
+               }
+
+       private void speaker_cb (GtkObject *obj,
+                                Bonobo:Media:GStreamer *self (check null type))
+               {
+                       audio_cleanup (self);
+                       audio_init (self);
+               }
+               
+       private void read_file_info (self)
+               {       
+               }
+
+       public gint PersistFile_load (BonoboPersistFile   *pf,
+                                     const CORBA_char    *filename,
+                                     CORBA_Environment   *ev,
+                                     Bonobo:Media:GStreamer *self (check null type))
+               {
+                       load_file (self, filename);
+                       
+                       return 0;
+               }
+
+       public gint PersistFile_save (BonoboPersistFile   *pf,
+                                     const CORBA_char    *filename,
+                                     CORBA_Environment   *ev,
+                                     Bonobo:Media:GStreamer *self (check null type))
+               {
+                       CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+                                            ex_Bonobo_NotSupported, NULL);
+                       return 0;
+               }
+       
+       public void load_file (self, const gchar *filename)
+               {
+                  gst_play_set_uri (self->_priv->play, filename);
+               }
+
+       private void construct (self)
+               {
+                       Bonobo_Media_Stream corba_stream;
+                       BonoboMediaVideo *gstreamer_video;
+                       BonoboPersistFile *pf;
+                       
+                       corba_stream = bonobo_media_stream_corba_object_create (BONOBO_OBJECT (self));
+
+                       self->_priv->play = gst_play_new ();
+                       //self->_priv->play = gtk_button_new ();
+
+                       gstreamer_video = BONOBO_MEDIA_VIDEO (bonobo_media_gstreamervideo_new (self->_priv->play));
+
+                       bonobo_object_add_interface (BONOBO_OBJECT (self), BONOBO_OBJECT (gstreamer_video));
+
+                       pf = bonobo_persist_file_new
+                               ((BonoboPersistFileIOFn) PersistFile_load,
+                                (BonoboPersistFileIOFn) PersistFile_save,
+                                self);
+                       bonobo_object_add_interface (BONOBO_OBJECT (self),
+                                                    BONOBO_OBJECT (pf));
+                       
+                       bonobo_media_stream_construct (BONOBO_MEDIA_STREAM (self), corba_stream);
+               }
+
+       public Bonobo:Media:GStreamer* new_from_file (const gchar *filename)
+               {
+                       Self *self;
+
+                       self = bonobo_media_gstreamer_new ();
+
+                       construct (self);
+                       load_file (self, filename);
+
+                       return self;
+               }
+
+       public Bonobo:Media:GStreamer* new (void)
+               {
+                       Self *self;
+                       
+                       self = GET_NEW;
+                       
+                       construct (self);
+
+                       return self;
+               }
+}
diff --git a/components/bonobo-media/bonobo-media-gstreamer.oafinfo b/components/bonobo-media/bonobo-media-gstreamer.oafinfo
new file mode 100644 (file)
index 0000000..d3cb391
--- /dev/null
@@ -0,0 +1,30 @@
+<oaf_info>
+<oaf_server iid="OAFIID:Bonobo_Media_GStreamer_Factory" type="exe" location="bonobo-media-gstreamer">
+<oaf_attribute name="repo_ids" type="stringv">
+<item value="IDL:Bonobo/GenericFactory:1.0"/>
+</oaf_attribute>
+<oaf_attribute name="name" type="string" value="Bonobo Media Ogg GStreamer player factory"/>
+<oaf_attribute name="description" type="string" value="Bonobo Media Ogg GStreamer player factory"/>
+</oaf_server>
+
+<oaf_server iid="OAFIID:Bonobo_Media_GStreamer" type="factory" location="OAFIID:Bonobo_Media_GStreamer_Factory">
+<oaf_attribute name="repo_ids" type="stringv">
+<item value="IDL:Bonobo/Unknown:1.0"/>
+<item value="IDL:Bonobo/Media/Stream:1.0"/>
+<item value="IDL:Bonobo/EventSource:1.0"/>
+<item value="IDL:Bonobo/Media/Audio:1.0"/>
+<item value="IDL:Bonobo/Media/Video:1.0"/>
+<item value="IDL:Bonobo/PersistFile:1.0"/>
+<item value="IDL:Bonobo/Persist:1.0"/>
+</oaf_attribute>
+<oaf_attribute name="name" type="string" value="Bonobo Media Ogg GStreamer component"/>
+<oaf_attribute name="description" type="string" value="Bonobo Media component for playing back Ogg
+GStreamer files (uses libogg/libvorbis/libao as the backend)"/>
+<oaf_attribute name="bonobo:editable" type="boolean" value="false"/>
+<oaf_attribute name="bonobo:supported_mime_types" type="stringv">
+<item value="video/mpeg"/>
+<item value="audio/x-mp3"/>
+</oaf_attribute>
+</oaf_server>
+
+</oaf_info>
diff --git a/components/bonobo-media/bonobo-media-gstreamervideo.gob b/components/bonobo-media/bonobo-media-gstreamervideo.gob
new file mode 100644 (file)
index 0000000..d518a54
--- /dev/null
@@ -0,0 +1,86 @@
+/* vim: set syntax=c: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+*/
+%at{
+ /* bonobo-media-gstreamer: GStreamer player using the Bonobo:Meida interfaces
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (c) 2001  Ali Abdin   <aliabdin@aucegypt.edu> and
+ *                     ÉRDI Gergõ  <cactus@cactus.rulez.org>
+ *                     Wim Taymans <wim.taymans@chello.be>
+ */
+%}
+
+%header{
+#include <bonobo-media/Bonobo-Media.h>
+#include <bonobo-media/bonobo-media-video.h>
+#include <gstplay/gstplay.h>
+%}
+
+%privateheader{
+%}
+
+%{
+#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-exception.h>
+
+#include <bonobo-media/bonobo-media-video-private.h>
+
+%}
+
+class Bonobo:Media:GStreamervideo from Bonobo:Media:Video
+{
+       private GstPlay         *play;
+       //private GtkWidget     *play;
+
+       override (Bonobo:Media:Video)
+               Bonobo_Control get_video_control (BonoboMediaVideo *video,
+                                                 CORBA_Environment *ev)
+               {
+                       BonoboControl *control;
+                       Bonobo_Control bcontrol;
+                       Self *self = SELF (video);
+                       GtkWidget *button;
+
+                       //button = gtk_button_new_with_label("test");
+                       //gtk_widget_show (button);
+                       
+                       //control = bonobo_control_new (button);
+                       control = bonobo_control_new (GTK_WIDGET (self->_priv->play));
+
+                       gtk_widget_realize (GTK_WIDGET (self->_priv->play));
+
+                       bcontrol = bonobo_object_corba_objref (BONOBO_OBJECT (control));
+
+                       return bcontrol;
+               }
+
+       public Bonobo:Media:GStreamervideo* new (GstPlay *play)
+               {
+                       Self *self;
+                       Bonobo_Media_Video corba_video;
+                       BonoboMediaVideo *video;
+                       
+                       self = GET_NEW;
+
+                       corba_video = bonobo_media_video_corba_object_create (BONOBO_OBJECT (self));
+
+                       self->_priv->play = play;
+                       
+                       video = bonobo_media_video_construct (BONOBO_MEDIA_VIDEO (self), corba_video);
+
+                       return self;
+               }
+}