GNUnet  0.10.x
Data Structures | Enumerations | Functions
conversation_api_call.c File Reference

call API to the conversation service More...

#include "platform.h"
#include "gnunet_conversation_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_gns_service.h"
#include "conversation.h"
Include dependency graph for conversation_api_call.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_CONVERSATION_Call
 Handle for an outgoing call. More...
 

Enumerations

enum  CallState {
  CS_LOOKUP = 0, CS_RINGING, CS_ACTIVE, CS_SHUTDOWN,
  CS_SUSPENDED_CALLER, CS_SUSPENDED_CALLEE, CS_SUSPENDED_BOTH, CS_RESOLVING,
  CS_RINGING, CS_CONNECTED, CS_SUSPENDED
}
 Possible states of the phone. More...
 

Functions

static void fail_call (struct GNUNET_CONVERSATION_Call *call)
 The call got disconnected, reconnect to the service. More...
 
static void transmit_call_audio (void *cls, size_t data_size, const void *data)
 Process recorded audio data. More...
 
static void handle_call_suspend (void *cls, const struct ClientPhoneSuspendMessage *msg)
 We received a GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND. More...
 
static void handle_call_resume (void *cls, const struct ClientPhoneResumeMessage *msg)
 We received a GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME. More...
 
static void handle_call_picked_up (void *cls, const struct ClientPhonePickedupMessage *msg)
 We received a GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP. More...
 
static void handle_call_hangup (void *cls, const struct ClientPhoneHangupMessage *msg)
 We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_HANG_UP. More...
 
static int check_call_audio (void *cls, const struct ClientAudioMessage *am)
 We received a struct ClientAudioMessage, check it is well-formed. More...
 
static void handle_call_audio (void *cls, const struct ClientAudioMessage *am)
 We received a struct ClientAudioMessage More...
 
static void handle_gns_response (void *cls, int was_gns, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Iterator called on obtained result for a GNS lookup. More...
 
static void call_error_handler (void *cls, enum GNUNET_MQ_Error error)
 We encountered an error talking with the conversation service. More...
 
struct GNUNET_CONVERSATION_CallGNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_IDENTITY_Ego *caller_id, const char *callee, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic, GNUNET_CONVERSATION_CallEventHandler event_handler, void *event_handler_cls)
 Call the phone of another user. More...
 
void GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call)
 Terminate a call. More...
 
void GNUNET_CONVERSATION_call_suspend (struct GNUNET_CONVERSATION_Call *call)
 Pause a call. More...
 
void GNUNET_CONVERSATION_call_resume (struct GNUNET_CONVERSATION_Call *call, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
 Resumes a call after GNUNET_CONVERSATION_call_suspend. More...
 

Detailed Description

call API to the conversation service

Author
Simon Dieterle
Andreas Fuchs
Christian Grothoff

Definition in file conversation_api_call.c.

Enumeration Type Documentation

◆ CallState

enum CallState

Possible states of the phone.

Enumerator
CS_LOOKUP 

We still need to lookup the callee.

CS_RINGING 

The call is ringing.

CS_ACTIVE 

The call is in an active conversation.

CS_SHUTDOWN 

The call is in termination.

CS_SUSPENDED_CALLER 

The call was suspended by the caller.

CS_SUSPENDED_CALLEE 

The call was suspended by the callee.

CS_SUSPENDED_BOTH 

The call was suspended by both caller and callee.

CS_RESOLVING 

We are looking up some other participant.

CS_RINGING 

We are now ringing the other participant.

CS_CONNECTED 

The other party accepted our call and we are now connected.

CS_SUSPENDED 

The call is currently suspended (by us).

Definition at line 38 of file conversation_api_call.c.

38  {
42  CS_LOOKUP = 0,
43 
47  CS_RINGING,
48 
52  CS_ACTIVE,
53 
58 
63 
68 
73 };
The call was suspended by the caller.
The call is ringing.
The call is in an active conversation.
The call was suspended by the callee.
The call was suspended by both caller and callee.
The call is in termination.
We still need to lookup the callee.

Function Documentation

◆ fail_call()

static void fail_call ( struct GNUNET_CONVERSATION_Call call)
static

The call got disconnected, reconnect to the service.

The call got disconnected, destroy the handle.

Parameters
callcall to reconnect

Definition at line 522 of file conversation_api_call.c.

References GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_SHUTDOWN, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_EC_CALL_ERROR, GNUNET_MQ_destroy(), GNUNET_CONVERSATION_Call::mic, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_Call::speaker, and GNUNET_CONVERSATION_Call::state.

Referenced by call_error_handler(), handle_call_audio(), handle_call_hangup(), handle_call_picked_up(), handle_call_resume(), and handle_call_suspend().

523 {
524  if (CS_ACTIVE == call->state)
525  {
526  call->speaker->disable_speaker(call->speaker->cls);
527  call->mic->disable_microphone(call->mic->cls);
528  }
529  if (NULL != call->mq)
530  {
531  GNUNET_MQ_destroy(call->mq);
532  call->mq = NULL;
533  }
534  call->state = CS_SHUTDOWN;
535  call->event_handler(call->event_handler_cls,
538 }
enum CallState state
State machine for the call.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
The call is in an active conversation.
void * event_handler_cls
Closure for event_handler.
void * cls
Closure for the callbacks.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
The call is in termination.
We had an error handing the call, and are now restarting it (back to lookup).
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmit_call_audio()

static void transmit_call_audio ( void *  cls,
size_t  data_size,
const void *  data 
)
static

Process recorded audio data.

Parameters
clsclosure with the struct GNUNET_CONVERSATION_Call
data_sizenumber of bytes in data
dataaudio data to play

Definition at line 159 of file conversation_api_call.c.

References call, CS_ACTIVE, e, GNUNET_assert, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_CONVERSATION_Call::mq, and GNUNET_CONVERSATION_Call::state.

Referenced by GNUNET_CONVERSATION_call_resume(), handle_call_picked_up(), and handle_call_resume().

162 {
163  struct GNUNET_CONVERSATION_Call *call = cls;
164  struct GNUNET_MQ_Envelope *e;
165  struct ClientAudioMessage *am;
166 
167  GNUNET_assert(CS_ACTIVE == call->state);
168  e = GNUNET_MQ_msg_extra(am,
169  data_size,
171  GNUNET_memcpy(&am[1],
172  data,
173  data_size);
174  GNUNET_MQ_send(call->mq,
175  e);
176 }
enum CallState state
State machine for the call.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static struct Experiment * e
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
The call is in an active conversation.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
Message Client <-> Service to transmit the audio.
Definition: conversation.h:180
Handle for an outgoing call.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_call_suspend()

static void handle_call_suspend ( void *  cls,
const struct ClientPhoneSuspendMessage msg 
)
static

We received a GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND.

Parameters
clsthe struct GNUNET_CONVERSATION_Call
msgthe message

Definition at line 186 of file conversation_api_call.c.

References call, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_LOOKUP, CS_RINGING, CS_SHUTDOWN, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, fail_call(), GNUNET_break, GNUNET_break_op, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_EC_CALL_SUSPENDED, GNUNET_CONVERSATION_Call::mic, GNUNET_CONVERSATION_Call::speaker, and GNUNET_CONVERSATION_Call::state.

188 {
189  struct GNUNET_CONVERSATION_Call *call = cls;
190 
191  (void)msg;
192  switch (call->state)
193  {
194  case CS_LOOKUP:
195  GNUNET_break(0);
196  fail_call(call);
197  break;
198 
199  case CS_RINGING:
200  GNUNET_break_op(0);
201  fail_call(call);
202  break;
203 
204  case CS_SUSPENDED_CALLER:
205  call->state = CS_SUSPENDED_BOTH;
206  call->event_handler(call->event_handler_cls,
208  break;
209 
210  case CS_SUSPENDED_CALLEE:
211  case CS_SUSPENDED_BOTH:
212  GNUNET_break_op(0);
213  break;
214 
215  case CS_ACTIVE:
216  call->state = CS_SUSPENDED_CALLEE;
217  call->speaker->disable_speaker(call->speaker->cls);
218  call->mic->disable_microphone(call->mic->cls);
219  call->event_handler(call->event_handler_cls,
221  break;
222 
223  case CS_SHUTDOWN:
225  break;
226  }
227 }
The call was suspended by the caller.
static void fail_call(struct GNUNET_CONVERSATION_Call *call)
The call got disconnected, reconnect to the service.
The call is ringing.
enum CallState state
State machine for the call.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
The call is in an active conversation.
void * event_handler_cls
Closure for event_handler.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void * cls
Closure for the callbacks.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
The call was suspended by the callee.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
The call was suspended by both caller and callee.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
We are the caller and the callee suspended the call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
Handle for an outgoing call.
The call is in termination.
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
We still need to lookup the callee.
Here is the call graph for this function:

◆ handle_call_resume()

static void handle_call_resume ( void *  cls,
const struct ClientPhoneResumeMessage msg 
)
static

We received a GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME.

Parameters
clsthe struct GNUNET_CONVERSATION_Call
msgthe message

Definition at line 237 of file conversation_api_call.c.

References call, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_LOOKUP, CS_RINGING, CS_SHUTDOWN, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, fail_call(), GNUNET_break, GNUNET_break_op, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_EC_CALL_RESUMED, GNUNET_CONVERSATION_Call::mic, GNUNET_CONVERSATION_Call::speaker, GNUNET_CONVERSATION_Call::state, and transmit_call_audio().

239 {
240  struct GNUNET_CONVERSATION_Call *call = cls;
241 
242  (void)msg;
243  switch (call->state)
244  {
245  case CS_LOOKUP:
246  GNUNET_break(0);
247  fail_call(call);
248  break;
249 
250  case CS_RINGING:
251  GNUNET_break_op(0);
252  fail_call(call);
253  break;
254 
255  case CS_SUSPENDED_CALLER:
256  GNUNET_break_op(0);
257  break;
258 
259  case CS_SUSPENDED_CALLEE:
260  call->state = CS_ACTIVE;
261  call->speaker->enable_speaker(call->speaker->cls);
262  call->mic->enable_microphone(call->mic->cls,
264  call);
265  call->event_handler(call->event_handler_cls,
267  break;
268 
269  case CS_SUSPENDED_BOTH:
270  call->state = CS_SUSPENDED_CALLER;
271  call->event_handler(call->event_handler_cls,
273  break;
274 
275  case CS_ACTIVE:
276  GNUNET_break_op(0);
277  break;
278 
279  case CS_SHUTDOWN:
281  break;
282  }
283 }
The call was suspended by the caller.
static void fail_call(struct GNUNET_CONVERSATION_Call *call)
The call got disconnected, reconnect to the service.
The call is ringing.
enum CallState state
State machine for the call.
We are the caller and the callee suspended the call.
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void transmit_call_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
The call is in an active conversation.
void * event_handler_cls
Closure for event_handler.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void * cls
Closure for the callbacks.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
The call was suspended by the callee.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
The call was suspended by both caller and callee.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
Handle for an outgoing call.
The call is in termination.
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
We still need to lookup the callee.
Here is the call graph for this function:

◆ handle_call_picked_up()

static void handle_call_picked_up ( void *  cls,
const struct ClientPhonePickedupMessage msg 
)
static

We received a GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP.

Parameters
clsthe struct GNUNET_CONVERSATION_Call
msgthe message

Definition at line 293 of file conversation_api_call.c.

References call, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_LOOKUP, CS_RINGING, CS_SHUTDOWN, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, fail_call(), GNUNET_break, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_EC_CALL_PICKED_UP, GNUNET_CONVERSATION_Call::mic, GNUNET_CONVERSATION_Call::speaker, GNUNET_CONVERSATION_Call::state, and transmit_call_audio().

295 {
296  struct GNUNET_CONVERSATION_Call *call = cls;
297 
298  (void)msg;
299  switch (call->state)
300  {
301  case CS_LOOKUP:
302  GNUNET_break(0);
303  fail_call(call);
304  break;
305 
306  case CS_RINGING:
307  call->state = CS_ACTIVE;
308  call->speaker->enable_speaker(call->speaker->cls);
309  call->mic->enable_microphone(call->mic->cls,
311  call);
312  call->event_handler(call->event_handler_cls,
314  break;
315 
316  case CS_SUSPENDED_CALLER:
317  case CS_SUSPENDED_CALLEE:
318  case CS_SUSPENDED_BOTH:
319  case CS_ACTIVE:
320  GNUNET_break(0);
321  fail_call(call);
322  break;
323 
324  case CS_SHUTDOWN:
326  break;
327  }
328 }
The call was suspended by the caller.
static void fail_call(struct GNUNET_CONVERSATION_Call *call)
The call got disconnected, reconnect to the service.
The call is ringing.
enum CallState state
State machine for the call.
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void transmit_call_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
We are the caller and are now ready to talk as the callee picked up.
The call is in an active conversation.
void * event_handler_cls
Closure for event_handler.
void * cls
Closure for the callbacks.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
The call was suspended by the callee.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
The call was suspended by both caller and callee.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
Handle for an outgoing call.
The call is in termination.
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
We still need to lookup the callee.
Here is the call graph for this function:

◆ handle_call_hangup()

static void handle_call_hangup ( void *  cls,
const struct ClientPhoneHangupMessage msg 
)
static

We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_HANG_UP.

Parameters
clsthe struct GNUNET_CONVERSATION_Call
msgthe message

Definition at line 338 of file conversation_api_call.c.

References call, CS_ACTIVE, CS_LOOKUP, CS_RINGING, CS_SHUTDOWN, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, fail_call(), GNUNET_break, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_EC_CALL_HUNG_UP, and GNUNET_CONVERSATION_Call::state.

340 {
341  struct GNUNET_CONVERSATION_Call *call = cls;
343  void *eh_cls;
344 
345  (void)msg;
346  switch (call->state)
347  {
348  case CS_LOOKUP:
349  GNUNET_break(0);
350  fail_call(call);
351  break;
352 
353  case CS_RINGING:
354  case CS_SUSPENDED_CALLER:
355  case CS_SUSPENDED_CALLEE:
356  case CS_SUSPENDED_BOTH:
357  case CS_ACTIVE:
358  eh = call->event_handler;
359  eh_cls = call->event_handler_cls;
361  eh(eh_cls,
363  return;
364 
365  case CS_SHUTDOWN:
367  break;
368  }
369 }
void(* GNUNET_CONVERSATION_CallEventHandler)(void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
Function called with an event emitted for a call.
The call was suspended by the caller.
static void fail_call(struct GNUNET_CONVERSATION_Call *call)
The call got disconnected, reconnect to the service.
The call is ringing.
enum CallState state
State machine for the call.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
The call is in an active conversation.
void * event_handler_cls
Closure for event_handler.
We are the caller and the callee called GNUNET_CONVERSATION_caller_hang_up.
The call was suspended by the callee.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
The call was suspended by both caller and callee.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
Handle for an outgoing call.
The call is in termination.
We still need to lookup the callee.
Here is the call graph for this function:

◆ check_call_audio()

static int check_call_audio ( void *  cls,
const struct ClientAudioMessage am 
)
static

We received a struct ClientAudioMessage, check it is well-formed.

Parameters
clsthe struct GNUNET_CONVERSATION_Call
msgthe message
Returns
GNUNET_OK (always well-formed)

Definition at line 380 of file conversation_api_call.c.

References GNUNET_OK.

382 {
383  (void)cls;
384  (void)am;
385  /* any payload is OK */
386  return GNUNET_OK;
387 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ handle_call_audio()

static void handle_call_audio ( void *  cls,
const struct ClientAudioMessage am 
)
static

We received a struct ClientAudioMessage

Parameters
clsthe struct GNUNET_CONVERSATION_Call
msgthe message

Definition at line 397 of file conversation_api_call.c.

References call, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_LOOKUP, CS_RINGING, CS_SHUTDOWN, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, fail_call(), GNUNET_break, GNUNET_CONVERSATION_call_stop(), ClientAudioMessage::header, GNUNET_SPEAKER_Handle::play, GNUNET_MessageHeader::size, GNUNET_CONVERSATION_Call::speaker, and GNUNET_CONVERSATION_Call::state.

399 {
400  struct GNUNET_CONVERSATION_Call *call = cls;
401 
402  switch (call->state)
403  {
404  case CS_LOOKUP:
405  GNUNET_break(0);
406  fail_call(call);
407  break;
408 
409  case CS_RINGING:
410  GNUNET_break(0);
411  fail_call(call);
412  break;
413 
414  case CS_SUSPENDED_CALLER:
415  /* can happen: we suspended, other peer did not yet
416  learn about this. */
417  break;
418 
419  case CS_SUSPENDED_CALLEE:
420  case CS_SUSPENDED_BOTH:
421  /* can (rarely) also happen: other peer suspended, but cadet might
422  have had delayed data on the unreliable channel */
423  break;
424 
425  case CS_ACTIVE:
426  call->speaker->play(call->speaker->cls,
427  ntohs(am->header.size) - sizeof(struct ClientAudioMessage),
428  &am[1]);
429  break;
430 
431  case CS_SHUTDOWN:
433  break;
434  }
435 }
The call was suspended by the caller.
static void fail_call(struct GNUNET_CONVERSATION_Call *call)
The call got disconnected, reconnect to the service.
The call is ringing.
enum CallState state
State machine for the call.
GNUNET_SPEAKER_PlayCallback play
Play audio.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
The call is in an active conversation.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
The call was suspended by the callee.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
The call was suspended by both caller and callee.
Message Client <-> Service to transmit the audio.
Definition: conversation.h:180
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
Definition: conversation.h:184
Handle for an outgoing call.
The call is in termination.
We still need to lookup the callee.
Here is the call graph for this function:

◆ handle_gns_response()

static void handle_gns_response ( void *  cls,
int  was_gns,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Iterator called on obtained result for a GNS lookup.

Parameters
clsclosure with the struct GNUNET_CONVERSATION_Call
was_gnsGNUNET_NO if name was not a GNS name
rd_countnumber of records in rd
rdthe records in reply

Definition at line 447 of file conversation_api_call.c.

References call, GNUNET_CONVERSATION_Call::caller_id, ClientCallMessage::caller_id, CS_LOOKUP, CS_RINGING, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, e, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, GNUNET_CONVERSATION_Call::gns_lookup, GNUNET_break, GNUNET_break_op, GNUNET_CONVERSATION_call_stop(), GNUNET_CONVERSATION_EC_CALL_GNS_FAIL, GNUNET_CONVERSATION_EC_CALL_RINGING, GNUNET_GNSRECORD_TYPE_PHONE, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_PhoneRecord::line_port, ClientCallMessage::line_port, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_PhoneRecord::peer, GNUNET_CONVERSATION_Call::phone_record, GNUNET_CONVERSATION_Call::state, and ClientCallMessage::target.

Referenced by GNUNET_CONVERSATION_call_start().

451 {
452  struct GNUNET_CONVERSATION_Call *call = cls;
453  struct GNUNET_MQ_Envelope *e;
454  struct ClientCallMessage *ccm;
455 
456  (void)was_gns;
457  GNUNET_break(NULL != call->gns_lookup);
458  GNUNET_break(CS_LOOKUP == call->state);
459  call->gns_lookup = NULL;
460  for (uint32_t i = 0; i < rd_count; i++)
461  {
462  if (GNUNET_GNSRECORD_TYPE_PHONE == rd[i].record_type)
463  {
464  if (rd[i].data_size != sizeof(struct GNUNET_CONVERSATION_PhoneRecord))
465  {
466  GNUNET_break_op(0);
467  continue;
468  }
470  rd[i].data,
471  rd[i].data_size);
472  e = GNUNET_MQ_msg(ccm,
474  ccm->line_port = call->phone_record.line_port;
475  ccm->target = call->phone_record.peer;
477  GNUNET_MQ_send(call->mq,
478  e);
479  call->state = CS_RINGING;
480  call->event_handler(call->event_handler_cls,
482  return;
483  }
484  }
485  /* not found */
486  call->event_handler(call->event_handler_cls,
489 }
Client -> Service message to call a phone.
Definition: conversation.h:199
struct GNUNET_PeerIdentity peer
Identity of the peer hosting the phone service.
The call is ringing.
enum CallState state
State machine for the call.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_CALL
Client <- Server message to indicate a ringing phone.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:553
struct GNUNET_PeerIdentity target
Which peer is hosting the line?
Definition: conversation.h:213
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
struct GNUNET_CONVERSATION_PhoneRecord phone_record
Target phone record, only valid after the lookup is done.
struct GNUNET_IDENTITY_Ego * caller_id
Our caller identity.
#define GNUNET_GNSRECORD_TYPE_PHONE
Record type for a phone (of CONVERSATION).
size_t data_size
Number of bytes in data.
struct GNUNET_CRYPTO_EcdsaPrivateKey caller_id
Identity of the caller.
Definition: conversation.h:223
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
A phone record specifies which peer is hosting a given user and may also specify the phone line that ...
void * event_handler_cls
Closure for event_handler.
const void * data
Binary value stored in the DNS record.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
We are the caller and are now ringing the other party (GNS lookup succeeded).
We are the caller and failed to locate a phone record in GNS.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
struct GNUNET_HashCode line_port
Which phone line to call at the peer?
Definition: conversation.h:218
struct GNUNET_GNS_LookupWithTldRequest * gns_lookup
Active GNS lookup (or NULL).
struct GNUNET_HashCode line_port
Phone line (CADET port) to connect to.
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
Handle for an outgoing call.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
We still need to lookup the callee.
static size_t data_size
Number of bytes in data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ call_error_handler()

static void call_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

We encountered an error talking with the conversation service.

Parameters
clsthe struct GNUNET_CONVERSATION_Call
errordetails about the error

Definition at line 499 of file conversation_api_call.c.

References _, call, CS_SHUTDOWN, fail_call(), GNUNET_CONVERSATION_call_stop(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, and GNUNET_CONVERSATION_Call::state.

Referenced by GNUNET_CONVERSATION_call_start().

501 {
502  struct GNUNET_CONVERSATION_Call *call = cls;
503 
504  (void)error;
505  if (CS_SHUTDOWN == call->state)
506  {
508  return;
509  }
511  _("Connection to conversation service lost, trying to reconnect\n"));
512  fail_call(call);
513 }
static void fail_call(struct GNUNET_CONVERSATION_Call *call)
The call got disconnected, reconnect to the service.
enum CallState state
State machine for the call.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
#define GNUNET_log(kind,...)
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
Handle for an outgoing call.
The call is in termination.
Here is the call graph for this function:
Here is the caller graph for this function: