function createAndAddAudioAndVideoTrack(streamArgumentType) {
  if (streamArgumentType !== 'no-stream' &&
      streamArgumentType !== 'shared-stream' &&
      streamArgumentType !== 'individual-streams')
    throw failTest('Unsupported streamArgumentType.');
  navigator.getUserMedia({ audio: true, video: true },
      function(stream) {
        let audioStream = undefined;
        if (streamArgumentType !== 'no-stream')
          audioStream = new MediaStream();

        let audioTrack = stream.getAudioTracks()[0];
        let audioSender =
            audioStream ? peerConnection_().addTrack(audioTrack, audioStream)
                        : peerConnection_().addTrack(audioTrack);
        if (!audioSender || audioSender.track != audioTrack)
          throw failTest('addTrack did not return a sender with the track.');

        let videoStream = undefined;
        if (streamArgumentType === 'shared-stream') {
          videoStream = audioStream;
        } else if (streamArgumentType === 'individual-streams') {
          videoStream = new MediaStream();
        }

        let videoTrack = stream.getVideoTracks()[0];
        let videoSender =
            videoStream ? peerConnection_().addTrack(videoTrack, videoStream)
                        : peerConnection_().addTrack(videoTrack);
        if (!videoSender || videoSender.track != videoTrack)
          throw failTest('addTrack did not return a sender with the track.');

        let audioStreamId = audioStream ? audioStream.id : 'null';
        let videoStreamId = videoStream ? videoStream.id : 'null';
        returnToTest('ok-' + audioStreamId + ' ' + audioTrack.id
                     + ' ' + videoStreamId + ' ' + videoTrack.id);
      },
      function(error) {
        throw failTest('getUserMedia failed: ' + error);
      });
}
/**
 * Creates an audio and video track and adds them to the peer connection using
 * |addTrack|. They are added with or without a stream in accordance with
 * |streamArgumentType|.
 *
 * Returns
 * "ok-<audio stream id> <audio track id> <video stream id> <video track id>" on
 * success. If no stream is backing up the track, <stream id> is "null".
 *
 * @param {string} streamArgumentType Must be one of the following values:
 * 'no-stream' - The tracks are added without an associated stream.
 * 'shared-stream' - The tracks are added with the same associated stream.
 * 'individual-streams' - A stream is created for each track.
 */
Creates an audio and video track and adds them to the peer connection using
|addTrack|. They are added with or without a stream in accordance with
|streamArgumentType|.

Returns
"ok-   " on
success. If no stream is backing up the track,  is "null".

@param {string} streamArgumentType Must be one of the following values:
'no-stream' - The tracks are added without an associated stream.
'shared-stream' - The tracks are added with the same associated stream.
'individual-streams' - A stream is created for each track.
Creates an audio and video track and adds them to the peer connection using |addTrack| . They are added with or without a stream in accordance with |streamArgumentType| . Returns " ok - " on success . If no stream is backing up the track is " null " . @param { string } streamArgumentType Must be one of the following values : ' no - stream ' - The tracks are added without an associated stream . ' shared - stream ' - The tracks are added with the same associated stream . ' individual - streams ' - A stream is created for each track .
function createAndAddAudioAndVideoTrack(streamArgumentType) {
  if (streamArgumentType !== 'no-stream' &&
      streamArgumentType !== 'shared-stream' &&
      streamArgumentType !== 'individual-streams')
    throw failTest('Unsupported streamArgumentType.');
  navigator.getUserMedia({ audio: true, video: true },
      function(stream) {
        let audioStream = undefined;
        if (streamArgumentType !== 'no-stream')
          audioStream = new MediaStream();
        let audioTrack = stream.getAudioTracks()[0];
        let audioSender =
            audioStream ? peerConnection_().addTrack(audioTrack, audioStream)
                        : peerConnection_().addTrack(audioTrack);
        if (!audioSender || audioSender.track != audioTrack)
          throw failTest('addTrack did not return a sender with the track.');
        let videoStream = undefined;
        if (streamArgumentType === 'shared-stream') {
          videoStream = audioStream;
        } else if (streamArgumentType === 'individual-streams') {
          videoStream = new MediaStream();
        }
        let videoTrack = stream.getVideoTracks()[0];
        let videoSender =
            videoStream ? peerConnection_().addTrack(videoTrack, videoStream)
                        : peerConnection_().addTrack(videoTrack);
        if (!videoSender || videoSender.track != videoTrack)
          throw failTest('addTrack did not return a sender with the track.');
        let audioStreamId = audioStream ? audioStream.id : 'null';
        let videoStreamId = videoStream ? videoStream.id : 'null';
        returnToTest('ok-' + audioStreamId + ' ' + audioTrack.id
                     + ' ' + videoStreamId + ' ' + videoTrack.id);
      },
      function(error) {
        throw failTest('getUserMedia failed: ' + error);
      });
}
function createAndAddAudioAndVideoTrack ( streamArgumentType ) { if ( streamArgumentType !== 'no-stream' && streamArgumentType !== 'shared-stream' && streamArgumentType !== 'individual-streams' ) throw failTest ( 'Unsupported streamArgumentType.' ) ; navigator . getUserMedia ( { audio : true , video : true } , function ( stream ) { let audioStream = undefined ; if ( streamArgumentType !== 'no-stream' ) audioStream = new MediaStream ( ) ; let audioTrack = stream . getAudioTracks ( ) [ 0 ] ; let audioSender = audioStream ? peerConnection_ ( ) . addTrack ( audioTrack , audioStream ) : peerConnection_ ( ) . addTrack ( audioTrack ) ; if ( ! audioSender || audioSender . track != audioTrack ) throw failTest ( 'addTrack did not return a sender with the track.' ) ; let videoStream = undefined ; if ( streamArgumentType === 'shared-stream' ) { videoStream = audioStream ; } else if ( streamArgumentType === 'individual-streams' ) { videoStream = new MediaStream ( ) ; } let videoTrack = stream . getVideoTracks ( ) [ 0 ] ; let videoSender = videoStream ? peerConnection_ ( ) . addTrack ( videoTrack , videoStream ) : peerConnection_ ( ) . addTrack ( videoTrack ) ; if ( ! videoSender || videoSender . track != videoTrack ) throw failTest ( 'addTrack did not return a sender with the track.' ) ; let audioStreamId = audioStream ? audioStream . id : 'null' ; let videoStreamId = videoStream ? videoStream . id : 'null' ; returnToTest ( 'ok-' + audioStreamId + ' ' + audioTrack . id + ' ' + videoStreamId + ' ' + videoTrack . id ) ; } , function ( error ) { throw failTest ( 'getUserMedia failed: ' + error ) ; } ) ; }
Creates an audio and video track and adds them to the peer connection using
 |addTrack|.
Creates an audio and video track and adds them to the peer connection using |addTrack| .