summaryrefslogtreecommitdiff
path: root/dom/presentation/interfaces/nsIPresentationControlChannel.idl
blob: 669e4088ee78afa3a31188d806c99f795c57e073 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIArray;
interface nsIInputStream;

[scriptable, uuid(ae318e05-2a4e-4f85-95c0-e8b191ad812c)]
interface nsIPresentationChannelDescription: nsISupports
{
  const unsigned short TYPE_TCP = 1;
  const unsigned short TYPE_DATACHANNEL = 2;

  // Type of transport channel.
  readonly attribute uint8_t type;

  // Addresses for TCP channel (as a list of nsISupportsCString).
  // Should only be used while type == TYPE_TCP.
  readonly attribute nsIArray tcpAddress;

  // Port number for TCP channel.
  // Should only be used while type == TYPE_TCP.
  readonly attribute uint16_t tcpPort;

  // SDP for Data Channel.
  // Should only be used while type == TYPE_DATACHANNEL.
  readonly attribute DOMString dataChannelSDP;
};

/*
 * The callbacks for events on control channel.
 */
[scriptable, uuid(96dd548f-7d0f-43c1-b1ad-28e666cf1e82)]
interface nsIPresentationControlChannelListener: nsISupports
{
  /*
   * Callback for receiving offer from remote endpoint.
   * @param offer The received offer.
   */
  void onOffer(in nsIPresentationChannelDescription offer);

  /*
   * Callback for receiving answer from remote endpoint.
   * @param answer The received answer.
   */
  void onAnswer(in nsIPresentationChannelDescription answer);

  /*
   * Callback for receiving ICE candidate from remote endpoint.
   * @param answer The received answer.
   */
  void onIceCandidate(in DOMString candidate);

  /*
   * The callback for notifying channel connected. This should be async called
   * after nsIPresentationDevice::establishControlChannel.
   */
  void notifyConnected();

  /*
   * The callback for notifying channel disconnected.
   * @param reason The reason of channel close, NS_OK represents normal close.
   */
  void notifyDisconnected(in nsresult reason);

  /*
   * The callback for notifying the reconnect command is acknowledged.
   */
  void notifyReconnected();
};

/*
 * The control channel for establishing RTCPeerConnection for a presentation
 * session. SDP Offer/Answer will be exchanged through this interface. The
 * control channel should be in-order.
 */
[scriptable, uuid(e60e208c-a9f5-4bc6-9a3e-47f3e4ae9c57)]
interface nsIPresentationControlChannel: nsISupports
{
  // The listener for handling events of this control channel.
  // All the events should be pending until listener is assigned.
  attribute nsIPresentationControlChannelListener listener;

  /*
   * Send offer to remote endpoint. |onOffer| should be invoked on remote
   * endpoint.
   * @param offer The offer to send.
   * @throws  NS_ERROR_FAILURE on failure
   */
  void sendOffer(in nsIPresentationChannelDescription offer);

  /*
   * Send answer to remote endpoint. |onAnswer| should be invoked on remote
   * endpoint.
   * @param answer The answer to send.
   * @throws  NS_ERROR_FAILURE on failure
   */
  void sendAnswer(in nsIPresentationChannelDescription answer);

  /*
   * Send ICE candidate to remote endpoint. |onIceCandidate| should be invoked
   * on remote endpoint.
   * @param candidate The candidate to send
   * @throws NS_ERROR_FAILURE on failure
   */
  void sendIceCandidate(in DOMString candidate);

  /*
   * Launch a presentation on remote endpoint.
   * @param presentationId The Id for representing this session.
   * @param url The URL requested to open by remote device.
   * @throws NS_ERROR_FAILURE on failure
   */
  void launch(in DOMString presentationId, in DOMString url);

  /*
   * Terminate a presentation on remote endpoint.
   * @param presentationId The Id for representing this session.
   * @throws NS_ERROR_FAILURE on failure
   */
  void terminate(in DOMString presentationId);

  /*
   * Disconnect the control channel.
   * @param reason The reason of disconnecting channel; NS_OK represents normal.
   */
  void disconnect(in nsresult reason);

  /*
   * Reconnect a presentation on remote endpoint.
   * Note that only controller is allowed to reconnect a session.
   * @param presentationId The Id for representing this session.
   * @param url The URL requested to open by remote device.
   * @throws NS_ERROR_FAILURE on failure
   */
  void reconnect(in DOMString presentationId, in DOMString url);
};