vitunes
 All Data Structures
gstplayer.h
1 /*
2  * Copyright (c) 2011 Daniel Walter <sahne@0x90.at>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /*
18  * gstplayer.h
19  *
20  * This gstreamer based player is part of vitunes, a great player written
21  * by Ryan Flannery.
22  */
23 
24 #ifndef VITUNES_GSTPLAYER_H
25 #define VITUNES_GSTPLAYER_H
26 
27 #include <gst/gst.h>
28 #include <stdbool.h>
29 
30 typedef struct {
31  float position;
32  float volume;
33  bool playing;
34  bool paused;
35  bool about_to_finish;
36  /* callback functions */
37  void (*playnext_cb)(void);
38  void (*notice_cb)(char *, ...);
39  void (*error_cb)(char *, ...);
40  void (*fatal_cb)(char *, ...);
41 
42  /* backend data */
43  GstElement *player;
44  GstBus *bus;
45 } gst_player;
46 
47 void gstplayer_init();
48 void gstplayer_cleanup();
49 
50 void gstplayer_stop();
51 void gstplayer_play(const char *);
52 void gstplayer_pause();
53 
54 void gstplayer_seek(int);
55 void gstplayer_volume_step(float);
56 
57 float gstplayer_get_position();
58 float gstplayer_get_volume();
59 bool gstplayer_is_playing();
60 bool gstplayer_is_paused();
61 
62 void gstplayer_set_callback_playnext(void (*f)(void));
63 void gstplayer_set_callback_notice(void (*f)(char *, ...));
64 void gstplayer_set_callback_error(void (*f)(char *, ...));
65 void gstplayer_set_callback_fatal(void (*f)(char *, ...));
66 
67 void gstplayer_monitor();
68 
69 #endif /* VITUNES_GSTPLAYER_H */