GNUnet 0.22.2

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

Collaboration diagram for Conversation service:

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_CRYPTO_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 75 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_CRYPTO_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 147 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 188 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 371 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 123 of file gnunet_conversation_service.h.

124{
130
136};
@ 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 162 of file gnunet_conversation_service.h.

163{
170
177};
@ 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 312 of file gnunet_conversation_service.h.

313{
319
324
333
341
348
355
362};
@ 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 650 of file conversation_api.c.

655{
657 char *line;
658 struct GNUNET_HashCode line_port;
659
660 if (GNUNET_OK !=
662 "CONVERSATION",
663 "LINE",
664 &line))
665 {
667 "CONVERSATION",
668 "LINE");
669 return NULL;
670 }
672 strlen (line),
673 &line_port);
676 if (GNUNET_OK !=
679 {
680 GNUNET_break (0);
682 return NULL;
683 }
684 phone->cfg = cfg;
686 phone->event_handler = event_handler;
687 phone->event_handler_cls = event_handler_cls;
689 phone->my_record.version = htonl (1);
690 phone->my_record.reserved = htonl (0);
691 phone->my_record.line_port = line_port;
693 if ((NULL == phone->mq) ||
694 (NULL == phone->ns))
695 {
696 GNUNET_break (0);
698 return NULL;
699 }
700 return phone;
701}
static void reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone)
The phone got disconnected, reconnect to the service.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
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.
enum GNUNET_GenericReturnValue 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_CRYPTO_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:517
@ GNUNET_OK
#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...
GNUNET_CONVERSATION_PhoneEventHandler event_handler
Function to call for phone events.
struct GNUNET_CRYPTO_PrivateKey my_zone
My GNS zone.
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 713 of file conversation_api.c.

715{
716 rd->data = &phone->my_record;
717 rd->expiration_time = 0;
721}
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
@ GNUNET_GNSRECORD_RF_NONE
Entry for no flags / cleared flags.
#define GNUNET_GNSRECORD_TYPE_PHONE
Endpoint for conversation.
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, rd, 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 735 of file conversation_api.c.

741{
742 struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
743 struct GNUNET_MQ_Envelope *e;
744 struct ClientPhonePickupMessage *pick;
745
746 GNUNET_assert (CS_RINGING == caller->state);
747 caller->speaker = speaker;
748 caller->mic = mic;
749 e = GNUNET_MQ_msg (pick,
751 pick->cid = caller->cid;
753 e);
754 caller->state = CS_ACTIVE;
755 caller->event_handler = event_handler;
756 caller->event_handler_cls = event_handler_cls;
757 caller->speaker->enable_speaker (caller->speaker->cls);
758 caller->mic->enable_microphone (caller->mic->cls,
760 caller);
761}
@ 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 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:305
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#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:158
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:168
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, 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 830 of file conversation_api.c.

831{
832 struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
833 struct GNUNET_MQ_Envelope *e;
834 struct ClientPhoneSuspendMessage *suspend;
835
836 GNUNET_assert ((CS_ACTIVE == caller->state) ||
837 (CS_CALLER_SUSPENDED == caller->state));
838 if (CS_ACTIVE == caller->state)
839 {
840 caller->speaker->disable_speaker (caller->speaker->cls);
841 caller->mic->disable_microphone (caller->mic->cls);
842 }
843 caller->speaker = NULL;
844 caller->mic = NULL;
845 e = GNUNET_MQ_msg (suspend,
847 suspend->cid = caller->cid;
849 e);
850 if (CS_ACTIVE == caller->state)
851 caller->state = CS_CALLEE_SUSPENDED;
852 else
853 caller->state = CS_BOTH_SUSPENDED;
854}
@ 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:122
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:132
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, 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 865 of file conversation_api.c.

868{
869 struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
870 struct GNUNET_MQ_Envelope *e;
871 struct ClientPhoneResumeMessage *resume;
872
874 (CS_BOTH_SUSPENDED == caller->state));
875 caller->speaker = speaker;
876 caller->mic = mic;
877 e = GNUNET_MQ_msg (resume,
879 resume->cid = caller->cid;
881 e);
882 if (CS_CALLEE_SUSPENDED == caller->state)
883 {
884 caller->state = CS_ACTIVE;
885 caller->speaker->enable_speaker (caller->speaker->cls);
886 caller->mic->enable_microphone (caller->mic->cls,
888 caller);
889 }
890 else
891 {
892 caller->state = CS_CALLER_SUSPENDED;
893 }
894}
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
Service <-> Client message for phone was resumed.
Definition: conversation.h:140
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:150

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

772{
773 struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
774 struct GNUNET_MQ_Envelope *e;
775 struct ClientPhoneHangupMessage *hang;
776
777 switch (caller->state)
778 {
779 case CS_ACTIVE:
780 caller->speaker->disable_speaker (caller->speaker->cls);
781 caller->mic->disable_microphone (caller->mic->cls);
782 break;
783
784 default:
785 break;
786 }
789 caller);
790 e = GNUNET_MQ_msg (hang,
792 hang->cid = caller->cid;
794 e);
795 GNUNET_free (caller);
796}
#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:177
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:187
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, 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(), and do_reject().

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

806{
808 if (NULL != phone->ns)
809 {
811 phone->ns = NULL;
812 }
813 if (NULL != phone->mq)
814 {
816 phone->mq = NULL;
817 }
819}
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:700
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 567 of file conversation_api_call.c.

575{
579 GNUNET_MQ_hd_fixed_size (call_suspend,
582 call),
583 GNUNET_MQ_hd_fixed_size (call_resume,
586 call),
587 GNUNET_MQ_hd_fixed_size (call_picked_up,
590 call),
591 GNUNET_MQ_hd_fixed_size (call_hangup,
594 call),
595 GNUNET_MQ_hd_var_size (call_audio,
597 struct ClientAudioMessage,
598 call),
600 };
601
603 "conversation",
604 handlers,
606 call);
607 if (NULL == call->mq)
608 {
609 GNUNET_break (0);
611 return NULL;
612 }
613 call->cfg = cfg;
614 call->caller_id = caller_id;
615 call->callee = GNUNET_strdup (callee);
617 call->mic = mic;
618 call->event_handler = event_handler;
619 call->event_handler_cls = event_handler_cls;
621 if (NULL == call->gns)
622 {
624 return NULL;
625 }
628 call->callee,
632 call);
633 if (NULL == call->gns_lookup)
634 {
636 return NULL;
637 }
638 return call;
639}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
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_CONVERSATION_Call * call
Call handle (for active outgoing call).
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_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:240
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:267
@ GNUNET_GNS_LO_DEFAULT
Defaults, look in cache, then in DHT.
#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:195
Service -> Client: other peer has picked up the phone, we are now talking.
Definition: conversation.h:252
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_LO_DEFAULT, 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_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 687 of file conversation_api_call.c.

688{
689 struct GNUNET_MQ_Envelope *e;
690 struct ClientPhoneSuspendMessage *suspend;
691
693 (CS_ACTIVE == call->state));
694 if (CS_ACTIVE == call->state)
695 {
698 }
699 call->speaker = NULL;
700 call->mic = NULL;
701 e = GNUNET_MQ_msg (suspend,
704 e);
707 else
709}
@ 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, 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 721 of file conversation_api_call.c.

724{
725 struct GNUNET_MQ_Envelope *e;
726 struct ClientPhoneResumeMessage *resume;
727
731 GNUNET_MQ_send (call->mq, e);
733 call->mic = mic;
735 {
740 call);
741 }
742 else
743 {
745 }
746}
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, 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 648 of file conversation_api_call.c.

649{
650 if ((NULL != call->speaker) &&
651 (CS_ACTIVE == call->state))
653 if ((NULL != call->mic) &&
654 (CS_ACTIVE == call->state))
656 if (CS_SHUTDOWN != call->state)
657 {
659 }
660 if (NULL != call->mq)
661 {
663 call->mq = NULL;
664 }
665 if (NULL != call->gns_lookup)
666 {
668 call->gns_lookup = NULL;
669 }
670 if (NULL != call->gns)
671 {
673 call->gns = NULL;
674 }
677}
@ 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:289
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
Definition: gns_tld_api.c:331

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_reject(), 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: