33 #include <gst/audio/gstaudiobasesrc.h>
34 #include <gst/app/gstappsrc.h>
37 #define DEBUG_READ_PURE_OGG 1
48 #define BUFFER_TIME 1000
54 #define LATENCY_TIME 1000
89 if (GST_IS_AUDIO_BASE_SRC (
object))
106 sinkpad = gst_element_get_static_pad (
decoder,
"sink");
108 gst_pad_link (pad, sinkpad);
112 gst_object_unref (sinkpad);
120 gst_app_src_end_of_stream (GST_APP_SRC (
source));
122 gst_element_set_state (
pipeline, GST_STATE_NULL);
132 switch (GST_MESSAGE_TYPE (
msg))
134 case GST_MESSAGE_EOS:
140 case GST_MESSAGE_ERROR:
145 gst_message_parse_error (
msg, &error, &
debug);
151 g_error_free (error);
180 "Feeding %u bytes to GStreamer\n",
181 (
unsigned int) b_len);
183 bufspace = g_memdup2 (audio, b_len);
184 b = gst_buffer_new_wrapped (bufspace, b_len);
188 "Failed to wrap a buffer\n");
192 flow = gst_app_src_push_buffer (GST_APP_SRC (
source), b);
201 "Fed %u bytes to the pipeline\n",
202 (
unsigned int) b_len);
205 case GST_FLOW_FLUSHING:
208 "Dropped a buffer\n");
219 "Unexpected push result\n");
264 typedef void (*SignalHandlerPointer) (
int);
266 SignalHandlerPointer inthandler, termhandler;
267 #ifdef DEBUG_READ_PURE_OGG
268 int read_pure_ogg =
getenv (
"GNUNET_READ_PURE_OGG") ? 1 : 0;
271 inthandler = signal (SIGINT,
273 termhandler = signal (SIGTERM,
277 gst_init (&argc, &argv);
285 "Audio sink starts\n");
291 pipeline = gst_pipeline_new (
"audio-player");
303 "One element could not be created. Exiting.\n");
307 g_signal_connect (
sink,
317 gst_object_ref (GST_OBJECT (
source));
322 g_object_set (G_OBJECT (
source),
328 g_object_set (G_OBJECT (
decoder),
331 "use-inband-fec", TRUE,
335 bus = gst_pipeline_get_bus (GST_PIPELINE (
pipeline));
337 gst_object_unref (bus);
349 gst_element_set_state (
pipeline, GST_STATE_PLAYING);
359 ret = read (0, readbuf,
sizeof(readbuf));
363 _ (
"Read error from STDIN: %d %s\n"),
364 ret, strerror (errno));
369 "Received %d bytes of audio data (total: %llu)\n",
371 (
unsigned long long) toff);
374 #ifdef DEBUG_READ_PURE_OGG
389 signal (SIGINT, inthandler);
390 signal (SIGINT, termhandler);
393 "Returned, stopping playback\n");
397 "Deleting pipeline\n");
398 gst_object_unref (GST_OBJECT (
source));
400 gst_object_unref (GST_OBJECT (
pipeline));
402 g_source_remove (bus_watch_id);
struct GNUNET_MessageHeader * msg
constants for network protocols
static int ret
Return value of the commandline.
static void signalhandler(int s)
static void sink_child_added(GstChildProxy *child_proxy, GObject *object, gchar *name, gpointer user_data)
static int abort_read
Set to 1 to break the reading loop.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
#define LATENCY_TIME
Min number of microseconds to buffer in audiosink.
static GstElement * pipeline
Main pipeline.
int main(int argc, char **argv)
#define MAXLINE
How much data to read in one go.
static void ogg_pad_added(GstElement *element, GstPad *pad, gpointer data)
static GstElement * decoder
static int stdin_receiver(void *cls, const struct GNUNET_MessageHeader *msg)
Message callback.
static GstElement * resampler
struct GNUNET_MessageStreamTokenizer * stdin_mst
Tokenizer for the data we get from stdin.
static int feed_buffer_to_gst(const char *audio, size_t b_len)
static GstElement * demuxer
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data)
#define BUFFER_TIME
Max number of microseconds to buffer in audiosink.
uint32_t data
The data value.
Core service; the main API for encrypted P2P communications.
#define gst_element_factory_make(element, name)
Constants for network protocols.
#define GNUNET_log(kind,...)
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO
Message to transmit the audio between helper and speaker/microphone library.
enum GNUNET_GenericReturnValue GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
Message to transmit the audio (between client and helpers).
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO.
Handle to a message stream tokenizer.