GNUnet  0.11.x
Macros | Functions
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);
GstElement * gst_element_factory_make_debug(gchar *, gchar *)
debug making elements
Definition: gnunet_gst.c:554
const char * name

Definition at line 36 of file gnunet_gst.h.

Referenced by get_app(), get_audiobin(), get_coder(), gst_element_factory_make_debug(), and main().

Function Documentation

◆ pl_graph()

void pl_graph ( )

◆ gst_element_factory_make_debug()

GstElement* gst_element_factory_make_debug ( gchar *  ,
gchar *   
)

debug making elements

Definition at line 554 of file gnunet_gst.c.

References gst_element_factory_make.

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

◆ get_audiobin()

GstBin* get_audiobin ( GNUNET_gstData ,
int   
)

Definition at line 949 of file gnunet_gst.c.

References ALSA, GNUNET_gstData::audiobackend, AUTO, autoaudiosink_child_added(), autoaudiosource_child_added(), BUFFER_TIME, conv, GNUNET_gstData::dropsilence, FAKE, filter, gst_element_factory_make, JACK, GNUNET_gstData::jack_pp_out, LATENCY_TIME, lf(), OPUS_CHANNELS, queue(), resampler, sink, SINK, source, and TEST.

Referenced by main().

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

◆ get_coder()

GstBin* get_coder ( GNUNET_gstData ,
int   
)

Definition at line 815 of file gnunet_gst.c.

References 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 GNUNET_gstData::usertp.

Referenced by main().

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

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

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

◆ gg_setup_gst_bus()

void gg_setup_gst_bus ( GNUNET_gstData d)

Definition at line 354 of file gnunet_gst.c.

References application_cb(), eos_cb(), error_cb(), GNUNET_gstData::pipeline, and state_changed_cb().

Referenced by main().

355 {
356  GstBus *bus;
357 
358  bus = gst_element_get_bus (GST_ELEMENT (d->pipeline));
359  gst_bus_add_signal_watch (bus);
360  g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb,
361  d);
362  g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb,
363  d);
364  g_signal_connect (G_OBJECT (bus), "message::state-changed",
365  (GCallback) state_changed_cb, d);
366  g_signal_connect (G_OBJECT (bus), "message::application",
367  (GCallback) application_cb, d);
368  g_signal_connect (G_OBJECT (bus), "message::about-to-finish",
369  (GCallback) application_cb, d);
370  gst_object_unref (bus);
371 }
GstPipeline * pipeline
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:338
void state_changed_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *d)
Definition: gnunet_gst.c:290
static void eos_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:346
static void application_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:330
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 70 of file gnunet_gst.c.

References ALSA, GNUNET_gstData::audiobackend, AUTO, GNUNET_gstData::dropsilence, FAKE, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_load(), GNUNET_YES, JACK, GNUNET_gstData::jack_pp_in, GNUNET_gstData::jack_pp_out, GNUNET_gstData::pure_ogg, TEST, and GNUNET_gstData::usertp.

Referenced by main().

71 {
72  char *audiobackend_string;
73 
75  GNUNET_CONFIGURATION_load (cfg, "mediahelper.conf");
76 
77  GNUNET_CONFIGURATION_get_value_string (cfg, "MEDIAHELPER", "JACK_PP_IN",
78  &d->jack_pp_in);
79  GNUNET_CONFIGURATION_get_value_string (cfg, "MEDIAHELPER", "JACK_PP_OUT",
80  &d->jack_pp_out);
81 
82  GNUNET_CONFIGURATION_get_value_string (cfg, "MEDIAHELPER", "AUDIOBACKEND",
83  &audiobackend_string);
84 
85  // printf("abstring: %s \n", audiobackend_string);
86 
87  if (0 == strcasecmp (audiobackend_string, "AUTO"))
88  {
89  d->audiobackend = AUTO;
90  }
91  else if (0 == strcasecmp (audiobackend_string, "JACK"))
92  {
93  d->audiobackend = JACK;
94  }
95  else if (0 == strcasecmp (audiobackend_string, "ALSA"))
96  {
97  d->audiobackend = ALSA;
98  }
99  else if (0 == strcasecmp (audiobackend_string, "FAKE"))
100  {
101  d->audiobackend = FAKE;
102  }
103  else if (0 == strcasecmp (audiobackend_string, "TEST"))
104  {
105  d->audiobackend = TEST;
106  }
107  else
108  {
109  d->audiobackend = AUTO;
110  }
111 
112  if (GNUNET_CONFIGURATION_get_value_yesno (cfg, "MEDIAHELPER",
113  "REMOVESILENCE") == GNUNET_YES)
114  {
115  d->dropsilence = TRUE;
116  }
117  else
118  {
119  d->dropsilence = FALSE;
120  }
121 
122  if (GNUNET_CONFIGURATION_get_value_yesno (cfg, "MEDIAHELPER",
123  "NO_GN_HEADERS") == GNUNET_YES)
124  {
125  d->pure_ogg = TRUE;
126  }
127  else
128  {
129  d->pure_ogg = FALSE;
130  }
131 
132 
133  if (GNUNET_CONFIGURATION_get_value_yesno (cfg, "MEDIAHELPER", "USERTP") ==
134  GNUNET_YES)
135  {
136  d->usertp = TRUE;
137  }
138  else
139  {
140  d->usertp = FALSE;
141  }
142 
143 // GNUNET_CONFIGURATION_write(cfg, "mediahelper.conf");
144 }
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
int 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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet_gst.c:30
#define GNUNET_YES
Definition: gnunet_common.h:77
int 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".
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 *  ,
GNUNET_gstData  
)

Definition at line 169 of file gnunet_gst.c.

References GNUNET_gstData::audio_message, GNUNET_memcpy, AudioMessage::header, len, map, GNUNET_gstData::pure_ogg, GNUNET_MessageHeader::size, and write_data().

Referenced by get_app().

170 {
171  // size of message including gnunet header
172  size_t msg_size;
173 
174  GstSample *s;
175  GstBuffer *b;
176  GstMapInfo map;
177 
178 /*
179  const GstStructure *si;
180  char *si_str;
181  GstCaps *s_caps;
182  char *caps_str;
183  */if (gst_app_sink_is_eos (GST_APP_SINK (element)))
184  return GST_FLOW_OK;
185 
186  // pull sample from appsink
187  s = gst_app_sink_pull_sample (GST_APP_SINK (element));
188 
189  if (s == NULL)
190  return GST_FLOW_OK;
191 
192  if (! GST_IS_SAMPLE (s))
193  return GST_FLOW_OK;
194 
195  b = gst_sample_get_buffer (s);
196 
197  GST_WARNING ("caps are %" GST_PTR_FORMAT, gst_sample_get_caps (s));
198 
199 
200  gst_buffer_map (b, &map, GST_MAP_READ);
201 
202  size_t len;
203  len = map.size;
204  if (len > UINT16_MAX - sizeof(struct AudioMessage))
205  {
206  // this should never happen?
207  printf ("GSTREAMER sample too big! \n");
208  exit (20);
209  len = UINT16_MAX - sizeof(struct AudioMessage);
210  }
211 
212  msg_size = sizeof(struct AudioMessage) + len;
213 
214  // copy the data into audio_message
215  GNUNET_memcpy (((char *) &(d->audio_message)[1]), map.data, len);
216  (d->audio_message)->header.size = htons ((uint16_t) msg_size);
217  if (d->pure_ogg)
218  // write the audio_message without the gnunet headers
219  write_data ((const char *) &(d->audio_message)[1], len);
220  else
221  write_data ((const char *) d->audio_message, msg_size);
222 
223  gst_sample_unref (s);
224  return GST_FLOW_OK;
225 }
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO.
Definition: conversation.h:61
#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
Handle to the map used to store old latency values for peers.
Message to transmit the audio (between client and helpers).
Definition: conversation.h:56
static void write_data(const char *ptr, size_t msg_size)
Definition: gnunet_gst.c:148
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function: