31#include <gst/audio/gstaudiobasesrc.h>
32#include <gst/app/gstappsrc.h>
35#define DEBUG_READ_PURE_OGG 1
46#define BUFFER_TIME 1000
52#define LATENCY_TIME 1000
87 if (GST_IS_AUDIO_BASE_SRC (
object))
101 GstElement *decoder_tmp = (GstElement *)
data;
104 sinkpad = gst_element_get_static_pad (decoder_tmp,
"sink");
106 gst_pad_link (pad, sinkpad);
110 gst_object_unref (sinkpad);
118 gst_app_src_end_of_stream (GST_APP_SRC (
source));
120 gst_element_set_state (
pipeline, GST_STATE_NULL);
130 switch (GST_MESSAGE_TYPE (
msg))
132 case GST_MESSAGE_EOS:
138 case GST_MESSAGE_ERROR:
143 gst_message_parse_error (
msg, &error, &
debug);
149 g_error_free (error);
178 "Feeding %u bytes to GStreamer\n",
179 (
unsigned int) b_len);
181 bufspace = g_memdup2 (audio, b_len);
182 b = gst_buffer_new_wrapped (bufspace, b_len);
186 "Failed to wrap a buffer\n");
190 flow = gst_app_src_push_buffer (GST_APP_SRC (
source), b);
199 "Fed %u bytes to the pipeline\n",
200 (
unsigned int) b_len);
203 case GST_FLOW_FLUSHING:
206 "Dropped a buffer\n");
217 "Unexpected push result\n");
262 typedef void (*SignalHandlerPointer) (
int);
264 SignalHandlerPointer inthandler, termhandler;
265#ifdef DEBUG_READ_PURE_OGG
266 int read_pure_ogg =
getenv (
"GNUNET_READ_PURE_OGG") ? 1 : 0;
269 inthandler = signal (SIGINT,
271 termhandler = signal (SIGTERM,
275 gst_init (&argc, &argv);
283 "Audio sink starts\n");
289 pipeline = gst_pipeline_new (
"audio-player");
301 "One element could not be created. Exiting.\n");
305 g_signal_connect (
sink,
315 gst_object_ref (GST_OBJECT (
source));
320 g_object_set (G_OBJECT (
source),
326 g_object_set (G_OBJECT (
decoder),
329 "use-inband-fec", TRUE,
333 bus = gst_pipeline_get_bus (GST_PIPELINE (
pipeline));
335 gst_object_unref (bus);
347 gst_element_set_state (
pipeline, GST_STATE_PLAYING);
357 ret = read (0, readbuf,
sizeof(readbuf));
361 _ (
"Read error from STDIN: %d %s\n"),
362 ret, strerror (errno));
367 "Received %d bytes of audio data (total: %llu)\n",
369 (
unsigned long long) toff);
372#ifdef DEBUG_READ_PURE_OGG
387 signal (SIGINT, inthandler);
388 signal (SIGINT, termhandler);
391 "Returned, stopping playback\n");
395 "Deleting pipeline\n");
396 gst_object_unref (GST_OBJECT (
source));
398 gst_object_unref (GST_OBJECT (
pipeline));
400 g_source_remove (bus_watch_id);
struct GNUNET_MessageHeader * msg
constants for network protocols
static int ret
Final status code.
static char * data
The data to insert into the dht.
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.
static char * name
Name (label) of the records to list.
#define gst_element_factory_make(element, name)
Constants for network protocols.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ 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.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a 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.