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_CRYPTO_EcdsaPublicKey *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_CRYPTO_EcdsaPublicKey *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 144 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 185 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 368 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 };
The conversation was terminated by the caller.
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 };
We are the callee and the caller resumed the call.
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 };
We are the caller and the callee suspended the call.
We are the caller and are now ready to talk as the callee picked up.
We are the caller and are now ringing the other party (GNS lookup succeeded).
We are the caller and the callee called GNUNET_CONVERSATION_caller_hang_up.
We are the caller and failed to locate a phone record in GNS.
We are the caller and the callee suspended the call.
We had an error handing the call, and are now restarting it (back to lookup).

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.

References cfg, GNUNET_CONVERSATION_Phone::cfg, GNUNET_CONVERSATION_Caller::event_handler, GNUNET_CONVERSATION_Phone::event_handler, GNUNET_CONVERSATION_Caller::event_handler_cls, 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, GNUNET_CONVERSATION_Caller::phone, reconnect_phone(), GNUNET_CONVERSATION_PhoneRecord::reserved, and GNUNET_CONVERSATION_PhoneRecord::version.

Referenced by start_phone().

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

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, and GNUNET_GNSRECORD_Data::record_type.

Referenced by start_phone().

688 {
689  rd->data = &phone->my_record;
690  rd->expiration_time = 0;
691  rd->data_size = sizeof(struct GNUNET_CONVERSATION_PhoneRecord);
694 }
#define GNUNET_GNSRECORD_TYPE_PHONE
Record type for a phone (of CONVERSATION).
size_t data_size
Number of bytes in data.
A phone record specifies which peer is hosting a given user and may also specify the phone line that ...
const void * data
Binary value stored in the DNS record.
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_CONVERSATION_PhoneRecord my_record
This phone's record.
uint32_t record_type
Type of the GNS/DNS record.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
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 708 of file conversation_api.c.

References GNUNET_CONVERSATION_Caller::cid, ClientPhonePickupMessage::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, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, GNUNET_CONVERSATION_Caller::speaker, GNUNET_CONVERSATION_Caller::state, and transmit_phone_audio().

Referenced by do_accept().

714 {
715  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
716  struct GNUNET_MQ_Envelope *e;
717  struct ClientPhonePickupMessage *pick;
718 
719  GNUNET_assert (CS_RINGING == caller->state);
720  caller->speaker = speaker;
721  caller->mic = mic;
722  e = GNUNET_MQ_msg (pick,
724  pick->cid = caller->cid;
725  GNUNET_MQ_send (phone->mq,
726  e);
727  caller->state = CS_ACTIVE;
728  caller->event_handler = event_handler;
729  caller->event_handler_cls = event_handler_cls;
730  caller->speaker->enable_speaker (caller->speaker->cls);
731  caller->mic->enable_microphone (caller->mic->cls,
733  caller);
734 }
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
The phone is in an active conversation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
#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:151
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
enum CallerState state
State machine for the phone.
The phone is ringing (user knows about incoming call).
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
GNUNET_CONVERSATION_CallerEventHandler event_handler
Function to call for phone events.
void * cls
Closure for the callbacks.
uint32_t cid
Internal handle to identify the caller with the service.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
static void transmit_phone_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
void * cls
Closure for the callbacks.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:162
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
void * event_handler_cls
Closure for event_handler.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
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 803 of file conversation_api.c.

References GNUNET_CONVERSATION_Caller::cid, ClientPhoneSuspendMessage::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, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Referenced by do_suspend().

804 {
805  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
806  struct GNUNET_MQ_Envelope *e;
807  struct ClientPhoneSuspendMessage *suspend;
808 
809  GNUNET_assert ((CS_ACTIVE == caller->state) ||
810  (CS_CALLER_SUSPENDED == caller->state));
811  if (CS_ACTIVE == caller->state)
812  {
813  caller->speaker->disable_speaker (caller->speaker->cls);
814  caller->mic->disable_microphone (caller->mic->cls);
815  }
816  caller->speaker = NULL;
817  caller->mic = NULL;
818  e = GNUNET_MQ_msg (suspend,
820  suspend->cid = caller->cid;
821  GNUNET_MQ_send (phone->mq,
822  e);
823  if (CS_ACTIVE == caller->state)
824  caller->state = CS_CALLEE_SUSPENDED;
825  else
826  caller->state = CS_BOTH_SUSPENDED;
827 }
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
The phone is in an active conversation.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
enum CallerState state
State machine for the phone.
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
void * cls
Closure for the callbacks.
We suspended the conversation.
uint32_t cid
Internal handle to identify the caller with the service.
Caller suspended the conversation.
void * cls
Closure for the callbacks.
Both sides suspended the conversation.
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
Service <-> Client message for phone was suspended.
Definition: conversation.h:115
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:126
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 838 of file conversation_api.c.

References GNUNET_CONVERSATION_Caller::cid, ClientPhoneResumeMessage::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, GNUNET_CONVERSATION_Phone::mq, GNUNET_CONVERSATION_Caller::phone, GNUNET_CONVERSATION_Caller::speaker, GNUNET_CONVERSATION_Caller::state, and transmit_phone_audio().

Referenced by do_resume().

841 {
842  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
843  struct GNUNET_MQ_Envelope *e;
844  struct ClientPhoneResumeMessage *resume;
845 
846  GNUNET_assert ((CS_CALLEE_SUSPENDED == caller->state) ||
847  (CS_BOTH_SUSPENDED == caller->state));
848  caller->speaker = speaker;
849  caller->mic = mic;
850  e = GNUNET_MQ_msg (resume,
852  resume->cid = caller->cid;
853  GNUNET_MQ_send (phone->mq,
854  e);
855  if (CS_CALLEE_SUSPENDED == caller->state)
856  {
857  caller->state = CS_ACTIVE;
858  caller->speaker->enable_speaker (caller->speaker->cls);
859  caller->mic->enable_microphone (caller->mic->cls,
861  caller);
862  }
863  else
864  {
865  caller->state = CS_CALLER_SUSPENDED;
866  }
867 }
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:144
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
The phone is in an active conversation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
enum CallerState state
State machine for the phone.
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
void * cls
Closure for the callbacks.
We suspended the conversation.
uint32_t cid
Internal handle to identify the caller with the service.
Caller suspended the conversation.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
static void transmit_phone_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
void * cls
Closure for the callbacks.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
Both sides suspended the conversation.
Service <-> Client message for phone was resumed.
Definition: conversation.h:133
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
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 744 of file conversation_api.c.

References GNUNET_CONVERSATION_Phone::caller_head, GNUNET_CONVERSATION_Phone::caller_tail, GNUNET_CONVERSATION_Caller::cid, ClientPhoneHangupMessage::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, GNUNET_CONVERSATION_Caller::speaker, and GNUNET_CONVERSATION_Caller::state.

Referenced by clean_up_callers(), and do_reject().

745 {
746  struct GNUNET_CONVERSATION_Phone *phone = caller->phone;
747  struct GNUNET_MQ_Envelope *e;
748  struct ClientPhoneHangupMessage *hang;
749 
750  switch (caller->state)
751  {
752  case CS_ACTIVE:
753  caller->speaker->disable_speaker (caller->speaker->cls);
754  caller->mic->disable_microphone (caller->mic->cls);
755  break;
756 
757  default:
758  break;
759  }
761  phone->caller_tail,
762  caller);
763  e = GNUNET_MQ_msg (hang,
765  hang->cid = caller->cid;
766  GNUNET_MQ_send (phone->mq,
767  e);
768  GNUNET_free (caller);
769 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CONVERSATION_Phone * phone
Phone handle.
The phone is in an active conversation.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
uint32_t cid
CID, internal caller ID to identify which active call we are talking about.
Definition: conversation.h:181
struct GNUNET_SPEAKER_Handle * speaker
Speaker, or NULL if none is attached.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
A phone is a device that can ring to signal an incoming call and that you can pick up to answer the c...
enum CallerState state
State machine for the phone.
struct GNUNET_CONVERSATION_Caller * caller_tail
We keep all callers in a DLL.
Client <-> Service hang up phone that may or may not be ringing.
Definition: conversation.h:170
struct GNUNET_MICROPHONE_Handle * mic
Microphone, or NULL if none is attached.
void * cls
Closure for the callbacks.
uint32_t cid
Internal handle to identify the caller with the service.
void * cls
Closure for the callbacks.
struct GNUNET_CONVERSATION_Phone * phone
Our phone.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_CONVERSATION_Caller * caller_head
We keep all callers in a DLL.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_free(ptr)
Wrapper around free.
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 778 of file conversation_api.c.

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

Referenced by do_stop_task(), and GNUNET_CONVERSATION_phone_create().

779 {
780  clean_up_callers (phone);
781  if (NULL != phone->ns)
782  {
784  phone->ns = NULL;
785  }
786  if (NULL != phone->mq)
787  {
788  GNUNET_MQ_destroy (phone->mq);
789  phone->mq = NULL;
790  }
791  GNUNET_free (phone);
792 }
static void clean_up_callers(struct GNUNET_CONVERSATION_Phone *phone)
Clean up all callers of the given phone.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_NAMESTORE_Handle * ns
Connection to NAMESTORE (for reverse lookup).
#define GNUNET_free(ptr)
Wrapper around free.
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.

References call, call_error_handler(), GNUNET_CONVERSATION_Call::callee, GNUNET_CONVERSATION_Call::caller_id, 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(), GNUNET_CONVERSATION_Call::mic, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_Call::speaker, and GNUNET_CONVERSATION_Call::state.

Referenced by do_call().

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 
596  call->mq = GNUNET_CLIENT_connect (cfg,
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;
614  call->gns = GNUNET_GNS_connect (cfg);
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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
enum CallState state
State machine for the 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
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_IDENTITY_Ego * caller_id
Our caller identity.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_GNSRECORD_TYPE_PHONE
Record type for a phone (of CONVERSATION).
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO
Client <-> Server message to send audio data.
struct GNUNET_GNS_Handle * gns
Connection to GNS (can be NULL).
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
void * event_handler_cls
Closure for event_handler.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
Client <-> Service hang up phone that may or may not be ringing.
Definition: conversation.h:170
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP
Service -> Client message to notify that phone was picked up.
char * callee
Target callee as a GNS address/name.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:262
Message handler for a specific message type.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
Service <-> Client message for phone was resumed.
Definition: conversation.h:133
Service -> Client: other peer has picked up the phone, we are now talking.
Definition: conversation.h:241
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
struct GNUNET_GNS_LookupWithTldRequest * gns_lookup
Active GNS lookup (or NULL).
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.
Message Client <-> Service to transmit the audio.
Definition: conversation.h:188
void GNUNET_CONVERSATION_call_stop(struct GNUNET_CONVERSATION_Call *call)
Terminate a call.
GNUNET_CONVERSATION_CallEventHandler event_handler
Function to call with events.
Handle for an outgoing call.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
static void call_error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error talking with the conversation service.
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
Service <-> Client message for phone was suspended.
Definition: conversation.h:115
We still need to lookup the callee.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP
Client -> Server message to reject/hangup a call.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
#define GNUNET_free(ptr)
Wrapper around free.
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.

References 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().

682 {
683  struct GNUNET_MQ_Envelope *e;
684  struct ClientPhoneSuspendMessage *suspend;
685 
687  (CS_ACTIVE == call->state));
688  if (CS_ACTIVE == call->state)
689  {
690  call->speaker->disable_speaker (call->speaker->cls);
691  call->mic->disable_microphone (call->mic->cls);
692  }
693  call->speaker = NULL;
694  call->mic = NULL;
695  e = GNUNET_MQ_msg (suspend,
697  GNUNET_MQ_send (call->mq,
698  e);
699  if (CS_SUSPENDED_CALLER == call->state)
700  call->state = CS_SUSPENDED_BOTH;
701  else
702  call->state = CS_SUSPENDED_CALLER;
703 }
The call was suspended by the caller.
enum CallState state
State machine for the call.
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
The call is in an active conversation.
void * cls
Closure for the callbacks.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
The call was suspended by the callee.
The call was suspended by both caller and callee.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND
Client <-> Server message to suspend connection.
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
Service <-> Client message for phone was suspended.
Definition: conversation.h:115
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.

References 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, GNUNET_CONVERSATION_Call::mq, GNUNET_CONVERSATION_Call::speaker, GNUNET_CONVERSATION_Call::state, and transmit_call_audio().

Referenced by do_resume().

718 {
719  struct GNUNET_MQ_Envelope *e;
720  struct ClientPhoneResumeMessage *resume;
721 
723  (CS_SUSPENDED_BOTH == call->state));
725  GNUNET_MQ_send (call->mq, e);
726  call->speaker = speaker;
727  call->mic = mic;
728  if (CS_SUSPENDED_CALLER == call->state)
729  {
730  call->state = CS_ACTIVE;
731  call->speaker->enable_speaker (call->speaker->cls);
732  call->mic->enable_microphone (call->mic->cls,
734  call);
735  }
736  else
737  {
738  call->state = CS_SUSPENDED_CALLEE;
739  }
740 }
The call was suspended by the caller.
enum CallState state
State machine for the call.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Experiment * e
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
static void transmit_call_audio(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
The call is in an active conversation.
void * cls
Closure for the callbacks.
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
#define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME
Client <-> Server message to resume connection.
Service <-> Client message for phone was resumed.
Definition: conversation.h:133
The call was suspended by the callee.
The call was suspended by both caller and callee.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
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.

References 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().

643 {
644  if ((NULL != call->speaker) &&
645  (CS_ACTIVE == call->state))
646  call->speaker->disable_speaker (call->speaker->cls);
647  if ((NULL != call->mic) &&
648  (CS_ACTIVE == call->state))
649  call->mic->disable_microphone (call->mic->cls);
650  if (CS_SHUTDOWN != call->state)
651  {
652  call->state = CS_SHUTDOWN;
653  }
654  if (NULL != call->mq)
655  {
656  GNUNET_MQ_destroy (call->mq);
657  call->mq = NULL;
658  }
659  if (NULL != call->gns_lookup)
660  {
662  call->gns_lookup = NULL;
663  }
664  if (NULL != call->gns)
665  {
666  GNUNET_GNS_disconnect (call->gns);
667  call->gns = NULL;
668  }
669  GNUNET_free (call->callee);
670  GNUNET_free (call);
671 }
enum CallState state
State machine for the call.
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
Definition: gns_tld_api.c:329
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
struct GNUNET_GNS_Handle * gns
Connection to GNS (can be NULL).
The call is in an active conversation.
void * cls
Closure for the callbacks.
char * callee
Target callee as a GNS address/name.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:284
struct GNUNET_MQ_Handle * mq
Handle for transmitting to the CONVERSATION service.
struct GNUNET_SPEAKER_Handle * speaker
Our speaker.
void * cls
Closure for the callbacks.
struct GNUNET_GNS_LookupWithTldRequest * gns_lookup
Active GNS lookup (or NULL).
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
The call is in termination.
struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: