1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Use the <code>chrome.audio_modem</code> API
6 // to transmit and receive short tokens over audio.
8 // The audio bands supported.
10 // Audible (up to 3 kHz)
12 // Inaudible (18-20 kHz)
16 // Details for how a token is encoded in audio.
17 dictionary TokenEncoding
{
18 // The length of the tokens to transmit, in bytes.
19 // For now, apps must always use the same token length.
21 // Whether to use a 2-byte CRC checksum. Defaults to false.
23 // Whether to use a parity symbol. Defaults to false.
27 // Details of a transmit or receive request.
28 dictionary RequestParams
{
29 // How long to transmit or receive for.
30 // The timeout has a maximum of 10 minutes for transmit,
31 // or 1 hour for receive.
33 // The audio band to use.
35 // The token encoding details.
36 TokenEncoding encoding
;
39 // Results of token decoding.
40 dictionary ReceivedToken
{
41 // The token contents in raw bytes.
43 // The audio band the token was heard on.
47 // The result of a requested operation.
49 // The requested operation was processed successfully.
51 // The request was invalid. See chrome.runtime.lastError for details.
53 // The requested audio band is already in use by another client.
54 // Eventually, simultaneous tokens will be time-sliced,
55 // and this error will no longer occur.
57 // Audio encoding or decoding failed.
61 // A callback to report the status of a request.
62 callback StatusCallback
= void(Status status
);
65 // Transmit a token. Only one can be transmitted at a time.
66 // Transmission of any previous tokens (by this app) will stop.
68 RequestParams params
, ArrayBuffer token
, StatusCallback
callback);
69 // Stop any active transmission on the specified band.
70 static
void stopTransmit
(Audioband band
, StatusCallback
callback);
71 // Start listening for audio tokens. For now,
72 // only one app will be able to listen at a time.
73 static
void receive
(RequestParams params
, StatusCallback
callback);
74 // Stop any active listening on the specified band.
75 static
void stopReceive
(Audioband band
, StatusCallback
callback);
79 // Audio tokens have been received.
80 static
void onReceived
(ReceivedToken
[] tokens
);
81 // Transmit could not be confirmed.
82 // The speaker volume might be too low.
83 static
void onTransmitFail
(Audioband band
);