[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r29797 - in gnunet/src: conversation include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r29797 - in gnunet/src: conversation include |
Date: |
Wed, 2 Oct 2013 21:06:07 +0200 |
Author: grothoff
Date: 2013-10-02 21:06:07 +0200 (Wed, 02 Oct 2013)
New Revision: 29797
Added:
gnunet/src/conversation/conversation_api2.c
gnunet/src/include/gnunet_microphone_lib.h
gnunet/src/include/gnunet_speaker_lib.h
Modified:
gnunet/src/conversation/Makefile.am
gnunet/src/include/Makefile.am
gnunet/src/include/gnunet_conversation_service.h
Log:
-split off microphone/speaker APIs
Modified: gnunet/src/conversation/Makefile.am
===================================================================
--- gnunet/src/conversation/Makefile.am 2013-10-02 18:28:36 UTC (rev 29796)
+++ gnunet/src/conversation/Makefile.am 2013-10-02 19:06:07 UTC (rev 29797)
@@ -21,7 +21,8 @@
libexecdir= $(prefix)/lib/gnunet/libexec/
libgnunetconversation_la_SOURCES = \
- conversation_api.c
+ conversation_api.c \
+ conversation_api2.c
libgnunetconversation_la_LIBADD = \
-lgnunetutil -lgnunetnamestore -lgnunetgns
libgnunetconversation_la_LDFLAGS = \
Added: gnunet/src/conversation/conversation_api2.c
===================================================================
--- gnunet/src/conversation/conversation_api2.c (rev 0)
+++ gnunet/src/conversation/conversation_api2.c 2013-10-02 19:06:07 UTC (rev
29797)
@@ -0,0 +1,251 @@
+/*
+ This file is part of GNUnet
+ (C) 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file conversation/conversation_api2.c
+ * @brief API to the conversation service
+ * @author Simon Dieterle
+ * @author Andreas Fuchs
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_conversation_service.h"
+
+
+/**
+ * A phone record specifies which peer is hosting a given user and
+ * may also specify the phone line that is used (typically zero).
+ * The version is also right now always zero.
+ */
+struct PhoneRecord
+{
+
+ /**
+ * Version of the phone record, for now always zero. We may
+ * use other versions for anonymously hosted phone lines in
+ * the future.
+ */
+ uint32_t version GNUNET_PACKED;
+
+ /**
+ * Phone line to use at the peer.
+ */
+ uint32_t line GNUNET_PACKED;
+
+ /**
+ * Identity of the peer hosting the phone service.
+ */
+ struct GNUNET_PeerIdentity my_peer;
+
+};
+
+
+
+/**
+ * A phone is a device that can ring to signal an incoming call and
+ * that you can pick up to answer the call and hang up to terminate
+ * the call. You can also hang up a ringing phone immediately
+ * (without picking it up) to stop it from ringing. Phones have
+ * caller ID. You can ask the phone for its record and make that
+ * record available (via GNS) to enable others to call you.
+ * Multiple phones maybe connected to the same line (the line is
+ * something rather internal to a phone and not obvious from it).
+ * You can only have one conversation per phone at any time.
+ */
+struct GNUNET_CONVERSATION_Phone
+{
+ /**
+ * Our configuration.
+ */
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ /**
+ * Function to call for phone events.
+ */
+ GNUNET_CONVERSATION_EventHandler event_handler;
+
+ /**
+ * Closure for @e event_handler
+ */
+ void *event_handler_cls;
+
+ /**
+ * Speaker, or NULL if none is attached.
+ */
+ struct GNUNET_CONVERSATION_Speaker *speaker;
+
+ /**
+ * Microphone, or NULL if none is attached.
+ */
+ struct GNUNET_CONVERSATION_Microphone *mic;
+
+ /**
+ * This phone's record.
+ */
+ struct PhoneRecord my_record;
+
+};
+
+
+/**
+ * Create a new phone.
+ *
+ * @param cfg configuration for the phone; specifies the phone service and
+ * which line the phone is to be connected to
+ * @param event_handler how to notify the owner of the phone about events
+ * @param event_handler_cls closure for @a event_handler
+ */
+struct GNUNET_CONVERSATION_Phone *
+GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle
*cfg,
+ GNUNET_CONVERSATION_EventHandler
event_handler,
+ void *event_handler_cls)
+{
+ return NULL;
+}
+
+
+/**
+ * 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.
+ *
+ * @param phone phone to create a record for
+ * @param rd namestore record to fill in
+ */
+void
+GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone,
+ struct GNUNET_NAMESTORE_RecordData *rd)
+{
+ GNUNET_assert (0);
+}
+
+
+/**
+ * Picks up a (ringing) phone. This will connect the speaker
+ * to the microphone of the other party, and vice versa.
+ *
+ * @param phone phone to pick up
+ * @param metadata meta data to give to the other user about the pick up event
+ * @param speaker speaker to use
+ * @param mic microphone to use
+ */
+void
+GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
+ const char *metadata,
+ struct GNUNET_SPEAKER_Handle *speaker,
+ struct GNUNET_MICROPHONE_Handle *mic)
+{
+ GNUNET_assert (0);
+}
+
+
+/**
+ * Hang up up a (possibly ringing) phone. This will notify the other
+ * party that we are no longer interested in talking with them.
+ *
+ * @param phone phone to pick up
+ * @param reason text we give to the other party about why we terminated the
conversation
+ */
+void
+GNUNET_CONVERSTATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone,
+ const char *reason)
+{
+ GNUNET_assert (0);
+}
+
+
+/**
+ * Destroys a phone.
+ *
+ * @param phone phone to destroy
+ */
+void
+GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone)
+{
+ GNUNET_assert (0);
+}
+
+
+/**
+ * Handle for an outgoing call.
+ */
+struct GNUNET_CONVERSATION_Call
+{
+
+ const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ struct GNUNET_IDENTITY_Ego *caller_id;
+
+ char *callee;
+
+ struct GNUNET_CONVERSATION_Speaker *speaker;
+
+ struct GNUNET_CONVERSATION_Microphone *mic;
+
+ GNUNET_CONVERSATION_EventHandler event_handler;
+
+ void *event_handler_cls;
+
+};
+
+
+/**
+ * Call the phone of another user.
+ *
+ * @param cfg configuration to use, specifies our phone service
+ * @param caller_id identity of the caller
+ * @param callee GNS name of the callee (used to locate the callee's record)
+ * @param speaker speaker to use (will be used automatically immediately once
the
+ * #GNUNET_CONVERSATION_EC_READY event is generated); we will NOT
generate
+ * a ring tone on the speaker
+ * @param mic microphone to use (will be used automatically immediately once
the
+ * #GNUNET_CONVERSATION_EC_READY event is generated)
+ * @param event_handler how to notify the owner of the phone about events
+ * @param event_handler_cls closure for @a event_handler
+ */
+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_EventHandler event_handler,
+ void *event_handler_cls)
+{
+ GNUNET_assert (0);
+}
+
+
+/**
+ * Terminate a call. The call may be ringing or ready at this time.
+ *
+ * @param call call to terminate
+ * @param reason if the call was active (ringing or ready) this will be the
+ * reason given to the other user for why we hung up
+ */
+void
+GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call,
+ const char *reason)
+{
+ GNUNET_assert (0);
+}
+
+
+/* end of conversation_api.c */
Modified: gnunet/src/include/Makefile.am
===================================================================
--- gnunet/src/include/Makefile.am 2013-10-02 18:28:36 UTC (rev 29796)
+++ gnunet/src/include/Makefile.am 2013-10-02 19:06:07 UTC (rev 29797)
@@ -54,6 +54,7 @@
gnunet_load_lib.h \
gnunet_lockmanager_service.h \
gnunet_mesh_service.h \
+ gnunet_microphone_lib.h \
gnunet_mq_lib.h \
gnunet_mysql_lib.h \
gnunet_namestore_plugin.h \
@@ -77,6 +78,7 @@
gnunet_service_lib.h \
gnunet_signal_lib.h \
gnunet_signatures.h \
+ gnunet_speaker_lib.h \
gnunet_statistics_service.h \
gnunet_strings_lib.h \
gnunet_testbed_service.h \
Modified: gnunet/src/include/gnunet_conversation_service.h
===================================================================
--- gnunet/src/include/gnunet_conversation_service.h 2013-10-02 18:28:36 UTC
(rev 29796)
+++ gnunet/src/include/gnunet_conversation_service.h 2013-10-02 19:06:07 UTC
(rev 29797)
@@ -36,6 +36,8 @@
#endif
#endif
+#include "gnunet_util_lib.h"
+
/**
* Version of the conversation API.
*/
@@ -233,63 +235,14 @@
talking to.x */
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_namestore_service.h"
+#include "gnunet_speaker_lib.h"
+#include "gnunet_microphone_lib.h"
/**
- * A speaker is a device that can play or record audio data.
- */
-struct GNUNET_CONVERSATION_Speaker;
-
-
-/**
- * Create a speaker that corresponds to the speaker hardware
- * of our system.
- *
- * @param cfg configuration to use
- * @return NULL on error
- */
-struct GNUNET_CONVERSATION_Speaker *
-GNUNET_CONVERSATION_speaker_create_from_hardware (struct
GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Destroy a speaker.
- *
- * @param speaker speaker to destroy
- */
-void
-GNUNET_CONVERSATION_speaker_destroy (struct GNUNET_CONVERSATION_Speaker
*speaker);
-
-
-/**
- * A speaker is a device that can generate audio data.
- */
-struct GNUNET_CONVERSATION_Microphone;
-
-
-/**
- * Create a speaker that corresponds to the speaker hardware
- * of our system.
- *
- * @param cfg configuration to use
- * @return NULL on error
- */
-struct GNUNET_CONVERSATION_Microphone *
-GNUNET_CONVERSATION_microphone_create_from_hardware (struct
GNUNET_CONFIGURATION_Handle *cfg);
-
-
-/**
- * Destroy a microphone.
- *
- * @param mic microphone to destroy
- */
-void
-GNUNET_CONVERSATION_microphone_destroy (struct GNUNET_CONVERSATION_Microphone
*mic);
-
-
-/**
* Information about the current status of a call. Each call
* progresses from ring over ready to terminated. Steps may
* be skipped.
@@ -382,8 +335,8 @@
void
GNUNET_CONVERSTATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone,
const char *metadata,
- struct GNUNET_CONVERSATION_Speaker *speaker,
- struct GNUNET_CONVERSATION_Microphone *mic);
+ struct GNUNET_SPEAKER_Handle *speaker,
+ struct GNUNET_MICROPHONE_Handle *mic);
/**
@@ -431,8 +384,8 @@
GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_IDENTITY_Ego *caller_id,
const char *callee,
- struct GNUNET_CONVERSATION_Speaker *speaker,
- struct GNUNET_CONVERSATION_Microphone *mic,
+ struct GNUNET_SPEAKER_Handle *speaker,
+ struct GNUNET_MICROPHONE_Handle *mic,
GNUNET_CONVERSATION_EventHandler event_handler,
void *event_handler_cls);
@@ -444,7 +397,7 @@
* @param reason if the call was active (ringing or ready) this will be the
* reason given to the other user for why we hung up
*/
-struct GNUNET_CONVERSATION_Call *
+void
GNUNET_CONVERSATION_call_stop (const struct GNUNET_CONVERSATION_Call *call,
const char *reason);
Added: gnunet/src/include/gnunet_microphone_lib.h
===================================================================
--- gnunet/src/include/gnunet_microphone_lib.h (rev 0)
+++ gnunet/src/include/gnunet_microphone_lib.h 2013-10-02 19:06:07 UTC (rev
29797)
@@ -0,0 +1,133 @@
+/*
+ This file is part of GNUnet
+ (C) 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file include/gnunet_microphone_lib.h
+ * @brief API to access an audio microphone; provides access to hardware
microphones
+ * @author Simon Dieterle
+ * @author Andreas Fuchs
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_MICROPHONE_SERVICE_H
+#define GNUNET_MICROPHONE_SERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+/**
+ * Process recorded audio data.
+ *
+ * @param cls clsoure
+ * @param data_size number of bytes in @a data
+ * @param data audio data to play
+ */
+typedef void (*GNUNET_MICROPHONE_RecordedDataCallback)(void *cls,
+ size_t data_size,
+ const void *data);
+
+/**
+ * Enable a microphone.
+ *
+ * @param cls clsoure
+ * @param rdc function to call with recorded data
+ * @param rdc_cls closure for @a dc
+ */
+typedef void (*GNUNET_MICROPHONE_EnableCallback)(void *cls,
+
GNUNET_MICROPHONE_RecordedDataCallback rdc,
+ void *rdc_cls);
+
+/**
+ * Function that disables a microphone.
+ *
+ * @param cls clsoure
+ */
+typedef void (*GNUNET_MICROPHONE_DisableCallback)(void *cls);
+
+/**
+ * Function to destroy a microphone.
+ *
+ * @param cls clsoure
+ */
+typedef void (*GNUNET_MICROPHONE_DestroyCallback)(void *cls);
+
+
+/**
+ * A microphone is a device that can play or record audio data.
+ */
+struct GNUNET_MICROPHONE_Handle
+{
+
+ /**
+ * Turn on the microphone.
+ */
+ GNUNET_MICROPHONE_EnableCallback enable_microphone;
+
+ /**
+ * Turn the microphone off.
+ */
+ GNUNET_MICROPHONE_DisableCallback disable_microphone;
+
+ /**
+ * Destroy the microphone. Called by #GNUNET_MICROPHONE_destroy.
+ */
+ GNUNET_MICROPHONE_DestroyCallback destroy_microphone;
+
+ /**
+ * Closure for the callbacks.
+ */
+ void *cls;
+
+};
+
+
+/**
+ * Create a microphone that corresponds to the microphone hardware
+ * of our system.
+ *
+ * @param cfg configuration to use
+ * @return NULL on error
+ */
+struct GNUNET_MICROPHONE_Handle *
+GNUNET_MICROPHONE_create_from_hardware (const struct
GNUNET_CONFIGURATION_Handle *cfg);
+
+
+/**
+ * Destroy a microphone.
+ *
+ * @param microphone microphone to destroy
+ */
+void
+GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone);
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of gnunet_microphone_lib.h */
Added: gnunet/src/include/gnunet_speaker_lib.h
===================================================================
--- gnunet/src/include/gnunet_speaker_lib.h (rev 0)
+++ gnunet/src/include/gnunet_speaker_lib.h 2013-10-02 19:06:07 UTC (rev
29797)
@@ -0,0 +1,135 @@
+/*
+ This file is part of GNUnet
+ (C) 2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file include/gnunet_speaker_lib.h
+ * @brief API to access an audio speaker; provides access to hardware speakers
+ * @author Simon Dieterle
+ * @author Andreas Fuchs
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_SPEAKER_SERVICE_H
+#define GNUNET_SPEAKER_SERVICE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+/**
+ * Function that enables a speaker.
+ *
+ * @param cls clsoure
+ */
+typedef void (*GNUNET_SPEAKER_EnableCallback)(void *cls);
+
+/**
+ * Function that disables a speaker.
+ *
+ * @param cls clsoure
+ */
+typedef void (*GNUNET_SPEAKER_DisableCallback)(void *cls);
+
+/**
+ * Function to destroy a speaker.
+ *
+ * @param cls clsoure
+ */
+typedef void (*GNUNET_SPEAKER_DestroyCallback)(void *cls);
+
+/**
+ * Function to cause a speaker to play audio data.
+ *
+ * @param cls clsoure
+ * @param data_size number of bytes in @a data
+ * @param data audio data to play, format is
+ * opaque to the API but should be OPUS.
+ */
+typedef void (*GNUNET_SPEAKER_PlayCallback)(void *cls,
+ size_t data_size,
+ const void *data);
+
+
+/**
+ * A speaker is a device that can play or record audio data.
+ */
+struct GNUNET_SPEAKER_Handle
+{
+
+ /**
+ * Turn on the speaker.
+ */
+ GNUNET_SPEAKER_EnableCallback enable_speaker;
+
+ /**
+ * Play audio.
+ */
+ GNUNET_SPEAKER_PlayCallback play;
+
+ /**
+ * Turn the speaker off.
+ */
+ GNUNET_SPEAKER_DisableCallback disable_speaker;
+
+ /**
+ * Destroy the speaker. Called by #GNUNET_SPEAKER_destroy.
+ */
+ GNUNET_SPEAKER_DestroyCallback destroy_speaker;
+
+ /**
+ * Closure for the callbacks.
+ */
+ void *cls;
+
+};
+
+
+/**
+ * Create a speaker that corresponds to the speaker hardware
+ * of our system.
+ *
+ * @param cfg configuration to use
+ * @return NULL on error
+ */
+struct GNUNET_SPEAKER_Handle *
+GNUNET_SPEAKER_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle
*cfg);
+
+
+/**
+ * Destroy a speaker.
+ *
+ * @param speaker speaker to destroy
+ */
+void
+GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker);
+
+
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of gnunet_speaker_lib.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r29797 - in gnunet/src: conversation include,
gnunet <=