// Copyright 2013 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.

// The <code>chrome.cast.streaming.session</code> API creates a Cast
// session using WebMediaStreamTrack as sources. The session is composed
// by RTP streams and a network transport.
//
// Calling this API will generate corresponding resources for use with
// chrome.cast.streaming.rtpStream and chrome.cast.streaming.udpTransport
// APIs.
//
// Valid resource IDs are positive and non-zero.
namespace cast.streaming.session {
  // Callback from the <code>create</code> method.
  // |audioStreamId| : The audio RTP stream ID.
  // |videoStreamId| : The video RTP stream ID.
  // |udpTransportId| : The UDP transport ID.
  callback CreateCallback = void (long audioStreamId,
                                  long videoStreamId,
                                  long udpTransportId);

  interface Functions {
    // Creates a Cast session using the provided audio and video track as
    // source. The tracks must be of type MediaStreamTrack. This will
    // create two RTP streams and a UDP transport that builds the session.
    // Either |audioTrack| or |videoTrack| can be null but not both. This
    // means creating a session with only audio or video. If a given
    // track is null then the created stream ID will be null.
    //
    // |audioTrack| : the source audio track.
    // |videoTrack| : the source video track.
    // |callback| : Called when the sesion has been created.
    [nocompile,allowAmbiguousOptionalArguments] static void create(
        [instanceOf=MediaStreamTrack] optional object audioTrack,
        [instanceOf=MediaStreamTrack] optional object videoTrack,
        CreateCallback callback);
  };
};
