tidied code formatting
[maemo-recorder] / src / maemo-recorder.h
1 /* vim: set ts=4 sw=4 et: */
2 /*
3  * maemo-recorder.h
4  *
5  * Copyright (C) 2006 Nokia Corporation
6  *
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22
23 #ifndef _MAEMO_RECORDER_H_
24 #define _MAEMO_RECORDER_H_
25
26 #include <libosso.h>
27 #include <osso-log.h>
28 #include <hildon-widgets/hildon-program.h>
29 #include <hildon-widgets/hildon-window.h>
30
31 #include <gtk/gtk.h>
32 #include <gst/gst.h>
33 #include <sys/time.h>
34
35 #define SERVICE_NAME "maemo_recorder"
36 #define SERVICE_NAME_FULL "com.nokia.maemo_recorder"
37
38 #define DEFAULT_CHANNELS 1
39 #define DEFAULT_RATE 8000
40
41 #define GST_TYPE_ILBC "audio/x-iLBC"
42 #define ILBC_RATE DEFAULT_RATE
43
44 /* 
45  * 15.2 kbps (SI kilo) for 20 ms frames
46  * 38 bytes / frame, 50 frames / sec 
47  */
48 /* 13.33 kbps for 30 ms frames */
49 #define ILBC_BITRATE_20 15200
50 /* 8000 Hz * 8 bits/sample */
51 #define PCMA_BITRATE 64000
52 #define PCMU_BITRATE 64000
53
54 #define GST_TYPE_PCMA "audio/x-alaw"
55 #define GST_TYPE_PCMU "audio/x-mulaw"
56 #define GST_TYPE_PCM "audio/x-raw-int"
57 #define PCM_RATE 8000
58 #define PCM_WIDTH 16
59 #define PCM_DEPTH 16
60 #define PCM_ENDIANNESS 1234
61
62 typedef enum
63 {
64     APPSTATE_READY = 1,
65     APPSTATE_PLAYING,
66     APPSTATE_RECORDING
67 } AppState;
68
69 typedef enum
70 {
71     FORMAT_NONE = 0,
72     FORMAT_PCM,
73     FORMAT_PCMA,
74     FORMAT_PCMU,
75     FORMAT_ILBC,
76     FORMAT_MP3,
77     FORMAT_WAV
78 } AudioFormat;
79
80 /* TODO: this kind of struct might be more handy when passing around audioformat info */
81 #if 0
82 struct _AudioFormatSpec
83 {
84     AudioFormat format;
85     gchar *mime_type;
86     gint rate;
87     gint channels;
88     gint width;
89     gint depth;
90     gint endianness;
91     gint frame_len;
92     gint frame_size;
93 };
94
95 typedef struct _AudioFormatSpec AudioFormatSpec;
96 #endif
97
98 typedef enum
99 {
100     TYPE_FILE = 0,
101     TYPE_STREAM = 1
102 } PipeMode;
103
104 typedef struct _mainViewStr
105 {
106     GtkWidget *toolBar;
107     GtkWidget *fileNameEntry;
108     GtkWidget *lengthEntry;
109     GtkWidget *stateEntry;
110     GtkObject *adjustment;
111
112 } mainViewStr;
113
114 typedef struct _AppDataStr
115 {
116     HildonProgram *app;
117     HildonWindow *mainView;
118
119     mainViewStr mainViewData;
120
121     /* gstreamer components */
122     GstElement *pipeline;
123     GstElement *recPipeline;
124     GstElement *playPipeline;
125     GstElement *queue;
126     gint playPipelineType;
127
128     osso_context_t *osso;
129
130     gchar * openFileName;
131     gchar * saveFileName;
132     gboolean saved;
133
134     AudioFormat filter;      /* selected recording format */
135     AudioFormat file_format; /* format of the recorded file or file currently open */
136     PipeMode type;
137     GtkWidget* radio_pcma;
138     GtkWidget* radio_ilbc;
139     GtkWidget* radio_pcm;          
140     GtkWidget* radiotype;
141     AppState state;
142
143     GtkWidget *buttonSave;
144     GtkWidget *buttonSaveAs;
145     GtkWidget *buttonPlay;
146     GtkWidget *buttonRec;
147
148     struct timeval recStartTv; /* timeval when recording started */
149     guint recUpdateId;     /* g_source_id for rec update timeout func */
150     gchar *mimeURI;        /* uri to open via mime cb */
151
152 } AppData;
153
154 void setAppState(AppData *app, AppState state);
155 AppState getAppState(AppData *app);
156
157 #if 0
158 AudioFormatSpec * audio_format_spec_new(void);
159 void audio_format_spec_free(AudioFormatSpec *af);
160 #endif
161
162 #endif /* _MAEMO_RECORDER_H_ */