diff options
author | hark <hark@puscii.nl> | 2016-03-25 03:33:09 +0000 |
---|---|---|
committer | hark <hark@puscii.nl> | 2016-03-25 03:33:09 +0000 |
commit | 2f5ca7693694fe917b9e322f6dc1692a5cbaacbf (patch) | |
tree | 46dc0cceb783ba5fac5fd30e9a631d6578abf233 /src/conversation/gnunet_gst_test.c | |
parent | 22d081dc59a8e94b41879606a6927c658cc76d29 (diff) | |
download | gnunet-2f5ca7693694fe917b9e322f6dc1692a5cbaacbf.tar.gz gnunet-2f5ca7693694fe917b9e322f6dc1692a5cbaacbf.zip |
experimental gstreamer audiobackend (not working)
Diffstat (limited to 'src/conversation/gnunet_gst_test.c')
-rw-r--r-- | src/conversation/gnunet_gst_test.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/conversation/gnunet_gst_test.c b/src/conversation/gnunet_gst_test.c new file mode 100644 index 000000000..3e1454c5b --- /dev/null +++ b/src/conversation/gnunet_gst_test.c | |||
@@ -0,0 +1,120 @@ | |||
1 | #include "gnunet_gst_def.h" | ||
2 | #include "gnunet_gst.h" | ||
3 | |||
4 | int | ||
5 | main (int argc, char *argv[]) | ||
6 | { | ||
7 | struct GNUNET_gstData *gst; | ||
8 | GstBus *bus; | ||
9 | GstMessage *msg; | ||
10 | GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder; | ||
11 | |||
12 | |||
13 | |||
14 | // audio_message = GNUNET_malloc (UINT16_MAX); | ||
15 | //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); | ||
16 | |||
17 | |||
18 | //GstPipeline *pipeline; | ||
19 | |||
20 | gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData)); | ||
21 | |||
22 | //gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); | ||
23 | |||
24 | |||
25 | gg_load_configuration(gst); | ||
26 | /* | ||
27 | gst->audiobackend = JACK; | ||
28 | gst->dropsilence = TRUE; | ||
29 | gst->usertp = FALSE; | ||
30 | */ | ||
31 | /* Initialize GStreamer */ | ||
32 | gst_init (&argc, &argv); | ||
33 | |||
34 | gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper")); | ||
35 | |||
36 | #ifdef IS_SPEAKER | ||
37 | int type = SPEAKER; | ||
38 | printf("this is the speaker \n"); | ||
39 | #endif | ||
40 | #ifdef IS_MIC | ||
41 | int type = MICROPHONE; | ||
42 | printf("this is the microphone \n"); | ||
43 | |||
44 | #endif | ||
45 | if ( type == SPEAKER) | ||
46 | { | ||
47 | |||
48 | gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE)); | ||
49 | |||
50 | sink = GST_ELEMENT(get_audiobin(gst, SINK)); | ||
51 | decoder = GST_ELEMENT(get_coder(gst, DECODER)); | ||
52 | gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL); | ||
53 | gst_element_link_many( gnunetsrc, decoder, sink , NULL); | ||
54 | |||
55 | } | ||
56 | if ( type == MICROPHONE ) { | ||
57 | |||
58 | source = GST_ELEMENT(get_audiobin(gst, SOURCE)); | ||
59 | |||
60 | encoder = GST_ELEMENT(get_coder(gst, ENCODER)); | ||
61 | |||
62 | gnunetsink = GST_ELEMENT(get_app(gst, SINK)); | ||
63 | |||
64 | gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL); | ||
65 | gst_element_link_many( source, encoder, gnunetsink , NULL); | ||
66 | |||
67 | |||
68 | } | ||
69 | /* | ||
70 | gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL); | ||
71 | gst_element_link_many( source, encoder, decoder, sink , NULL); | ||
72 | */ | ||
73 | pl_graph(gst->pipeline); | ||
74 | /* Start playing */ | ||
75 | gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING); | ||
76 | |||
77 | //pl_graph(gst->pipeline); | ||
78 | |||
79 | /* Wait until error or EOS */ | ||
80 | //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline)); | ||
81 | //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline); | ||
82 | |||
83 | gg_setup_gst_bus(gst); | ||
84 | // g_print ("Running...\n"); | ||
85 | |||
86 | |||
87 | // start pushing buffers | ||
88 | if ( type == MICROPHONE ) | ||
89 | { | ||
90 | |||
91 | |||
92 | GMainLoop *loop; | ||
93 | loop = g_main_loop_new (NULL, FALSE); | ||
94 | |||
95 | g_main_loop_run (loop); | ||
96 | |||
97 | /* | ||
98 | while ( 1 ) | ||
99 | { | ||
100 | GstFlowReturn flow; | ||
101 | flow = on_appsink_new_sample (gst->appsink, gst); | ||
102 | } | ||
103 | */ | ||
104 | } | ||
105 | if ( type == SPEAKER ) | ||
106 | { | ||
107 | while ( 1 ) | ||
108 | { | ||
109 | // printf("read.. \n"); | ||
110 | gnunet_read(gst); | ||
111 | } | ||
112 | } | ||
113 | g_print ("Returned, stopping playback\n"); | ||
114 | |||
115 | gst_object_unref (bus); | ||
116 | gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_NULL); | ||
117 | gst_object_unref (gst->pipeline); | ||
118 | |||
119 | return 0; | ||
120 | } | ||