2015-03-25 14:47:56 +03:00
|
|
|
/* 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;
|
2015-09-10 11:29:08 +03:00
|
|
|
interface nsIPresentationAvailabilityListener;
|
|
|
|
interface nsIPresentationRespondingListener;
|
2015-03-25 14:47:56 +03:00
|
|
|
interface nsIPresentationSessionListener;
|
2016-09-16 15:59:00 +03:00
|
|
|
interface nsIPresentationTransportBuilderConstructor;
|
2016-10-04 09:27:05 +03:00
|
|
|
interface nsIPrincipal;
|
2015-03-25 14:47:56 +03:00
|
|
|
|
2018-05-22 03:32:44 +03:00
|
|
|
webidl Blob;
|
2018-04-20 07:49:30 +03:00
|
|
|
webidl EventTarget;
|
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
%{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"
|
2016-09-05 02:17:00 +03:00
|
|
|
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2016-09-05 02:17:00 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
%}
|
|
|
|
|
2016-09-05 02:17:00 +03:00
|
|
|
[ref] native URLArrayRef(const nsTArray<nsString>);
|
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
[scriptable, uuid(12073206-0065-4b10-9488-a6eb9b23e65b)]
|
|
|
|
interface nsIPresentationServiceCallback : nsISupports
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Called when the operation succeeds.
|
2016-09-05 02:17:00 +03:00
|
|
|
*
|
|
|
|
* @param url: the selected request url used to start or reconnect a session.
|
2015-03-25 14:47:56 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void notifySuccess(in AString url);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Called when the operation fails.
|
|
|
|
*
|
|
|
|
* @param error: error message.
|
|
|
|
*/
|
|
|
|
void notifyError(in nsresult error);
|
|
|
|
};
|
|
|
|
|
2016-04-11 06:20:55 +03:00
|
|
|
[scriptable, uuid(de42b741-5619-4650-b961-c2cebb572c95)]
|
2015-03-25 14:47:56 +03:00
|
|
|
interface nsIPresentationService : nsISupports
|
|
|
|
{
|
2016-04-18 03:19:00 +03:00
|
|
|
const unsigned short ROLE_CONTROLLER = 0x1;
|
|
|
|
const unsigned short ROLE_RECEIVER = 0x2;
|
|
|
|
|
2016-05-30 09:48:00 +03:00
|
|
|
const unsigned short CLOSED_REASON_ERROR = 0x1;
|
|
|
|
const unsigned short CLOSED_REASON_CLOSED = 0x2;
|
|
|
|
const unsigned short CLOSED_REASON_WENTAWAY = 0x3;
|
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
/*
|
|
|
|
* Start a new presentation session and display a prompt box which asks users
|
|
|
|
* to select a device.
|
|
|
|
*
|
2016-09-05 02:17:00 +03:00
|
|
|
* @param urls: The candidate Urls of presenting page. Only one url would be used.
|
2015-03-25 14:47:56 +03:00
|
|
|
* @param sessionId: An ID to identify presentation session.
|
|
|
|
* @param origin: The url of requesting page.
|
2016-01-13 14:21:25 +03:00
|
|
|
* @param deviceId: The specified device of handling this request, null string
|
2016-08-31 15:56:17 +03:00
|
|
|
* for prompt device selection dialog.
|
2016-04-11 06:20:55 +03:00
|
|
|
* @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)
|
2016-08-31 15:56:17 +03:00
|
|
|
* @param eventTarget: The chrome event handler, in particular XUL browser
|
|
|
|
* element in parent process, that the request was
|
|
|
|
* originated in.
|
2016-10-04 09:27:05 +03:00
|
|
|
* @param principal: The principal that initiated the session.
|
2015-03-25 14:47:56 +03:00
|
|
|
* @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.
|
2016-09-16 15:59:00 +03:00
|
|
|
* @param constructor: The constructor for creating a transport builder.
|
2015-03-25 14:47:56 +03:00
|
|
|
*/
|
2016-09-05 02:17:00 +03:00
|
|
|
[noscript] void startSession(in URLArrayRef urls,
|
2018-09-06 11:02:43 +03:00
|
|
|
in AString sessionId,
|
|
|
|
in AString origin,
|
|
|
|
in AString deviceId,
|
2016-09-05 02:17:00 +03:00
|
|
|
in unsigned long long windowId,
|
2018-04-20 07:49:30 +03:00
|
|
|
in EventTarget eventTarget,
|
2016-10-04 09:27:05 +03:00
|
|
|
in nsIPrincipal principal,
|
2016-09-16 15:59:00 +03:00
|
|
|
in nsIPresentationServiceCallback callback,
|
|
|
|
in nsIPresentationTransportBuilderConstructor constructor);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
|
|
|
/*
|
2016-04-11 06:20:55 +03:00
|
|
|
* Send the message to the session.
|
2015-03-25 14:47:56 +03:00
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-04-18 03:19:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2016-04-11 06:20:55 +03:00
|
|
|
* @param data: the message being sent out.
|
2015-03-25 14:47:56 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void sendSessionMessage(in AString sessionId,
|
|
|
|
in uint8_t role,
|
|
|
|
in AString data);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
2016-09-18 02:42:00 +03:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void sendSessionBinaryMsg(in AString sessionId,
|
2016-09-18 02:42:00 +03:00
|
|
|
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.
|
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void sendSessionBlob(in AString sessionId,
|
2016-09-18 02:42:00 +03:00
|
|
|
in uint8_t role,
|
2018-05-22 03:32:44 +03:00
|
|
|
in Blob blob);
|
2016-09-18 02:42:00 +03:00
|
|
|
|
2015-10-08 13:11:10 +03:00
|
|
|
/*
|
|
|
|
* Close the session.
|
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-04-18 03:19:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2015-10-08 13:11:10 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void closeSession(in AString sessionId,
|
2016-05-30 09:48:00 +03:00
|
|
|
in uint8_t role,
|
|
|
|
in uint8_t closedReason);
|
2015-10-08 13:11:10 +03:00
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
/*
|
|
|
|
* Terminate the session.
|
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-04-18 03:19:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2015-03-25 14:47:56 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void terminateSession(in AString sessionId,
|
2016-04-18 03:19:00 +03:00
|
|
|
in uint8_t role);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
2016-08-02 20:11:00 +03:00
|
|
|
/*
|
|
|
|
* Reconnect the session.
|
|
|
|
*
|
2016-09-05 02:17:00 +03:00
|
|
|
* @param url: The request Urls.
|
2016-08-02 20:11:00 +03:00
|
|
|
* @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.
|
|
|
|
*/
|
2016-09-05 02:17:00 +03:00
|
|
|
[noscript] void reconnectSession(in URLArrayRef urls,
|
2018-09-06 11:02:43 +03:00
|
|
|
in AString sessionId,
|
2016-09-05 02:17:00 +03:00
|
|
|
in uint8_t role,
|
|
|
|
in nsIPresentationServiceCallback callback);
|
2016-08-02 20:11:00 +03:00
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
/*
|
2015-09-10 11:29:08 +03:00
|
|
|
* Register an availability listener. Must be called from the main thread.
|
2015-03-25 14:47:56 +03:00
|
|
|
*
|
2016-11-08 06:13:00 +03:00
|
|
|
* @param availabilityUrls: The Urls that this listener is interested in.
|
2015-03-25 14:47:56 +03:00
|
|
|
* @param listener: The listener to register.
|
|
|
|
*/
|
2016-11-08 06:13:00 +03:00
|
|
|
[noscript] void registerAvailabilityListener(
|
|
|
|
in URLArrayRef availabilityUrls,
|
|
|
|
in nsIPresentationAvailabilityListener listener);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
|
|
|
/*
|
2015-09-10 11:29:08 +03:00
|
|
|
* Unregister an availability listener. Must be called from the main thread.
|
2016-11-08 06:13:00 +03:00
|
|
|
*
|
|
|
|
* @param availabilityUrls: The Urls that are registered before.
|
2015-03-25 14:47:56 +03:00
|
|
|
* @param listener: The listener to unregister.
|
|
|
|
*/
|
2016-11-08 06:13:00 +03:00
|
|
|
[noscript] void unregisterAvailabilityListener(
|
|
|
|
in URLArrayRef availabilityUrls,
|
|
|
|
in nsIPresentationAvailabilityListener listener);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register a session listener. Must be called from the main thread.
|
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-04-18 03:19:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2015-03-25 14:47:56 +03:00
|
|
|
* @param listener: The listener to register.
|
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void registerSessionListener(in AString sessionId,
|
2016-04-18 03:19:00 +03:00
|
|
|
in uint8_t role,
|
2015-03-25 14:47:56 +03:00
|
|
|
in nsIPresentationSessionListener listener);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unregister a session listener. Must be called from the main thread.
|
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-04-18 03:19:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2015-03-25 14:47:56 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void unregisterSessionListener(in AString sessionId,
|
2016-04-18 03:19:00 +03:00
|
|
|
in uint8_t role);
|
2015-03-25 14:47:56 +03:00
|
|
|
|
2015-09-10 11:29:08 +03:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-04-11 06:20:55 +03:00
|
|
|
void registerRespondingListener(in unsigned long long windowId,
|
2015-09-10 11:29:08 +03:00
|
|
|
in nsIPresentationRespondingListener listener);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unregister a responding listener. Must be called from the main thread.
|
|
|
|
* @param windowId: The window ID associated with the listener.
|
|
|
|
*/
|
2016-04-11 06:20:55 +03:00
|
|
|
void unregisterRespondingListener(in unsigned long long windowId);
|
2015-09-10 11:29:08 +03:00
|
|
|
|
2015-03-25 14:47:56 +03:00
|
|
|
/*
|
|
|
|
* Notify the receiver page is ready for presentation use.
|
|
|
|
*
|
2016-08-04 04:46:14 +03:00
|
|
|
* @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.
|
2016-09-16 15:59:00 +03:00
|
|
|
* @param constructor: The constructor for creating a transport builder.
|
2015-08-31 08:24:35 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void notifyReceiverReady(in AString sessionId,
|
2016-08-04 04:46:14 +03:00
|
|
|
in unsigned long long windowId,
|
2016-09-16 15:59:00 +03:00
|
|
|
in boolean isLoading,
|
|
|
|
in nsIPresentationTransportBuilderConstructor constructor);
|
2015-08-31 08:24:35 +03:00
|
|
|
|
2016-06-03 06:03:27 +03:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void NotifyTransportClosed(in AString sessionId,
|
2016-06-03 06:03:27 +03:00
|
|
|
in uint8_t role,
|
|
|
|
in nsresult reason);
|
|
|
|
|
2015-08-31 08:24:35 +03:00
|
|
|
/*
|
|
|
|
* Untrack the relevant info about the presentation session if there's any.
|
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-04-18 03:19:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2015-03-25 14:47:56 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void untrackSessionInfo(in AString sessionId, in uint8_t role);
|
2016-04-11 06:20:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The windowId for building RTCDataChannel session transport
|
2016-08-30 02:40:00 +03:00
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2016-04-11 06:20:55 +03:00
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
unsigned long long getWindowIdBySessionId(in AString sessionId,
|
2016-08-30 02:40:00 +03:00
|
|
|
in uint8_t role);
|
2016-08-02 20:11:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the mapping of the session ID and window ID.
|
|
|
|
*
|
|
|
|
* @param sessionId: An ID to identify presentation session.
|
2016-08-30 02:40:00 +03:00
|
|
|
* @param role: Identify the function called by controller or receiver.
|
2016-08-02 20:11:00 +03:00
|
|
|
* @param windowId: The inner window ID associated with the presentation
|
|
|
|
* session.
|
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void updateWindowIdBySessionId(in AString sessionId,
|
2016-08-30 02:40:00 +03:00
|
|
|
in uint8_t role,
|
2016-08-02 20:11:00 +03:00
|
|
|
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.
|
|
|
|
*/
|
2018-09-06 11:02:43 +03:00
|
|
|
void buildTransport(in AString sessionId, in uint8_t role);
|
2015-03-25 14:47:56 +03:00
|
|
|
};
|