summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/api/copresence_private.idl
blob: 6db3420a9fc97e5441f205fe305e6e223ec25fd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Use the <code>chrome.copresencePrivate</code> API to interface with Chrome
// from the whispernet_proxy extension.
namespace copresencePrivate {
  dictionary Token {
    DOMString token;
    boolean audible;
  };

  dictionary TokenParameters {
    long length;
    boolean crc;
    boolean parity;
  };

  dictionary DecodeSamplesParameters {
    ArrayBuffer samples;

    boolean decodeAudible;
    boolean decodeInaudible;

    TokenParameters audibleTokenParams;
    TokenParameters inaudibleTokenParams;
  };

  dictionary EncodeTokenParameters {
    Token token;
    long repetitions;
    TokenParameters tokenParams;
  };

  dictionary AudioParameters {
    // This string contains marshalling of a custom parameters structure
    // that Chrome and the Whispernet wrapper both know about. These are
    // based off //components/copresence/proto/config_data.proto.
    ArrayBuffer paramData;
  };

  interface Functions {
    // Send a boolean indicating whether our initialization was successful.
    static void sendInitialized(boolean success);

    // Sends an array of found tokens to Chrome.
    static void sendFound(DOMString clientId, Token[] tokens);

    // Send an array buffer of samples encoded for the specified token.
    static void sendSamples(DOMString clientId,
                            Token token,
                            ArrayBuffer samples);
  };

  interface Events {
    // Fired to request audio configuration of the whisper.net library.
    static void onConfigAudio(DOMString clientId, AudioParameters audioParams);

    // Fired to request encoding of the given token.
    static void onEncodeTokenRequest(DOMString clientId,
                                     EncodeTokenParameters encodeParams);

    // Fired when we have new samples to decode.
    static void onDecodeSamplesRequest(DOMString clientId,
                                       DecodeSamplesParameters decodeParams);
  };
};