GNUnet 0.25.2-11-g84e94e98c
 
Loading...
Searching...
No Matches
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 }
 Possible states of a phone. More...
 

Functions

static void reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone)
 The phone got disconnected, reconnect to the service.
 
static void transmit_phone_audio (void *cls, size_t data_size, const void *data)
 Process recorded audio data.
 
static enum GNUNET_GenericReturnValue check_phone_ring (void *cls, const struct ClientPhoneRingMessage *ring)
 We received a struct ClientPhoneRingMessage
 
static void handle_phone_ring (void *cls, const struct ClientPhoneRingMessage *ring)
 We received a struct ClientPhoneRingMessage
 
static struct GNUNET_CONVERSATION_Callerfind_caller (struct GNUNET_CONVERSATION_Phone *phone, uint32_t cid)
 Find the record of the caller matching the cid.
 
static void handle_phone_hangup (void *cls, const struct ClientPhoneHangupMessage *hang)
 We received a struct ClientPhoneHangupMessage.
 
static void handle_phone_suspend (void *cls, const struct ClientPhoneSuspendMessage *suspend)
 We received a struct ClientPhoneSuspendMessage.
 
static void handle_phone_resume (void *cls, const struct ClientPhoneResumeMessage *resume)
 We received a struct ClientPhoneResumeMessage.
 
static int check_phone_audio (void *cls, const struct ClientAudioMessage *am)
 We received a struct ClientAudioMessage, check it is well-formed.
 
static void handle_phone_audio (void *cls, const struct ClientAudioMessage *am)
 We received a struct ClientAudioMessage
 
static void phone_error_handler (void *cls, enum GNUNET_MQ_Error error)
 We encountered an error talking with the conversation service.
 
static void clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone)
 Clean up all callers of the given phone.
 
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.
 
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.
 
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.
 
void GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller)
 Hang up up a (possibly ringing) phone.
 
void GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone)
 Destroys a phone.
 
void GNUNET_CONVERSATION_caller_suspend (struct GNUNET_CONVERSATION_Caller *caller)
 Pause conversation of an active call.
 
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.
 

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.

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 591 of file conversation_api.c.

592{
594 GNUNET_MQ_hd_var_size (phone_ring,
597 phone),
598 GNUNET_MQ_hd_fixed_size (phone_hangup,
601 phone),
602 GNUNET_MQ_hd_fixed_size (phone_suspend,
605 phone),
606 GNUNET_MQ_hd_fixed_size (phone_resume,
609 phone),
610 GNUNET_MQ_hd_var_size (phone_audio,
612 struct ClientAudioMessage,
613 phone),
615 };
616 struct GNUNET_MQ_Envelope *e;
617 struct ClientPhoneRegisterMessage *reg;
618
620 if (NULL != phone->mq)
621 {
623 phone->mq = NULL;
624 }
627 "conversation",
628 handlers,
630 phone);
631 if (NULL == phone->mq)
632 return;
633 e = GNUNET_MQ_msg (reg,
637 e);
639}
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:1060
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#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:700
#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.
Client <-> Service hang up phone that may or may not be ringing.
Client -> Service message to register a phone.
struct GNUNET_HashCode line_port
Phone line / CADET port to register.
Service <-> Client message for phone was resumed.
Service -> Client message for phone is ringing.
Service <-> Client message for phone was suspended.
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.
uint32_t cid
CID, internal caller ID to identify which active call we are sending data to.
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 249 of file conversation_api.c.

251{
252 // FIXME
253 return GNUNET_OK;
254}
@ 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 264 of file conversation_api.c.

266{
267 struct GNUNET_CONVERSATION_Phone *phone = cls;
268 struct GNUNET_CONVERSATION_Caller *caller;
269 struct GNUNET_CRYPTO_BlindablePublicKey caller_id;
270 size_t key_len;
271 size_t read;
272
273 key_len = ntohl (ring->key_len);
274 switch (phone->state)
275 {
276 case PS_REGISTER:
277 GNUNET_assert (0);
278 break;
279
280 case PS_READY:
281 if ((GNUNET_SYSERR ==
283 key_len,
284 &caller_id,
285 &read)) ||
286 (read != key_len))
287 {
288 GNUNET_break (0);
289 break;
290 }
291 caller = GNUNET_new (struct GNUNET_CONVERSATION_Caller);
292 caller->phone = phone;
295 caller);
296 caller->caller_id = caller_id;
297 caller->cid = ring->cid;
298 caller->state = CS_RINGING;
301 caller,
302 &caller->caller_id);
303 break;
304 }
305}
@ 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_BlindablePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePublicKey from a compact buffer.
@ 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.
uint32_t key_len
The identity key length.
enum CallerState state
State machine for the phone.
struct GNUNET_CRYPTO_BlindablePublicKey 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 316 of file conversation_api.c.

318{
319 struct GNUNET_CONVERSATION_Caller *caller;
320
321 for (caller = phone->caller_head; NULL != caller; caller = caller->next)
322 if (cid == caller->cid)
323 return caller;
324 return NULL;
325}
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 335 of file conversation_api.c.

337{
338 struct GNUNET_CONVERSATION_Phone *phone = cls;
339 struct GNUNET_CONVERSATION_Caller *caller;
340
341 caller = find_caller (phone,
342 hang->cid);
343 if (NULL == caller)
344 {
346 "Received HANG_UP message for unknown caller ID %u\n",
347 (unsigned int) hang->cid);
348 return;
349 }
350
352 "Received HANG_UP message, terminating call with `%s'\n",
354 switch (caller->state)
355 {
356 case CS_RINGING:
359 caller,
360 &caller->caller_id);
361 break;
362
363 case CS_ACTIVE:
364 caller->speaker->disable_speaker (caller->speaker->cls);
365 caller->mic->disable_microphone (caller->mic->cls);
368 caller,
369 &caller->caller_id);
370 break;
371
377 caller,
378 &caller->caller_id);
379 break;
380 }
383 caller);
384 GNUNET_free (caller);
385}
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_BlindablePublicKey *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.
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 395 of file conversation_api.c.

397{
398 struct GNUNET_CONVERSATION_Phone *phone = cls;
399 struct GNUNET_CONVERSATION_Caller *caller;
400
401 caller = find_caller (phone,
402 suspend->cid);
403 if (NULL == caller)
404 return;
405 switch (caller->state)
406 {
407 case CS_RINGING:
408 GNUNET_break_op (0);
409 break;
410
411 case CS_ACTIVE:
412 caller->state = CS_CALLER_SUSPENDED;
413 caller->speaker->disable_speaker (caller->speaker->cls);
414 caller->mic->disable_microphone (caller->mic->cls);
415 caller->event_handler (caller->event_handler_cls,
417 break;
418
420 caller->state = CS_BOTH_SUSPENDED;
421 caller->event_handler (caller->event_handler_cls,
423 break;
424
427 GNUNET_break_op (0);
428 break;
429 }
430}
@ 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.
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 440 of file conversation_api.c.

442{
443 struct GNUNET_CONVERSATION_Phone *phone = cls;
444 struct GNUNET_CONVERSATION_Caller *caller;
445
446 caller = find_caller (phone,
447 resume->cid);
448 if (NULL == caller)
449 return;
450 switch (caller->state)
451 {
452 case CS_RINGING:
453 GNUNET_break_op (0);
454 break;
455
456 case CS_ACTIVE:
458 GNUNET_break_op (0);
459 break;
460
462 caller->state = CS_ACTIVE;
463 caller->speaker->enable_speaker (caller->speaker->cls);
464 caller->mic->enable_microphone (caller->mic->cls,
466 caller);
467 caller->event_handler (caller->event_handler_cls,
469 break;
470
472 caller->state = CS_CALLEE_SUSPENDED;
473 caller->event_handler (caller->event_handler_cls,
475 break;
476 }
477}
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.
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 488 of file conversation_api.c.

490{
491 (void) cls;
492 (void) am;
493
494 /* any variable-size payload is OK */
495 return GNUNET_OK;
496}

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 506 of file conversation_api.c.

508{
509 struct GNUNET_CONVERSATION_Phone *phone = cls;
510 struct GNUNET_CONVERSATION_Caller *caller;
511
512 caller = find_caller (phone,
513 am->cid);
514 if (NULL == caller)
515 return;
516 switch (caller->state)
517 {
518 case CS_RINGING:
519 GNUNET_break_op (0);
520 break;
521
522 case CS_ACTIVE:
523 caller->speaker->play (caller->speaker->cls,
524 ntohs (am->header.size) - sizeof(struct
526 &am[1]);
527 break;
528
532 break;
533 }
534}
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO.
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 544 of file conversation_api.c.

546{
547 struct GNUNET_CONVERSATION_Phone *phone = cls;
548
549 (void) error;
551 _ (
552 "Connection to conversation service lost, trying to reconnect\n"));
554}
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:179

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 563 of file conversation_api.c.

564{
565 struct GNUNET_CONVERSATION_Caller *caller;
566
567 while (NULL != (caller = phone->caller_head))
568 {
569 /* make sure mic/speaker are disabled *before* callback */
570 if (CS_ACTIVE == caller->state)
571 {
572 caller->speaker->disable_speaker (caller->speaker->cls);
573 caller->mic->disable_microphone (caller->mic->cls);
574 caller->state = CS_CALLER_SUSPENDED;
575 }
578 caller,
579 &caller->caller_id);
581 }
582}
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: