aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-02 18:28:36 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-02 18:28:36 +0000
commit705d8a8c1efe6cd7f0d9a452e8bb89cd7923fe99 (patch)
tree9869e078282d60fc21c4e31029373bd32e050219 /src/include
parent17e35f0a3eabb698ac7a0e34e096d64ab3a6d123 (diff)
downloadgnunet-705d8a8c1efe6cd7f0d9a452e8bb89cd7923fe99.tar.gz
gnunet-705d8a8c1efe6cd7f0d9a452e8bb89cd7923fe99.zip
-proposing improved conversation API
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_conversation_service.h243
1 files changed, 243 insertions, 0 deletions
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h
index 6b01119d8..9f7b829aa 100644
--- a/src/include/gnunet_conversation_service.h
+++ b/src/include/gnunet_conversation_service.h
@@ -23,6 +23,7 @@
23 * @brief API to the conversation service 23 * @brief API to the conversation service
24 * @author Simon Dieterle 24 * @author Simon Dieterle
25 * @author Andreas Fuchs 25 * @author Andreas Fuchs
26 * @author Christian Grothoff
26 */ 27 */
27#ifndef GNUNET_CONVERSATION_SERVICE_H 28#ifndef GNUNET_CONVERSATION_SERVICE_H
28#define GNUNET_CONVERSATION_SERVICE_H 29#define GNUNET_CONVERSATION_SERVICE_H
@@ -206,6 +207,248 @@ void
206GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle); 207GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle);
207 208
208 209
210
211////////////////////////////////////////////////////////////////////
212////////////////////////// NEW API /////////////////////////////////
213////////////////////////////////////////////////////////////////////
214
215/*
216 NOTE: This API is deliberately deceptively simple; the idea
217 is that advanced features (such as answering machines) will
218 be done with a separate service (an answering machine service)
219 with its own APIs; the speaker/microphone abstractions are
220 used to facilitate plugging in custom logic for implementing
221 such a service later by creating "software" versions of
222 speakers and microphones that record to disk or play a file.
223 Notifications about missed calls should similarly be done
224 using a separate service; CONVERSATION is supposed to be just
225 the "bare bones" voice service.
226
227 Meta data passing is supported so that advanced services
228 can identify themselves appropriately.
229
230 As this is supposed to be a "secure" service, caller ID is of
231 course provided as part of the basic implementation, as only the
232 CONVERSATION service can know for sure who it is that we are
233 talking to.x */
234
235
236#include "gnunet_identity_service.h"
237#include "gnunet_namestore_service.h"
238
239
240/**
241 * A speaker is a device that can play or record audio data.
242 */
243struct GNUNET_CONVERSATION_Speaker;
244
245
246/**
247 * Create a speaker that corresponds to the speaker hardware
248 * of our system.
249 *
250 * @param cfg configuration to use
251 * @return NULL on error
252 */
253struct GNUNET_CONVERSATION_Speaker *
254GNUNET_CONVERSATION_speaker_create_from_hardware (struct GNUNET_CONFIGURATION_Handle *cfg);
255
256
257/**
258 * Destroy a speaker.
259 *
260 * @param speaker speaker to destroy
261 */
262void
263GNUNET_CONVERSATION_speaker_destroy (struct GNUNET_CONVERSATION_Speaker *speaker);
264
265
266/**
267 * A speaker is a device that can generate audio data.
268 */
269struct GNUNET_CONVERSATION_Microphone;
270
271
272/**
273 * Create a speaker that corresponds to the speaker hardware
274 * of our system.
275 *
276 * @param cfg configuration to use
277 * @return NULL on error
278 */
279struct GNUNET_CONVERSATION_Microphone *
280GNUNET_CONVERSATION_microphone_create_from_hardware (struct GNUNET_CONFIGURATION_Handle *cfg);
281
282
283/**
284 * Destroy a microphone.
285 *
286 * @param mic microphone to destroy
287 */
288void
289GNUNET_CONVERSATION_microphone_destroy (struct GNUNET_CONVERSATION_Microphone *mic);
290
291
292/**
293 * Information about the current status of a call. Each call
294 * progresses from ring over ready to terminated. Steps may
295 * be skipped.
296 */
297enum GNUNET_CONVERSATION_EventCode
298{
299 /**
300 * The phone is ringing, caller ID is provided in the varargs as
301 * a `const char *`. The caller ID will be a GNS name.
302 */
303 GNUNET_CONVERSATION_EC_RING,
304
305 /**
306 * We are ready to talk, metadata about the call may be supplied
307 * as a `const char *` in the varargs.
308 */
309 GNUNET_CONVERSATION_EC_READY,
310
311 /**
312 * The conversation was terminated, a reason may be supplied
313 * as a `const char *` in the varargs.
314 */
315 GNUNET_CONVERSATION_EC_TERMINATED
316
317};
318
319
320/**
321 * Function called with an event emitted by a phone.
322 *
323 * @param cls closure
324 * @param code type of the event on the phone
325 * @param ... additional information, depends on @a code
326 */
327typedef void (*GNUNET_CONVERSATION_EventHandler)(void *cls,
328 enum GNUNET_CONVERSATION_EventCode code,
329 ...);
330
331
332/**
333 * A phone is a device that can ring to signal an incoming call and
334 * that you can pick up to answer the call and hang up to terminate
335 * the call. You can also hang up a ringing phone immediately
336 * (without picking it up) to stop it from ringing. Phones have
337 * caller ID. You can ask the phone for its record and make that
338 * record available (via GNS) to enable others to call you.
339 * Multiple phones maybe connected to the same line (the line is
340 * something rather internal to a phone and not obvious from it).
341 * You can only have one conversation per phone at any time.
342 */
343struct GNUNET_CONVERSATION_Phone;
344
345
346/**
347 * Create a new phone.
348 *
349 * @param cfg configuration for the phone; specifies the phone service and
350 * which line the phone is to be connected to
351 * @param event_handler how to notify the owner of the phone about events
352 * @param event_handler_cls closure for @a event_handler
353 */
354struct GNUNET_CONVERSATION_Phone *
355GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
356 GNUNET_CONVERSATION_EventHandler event_handler,
357 void *event_handler_cls);
358
359
360/**
361 * Fill in a namestore record with the contact information
362 * for this phone. Note that the filled in "data" value
363 * is only valid until the phone is destroyed.
364 *
365 * @param phone phone to create a record for
366 * @param rd namestore record to fill in
367 */
368void
369GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone,
370 struct GNUNET_NAMESTORE_RecordData *rd);
371
372
373/**
374 * Picks up a (ringing) phone. This will connect the speaker
375 * to the microphone of the other party, and vice versa.
376 *
377 * @param phone phone to pick up
378 * @param metadata meta data to give to the other user about the pick up event
379 * @param speaker speaker to use
380 * @param mic microphone to use
381 */
382void
383GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
384 const char *metadata,
385 struct GNUNET_CONVERSATION_Speaker *speaker,
386 struct GNUNET_CONVERSATION_Microphone *mic);
387
388
389/**
390 * Hang up up a (possibly ringing) phone. This will notify the other
391 * party that we are no longer interested in talking with them.
392 *
393 * @param phone phone to pick up
394 * @param reason text we give to the other party about why we terminated the conversation
395 */
396void
397GNUNET_CONVERSTATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone,
398 const char *reason);
399
400
401/**
402 * Destroys a phone.
403 *
404 * @param phone phone to destroy
405 */
406void
407GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone);
408
409
410/**
411 * Handle for an outgoing call.
412 */
413struct GNUNET_CONVERSATION_Call;
414
415
416/**
417 * Call the phone of another user.
418 *
419 * @param cfg configuration to use, specifies our phone service
420 * @param caller_id identity of the caller
421 * @param callee GNS name of the callee (used to locate the callee's record)
422 * @param speaker speaker to use (will be used automatically immediately once the
423 * #GNUNET_CONVERSATION_EC_READY event is generated); we will NOT generate
424 * a ring tone on the speaker
425 * @param mic microphone to use (will be used automatically immediately once the
426 * #GNUNET_CONVERSATION_EC_READY event is generated)
427 * @param event_handler how to notify the owner of the phone about events
428 * @param event_handler_cls closure for @a event_handler
429 */
430struct GNUNET_CONVERSATION_Call *
431GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
432 struct GNUNET_IDENTITY_Ego *caller_id,
433 const char *callee,
434 struct GNUNET_CONVERSATION_Speaker *speaker,
435 struct GNUNET_CONVERSATION_Microphone *mic,
436 GNUNET_CONVERSATION_EventHandler event_handler,
437 void *event_handler_cls);
438
439
440/**
441 * Terminate a call. The call may be ringing or ready at this time.
442 *
443 * @param call call to terminate
444 * @param reason if the call was active (ringing or ready) this will be the
445 * reason given to the other user for why we hung up
446 */
447struct GNUNET_CONVERSATION_Call *
448GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call,
449 const char *reason);
450
451
209#if 0 /* keep Emacsens' auto-indent happy */ 452#if 0 /* keep Emacsens' auto-indent happy */
210{ 453{
211#endif 454#endif