GNUnet 0.21.0
gnunet_gst_test.c File Reference

FIXME. More...

#include "platform.h"
#include "gnunet_gst_def.h"
#include "gnunet_gst.h"
Include dependency graph for gnunet_gst_test.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

FIXME.

Author
Hark

Definition in file gnunet_gst_test.c.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 31 of file gnunet_gst_test.c.

32{
33 struct GNUNET_gstData *gst;
34 // GstBus *bus;
35 GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder;
36
37
38 // audio_message = GNUNET_malloc (UINT16_MAX);
39 // audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
40
41
42 // GstPipeline *pipeline;
43
44 gst = (GNUNET_gstData *) malloc (sizeof(struct GNUNET_gstData));
45
46 // gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
47
48
50/*
51 gst->audiobackend = JACK;
52 gst->dropsilence = TRUE;
53 gst->usertp = FALSE;
54 *//* Initialize GStreamer */gst_init (&argc, &argv);
55
56 gst->pipeline = GST_PIPELINE (gst_pipeline_new ("gnunet-media-helper"));
57
58#ifdef IS_SPEAKER
59 int type = SPEAKER;
60 printf ("this is the speaker \n");
61#endif
62#ifdef IS_MIC
63 int type = MICROPHONE;
64 printf ("this is the microphone \n");
65#endif
66 if (type == SPEAKER)
67 {
68 gnunetsrc = GST_ELEMENT (get_app (gst, SOURCE));
69
70 sink = GST_ELEMENT (get_audiobin (gst, SINK));
71 decoder = GST_ELEMENT (get_coder (gst, DECODER));
72 gst_bin_add_many (GST_BIN (gst->pipeline), gnunetsrc, decoder, sink, NULL);
73 gst_element_link_many (gnunetsrc, decoder, sink, NULL);
74 }
75 if (type == MICROPHONE)
76 {
77 source = GST_ELEMENT (get_audiobin (gst, SOURCE));
78
79 encoder = GST_ELEMENT (get_coder (gst, ENCODER));
80
81 gnunetsink = GST_ELEMENT (get_app (gst, SINK));
82
83 gst_bin_add_many (GST_BIN (gst->pipeline), source, encoder, gnunetsink,
84 NULL);
85 gst_element_link_many (source, encoder, gnunetsink, NULL);
86 }
87 /*
88 gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL);
89 gst_element_link_many( source, encoder, decoder, sink , NULL);
90 */
91 pl_graph (gst->pipeline);
92 /* Start playing */
93 gst_element_set_state (GST_ELEMENT (gst->pipeline), GST_STATE_PLAYING);
94
95 // pl_graph(gst->pipeline);
96
97 /* Wait until error or EOS */
98 // bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline));
99 // bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline);
100
101 gg_setup_gst_bus (gst);
102// g_print ("Running...\n");
103
104
105 // start pushing buffers
106 if (type == MICROPHONE)
107 {
108 GMainLoop *loop;
109 loop = g_main_loop_new (NULL, FALSE);
110
111 g_main_loop_run (loop);
112
113/*
114 while ( 1 )
115 {
116 GstFlowReturn flow;
117 flow = on_appsink_new_sample (gst->appsink, gst);
118 }
119 */}
120 if (type == SPEAKER)
121 {
122 while (1)
123 {
124// printf("read.. \n");
125 gnunet_read (gst);
126 }
127 }
128 g_print ("Returned, stopping playback\n");
129
130 // gst_object_unref (bus);
131 gst_element_set_state (GST_ELEMENT (gst->pipeline), GST_STATE_NULL);
132 gst_object_unref (gst->pipeline);
133
134 return 0;
135}
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static GstElement * decoder
static GstElement * sink
static uint32_t type
Type string converted to DNS type value.
void gg_load_configuration(GNUNET_gstData *d)
Definition: gnunet_gst.c:71
GstBin * get_app(GNUNET_gstData *d, int type)
Definition: gnunet_gst.c:732
void pl_graph(GstElement *pipeline)
Definition: gnunet_gst.c:233
void gg_setup_gst_bus(GNUNET_gstData *d)
Definition: gnunet_gst.c:355
int gnunet_read(GNUNET_gstData *d)
Definition: gnunet_gst.c:655
GstBin * get_coder(GNUNET_gstData *d, int type)
Definition: gnunet_gst.c:816
GstBin * get_audiobin(GNUNET_gstData *d, int type)
Definition: gnunet_gst.c:950
@ SPEAKER
@ MICROPHONE
@ SOURCE
@ SINK
@ ENCODER
@ DECODER
GstPipeline * pipeline

References decoder, DECODER, ENCODER, get_app(), get_audiobin(), get_coder(), gg_load_configuration(), gg_setup_gst_bus(), gnunet_read(), MICROPHONE, GNUNET_gstData::pipeline, pl_graph(), sink, SINK, source, SOURCE, SPEAKER, and type.

Here is the call graph for this function: