diff options
Diffstat (limited to 'src/conversation/gnunet_gst_test.c')
-rw-r--r-- | src/conversation/gnunet_gst_test.c | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/src/conversation/gnunet_gst_test.c b/src/conversation/gnunet_gst_test.c index 60e920f10..884b0fe83 100644 --- a/src/conversation/gnunet_gst_test.c +++ b/src/conversation/gnunet_gst_test.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "gnunet_gst.h" | 27 | #include "gnunet_gst.h" |
28 | 28 | ||
29 | int | 29 | int |
30 | main(int argc, char *argv[]) | 30 | main (int argc, char *argv[]) |
31 | { | 31 | { |
32 | struct GNUNET_gstData *gst; | 32 | struct GNUNET_gstData *gst; |
33 | // GstBus *bus; | 33 | // GstBus *bus; |
@@ -36,80 +36,81 @@ main(int argc, char *argv[]) | |||
36 | 36 | ||
37 | 37 | ||
38 | // audio_message = GNUNET_malloc (UINT16_MAX); | 38 | // audio_message = GNUNET_malloc (UINT16_MAX); |
39 | //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); | 39 | // audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); |
40 | 40 | ||
41 | 41 | ||
42 | //GstPipeline *pipeline; | 42 | // GstPipeline *pipeline; |
43 | 43 | ||
44 | gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData)); | 44 | gst = (GNUNET_gstData*) malloc (sizeof(struct GNUNET_gstData)); |
45 | 45 | ||
46 | //gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); | 46 | // gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); |
47 | 47 | ||
48 | 48 | ||
49 | gg_load_configuration(gst); | 49 | gg_load_configuration (gst); |
50 | /* | 50 | /* |
51 | gst->audiobackend = JACK; | 51 | gst->audiobackend = JACK; |
52 | gst->dropsilence = TRUE; | 52 | gst->dropsilence = TRUE; |
53 | gst->usertp = FALSE; | 53 | gst->usertp = FALSE; |
54 | */ | 54 | */ |
55 | /* Initialize GStreamer */ | 55 | /* Initialize GStreamer */ |
56 | gst_init(&argc, &argv); | 56 | gst_init (&argc, &argv); |
57 | 57 | ||
58 | gst->pipeline = GST_PIPELINE(gst_pipeline_new("gnunet-media-helper")); | 58 | gst->pipeline = GST_PIPELINE (gst_pipeline_new ("gnunet-media-helper")); |
59 | 59 | ||
60 | #ifdef IS_SPEAKER | 60 | #ifdef IS_SPEAKER |
61 | int type = SPEAKER; | 61 | int type = SPEAKER; |
62 | printf("this is the speaker \n"); | 62 | printf ("this is the speaker \n"); |
63 | #endif | 63 | #endif |
64 | #ifdef IS_MIC | 64 | #ifdef IS_MIC |
65 | int type = MICROPHONE; | 65 | int type = MICROPHONE; |
66 | printf("this is the microphone \n"); | 66 | printf ("this is the microphone \n"); |
67 | #endif | 67 | #endif |
68 | if (type == SPEAKER) | 68 | if (type == SPEAKER) |
69 | { | 69 | { |
70 | gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE)); | 70 | gnunetsrc = GST_ELEMENT (get_app (gst, SOURCE)); |
71 | 71 | ||
72 | sink = GST_ELEMENT(get_audiobin(gst, SINK)); | 72 | sink = GST_ELEMENT (get_audiobin (gst, SINK)); |
73 | decoder = GST_ELEMENT(get_coder(gst, DECODER)); | 73 | decoder = GST_ELEMENT (get_coder (gst, DECODER)); |
74 | gst_bin_add_many(GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL); | 74 | gst_bin_add_many (GST_BIN (gst->pipeline), gnunetsrc, decoder, sink, NULL); |
75 | gst_element_link_many(gnunetsrc, decoder, sink, NULL); | 75 | gst_element_link_many (gnunetsrc, decoder, sink, NULL); |
76 | } | 76 | } |
77 | if (type == MICROPHONE) | 77 | if (type == MICROPHONE) |
78 | { | 78 | { |
79 | source = GST_ELEMENT(get_audiobin(gst, SOURCE)); | 79 | source = GST_ELEMENT (get_audiobin (gst, SOURCE)); |
80 | 80 | ||
81 | encoder = GST_ELEMENT(get_coder(gst, ENCODER)); | 81 | encoder = GST_ELEMENT (get_coder (gst, ENCODER)); |
82 | 82 | ||
83 | gnunetsink = GST_ELEMENT(get_app(gst, SINK)); | 83 | gnunetsink = GST_ELEMENT (get_app (gst, SINK)); |
84 | 84 | ||
85 | gst_bin_add_many(GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL); | 85 | gst_bin_add_many (GST_BIN (gst->pipeline), source, encoder, gnunetsink, |
86 | gst_element_link_many(source, encoder, gnunetsink, NULL); | 86 | NULL); |
87 | } | 87 | gst_element_link_many (source, encoder, gnunetsink, NULL); |
88 | } | ||
88 | /* | 89 | /* |
89 | gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL); | 90 | 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 | gst_element_link_many( source, encoder, decoder, sink , NULL); |
91 | */ | 92 | */ |
92 | pl_graph(gst->pipeline); | 93 | pl_graph (gst->pipeline); |
93 | /* Start playing */ | 94 | /* Start playing */ |
94 | gst_element_set_state(GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING); | 95 | gst_element_set_state (GST_ELEMENT (gst->pipeline), GST_STATE_PLAYING); |
95 | 96 | ||
96 | //pl_graph(gst->pipeline); | 97 | // pl_graph(gst->pipeline); |
97 | 98 | ||
98 | /* Wait until error or EOS */ | 99 | /* Wait until error or EOS */ |
99 | //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline)); | 100 | // bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline)); |
100 | //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline); | 101 | // bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline); |
101 | 102 | ||
102 | gg_setup_gst_bus(gst); | 103 | gg_setup_gst_bus (gst); |
103 | // g_print ("Running...\n"); | 104 | // g_print ("Running...\n"); |
104 | 105 | ||
105 | 106 | ||
106 | // start pushing buffers | 107 | // start pushing buffers |
107 | if (type == MICROPHONE) | 108 | if (type == MICROPHONE) |
108 | { | 109 | { |
109 | GMainLoop *loop; | 110 | GMainLoop *loop; |
110 | loop = g_main_loop_new(NULL, FALSE); | 111 | loop = g_main_loop_new (NULL, FALSE); |
111 | 112 | ||
112 | g_main_loop_run(loop); | 113 | g_main_loop_run (loop); |
113 | 114 | ||
114 | /* | 115 | /* |
115 | while ( 1 ) | 116 | while ( 1 ) |
@@ -118,20 +119,20 @@ main(int argc, char *argv[]) | |||
118 | flow = on_appsink_new_sample (gst->appsink, gst); | 119 | flow = on_appsink_new_sample (gst->appsink, gst); |
119 | } | 120 | } |
120 | */ | 121 | */ |
121 | } | 122 | } |
122 | if (type == SPEAKER) | 123 | if (type == SPEAKER) |
124 | { | ||
125 | while (1) | ||
123 | { | 126 | { |
124 | while (1) | ||
125 | { | ||
126 | // printf("read.. \n"); | 127 | // printf("read.. \n"); |
127 | gnunet_read(gst); | 128 | gnunet_read (gst); |
128 | } | ||
129 | } | 129 | } |
130 | g_print("Returned, stopping playback\n"); | 130 | } |
131 | g_print ("Returned, stopping playback\n"); | ||
131 | 132 | ||
132 | // gst_object_unref (bus); | 133 | // gst_object_unref (bus); |
133 | gst_element_set_state(GST_ELEMENT(gst->pipeline), GST_STATE_NULL); | 134 | gst_element_set_state (GST_ELEMENT (gst->pipeline), GST_STATE_NULL); |
134 | gst_object_unref(gst->pipeline); | 135 | gst_object_unref (gst->pipeline); |
135 | 136 | ||
136 | return 0; | 137 | return 0; |
137 | } | 138 | } |