Page 1 of 1

Media with Gstreamer

Posted: Thu Nov 03, 2005 11:47 am
by GeoVah
I've started to use gstreamer for bygfoot media API.
This API contains (now) those functions :

//start to init GStreamer
gint mediaPlayer_init();

//play a sound and return from function when sound is stop
gint mediaPlayer_playSoundToEnd(const gchar *path);


The implementation is on going, the configure.in script has been modified to check for GSTREAMER and add a #define into config.h

BUT nothing is working now :-s
-> compil problem


I've wanted to add three more functions :

//Start to play a sound (needthread :-s
gint mediaPlayer_playSoundAndComeBack(const gchar *path,gint * soundId);

//stop a sound which is playing
gint mediaPlayer_stopSound(gint soundId);

//Play a video. return when video is stop.
gint mediaPlayer_playVideo(const gchar * path);


PS : all this code is on my computer, with a copy/paste from GStream Developer doc.

Posted: Thu Nov 03, 2005 11:54 am
by gyboth
what kind of error do you get? i mean, what exactly?

gyözö

Posted: Thu Nov 03, 2005 12:00 pm
by gyboth
i'm not sure config.h is the right file to tinker with (i never edited it).
from the gstreamer docs:
gstreamer docs wrote:Initializing GStreamer

When writing a GStreamer application, you can simply include gst/gst.h to get access to the library functions. Besides that, you will also need to intialize the GStreamer library.
so, you should make files 'sound.c/h' and put

Code: Select all

#include <gst/gst.h>
into the h file. put it also into main.c and call

Code: Select all

gst_init (&argc, &argv);
somewhere in main() (after 'g_init' or so).

put all sound-related funcs into sound.c.

gyözö

Posted: Thu Nov 03, 2005 1:09 pm
by GeoVah
gyboth wrote:i'm not sure config.h is the right file to tinker with (i never edited it).
I've not directly edit config.h but this file is modified to have a #define HAVE_GSTREAMER if gstreamer is detected on the current computer with a ./configure --enable-gstreamer
This is why i have modified the configure.in file

My .c file looks like :

Code: Select all

#ifdef HAVE_GSTREAMER
gint mediaPlayer_int(int argc,char * argv[]) {

}
#else 
gint mediaPlayer_init(int argc,char *argv[]) {
  return 0;
}
#endif
So it's the media code who know if it sound is enable or not at COMPIL time :
the one who want to play sound always call mediaPlayer_playSound().

gyboth wrote: put all sound-related funcs into sound.c.
gyözö
My filename are mediaplayer.h and mediaplayer.c since i planned to support video.

in order to simplyfi the code, I started to only support Ogg/Vorbis audio file.

Posted: Thu Nov 03, 2005 1:13 pm
by GeoVah
gyboth wrote:what kind of error do you get? i mean, what exactly?

gyözö
I don't have access to my computer because i'm at work but the probleme is a bad header : error in gst/gst.h :( , very strange.

If you want, as soon as the ./configure --enable-gstreamer works totaly and mediaPlayer.c works (a little), I can send U or commit the code to the CVS.

Posted: Thu Nov 03, 2005 1:38 pm
by gyboth
GeoVah wrote:I've not directly edit config.h but this file is modified to have a #define HAVE_GSTREAMER if gstreamer is detected on the current computer with a ./configure --enable-gstreamer
This is why i have modified the configure.in file
ok, sounds like you know what you're doing.
the one who want to play sound always call mediaPlayer_playSound().
reasonable. may i ask you to make functions and variables lower-case and underscore-separated? that's the Bygfoot and GTK way of doing them, and it makes the code more consistent if you use it too. like this:

Code: Select all

mediaplayer_play_sound(const gchar *sound_file)
(note that almost all functions start with the filename they're in). and structs are like

Code: Select all

GeovahSoundStruct
ie. w/o underscores but capitalised.
gyboth wrote: put all sound-related funcs into sound.c.
gyözö
My filename are mediaplayer.h and mediaplayer.c since i planned to support video.
even better :-)
in order to simplyfi the code, I started to only support Ogg/Vorbis audio file.
i'd say we use ogg as the default format (the obvious choice for a GPL OSS). but maybe it's possible to create code that recognises the format, so that users can use their own mp3s and wavs, too, if they want.
GeoVah wrote:If you want, as soon as the ./configure --enable-gstreamer works totaly and mediaPlayer.c works (a little), I can send U or commit the code to the CVS.
send it to me first. and thanks for working on it, it's great that i don't have to do it ;-)

gyözö

Posted: Fri Nov 04, 2005 11:13 pm
by vector
I think things are starting to bend towards oog. Im certainly doing my bit on this side of the world to Ogg everything:)
Im not sure exactly what you guys are up to but let me know if you need sound effects or music

Posted: Sat Nov 05, 2005 8:29 pm
by gyboth
vector's really eager to have sounds it seems ;-)

i think we'll definitely be needing sounds (mainly for live game events, i guess), so keep your ears open and collect anything you think can be used.

gyözö