GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
Conversation service

One-to-one voice communication over CADET. More...

Data Structures

struct  GNUNET_CONVERSATION_PhoneRecord
 A phone record specifies which peer is hosting a given user and may also specify the phone line that is used (typically zero). More...
 

Macros

#define GNUNET_CONVERSATION_VERSION   0x00000004
 Version of the conversation API. More...
 

Typedefs

typedef void(* GNUNET_CONVERSATION_PhoneEventHandler) (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_IDENTITY_PublicKey *caller_id)
 Function called with an event emitted by a phone. More...
 
typedef void(* GNUNET_CONVERSATION_CallerEventHandler) (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)
 Function called with an event emitted by a caller. More...
 
typedef void(* GNUNET_CONVERSATION_CallEventHandler) (void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
 Function called with an event emitted for a call. More...
 

Enumerations

enum  GNUNET_CONVERSATION_PhoneEventCode { GNUNET_CONVERSATION_EC_PHONE_RING , GNUNET_CONVERSATION_EC_PHONE_HUNG_UP }
 Information about active callers to a phone. More...
 
enum  GNUNET_CONVERSATION_CallerEventCode { GNUNET_CONVERSATION_EC_CALLER_SUSPEND , GNUNET_CONVERSATION_EC_CALLER_RESUME }
 Information about the current status of a call. More...
 
enum  GNUNET_CONVERSATION_CallEventCode {
  GNUNET_CONVERSATION_EC_CALL_RINGING , GNUNET_CONVERSATION_EC_CALL_PICKED_UP , GNUNET_CONVERSATION_EC_CALL_GNS_FAIL , GNUNET_CONVERSATION_EC_CALL_HUNG_UP ,
  GNUNET_CONVERSATION_EC_CALL_SUSPENDED , GNUNET_CONVERSATION_EC_CALL_RESUMED , GNUNET_CONVERSATION_EC_CALL_ERROR
}
 Information about the current status of a call. More...
 

Functions

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 call. 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...
 
void GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller)
 Hang up up a (possibly ringing or paused) phone. More...
 
void GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone)
 Destroys a phone. 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_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...
 
void GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call)
 Terminate a call. More...
 

Detailed Description

One-to-one voice communication over CADET.

NOTE: This API is deliberately deceptively simple; the idea is that advanced features (such as answering machines) will be done with a separate service (an answering machine service) with its own APIs; the speaker/microphone abstractions are used to facilitate plugging in custom logic for implementing such a service later by creating "software" versions of speakers and microphones that record to disk or play a file. Notifications about missed calls should similarly be done using a separate service; CONVERSATION is supposed to be just the "bare bones" voice service.

As this is supposed to be a "secure" service, caller ID is of course provided as part of the basic implementation, as only the CONVERSATION service can know for sure who it is that we are talking to.

Macro Definition Documentation

◆ GNUNET_CONVERSATION_VERSION

#define GNUNET_CONVERSATION_VERSION   0x00000004

Version of the conversation API.

Definition at line 71 of file gnunet_conversation_service.h.

Typedef Documentation

◆ GNUNET_CONVERSATION_PhoneEventHandler

typedef void(* GNUNET_CONVERSATION_PhoneEventHandler) (void *cls, enum GNUNET_CONVERSATION_PhoneEventCode code, struct GNUNET_CONVERSATION_Caller *caller, const struct GNUNET_IDENTITY_PublicKey *caller_id)

Function called with an event emitted by a phone.

Parameters
clsclosure
codetype of the event
callerhandle for the caller
caller_idpublic key of the caller (in GNS)

Definition at line 143 of file gnunet_conversation_service.h.

◆ GNUNET_CONVERSATION_CallerEventHandler

typedef void(* GNUNET_CONVERSATION_CallerEventHandler) (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code)

Function called with an event emitted by a caller.

These events are only generated after the phone is picked up.

Parameters
clsclosure
codetype of the event for this caller

Definition at line 184 of file gnunet_conversation_service.h.

◆ GNUNET_CONVERSATION_CallEventHandler

typedef void(* GNUNET_CONVERSATION_CallEventHandler) (void *cls, enum GNUNET_CONVERSATION_CallEventCode code)

Function called with an event emitted for a call.

Parameters
clsclosure
codetype of the event on the call

Definition at line 367 of file gnunet_conversation_service.h.

Enumeration Type Documentation

◆ GNUNET_CONVERSATION_PhoneEventCode

Information about active callers to a phone.

Enumerator
GNUNET_CONVERSATION_EC_PHONE_RING 

We are the callee and the phone is ringing.

We should accept the call or hang up.

GNUNET_CONVERSATION_EC_PHONE_HUNG_UP 

The conversation was terminated by the caller.

We must no longer use the caller's handle.

Definition at line 119 of file gnunet_conversation_service.h.

120 {
126 
132 };
@ GNUNET_CONVERSATION_EC_PHONE_HUNG_UP
The conversation was terminated by the caller.
@ GNUNET_CONVERSATION_EC_PHONE_RING
We are the callee and the phone is ringing.

◆ GNUNET_CONVERSATION_CallerEventCode

Information about the current status of a call.

Each call progresses from ring over ready to terminated. Steps may be skipped.

Enumerator
GNUNET_CONVERSATION_EC_CALLER_SUSPEND 

We are the callee and the caller suspended the call.

Note that both sides can independently suspend and resume calls; a call is only "working" of both sides are active.

GNUNET_CONVERSATION_EC_CALLER_RESUME 

We are the callee and the caller resumed the call.

Note that both sides can independently suspend and resume calls; a call is only "working" of both sides are active.

Definition at line 158 of file gnunet_conversation_service.h.

159 {
166 
173 };
@ GNUNET_CONVERSATION_EC_CALLER_RESUME
We are the callee and the caller resumed the call.
@ GNUNET_CONVERSATION_EC_CALLER_SUSPEND
We are the callee and the caller suspended the call.

◆ GNUNET_CONVERSATION_CallEventCode

Information about the current status of a call.

Enumerator
GNUNET_CONVERSATION_EC_CALL_RINGING 

We are the caller and are now ringing the other party (GNS lookup succeeded).

GNUNET_CONVERSATION_EC_CALL_PICKED_UP 

We are the caller and are now ready to talk as the callee picked up.

GNUNET_CONVERSATION_EC_CALL_GNS_FAIL 

We are the caller and failed to locate a phone record in GNS.

After this invocation, the respective call handle will be automatically destroyed and the client must no longer call GNUNET_CONVERSATION_call_stop or any other function on the call object.

GNUNET_CONVERSATION_EC_CALL_HUNG_UP 

We are the caller and the callee called GNUNET_CONVERSATION_caller_hang_up.

After this invocation, the respective call handle will be automatically destroyed and the client must no longer call GNUNET_CONVERSATION_call_stop.

GNUNET_CONVERSATION_EC_CALL_SUSPENDED 

We are the caller and the callee suspended the call.

Note that both sides can independently suspend and resume calls; a call is only "working" of both sides are active.

GNUNET_CONVERSATION_EC_CALL_RESUMED 

We are the caller and the callee suspended the call.

Note that both sides can independently suspend and resume calls; a call is only "working" of both sides are active.

GNUNET_CONVERSATION_EC_CALL_ERROR 

We had an error handing the call, and are now restarting it (back to lookup).

This happens, for example, if the peer is restarted during a call.

Definition at line 308 of file gnunet_conversation_service.h.

309 {
315 
320 
329 
337 
344 
351 
358 };
@ GNUNET_CONVERSATION_EC_CALL_SUSPENDED
We are the caller and the callee suspended the call.
@ GNUNET_CONVERSATION_EC_CALL_GNS_FAIL
We are the caller and failed to locate a phone record in GNS.
@ GNUNET_CONVERSATION_EC_CALL_PICKED_UP
We are the caller and are now ready to talk as the callee picked up.
@ GNUNET_CONVERSATION_EC_CALL_RESUMED
We are the caller and the callee suspended the call.
@ GNUNET_CONVERSATION_EC_CALL_RINGING
We are the caller and are now ringing the other party (GNS lookup succeeded).
@ GNUNET_CONVERSATION_EC_CALL_ERROR
We had an error handing the call, and are now restarting it (back to lookup).
@ GNUNET_CONVERSATION_EC_CALL_HUNG_UP
We are the caller and the callee called GNUNET_CONVERSATION_caller_hang_up.

Function Documentation

◆ GNUNET_CONVERSATION_phone_create()

struct GNUNET_CONVERSATION_Phone* GNUNET_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.

Parameters
cfgconfiguration for the phone; specifies the phone service and which line the phone is to be connected to
egoego to use for name resolution (when determining caller ID)
event_handlerhow to notify the owner of the phone about events
event_handler_clsclosure for event_handler
cfgconfiguration for the phone; specifies the phone service and which line the phone is to be connected to
egoego to use for name resolution (when determining caller ID)
event_handlerhow to notify the owner of the phone about events
event_handler_clsclosure for event_handler
Returns
NULL on error (no valid line configured)

Definition at line 624 of file conversation_api.c.

629 {
631  char *line;
632  struct GNUNET_HashCode line_port;
633 
634  if (GNUNET_OK !=
636  "CONVERSATION",
637  "LINE",
638  &line))
639  {
641  "CONVERSATION",
642  "LINE");
643  return NULL;
644  }
646  strlen (line),
647  &line_port);
648  GNUNET_free (line);
650  if (GNUNET_OK !=
652  &phone->my_record.peer))
653  {
654  GNUNET_break (0);
655  GNUNET_free (phone);
656  return NULL;
657  }
658  phone->cfg = cfg;
660  phone->event_handler = event_handler;
661  phone->event_handler_cls = event_handler_cls;
663  phone->my_record.version = htonl (1);
664  phone->my_record.reserved = htonl (0);
665  phone->my_record.line_port = line_port;
667  if ((NULL == phone->mq) ||
668  (NULL == phone->ns))
669  {
670  GNUNET_break (0);
672  return NULL;
673  }
674  return phone;
675 }
static void reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone)
The phone got disconnected, reconnect to the service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
@ GNUNET_OK
Definition: gnunet_common.h:95
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CONVERSATION_phone_destroy(struct GNUNET_CONVERSATION_Phone *phone)
Destroys a phone.
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:639
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_HashCode line_port
Phone line (CADET port) to connect to.
struct GNUNET_PeerIdentity peer
Identity of the peer hosting the phone service.
uint32_t version
Version of the phone record, for now always one.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
struct GNUNET_IDENTITY_PrivateKey my_zone
My GNS zone.
GNUNET_CONVERSATION_PhoneEventHandler event_handler
Function to call for phone events.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_NAMESTORE_Handle * ns
Connection to NAMESTORE (for reverse lookup).
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_CONVERSATION_PhoneRecord my_record
This phone's record.
void * event_handler_cls
Closure for event_handler.
A 512-bit hashcode.

References cfg, GNUNET_CONVERSATION_Phone::cfg, GNUNET_CONVERSATION_Phone::event_handler, GNUNET_CONVERSATION_Phone::event_handler_cls, GNUNET_break, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONVERSATION_phone_destroy(), GNUNET_CRYPTO_get_peer_identity(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log_config_missing(), GNUNET_NAMESTORE_connect(), GNUNET_new, GNUNET_OK, line, GNUNET_CONVERSATION_PhoneRecord::line_port, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Phone::my_record, GNUNET_CONVERSATION_Phone::my_zone, GNUNET_CONVERSATION_Phone::ns, GNUNET_CONVERSATION_PhoneRecord::peer, phone, reconnect_phone(), GNUNET_CONVERSATION_PhoneRecord::reserved, and GNUNET_CONVERSATION_PhoneRecord::version.

Referenced by start_phone().

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

◆ GNUNET_CONVERSATION_phone_get_record()

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.

Note that the filled in "data" value is only valid until the phone is destroyed.

Parameters
phonephone to create a record for
rdnamestore record to fill in

Definition at line 687 of file conversation_api.c.

689 {
690  rd->data = &phone->my_record;
691  rd->expiration_time = 0;
692  rd->data_size = sizeof(struct GNUNET_CONVERSATION_PhoneRecord);
695 }
#define GNUNET_GNSRECORD_TYPE_PHONE
Endpoint for conversation.
@ GNUNET_GNSRECORD_RF_NONE
No special options.
A phone record specifies which peer is hosting a given user and may also specify the phone line that ...
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.

References GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_GNSRECORD_RF_NONE, GNUNET_GNSRECORD_TYPE_PHONE, GNUNET_CONVERSATION_Phone::my_record, phone, and GNUNET_GNSRECORD_Data::record_type.

Referenced by start_phone().

Here is the caller graph for this function:

◆ GNUNET_CONVERSATION_caller_pick_up()

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 call.

This will connect the speaker to the microphone of the other party, and vice versa.

Parameters
callerhandle that identifies which caller should be answered
event_handlerhow to notify about events by the caller
event_handler_clsclosure for event_handler
speakerspeaker to use
micmicrophone to use

Picks up a (ringing) phone call.

This will connect the speaker to the microphone of the other party, and vice versa.

Parameters
callerhandle that identifies which caller should be answered
event_handlerhow to notify about events by the caller
event_handler_clsclosure for event_handler
speakerspeaker to use
micmicrophone to use

Definition at line 709 of file conversation_api.c.

715 {
716  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
717  struct GNUNET_MQ_Envelope *e;
718  struct ClientPhonePickupMessage *pick;
719 
720  GNUNET_assert (CS_RINGING == caller->state);
721  caller->speaker = speaker;
722  caller->mic = mic;
723  e = GNUNET_MQ_msg (pick,
725  pick->cid = caller->cid;
727  e);
728  caller->state = CS_ACTIVE;
729  caller->event_handler = event_handler;
730  caller->event_handler_cls = event_handler_cls;
731  caller->speaker->enable_speaker (caller->speaker->cls);
732  caller->mic->enable_microphone (caller->mic->cls,
734  caller);
735 }
@ CS_ACTIVE
The phone is in an active conversation.
@ CS_RINGING
The phone is ringing (user knows about incoming call).
static void transmit_phone_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct Experiment * e
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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:355
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP
Client -> Server message to reject/hangup a call.
Client -> Service pick up phone that is ringing.
Definition: conversation.h:154
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:164
uint32_t cid
Internal handle to identify the caller with the service.
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
void * event_handler_cls
Closure for event_handler.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
enum CallerState state
State machine for the phone.
GNUNET_CONVERSATION_CallerEventHandler event_handler
Function to call for phone events.
void * cls
Closure for the callbacks.
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
void * cls
Closure for the callbacks.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.

References ClientPhonePickupMessage::cid, GNUNET_CONVERSATION_Caller::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_RINGING, e, GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_CONVERSATION_Caller::event_handler, GNUNET_CONVERSATION_Caller::event_handler_cls, GNUNET_assert, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_Caller::mic, mic, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, phone, GNUNET_CONVERSATION_Caller::speaker, speaker, GNUNET_CONVERSATION_Caller::state, and transmit_phone_audio().

Referenced by do_accept().

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

◆ GNUNET_CONVERSATION_caller_suspend()

void GNUNET_CONVERSATION_caller_suspend ( struct GNUNET_CONVERSATION_Caller caller)

Pause conversation of an active call.

This will disconnect the speaker and the microphone. The call can later be resumed with GNUNET_CONVERSATION_caller_resume.

Parameters
callercall to suspend

Definition at line 804 of file conversation_api.c.

805 {
806  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
807  struct GNUNET_MQ_Envelope *e;
808  struct ClientPhoneSuspendMessage *suspend;
809 
810  GNUNET_assert ((CS_ACTIVE == caller->state) ||
811  (CS_CALLER_SUSPENDED == caller->state));
812  if (CS_ACTIVE == caller->state)
813  {
814  caller->speaker->disable_speaker (caller->speaker->cls);
815  caller->mic->disable_microphone (caller->mic->cls);
816  }
817  caller->speaker = NULL;
818  caller->mic = NULL;
819  e = GNUNET_MQ_msg (suspend,
821  suspend->cid = caller->cid;
823  e);
824  if (CS_ACTIVE == caller->state)
825  caller->state = CS_CALLEE_SUSPENDED;
826  else
827  caller->state = CS_BOTH_SUSPENDED;
828 }
@ CS_CALLEE_SUSPENDED
We suspended the conversation.
@ CS_BOTH_SUSPENDED
Both sides suspended the conversation.
@ CS_CALLER_SUSPENDED
Caller suspended the conversation.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
Service <-> Client message for phone was suspended.
Definition: conversation.h:118
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:128
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.

References ClientPhoneSuspendMessage::cid, GNUNET_CONVERSATION_Caller::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_BOTH_SUSPENDED, CS_CALLEE_SUSPENDED, CS_CALLER_SUSPENDED, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, e, GNUNET_assert, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_Caller::mic, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, phone, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Referenced by do_suspend().

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

◆ GNUNET_CONVERSATION_caller_resume()

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.

Parameters
callercall to resume
speakerspeaker to use
micmicrophone to use

Definition at line 839 of file conversation_api.c.

842 {
843  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
844  struct GNUNET_MQ_Envelope *e;
845  struct ClientPhoneResumeMessage *resume;
846 
847  GNUNET_assert ((CS_CALLEE_SUSPENDED == caller->state) ||
848  (CS_BOTH_SUSPENDED == caller->state));
849  caller->speaker = speaker;
850  caller->mic = mic;
851  e = GNUNET_MQ_msg (resume,
853  resume->cid = caller->cid;
855  e);
856  if (CS_CALLEE_SUSPENDED == caller->state)
857  {
858  caller->state = CS_ACTIVE;
859  caller->speaker->enable_speaker (caller->speaker->cls);
860  caller->mic->enable_microphone (caller->mic->cls,
862  caller);
863  }
864  else
865  {
866  caller->state = CS_CALLER_SUSPENDED;
867  }
868 }
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
Service <-> Client message for phone was resumed.
Definition: conversation.h:136
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:146

References ClientPhoneResumeMessage::cid, GNUNET_CONVERSATION_Caller::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_BOTH_SUSPENDED, CS_CALLEE_SUSPENDED, CS_CALLER_SUSPENDED, e, GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_assert, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_Caller::mic, mic, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, phone, GNUNET_CONVERSATION_Caller::speaker, speaker, GNUNET_CONVERSATION_Caller::state, and transmit_phone_audio().

Referenced by do_resume().

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

◆ GNUNET_CONVERSATION_caller_hang_up()

void GNUNET_CONVERSATION_caller_hang_up ( struct GNUNET_CONVERSATION_Caller caller)

Hang up up a (possibly ringing or paused) phone.

This will notify the caller that we are no longer interested in talking with them.

Parameters
callerwho should we hang up on

Hang up up a (possibly ringing or paused) phone.

This will notify the other party that we are no longer interested in talking with them.

Parameters
callerconversation to hang up on

Definition at line 745 of file conversation_api.c.

746 {
747  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
748  struct GNUNET_MQ_Envelope *e;
749  struct ClientPhoneHangupMessage *hang;
750 
751  switch (caller->state)
752  {
753  case CS_ACTIVE:
754  caller->speaker->disable_speaker (caller->speaker->cls);
755  caller->mic->disable_microphone (caller->mic->cls);
756  break;
757 
758  default:
759  break;
760  }
763  caller);
764  e = GNUNET_MQ_msg (hang,
766  hang->cid = caller->cid;
768  e);
769  GNUNET_free (caller);
770 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
Client <-> Service hang up phone that may or may not be ringing.
Definition: conversation.h:173
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:183
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.

References GNUNET_CONVERSATION_Phone::caller_head, GNUNET_CONVERSATION_Phone::caller_tail, ClientPhoneHangupMessage::cid, GNUNET_CONVERSATION_Caller::cid, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, e, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_Caller::mic, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, phone, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Referenced by clean_up_callers().

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

◆ GNUNET_CONVERSATION_phone_destroy()

void GNUNET_CONVERSATION_phone_destroy ( struct GNUNET_CONVERSATION_Phone phone)

Destroys a phone.

Parameters
phonephone to destroy

Definition at line 779 of file conversation_api.c.

780 {
782  if (NULL != phone->ns)
783  {
785  phone->ns = NULL;
786  }
787  if (NULL != phone->mq)
788  {
790  phone->mq = NULL;
791  }
792  GNUNET_free (phone);
793 }
static void clean_up_callers(struct GNUNET_CONVERSATION_Phone *phone)
Clean up all callers of the given phone.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).

References clean_up_callers(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_NAMESTORE_disconnect(), GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Phone::ns, and phone.

Referenced by do_stop_task(), and GNUNET_CONVERSATION_phone_create().

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

◆ GNUNET_CONVERSATION_call_start()

struct GNUNET_CONVERSATION_Call* GNUNET_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.

Parameters
cfgconfiguration to use, specifies our phone service
caller_ididentity of the caller
calleeGNS name of the callee (used to locate the callee's record)
speakerspeaker to use (will be used automatically immediately once the GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated); we will NOT generate a ring tone on the speaker
micmicrophone to use (will be used automatically immediately once the GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated)
event_handlerhow to notify the owner of the phone about events
event_handler_clsclosure for event_handler
Returns
handle for the call
Parameters
cfgconfiguration to use, specifies our phone service
caller_ididentity of the caller
calleeGNS name of the callee (used to locate the callee's record)
speakerspeaker to use (will be used automatically immediately once the GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated); we will NOT generate a ring tone on the speaker
micmicrophone to use (will be used automatically immediately once the GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated)
event_handlerhow to notify the owner of the phone about events
event_handler_clsclosure for event_handler
Returns
handle for the call, NULL on hard errors

Definition at line 561 of file conversation_api_call.c.

569 {
573  GNUNET_MQ_hd_fixed_size (call_suspend,
576  call),
577  GNUNET_MQ_hd_fixed_size (call_resume,
580  call),
581  GNUNET_MQ_hd_fixed_size (call_picked_up,
584  call),
585  GNUNET_MQ_hd_fixed_size (call_hangup,
588  call),
589  GNUNET_MQ_hd_var_size (call_audio,
591  struct ClientAudioMessage,
592  call),
594  };
595 
597  "conversation",
598  handlers,
600  call);
601  if (NULL == call->mq)
602  {
603  GNUNET_break (0);
604  GNUNET_free (call);
605  return NULL;
606  }
607  call->cfg = cfg;
608  call->caller_id = caller_id;
609  call->callee = GNUNET_strdup (callee);
610  call->speaker = speaker;
611  call->mic = mic;
612  call->event_handler = event_handler;
613  call->event_handler_cls = event_handler_cls;
615  if (NULL == call->gns)
616  {
618  return NULL;
619  }
620  call->state = CS_LOOKUP;
622  call->callee,
624  GNUNET_NO,
626  call);
627  if (NULL == call->gns_lookup)
628  {
630  return NULL;
631  }
632  return call;
633 }
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.
@ CS_LOOKUP
We still need to lookup the callee.
static void call_error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error talking with the conversation service.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
@ GNUNET_NO
Definition: gnunet_common.h:94
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:1064
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
struct GNUNET_GNS_LookupWithTldRequest * GNUNET_GNS_lookup_with_tld(struct GNUNET_GNS_Handle *handle, const char *name, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor2 proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS, determining the zone using the TLD of the given ...
Definition: gns_tld_api.c:241
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:268
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
Service -> Client message to notify that phone was picked up.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
Message Client <-> Service to transmit the audio.
Definition: conversation.h:191
Service -> Client: other peer has picked up the phone, we are now talking.
Definition: conversation.h:244
Handle for an outgoing call.
void * event_handler_cls
Closure for event_handler.
char * callee
Target callee as a GNS address/name.
struct GNUNET_GNS_LookupWithTldRequest * gns_lookup
Active GNS lookup (or NULL).
struct GNUNET_GNS_Handle * gns
Connection to GNS (can be NULL).
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
enum CallState state
State machine for the call.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
struct GNUNET_IDENTITY_Ego * caller_id
Our caller identity.
Message handler for a specific message type.

References call, call_error_handler(), GNUNET_CONVERSATION_Call::callee, GNUNET_CONVERSATION_Call::caller_id, cfg, GNUNET_CONVERSATION_Call::cfg, CS_LOOKUP, GNUNET_CONVERSATION_Call::event_handler, GNUNET_CONVERSATION_Call::event_handler_cls, GNUNET_CONVERSATION_Call::gns, GNUNET_CONVERSATION_Call::gns_lookup, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_CONVERSATION_call_stop(), GNUNET_free, GNUNET_GNS_connect(), GNUNET_GNS_lookup_with_tld(), GNUNET_GNSRECORD_TYPE_PHONE, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NO, GNUNET_strdup, handle_gns_response(), handlers, GNUNET_CONVERSATION_Call::mic, mic, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_Call::speaker, speaker, and GNUNET_CONVERSATION_Call::state.

Referenced by do_call().

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

◆ GNUNET_CONVERSATION_call_suspend()

void GNUNET_CONVERSATION_call_suspend ( struct GNUNET_CONVERSATION_Call call)

Pause a call.

Temporarily suspends the use of speaker and microphone.

Parameters
callcall to pause

Definition at line 681 of file conversation_api_call.c.

682 {
683  struct GNUNET_MQ_Envelope *e;
684  struct ClientPhoneSuspendMessage *suspend;
685 
687  (CS_ACTIVE == call->state));
688  if (CS_ACTIVE == call->state)
689  {
692  }
693  call->speaker = NULL;
694  call->mic = NULL;
695  e = GNUNET_MQ_msg (suspend,
698  e);
701  else
703 }
@ CS_SUSPENDED_CALLEE
The call was suspended by the callee.
@ CS_SUSPENDED_CALLER
The call was suspended by the caller.
@ CS_SUSPENDED_BOTH
The call was suspended by both caller and callee.
@ CS_ACTIVE
The call is in an active conversation.

References call, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, GNUNET_MICROPHONE_Handle::disable_microphone, GNUNET_SPEAKER_Handle::disable_speaker, e, GNUNET_assert, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_Call::mic, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_Call::speaker, and GNUNET_CONVERSATION_Call::state.

Referenced by do_suspend().

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

◆ GNUNET_CONVERSATION_call_resume()

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.

Parameters
callcall to resume
speakerspeaker to use
micmicrophone to use
callcall to resume
speakerspeaker to use a ring tone on the speaker
micmicrophone to use

Definition at line 715 of file conversation_api_call.c.

718 {
719  struct GNUNET_MQ_Envelope *e;
720  struct ClientPhoneResumeMessage *resume;
721 
725  GNUNET_MQ_send (call->mq, e);
726  call->speaker = speaker;
727  call->mic = mic;
729  {
730  call->state = CS_ACTIVE;
734  call);
735  }
736  else
737  {
739  }
740 }
static void transmit_call_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.

References call, GNUNET_MICROPHONE_Handle::cls, GNUNET_SPEAKER_Handle::cls, CS_ACTIVE, CS_SUSPENDED_BOTH, CS_SUSPENDED_CALLEE, CS_SUSPENDED_CALLER, e, GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_assert, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CONVERSATION_Call::mic, mic, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_Call::speaker, speaker, GNUNET_CONVERSATION_Call::state, and transmit_call_audio().

Referenced by do_resume().

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

◆ GNUNET_CONVERSATION_call_stop()

void GNUNET_CONVERSATION_call_stop ( struct GNUNET_CONVERSATION_Call call)

Terminate a call.

The call may be ringing or ready at this time.

Parameters
callcall to terminate

Definition at line 642 of file conversation_api_call.c.

643 {
644  if ((NULL != call->speaker) &&
645  (CS_ACTIVE == call->state))
647  if ((NULL != call->mic) &&
648  (CS_ACTIVE == call->state))
650  if (CS_SHUTDOWN != call->state)
651  {
653  }
654  if (NULL != call->mq)
655  {
657  call->mq = NULL;
658  }
659  if (NULL != call->gns_lookup)
660  {
662  call->gns_lookup = NULL;
663  }
664  if (NULL != call->gns)
665  {
667  call->gns = NULL;
668  }
670  GNUNET_free (call);
671 }
@ CS_SHUTDOWN
The call is in termination.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:290
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
Definition: gns_tld_api.c:332

References call, GNUNET_CONVERSATION_Call::callee, 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::gns, GNUNET_CONVERSATION_Call::gns_lookup, GNUNET_free, GNUNET_GNS_disconnect(), GNUNET_GNS_lookup_with_tld_cancel(), 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(), do_stop_task(), fail_call(), GNUNET_CONVERSATION_call_start(), handle_call_audio(), handle_call_hangup(), handle_call_picked_up(), handle_call_resume(), handle_call_suspend(), and handle_gns_response().

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