Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experience Composer API enhancements #283

Merged
merged 7 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ exports.ArgumentError = function (message) {

exports.ArgumentError.prototype = Object.create(Error.prototype);


exports.AuthError = function (message) {
exports.AuthError = function (message = 'Invalid API key or secret') {
this.message = message;
};

Expand Down Expand Up @@ -47,9 +46,14 @@ exports.CallbackError = function (message) {

exports.CallbackError.prototype = Object.create(Error.prototype);


exports.RequestError = function (message) {
exports.RequestError = function (message = 'Unexpected response from OpenTok') {
this.message = message;
};

exports.RequestError.prototype = Object.create(Error.prototype);

exports.NotFoundError = function (message = 'Not Found') {
this.message = message;
};

exports.NotFoundError.prototype = Object.create(Error.prototype);
160 changes: 160 additions & 0 deletions lib/opentok.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var signaling = require('./signaling');
var errors = require('./errors');
var callbacks = require('./callbacks');
var generateJwt = require('./generateJwt');
var render = require('./render.js');
var OpenTok;
var key;

Expand Down Expand Up @@ -477,6 +478,165 @@ OpenTok = function (apiKey, apiSecret, env) {
);
};

/**
* Retrieves a List of {@link Render} objects, representing any renders in the starting,
* started, stopped or failed state, for your API key.
*
* @param options {Object} An options parameter with three properties:
*
* <ul>
*
* <li>
* <code>count</code> &mdash; The maximum number of renders to return. The default number of
* renders returned is 50 (or fewer, if there are fewer than 50 renders). The method returns
* a maximum of 1000 renders.
* </li>
*
* <li>
* <code>offset</code> &mdash; The offset for the first render to list (starting with the
* first render recorded as offset 0). 1 is the offset of the render that started prior
* to the most recent render. This property is optional; the default is 0.
* </li>
*
* <li>
* <code>sessionId</code> &mdash; Specify the ID of a session in order to retrieve renders
* specifically for that session. This property is optional. When no session ID is specified,
* then the method will return renders from any session created with your API key.
* </li>
*
* </ul>
*
* <p>If you don't pass in an <code>options</code> argument,
* the method returns up to 1000 renders, starting with the first render recorded.
*
* @param callback {Function} The function to call upon completing the operation. Two arguments
* are passed to the function:
*
* <ul>
*
* <li>
* <code>error</code> &mdash; An error object (if the call to the method fails).
* </li>
*
* <li>
* <code>renders</code> &mdash; An array of {@link Render} objects.
* </li>
*
* </ul>
*
* @method #listRenders
* @memberof OpenTok
*/
this.listRenders = render.listRenders.bind(null, apiConfig);

/**
* Gets an {@link Render} object for the given render ID.
*
* @param renderId {String} The render ID.
*
* @param callback {Function} The function to call upon completing the operation. Two arguments
* are passed to the function:
* <ul>
* <li><code>error</code> &mdash; An error object (if the call to the method fails). </li>
* <li><code>render</code> &mdash; The {@link Render} object.</li>
* </ul>
*
* @method #getArchive
* @memberof OpenTok
*/
this.getRender = render.getRender.bind(null, apiConfig);

/**
* Starts an Experience Composer for an OpenTok session. The Experience Composer
* instance is represented as a Render object.
* For more information, see the
* <a href="https://tokbox.com/developer/guides/experience-composer/">Experience Composer developer guide</a>.
* <p>
* Clients must be actively connected to the OpenTok session for you to successfully start
* rendering a session.
* <p>
*
* @param options {Object} An optional options object with the following properties (each
* of which is optional):
* <p>
* <ul>
* <li>
* <code>sessionId</code> (String) &mdash; The ID of a session (generated with the same
* `APIKEY`as specified in the URL) which you wish to start rendering into
* </li>
* <li>
* <code>token</code> (String) &mdash; A valid OpenTok token with a Publisher role and
* (optionally) connection data to be associated with the output stream.
* </li>
*
* <li>
* <code>url</code> (String) &mdash; A publically reachable URL controlled by the
* customer and capable of generating the content to be rendered without user intervention.
* </li>
*
* <li>
* <code>properties</code> (Object) &mdash; Initial configuration of Publisher properties for
* the composed output stream.
* </li>
*
* <li>
* <code>maxDuration</code> (Number) &mdash; The maximum time allowed for the Render, in
* seconds. After this time, the Render will be stopped automatically, if it is still running.
* </li>
*
* <li>
* <code>resolution</code> (String) &mdash; Resolution of the display area for the composition.
* </li>
*
* </ul>
*
* @param callback {Function} The function to call upon completing the operation. Two arguments
* are passed to the function:
*
* <ul>
*
* <li>
* <code>error</code> &mdash; An error object (if the call to the method fails).
* </li>
*
* <li>
* <code>render</code> &mdash; The {@link Render} object. This object includes properties
* defining the render, including the render ID.
* </li>
*
* </ul>
*
* @method #startRender
* @memberof OpenTok
*/
this.startRender = render.startRender.bind(null, apiConfig);

/**
* Stops an Experience Composer that is being rendered.
*
* @param renderId {String} The ID of the render you want to stop rendering.
* @return The {@link Archive} object corresponding to the archive being STOPPED.
*
* @param callback {Function} The function to call upon completing the operation. Two arguments
* are passed to the function:
*
* <ul>
*
* <li>
* <code>error</code> &mdash; An error object (if the call to the method fails).
* </li>
*
* <li>
* <code>render</code> &mdash; The {@link Render} object.
* </li>
*
* </ul>
*
* @method #stopRender
* @memberof OpenTok
*/
this.stopRender = render.stopRender.bind(null, apiConfig);

/**
* Starts a <a href="https://tokbox.com/developer/guides/broadcast/live-streaming/">live
* streaming broadcast</a>.
Expand Down
Loading