common.h 3.92 KB
Newer Older
hark's avatar
hark committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* [name], A player for snowmix
 *
 *
 * 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
 */


// don't define it here user gcc -DGST1
//#define GST1

// asprintf,getopt is gnu
//#define _GNU_SOURCE
// for getopt
//#define _XOPEN_SOURCE
#include <getopt.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
hark's avatar
hark committed
34
#include <regex.h>
hark's avatar
hark committed
35
36

// switch for strings
hark's avatar
hark committed
37
#include "switchs.h"
hark's avatar
hark committed
38
39
40
41
42
43
44
45
46
47
48
49

// sockets
#include <netinet/in.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <arpa/inet.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>


hark's avatar
hark committed
50
//glib stuff
hark's avatar
hark committed
51
52
53
54
#include <glib.h>
#include <glib-2.0/glib/gprintf.h>
#include <glib-unix.h>

hark's avatar
hark committed
55
56
//gtk stuff

hark's avatar
hark committed
57
#ifdef GTK
hark's avatar
hark committed
58
59
60
61
62
63
64
65
66
67
68
#ifndef CLI
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#if defined (GDK_WINDOWING_X11)
#include <gdk/gdkx.h>
#elif defined (GDK_WINDOWING_WIN32)
#include <gdk/gdkwin32.h>
#elif defined (GDK_WINDOWING_QUARTZ)
#include <gdk/gdkquartz.h>
#endif
#endif
hark's avatar
hark committed
69
#endif
hark's avatar
hark committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//gstreamer stuff

#define GST_DISABLE_DEPRECATED

#ifdef GST1
#include <gstreamer-1.0/gst/gst.h>
#include <gstreamer-1.0/gst/pbutils/pbutils.h>
#include <gstreamer-1.0/gst/video/videooverlay.h>
#else
#include <gst/gst.h>
#include <gst/interfaces/xoverlay.h>
#include <gst/pbutils/pbutils.h>
#endif
// some macros

#define asprintf(...) if (asprintf (__VA_ARGS__) == -1) printf("asprintf failed\n");


#include "wraps.h"

#define gst_element_factory_make(element, name) gst_element_factory_make_debug (element, name);

hark's avatar
hark committed
92
enum {
hark's avatar
hark committed
93
  AUTO,
hark's avatar
hark committed
94
95
  JACK,
  SNOWMIX,
hark's avatar
hark committed
96
97
  FAKE,
  RTMP
hark's avatar
hark committed
98
};
hark's avatar
hark committed
99

hark's avatar
hark committed
100
101
102
103
typedef struct snowMixer snowMixer;
struct snowMixer {
  //general
  char *host; //host
hark's avatar
hark committed
104
  char  *port; //port
hark's avatar
hark committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  char *control_socket; //ctrsocket
  char *state; //snowmix
  //video
  int width; //system_width
  int height; //system_height
  char *ratefraction; //ratefraction
  //audio
  int audio_rate; //rate
  int audio_channels; //channels
};

typedef struct snowFeed snowFeed;
struct snowFeed {
  //general
  int id;
  char *control_pipe; //feed_control_pipe
  // video
  int width; //feed_width
  int height; //feed_height
  //framerate == mixer framerate 
  // audio
  //  int audio_backend; // jack??
  int audio_channels; //feed_channels
  int audio_rate;
};

typedef struct snowData snowData;
struct snowData {
  snowFeed *currentFeed;
  snowMixer *mixer;
hark's avatar
hark committed
135
  int audiosink;
hark's avatar
hark committed
136
137
};

hark's avatar
hark committed
138
/* Structure to contain all our information, so we can pass it around */
hark's avatar
hark committed
139
140
typedef struct PlayerData PlayerData;
struct PlayerData{
hark's avatar
hark committed
141
142
143
144
145
146
147
  // things that used to be global vars
  char *playuri; 
  int feedid;
  int sink;
  int preview;
  //mainloop
  GMainLoop *loop;
hark's avatar
hark committed
148
  //gstreamer
hark's avatar
hark committed
149
150
  GstElement *playbin2;		/* Our one and only pipeline */
  GstDiscoverer *discoverer;
hark's avatar
hark committed
151
152
  GstState state;		/* Current state of the pipeline */
  gint64 duration;		/* Duration of the clip, in nanoseconds */
hark's avatar
hark committed
153
154
  GstElement *valve;
 
hark's avatar
hark committed
155
156
//gtk
#ifdef GTK
hark's avatar
hark committed
157
158
159
  GtkWidget *slider;		/* Slider widget to keep track of current position */
  GtkWidget *streams_list;	/* Text widget to display info about the streams */
  gulong slider_update_signal_id;	/* Signal ID for the slider update signal */
hark's avatar
hark committed
160
  GtkWidget *preview_check;
hark's avatar
hark committed
161
#endif
hark's avatar
hark committed
162
 snowData *snow;
hark's avatar
hark committed
163
};
hark's avatar
hark committed
164

hark's avatar
hark committed
165
//CustomData globalData;
hark's avatar
hark committed
166

hark's avatar
hark committed
167
168
PlayerData *pData;
//CustomData *data;
hark's avatar
hark committed
169

hark's avatar
hark committed
170
171
172
// depreciated globall vars 
#ifdef GTK
GtkWidget *loaded_label;
hark's avatar
hark committed
173
174
175
GtkWidget *playlist_view;
GtkWidget *playlist_box;
#endif
hark's avatar
hark committed
176
177
178
gboolean playabool;