GNUnet  0.10.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)   gst_element_factory_make_debug (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 
)    gst_element_factory_make_debug (element, 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 522 of file gnunet_gst.c.

References gst_element_factory_make.

523 {
524  GstElement *element;
525 
526  element = gst_element_factory_make(factoryname,name);
527 
528  if (element == NULL) {
529 
530  printf ("\n Failed to create element - type: %s name: %s \n", factoryname, name);
531  exit(10);
532  return element;
533  } else {
534  return element;
535  }
536 }
#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 899 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().

900 {
901  GstBin *bin;
902  GstElement *sink, *source, *queue, *conv, *resampler, *removesilence, *filter;
903  GstPad *pad, *ghostpad;
904  GstCaps *caps;
905  if ( type == SINK ) {
906 
907  bin = GST_BIN(gst_bin_new("Gnunet audiosink"));
908 
909  /* Create all the elements */
910  if ( d->dropsilence == TRUE )
911  {
912  queue = gst_element_factory_make ("queue", "queue");
913  removesilence = gst_element_factory_make ("removesilence", "removesilence");
914  }
915 
916  conv = gst_element_factory_make ("audioconvert", "converter");
917  resampler= gst_element_factory_make ("audioresample", "resampler");
918 
919  if ( d->audiobackend == AUTO )
920  {
921  sink = gst_element_factory_make ("autoaudiosink", "audiosink");
922  g_signal_connect (sink, "child-added", G_CALLBACK (autoaudiosink_child_added), NULL);
923 
924  }
925 
926  if ( d->audiobackend == ALSA )
927  {
928  sink = gst_element_factory_make ("alsaaudiosink", "audiosink");
929  }
930 
931  if ( d->audiobackend == JACK )
932  {
933  sink = gst_element_factory_make ("jackaudiosink", "audiosink");
934 
935  g_object_set (G_OBJECT (sink), "client-name", "gnunet", NULL);
936 
937  if (g_object_class_find_property
938  (G_OBJECT_GET_CLASS (sink), "port-pattern"))
939  {
940 
941 // char *portpattern = "system";
942 
943  g_object_set (G_OBJECT (sink), "port-pattern", d->jack_pp_out,
944  NULL);
945  }
946 
947  }
948 
949  if ( d->audiobackend == FAKE )
950  {
951  sink = gst_element_factory_make ("fakesink", "audiosink");
952  }
953 
954  g_object_set (sink,
955  "buffer-time", (gint64) BUFFER_TIME,
956  "latency-time", (gint64) LATENCY_TIME,
957  NULL);
958 
959  if ( d->dropsilence == TRUE )
960  {
961  // Do not remove silence by default
962  g_object_set( removesilence, "remove", FALSE, NULL);
963  g_object_set( queue, "max-size-buffers", 12, NULL);
964  /*
965  g_signal_connect (source,
966  "need-data",
967  G_CALLBACK(appsrc_need_data),
968  NULL);
969 
970  g_signal_connect (source,
971  "enough-data",
972  G_CALLBACK(appsrc_enough_data),
973  NULL);
974  */
975 /*
976  g_signal_connect (queue,
977  "notify::current-level-bytes",
978  G_CALLBACK(queue_current_level),
979  NULL);
980 
981  g_signal_connect (queue,
982  "underrun",
983  G_CALLBACK(queue_underrun),
984  NULL);
985 
986  g_signal_connect (queue,
987  "running",
988  G_CALLBACK(queue_running),
989  NULL);
990 
991  g_signal_connect (queue,
992  "overrun",
993  G_CALLBACK(queue_overrun),
994  NULL);
995 
996  g_signal_connect (queue,
997  "pushing",
998  G_CALLBACK(queue_pushing),
999  NULL);
1000  */
1001 
1002  }
1003 
1004 
1005 
1006 
1007 
1008  gst_bin_add_many (bin , conv, resampler, sink, NULL);
1009  gst_element_link_many ( conv, resampler, sink, NULL);
1010 
1011  if ( d->dropsilence == TRUE )
1012  {
1013  gst_bin_add_many (bin , queue ,removesilence , NULL);
1014 
1015  if ( !gst_element_link_many ( queue, removesilence, conv, NULL) )
1016  lf ("queue, removesilence, conv ");
1017 
1018  pad = gst_element_get_static_pad (queue, "sink");
1019 
1020  } else {
1021 
1022  pad = gst_element_get_static_pad(conv, "sink");
1023 
1024  }
1025 
1026  ghostpad = gst_ghost_pad_new ("sink", pad);
1027 
1028  } else {
1029  // SOURCE
1030 
1031  bin = GST_BIN(gst_bin_new("Gnunet audiosource"));
1032 
1033  // source = gst_element_factory_make("audiotestsrc", "audiotestsrcbla");
1034 
1035  if (d->audiobackend == AUTO )
1036  {
1037  source = gst_element_factory_make ("autoaudiosrc", "audiosource");
1038  }
1039  if (d->audiobackend == ALSA )
1040  {
1041  source = gst_element_factory_make ("alsasrc", "audiosource");
1042  }
1043  if (d->audiobackend == JACK )
1044  {
1045  source = gst_element_factory_make ("jackaudiosrc", "audiosource");
1046  }
1047  if (d->audiobackend == TEST )
1048  {
1049  source = gst_element_factory_make ("audiotestsrc", "audiosource");
1050  }
1051 
1052  filter = gst_element_factory_make ("capsfilter", "filter");
1053  conv = gst_element_factory_make ("audioconvert", "converter");
1054  resampler= gst_element_factory_make ("audioresample", "resampler");
1055 
1056  if (d->audiobackend == AUTO ) {
1057  g_signal_connect (source, "child-added", G_CALLBACK (autoaudiosource_child_added), NULL);
1058 
1059  } else {
1060  if (GST_IS_AUDIO_BASE_SRC (source))
1061  g_object_set (source, "buffer-time", (gint64) BUFFER_TIME, "latency-time", (gint64) LATENCY_TIME, NULL);
1062  if ( d->audiobackend == JACK ) {
1063  g_object_set (G_OBJECT (source), "client-name", "gnunet", NULL);
1064  if (g_object_class_find_property
1065  (G_OBJECT_GET_CLASS (source), "port-pattern"))
1066  {
1067 
1068  char *portpattern = "moc";
1069 
1070  g_object_set (G_OBJECT (source), "port-pattern", portpattern,
1071  NULL);
1072  }
1073  }
1074  }
1075 
1076  caps = gst_caps_new_simple ("audio/x-raw",
1077  /* "format", G_TYPE_STRING, "S16LE", */
1078  /* "rate", G_TYPE_INT, SAMPLING_RATE,*/
1079  "channels", G_TYPE_INT, OPUS_CHANNELS,
1080  /* "layout", G_TYPE_STRING, "interleaved",*/
1081  NULL);
1082 
1083  g_object_set (G_OBJECT (filter),
1084  "caps", caps,
1085  NULL);
1086  gst_caps_unref (caps);
1087 
1088  gst_bin_add_many (bin , source, filter, conv, resampler, NULL);
1089  gst_element_link_many ( source, filter, conv, resampler, NULL);
1090 
1091  pad = gst_element_get_static_pad (resampler, "src");
1092 
1093 
1094  /* pads */
1095  ghostpad = gst_ghost_pad_new ("src", pad);
1096 
1097  }
1098 
1099  /* set the bin pads */
1100  gst_pad_set_active (ghostpad, TRUE);
1101  gst_element_add_pad (GST_ELEMENT(bin), ghostpad);
1102 
1103  gst_object_unref (pad);
1104 
1105  return bin;
1106 }
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:576
static void autoaudiosink_child_added(GstChildProxy *child_proxy, GObject *object, gchar *name, gpointer user_data)
Definition: gnunet_gst.c:560
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:550
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 768 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().

769 {
770  GstBin *bin;
771  GstPad *srcpad, *sinkpad, *srcghostpad, *sinkghostpad;
772  GstCaps *rtpcaps;
773  GstElement *encoder, *muxer, *decoder, *demuxer, *jitterbuffer, *rtpcapsfilter;
774 
775  if ( d->usertp == TRUE )
776  {
777  /*
778  * 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 */
779 /*
780  rtpcaps = gst_caps_new_simple ("application/x-rtp",
781  "media", G_TYPE_STRING, "audio",
782  "clock-rate", G_TYPE_INT, SAMPLING_RATE,
783  "encoding-name", G_TYPE_STRING, "OPUS",
784  "payload", G_TYPE_INT, 96,
785  "sprop-stereo", G_TYPE_STRING, "0",
786  "encoding-params", G_TYPE_STRING, "2",
787  NULL);
788 */
789  rtpcaps = gst_caps_new_simple ("application/x-rtp",
790  "media", G_TYPE_STRING, "audio",
791  "clock-rate", G_TYPE_INT, SAMPLING_RATE,
792  "encoding-name", G_TYPE_STRING, "OPUS",
793  "payload", G_TYPE_INT, 96,
794  "sprop-stereo", G_TYPE_STRING, "0",
795  "encoding-params", G_TYPE_STRING, "2",
796  NULL);
797 
798 
799  rtpcapsfilter = gst_element_factory_make ("capsfilter", "rtpcapsfilter");
800 
801  g_object_set (G_OBJECT (rtpcapsfilter),
802  "caps", rtpcaps,
803  NULL);
804  gst_caps_unref (rtpcaps);
805 
806  }
807 
808 
809  if ( type == ENCODER )
810  {
811  bin = GST_BIN(gst_bin_new("Gnunet audioencoder"));
812 
813  encoder = gst_element_factory_make ("opusenc", "opus-encoder");
814  if ( d->usertp == TRUE )
815  {
816  muxer = gst_element_factory_make ("rtpopuspay", "rtp-payloader");
817  } else {
818  muxer = gst_element_factory_make ("oggmux", "ogg-muxer");
819  }
820  g_object_set (G_OBJECT (encoder),
821  /* "bitrate", 64000, */
822  /* "bandwidth", OPUS_BANDWIDTH_FULLBAND, */
823  "inband-fec", INBAND_FEC_MODE,
824  "packet-loss-percentage", PACKET_LOSS_PERCENTAGE,
825  "max-payload-size", MAX_PAYLOAD_SIZE,
826  "audio", TRUE, /* VoIP, not audio */
827  "frame-size", OPUS_FRAME_SIZE,
828  NULL);
829 
830  if ( d->usertp != TRUE)
831  {
832  g_object_set (G_OBJECT (muxer),
833  "max-delay", OGG_MAX_DELAY,
834  "max-page-delay", OGG_MAX_PAGE_DELAY,
835  NULL);
836  }
837 
838  gst_bin_add_many( bin, encoder, muxer, NULL);
839  gst_element_link_many ( encoder, muxer, NULL);
840  sinkpad = gst_element_get_static_pad(encoder, "sink");
841  sinkghostpad = gst_ghost_pad_new ("sink", sinkpad);
842 
843  srcpad = gst_element_get_static_pad(muxer, "src");
844  srcghostpad = gst_ghost_pad_new ("src", srcpad);
845 
846  }
847  if ( type == DECODER )
848  {
849  bin = GST_BIN(gst_bin_new("Gnunet audiodecoder"));
850 
851  // decoder
852  if ( d->usertp == TRUE )
853  {
854 
855  demuxer = gst_element_factory_make ("rtpopusdepay", "ogg-demuxer");
856  jitterbuffer = gst_element_factory_make ("rtpjitterbuffer", "rtpjitterbuffer");
857  } else {
858  demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer");
859  }
860  decoder = gst_element_factory_make ("opusdec", "opus-decoder");
861 
862  if ( d->usertp == TRUE )
863  {
864  gst_bin_add_many( bin, rtpcapsfilter, jitterbuffer, demuxer, decoder, NULL);
865  gst_element_link_many ( rtpcapsfilter, jitterbuffer, demuxer, decoder, NULL);
866  sinkpad = gst_element_get_static_pad(rtpcapsfilter, "sink");
867 
868 
869  } else {
870  gst_bin_add_many( bin, demuxer, decoder, NULL);
871 
872  g_signal_connect (demuxer,
873  "pad-added",
874  G_CALLBACK (decoder_ogg_pad_added),
875  decoder);
876 
877  sinkpad = gst_element_get_static_pad(demuxer, "sink");
878  }
879  sinkghostpad = gst_ghost_pad_new ("sink", sinkpad);
880 
881  srcpad = gst_element_get_static_pad(decoder, "src");
882  srcghostpad = gst_ghost_pad_new ("src", srcpad);
883 
884  }
885 
886  // add pads to the bin
887  gst_pad_set_active (sinkghostpad, TRUE);
888  gst_element_add_pad (GST_ELEMENT(bin), sinkghostpad);
889 
890  gst_pad_set_active (srcghostpad, TRUE);
891  gst_element_add_pad (GST_ELEMENT(bin), srcghostpad);
892 
893 
894  return bin;
895 }
#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:594
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 230 of file gnunet_gst.c.

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

231 {
233  "Bus message\n");
234  switch (GST_MESSAGE_TYPE (msg))
235  {
236  case GST_MESSAGE_EOS:
238  "End of stream\n");
239  exit (10);
240  break;
241 
242  case GST_MESSAGE_ERROR:
243  {
244  gchar *debug;
245  GError *error;
246 
247  gst_message_parse_error (msg, &error, &debug);
248  g_free (debug);
249 
251  "Error: %s\n",
252  error->message);
253  g_error_free (error);
254 
255  exit (10);
256  break;
257  }
258  default:
259  break;
260  }
261 
262  return TRUE;
263 }
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 325 of file gnunet_gst.c.

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

Referenced by main().

326 {
327  GstBus *bus;
328  bus = gst_element_get_bus (GST_ELEMENT(d->pipeline));
329  gst_bus_add_signal_watch (bus);
330  g_signal_connect (G_OBJECT (bus), "message::error", (GCallback) error_cb,
331  d);
332  g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback) eos_cb,
333  d);
334  g_signal_connect (G_OBJECT (bus), "message::state-changed",
335  (GCallback) state_changed_cb, d);
336  g_signal_connect (G_OBJECT (bus), "message::application",
337  (GCallback) application_cb, d);
338  g_signal_connect (G_OBJECT (bus), "message::about-to-finish",
339  (GCallback) application_cb, d);
340  gst_object_unref (bus);
341 
342 }
GstPipeline * pipeline
static void error_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:311
void state_changed_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *d)
Definition: gnunet_gst.c:267
static void eos_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:318
static void application_cb(GstBus *bus, GstMessage *msg, GNUNET_gstData *data)
Definition: gnunet_gst.c:304
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 66 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().

67 {
68  char *audiobackend_string;
70  GNUNET_CONFIGURATION_load(cfg, "mediahelper.conf");
71 
72  GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "JACK_PP_IN", &d->jack_pp_in);
73  GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "JACK_PP_OUT", &d->jack_pp_out);
74 
75  GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "AUDIOBACKEND", &audiobackend_string);
76 
77  // printf("abstring: %s \n", audiobackend_string);
78 
79  if (0 == strcasecmp (audiobackend_string, "AUTO"))
80  {
81  d->audiobackend = AUTO;
82  } else if (0 == strcasecmp (audiobackend_string, "JACK"))
83  {
84  d->audiobackend = JACK;
85  } else if (0 == strcasecmp (audiobackend_string, "ALSA"))
86  {
87  d->audiobackend = ALSA;
88  } else if (0 == strcasecmp (audiobackend_string, "FAKE"))
89  {
90  d->audiobackend = FAKE;
91  } else if (0 == strcasecmp (audiobackend_string, "TEST"))
92  {
93  d->audiobackend = TEST;
94  } else
95  {
96  d->audiobackend = AUTO;
97  }
98 
99  if (GNUNET_CONFIGURATION_get_value_yesno(cfg, "MEDIAHELPER", "REMOVESILENCE") == GNUNET_YES)
100  {
101  d->dropsilence = TRUE;
102  } else {
103  d->dropsilence = FALSE;
104  }
105 
106  if (GNUNET_CONFIGURATION_get_value_yesno(cfg, "MEDIAHELPER", "NO_GN_HEADERS") == GNUNET_YES)
107  {
108  d->pure_ogg = TRUE;
109  } else {
110  d->pure_ogg = FALSE;
111  }
112 
113 
114  if (GNUNET_CONFIGURATION_get_value_yesno(cfg, "MEDIAHELPER", "USERTP") == GNUNET_YES)
115  {
116  d->usertp = TRUE;
117  } else {
118  d->usertp = FALSE;
119  }
120 
121 // GNUNET_CONFIGURATION_write(cfg, "mediahelper.conf");
122 
123 }
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:80
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 147 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().

148 {
149  //size of message including gnunet header
150  size_t msg_size;
151 
152  GstSample *s;
153  GstBuffer *b;
154  GstMapInfo map;
155 /*
156  const GstStructure *si;
157  char *si_str;
158  GstCaps *s_caps;
159  char *caps_str;
160 */
161 
162  if (gst_app_sink_is_eos(GST_APP_SINK(element)))
163  return GST_FLOW_OK;
164 
165  //pull sample from appsink
166  s = gst_app_sink_pull_sample (GST_APP_SINK(element));
167 
168  if (s == NULL)
169  return GST_FLOW_OK;
170 
171  if (!GST_IS_SAMPLE (s))
172  return GST_FLOW_OK;
173 
174  b = gst_sample_get_buffer(s);
175 
176  GST_WARNING ("caps are %" GST_PTR_FORMAT, gst_sample_get_caps(s));
177 
178 
179 
180  gst_buffer_map (b, &map, GST_MAP_READ);
181 
182  size_t len;
183  len = map.size;
184  if (len > UINT16_MAX - sizeof (struct AudioMessage))
185  {
186  // this should never happen?
187  printf("GSTREAMER sample too big! \n");
188  exit(20);
189  len = UINT16_MAX - sizeof (struct AudioMessage);
190  }
191 
192  msg_size = sizeof (struct AudioMessage) + len;
193 
194  // copy the data into audio_message
195  GNUNET_memcpy (((char *) &(d->audio_message)[1]), map.data, len);
196  (d->audio_message)->header.size = htons ((uint16_t) msg_size);
197  if (d->pure_ogg)
198  // write the audio_message without the gnunet headers
199  write_data ((const char *) &(d->audio_message)[1], len);
200  else
201  write_data ((const char *) d->audio_message, msg_size);
202 
203  gst_sample_unref(s);
204  return GST_FLOW_OK;
205 }
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO.
Definition: conversation.h:60
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.
#define GNUNET_memcpy(dst, src, n)
Message to transmit the audio (between client and helpers).
Definition: conversation.h:55
static void write_data(const char *ptr, size_t msg_size)
Definition: gnunet_gst.c:126
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: