libtoxcore-racket
1 Examples
2 Constants and Enums
2.1 Constants
TOX_  PUBLIC_  KEY_  SIZE
TOX_  SECRET_  KEY_  SIZE
TOX_  ADDRESS_  SIZE
TOX_  MAX_  NAME_  LENGTH
TOX_  MAX_  STATUS_  MESSAGE_  LENGTH
TOX_  MAX_  FRIEND_  REQUEST_  LENGTH
TOX_  MAX_  MESSAGE_  LENGTH
TOX_  MAX_  CUSTOM_  PACKET_  SIZE
TOX_  HASH_  LENGTH
TOX_  FILE_  ID_  LENGTH
TOX_  MAX_  FILENAME_  LENGTH
TOXDNS_  MAX_  RECOMMENDED_  NAME_  LENGTH
2.2 Enums
_  TOX-USER-STATUS
_  TOX-MESSAGE-TYPE
_  TOX-PROXY-TYPE
_  TOX-ERR-OPTIONS-NEW
_  TOX-ERR-NEW
_  TOX-ERR-BOOTSTRAP
_  TOX-CONNECTION
_  TOX-ERR-SET-INFO
_  TOX-ERR-FRIEND-SEND-MESSAGE
_  TOX-FILE-KIND
_  TOX-FILE-CONTROL
_  TOX-ERR-FILE-CONTROL
_  TOX-ERR-FILE-SEEK
_  TOX-ERR-FILE-GET
_  TOX-ERR-FILE-SEND
_  TOX-ERR-FILE-SEND-CHUNK
_  TOX-ERR-FRIEND-CUSTOM-PACKET
_  TOX-ERR-KEY-DERIVATION
_  TOX-ERR-ENCRYPTION
_  TOX-ERR-DECRYPTION
_  TOX-GROUPCHAT-TYPE
_  TOX-CHAT-CHANGE-PEER
_  Tox  Av  Callback  ID
_  Tox  Av  Call  Type
_  Tox  Av  Call  State
_  Tox  Av  Error
_  Tox  Av  Capabilities
3 Functions
3.1 Getters and Setters
friendlist-length
friend-exists?
get-self-address
get-client-id
get-friend-connection-status
get-friendlist
get-friend-number
is-typing?
get-last-online
get-name
get-name-size
get-num-online-friends
get-self-name
get-self-name-size
get-self-status-message
get-self-status-message-size
get-user-status
get-self-user-status
get-status-message
get-status-message-size
set-name
set-status-message!
set-user-status!
set-user-is-typing!
get-group-number-peers
get-group-names
get-group-peername
get-group-peer-pubkey
count-chatlist
get-chatlist
get-nospam
set-nospam!
get-keys
group-set-title!
group-get-title
3.2 Interact with Tox
bootstrap-from-address
tox-connected?
send-message
send-action
group-message-send
group-action-send
group-peernumber-is-ours?
Tox-Options
tox-new
tox-kill!
tox-do
tox-do-interval
3.3 Saving and Loading Functions
tox-size
tox-save
tox-load
3.4 Friend and Group Manipulation
add-friend
add-friend-norequest
del-friend!
add-groupchat
del-groupchat!
invite-friend
join-groupchat
3.5 Filesending Functions
new-file-sender
send-file-control
send-file-data
file-data-size
file-data-remaining
3.6 Avatar Handling and Manipulation
set-avatar!
unset-avatar!
get-self-avatar
tox-hash
request-avatar-info
send-avatar-info
request-avatar-data
3.7 Callbacks
3.7.1 General Callbacks
callback-friend-request
callback-friend-message
callback-friend-action
callback-name-change
callback-status-message
callback-user-status
callback-typing-change
callback-read-receipt
callback-connection-status
3.7.2 File Sending Callbacks
callback-file-send-request
callback-file-control
callback-file-data
3.7.3 Groupchat Callbacks
callback-group-invite
callback-group-message
callback-group-action
callback-group-title
callback-group-namelist-change
3.7.4 Avatar Callbacks
callback-avatar-info
callback-avatar-data
4 Audio/  Video
4.1 Structs
_  Tox  Av  CSettings
4.2 Procedures
Tox  AVCallback
Tox  Av  Audio  Callback
Tox  Av  Video  Callback
av-new
av-kill!
toxav-do-interval
toxav-do
callback-callstate
callback-audio-recv
callback-video-recv
av-call
av-hangup
av-answer
av-reject
av-change-settings
av-cancel
av-stop-call
prepare-transmission
kill-transmission
prepare-video-frame
send-video
prepare-audio-frame
send-audio
get-peer-csettings
get-peer-id
get-call-state
capability-supported?
av-get-tox
get-active-calls
add-av-groupchat
join-av-groupchat
group-send-audio
5 Licensing
5.1 Library License
5.2 Documentation License
Index
6.12

libtoxcore-racket

Lehi Toskin

This library provides a Racket-like interface to the libtoxcore, libtoxav, and libtoxdns libraries. Be aware that Tox is currently thread-unsafe, so please take all proper precautions while using the library.

    1 Examples

    2 Constants and Enums

      2.1 Constants

      2.2 Enums

    3 Functions

      3.1 Getters and Setters

      3.2 Interact with Tox

      3.3 Saving and Loading Functions

      3.4 Friend and Group Manipulation

      3.5 Filesending Functions

      3.6 Avatar Handling and Manipulation

      3.7 Callbacks

        3.7.1 General Callbacks

        3.7.2 File Sending Callbacks

        3.7.3 Groupchat Callbacks

        3.7.4 Avatar Callbacks

    4 Audio/Video

      4.1 Structs

      4.2 Procedures

    5 Licensing

      5.1 Library License

      5.2 Documentation License

    Index

1 Examples

; simple 1-to-1 function wrapper
(require libtoxcore-racket)
 
(define-values (my-tox new-err) (tox-new TOX_ENABLE_IPV6_DEFAULT))
(define my-name "Toxizen5k")
(define my-status-message "Testing Tox with the Racket wrapper!")
 
(set-self-name! my-tox my-name)
(set-self-status-message! my-status-message)
 
(tox-kill! my-tox)

2 Constants and Enums

Tox uses several enums and many different constants. It is important to be familiar with the enums, especially.

2.1 Constants

value

TOX_PUBLIC_KEY_SIZE : 32

value

TOX_SECRET_KEY_SIZE : 32

value

TOX_ADDRESS_SIZE

 : 
(+ TOX_PUBLIC_KEY_SIZE
          (ctype-sizeof uint32_t) (ctype-sizeof uint16_t))

value

TOX_MAX_NAME_LENGTH : 128

value

TOX_MAX_STATUS_MESSAGE_LENGTH : 1007

value

TOX_MAX_FRIEND_REQUEST_LENGTH : 1016

Maximum length a message can be before it must be split.

value

TOX_MAX_CUSTOM_PACKET_SIZE : 1373

value

TOX_HASH_LENGTH : 32

value

TOX_FILE_ID_LENGTH : 32

value

TOX_MAX_FILENAME_LENGTH : 255

value

TOXDNS_MAX_RECOMMENDED_NAME_LENGTH : 32

2.2 Enums

Tox uses various enumerations in many of its functions and they are explained below.

value

_TOX-USER-STATUS : '(available away busy)

value

_TOX-MESSAGE-TYPE : '(normal action)

value

_TOX-PROXY-TYPE : '(none http socks5)

value

_TOX-ERR-OPTIONS-NEW : '(ok malloc)

value

_TOX-ERR-NEW : 
'(ok
  null
  malloc
  port-alloc
  proxy-bad-type
  proxy-bad-host
  proxy-bad-port
  proxy-not-found
  load-encrypted
  load-bad-format)
'malloc is returned when the function was unable to allocate enough memory to store the internal structures for the Tox object.

'port-alloc is returned when the function was unable to bind to a port. This may mean that all ports have already been bound, e.g. by other Tox instances, or it may mean a permission error.

'proxy-bad-type is returned when the proxy-type variable was invalid.

'proxy-bad-host is returned when the proxy-type variable was valid, but the proxy-host had an invalid format or was NULL.

'proxy-bad-port is returned when the proxy-type was valid, but the proxy-port was invalid.

'proxy-not-found is returned when the proxy host passed could not be resolved.

'load-encrypted is returned when the bytes loaded into the function contained an encrypted save.

'load-bad-format is returned when the data format was invalid. This can happen when loading data that was saved by an older version of Tox, or when the data has been corrupted. When loading from badly formatted data, some data may have been loaded, and the rest is discarded.

value

_TOX-ERR-BOOTSTRAP : '(ok null bad-host bad-port)

value

_TOX-CONNECTION : '(none tcp udp)

value

_TOX-ERR-SET-INFO : '(ok null too-long)

value

_TOX-ERR-FRIEND-SEND-MESSAGE : 
'(ok
  null
  friend-not-found
  friend-not-connected
  sendq
  too-long
  empty)
'sendq is returned when an allocation error occurred while increasing the send queue size

value

_TOX-FILE-KIND : '(data avatar)

'data is used when sending arbitrary file data. Clients can choose to handle it based on the file name or magic or any other way.

'avatar is used when sending avatar data. Avatars can be sent at any time the client wishes. Generally, a client will send the avatar to a friend when that friend comes online, and to all friends when the avatar changed. A client can save some traffic by remembering which friend received the updated avatar already and only send it if the friend has an out of date avatar. Clients who receive avatar send requests can reject it (by sending TOX_FILE_CONTROL_CANCEL before any other controls), or accept it (by sending TOX_FILE_CONTROL_RESUME). The file_id of length TOX_HASH_LENGTH bytes (same length as TOX_FILE_ID_LENGTH) will contain the hash. A client can compare this hash with a saved hash and send TOX_FILE_CONTROL_CANCEL to terminate the avatar transfer if it matches. When file_size is set to 0 in the transfer request it means that the client has no avatar.

value

_TOX-FILE-CONTROL : '(resume pause cancel)

'resume is used when accepting a file transfer or when resuming a paused transfer.

'pause is sent by clients to pause the file transfer. The initial state of a file transfer is always paused on the receiving side and running on the sending side. If both the sending and receiving side pause the transfer, then both need to send TOX_FILE_CONTROL_RESUME for the transfer to resume.

'cancel is sent by the receiving client to reject a file send request before any other commands are sent. Also sent by either side to terminate a file transfer.

value

_TOX-ERR-FILE-CONTROL : 
'(ok
  friend-not-found
  friend-not-connected
  not-found
  not-paused
  denied
  already-paused
  sendq)
'not-found is returned when ; no file transfer with the given file number was found for the given friend.

'denied is returned when a 'resume control was sent, but the file transfer was paused by the other party. Only the party that paused the transfar can resume it.

'senq is returned when the packet queue is full.

value

_TOX-ERR-FILE-SEEK : 
'(ok
  friend-not-found
  friend-not-connected
  transfer-not-found
  seek-denied
  invalid-position
  sendq)
'transfer-not-found is returned when no transfer with the given file number was found for the given friend.

'seek-denied is returned when the file was not in a state where it could be seeked.

'invalid-position is returned when the seek position was invalid.

'senq is returned when the packet queue is full.

value

_TOX-ERR-FILE-GET : '(ok friend-not-found transfer-not-found)

value

_TOX-ERR-FILE-SEND : 
'(ok
  null
  friend-not-found
  friend-not-connected
  name-too-long
  too-many)

value

_TOX-ERR-FILE-SEND-CHUNK : 
'(ok
  null
  friend-not-found
  friend-not-connected
  not-found
  not-transferring
  invalid-length
  senq
  wrong-position)

value

_TOX-ERR-FRIEND-CUSTOM-PACKET : 
'(ok
  null
  friend-not-found
  friend-not-connected
  invalid
  empty
  too-long
  sendq)

value

_TOX-ERR-KEY-DERIVATION : '(ok null failed)

value

_TOX-ERR-ENCRYPTION : 
'(ok
  null
  key-derivation-failed
  encryption-failed)
'null is returned when some input data, or maybe the output pointer, was null.

'key-derivation-failed is returned when the crypto lib was unable to derive a key from the given passphrase, which is usually a lack of memory issue. The functions accepting keys do not produce this error.

'encryption-failed is returned when the encryption itself failed.

value

_TOX-ERR-DECRYPTION : 
'(ok
  null
  invalid-length
  bad-format
  key-derivation-failed
  decryption-failed)

value

_TOX-GROUPCHAT-TYPE : '(text av)

value

_TOX-CHAT-CHANGE-PEER : '(add del name)

'add is for when a new peer has joined the groupchat.

'del is for when a peer has left the groupchat.

'name is for when a peer has changed her nickname.

procedure

(_ToxAvCallbackID sym)  (or/c false? integer?)

  sym : 
(or/c 'Invite
      'Ringing
      'Start
      'Cancel
      'Reject
      'End
      'RequestTimeout
      'PeerTimeout
      'PeerCSChange
      'SelfCSChange)
'Invite is when there has been a call invitation.

'Ringing is when the peer is ready to accept/reject the call.

'Start is when the call (rtp transmission) has started.

'Cancel is when the side that initiated the call has canceled the invite.

'Reject is when the side that was invited rejected the call.

'End is when the call that was active has ended.

'RequestTimeout is when the request didn’t get a response in time.

'PeerTimeout peer timed out; stop the call.

'PeerCSChange is when the peer changed csettings. Prepare for changed AV.

'SelfCSChange is for csettings change confirmation. Once triggered, the peer is ready to receive changed AV.

procedure

(_ToxAvCallType sym)  (or/c false? integer?)

  sym : (or/c 'Audio 'Video)
Represents the type of A/V call.

procedure

(_ToxAvCallState sym)  (or/c false? integer?)

  sym : 
(or/c 'CallNonExistant
      'CallInviting
      'CallStarting
      'CallActive
      'CallHold
      'CallHangedUp)
Represents the state of the current call.

'CallInviting is for when we’re sending a call invite.

'CallStarting is for when we’re getting a call invite.

procedure

(_ToxAvError sym)  (or/c false? integer?)

  sym : 
(or/c 'None = 0
      'Unknown = -1
      'NoCall = -20
      'InvalidState = -21
      'AlreadyInCallWithPeer = -22
      'ReachedCallLimit = -23
      'InitializingCodecs = -30
      'SettingVideoResolution = -31
      'SettingVideoBitrate = -32
      'SplittingVideoPayload = -33
      'EncodingVideo = -34
      'EncodingAudio = -35
      'SendingPayload = -40
      'CreatingRtpSessions = -41
      'NoRtpSession = -50
      'InvalidCodecState = -51
      'PacketTooLarge = -52)
'NoCall means we are trying to perform a call action while not in a call.

'InvalidState means we are trying to perform a call action while in an invalid state.

'AlreadyInCallWithPeer means we are trying to call peer when already in a call with peer.

'ReachedCallLimit means we cannot handle more calls.

'InitializingCodecs means we failed to create a CSSession.

'SplittingVideoPayload means there was an error splitting the video payload

'EncodingVideo means vpx_codec_encode failed.

'EncodingAudio means opus_encode failed.

'SendingPayload means sending lossy packet failed.

'CreatingRtpSessions means one of the rtp sessions failed to initialize.

'NoRtpSession means we tried to perform an rtp action on an invalid session.

'InvalidCodecState means the codec state was not initialized.

'PacketTooLarge means the buffer exceeds size while encoding.

Those not listed above are self-explanatory.

procedure

(_ToxAvCapabilities sym)  (or/c false? integer?)

  sym : 
(or/c 'AudioEncoding
      'AudioDecoding
      'VideoEncoding
      'VideoDecoding)
'AudioEncoding is equivalent to 1 << 0 or (expt 2 0)

'AudioDecoding is equivalent to 1 << 1 or (expt 2 1)

'VideoEncoding is equivalent to 1 << 2 or (expt 2 2)

'VideoDecoding is equivalent to 1 << 3 or (expt 2 3)

3 Functions

 (require libtoxcore-racket/functions)
  package: libtoxcore-racket

The functions in libtoxcore-racket/functions are the base wrappers for the functions found in libtoxcore.

3.1 Getters and Setters

procedure

(friendlist-length tox)  integer?

  tox : _Tox-pointer
Return the number of friends in the instance.

You should use this to determine how much memory to allocate for copy_friendlist.

procedure

(friend-exists? tox friendnumber)  boolean?

  tox : _Tox-pointer
  friendnumber : integer?
Checks if there exists a friend with given friendnumber.

return #t if friend exists.

return #f if friend doesn’t exist.

procedure

(get-self-address tox address)  void?

  tox : _Tox-pointer
  address : bytes?
format: [public-key (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)]

Return an address to give to others. (Must be transformed into hex format for ordinary usage).

procedure

(get-client-id tox friendnumber)  integer?

  tox : _Tox-pointer
  friendnumber : integer?
Returns the public key associated to that friend id.

return public key if success.

return #f if failure.

procedure

(get-friend-connection-status tox    
  friendnumber)  integer?
  tox : _Tox-pointer
  friendnumber : integer?
Checks friend’s connecting status.

return 1 if friend is connected to us (Online).

return 0 if friend is not connected to us (Offline).

return -1 on failure.

procedure

(get-friendlist tox list-size)  (or/c integer? bytes?)

  tox : _Tox-pointer
  list-size : integer?
Copy a list of valid friend IDs into the array out-list.

Returns the friend list (in bytes).

If the list-size was too small, the contents of the return value will be truncated to list-size.

procedure

(get-friend-number tox public-key)  (or/c integer? boolean?)

  tox : _Tox-pointer
  public-key : bytes?
return the friend number associated to that public key.

return #f if no such friend

procedure

(is-typing? tox friendnumber)  boolean?

  tox : _Tox-pointer
  friendnumber : integer?
Get the typing status of a friend.

returns #t if friend is typing.

returns #f if friend is not typing.

procedure

(get-last-online tox friendnumber)  (or/c integer? boolean?)

  tox : _Tox-pointer
  friendnumber : integer?
returns timestamp of last time friendnumber was seen online, or 0 if never seen.

returns #f on error.

procedure

(get-name tox friendnumber)  (or/c boolean? bytes?)

  tox : _Tox-pointer
  friendnumber : integer?
return name (in bytes) if success.

return #f if failure.

procedure

(get-name-size tox friendnumber)  (or/c integer? boolean?)

  tox : _Tox-pointer
  friendnumber : integer?
returns the length of name on success.

returns #f on failure.

procedure

(get-num-online-friends tox)  integer?

  tox : _Tox-pointer
Return the number of online friends in the instance m.

procedure

(get-self-name tox)  (or/c integer? bytes?)

  tox : _Tox-pointer
return name (in bytes) on success

return 0 on error.

procedure

(get-self-name-size tox)  (or/c boolean? bytes?)

  tox : _Tox-pointer
The self variant returns the length of our name on success

return #f on failure.

procedure

(get-self-status-message tox)  (or/c boolean? bytes?)

  tox : _Tox-pointer
Like get-status-message, the self variant returns our status message.

procedure

(get-self-status-message-size tox)  (or/c integer? boolean?)

  tox : _Tox-pointer
Like get-status-message-size, the self variant returns the length of our status message on success

return #f on failure.

procedure

(get-user-status tox friendnumber)  integer?

  tox : _Tox-pointer
  friendnumber : integer?
return one of TOX_USERSTATUS values.

Values unknown to your application should be represented as TOX_USERSTATUS_NONE.

If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID.

procedure

(get-self-user-status tox)  integer?

  tox : _Tox-pointer
Like get-user-status, the self variant will return our own TOX_USERSTATUS.

procedure

(get-status-message tox friendnumber)  (or/c boolean? bytes?)

  tox : _Tox-pointer
  friendnumber : integer?
Return friendnumber’s status message.

The self variant will return our own status message.

returns the status message (in bytes) of the friend on success.

return #f on failure.

procedure

(get-status-message-size tox friendnumber)  integer?

  tox : _Tox-pointer
  friendnumber : integer?
returns the length of status message on success.

returns #f on failure.

procedure

(set-name tox name)  boolean?

  tox : _Tox-pointer
  name : string?
Set our nickname.

name must be a string of maximum TOX_MAX_NAME_LENGTH length.

length must be at least 1 byte.

length is the length of name with the NULL terminator.

return #t if success.

return #f if failure.

procedure

(set-status-message! tox status [len])  boolean?

  tox : _Tox-pointer
  status : string?
  len : integer? = 
(bytes-length
 (string->bytes/utf-8 status))
Set our status message.

max length of the status is TOX_MAX_STATUSMESSAGE_LENGTH.

returns #t on success.

returns #f on failure.

procedure

(set-user-status! tox userstatus)  boolean?

  tox : _Tox-pointer
  userstatus : integer?
Set our user status.

userstatus must be one of TOX_USERSTATUS values.

returns #t on success.

returns #f on failure.

procedure

(set-user-is-typing! tox    
  friendnumber    
  istyping?)  boolean?
  tox : _Tox-pointer
  friendnumber : integer?
  istyping? : boolean?
Set our typing status for a friend.

You are responsible for turning it on or off.

returns #t on success.

returns #f on failure.

procedure

(get-group-number-peers tox groupnumber)

  (or/c integer? boolean?)
  tox : _Tox-pointer
  groupnumber : integer?
Return the number of peers in the group chat on success.

return #f on failure

procedure

(get-group-names tox groupnumber len)  (or/c boolean? list?)

  tox : _Tox-pointer
  groupnumber : integer?
  len : integer?
List all the peers in the group chat.

Returns a list whose car is the lengths if the names in its cdr on success.

return #f on failure.

procedure

(get-group-peername tox    
  groupnumber    
  peernumber)  (or/c boolean? bytes?)
  tox : _Tox-pointer
  groupnumber : integer?
  peernumber : integer?
Return the name of peernumber who is in groupnumber.

return #f on failure

procedure

(get-group-peer-pubkey tox    
  groupnumber    
  peernumber)  (or/c integer? bytes?)
  tox : _Tox-pointer
  groupnumber : integer?
  peernumber : integer?
Return the public key (in bytes) of peernumber who is in groupnumber.

procedure

(count-chatlist tox)  integer?

  tox : _Tox-pointer
Return the number of group chats in the instance tox.

You should use this to determine how much memory to allocate for copy_chatlist.

procedure

(get-chatlist tox list-size)  (or/c integer? list?)

  tox : _Tox-pointer
  list-size : integer?
Returns a list of valid chat ID’s.

If list-size was too small, the contents of the return value will be truncated to list-size.

return 0 on failure.

procedure

(get-nospam tox)  integer?

  tox : _Tox-pointer
Procedure to get the nospam part of the ID.

procedure

(set-nospam! tox nospam)  void?

  tox : _Tox-pointer
  nospam : integer?
Procedure to set the nospam part of the ID.

procedure

(get-keys tox secret-key public-key)  void?

  tox : _Tox-pointer
  secret-key : bytes?
  public-key : bytes?
Copy the public and secret key from the Tox object.

public-key and secret-key must be 32 bytes long.

if the pointer is NULL, no data will be copied to it.

procedure

(group-set-title! tox groupnumber title)  boolean?

  tox : _Tox-pointer
  groupnumber : integer?
  title : bytes?
Set the group’s title, limited to TOX_MAX_NAME_LENGTH.

return #t on success

return #f on failure.

procedure

(group-get-title tox groupnumber)  (or/c boolean? bytes?)

  tox : _Tox-pointer
  groupnumber : integer?
Get group’s title from groupnumber.

Return title (in bytes) on success.

return #f on failure.

3.2 Interact with Tox

procedure

(bootstrap-from-address tox    
  address    
  port    
  public-key)  boolean?
  tox : _Tox-pointer
  address : string?
  port : integer?
  public-key : string?
Resolves address into an IP address. If successful, sends a "get nodes" request to the given node with ip, port (in host byte order) and public_key to setup connections

address can be a hostname or an IP address (IPv4 or IPv6)

returns #t if the address was converted into an IP address

returns #f otherwise

procedure

(tox-connected? tox)  boolean?

  tox : _Tox-pointer
return #f if we are not connected to the DHT.

return #t if we are.

procedure

(send-message tox friendnumber message)  integer?

  tox : _Tox-pointer
  friendnumber : integer?
  message : bytes?
Send a text chat message to an online friend.

return the message id if packet was successfully put into the send queue.

return 0 if it was not.

maximum length of messages is TOX_MAX_MESSAGE_LENGTH, your client must split larger messages or else sending them will not work.

You will want to retain the return value, it will be passed to your read_receipt callback if one is received.

procedure

(send-action tox friendnumber action)  integer?

  tox : _Tox-pointer
  friendnumber : integer?
  action : bytes?
Send an action to an online friend.

return the message id if packet was successfully put into the send queue.

return 0 if it was not.

You will want to retain the return value, it will be passed to your read_receipt callback if one is received.

procedure

(group-message-send tox groupnumber message)  boolean?

  tox : _Tox-pointer
  groupnumber : integer?
  message : bytes?
Send a group message.

return #t on success.

return #f on failure.

procedure

(group-action-send tox groupnumber action)  boolean?

  tox : _Tox-pointer
  groupnumber : integer?
  action : bytes?
Send a group action.

return #t on success.

return #f on failure.

procedure

(group-peernumber-is-ours? tox    
  groupnumber    
  peernumber)  boolean?
  tox : _Tox-pointer
  groupnumber : integer?
  peernumber : integer?
Check if the current peernumber corresponds to ours.

returns #t if it does

returns #f if it does not.

struct

(struct Tox-Options (ipv6-enabled?
    udp-disabled?
    proxy-type
    proxy-address
    proxy-port)
    #:extra-constructor-name make-Tox-Options)
  ipv6-enabled? : boolean?
  udp-disabled? : boolean?
  proxy-type : integer?
  proxy-address : string?
  proxy-port : integer?
The type of UDP socket created depends on ipv6-enabled?: If set to #f, creates an IPv4 socket which subsequently only allows IPv4 communication. If set to #t (default), creates an IPv6 socket which allows both IPv4 AND IPv6 communication.

Set udp-disabled? to #t to disable udp support. (default: #f) This will force Tox to use TCP only which may slow things down. Disabling udp support is necessary when using anonymous proxies or Tor.

proxy-type is a value from TOX_PROXY_TYPE enumerator.

proxy-address is the IP or domain of the proxy.

proxy-port is the port of the proxy in host byte order.

procedure

(tox-new opts)  _Tox-pointer

  opts : _Tox-Options-pointer
Run this function at startup.

Options are some options that can be passed to the Tox instance (see above struct).

If options is null, tox-new will use default settings.

Initializes a tox structure

return allocated instance of tox on success.

return 0 if there are problems.

procedure

(tox-kill! tox)  void?

  tox : _Tox-pointer
Run this before closing shop.

Free all datastructures.

procedure

(tox-do tox)  void?

  tox : _Tox-pointer
The main loop that needs to be run in intervals of tox-do-interval ms.

procedure

(tox-do-interval tox)  integer?

  tox : _Tox-pointer
Return the time in milliseconds before tox-do should be called again for optimal performance.

3.3 Saving and Loading Functions

procedure

(tox-size tox)  integer?

  tox : _Tox-pointer
return size of messenger data (for saving).

procedure

(tox-save tox)  bytes?

  tox : _Tox-pointer
Return a byte string containing the saved Tox data.

procedure

(tox-load tox data)  boolean?

  tox : _Tox-pointer
  data : bytes?
Load the messenger from data of size length.

returns #t on success

returns #f on failure

3.4 Friend and Group Manipulation

procedure

(add-friend tox    
  address    
  message    
  [message-length])  integer?
  tox : _Tox-pointer
  address : bytes?
  message : string?
  message-length : integer? = (bytes-length message)
Add a friend.

Set the message that will be sent along with friend request. Must not be longer than TOX_MAX_FRIENDREQUEST_LENGTH length in bytes.

address is the address of the friend (returned by getaddress of the friend you wish to add) it must be TOX_ADDRESS_SIZE bytes.

message is the friend request message and message-length is the length of the message being sent.

return the friend number if success.

return TOX_FA_TOOLONG if message length is too long.

return TOX_FAERR_NOMESSAGE if no message (message length must be >= 1 byte).

return TOX_FAERR_OWNKEY if our own key.

return TOX_FAERR_ALREADYSENT if friend request already sent or already a friend.

return TOX_FAERR_UNKNOWN for unknown error.

return TOX_FAERR_BADCHECKSUM if bad checksum in address.

return TOX_FAERR_SETNEWNOSPAM if the friend was already there but the nospam was different. (the nospam for that friend was set to a different one).

return TOX_FAERR_NOMEM if increasing the friend list size fails.

procedure

(add-friend-norequest tox public-key)  (or/c integer? boolean?)

  tox : _Tox-pointer
  public-key : bytes?
Add a friend without sending a friendrequest.

return the friend number on success.

return #f on failure.

public-key is the bytes form of the Tox ID; e.g. (hex-string->bytes str).

procedure

(del-friend! tox friendnumber)  integer?

  tox : _Tox-pointer
  friendnumber : integer?
Remove a friend.

return #t if success.

return #f if failure.

procedure

(add-groupchat tox)  (or/c integer? boolean?)

  tox : _Tox-pointer
Creates a new groupchat and puts it in the chats array.

return group number on success.

return #f on failure.

procedure

(del-groupchat! tox groupnumber)  boolean?

  tox : _Tox-pointer
  groupnumber : integer?
Delete a groupchat.

return #t on success.

return #f on failure.

procedure

(invite-friend tox friendnumber groupnumber)  boolean?

  tox : _Tox-pointer
  friendnumber : integer?
  groupnumber : integer?
Invite friendnumber to groupnumber.

return #t on success.

return #f on failure.

procedure

(join-groupchat tox friendnumber data len)

  (or/c integer? boolean?)
  tox : _Tox-pointer
  friendnumber : integer?
  data : bytes?
  len : integer?
Join a group (you need to have been invited first.)

return groupnumber on success.

return #f on failure.

3.5 Filesending Functions

procedure

(new-file-sender tox    
  friendnumber    
  filesize    
  filename    
  [filename-length])  (or/c integer? boolean)
  tox : _Tox-pointer
  friendnumber : integer?
  filesize : integer?
  filename : string?
  filename-length : integer? = 
(bytes-length
 (string->bytes/utf-8 filename))
Send a file send request.

Maximum filename length is 255 bytes.

return file number on success

return #f on failure

procedure

(send-file-control tox    
  friendnumber    
  receiving?    
  filenumber    
  message-id    
  data    
  len)  boolean?
  tox : _Tox-pointer
  friendnumber : integer?
  receiving? : boolean?
  filenumber : integer?
  message-id : integer?
  data : bytes?
  len : integer?
Send a file control request.

return #t on success

return #f on failure

procedure

(send-file-data tox    
  friendnumber    
  filenumber    
  data    
  len)  boolean?
  tox : _Tox-pointer
  friendnumber : integer?
  filenumber : integer?
  data : bytes?
  len : integer?
Send file data.

return #t on success

return #f on failure

If this function returns #f, you must tox-do, sleep tox-do-interval miliseconds, then attempt to send the data again.

procedure

(file-data-size tox friendnumber)  (or/c integer? boolean?)

  tox : _Tox-pointer
  friendnumber : integer?
Returns the recommended/maximum size of the filedata you send with send-file-data

return size on success

return #f on failure (currently will never return #f)

procedure

(file-data-remaining tox    
  friendnumber    
  filenumber    
  receiving?)  (or/c integer? boolean?)
  tox : _Tox-pointer
  friendnumber : integer?
  filenumber : integer?
  receiving? : boolean?
Give the number of bytes left to be sent/received.

return number of bytes remaining to be sent/received on success

return #f on failure

3.6 Avatar Handling and Manipulation

procedure

(set-avatar! tox format data [len])  boolean?

  tox : _Tox-pointer
  format : integer?
  data : bytes?
  len : integer? = (bytes-length data)
Set the user avatar image data.

This should be made before connecting, so we will not announce that the user have no avatar before setting and announcing a new one, forcing the peers to re-download it.

Notice that the library treats the image as raw data and does not interpret it by any way.

Arguments:

format - Avatar image format or NONE for user with no avatar (see TOX_AVATAR_FORMAT);

data - bytes containing the avatar data (may be NULL it the format is NONE);

len - length of image data. Must be <= TOX_AVATAR_MAX_DATA_LENGTH.

returns #t on success

returns #f on failure.

procedure

(unset-avatar! tox)  integer?

  tox : _Tox-pointer
Unsets the user avatar.

returns 0 on success (currently always returns 0).

procedure

(get-self-avatar tox format len)  (or/c boolean? list?)

  tox : _Tox-pointer
  format : integer?
  len : integer?
Get avatar data from the current user.

returns a list containing the image hash and the image data.

returns #f on failure.

procedure

(tox-hash data)  (or/c boolean? bytes?)

  data : bytes?
Generates a cryptographic hash of the given data.

This function may be used by clients for any purpose, but is provided primarily for validating cached avatars.

This function is a wrapper to internal message-digest functions.

returns hash (in bytes) on success

returns #f on failure.

procedure

(request-avatar-info tox friendnumber)  boolean?

  tox : _Tox-pointer
  friendnumber : integer?
Request avatar information from a friend.

Asks a friend to provide their avatar information (image format and hash). The friend may or may not answer this request and, if answered, the information will be provided through the callback ’avatar_info’.

returns #t on success

returns #f on failure.

procedure

(send-avatar-info tox friendnumber)  boolean?

  tox : _Tox-pointer
  friendnumber : integer?
Send an unrequested avatar information to a friend.

Sends our avatar format and hash to a friend; he/she can use this information to validate an avatar from the cache and may (or not) reply with an avatar data request.

Notice: it is NOT necessary to send this notification after changing the avatar or connecting. The library already does this.

returns #t on success

returns #f on failure.

procedure

(request-avatar-data tox friendnumber)  boolean?

  tox : _Tox-pointer
  friendnumber : integer?
Request the avatar data from a friend.

Ask a friend to send their avatar data. The friend may or may not answer this request and, if answered, the information will be provided in callback ’avatar_data’.

returns #t on sucess

returns #f on failure.

3.7 Callbacks

3.7.1 General Callbacks

procedure

(callback-friend-request tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the function that will be executed when a friend request is received.

anonproc is in the form (anonproc tox public-key data len userdata)

procedure

(callback-friend-message tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the function that will be executed when a message from a friend is received.

anonproc is in the form (anonproc tox friendnumber message len userdata).

procedure

(callback-friend-action tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the function that will be executed when an action from a friend is received.

anonproc is in the form (anonproc tox friendnumber action len userdata)

procedure

(callback-name-change tox anonproc [userdata])  void?

  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for name changes.

anonproc is in the form (anonproc tox friendnumber newname len userdata)

procedure

(callback-status-message tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for status message changes.

anonproc is in the form (anonproc tox friendstatus newstatus len userdata)

procedure

(callback-user-status tox anonproc [userdata])  void?

  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for status type changes.

anonproc is in the form (anonproc tox friendnumber TOX_USERSTATUS userdata)

procedure

(callback-typing-change tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : prodecure?
  userdata : cpointer? = #f
Set the callback for typing changes.

anonproc is in the form (anonproc tox friendnumber typing? userdata) where typing? is a boolean value.

procedure

(callback-read-receipt tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for read receipts.

anonproc is in the form (anonproc tox friendnumber status userdata).

If you are keeping a record of returns from m_sendmessage; receipt might be one of those values, meaning the message has been received on the other side.

Since core doesn’t track ids for you, receipt may not correspond to any message. In that case, you should discard it.

procedure

(callback-connection-status tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
This function is kind of tricky because the C library requires a function as a parameter (anonproc). This wrapper procedure is kind of tricky and shouldn’t be considered complete.

anonproc is in the form (anonproc tox friendnumber status userdata) where status is a string.

Status:

0 – friend went offline after being previously online

1 – friend went online

NOTE: This callback is not called when adding friends, thus the "after being previously online" part. it’s assumed that when adding friends, their connection status is offline.

3.7.2 File Sending Callbacks

procedure

(callback-file-send-request tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for file send requests.

anonproc is in the form (anonproc tox friendnumber filenumber filesize filename filename-length userdata) where filename is a string.

procedure

(callback-file-control tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for file control requests.

anonproc is in the form (anonproc tox friendnumber sending? filenumber control-type data len userdata) where control-type is a TOX_FILECONTROL enum value.

procedure

(callback-file-data tox anonproc [userdata?])  void?

  tox : _Tox-pointer
  anonproc : procedure?
  userdata? : cpointer? = #f
Set the callback for file data.

anonproc is in the form (anonproc tox friendnumber filenumber data len userdata)

data is a byte string of length len.

3.7.3 Groupchat Callbacks

WARNING: Groupchats will be rewritten so these might change

procedure

(callback-group-invite tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for group invites.

anonproc is in the form (anonproc tox friendnumber type data len userdata)

procedure

(callback-group-message tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for group messages.

anonproc is in the form (anonproc tox groupnumber peernumber message len userdata)

procedure

(callback-group-action tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback for group actions.

anonproc is in the form (anonproc tox groupnumber peernumber action len userdata)

procedure

(callback-group-title tox anonproc [userdata])  void?

  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set callback function for groupchat title changes.

anonproc is in the form (anonproc tox groupnumber peernumber title len userdata) where title is a byte string.

procedure

(callback-group-namelist-change tox    
  anonproc    
  [userdata])  void?
  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set callback function for peer name list changes.

It gets called every time the name list changes (new peer/name, deleted peer)

anonproc is in the form (anonproc tox groupnumber peernumber change userdata)

change is a TOX_CHAT_CHANGE enum value.

3.7.4 Avatar Callbacks

Avatars must be in PNG format.

procedure

(callback-avatar-info tox anonproc [userdata])  void?

  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback function for avatar information.

This callback will be called when avatar information are received from friends. These events can arrive at anytime, but are usually received upon connection and in reply of avatar information requests.

anonproc is in the form (anonproc tox friendnumber format hash userdata) where ’format’ is the avatar image format (see TOX_AVATAR_FORMAT) and ’hash’ is the hash of the avatar data (in a byte-string) for caching purposes and it is exactly TOX_HASH_LENGTH long. If the image format is NONE, the hash is zeroed.

procedure

(callback-avatar-data tox anonproc [userdata])  void?

  tox : _Tox-pointer
  anonproc : procedure?
  userdata : cpointer? = #f
Set the callback function for avatar data.

This callback will be called when the complete avatar data was correctly received from a friend. This only happens in reply of an avatar data request (see request-avatar-data);

anonproc is in the form (anonproc tox friendnumber img-format img-hash data-ptr datalen userdata) where img-format is the avatar image format (see TOX_AVATAR_FORMAT); img-hash is the locally-calculated cryptographic hash of the avatar data (in a byte-string) and it is exactly TOX_HASH_LENGTH long; data-ptr is the avatar image data (as a pointer) and datalen is the length of such data.

If format is 'NONE, data-ptr is #f, datalen is zero, and the hash is zeroed. The hash is always validated locally with the function tox-hash and ensured to match the image data, so this value can be safely used to compare with cached avatars.

WARNING: users MUST treat all avatar image data received from another peer as untrusted and potentially malicious. The library only ensures that the data which arrived is the same the other user sent, and does not interpret or validate any image data.

4 Audio/Video

 (require libtoxcore-racket/av)
  package: libtoxcore-racket

The functions in libtoxcore-racket/av pertain to Audio/Video interaction.

4.1 Structs

struct

(struct _ToxAvCSettings (call_type
    video_bitrate
    video_width
    video_height
    audio_bitrate
    audio_frame_duration
    audio_sample_rate
    audio_channels)
    #:extra-constructor-name make-_ToxAvCSettings)
  call_type : integer?
  video_bitrate : integer?
  video_width : integer?
  video_height : integer?
  audio_bitrate : integer?
  audio_frame_duration : integer?
  audio_sample_rate : integer?
  audio_channels : integer?
call_type is a _ToxAvCallType enum value.

video_bitrate is in kbit/s

video_width is in px

video_height is in px

audio_bitrate is in bits/s

audio_frame_duration is in ms

audio_sample_rate is in Hz

4.2 Procedures

procedure

(ToxAVCallback agent call-index arg)  void?

  agent : cpointer?
  call-index : integer?
  arg : cpointer?
Commonly reused callback form.

procedure

(ToxAvAudioCallback agent    
  call-index    
  pcm    
  size    
  data)  void?
  agent : cpointer?
  call-index : integer?
  pcm : bytes?
  size : integer?
  data : cpointer?
Commonly reused audio callback form.

procedure

(ToxAvVideoCallback agent    
  call-index    
  img    
  data)  void?
  agent : cpointer?
  call-index : integer?
  img : bytes?
  data : cpointer?
Commonly reused video callback form.

procedure

(av-new messenger max_calls)  _ToxAv-pointer

  messenger : _Tox-pointer
  max_calls : integer?
Start new A/V session. There can only be one session at the time. If you register more it will result in undefined behaviour.

return _ToxAv-pointer

return NULL On error.

procedure

(av-kill! av)  void?

  av : _ToxAv-pointer
Remove A/V session.

return void

procedure

(toxav-do-interval av)  integer?

  av : _ToxAv-pointer
Returns the amount of time you should sleep before running tox-do again. If there is no call at the moment, it returns 200.

procedure

(toxav-do av)  void?

  av : _ToxAv-pointer
Main loop for the session. Best called right after tox-do.

procedure

(callback-callstate av callback id [userdata])  void?

  av : _ToxAv-pointer
  callback : procedure?
  id : integer?
  userdata : cpointer? = #f
Register callback for call state.

callback is the ToxAvCallback procedure.

id is one of the ToxAvCallbackID values

return void

procedure

(callback-audio-recv av callback [userdata])  void?

  av : _ToxAv-pointer
  callback : procedure?
  userdata : cpointer? = #f
Register callback for receiving audio data.

callback is in the ToxAvAudioCallback procedure.

return void

procedure

(callback-video-recv av callback)  void?

  av : Tox-Av-pointer
  callback : procedure?
Register callback for receiving video data.

callback is in the ToxAvAudioCallback procedure.

return void

procedure

(av-call av    
  call-index    
  friend-id    
  csettings    
  ringing-seconds)  integer?
  av : _ToxAv-pointer
  call-index : bytes?
  friend-id : integer?
  csettings : cpointer?
  ringing-seconds : integer?
Call user. Use its friend-id.

procedure

(av-hangup av call-index)  (or/c boolean? integer?)

  av : _ToxAv-pointer
  call-index : integer?
Hangup active call.

return #t on success.

return _ToxAvError on error.

procedure

(av-answer av call-index csettings)  (or/c boolean? integer?)

  av : _ToxAv-pointer
  call-index : integer?
  csettings : cpointer?
Answer incoming call.

return #t on success.

return _ToxAvError On error.

procedure

(av-reject av call-index reason)  (or/c boolean? integer?)

  av : _ToxAv-pointer
  call-index : integer?
  reason : string?
Reject incoming call.

Optional reason. Set NULL if none.

return #t on success.

return _ToxAvError on error.

procedure

(av-change-settings av call-index csettings)  integer?

  av : _ToxAv-pointer
  call-index : integer?
  csettings : cpointer?
Notify peer that we are changing call settings.

return 0 on success

return _ToxAvError

procedure

(av-cancel av call-index peer-id reason)  integer?

  av : _ToxAv-pointer
  call-index : integer?
  peer-id : integer?
  reason : string?
Cancel outgoing request.

Optional reason.

return 0 on success.

return _ToxAvError on error.

procedure

(av-stop-call av call-index)  integer?

  av : _ToxAv-pointer
  call-index : integer?
Terminate transmission. Note that transmission will be terminated without informing remote peer.

return 0 on success.

return _ToxAvError on error.

procedure

(prepare-transmission av    
  call-index    
  support-video?)  integer?
  av : _ToxAv-pointer
  call-index : integer?
  support-video? : boolean?
Allocates transmission data. Must be called before calling toxav_prepare_* and toxav_send_*.

Also, it must be called when call is started

procedure

(kill-transmission av call-index)  integer?

  av : _ToxAv-pointer
  call-index : integer?
Call this at the end of the transmission.

return 0 on success.

return _ToxAvError on error.

procedure

(prepare-video-frame av    
  call-index    
  dest    
  dest-max    
  input)  integer?
  av : _ToxAv-pointer
  call-index : integer?
  dest : cpointer?
  dest-max : integer?
  input : bytes?
Encode video frame.

procedure

(send-video av call-index frame frame-size)  integer?

  av : _ToxAv-pointer
  call-index : integer?
  frame : cpointer?
  frame-size : integer?
Encode and send video packet.

return 0 on success.

return _ToxAvError on error.

procedure

(prepare-audio-frame av    
  call-index    
  dest    
  dest-max    
  frame    
  frame-size)  integer?
  av : _ToxAv-pointer
  call-index : integer?
  dest : cpointer?
  dest-max : integer?
  frame : cpointer?
  frame-size : integer?
Encode audio frame.

return >0 on success.

return _ToxAvError on error.

procedure

(send-audio av call-index frame frame-size)  integer?

  av : _ToxAv-pointer
  call-index : inteder?
  frame : bytes?
  frame-size : integer?
Send audio frame.

frame is the frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.)

frame-size is its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes). frame-size should be AUDIO_FRAME_SIZE.

return 0 on success.

return _ToxAvError on error.

procedure

(get-peer-csettings av call-index peer)  list?

  av : _ToxAv-pointer
  call-index : integer?
  peer : integer?
Get peer transmission type. It can either be audio or video.

return a list containing _ToxAvCallType and a csettings cpointer on success.

return a list containing _ToxAvError on error.

procedure

(get-peer-id av call-index peer)  integer?

  av : _ToxAv-pointer
  call-index : integer?
  peer : integer?
Get id of peer participating in conversation

return _ToxAvError when there is no peer id

procedure

(get-call-state av call-index)  integer?

  av : _ToxAv-pointer
  call-index : integer?
Get current call state.

returns integer from _ToxAvCallState.

procedure

(capability-supported? av    
  call-index    
  capability)  boolean?
  av : _ToxAv-pointer
  call-index : integer?
  capability : integer?
Is a certain capability supported?

capability is on of ToxAvCapabilities.

procedure

(av-get-tox av)  _Tox-pointer

  av : _ToxAv-pointer
Return the _Tox-pointer being used with the _ToxAv-pointer.

procedure

(get-active-calls av)  integer?

  av : _ToxAv-pointer
Returns number of active calls or -1 on error.

procedure

(add-av-groupchat tox    
  audio-callback    
  [userdata])  integer?
  tox : _Tox-pointer
  audio-callback : procedure?
  userdata : cpointer? = #f
Create a new ToxAV group.

audio-callback is in the form (audio-callback tox groupnumber peernumber pcm samples channels sample-rate userdata) where pcm is a byte string of the size (* samples channels (ctype-sizeof int16_t)).

return groupnumber on success.

return -1 on failure.

procedure

(join-av-groupchat tox    
  friendnumber    
  data    
  data-len    
  audio-callback    
  [userdata])  integer?
  tox : _Tox-pointer
  friendnumber : integer?
  data : cpointer?
  data-len : integer?
  audio-callback : procedure?
  userdata : cpointer? = #f
Join AV group (you need to have been invited first).

audio-callback is in the form (audio-callback tox groupnumber peernumber pcm samples channels sample-rate userdata) where pcm is of size (* samples channels).

return groupnumber on success.

return -1 on failure.

procedure

(group-send-audio tox    
  groupnumber    
  pcm    
  samples    
  channels    
  sample-rate)  integer?
  tox : _Tox-pointer
  groupnumber : integer?
  pcm : bytes?
  samples : integer?
  channels : integer?
  sample-rate : integer?
Send audio to the groupchat.

Note that pcm is a byte string of the size (* samples channels (ctype-sizeof int16_t)).

Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000)

Valid number of channels are 1 or 2.

Valid sample rates are 8000, 12000, 16000, 24000, or 48000.

Recommended values are: samples = 960, channels = 1, sample_rate = 48000

return 0 on success

return -1 on failure.

5 Licensing

5.1 Library License

Copyright (C) 2014 Lehi Toskin.

This program 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 of the License, or (at your option) any later version.

This program 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 and GNU Lesser General Public License for more details.

5.2 Documentation License

Copyright (C) 2014 Lehi Toskin.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

Index

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

_TOX-CHAT-CHANGE-PEER
_TOX-CONNECTION
_TOX-ERR-BOOTSTRAP
_TOX-ERR-DECRYPTION
_TOX-ERR-ENCRYPTION
_TOX-ERR-FILE-CONTROL
_TOX-ERR-FILE-GET
_TOX-ERR-FILE-SEEK
_TOX-ERR-FILE-SEND
_TOX-ERR-FILE-SEND-CHUNK
_TOX-ERR-FRIEND-CUSTOM-PACKET
_TOX-ERR-FRIEND-SEND-MESSAGE
_TOX-ERR-KEY-DERIVATION
_TOX-ERR-NEW
_TOX-ERR-OPTIONS-NEW
_TOX-ERR-SET-INFO
_TOX-FILE-CONTROL
_TOX-FILE-KIND
_TOX-GROUPCHAT-TYPE
_TOX-MESSAGE-TYPE
_TOX-PROXY-TYPE
_TOX-USER-STATUS
_ToxAvCallbackID
_ToxAvCallState
_ToxAvCallType
_ToxAvCapabilities
_ToxAvCSettings
_ToxAvCSettings-audio_bitrate
_ToxAvCSettings-audio_channels
_ToxAvCSettings-audio_frame_duration
_ToxAvCSettings-audio_sample_rate
_ToxAvCSettings-call_type
_ToxAvCSettings-video_bitrate
_ToxAvCSettings-video_height
_ToxAvCSettings-video_width
_ToxAvCSettings?
_ToxAvError
add-av-groupchat
add-friend
add-friend-norequest
add-groupchat
Audio/Video
av-answer
av-call
av-cancel
av-change-settings
av-get-tox
av-hangup
av-kill!
av-new
av-reject
av-stop-call
Avatar Callbacks
Avatar Handling and Manipulation
bootstrap-from-address
callback-audio-recv
callback-avatar-data
callback-avatar-info
callback-callstate
callback-connection-status
callback-file-control
callback-file-data
callback-file-send-request
callback-friend-action
callback-friend-message
callback-friend-request
callback-group-action
callback-group-invite
callback-group-message
callback-group-namelist-change
callback-group-title
callback-name-change
callback-read-receipt
callback-status-message
callback-typing-change
callback-user-status
callback-video-recv
Callbacks
capability-supported?
Constants
Constants and Enums
count-chatlist
del-friend!
del-groupchat!
Documentation License
Enums
Examples
File Sending Callbacks
file-data-remaining
file-data-size
Filesending Functions
Friend and Group Manipulation
friend-exists?
friendlist-length
Functions
General Callbacks
get-active-calls
get-call-state
get-chatlist
get-client-id
get-friend-connection-status
get-friend-number
get-friendlist
get-group-names
get-group-number-peers
get-group-peer-pubkey
get-group-peername
get-keys
get-last-online
get-name
get-name-size
get-nospam
get-num-online-friends
get-peer-csettings
get-peer-id
get-self-address
get-self-avatar
get-self-name
get-self-name-size
get-self-status-message
get-self-status-message-size
get-self-user-status
get-status-message
get-status-message-size
get-user-status
Getters and Setters
group-action-send
group-get-title
group-message-send
group-peernumber-is-ours?
group-send-audio
group-set-title!
Groupchat Callbacks
Interact with Tox
invite-friend
is-typing?
join-av-groupchat
join-groupchat
kill-transmission
Library License
libtoxcore-racket
libtoxcore-racket
libtoxcore-racket/av
libtoxcore-racket/functions
Licensing
make-_ToxAvCSettings
make-Tox-Options
new-file-sender
prepare-audio-frame
prepare-transmission
prepare-video-frame
Procedures
request-avatar-data
request-avatar-info
Saving and Loading Functions
send-action
send-audio
send-avatar-info
send-file-control
send-file-data
send-message
send-video
set-avatar!
set-name
set-nospam!
set-status-message!
set-user-is-typing!
set-user-status!
struct:_ToxAvCSettings
struct:Tox-Options
Structs
tox-connected?
tox-do
tox-do-interval
tox-hash
tox-kill!
tox-load
tox-new
Tox-Options
Tox-Options-ipv6-enabled?
Tox-Options-proxy-address
Tox-Options-proxy-port
Tox-Options-proxy-type
Tox-Options-udp-disabled?
Tox-Options?
tox-save
tox-size
TOX_ADDRESS_SIZE
TOX_FILE_ID_LENGTH
TOX_HASH_LENGTH
TOX_MAX_CUSTOM_PACKET_SIZE
TOX_MAX_FILENAME_LENGTH
TOX_MAX_FRIEND_REQUEST_LENGTH
TOX_MAX_MESSAGE_LENGTH
TOX_MAX_NAME_LENGTH
TOX_MAX_STATUS_MESSAGE_LENGTH
TOX_PUBLIC_KEY_SIZE
TOX_SECRET_KEY_SIZE
toxav-do
toxav-do-interval
ToxAvAudioCallback
ToxAVCallback
ToxAvVideoCallback
TOXDNS_MAX_RECOMMENDED_NAME_LENGTH
unset-avatar!