GNUnet 0.21.1
conversation_api.c File Reference

phone and caller API to the conversation service More...

#include "platform.h"
#include "gnunet_conversation_service.h"
#include "conversation.h"
Include dependency graph for conversation_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_CONVERSATION_Caller
 A caller is the handle we have for an incoming call. More...
 
struct  GNUNET_CONVERSATION_Phone
 A phone is a device that can ring to signal an incoming call and that you can pick up to answer the call and hang up to terminate the call. More...
 

Enumerations

enum  CallerState {
  CS_RINGING , CS_ACTIVE , CS_CALLEE_SUSPENDED , CS_CALLER_SUSPENDED ,
  CS_BOTH_SUSPENDED
}
 Possible states of a caller. More...
 
enum  PhoneState {
  PS_REGISTER = 0 , PS_READY , PS_LOOKUP_EGO , PS_LISTEN ,
  PS_ACCEPTED , PS_ERROR
}
 Possible states of a phone. More...
 

Functions

static void reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone)
 The phone got disconnected, reconnect to the service. More...
 
static void transmit_phone_audio (void *cls, size_t data_size, const void *data)
 Process recorded audio data. More...
 
static enum GNUNET_GenericReturnValue check_phone_ring (void *cls, const struct ClientPhoneRingMessage *ring)
 We received a struct ClientPhoneRingMessage More...
 
static void handle_phone_ring (void *cls, const struct ClientPhoneRingMessage *ring)
 We received a struct ClientPhoneRingMessage More...
 
static struct GNUNET_CONVERSATION_Callerfind_caller (struct GNUNET_CONVERSATION_Phone *phone, uint32_t cid)
 Find the record of the caller matching the cid. More...
 
static void handle_phone_hangup (void *cls, const struct ClientPhoneHangupMessage *hang)
 We received a struct ClientPhoneHangupMessage. More...
 
static void handle_phone_suspend (void *cls, const struct ClientPhoneSuspendMessage *suspend)
 We received a struct ClientPhoneSuspendMessage. More...
 
static void handle_phone_resume (void *cls, const struct ClientPhoneResumeMessage *resume)
 We received a struct ClientPhoneResumeMessage. More...
 
static int check_phone_audio (void *cls, const struct ClientAudioMessage *am)
 We received a struct ClientAudioMessage, check it is well-formed. More...
 
static void handle_phone_audio (void *cls, const struct ClientAudioMessage *am)
 We received a struct ClientAudioMessage More...
 
static void phone_error_handler (void *cls, enum GNUNET_MQ_Error error)
 We encountered an error talking with the conversation service. More...
 
static void clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone)
 Clean up all callers of the given phone. More...
 
struct GNUNET_CONVERSATION_PhoneGNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_IDENTITY_Ego *ego, GNUNET_CONVERSATION_PhoneEventHandler event_handler, void *event_handler_cls)
 Create a new phone. More...
 
void GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone, struct GNUNET_GNSRECORD_Data *rd)
 Fill in a namestore record with the contact information for this phone. More...
 
void GNUNET_CONVERSATION_caller_pick_up (struct GNUNET_CONVERSATION_Caller *caller, GNUNET_CONVERSATION_CallerEventHandler event_handler, void *event_handler_cls, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
 Picks up a (ringing) phone. More...
 
void GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller)
 Hang up up a (possibly ringing) phone. More...
 
void GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone)
 Destroys a phone. More...
 
void GNUNET_CONVERSATION_caller_suspend (struct GNUNET_CONVERSATION_Caller *caller)
 Pause conversation of an active call. More...
 
void GNUNET_CONVERSATION_caller_resume (struct GNUNET_CONVERSATION_Caller *caller, struct GNUNET_SPEAKER_Handle *speaker, struct GNUNET_MICROPHONE_Handle *mic)
 Resume suspended conversation of a phone. More...
 

Detailed Description

phone and caller API to the conversation service

Author
Simon Dieterle
Andreas Fuchs
Christian Grothoff

Definition in file conversation_api.c.

Enumeration Type Documentation

◆ CallerState

Possible states of a caller.

Enumerator
CS_RINGING 

The phone is ringing (user knows about incoming call).

CS_ACTIVE 

The phone is in an active conversation.

CS_CALLEE_SUSPENDED 

We suspended the conversation.

CS_CALLER_SUSPENDED 

Caller suspended the conversation.

CS_BOTH_SUSPENDED 

Both sides suspended the conversation.

Definition at line 36 of file conversation_api.c.

37{
42
47
52
57
62};
@ CS_CALLEE_SUSPENDED
We suspended the conversation.
@ CS_BOTH_SUSPENDED
Both sides suspended the conversation.
@ CS_ACTIVE
The phone is in an active conversation.
@ CS_CALLER_SUSPENDED
Caller suspended the conversation.
@ CS_RINGING
The phone is ringing (user knows about incoming call).

◆ PhoneState

enum PhoneState

Possible states of a phone.

Enumerator
PS_REGISTER 

We still need to register the phone.

PS_READY 

We are waiting for calls.

PS_LOOKUP_EGO 

We're waiting for our own idenitty.

PS_LISTEN 

We're listening for calls.

PS_ACCEPTED 

We accepted an incoming phone call.

PS_ERROR 

Internal error.

Definition at line 125 of file conversation_api.c.

126{
130 PS_REGISTER = 0,
131
136};
@ PS_REGISTER
We still need to register the phone.
@ PS_READY
We are waiting for calls.

Function Documentation

◆ reconnect_phone()

static void reconnect_phone ( struct GNUNET_CONVERSATION_Phone phone)
static

The phone got disconnected, reconnect to the service.

Parameters
phonephone to reconnect

Definition at line 588 of file conversation_api.c.

589{
591 GNUNET_MQ_hd_var_size (phone_ring,
594 phone),
595 GNUNET_MQ_hd_fixed_size (phone_hangup,
598 phone),
599 GNUNET_MQ_hd_fixed_size (phone_suspend,
602 phone),
603 GNUNET_MQ_hd_fixed_size (phone_resume,
606 phone),
607 GNUNET_MQ_hd_var_size (phone_audio,
609 struct ClientAudioMessage,
610 phone),
612 };
613 struct GNUNET_MQ_Envelope *e;
614 struct ClientPhoneRegisterMessage *reg;
615
617 if (NULL != phone->mq)
618 {
620 phone->mq = NULL;
621 }
624 "conversation",
625 handlers,
627 phone);
628 if (NULL == phone->mq)
629 return;
630 e = GNUNET_MQ_msg (reg,
634 e);
636}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static void clean_up_callers(struct GNUNET_CONVERSATION_Phone *phone)
Clean up all callers of the given phone.
static void phone_error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error talking with the conversation service.
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER
Client -> Server message to register a phone.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING
Client <- Server message to indicate a ringing phone.
Message Client <-> Service to transmit the audio.
Definition: conversation.h:195
Client <-> Service hang up phone that may or may not be ringing.
Definition: conversation.h:177
Client -> Service message to register a phone.
Definition: conversation.h:73
struct GNUNET_HashCode line_port
Phone line / CADET port to register.
Definition: conversation.h:87
Service <-> Client message for phone was resumed.
Definition: conversation.h:140
Service -> Client message for phone is ringing.
Definition: conversation.h:95
Service <-> Client message for phone was suspended.
Definition: conversation.h:122
struct GNUNET_HashCode line_port
Phone line (CADET port) to connect to.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_CONVERSATION_PhoneRecord my_record
This phone's record.
enum PhoneState state
State machine for the phone.
Message handler for a specific message type.

References GNUNET_CONVERSATION_Phone::cfg, clean_up_callers(), GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, GNUNET_MQ_destroy(), GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handlers, ClientPhoneRegisterMessage::line_port, GNUNET_CONVERSATION_PhoneRecord::line_port, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Phone::my_record, phone, phone_error_handler(), PS_READY, PS_REGISTER, and GNUNET_CONVERSATION_Phone::state.

Referenced by GNUNET_CONVERSATION_phone_create(), and phone_error_handler().

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

◆ transmit_phone_audio()

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

Process recorded audio data.

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

Definition at line 221 of file conversation_api.c.

224{
225 struct GNUNET_CONVERSATION_Caller *caller = cls;
226 struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
227 struct GNUNET_MQ_Envelope *e;
228 struct ClientAudioMessage *am;
229
230 e = GNUNET_MQ_msg_extra (am,
231 data_size,
233 am->cid = caller->cid;
234 GNUNET_memcpy (&am[1],
235 data,
236 data_size);
238 e);
239}
static char * data
The data to insert into the dht.
static size_t data_size
Number of bytes in data.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:63
uint32_t cid
CID, internal caller ID to identify which active call we are sending data to.
Definition: conversation.h:205
A caller is the handle we have for an incoming call.
uint32_t cid
Internal handle to identify the caller with the service.
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...

References ClientAudioMessage::cid, GNUNET_CONVERSATION_Caller::cid, data, data_size, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, and phone.

Referenced by GNUNET_CONVERSATION_caller_pick_up(), GNUNET_CONVERSATION_caller_resume(), and handle_phone_resume().

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

◆ check_phone_ring()

static enum GNUNET_GenericReturnValue check_phone_ring ( void *  cls,
const struct ClientPhoneRingMessage ring 
)
static

We received a struct ClientPhoneRingMessage

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
ringthe message

Definition at line 248 of file conversation_api.c.

250{
251 //FIXME
252 return GNUNET_OK;
253}
@ GNUNET_OK

References GNUNET_OK.

◆ handle_phone_ring()

static void handle_phone_ring ( void *  cls,
const struct ClientPhoneRingMessage ring 
)
static

We received a struct ClientPhoneRingMessage

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
ringthe message

Definition at line 261 of file conversation_api.c.

263{
264 struct GNUNET_CONVERSATION_Phone *phone = cls;
265 struct GNUNET_CONVERSATION_Caller *caller;
266 struct GNUNET_CRYPTO_PublicKey caller_id;
267 size_t key_len;
268 size_t read;
269
270 key_len = ntohl (ring->key_len);
271 switch (phone->state)
272 {
273 case PS_REGISTER:
274 GNUNET_assert (0);
275 break;
276
277 case PS_READY:
278 if ((GNUNET_SYSERR ==
280 key_len,
281 &caller_id,
282 &read)) ||
283 (read != key_len))
284 {
285 GNUNET_break (0);
286 break;
287 }
288 caller = GNUNET_new (struct GNUNET_CONVERSATION_Caller);
289 caller->phone = phone;
292 caller);
293 caller->caller_id = caller_id;
294 caller->cid = ring->cid;
295 caller->state = CS_RINGING;
298 caller,
299 &caller->caller_id);
300 break;
301 }
302}
@ GNUNET_CONVERSATION_EC_PHONE_RING
We are the callee and the phone is ringing.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:103
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t cid
CID, internal caller ID number used in the future to identify which active call we are talking about.
Definition: conversation.h:105
uint32_t key_len
The identity key length.
Definition: conversation.h:110
enum CallerState state
State machine for the phone.
struct GNUNET_CRYPTO_PublicKey caller_id
Identity of the person calling us.
GNUNET_CONVERSATION_PhoneEventHandler event_handler
Function to call for phone events.
struct GNUNET_CONVERSATION_Caller * caller_tail
We keep all callers in a DLL.
struct GNUNET_CONVERSATION_Caller * caller_head
We keep all callers in a DLL.
void * event_handler_cls
Closure for event_handler.
An identity key as per LSD0001.

References GNUNET_CONVERSATION_Phone::caller_head, GNUNET_CONVERSATION_Caller::caller_id, GNUNET_CONVERSATION_Phone::caller_tail, ClientPhoneRingMessage::cid, GNUNET_CONVERSATION_Caller::cid, CS_RINGING, GNUNET_CONVERSATION_Phone::event_handler, GNUNET_CONVERSATION_Phone::event_handler_cls, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONVERSATION_EC_PHONE_RING, GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_new, GNUNET_SYSERR, ClientPhoneRingMessage::key_len, GNUNET_CONVERSATION_Caller::phone, phone, PS_READY, PS_REGISTER, GNUNET_CONVERSATION_Caller::state, and GNUNET_CONVERSATION_Phone::state.

Here is the call graph for this function:

◆ find_caller()

static struct GNUNET_CONVERSATION_Caller * find_caller ( struct GNUNET_CONVERSATION_Phone phone,
uint32_t  cid 
)
static

Find the record of the caller matching the cid.

Parameters
phonephone to search
cidcaller ID to search for (in NBO)
Returns
NULL if cid was not found

Definition at line 313 of file conversation_api.c.

315{
316 struct GNUNET_CONVERSATION_Caller *caller;
317
318 for (caller = phone->caller_head; NULL != caller; caller = caller->next)
319 if (cid == caller->cid)
320 return caller;
321 return NULL;
322}
struct GNUNET_CONVERSATION_Caller * next
We keep all callers in a DLL.

References GNUNET_CONVERSATION_Phone::caller_head, GNUNET_CONVERSATION_Caller::cid, GNUNET_CONVERSATION_Caller::next, and phone.

Referenced by handle_phone_audio(), handle_phone_hangup(), handle_phone_resume(), and handle_phone_suspend().

Here is the caller graph for this function:

◆ handle_phone_hangup()

static void handle_phone_hangup ( void *  cls,
const struct ClientPhoneHangupMessage hang 
)
static

We received a struct ClientPhoneHangupMessage.

Parameters
clsthe struct GNUNET_CONVERSATION_Phone *
hangthe message

Definition at line 332 of file conversation_api.c.

334{
335 struct GNUNET_CONVERSATION_Phone *phone = cls;
336 struct GNUNET_CONVERSATION_Caller *caller;
337
338 caller = find_caller (phone,
339 hang->cid);
340 if (NULL == caller)
341 {
343 "Received HANG_UP message for unknown caller ID %u\n",
344 (unsigned int) hang->cid);
345 return;
346 }
347
349 "Received HANG_UP message, terminating call with `%s'\n",
351 switch (caller->state)
352 {
353 case CS_RINGING:
356 caller,
357 &caller->caller_id);
358 break;
359
360 case CS_ACTIVE:
361 caller->speaker->disable_speaker (caller->speaker->cls);
362 caller->mic->disable_microphone (caller->mic->cls);
365 caller,
366 &caller->caller_id);
367 break;
368
374 caller,
375 &caller->caller_id);
376 break;
377 }
380 caller);
381 GNUNET_free (caller);
382}
static struct GNUNET_CONVERSATION_Caller * find_caller(struct GNUNET_CONVERSATION_Phone *phone, uint32_t cid)
Find the record of the caller matching the cid.
@ GNUNET_CONVERSATION_EC_PHONE_HUNG_UP
The conversation was terminated by the caller.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
const char * GNUNET_GNSRECORD_pkey_to_zkey(const struct GNUNET_CRYPTO_PublicKey *pkey)
Convert public key to the respective absolute domain name in the ".zkey" pTLD.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:187
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
void * cls
Closure for the callbacks.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
void * cls
Closure for the callbacks.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.

References GNUNET_CONVERSATION_Phone::caller_head, GNUNET_CONVERSATION_Caller::caller_id, GNUNET_CONVERSATION_Phone::caller_tail, ClientPhoneHangupMessage::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_BOTH_SUSPENDED, CS_CALLEE_SUSPENDED, CS_CALLER_SUSPENDED, CS_RINGING, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, GNUNET_CONVERSATION_Phone::event_handler, GNUNET_CONVERSATION_Phone::event_handler_cls, find_caller(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_pkey_to_zkey(), GNUNET_log, GNUNET_CONVERSATION_Caller::mic, phone, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Here is the call graph for this function:

◆ handle_phone_suspend()

static void handle_phone_suspend ( void *  cls,
const struct ClientPhoneSuspendMessage suspend 
)
static

We received a struct ClientPhoneSuspendMessage.

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
suspendthe message

Definition at line 392 of file conversation_api.c.

394{
395 struct GNUNET_CONVERSATION_Phone *phone = cls;
396 struct GNUNET_CONVERSATION_Caller *caller;
397
398 caller = find_caller (phone,
399 suspend->cid);
400 if (NULL == caller)
401 return;
402 switch (caller->state)
403 {
404 case CS_RINGING:
405 GNUNET_break_op (0);
406 break;
407
408 case CS_ACTIVE:
409 caller->state = CS_CALLER_SUSPENDED;
410 caller->speaker->disable_speaker (caller->speaker->cls);
411 caller->mic->disable_microphone (caller->mic->cls);
412 caller->event_handler (caller->event_handler_cls,
414 break;
415
417 caller->state = CS_BOTH_SUSPENDED;
418 caller->event_handler (caller->event_handler_cls,
420 break;
421
424 GNUNET_break_op (0);
425 break;
426 }
427}
@ GNUNET_CONVERSATION_EC_CALLER_SUSPEND
We are the callee and the caller suspended the call.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:132
void * event_handler_cls
Closure for event_handler.
GNUNET_CONVERSATION_CallerEventHandler event_handler
Function to call for phone events.

References ClientPhoneSuspendMessage::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_BOTH_SUSPENDED, CS_CALLEE_SUSPENDED, CS_CALLER_SUSPENDED, CS_RINGING, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, GNUNET_CONVERSATION_Caller::event_handler, GNUNET_CONVERSATION_Caller::event_handler_cls, find_caller(), GNUNET_break_op, GNUNET_CONVERSATION_EC_CALLER_SUSPEND, GNUNET_CONVERSATION_Caller::mic, phone, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Here is the call graph for this function:

◆ handle_phone_resume()

static void handle_phone_resume ( void *  cls,
const struct ClientPhoneResumeMessage resume 
)
static

We received a struct ClientPhoneResumeMessage.

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
resumethe message

Definition at line 437 of file conversation_api.c.

439{
440 struct GNUNET_CONVERSATION_Phone *phone = cls;
441 struct GNUNET_CONVERSATION_Caller *caller;
442
443 caller = find_caller (phone,
444 resume->cid);
445 if (NULL == caller)
446 return;
447 switch (caller->state)
448 {
449 case CS_RINGING:
450 GNUNET_break_op (0);
451 break;
452
453 case CS_ACTIVE:
455 GNUNET_break_op (0);
456 break;
457
459 caller->state = CS_ACTIVE;
460 caller->speaker->enable_speaker (caller->speaker->cls);
461 caller->mic->enable_microphone (caller->mic->cls,
463 caller);
464 caller->event_handler (caller->event_handler_cls,
466 break;
467
469 caller->state = CS_CALLEE_SUSPENDED;
470 caller->event_handler (caller->event_handler_cls,
472 break;
473 }
474}
static void transmit_phone_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
@ GNUNET_CONVERSATION_EC_CALLER_RESUME
We are the callee and the caller resumed the call.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:150
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.

References ClientPhoneResumeMessage::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_BOTH_SUSPENDED, CS_CALLEE_SUSPENDED, CS_CALLER_SUSPENDED, CS_RINGING, GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_CONVERSATION_Caller::event_handler, GNUNET_CONVERSATION_Caller::event_handler_cls, find_caller(), GNUNET_break_op, GNUNET_CONVERSATION_EC_CALLER_RESUME, GNUNET_CONVERSATION_Caller::mic, phone, GNUNET_CONVERSATION_Caller::speaker, GNUNET_CONVERSATION_Caller::state, and transmit_phone_audio().

Here is the call graph for this function:

◆ check_phone_audio()

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

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

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
amthe message
Returns
GNUNET_OK if am is well-formed

Definition at line 485 of file conversation_api.c.

487{
488 (void) cls;
489 (void) am;
490
491 /* any variable-size payload is OK */
492 return GNUNET_OK;
493}

References GNUNET_OK.

◆ handle_phone_audio()

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

We received a struct ClientAudioMessage

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
amthe message

Definition at line 503 of file conversation_api.c.

505{
506 struct GNUNET_CONVERSATION_Phone *phone = cls;
507 struct GNUNET_CONVERSATION_Caller *caller;
508
509 caller = find_caller (phone,
510 am->cid);
511 if (NULL == caller)
512 return;
513 switch (caller->state)
514 {
515 case CS_RINGING:
516 GNUNET_break_op (0);
517 break;
518
519 case CS_ACTIVE:
520 caller->speaker->play (caller->speaker->cls,
521 ntohs (am->header.size) - sizeof(struct
523 &am[1]);
524 break;
525
529 break;
530 }
531}
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
Definition: conversation.h:199
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
GNUNET_SPEAKER_PlayCallback play
Play audio.

References ClientAudioMessage::cid, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_BOTH_SUSPENDED, CS_CALLEE_SUSPENDED, CS_CALLER_SUSPENDED, CS_RINGING, find_caller(), GNUNET_break_op, ClientAudioMessage::header, phone, GNUNET_SPEAKER_Handle::play, GNUNET_MessageHeader::size, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Here is the call graph for this function:

◆ phone_error_handler()

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

We encountered an error talking with the conversation service.

Parameters
clsthe struct GNUNET_CONVERSATION_Phone
errordetails about the error

Definition at line 541 of file conversation_api.c.

543{
544 struct GNUNET_CONVERSATION_Phone *phone = cls;
545
546 (void) error;
548 _ (
549 "Connection to conversation service lost, trying to reconnect\n"));
551}
static void reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone)
The phone got disconnected, reconnect to the service.
@ GNUNET_ERROR_TYPE_WARNING
#define _(String)
GNU gettext support macro.
Definition: platform.h:178

References _, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, phone, and reconnect_phone().

Referenced by reconnect_phone().

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

◆ clean_up_callers()

static void clean_up_callers ( struct GNUNET_CONVERSATION_Phone phone)
static

Clean up all callers of the given phone.

Parameters
phonephone to clean up callers for

Definition at line 560 of file conversation_api.c.

561{
562 struct GNUNET_CONVERSATION_Caller *caller;
563
564 while (NULL != (caller = phone->caller_head))
565 {
566 /* make sure mic/speaker are disabled *before* callback */
567 if (CS_ACTIVE == caller->state)
568 {
569 caller->speaker->disable_speaker (caller->speaker->cls);
570 caller->mic->disable_microphone (caller->mic->cls);
571 caller->state = CS_CALLER_SUSPENDED;
572 }
575 caller,
576 &caller->caller_id);
578 }
579}
void GNUNET_CONVERSATION_caller_hang_up(struct GNUNET_CONVERSATION_Caller *caller)
Hang up up a (possibly ringing) phone.

References GNUNET_CONVERSATION_Phone::caller_head, GNUNET_CONVERSATION_Caller::caller_id, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_CALLER_SUSPENDED, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, GNUNET_CONVERSATION_Phone::event_handler, GNUNET_CONVERSATION_Phone::event_handler_cls, GNUNET_CONVERSATION_caller_hang_up(), GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, GNUNET_CONVERSATION_Caller::mic, phone, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Referenced by GNUNET_CONVERSATION_phone_destroy(), and reconnect_phone().

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