generateScreenCaptureStream_(constraints) {
    return new Promise((resolve, reject) => {
      this.logger_.info(
          () => 'Starting desktop capture with constraints ' +
              JSON.stringify(constraints));
      navigator.mediaDevices.getUserMedia(constraints)
          .then(
              stream => {
                if (!stream) {
                  // NOTE(miu): This implies that getUserMedia is broken, and it
                  // may also be breaking chrome.tabCapture.
                  reject(new mr.mirror.Error(
                      mr.mirror.MirrorMediaStream.EMPTY_STREAM_,
                      mr.MirrorAnalytics.CapturingFailure.DESKTOP_FAIL));
                }
                this.setStream_(stream);
                resolve(stream);
              },
              error => {
                let errorReason =
                    mr.MirrorAnalytics.CapturingFailure.DESKTOP_FAIL;
                // Certain errors indicate the user cancelled the request.
                // https://www.w3.org/TR/mediacapture-streams/#methods-5
                if (error.name == 'NotAllowedError') {
                  errorReason = mr.MirrorAnalytics.CapturingFailure
                                    .CAPTURE_DESKTOP_FAIL_ERROR_USER_CANCEL;
                }
                reject(new mr.mirror.Error(
                    `${error.name} ${error.constraintName}: ${error.message}`,
                    errorReason));
              });
    });
  }
/**
   * Generates a screen capture MediaStream from the given
   * MediaStreamConstraints.
   * @param {!MediaStreamConstraints} constraints The constraints object to use.
   * @return {!Promise<MediaStream>} Fulfilled with the MediaStream from
   *     capture.
   * @private
   */
Generates a screen capture MediaStream from the given
MediaStreamConstraints.
@param {!MediaStreamConstraints} constraints The constraints object to use.
@return {!Promise} Fulfilled with the MediaStream from
capture.
@private
Generates a screen capture MediaStream from the given MediaStreamConstraints . @param { !MediaStreamConstraints } constraints The constraints object to use . @return { !Promise } Fulfilled with the MediaStream from capture . @private
generateScreenCaptureStream_(constraints) {
    return new Promise((resolve, reject) => {
      this.logger_.info(
          () => 'Starting desktop capture with constraints ' +
              JSON.stringify(constraints));
      navigator.mediaDevices.getUserMedia(constraints)
          .then(
              stream => {
                if (!stream) {
                  reject(new mr.mirror.Error(
                      mr.mirror.MirrorMediaStream.EMPTY_STREAM_,
                      mr.MirrorAnalytics.CapturingFailure.DESKTOP_FAIL));
                }
                this.setStream_(stream);
                resolve(stream);
              },
              error => {
                let errorReason =
                    mr.MirrorAnalytics.CapturingFailure.DESKTOP_FAIL;
                if (error.name == 'NotAllowedError') {
                  errorReason = mr.MirrorAnalytics.CapturingFailure
                                    .CAPTURE_DESKTOP_FAIL_ERROR_USER_CANCEL;
                }
                reject(new mr.mirror.Error(
                    `${error.name} ${error.constraintName}: ${error.message}`,
                    errorReason));
              });
    });
  }
generateScreenCaptureStream_ ( constraints ) { return new Promise ( ( resolve , reject ) => { this . logger_ . info ( ( ) => 'Starting desktop capture with constraints ' + JSON . stringify ( constraints ) ) ; navigator . mediaDevices . getUserMedia ( constraints ) . then ( stream => { if ( ! stream ) { reject ( new mr . mirror . Error ( mr . mirror . MirrorMediaStream . EMPTY_STREAM_ , mr . MirrorAnalytics . CapturingFailure . DESKTOP_FAIL ) ) ; } this . setStream_ ( stream ) ; resolve ( stream ) ; } , error => { let errorReason = mr . MirrorAnalytics . CapturingFailure . DESKTOP_FAIL ; if ( error . name == 'NotAllowedError' ) { errorReason = mr . MirrorAnalytics . CapturingFailure . CAPTURE_DESKTOP_FAIL_ERROR_USER_CANCEL ; } reject ( new mr . mirror . Error ( ` ${ error . name } ${ error . constraintName } ${ error . message } ` , errorReason ) ) ; } ) ; } ) ; }
Generates a screen capture MediaStream from the given
 MediaStreamConstraints.
Generates a screen capture MediaStream from the given MediaStreamConstraints .
// NOTE(miu): This implies that getUserMedia is broken, and it // may also be breaking chrome.tabCapture. // Certain errors indicate the user cancelled the request. // https://www.w3.org/TR/mediacapture-streams/#methods-5