Media with Gstreamer

Discussions about the internal structures of the game. You can also post here if you'd like to know how things really work (and don't know how to read C code).
Post Reply
GeoVah
Posts: 50
Joined: Sat Dec 18, 2004 10:38 am
Location: Sophia Antipolis - France

Media with Gstreamer

Post 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.
Geovah - geovah@jabber.sk- (yes i'm french...)
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Post by gyboth »

what kind of error do you get? i mean, what exactly?

gyözö
Press any key to continue or any other key to quit.
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Post 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ö
Press any key to continue or any other key to quit.
GeoVah
Posts: 50
Joined: Sat Dec 18, 2004 10:38 am
Location: Sophia Antipolis - France

Post 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.
Geovah - geovah@jabber.sk- (yes i'm french...)
GeoVah
Posts: 50
Joined: Sat Dec 18, 2004 10:38 am
Location: Sophia Antipolis - France

Post 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.
Geovah - geovah@jabber.sk- (yes i'm french...)
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Post 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ö
Press any key to continue or any other key to quit.
vector
Posts: 449
Joined: Sat Dec 18, 2004 11:26 pm
Location: Australia, Victoria

Post 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
"There are two ways to score. Dribble it over the line or smash it into the back of the net."
What type are you?
gyboth
Site Admin
Posts: 1421
Joined: Sat Dec 18, 2004 8:42 am
Location: Passau, Germany
Contact:

Post 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ö
Press any key to continue or any other key to quit.
Post Reply