GNUnet  0.10.x
Functions
gnunet_gst_test.c File Reference

FIXME. More...

#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 30 of file gnunet_gst_test.c.

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.

31 {
32  struct GNUNET_gstData *gst;
33  // GstBus *bus;
34  GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder;
35 
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  */
55  /* Initialize GStreamer */
56  gst_init(&argc, &argv);
57 
58  gst->pipeline = GST_PIPELINE(gst_pipeline_new("gnunet-media-helper"));
59 
60 #ifdef IS_SPEAKER
61  int type = SPEAKER;
62  printf("this is the speaker \n");
63 #endif
64 #ifdef IS_MIC
65  int type = MICROPHONE;
66  printf("this is the microphone \n");
67 #endif
68  if (type == SPEAKER)
69  {
70  gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE));
71 
72  sink = GST_ELEMENT(get_audiobin(gst, SINK));
73  decoder = GST_ELEMENT(get_coder(gst, DECODER));
74  gst_bin_add_many(GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL);
75  gst_element_link_many(gnunetsrc, decoder, sink, NULL);
76  }
77  if (type == MICROPHONE)
78  {
79  source = GST_ELEMENT(get_audiobin(gst, SOURCE));
80 
81  encoder = GST_ELEMENT(get_coder(gst, ENCODER));
82 
83  gnunetsink = GST_ELEMENT(get_app(gst, SINK));
84 
85  gst_bin_add_many(GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL);
86  gst_element_link_many(source, encoder, gnunetsink, NULL);
87  }
88  /*
89  gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL);
90  gst_element_link_many( source, encoder, decoder, sink , NULL);
91  */
92  pl_graph(gst->pipeline);
93  /* Start playing */
94  gst_element_set_state(GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING);
95 
96  //pl_graph(gst->pipeline);
97 
98  /* Wait until error or EOS */
99  //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline));
100  //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline);
101 
102  gg_setup_gst_bus(gst);
103 // g_print ("Running...\n");
104 
105 
106  // start pushing buffers
107  if (type == MICROPHONE)
108  {
109  GMainLoop *loop;
110  loop = g_main_loop_new(NULL, FALSE);
111 
112  g_main_loop_run(loop);
113 
114 /*
115  while ( 1 )
116  {
117  GstFlowReturn flow;
118  flow = on_appsink_new_sample (gst->appsink, gst);
119  }
120  */
121  }
122  if (type == SPEAKER)
123  {
124  while (1)
125  {
126 // printf("read.. \n");
127  gnunet_read(gst);
128  }
129  }
130  g_print("Returned, stopping playback\n");
131 
132  // gst_object_unref (bus);
133  gst_element_set_state(GST_ELEMENT(gst->pipeline), GST_STATE_NULL);
134  gst_object_unref(gst->pipeline);
135 
136  return 0;
137 }
void pl_graph(GstElement *pipeline)
Definition: gnunet_gst.c:227
GstPipeline * pipeline
void gg_load_configuration(GNUNET_gstData *d)
Definition: gnunet_gst.c:69
GstBin * get_app(GNUNET_gstData *d, int type)
Definition: gnunet_gst.c:710
static GstElement * sink
GstBin * get_coder(GNUNET_gstData *d, int type)
Definition: gnunet_gst.c:791
static GstElement * source
Appsrc instance into which we write data for the pipeline.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
GstBin * get_audiobin(GNUNET_gstData *d, int type)
Definition: gnunet_gst.c:922
static GstElement * decoder
void gg_setup_gst_bus(GNUNET_gstData *d)
Definition: gnunet_gst.c:341
int gnunet_read(GNUNET_gstData *d)
Definition: gnunet_gst.c:634
Here is the call graph for this function: