summaryrefslogtreecommitdiffstats
path: root/dom/presentation/interfaces
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dom/presentation/interfaces/moz.build29
-rw-r--r--dom/presentation/interfaces/nsIPresentationControlChannel.idl139
-rw-r--r--dom/presentation/interfaces/nsIPresentationControlService.idl156
-rw-r--r--dom/presentation/interfaces/nsIPresentationDevice.idl43
-rw-r--r--dom/presentation/interfaces/nsIPresentationDeviceManager.idl51
-rw-r--r--dom/presentation/interfaces/nsIPresentationDevicePrompt.idl59
-rw-r--r--dom/presentation/interfaces/nsIPresentationDeviceProvider.idl75
-rw-r--r--dom/presentation/interfaces/nsIPresentationListener.idl54
-rw-r--r--dom/presentation/interfaces/nsIPresentationLocalDevice.idl17
-rw-r--r--dom/presentation/interfaces/nsIPresentationNetworkHelper.idl36
-rw-r--r--dom/presentation/interfaces/nsIPresentationRequestUIGlue.idl29
-rw-r--r--dom/presentation/interfaces/nsIPresentationService.idl276
-rw-r--r--dom/presentation/interfaces/nsIPresentationSessionRequest.idl35
-rw-r--r--dom/presentation/interfaces/nsIPresentationSessionTransport.idl70
-rw-r--r--dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl80
-rw-r--r--dom/presentation/interfaces/nsIPresentationTerminateRequest.idl33
16 files changed, 1182 insertions, 0 deletions
diff --git a/dom/presentation/interfaces/moz.build b/dom/presentation/interfaces/moz.build
new file mode 100644
index 0000000000..bc09f5679f
--- /dev/null
+++ b/dom/presentation/interfaces/moz.build
@@ -0,0 +1,29 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+XPIDL_SOURCES += [
+ "nsIPresentationControlChannel.idl",
+ "nsIPresentationControlService.idl",
+ "nsIPresentationDevice.idl",
+ "nsIPresentationDeviceManager.idl",
+ "nsIPresentationDevicePrompt.idl",
+ "nsIPresentationDeviceProvider.idl",
+ "nsIPresentationListener.idl",
+ "nsIPresentationLocalDevice.idl",
+ "nsIPresentationRequestUIGlue.idl",
+ "nsIPresentationService.idl",
+ "nsIPresentationSessionRequest.idl",
+ "nsIPresentationSessionTransport.idl",
+ "nsIPresentationSessionTransportBuilder.idl",
+ "nsIPresentationTerminateRequest.idl",
+]
+
+if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
+ XPIDL_SOURCES += [
+ "nsIPresentationNetworkHelper.idl",
+ ]
+
+XPIDL_MODULE = "dom_presentation"
diff --git a/dom/presentation/interfaces/nsIPresentationControlChannel.idl b/dom/presentation/interfaces/nsIPresentationControlChannel.idl
new file mode 100644
index 0000000000..2b44fbd412
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationControlChannel.idl
@@ -0,0 +1,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 AString 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 AString 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 AString 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 AString presentationId, in AString url);
+
+ /*
+ * Terminate a presentation on remote endpoint.
+ * @param presentationId The Id for representing this session.
+ * @throws NS_ERROR_FAILURE on failure
+ */
+ void terminate(in AString 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 AString presentationId, in AString url);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationControlService.idl b/dom/presentation/interfaces/nsIPresentationControlService.idl
new file mode 100644
index 0000000000..6602b49776
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationControlService.idl
@@ -0,0 +1,156 @@
+/* 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 nsIPresentationControlChannel;
+
+%{C++
+#define PRESENTATION_CONTROL_SERVICE_CONTACT_ID \
+ "@mozilla.org/presentation/control-service;1"
+%}
+
+/*
+ * The device information required for establishing control channel.
+ */
+[scriptable, uuid(296fd171-e4d0-4de0-99ff-ad8ed52ddef3)]
+interface nsITCPDeviceInfo: nsISupports
+{
+ readonly attribute AUTF8String id;
+ readonly attribute AUTF8String address;
+ readonly attribute uint16_t port;
+ // SHA-256 fingerprint of server certificate. Empty string represents
+ // server doesn't support TLS or not available.
+ readonly attribute AUTF8String certFingerprint;
+};
+
+[scriptable, uuid(09bddfaf-fcc2-4dc9-b33e-a509a1c2fb6d)]
+interface nsIPresentationControlServerListener: nsISupports
+{
+ /**
+ * Callback while the server is ready or restarted.
+ * @param aPort
+ * The port of the server socket.
+ * @param aCertFingerprint
+ * The SHA-256 fingerprint of TLS server certificate.
+ * Empty string represents server started without encryption.
+ */
+ void onServerReady(in uint16_t aPort, in AUTF8String aCertFingerprint);
+
+ /**
+ * Callback while the server is stopped or fails to start.
+ * @param aResult
+ * The error cause of server stopped or the reason of
+ * start failure.
+ * NS_OK means the server is stopped by close.
+ */
+ void onServerStopped(in nsresult aResult);
+
+ /**
+ * Callback while the remote host is requesting to start a presentation session.
+ * @param aDeviceInfo The device information related to the remote host.
+ * @param aUrl The URL requested to open by remote device.
+ * @param aPresentationId The Id for representing this session.
+ * @param aControlChannel The control channel for this session.
+ */
+ void onSessionRequest(in nsITCPDeviceInfo aDeviceInfo,
+ in AString aUrl,
+ in AString aPresentationId,
+ in nsIPresentationControlChannel aControlChannel);
+
+ /**
+ * Callback while the remote host is requesting to terminate a presentation session.
+ * @param aDeviceInfo The device information related to the remote host.
+ * @param aPresentationId The Id for representing this session.
+ * @param aControlChannel The control channel for this session.
+ * @param aIsFromReceiver true if termination is initiated by receiver.
+ */
+ void onTerminateRequest(in nsITCPDeviceInfo aDeviceInfo,
+ in AString aPresentationId,
+ in nsIPresentationControlChannel aControlChannel,
+ in boolean aIsFromReceiver);
+
+ /**
+ * Callback while the remote host is requesting to reconnect a presentation session.
+ * @param aDeviceInfo The device information related to the remote host.
+ * @param aUrl The URL requested to open by remote device.
+ * @param aPresentationId The Id for representing this session.
+ * @param aControlChannel The control channel for this session.
+ */
+ void onReconnectRequest(in nsITCPDeviceInfo aDeviceInfo,
+ in AString url,
+ in AString aPresentationId,
+ in nsIPresentationControlChannel aControlChannel);
+};
+
+/**
+ * Presentation control service which can be used for both presentation
+ * control client and server.
+ */
+[scriptable, uuid(55d6b605-2389-4aae-a8fe-60d4440540ea)]
+interface nsIPresentationControlService: nsISupports
+{
+ /**
+ * This method initializes server socket. Caller should set listener and
+ * monitor onServerReady event to get the correct server info.
+ * @param aEncrypted
+ * True for using TLS control channel.
+ * @param aPort
+ * The port of the server socket. Pass 0 or opt-out to indicate no
+ * preference, and a port will be selected automatically.
+ * @throws NS_ERROR_FAILURE if the server socket has been inited or the
+ * server socket can not be inited.
+ */
+ void startServer(in boolean aEncrypted, [optional] in uint16_t aPort);
+
+ /**
+ * Request connection to designated remote presentation control receiver.
+ * @param aDeviceInfo
+ * The remtoe device info for establish connection.
+ * @returns The control channel for this session.
+ * @throws NS_ERROR_FAILURE if the Id hasn't been inited.
+ */
+ nsIPresentationControlChannel connect(in nsITCPDeviceInfo aDeviceInfo);
+
+ /**
+ * Check the compatibility to remote presentation control server.
+ * @param aVersion
+ * The version of remote server.
+ */
+ boolean isCompatibleServer(in uint32_t aVersion);
+
+ /**
+ * Close server socket and call |listener.onClose(NS_OK)|
+ */
+ void close();
+
+ /**
+ * Get the listen port of the TCP socket, valid after the server is ready.
+ * 0 indicates the server socket is not ready or is closed.
+ */
+ readonly attribute uint16_t port;
+
+ /**
+ * The protocol version implemented by this server.
+ */
+ readonly attribute uint32_t version;
+
+ /**
+ * The id of the TCP presentation server. |requestSession| won't
+ * work until the |id| is set.
+ */
+ attribute AUTF8String id;
+
+ /**
+ * The fingerprint of the TLS server certificate.
+ * Empty string indicates the server is not ready or not encrypted.
+ */
+ attribute AUTF8String certFingerprint;
+
+ /**
+ * The listener for handling events of this presentation control server.
+ * Listener must be provided before invoke |startServer| and |close|.
+ */
+ attribute nsIPresentationControlServerListener listener;
+};
diff --git a/dom/presentation/interfaces/nsIPresentationDevice.idl b/dom/presentation/interfaces/nsIPresentationDevice.idl
new file mode 100644
index 0000000000..e70820270a
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationDevice.idl
@@ -0,0 +1,43 @@
+/* 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 nsIPresentationControlChannel;
+
+/*
+ * Remote device.
+ */
+[scriptable, uuid(b1e0a7af-5936-4066-8f2e-f789fb9a7e8f)]
+interface nsIPresentationDevice : nsISupports
+{
+ // The unique Id for the device. UUID is recommanded.
+ readonly attribute AUTF8String id;
+
+ // The human-readable name of this device.
+ readonly attribute AUTF8String name;
+
+ // TODO expose more info in order to fulfill UX spec
+ // The category of this device, could be "wifi", "bluetooth", "hdmi", etc.
+ readonly attribute AUTF8String type;
+
+ /*
+ * Establish a control channel to this device.
+ * @returns The control channel for this session.
+ * @throws NS_ERROR_FAILURE if the establishment fails
+ */
+ nsIPresentationControlChannel establishControlChannel();
+
+ // Do something when presentation session is disconnected.
+ void disconnect();
+
+ /*
+ * Query if requested presentation URL is supported.
+ * @params requestedUrl the designated URL for a presentation request.
+ * @returns true if designated URL is supported.
+ */
+ boolean isRequestedUrlSupported(in AString requestedUrl);
+};
+
+
diff --git a/dom/presentation/interfaces/nsIPresentationDeviceManager.idl b/dom/presentation/interfaces/nsIPresentationDeviceManager.idl
new file mode 100644
index 0000000000..adff9fc09e
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationDeviceManager.idl
@@ -0,0 +1,51 @@
+/* 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 nsIPresentationDeviceProvider;
+
+%{C++
+#define PRESENTATION_DEVICE_MANAGER_CONTRACTID "@mozilla.org/presentation-device/manager;1"
+#define PRESENTATION_DEVICE_CHANGE_TOPIC "presentation-device-change"
+%}
+
+/*
+ * Manager for the device availability. User can observe "presentation-device-change"
+ * for any update of the available devices.
+ */
+[scriptable, uuid(beb61db5-3d5f-454f-a15a-dbfa0337c569)]
+interface nsIPresentationDeviceManager : nsISupports
+{
+ // true if there is any device available.
+ readonly attribute boolean deviceAvailable;
+
+ /*
+ * Register a device provider manually.
+ * @param provider The device provider to add.
+ */
+ void addDeviceProvider(in nsIPresentationDeviceProvider provider);
+
+ /*
+ * Unregister a device provider manually.
+ * @param provider The device provider to remove.
+ */
+ void removeDeviceProvider(in nsIPresentationDeviceProvider provider);
+
+ /*
+ * Force all registered device providers to update device information.
+ */
+ void forceDiscovery();
+
+ /*
+ * Retrieve all available devices or all available devices that supports
+ * designated presentation URLs, return a list of nsIPresentationDevice.
+ * The returned list is a cached device list and could be out-of-date.
+ * Observe device change events to get following updates.
+ * @param presentationUrls the target presentation URLs for device filtering
+ */
+ nsIArray getAvailableDevices([optional] in nsIArray presentationUrls);
+};
+
diff --git a/dom/presentation/interfaces/nsIPresentationDevicePrompt.idl b/dom/presentation/interfaces/nsIPresentationDevicePrompt.idl
new file mode 100644
index 0000000000..9128b1cc75
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationDevicePrompt.idl
@@ -0,0 +1,59 @@
+/* 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 nsIPresentationDevice;
+interface nsIPrincipal;
+
+webidl EventTarget;
+
+%{C++
+#define PRESENTATION_DEVICE_PROMPT_CONTRACTID "@mozilla.org/presentation-device/prompt;1"
+%}
+
+/*
+ * The information and callbacks for device selection
+ */
+[scriptable, uuid(b2aa7f6a-9448-446a-bba4-9c29638b0ed4)]
+interface nsIPresentationDeviceRequest : nsISupports
+{
+ // The origin which initiate the request.
+ readonly attribute AString origin;
+
+ // The array of candidate URLs.
+ readonly attribute nsIArray requestURLs;
+
+ // The XUL browser element that the request was originated in.
+ readonly attribute EventTarget chromeEventHandler;
+
+ // The principal of the request.
+ readonly attribute nsIPrincipal principal;
+
+ /*
+ * Callback after selecting a device
+ * @param device The selected device.
+ */
+ void select(in nsIPresentationDevice device);
+
+ /*
+ * Callback after selection failed or canceled by user.
+ * @param reason The error cause for canceling this request.
+ */
+ void cancel(in nsresult reason);
+};
+
+/*
+ * UI prompt for device selection.
+ */
+[scriptable, uuid(ac1a7e44-de86-454f-a9f1-276de2539831)]
+interface nsIPresentationDevicePrompt : nsISupports
+{
+ /*
+ * Request a device selection.
+ * @param request The information and callbacks of this selection request.
+ */
+ void promptDeviceSelection(in nsIPresentationDeviceRequest request);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationDeviceProvider.idl b/dom/presentation/interfaces/nsIPresentationDeviceProvider.idl
new file mode 100644
index 0000000000..15d09241ef
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationDeviceProvider.idl
@@ -0,0 +1,75 @@
+/* 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 nsIPresentationDevice;
+interface nsIPresentationControlChannel;
+
+%{C++
+#define PRESENTATION_DEVICE_PROVIDER_CATEGORY "presentation-device-provider"
+%}
+
+/*
+ * The callbacks for any device updates and session request.
+ */
+[scriptable, uuid(46fd372b-2e40-4179-9b36-0478d141e440)]
+interface nsIPresentationDeviceListener: nsISupports
+{
+ void addDevice(in nsIPresentationDevice device);
+ void removeDevice(in nsIPresentationDevice device);
+ void updateDevice(in nsIPresentationDevice device);
+
+ /*
+ * Callback while the remote device is requesting to start a presentation session.
+ * @param device The remote device that sent session request.
+ * @param url The URL requested to open by remote device.
+ * @param presentationId The Id for representing this session.
+ * @param controlChannel The control channel for this session.
+ */
+ void onSessionRequest(in nsIPresentationDevice device,
+ in AString url,
+ in AString presentationId,
+ in nsIPresentationControlChannel controlChannel);
+
+ /*
+ * Callback while the remote device is requesting to terminate a presentation session.
+ * @param device The remote device that sent session request.
+ * @param presentationId The Id for representing this session.
+ * @param controlChannel The control channel for this session.
+ * @param aIsFromReceiver true if termination is initiated by receiver.
+ */
+ void onTerminateRequest(in nsIPresentationDevice device,
+ in AString presentationId,
+ in nsIPresentationControlChannel controlChannel,
+ in boolean aIsFromReceiver);
+
+ /*
+ * Callback while the remote device is requesting to reconnect a presentation session.
+ * @param device The remote device that sent session request.
+ * @param aUrl The URL requested to open by remote device.
+ * @param presentationId The Id for representing this session.
+ * @param controlChannel The control channel for this session.
+ */
+ void onReconnectRequest(in nsIPresentationDevice device,
+ in AString url,
+ in AString presentationId,
+ in nsIPresentationControlChannel controlChannel);
+};
+
+/*
+ * Device provider for any device protocol, can be registered as default
+ * providers by adding its contractID to category "presentation-device-provider".
+ */
+[scriptable, uuid(3db2578a-0f50-44ad-b01b-28427b71b7bf)]
+interface nsIPresentationDeviceProvider: nsISupports
+{
+ // The listener for handling any device update.
+ attribute nsIPresentationDeviceListener listener;
+
+ /*
+ * Force to update device information.
+ */
+ void forceDiscovery();
+};
diff --git a/dom/presentation/interfaces/nsIPresentationListener.idl b/dom/presentation/interfaces/nsIPresentationListener.idl
new file mode 100644
index 0000000000..609ab27c78
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationListener.idl
@@ -0,0 +1,54 @@
+/* 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"
+
+%{C++
+#include "nsTArray.h"
+%}
+
+[ref] native URLArrayRef(const nsTArray<nsString>);
+
+[uuid(0105f837-4279-4715-9d5b-2dc3f8b65353)]
+interface nsIPresentationAvailabilityListener : nsISupports
+{
+ /*
+ * Called when device availability changes.
+ */
+ [noscript] void notifyAvailableChange(in URLArrayRef urls,
+ in bool available);
+};
+
+[scriptable, uuid(7dd48df8-8f8c-48c7-ac37-7b9fd1acf2f8)]
+interface nsIPresentationSessionListener : nsISupports
+{
+ const unsigned short STATE_CONNECTING = 0;
+ const unsigned short STATE_CONNECTED = 1;
+ const unsigned short STATE_CLOSED = 2;
+ const unsigned short STATE_TERMINATED = 3;
+
+ /*
+ * Called when session state changes.
+ */
+ void notifyStateChange(in AString sessionId,
+ in unsigned short state,
+ in nsresult reason);
+
+ /*
+ * Called when receive messages.
+ */
+ void notifyMessage(in AString sessionId,
+ in ACString data,
+ in boolean isBinary);
+};
+
+[scriptable, uuid(27f101d7-9ed1-429e-b4f8-43b00e8e111c)]
+interface nsIPresentationRespondingListener : nsISupports
+{
+ /*
+ * Called when an incoming session connects.
+ */
+ void notifySessionConnect(in unsigned long long windowId,
+ in AString sessionId);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationLocalDevice.idl b/dom/presentation/interfaces/nsIPresentationLocalDevice.idl
new file mode 100644
index 0000000000..80e3b4041f
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationLocalDevice.idl
@@ -0,0 +1,17 @@
+/* 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 "nsIPresentationDevice.idl"
+
+/*
+ * Local device.
+ * This device is used for 1-UA use case. The result for display is rendered by
+ * this host device.
+ */
+[scriptable, uuid(dd239720-cab6-4fb5-9025-cba23f1bbc2d)]
+interface nsIPresentationLocalDevice : nsIPresentationDevice
+{
+ // (1-UA only) The property is used to get the window ID of 1-UA device.
+ readonly attribute AUTF8String windowId;
+};
diff --git a/dom/presentation/interfaces/nsIPresentationNetworkHelper.idl b/dom/presentation/interfaces/nsIPresentationNetworkHelper.idl
new file mode 100644
index 0000000000..514075dfab
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationNetworkHelper.idl
@@ -0,0 +1,36 @@
+/* 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"
+
+%{C++
+#define PRESENTATION_NETWORK_HELPER_CONTRACTID \
+ "@mozilla.org/presentation-device/networkHelper;1"
+%}
+
+[scriptable, uuid(0a7e134f-ff80-4e73-91e6-12b3134fe568)]
+interface nsIPresentationNetworkHelperListener : nsISupports
+{
+ /**
+ * Called when error occurs.
+ * @param aReason error message.
+ */
+ void onError(in AUTF8String aReason);
+
+ /**
+ * Called when get Wi-Fi IP address.
+ * @param aIPAddress the IP address of Wi-Fi interface.
+ */
+ void onGetWifiIPAddress(in AUTF8String aIPAddress);
+};
+
+[scriptable, uuid(650dc16b-3d9c-49a6-9037-1d6f2d18c90c)]
+interface nsIPresentationNetworkHelper : nsISupports
+{
+ /**
+ * Get IP address of Wi-Fi interface.
+ * @param aListener the callback interface.
+ */
+ void getWifiIPAddress(in nsIPresentationNetworkHelperListener aListener);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationRequestUIGlue.idl b/dom/presentation/interfaces/nsIPresentationRequestUIGlue.idl
new file mode 100644
index 0000000000..162ffb0ad8
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationRequestUIGlue.idl
@@ -0,0 +1,29 @@
+/* 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 nsIPresentationDevice;
+
+%{C++
+#define PRESENTATION_REQUEST_UI_GLUE_CONTRACTID \
+ "@mozilla.org/presentation/requestuiglue;1"
+%}
+
+[scriptable, uuid(faa45119-6fb5-496c-aa4c-f740177a38b5)]
+interface nsIPresentationRequestUIGlue : nsISupports
+{
+ /*
+ * This method is called to open the responding app/page when
+ * a presentation request comes in at receiver side.
+ *
+ * @param url The url of the request.
+ * @param sessionId The session ID of the request.
+ *
+ * @return A promise that resolves to the opening frame.
+ */
+ Promise sendRequest(in AString url,
+ in AString sessionId,
+ in nsIPresentationDevice device);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationService.idl b/dom/presentation/interfaces/nsIPresentationService.idl
new file mode 100644
index 0000000000..f1bf7ef9c2
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationService.idl
@@ -0,0 +1,276 @@
+/* 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 nsIInputStream;
+interface nsIPresentationAvailabilityListener;
+interface nsIPresentationRespondingListener;
+interface nsIPresentationSessionListener;
+interface nsIPresentationTransportBuilderConstructor;
+interface nsIPrincipal;
+
+webidl Blob;
+webidl EventTarget;
+
+%{C++
+#define PRESENTATION_SERVICE_CID \
+ { 0x1d9bb10c, 0xc0ab, 0x4fe8, \
+ { 0x9e, 0x4f, 0x40, 0x58, 0xb8, 0x51, 0x98, 0x32 } }
+#define PRESENTATION_SERVICE_CONTRACTID \
+ "@mozilla.org/presentation/presentationservice;1"
+
+#include "nsStringFwd.h"
+#include "nsTArray.h"
+
+%}
+
+[ref] native URLArrayRef(const nsTArray<nsString>);
+
+[scriptable, uuid(12073206-0065-4b10-9488-a6eb9b23e65b)]
+interface nsIPresentationServiceCallback : nsISupports
+{
+ /*
+ * Called when the operation succeeds.
+ *
+ * @param url: the selected request url used to start or reconnect a session.
+ */
+ void notifySuccess(in AString url);
+
+ /*
+ * Called when the operation fails.
+ *
+ * @param error: error message.
+ */
+ void notifyError(in nsresult error);
+};
+
+[scriptable, uuid(de42b741-5619-4650-b961-c2cebb572c95)]
+interface nsIPresentationService : nsISupports
+{
+ const unsigned short ROLE_CONTROLLER = 0x1;
+ const unsigned short ROLE_RECEIVER = 0x2;
+
+ const unsigned short CLOSED_REASON_ERROR = 0x1;
+ const unsigned short CLOSED_REASON_CLOSED = 0x2;
+ const unsigned short CLOSED_REASON_WENTAWAY = 0x3;
+
+ /*
+ * Start a new presentation session and display a prompt box which asks users
+ * to select a device.
+ *
+ * @param urls: The candidate Urls of presenting page. Only one url would be used.
+ * @param sessionId: An ID to identify presentation session.
+ * @param origin: The url of requesting page.
+ * @param deviceId: The specified device of handling this request, null string
+ * for prompt device selection dialog.
+ * @param windowId: The inner window ID associated with the presentation
+ * session. (0 implies no window ID since no actual window
+ * uses 0 as its ID. Generally it's the case the window is
+ * located in different process from this service)
+ * @param eventTarget: The chrome event handler, in particular XUL browser
+ * element in parent process, that the request was
+ * originated in.
+ * @param principal: The principal that initiated the session.
+ * @param callback: Invoke the callback when the operation is completed.
+ * NotifySuccess() is called with |id| if a session is
+ * established successfully with the selected device.
+ * Otherwise, NotifyError() is called with a error message.
+ * @param constructor: The constructor for creating a transport builder.
+ */
+ [noscript] void startSession(in URLArrayRef urls,
+ in AString sessionId,
+ in AString origin,
+ in AString deviceId,
+ in unsigned long long windowId,
+ in EventTarget eventTarget,
+ in nsIPrincipal principal,
+ in nsIPresentationServiceCallback callback,
+ in nsIPresentationTransportBuilderConstructor constructor);
+
+ /*
+ * Send the message to the session.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param data: the message being sent out.
+ */
+ void sendSessionMessage(in AString sessionId,
+ in uint8_t role,
+ in AString data);
+
+ /*
+ * Send the binary message to the session.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param data: the message being sent out.
+ */
+ void sendSessionBinaryMsg(in AString sessionId,
+ in uint8_t role,
+ in ACString data);
+
+ /*
+ * Send the blob to the session.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param blob: The input blob to be sent.
+ */
+ void sendSessionBlob(in AString sessionId,
+ in uint8_t role,
+ in Blob blob);
+
+ /*
+ * Close the session.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ */
+ void closeSession(in AString sessionId,
+ in uint8_t role,
+ in uint8_t closedReason);
+
+ /*
+ * Terminate the session.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ */
+ void terminateSession(in AString sessionId,
+ in uint8_t role);
+
+ /*
+ * Reconnect the session.
+ *
+ * @param url: The request Urls.
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param callback: NotifySuccess() is called when a control channel
+ * is opened successfully.
+ * Otherwise, NotifyError() is called with a error message.
+ */
+ [noscript] void reconnectSession(in URLArrayRef urls,
+ in AString sessionId,
+ in uint8_t role,
+ in nsIPresentationServiceCallback callback);
+
+ /*
+ * Register an availability listener. Must be called from the main thread.
+ *
+ * @param availabilityUrls: The Urls that this listener is interested in.
+ * @param listener: The listener to register.
+ */
+ [noscript] void registerAvailabilityListener(
+ in URLArrayRef availabilityUrls,
+ in nsIPresentationAvailabilityListener listener);
+
+ /*
+ * Unregister an availability listener. Must be called from the main thread.
+ *
+ * @param availabilityUrls: The Urls that are registered before.
+ * @param listener: The listener to unregister.
+ */
+ [noscript] void unregisterAvailabilityListener(
+ in URLArrayRef availabilityUrls,
+ in nsIPresentationAvailabilityListener listener);
+
+ /*
+ * Register a session listener. Must be called from the main thread.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param listener: The listener to register.
+ */
+ void registerSessionListener(in AString sessionId,
+ in uint8_t role,
+ in nsIPresentationSessionListener listener);
+
+ /*
+ * Unregister a session listener. Must be called from the main thread.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ */
+ void unregisterSessionListener(in AString sessionId,
+ in uint8_t role);
+
+ /*
+ * Register a responding listener. Must be called from the main thread.
+ *
+ * @param windowId: The window ID associated with the listener.
+ * @param listener: The listener to register.
+ */
+ void registerRespondingListener(in unsigned long long windowId,
+ in nsIPresentationRespondingListener listener);
+
+ /*
+ * Unregister a responding listener. Must be called from the main thread.
+ * @param windowId: The window ID associated with the listener.
+ */
+ void unregisterRespondingListener(in unsigned long long windowId);
+
+ /*
+ * Notify the receiver page is ready for presentation use.
+ *
+ * @param sessionId An ID to identify presentation session.
+ * @param windowId The inner window ID associated with the presentation
+ * session.
+ * @param isLoading true if receiver page is loading successfully.
+ * @param constructor: The constructor for creating a transport builder.
+ */
+ void notifyReceiverReady(in AString sessionId,
+ in unsigned long long windowId,
+ in boolean isLoading,
+ in nsIPresentationTransportBuilderConstructor constructor);
+
+ /*
+ * Notify the transport is closed
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param reason: the error message. NS_OK indicates it is closed normally.
+ */
+ void NotifyTransportClosed(in AString sessionId,
+ in uint8_t role,
+ in nsresult reason);
+
+ /*
+ * Untrack the relevant info about the presentation session if there's any.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ */
+ void untrackSessionInfo(in AString sessionId, in uint8_t role);
+
+ /*
+ * The windowId for building RTCDataChannel session transport
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ */
+ unsigned long long getWindowIdBySessionId(in AString sessionId,
+ in uint8_t role);
+
+ /*
+ * Update the mapping of the session ID and window ID.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ * @param windowId: The inner window ID associated with the presentation
+ * session.
+ */
+ void updateWindowIdBySessionId(in AString sessionId,
+ in uint8_t role,
+ in unsigned long long windowId);
+
+ /*
+ * To build the session transport.
+ * NOTE: This function should be only called at controller side.
+ *
+ * @param sessionId: An ID to identify presentation session.
+ * @param role: Identify the function called by controller or receiver.
+ */
+ void buildTransport(in AString sessionId, in uint8_t role);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationSessionRequest.idl b/dom/presentation/interfaces/nsIPresentationSessionRequest.idl
new file mode 100644
index 0000000000..a145aaeed7
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationSessionRequest.idl
@@ -0,0 +1,35 @@
+/* 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 nsIPresentationDevice;
+interface nsIPresentationControlChannel;
+
+%{C++
+#define PRESENTATION_SESSION_REQUEST_TOPIC "presentation-session-request"
+#define PRESENTATION_RECONNECT_REQUEST_TOPIC "presentation-reconnect-request"
+%}
+
+/*
+ * The event of a device requesting for starting or reconnecting
+ * a presentation session. User can monitor the session request
+ * on every device by observing "presentation-sesion-request" for a
+ * new session and "presentation-reconnect-request" for reconnecting.
+ */
+[scriptable, uuid(d808a084-d0f8-455a-a8df-5879e05a755b)]
+interface nsIPresentationSessionRequest: nsISupports
+{
+ // The device which requesting the presentation session.
+ readonly attribute nsIPresentationDevice device;
+
+ // The URL requested to open by remote device.
+ readonly attribute AString url;
+
+ // The Id for representing this session.
+ readonly attribute AString presentationId;
+
+ // The control channel for this session.
+ readonly attribute nsIPresentationControlChannel controlChannel;
+};
diff --git a/dom/presentation/interfaces/nsIPresentationSessionTransport.idl b/dom/presentation/interfaces/nsIPresentationSessionTransport.idl
new file mode 100644
index 0000000000..f5b7187b21
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationSessionTransport.idl
@@ -0,0 +1,70 @@
+/* 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 nsIInputStream;
+interface nsINetAddr;
+
+webidl Blob;
+
+%{C++
+#define PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID \
+ "@mozilla.org/presentation/presentationtcpsessiontransport;1"
+%}
+
+/*
+ * The callback for session transport events.
+ */
+[scriptable, uuid(9f158786-41a6-4a10-b29b-9497f25d4b67)]
+interface nsIPresentationSessionTransportCallback : nsISupports
+{
+ void notifyTransportReady();
+ void notifyTransportClosed(in nsresult reason);
+ void notifyData(in ACString data, in boolean isBinary);
+};
+
+/*
+ * App-to-App transport channel for the presentation session.
+ */
+[scriptable, uuid(670b7e1b-65be-42b6-a596-be571907fa18)]
+interface nsIPresentationSessionTransport : nsISupports
+{
+ // Should be set once the underlying session transport is built
+ attribute nsIPresentationSessionTransportCallback callback;
+
+ // valid for TCP session transport
+ readonly attribute nsINetAddr selfAddress;
+
+ /*
+ * Enable the notification for incoming data. |notifyData| of
+ * |nsIPresentationSessionTransportCallback| can start getting invoked.
+ * Should set callback before |enableDataNotification| is called.
+ */
+ void enableDataNotification();
+
+ /*
+ * Send message to the remote endpoint.
+ * @param data The message to send.
+ */
+ void send(in AString data);
+
+ /*
+ * Send the binary message to the remote endpoint.
+ * @param data: the message being sent out.
+ */
+ void sendBinaryMsg(in ACString data);
+
+ /*
+ * Send the blob to the remote endpoint.
+ * @param blob: The input blob to be sent.
+ */
+ void sendBlob(in Blob blob);
+
+ /*
+ * Close this session transport.
+ * @param reason The reason for closing this session transport.
+ */
+ void close(in nsresult reason);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl b/dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl
new file mode 100644
index 0000000000..4b9d46db98
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationSessionTransportBuilder.idl
@@ -0,0 +1,80 @@
+/* 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 nsIPresentationChannelDescription;
+interface nsISocketTransport;
+interface mozIDOMWindow;
+interface nsIPresentationControlChannel;
+interface nsIPresentationSessionTransport;
+
+[scriptable, uuid(673f6de1-e253-41b8-9be8-b7ff161fa8dc)]
+interface nsIPresentationSessionTransportBuilderListener : nsISupports
+{
+ // Should set |transport.callback| in |onSessionTransport|.
+ void onSessionTransport(in nsIPresentationSessionTransport transport);
+ void onError(in nsresult reason);
+
+ void sendOffer(in nsIPresentationChannelDescription offer);
+ void sendAnswer(in nsIPresentationChannelDescription answer);
+ void sendIceCandidate(in AString candidate);
+ void close(in nsresult reason);
+};
+
+[scriptable, uuid(2fdbe67d-80f9-48dc-8237-5bef8fa19801)]
+interface nsIPresentationSessionTransportBuilder : nsISupports
+{
+};
+
+/**
+ * The constructor for creating a transport builder.
+ */
+[scriptable, uuid(706482b2-1b51-4bed-a21d-785a9cfcfac7)]
+interface nsIPresentationTransportBuilderConstructor : nsISupports
+{
+ nsIPresentationSessionTransportBuilder createTransportBuilder(in uint8_t type);
+};
+
+/**
+ * Builder for TCP session transport
+ */
+[scriptable, uuid(cde36d6e-f471-4262-a70d-f932a26b21d9)]
+interface nsIPresentationTCPSessionTransportBuilder : nsIPresentationSessionTransportBuilder
+{
+ /**
+ * The following creation functions will trigger |listener.onSessionTransport|
+ * if the session transport is successfully built, |listener.onError| if some
+ * error occurs during building session transport.
+ */
+ void buildTCPSenderTransport(in nsISocketTransport aTransport,
+ in nsIPresentationSessionTransportBuilderListener aListener);
+
+ void buildTCPReceiverTransport(in nsIPresentationChannelDescription aDescription,
+ in nsIPresentationSessionTransportBuilderListener aListener);
+};
+
+/**
+ * Builder for WebRTC data channel session transport
+ */
+[scriptable, uuid(8131c4e0-3a8c-4bc1-a92a-8431473d2fe8)]
+interface nsIPresentationDataChannelSessionTransportBuilder : nsIPresentationSessionTransportBuilder
+{
+ /**
+ * The following creation function will trigger |listener.onSessionTransport|
+ * if the session transport is successfully built, |listener.onError| if some
+ * error occurs during creating session transport. The |notifyConnected| of
+ * |aControlChannel| should be called before calling
+ * |buildDataChannelTransport|.
+ */
+ void buildDataChannelTransport(in uint8_t aRole,
+ in mozIDOMWindow aWindow,
+ in nsIPresentationSessionTransportBuilderListener aListener);
+
+ // Bug 1275150 - Merge TCP builder with the following APIs
+ void onOffer(in nsIPresentationChannelDescription offer);
+ void onAnswer(in nsIPresentationChannelDescription answer);
+ void onIceCandidate(in AString candidate);
+ void notifyDisconnected(in nsresult reason);
+};
diff --git a/dom/presentation/interfaces/nsIPresentationTerminateRequest.idl b/dom/presentation/interfaces/nsIPresentationTerminateRequest.idl
new file mode 100644
index 0000000000..cbfd486e9e
--- /dev/null
+++ b/dom/presentation/interfaces/nsIPresentationTerminateRequest.idl
@@ -0,0 +1,33 @@
+/* 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 nsIPresentationDevice;
+interface nsIPresentationControlChannel;
+
+%{C++
+#define PRESENTATION_TERMINATE_REQUEST_TOPIC "presentation-terminate-request"
+%}
+
+/*
+ * The event of a device requesting for terminating a presentation session. User can
+ * monitor the terminate request on every device by observing "presentation-terminate-request".
+ */
+[scriptable, uuid(3ddbf3a4-53ee-4b70-9bbc-58ac90dce6b5)]
+interface nsIPresentationTerminateRequest: nsISupports
+{
+ // The device which requesting to terminate presentation session.
+ readonly attribute nsIPresentationDevice device;
+
+ // The Id for representing this session.
+ readonly attribute AString presentationId;
+
+ // The control channel for this session.
+ // Should only use this channel to complete session termination.
+ readonly attribute nsIPresentationControlChannel controlChannel;
+
+ // True if termination is initiated by receiver.
+ readonly attribute boolean isFromReceiver;
+};