GNUnet 0.22.0
gnunet_gst.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define gst_element_factory_make(element, name)
 

Functions

void pl_graph ()
 
GstElement * gst_element_factory_make_debug (gchar *, gchar *)
 debug making elements More...
 
GstBin * get_audiobin (GNUNET_gstData *, int)
 
GstBin * get_coder (GNUNET_gstData *, int)
 
gboolean gnunet_gst_bus_call (GstBus *bus, GstMessage *msg, gpointer data)
 
void gg_setup_gst_bus (GNUNET_gstData *d)
 
void gg_load_configuration (GNUNET_gstData *d)
 
GstFlowReturn on_appsink_new_sample (GstElement *, GNUNET_gstData *)
 

Macro Definition Documentation

◆ gst_element_factory_make

#define gst_element_factory_make (   element,
  name 
)
Value:
element, name);
static char * name
Name (label) of the records to list.
GstElement * gst_element_factory_make_debug(gchar *, gchar *)
debug making elements
Definition: gnunet_gst.c:555

Definition at line 36 of file gnunet_gst.h.

Function Documentation

◆ pl_graph()

void pl_graph ( )

◆ gst_element_factory_make_debug()

GstElement * gst_element_factory_make_debug ( gchar *  factoryname,
gchar *  name 
)

debug making elements

Definition at line 555 of file gnunet_gst.c.

556{
557 GstElement *element;
558
559 element = gst_element_factory_make (factoryname, name);
560
561 if (element == NULL)
562 {
563 printf ("\n Failed to create element - type: %s name: %s \n", factoryname,
564 name);
565 exit (10);
566 return element;
567 }
568 else
569 {
570 return element;
571 }
572}
#define gst_element_factory_make(element, name)
Definition: gnunet_gst.h:36

References gst_element_factory_make, and name.

◆ get_audiobin()

GstBin * get_audiobin ( GNUNET_gstData d,
int  type 
)

Definition at line 950 of file gnunet_gst.c.

951{
952 GstBin *bin;
953 GstElement *sink, *source, *queue, *conv, *resampler, *removesilence, *filter;
954 GstPad *pad, *ghostpad;
955 GstCaps *caps;
956
957 if (type == SINK)
958 {
959 bin = GST_BIN (gst_bin_new ("Gnunet audiosink"));
960
961 /* Create all the elements */
962 if (d->dropsilence == TRUE)
963 {
964 queue = gst_element_factory_make ("queue", "queue");
965 removesilence = gst_element_factory_make ("removesilence",
966 "removesilence");
967 }
968
969 conv = gst_element_factory_make ("audioconvert", "converter");
970 resampler = gst_element_factory_make ("audioresample", "resampler");
971
972 if (d->audiobackend == AUTO)
973 {
974 sink = gst_element_factory_make ("autoaudiosink", "audiosink");
975 g_signal_connect (sink, "child-added", G_CALLBACK (
977 }
978
979 if (d->audiobackend == ALSA)
980 {
981 sink = gst_element_factory_make ("alsaaudiosink", "audiosink");
982 }
983
984 if (d->audiobackend == JACK)
985 {
986 sink = gst_element_factory_make ("jackaudiosink", "audiosink");
987
988 g_object_set (G_OBJECT (sink), "client-name", "gnunet", NULL);
989
990 if (g_object_class_find_property
991 (G_OBJECT_GET_CLASS (sink), "port-pattern"))
992 {
993// char *portpattern = "system";
994
995 g_object_set (G_OBJECT (sink), "port-pattern", d->jack_pp_out,
996 NULL);
997 }
998 }
999
1000 if (d->audiobackend == FAKE)
1001 {
1002 sink = gst_element_factory_make ("fakesink", "audiosink");
1003 }
1004
1005 g_object_set (sink,
1006 "buffer-time", (gint64) BUFFER_TIME,
1007 "latency-time", (gint64) LATENCY_TIME,
1008 NULL);
1009
1010 if (d->dropsilence == TRUE)
1011 {
1012 // Do not remove silence by default
1013 g_object_set (removesilence, "remove", FALSE, NULL);
1014 g_object_set (queue, "max-size-buffers", 12, NULL);
1015 /*
1016 g_signal_connect (source,
1017 "need-data",
1018 G_CALLBACK(appsrc_need_data),
1019 NULL);
1020
1021 g_signal_connect (source,
1022 "enough-data",
1023 G_CALLBACK(appsrc_enough_data),
1024 NULL);
1025 *//*
1026 g_signal_connect (queue,
1027 "notify::current-level-bytes",
1028 G_CALLBACK(queue_current_level),
1029 NULL);
1030
1031 g_signal_connect (queue,
1032 "underrun",
1033 G_CALLBACK(queue_underrun),
1034 NULL);
1035
1036 g_signal_connect (queue,
1037 "running",
1038 G_CALLBACK(queue_running),
1039 NULL);
1040
1041 g_signal_connect (queue,
1042 "overrun",
1043 G_CALLBACK(queue_overrun),
1044 NULL);
1045
1046 g_signal_connect (queue,
1047 "pushing",
1048 G_CALLBACK(queue_pushing),
1049 NULL);
1050 */ }
1051
1052
1053 gst_bin_add_many (bin, conv, resampler, sink, NULL);
1054 gst_element_link_many (conv, resampler, sink, NULL);
1055
1056 if (d->dropsilence == TRUE)
1057 {
1058 gst_bin_add_many (bin, queue, removesilence, NULL);
1059
1060 if (! gst_element_link_many (queue, removesilence, conv, NULL))
1061 lf ("queue, removesilence, conv ");
1062
1063 pad = gst_element_get_static_pad (queue, "sink");
1064 }
1065 else
1066 {
1067 pad = gst_element_get_static_pad (conv, "sink");
1068 }
1069
1070 ghostpad = gst_ghost_pad_new ("sink", pad);
1071 }
1072 else
1073 {
1074 // SOURCE
1075
1076 bin = GST_BIN (gst_bin_new ("Gnunet audiosource"));
1077
1078 // source = gst_element_factory_make("audiotestsrc", "audiotestsrcbla");
1079
1080 if (d->audiobackend == AUTO)
1081 {
1082 source = gst_element_factory_make ("autoaudiosrc", "audiosource");
1083 }
1084 if (d->audiobackend == ALSA)
1085 {
1086 source = gst_element_factory_make ("alsasrc", "audiosource");
1087 }
1088 if (d->audiobackend == JACK)
1089 {
1090 source = gst_element_factory_make ("jackaudiosrc", "audiosource");
1091 }
1092 if (d->audiobackend == TEST)
1093 {
1094 source = gst_element_factory_make ("audiotestsrc", "audiosource");
1095 }
1096
1097 filter = gst_element_factory_make ("capsfilter", "filter");
1098 conv = gst_element_factory_make ("audioconvert", "converter");
1099 resampler = gst_element_factory_make ("audioresample", "resampler");
1100
1101 if (d->audiobackend == AUTO)
1102 {
1103 g_signal_connect (source, "child-added", G_CALLBACK (
1105 }
1106 else
1107 {
1108 if (GST_IS_AUDIO_BASE_SRC (source))
1109 g_object_set (source, "buffer-time", (gint64) BUFFER_TIME,
1110 "latency-time", (gint64) LATENCY_TIME, NULL);
1111 if (d->audiobackend == JACK)
1112 {
1113 g_object_set (G_OBJECT (source), "client-name", "gnunet", NULL);
1114 if (g_object_class_find_property
1115 (G_OBJECT_GET_CLASS (source), "port-pattern"))
1116 {
1117 char *portpattern = "moc";
1118
1119 g_object_set (G_OBJECT (source), "port-pattern", portpattern,
1120 NULL);
1121 }
1122 }
1123 }
1124
1125 caps = gst_caps_new_simple ("audio/x-raw",
1126 /* "format", G_TYPE_STRING, "S16LE", */
1127 /* "rate", G_TYPE_INT, SAMPLING_RATE,*/
1128 "channels", G_TYPE_INT, OPUS_CHANNELS,
1129 /* "layout", G_TYPE_STRING, "interleaved",*/
1130 NULL);
1131
1132 g_object_set (G_OBJECT (filter),
1133 "caps", caps,
1134 NULL);
1135 gst_caps_unref (caps);
1136
1137 gst_bin_add_many (bin, source, filter, conv, resampler, NULL);
1138 gst_element_link_many (source, filter, conv, resampler, NULL);
1139
1140 pad = gst_element_get_static_pad (resampler, "src");
1141
1142
1143 /* pads */
1144 ghostpad = gst_ghost_pad_new ("src", pad);
1145 }
1146
1147 /* set the bin pads */
1148 gst_pad_set_active (ghostpad, TRUE);
1149 gst_element_add_pad (GST_ELEMENT (bin), ghostpad);
1150
1151 gst_object_unref (pad);
1152
1153 return bin;
1154}
static mp_limb_t d[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
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 * resampler
static GstElement * sink
static GstElement * conv
#define BUFFER_TIME
Max number of microseconds to buffer in audiosink.
#define OPUS_CHANNELS
Number of channels.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
static void autoaudiosource_child_added(GstChildProxy *child_proxy, GObject *object, gchar *name, gpointer user_data)
Definition: gnunet_gst.c:615
void lf(char *msg)
Definition: gnunet_gst.c:587
static void autoaudiosink_child_added(GstChildProxy *child_proxy, GObject *object, gchar *name, gpointer user_data)
Definition: gnunet_gst.c:598
@ ALSA
@ JACK
@ TEST
@ FAKE
@ AUTO
@ SINK

References ALSA, AUTO, autoaudiosink_child_added(), autoaudiosource_child_added(), BUFFER_TIME, conv, d, FAKE, filter, gst_element_factory_make, JACK, LATENCY_TIME, lf(), OPUS_CHANNELS, queue(), resampler, sink, SINK, source, TEST, and type.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_coder()

GstBin * get_coder ( GNUNET_gstData d,
int  type 
)

Definition at line 816 of file gnunet_gst.c.

817{
818 GstBin *bin;
819 GstPad *srcpad, *sinkpad, *srcghostpad, *sinkghostpad;
820 GstCaps *rtpcaps;
821 GstElement *encoder, *muxer, *decoder, *demuxer, *jitterbuffer,
822 *rtpcapsfilter;
823
824 if (d->usertp == TRUE)
825 {
826 /*
827 * application/x-rtp, media=(string)audio, clock-rate=(int)48000, encoding-name=(string)OPUS, sprop-maxcapturerate=(string)48000, sprop-stereo=(string)0, payload=(int)96, encoding-params=(string)2, ssrc=(uint)630297634, timestamp-offset=(uint)678334141, seqnum-offset=(uint)16938 */
828/*
829 rtpcaps = gst_caps_new_simple ("application/x-rtp",
830 "media", G_TYPE_STRING, "audio",
831 "clock-rate", G_TYPE_INT, SAMPLING_RATE,
832 "encoding-name", G_TYPE_STRING, "OPUS",
833 "payload", G_TYPE_INT, 96,
834 "sprop-stereo", G_TYPE_STRING, "0",
835 "encoding-params", G_TYPE_STRING, "2",
836 NULL);
837 */ rtpcaps = gst_caps_new_simple ("application/x-rtp",
838 "media", G_TYPE_STRING, "audio",
839 "clock-rate", G_TYPE_INT, SAMPLING_RATE,
840 "encoding-name", G_TYPE_STRING, "OPUS",
841 "payload", G_TYPE_INT, 96,
842 "sprop-stereo", G_TYPE_STRING, "0",
843 "encoding-params", G_TYPE_STRING, "2",
844 NULL);
845
846
847 rtpcapsfilter = gst_element_factory_make ("capsfilter", "rtpcapsfilter");
848
849 g_object_set (G_OBJECT (rtpcapsfilter),
850 "caps", rtpcaps,
851 NULL);
852 gst_caps_unref (rtpcaps);
853 }
854
855
856 if (type == ENCODER)
857 {
858 bin = GST_BIN (gst_bin_new ("Gnunet audioencoder"));
859
860 encoder = gst_element_factory_make ("opusenc", "opus-encoder");
861 if (d->usertp == TRUE)
862 {
863 muxer = gst_element_factory_make ("rtpopuspay", "rtp-payloader");
864 }
865 else
866 {
867 muxer = gst_element_factory_make ("oggmux", "ogg-muxer");
868 }
869 g_object_set (G_OBJECT (encoder),
870 /* "bitrate", 64000, */
871 /* "bandwidth", OPUS_BANDWIDTH_FULLBAND, */
872 "inband-fec", INBAND_FEC_MODE,
873 "packet-loss-percentage", PACKET_LOSS_PERCENTAGE,
874 "max-payload-size", MAX_PAYLOAD_SIZE,
875 "audio", TRUE, /* VoIP, not audio */
876 "frame-size", OPUS_FRAME_SIZE,
877 NULL);
878
879 if (d->usertp != TRUE)
880 {
881 g_object_set (G_OBJECT (muxer),
882 "max-delay", OGG_MAX_DELAY,
883 "max-page-delay", OGG_MAX_PAGE_DELAY,
884 NULL);
885 }
886
887 gst_bin_add_many (bin, encoder, muxer, NULL);
888 gst_element_link_many (encoder, muxer, NULL);
889 sinkpad = gst_element_get_static_pad (encoder, "sink");
890 sinkghostpad = gst_ghost_pad_new ("sink", sinkpad);
891
892 srcpad = gst_element_get_static_pad (muxer, "src");
893 srcghostpad = gst_ghost_pad_new ("src", srcpad);
894 }
895 if (type == DECODER)
896 {
897 bin = GST_BIN (gst_bin_new ("Gnunet audiodecoder"));
898
899 // decoder
900 if (d->usertp == TRUE)
901 {
902 demuxer = gst_element_factory_make ("rtpopusdepay", "ogg-demuxer");
903 jitterbuffer = gst_element_factory_make ("rtpjitterbuffer",
904 "rtpjitterbuffer");
905 }
906 else
907 {
908 demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer");
909 }
910 decoder = gst_element_factory_make ("opusdec", "opus-decoder");
911
912 if (d->usertp == TRUE)
913 {
914 gst_bin_add_many (bin, rtpcapsfilter, jitterbuffer, demuxer, decoder,
915 NULL);
916 gst_element_link_many (rtpcapsfilter, jitterbuffer, demuxer, decoder,
917 NULL);
918 sinkpad = gst_element_get_static_pad (rtpcapsfilter, "sink");
919 }
920 else
921 {
922 gst_bin_add_many (bin, demuxer, decoder, NULL);
923
924 g_signal_connect (demuxer,
925 "pad-added",
926 G_CALLBACK (decoder_ogg_pad_added),
927 decoder);
928
929 sinkpad = gst_element_get_static_pad (demuxer, "sink");
930 }
931 sinkghostpad = gst_ghost_pad_new ("sink", sinkpad);
932
933 srcpad = gst_element_get_static_pad (decoder, "src");
934 srcghostpad = gst_ghost_pad_new ("src", srcpad);
935 }
936
937 // add pads to the bin
938 gst_pad_set_active (sinkghostpad, TRUE);
939 gst_element_add_pad (GST_ELEMENT (bin), sinkghostpad);
940
941 gst_pad_set_active (srcghostpad, TRUE);
942 gst_element_add_pad (GST_ELEMENT (bin), srcghostpad);
943
944
945 return bin;
946}
static GstElement * decoder
static GstElement * demuxer
#define SAMPLING_RATE
#define MAX_PAYLOAD_SIZE
Maximal size of a single opus packet.
#define OGG_MAX_DELAY
Maximum delay in multiplexing streams, in ns.
#define INBAND_FEC_MODE
Set to 1 to enable forward error correction.
#define OPUS_FRAME_SIZE
Size of a single frame fed to the encoder, in ms.
#define OGG_MAX_PAGE_DELAY
Maximum delay for sending out a page, in ns.
#define PACKET_LOSS_PERCENTAGE
Expected packet loss to prepare for, in percents.
static void decoder_ogg_pad_added(GstElement *element, GstPad *pad, gpointer data)
Definition: gnunet_gst.c:636
@ ENCODER
@ DECODER

References d, decoder, DECODER, decoder_ogg_pad_added(), demuxer, ENCODER, gst_element_factory_make, INBAND_FEC_MODE, MAX_PAYLOAD_SIZE, OGG_MAX_DELAY, OGG_MAX_PAGE_DELAY, OPUS_FRAME_SIZE, PACKET_LOSS_PERCENTAGE, SAMPLING_RATE, and type.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gnunet_gst_bus_call()

gboolean gnunet_gst_bus_call ( GstBus *  bus,
GstMessage *  msg,
gpointer  data 
)

Definition at line 252 of file gnunet_gst.c.

253{
255 "Bus message\n");
256 switch (GST_MESSAGE_TYPE (msg))
257 {
258 case GST_MESSAGE_EOS:
260 "End of stream\n");
261 exit (10);
262 break;
263
264 case GST_MESSAGE_ERROR:
265 {
266 gchar *debug;
267 GError *error;
268
269 gst_message_parse_error (msg, &error, &debug);
270 g_free (debug);
271
273 "Error: %s\n",
274 error->message);
275 g_error_free (error);
276
277 exit (10);
278 break;
279 }
280
281 default:
282 break;
283 }
284
285 return TRUE;
286}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO

References find_typedefs::debug, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, and msg.

◆ gg_setup_gst_bus()

void gg_setup_gst_bus ( GNUNET_gstData d)

Definition at line 355 of file gnunet_gst.c.

356{
357 GstBus *bus;
358
359 bus = gst_element_get_bus (GST_ELEMENT (d->pipeline));
360 gst_bus_add_signal_watch (bus);
361 g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb,
362 d);
363 g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb,
364 d);
365 g_signal_connect (G_OBJECT (bus), "message::state-changed",
366 (GCallback) state_changed_cb, d);
367 g_signal_connect (G_OBJECT (bus), "message::application",
368 (GCallback) application_cb, d);
369 g_signal_connect (G_OBJECT (bus), "message::about-to-finish",
370 (GCallback) application_cb, d);
371 gst_object_unref (bus);
372}
static void eos_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:347
void state_changed_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *d)
Definition: gnunet_gst.c:291
static void application_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:331
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:339

References application_cb(), d, eos_cb(), error_cb(), and state_changed_cb().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gg_load_configuration()

void gg_load_configuration ( GNUNET_gstData d)

Definition at line 71 of file gnunet_gst.c.

72{
73 char *audiobackend_string;
74
76 GNUNET_CONFIGURATION_load (cfg, "mediahelper.conf");
77
78 GNUNET_CONFIGURATION_get_value_string (cfg, "MEDIAHELPER", "JACK_PP_IN",
79 &d->jack_pp_in);
80 GNUNET_CONFIGURATION_get_value_string (cfg, "MEDIAHELPER", "JACK_PP_OUT",
81 &d->jack_pp_out);
82
83 GNUNET_CONFIGURATION_get_value_string (cfg, "MEDIAHELPER", "AUDIOBACKEND",
84 &audiobackend_string);
85
86 // printf("abstring: %s \n", audiobackend_string);
87
88 if (0 == strcasecmp (audiobackend_string, "AUTO"))
89 {
90 d->audiobackend = AUTO;
91 }
92 else if (0 == strcasecmp (audiobackend_string, "JACK"))
93 {
94 d->audiobackend = JACK;
95 }
96 else if (0 == strcasecmp (audiobackend_string, "ALSA"))
97 {
98 d->audiobackend = ALSA;
99 }
100 else if (0 == strcasecmp (audiobackend_string, "FAKE"))
101 {
102 d->audiobackend = FAKE;
103 }
104 else if (0 == strcasecmp (audiobackend_string, "TEST"))
105 {
106 d->audiobackend = TEST;
107 }
108 else
109 {
110 d->audiobackend = AUTO;
111 }
112
113 if (GNUNET_CONFIGURATION_get_value_yesno (cfg, "MEDIAHELPER",
114 "REMOVESILENCE") == GNUNET_YES)
115 {
116 d->dropsilence = TRUE;
117 }
118 else
119 {
120 d->dropsilence = FALSE;
121 }
122
123 if (GNUNET_CONFIGURATION_get_value_yesno (cfg, "MEDIAHELPER",
124 "NO_GN_HEADERS") == GNUNET_YES)
125 {
126 d->pure_ogg = TRUE;
127 }
128 else
129 {
130 d->pure_ogg = FALSE;
131 }
132
133
134 if (GNUNET_CONFIGURATION_get_value_yesno (cfg, "MEDIAHELPER", "USERTP") ==
136 {
137 d->usertp = TRUE;
138 }
139 else
140 {
141 d->usertp = FALSE;
142 }
143
144// GNUNET_CONFIGURATION_write(cfg, "mediahelper.conf");
145}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet_gst.c:31
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
@ GNUNET_YES

References ALSA, AUTO, cfg, d, FAKE, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_load(), GNUNET_YES, JACK, and TEST.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_appsink_new_sample()

GstFlowReturn on_appsink_new_sample ( GstElement *  element,
GNUNET_gstData d 
)

Definition at line 170 of file gnunet_gst.c.

171{
172 // size of message including gnunet header
173 size_t msg_size;
174
175 GstSample *s;
176 GstBuffer *b;
177 GstMapInfo map;
178
179/*
180 const GstStructure *si;
181 char *si_str;
182 GstCaps *s_caps;
183 char *caps_str;
184 */if (gst_app_sink_is_eos (GST_APP_SINK (element)))
185 return GST_FLOW_OK;
186
187 // pull sample from appsink
188 s = gst_app_sink_pull_sample (GST_APP_SINK (element));
189
190 if (s == NULL)
191 return GST_FLOW_OK;
192
193 if (! GST_IS_SAMPLE (s))
194 return GST_FLOW_OK;
195
196 b = gst_sample_get_buffer (s);
197
198 GST_WARNING ("caps are %" GST_PTR_FORMAT, gst_sample_get_caps (s));
199
200
201 gst_buffer_map (b, &map, GST_MAP_READ);
202
203 size_t len;
204 len = map.size;
205 if (len > UINT16_MAX - sizeof(struct AudioMessage))
206 {
207 // this should never happen?
208 printf ("GSTREAMER sample too big! \n");
209 exit (20);
210 len = UINT16_MAX - sizeof(struct AudioMessage);
211 }
212
213 msg_size = sizeof(struct AudioMessage) + len;
214
215 // copy the data into audio_message
216 GNUNET_memcpy (((char *) &(d->audio_message)[1]), map.data, len);
217 (d->audio_message)->header.size = htons ((uint16_t) msg_size);
218 if (d->pure_ogg)
219 // write the audio_message without the gnunet headers
220 write_data ((const char *) &(d->audio_message)[1], len);
221 else
222 write_data ((const char *) d->audio_message, msg_size);
223
224 gst_sample_unref (s);
225 return GST_FLOW_OK;
226}
static void write_data(const char *ptr, size_t msg_size)
Definition: gnunet_gst.c:149
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Peermap of PeerIdentities to "struct PeerEntry" (for fast lookup).
Definition: peer.c:63
Message to transmit the audio (between client and helpers).
Definition: conversation.h:59
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO.
Definition: conversation.h:63
unsigned int size
Number of entries in the map.

References d, GNUNET_memcpy, AudioMessage::header, map, GNUNET_MessageHeader::size, GNUNET_CONTAINER_MultiPeerMap::size, and write_data().

Referenced by get_app().

Here is the call graph for this function:
Here is the caller graph for this function: