After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 424157 - (gst-play-audio-file) Provide gst_play_audio_file
(gst-play-audio-file)
Provide gst_play_audio_file
Status: VERIFIED WONTFIX
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.x
Other Linux
: Normal enhancement
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 439091 505401 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-03-29 15:30 UTC by Mathias Hasselmann (IRC: tbf)
Modified: 2009-06-18 21:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample implementation of gst_play_file (2.05 KB, text/x-csrc)
2007-03-29 15:30 UTC, Mathias Hasselmann (IRC: tbf)
Details
gst-player.c (4.21 KB, text/x-csrc)
2007-03-30 18:36 UTC, Mathias Hasselmann (IRC: tbf)
Details
gst-player.h (2.18 KB, text/x-chdr)
2007-03-30 18:37 UTC, Mathias Hasselmann (IRC: tbf)
Details
hello-gst.c (761 bytes, text/x-csrc)
2007-03-30 18:37 UTC, Mathias Hasselmann (IRC: tbf)
Details

Description Mathias Hasselmann (IRC: tbf) 2007-03-29 15:30:00 UTC
GStreamer often is called too complicated and heavy for simple usage. Considering that there is this great playbin element, I believe this assumption is wrong. All that GStreamer needs for overcoming this wrong picture is a simple API like this:

gboolean 
gst_play_file (const gchar *filename, GError **error);

Filename would be the absolute path to a file GStreamer can handle. The function returns TRUE on success and FALSE on failure. Having such a function, hello-gst.c would be reduced to this trivial snipped of code:

int main (int argc, char *argv[]) {
    GError *error = NULL;

    gst_init (&argc, &argv);

    if (argc < 2) {
	g_print ("Usage: %s FILENAME\n", argv[0]);
        return 1;
    }

    if (!gst_play_file (argv[1], &error)) {
	g_warning (error ? error->message : "Unknown error");
	g_clear_error (&error);
	return 1;
    }

    return 0;
}

My assumption and hope is, that this function would greatly extend usage of GStreamer as nobody could argue any more, GStreamer would be too complicated for his/her simple application.

See also: Bug 424143, Project Ridley.
Comment 1 Mathias Hasselmann (IRC: tbf) 2007-03-29 15:30:50 UTC
Created attachment 85517 [details]
Sample implementation of gst_play_file

Hope I've got it right: I am clearly no GStreamer expert.
Comment 2 David Schleef 2007-03-29 18:45:09 UTC
I'm not convinced of the usefulness of this.  Sure, it's good for a simple hello world program, but in order to integrate it into a gtk app, for example, you need to deal with:

 - where the video output should go

 - how to handle play/pause/stop buttons

 - how to integrate into the glib main loop

 - how to handle URIs

 - how to handle missing codecs

Comment 3 Mathias Hasselmann (IRC: tbf) 2007-03-29 20:39:27 UTC
(In reply to comment #1)
> Created an attachment (id=85517) [edit]
> Sample implementation of gst_play_file
> 
> Hope I've got it right: I am clearly no GStreamer expert.
> 

Playing videos, controlling playback, network access, weird codecs is not the scope of this tiny function. Purpose I have in mind for this function is just playing simple audio samples you have somewhere on your disk. That primitive stuff you have in /usr/share/sounds. Had that idea, when some folk on GTK+ asked about how to do this. If he shall use plain Alsa, or Jack, or ESD, or libaudiofile, or even directly write to /dev/dsp? And I thought: Hell, there we have this fine media framework, and you cannot even use it for this trivial usecase of playing a fixed audio snippet, as its API is far too complicated for this trivial use case. 

As sound as you want to do more complicated stuff involing pause, stop, remote files, then the regular API of GStreamer is just fine for my taste. Well - I know, I repeat myself - for the trivial, but common usecase of just playing a audio sample, current GStreamer API is pure overkill. Adding that trival function could greatly improve utility of GStreamer.

As you raised the main-loop issue. Also thought about this already. Have not found a good solution yet.
Comment 4 David Schleef 2007-03-29 22:32:21 UTC
Ok, I misunderstood what you said in #1, then.  I agree, a dirt simple audio player would be easy and beneficial for anyone trying to migrate away from audiofile, etc.

Main loop integration for such a case is fairly easy (in pseudocode):

gst_play_audio_file() {
  set up pipeline
  add idle handler to main loop
  set pipeline to PLAYING
  return object
}

idle_handler() {
  get bus message
  handle bus message
  if in error state, fire error signal
  if done, fire done signal
  if not done, re-add idle handler
}

In this case, gst_play_audio_file() returns immediately, and the app can wait for the "done" signal if it wants.  Or, there could be a separate waiting version.
Comment 5 Mathias Hasselmann (IRC: tbf) 2007-03-30 07:28:57 UTC
Indeed! Using g_idle_add fills the gap and letting gst_play_file return a object provides a clean path for future extensions, if there should be requests for getting slightly more control.
Comment 6 Mathias Hasselmann (IRC: tbf) 2007-03-30 18:36:59 UTC
Created attachment 85577 [details]
gst-player.c
Comment 7 Mathias Hasselmann (IRC: tbf) 2007-03-30 18:37:24 UTC
Created attachment 85578 [details]
gst-player.h
Comment 8 Mathias Hasselmann (IRC: tbf) 2007-03-30 18:37:44 UTC
Created attachment 85579 [details]
hello-gst.c
Comment 9 Tim-Philipp Müller 2007-05-17 11:36:20 UTC
*** Bug 439091 has been marked as a duplicate of this bug. ***
Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2007-11-07 06:35:02 UTC
for me playbin is easy enough to be used. and it already provides close-to-play-file api. just having play-fille is too simple even for simple case like providing preview in file-chooser.
Comment 11 Mathias Hasselmann (IRC: tbf) 2007-11-07 08:31:29 UTC
(In reply to comment #10)
> for me playbin is easy enough to be used. and it already provides
> close-to-play-file api. just having play-fille is too simple even for simple
> case like providing preview in file-chooser.

Yes, playbin is easy when you took the time to learn the concepts of GStreamer. You'll agree that learning those concepts can take some hours - depending on your background. In opposition to that gst_play_file shall provide a convenient API for those who want to play a simple notification sound without caring much about having a complete audio framework. 

In case they realize later that they need the framework they know which one to use ;-)

Comment 12 Mathias Hasselmann (IRC: tbf) 2007-11-07 08:32:55 UTC
Btw, when reading the entire report again: s/gst_play_file/gst_play_audio_file/
Comment 13 Stefan Sauer (gstreamer, gtkdoc dev) 2007-11-07 12:34:03 UTC
Matthias, please don't get me wrong, but I belive in most cases it would be too simple. Could you share with use what use-cases you have in mind? I could only think of sound-events, but they should be done via e.g. libnotify or the libcanberra proposal (from the pulseaudio developer).
Comment 14 Wim Taymans 2007-12-24 12:37:03 UTC
*** Bug 505401 has been marked as a duplicate of this bug. ***
Comment 15 Jaap A. Haitsma 2007-12-26 18:33:29 UTC
Stefan,

libcanberra seems to be stuck in the proposal stage if I look at SVN [1]

Is linking to a library like libnotify not a bit overdone if you just want to have a sound event. Furthermore libnotify is not a part of the GNOME desktop

Can you explain why you think a very basic API that plays audio files does not belong in gstreamer? 

For a programmer not familiar with gstreamer that just wants to add a sound event to it's program using a playbin is not trivial.

Jaap


[1] http://svn.0pointer.de/viewvc/trunk/?root=libcanberra
Comment 16 Wim Taymans 2007-12-28 10:15:00 UTC
@Jaap: I have no problem with simple APIs but adding them to the GStreamer core is not a good idea for the same reason GTK+ does not have an API for a simple text editor.

I believe we should have a simple API for common things, like the audio playback example and I also believe it should go into a library, other than GStreamer, that does this. 

For events you also typically want to cache them serverside (to reduce latency and CPU, especially in embedded devices and thin clients). The above simple API on top of playbin then needs to be extended some more (it also does not handle the cases where you have an error while playing). 

I'm willing to add this as an example object that demonstrates how to shuffly around signals, GError and encapsulate multiple GStreamer objects, but going as far as promote this as the blessed 'ding'-API is not going to happen. 
Comment 17 Jaap A. Haitsma 2007-12-28 15:22:09 UTC
Wim, I see your point. In that case a library like libnotify is indeed a better idea.
I filed a bug on libnotify
http://trac.galago-project.org/ticket/153
Comment 18 Tim-Philipp Müller 2009-06-08 23:16:27 UTC
Let's WONTFIX this. There's certainly a niche for such a small helper function/lib somewhere, but I don't see it being added anywhere in GStreamer any time soon, especially not now that there's libcanberra, which is also a much better choice for this kind of thing.
Comment 19 Mathias Hasselmann (IRC: tbf) 2009-06-18 21:56:10 UTC
(In reply to comment #18)
> Let's WONTFIX this. There's certainly a niche for such a small helper
> function/lib somewhere, but I don't see it being added anywhere in GStreamer
> any time soon, especially not now that there's libcanberra, which is also a
> much better choice for this kind of thing.
> 

ACK. Came to exactly the same conclusion when I saw the bug notification in my mailbox.