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.

39 {
43  CS_LOOKUP = 0,
44 
48  CS_RINGING,
49 
53  CS_ACTIVE,
54 
59 
64 
69 
74 };
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 505 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().

506 {
507  if (CS_ACTIVE == call->state)
508  {
509  call->speaker->disable_speaker (call->speaker->cls);
510  call->mic->disable_microphone (call->mic->cls);
511  }
512  if (NULL != call->mq)
513  {
514  GNUNET_MQ_destroy (call->mq);
515  call->mq = NULL;
516  }
517  call->state = CS_SHUTDOWN;
518  call->event_handler (call->event_handler_cls,
521 }
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:824
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 163 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().

166 {
167  struct GNUNET_CONVERSATION_Call *call = cls;
168  struct GNUNET_MQ_Envelope *e;
169  struct ClientAudioMessage *am;
170 
171  GNUNET_assert (CS_ACTIVE == call->state);
172  e = GNUNET_MQ_msg_extra (am,
173  data_size,
175  GNUNET_memcpy (&am[1],
176  data,
177  data_size);
178  GNUNET_MQ_send (call->mq,
179  e);
180 }
enum CallState state
State machine for the call.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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
#define GNUNET_memcpy(dst, src, n)
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:193
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:353
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 190 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.

192 {
193  struct GNUNET_CONVERSATION_Call *call = cls;
194 
195  (void) msg;
196  switch (call->state)
197  {
198  case CS_LOOKUP:
199  GNUNET_break (0);
200  fail_call (call);
201  break;
202  case CS_RINGING:
203  GNUNET_break_op (0);
204  fail_call (call);
205  break;
206  case CS_SUSPENDED_CALLER:
207  call->state = CS_SUSPENDED_BOTH;
208  call->event_handler (call->event_handler_cls,
210  break;
211  case CS_SUSPENDED_CALLEE:
212  case CS_SUSPENDED_BOTH:
213  GNUNET_break_op (0);
214  break;
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  case CS_SHUTDOWN:
224  break;
225  }
226 }
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 236 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().

238 {
239  struct GNUNET_CONVERSATION_Call *call = cls;
240 
241  (void) msg;
242  switch (call->state)
243  {
244  case CS_LOOKUP:
245  GNUNET_break (0);
246  fail_call (call);
247  break;
248  case CS_RINGING:
249  GNUNET_break_op (0);
250  fail_call (call);
251  break;
252  case CS_SUSPENDED_CALLER:
253  GNUNET_break_op (0);
254  break;
255  case CS_SUSPENDED_CALLEE:
256  call->state = CS_ACTIVE;
257  call->speaker->enable_speaker (call->speaker->cls);
258  call->mic->enable_microphone (call->mic->cls,
260  call);
261  call->event_handler (call->event_handler_cls,
263  break;
264  case CS_SUSPENDED_BOTH:
265  call->state = CS_SUSPENDED_CALLER;
266  call->event_handler (call->event_handler_cls,
268  break;
269  case CS_ACTIVE:
270  GNUNET_break_op (0);
271  break;
272  case CS_SHUTDOWN:
274  break;
275  }
276 }
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 286 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().

288 {
289  struct GNUNET_CONVERSATION_Call *call = cls;
290 
291  (void) msg;
292  switch (call->state)
293  {
294  case CS_LOOKUP:
295  GNUNET_break (0);
296  fail_call (call);
297  break;
298  case CS_RINGING:
299  call->state = CS_ACTIVE;
300  call->speaker->enable_speaker (call->speaker->cls);
301  call->mic->enable_microphone (call->mic->cls,
303  call);
304  call->event_handler (call->event_handler_cls,
306  break;
307  case CS_SUSPENDED_CALLER:
308  case CS_SUSPENDED_CALLEE:
309  case CS_SUSPENDED_BOTH:
310  case CS_ACTIVE:
311  GNUNET_break (0);
312  fail_call (call);
313  break;
314  case CS_SHUTDOWN:
316  break;
317  }
318 }
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 328 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.

330 {
331  struct GNUNET_CONVERSATION_Call *call = cls;
333  void *eh_cls;
334 
335  (void) msg;
336  switch (call->state)
337  {
338  case CS_LOOKUP:
339  GNUNET_break (0);
340  fail_call (call);
341  break;
342  case CS_RINGING:
343  case CS_SUSPENDED_CALLER:
344  case CS_SUSPENDED_CALLEE:
345  case CS_SUSPENDED_BOTH:
346  case CS_ACTIVE:
347  eh = call->event_handler;
348  eh_cls = call->event_handler_cls;
350  eh (eh_cls,
352  return;
353  case CS_SHUTDOWN:
355  break;
356  }
357 }
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 368 of file conversation_api_call.c.

References GNUNET_OK.

370 {
371  (void) cls;
372  (void) am;
373  /* any payload is OK */
374  return GNUNET_OK;
375 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ 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 385 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.

387 {
388  struct GNUNET_CONVERSATION_Call *call = cls;
389 
390  switch (call->state)
391  {
392  case CS_LOOKUP:
393  GNUNET_break (0);
394  fail_call (call);
395  break;
396  case CS_RINGING:
397  GNUNET_break (0);
398  fail_call (call);
399  break;
400  case CS_SUSPENDED_CALLER:
401  /* can happen: we suspended, other peer did not yet
402  learn about this. */
403  break;
404  case CS_SUSPENDED_CALLEE:
405  case CS_SUSPENDED_BOTH:
406  /* can (rarely) also happen: other peer suspended, but cadet might
407  have had delayed data on the unreliable channel */
408  break;
409  case CS_ACTIVE:
410  call->speaker->play (call->speaker->cls,
411  ntohs (am->header.size) - sizeof (struct ClientAudioMessage),
412  &am[1]);
413  break;
414  case CS_SHUTDOWN:
416  break;
417  }
418 }
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:193
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:198
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 430 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().

434 {
435  struct GNUNET_CONVERSATION_Call *call = cls;
436  struct GNUNET_MQ_Envelope *e;
437  struct ClientCallMessage *ccm;
438 
439  (void) was_gns;
440  GNUNET_break (NULL != call->gns_lookup);
441  GNUNET_break (CS_LOOKUP == call->state);
442  call->gns_lookup = NULL;
443  for (uint32_t i=0;i<rd_count;i++)
444  {
445  if (GNUNET_GNSRECORD_TYPE_PHONE == rd[i].record_type)
446  {
447  if (rd[i].data_size != sizeof (struct GNUNET_CONVERSATION_PhoneRecord))
448  {
449  GNUNET_break_op (0);
450  continue;
451  }
452  GNUNET_memcpy (&call->phone_record,
453  rd[i].data,
454  rd[i].data_size);
455  e = GNUNET_MQ_msg (ccm,
457  ccm->line_port = call->phone_record.line_port;
458  ccm->target = call->phone_record.peer;
460  GNUNET_MQ_send (call->mq,
461  e);
462  call->state = CS_RINGING;
463  call->event_handler (call->event_handler_cls,
465  return;
466  }
467  }
468  /* not found */
469  call->event_handler (call->event_handler_cls,
472 }
Client -> Service message to call a phone.
Definition: conversation.h:214
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:556
struct GNUNET_PeerIdentity target
Which peer is hosting the line?
Definition: conversation.h:229
#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:239
#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.
#define GNUNET_memcpy(dst, src, n)
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:234
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:353
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 482 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().

484 {
485  struct GNUNET_CONVERSATION_Call *call = cls;
486 
487  (void) error;
488  if (CS_SHUTDOWN == call->state)
489  {
491  return;
492  }
494  _("Connection to conversation service lost, trying to reconnect\n"));
495  fail_call (call);
496 }
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:208
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: