{"version":3,"file":"cbdev-ngx-webcam.mjs","sources":["../../src/app/modules/webcam/domain/webcam-image.ts","../../src/app/modules/webcam/util/webcam.util.ts","../../src/app/modules/webcam/webcam/webcam.component.ts","../../src/app/modules/webcam/webcam/webcam.component.html","../../src/app/modules/webcam/webcam.module.ts","../../src/app/modules/webcam/domain/webcam-init-error.ts","../../src/app/modules/webcam/domain/webcam-mirror-properties.ts","../../cbdev-ngx-webcam.ts"],"sourcesContent":["/**\n * Container class for a captured webcam image\n * @author basst314, davidshen84\n */\nexport class WebcamImage {\n\n  public constructor(imageAsDataUrl: string, mimeType: string, imageData: ImageData) {\n    this._mimeType = mimeType;\n    this._imageAsDataUrl = imageAsDataUrl;\n    this._imageData = imageData;\n  }\n\n  private readonly _mimeType: string = null;\n  private _imageAsBase64: string = null;\n  private readonly _imageAsDataUrl: string = null;\n  private readonly _imageData: ImageData = null;\n\n\n  /**\n   * Extracts the Base64 data out of the given dataUrl.\n   * @param dataUrl the given dataUrl\n   * @param mimeType the mimeType of the data\n   */\n  private static getDataFromDataUrl(dataUrl: string, mimeType: string) {\n    return dataUrl.replace(`data:${mimeType};base64,`, '');\n  }\n\n  /**\n   * Get the base64 encoded image data\n   * @returns base64 data of the image\n   */\n  public get imageAsBase64(): string {\n    return this._imageAsBase64 ? this._imageAsBase64\n      : this._imageAsBase64 = WebcamImage.getDataFromDataUrl(this._imageAsDataUrl, this._mimeType);\n  }\n\n  /**\n   * Get the encoded image as dataUrl\n   * @returns the dataUrl of the image\n   */\n  public get imageAsDataUrl(): string {\n    return this._imageAsDataUrl;\n  }\n\n  /**\n   * Get the ImageData object associated with the canvas' 2d context.\n   * @returns the ImageData of the canvas's 2d context.\n   */\n  public get imageData(): ImageData {\n    return this._imageData;\n  }\n\n}\n","export class WebcamUtil {\n\n  private static availableVideoInputs: MediaDeviceInfo[] = [];\n\n  static hasVideoInputs() {\n    const inputs = WebcamUtil.availableVideoInputs;\n    return !!inputs.find(input => !!input.deviceId);\n  }\n\n  /**\n   * Lists available videoInput devices\n   * @returns a list of media device info.\n   */\n  public static async getAvailableVideoInputs(): Promise<MediaDeviceInfo[]> {\n    if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {\n      throw new Error('enumerateDevices() not supported.');\n    }\n\n    if (!this.hasVideoInputs()) {\n      const devices = await navigator.mediaDevices.enumerateDevices();\n      WebcamUtil.availableVideoInputs = devices.filter((device: MediaDeviceInfo) => device.kind === 'videoinput');\n    }\n\n    return WebcamUtil.availableVideoInputs;\n  }\n}\n","import {AfterViewInit, Component, EventEmitter, Input, OnDestroy, Output, ViewChild} from '@angular/core';\nimport {WebcamInitError} from '../domain/webcam-init-error';\nimport {WebcamImage} from '../domain/webcam-image';\nimport {Observable, Subscription} from 'rxjs';\nimport {WebcamUtil} from '../util/webcam.util';\nimport {WebcamMirrorProperties} from '../domain/webcam-mirror-properties';\n\n@Component({\n  selector: 'webcam',\n  templateUrl: './webcam.component.html',\n  styleUrls: ['./webcam.component.scss']\n})\nexport class WebcamComponent implements AfterViewInit, OnDestroy {\n  private static DEFAULT_VIDEO_OPTIONS: MediaTrackConstraints = {facingMode: 'environment'};\n  private static DEFAULT_IMAGE_TYPE: string = 'image/jpeg';\n  private static DEFAULT_IMAGE_QUALITY: number = 0.92;\n\n  /** Defines the max width of the webcam area in px */\n  @Input() public width: number = 640;\n  /** Defines the max height of the webcam area in px */\n  @Input() public height: number = 480;\n  /** Defines base constraints to apply when requesting video track from UserMedia */\n  @Input() public videoOptions: MediaTrackConstraints = WebcamComponent.DEFAULT_VIDEO_OPTIONS;\n  /** Flag to enable/disable camera switch. If enabled, a switch icon will be displayed if multiple cameras were found */\n  @Input() public allowCameraSwitch: boolean = true;\n  /** Parameter to control image mirroring (i.e. for user-facing camera). [\"auto\", \"always\", \"never\"] */\n  @Input() public mirrorImage: string | WebcamMirrorProperties;\n  /** Flag to control whether an ImageData object is stored into the WebcamImage object. */\n  @Input() public captureImageData: boolean = false;\n  /** The image type to use when capturing snapshots */\n  @Input() public imageType: string = WebcamComponent.DEFAULT_IMAGE_TYPE;\n  /** The image quality to use when capturing snapshots (number between 0 and 1) */\n  @Input() public imageQuality: number = WebcamComponent.DEFAULT_IMAGE_QUALITY;\n\n  /** EventEmitter which fires when an image has been captured */\n  @Output() public imageCapture: EventEmitter<WebcamImage> = new EventEmitter<WebcamImage>();\n  /** Emits a mediaError if webcam cannot be initialized (e.g. missing user permissions) */\n  @Output() public initError: EventEmitter<WebcamInitError> = new EventEmitter<WebcamInitError>();\n  /** Emits when the webcam video was clicked */\n  @Output() public imageClick: EventEmitter<void> = new EventEmitter<void>();\n  /** Emits the active deviceId after the active video device was switched */\n  @Output() public cameraSwitched: EventEmitter<string> = new EventEmitter<string>();\n\n  /** available video devices */\n  public availableVideoInputs: MediaDeviceInfo[] = [];\n\n  /** Indicates whether the video device is ready to be switched */\n  public videoInitialized: boolean = false;\n\n  /** If the Observable represented by this subscription emits, an image will be captured and emitted through\n   * the 'imageCapture' EventEmitter */\n  private triggerSubscription: Subscription;\n  /** Index of active video in availableVideoInputs */\n  private activeVideoInputIndex: number = -1;\n  /** Subscription to switchCamera events */\n  private switchCameraSubscription: Subscription;\n  /** MediaStream object in use for streaming UserMedia data */\n  private mediaStream: MediaStream = null;\n  @ViewChild('video', {static: true}) private video: any;\n  /** Canvas for Video Snapshots */\n  @ViewChild('canvas', {static: true}) private canvas: any;\n\n  /** width and height of the active video stream */\n  private activeVideoSettings: MediaTrackSettings = null;\n\n  /**\n   * If the given Observable emits, an image will be captured and emitted through 'imageCapture' EventEmitter\n   */\n  @Input()\n  public set trigger(trigger: Observable<void>) {\n    if (this.triggerSubscription) {\n      this.triggerSubscription.unsubscribe();\n    }\n\n    // Subscribe to events from this Observable to take snapshots\n    this.triggerSubscription = trigger.subscribe(() => {\n      this.takeSnapshot();\n    });\n  }\n\n  /**\n   * If the given Observable emits, the active webcam will be switched to the one indicated by the emitted value.\n   * @param switchCamera Indicates which webcam to switch to\n   *   true: cycle forwards through available webcams\n   *   false: cycle backwards through available webcams\n   *   string: activate the webcam with the given id\n   */\n  @Input()\n  public set switchCamera(switchCamera: Observable<boolean | string>) {\n    if (this.switchCameraSubscription) {\n      this.switchCameraSubscription.unsubscribe();\n    }\n\n    // Subscribe to events from this Observable to switch video device\n    this.switchCameraSubscription = switchCamera.subscribe((value: boolean | string) => {\n      if (typeof value === 'string') {\n        // deviceId was specified\n        this.switchToVideoInput(value);\n      } else {\n        // direction was specified\n        this.rotateVideoInput(value !== false);\n      }\n    });\n  }\n\n  /**\n   * Get MediaTrackConstraints to request streaming the given device\n   * @param deviceId\n   * @param baseMediaTrackConstraints base constraints to merge deviceId-constraint into\n   * @returns\n   */\n  private static getMediaConstraintsForDevice(deviceId: string, baseMediaTrackConstraints: MediaTrackConstraints): MediaTrackConstraints {\n    const result: MediaTrackConstraints = baseMediaTrackConstraints ? baseMediaTrackConstraints : this.DEFAULT_VIDEO_OPTIONS;\n    if (deviceId) {\n      result.deviceId = {exact: deviceId};\n    }\n\n    return result;\n  }\n\n  /**\n   * Tries to harvest the deviceId from the given mediaStreamTrack object.\n   * Browsers populate this object differently; this method tries some different approaches\n   * to read the id.\n   * @param mediaStreamTrack\n   * @returns deviceId if found in the mediaStreamTrack\n   */\n  private static getDeviceIdFromMediaStreamTrack(mediaStreamTrack: MediaStreamTrack): string {\n    if (mediaStreamTrack.getSettings && mediaStreamTrack.getSettings() && mediaStreamTrack.getSettings().deviceId) {\n      return mediaStreamTrack.getSettings().deviceId;\n    } else if (mediaStreamTrack.getConstraints && mediaStreamTrack.getConstraints() && mediaStreamTrack.getConstraints().deviceId) {\n      const deviceIdObj: ConstrainDOMString = mediaStreamTrack.getConstraints().deviceId;\n      return WebcamComponent.getValueFromConstrainDOMString(deviceIdObj);\n    }\n  }\n\n  /**\n   * Tries to harvest the facingMode from the given mediaStreamTrack object.\n   * Browsers populate this object differently; this method tries some different approaches\n   * to read the value.\n   * @param mediaStreamTrack\n   * @returns facingMode if found in the mediaStreamTrack\n   */\n  private static getFacingModeFromMediaStreamTrack(mediaStreamTrack: MediaStreamTrack): string {\n    if (mediaStreamTrack) {\n      if (mediaStreamTrack.getSettings && mediaStreamTrack.getSettings() && mediaStreamTrack.getSettings().facingMode) {\n        return mediaStreamTrack.getSettings().facingMode;\n      } else if (mediaStreamTrack.getConstraints && mediaStreamTrack.getConstraints() && mediaStreamTrack.getConstraints().facingMode) {\n        const facingModeConstraint: ConstrainDOMString = mediaStreamTrack.getConstraints().facingMode;\n        return WebcamComponent.getValueFromConstrainDOMString(facingModeConstraint);\n      }\n    }\n  }\n\n  /**\n   * Determines whether the given mediaStreamTrack claims itself as user facing\n   * @param mediaStreamTrack\n   */\n  private static isUserFacing(mediaStreamTrack: MediaStreamTrack): boolean {\n    const facingMode: string = WebcamComponent.getFacingModeFromMediaStreamTrack(mediaStreamTrack);\n    return facingMode ? 'user' === facingMode.toLowerCase() : false;\n  }\n\n  /**\n   * Extracts the value from the given ConstrainDOMString\n   * @param constrainDOMString\n   */\n  private static getValueFromConstrainDOMString(constrainDOMString: ConstrainDOMString): string {\n    if (constrainDOMString) {\n      if (constrainDOMString instanceof String) {\n        return String(constrainDOMString);\n      } else if (Array.isArray(constrainDOMString) && Array(constrainDOMString).length > 0) {\n        return String(constrainDOMString[0]);\n      } else if (typeof constrainDOMString === 'object') {\n        if (constrainDOMString['exact']) {\n          return String(constrainDOMString['exact']);\n        } else if (constrainDOMString['ideal']) {\n          return String(constrainDOMString['ideal']);\n        }\n      }\n    }\n\n    return null;\n  }\n\n  public async ngAfterViewInit() {\n    try {\n      await this.detectAvailableDevices();\n    } catch (e) {\n      this.initError.next(<WebcamInitError>{message: e.message});\n    }\n    this.switchToVideoInput(null);\n  }\n\n  public ngOnDestroy(): void {\n    this.stopMediaTracks();\n    this.unsubscribeFromSubscriptions();\n  }\n\n  /**\n   * Takes a snapshot of the current webcam's view and emits the image as an event\n   */\n  public takeSnapshot(): void {\n    // set canvas size to actual video size\n    const _video = this.nativeVideoElement;\n    const dimensions = {width: this.width, height: this.height};\n    if (_video.videoWidth) {\n      dimensions.width = _video.videoWidth;\n      dimensions.height = _video.videoHeight;\n    }\n\n    const _canvas = this.canvas.nativeElement;\n    _canvas.width = dimensions.width;\n    _canvas.height = dimensions.height;\n\n    // paint snapshot image to canvas\n    const context2d = _canvas.getContext('2d');\n    context2d.drawImage(_video, 0, 0);\n\n    // read canvas content as image\n    const mimeType: string = this.imageType ? this.imageType : WebcamComponent.DEFAULT_IMAGE_TYPE;\n    const quality: number = this.imageQuality ? this.imageQuality : WebcamComponent.DEFAULT_IMAGE_QUALITY;\n    const dataUrl: string = _canvas.toDataURL(mimeType, quality);\n\n    // get the ImageData object from the canvas' context.\n    let imageData: ImageData = null;\n\n    if (this.captureImageData) {\n      imageData = context2d.getImageData(0, 0, _canvas.width, _canvas.height);\n    }\n\n    this.imageCapture.next(new WebcamImage(dataUrl, mimeType, imageData));\n  }\n\n  /**\n   * Switches to the next/previous video device\n   * @param forward\n   */\n  public rotateVideoInput(forward: boolean) {\n    if (this.availableVideoInputs && this.availableVideoInputs.length > 1) {\n      const increment: number = forward ? 1 : (this.availableVideoInputs.length - 1);\n      const nextInputIndex = (this.activeVideoInputIndex + increment) % this.availableVideoInputs.length;\n      this.switchToVideoInput(this.availableVideoInputs[nextInputIndex].deviceId);\n    }\n  }\n\n  /**\n   * Switches the camera-view to the specified video device\n   */\n  public switchToVideoInput(deviceId: string): void {\n    this.videoInitialized = false;\n    this.stopMediaTracks();\n    this.initWebcam(deviceId, this.videoOptions);\n  }\n\n\n  /**\n   * Event-handler for video resize event.\n   * Triggers Angular change detection so that new video dimensions get applied\n   */\n  public videoResize(): void {\n    // here to trigger Angular change detection\n  }\n\n  public get videoWidth() {\n    const videoRatio = this.getVideoAspectRatio();\n    return Math.min(this.width, this.height * videoRatio);\n  }\n\n  public get videoHeight() {\n    const videoRatio = this.getVideoAspectRatio();\n    return Math.min(this.height, this.width / videoRatio);\n  }\n\n  public get videoStyleClasses() {\n    let classes: string = '';\n\n    if (this.isMirrorImage()) {\n      classes += 'mirrored ';\n    }\n\n    return classes.trim();\n  }\n\n  public get nativeVideoElement() {\n    return this.video.nativeElement;\n  }\n\n  /**\n   * Returns the video aspect ratio of the active video stream\n   */\n  private getVideoAspectRatio(): number {\n    // calculate ratio from video element dimensions if present\n    const videoElement = this.nativeVideoElement;\n    if (videoElement.videoWidth && videoElement.videoWidth > 0 &&\n      videoElement.videoHeight && videoElement.videoHeight > 0) {\n\n      return videoElement.videoWidth / videoElement.videoHeight;\n    }\n\n    // nothing present - calculate ratio based on width/height params\n    return this.width / this.height;\n  }\n\n  /**\n   * Init webcam live view\n   */\n  private initWebcam(deviceId: string, userVideoTrackConstraints: MediaTrackConstraints) {\n    const _video = this.nativeVideoElement;\n    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n\n      // merge deviceId -> userVideoTrackConstraints\n      const videoTrackConstraints = WebcamComponent.getMediaConstraintsForDevice(deviceId, userVideoTrackConstraints);\n\n      navigator.mediaDevices.getUserMedia(<MediaStreamConstraints>{video: videoTrackConstraints})\n        .then(async (stream: MediaStream) => {\n          this.mediaStream = stream;\n          _video.srcObject = stream;\n          _video.play();\n\n          this.activeVideoSettings = stream.getVideoTracks()[0].getSettings();\n          const activeDeviceId: string = WebcamComponent.getDeviceIdFromMediaStreamTrack(stream.getVideoTracks()[0]);\n\n          this.cameraSwitched.next(activeDeviceId);\n\n          // Initial detect may run before user gave permissions, returning no deviceIds. This prevents later camera switches. (#47)\n          // Run detect once again within getUserMedia callback, to make sure this time we have permissions and get deviceIds.\n          await this.detectAvailableDevices();\n\n          this.activeVideoInputIndex = activeDeviceId ? this.availableVideoInputs\n            .findIndex((mediaDeviceInfo: MediaDeviceInfo) => mediaDeviceInfo.deviceId === activeDeviceId) : -1;\n          this.videoInitialized = true;\n        })\n        .catch((err: DOMException) => {\n          this.initError.next(<WebcamInitError>{message: err.message, mediaStreamError: err});\n        });\n    } else {\n      this.initError.next(<WebcamInitError>{message: 'Cannot read UserMedia from MediaDevices.'});\n    }\n  }\n\n  private getActiveVideoTrack(): MediaStreamTrack {\n    return this.mediaStream ? this.mediaStream.getVideoTracks()[0] : null;\n  }\n\n  private isMirrorImage(): boolean {\n    if (!this.getActiveVideoTrack()) {\n      return false;\n    }\n\n    // check for explicit mirror override parameter\n    {\n      let mirror: string = 'auto';\n      if (this.mirrorImage) {\n        if (typeof this.mirrorImage === 'string') {\n          mirror = String(this.mirrorImage).toLowerCase();\n        } else {\n          // WebcamMirrorProperties\n          if (this.mirrorImage.x) {\n            mirror = this.mirrorImage.x.toLowerCase();\n          }\n        }\n      }\n\n      switch (mirror) {\n        case 'always':\n          return true;\n        case 'never':\n          return false;\n      }\n    }\n\n    // default: enable mirroring if webcam is user facing\n    return WebcamComponent.isUserFacing(this.getActiveVideoTrack());\n  }\n\n  /**\n   * Stops all active media tracks.\n   * This prevents the webcam from being indicated as active,\n   * even if it is no longer used by this component.\n   */\n  private stopMediaTracks() {\n    if (this.mediaStream && this.mediaStream.getTracks) {\n      // getTracks() returns all media tracks (video+audio)\n      this.mediaStream.getTracks()\n        .forEach((track: MediaStreamTrack) => track.stop());\n    }\n  }\n\n  /**\n   * Unsubscribe from all open subscriptions\n   */\n  private unsubscribeFromSubscriptions() {\n    if (this.triggerSubscription) {\n      this.triggerSubscription.unsubscribe();\n    }\n    if (this.switchCameraSubscription) {\n      this.switchCameraSubscription.unsubscribe();\n    }\n  }\n\n  /**\n   * Reads available input devices\n   */\n  private async detectAvailableDevices(): Promise<void> {\n    this.availableVideoInputs = await WebcamUtil.getAvailableVideoInputs();\n  }\n\n}\n","<div class=\"webcam-wrapper\" (click)=\"imageClick.next();\">\n  <video #video [width]=\"videoWidth\" [height]=\"videoHeight\" [class]=\"videoStyleClasses\" autoplay muted playsinline (resize)=\"videoResize()\"></video>\n  <div class=\"camera-switch\" *ngIf=\"allowCameraSwitch && availableVideoInputs.length > 1 && videoInitialized\" (click)=\"rotateVideoInput(true)\"></div>\n  <canvas #canvas [width]=\"width\" [height]=\"height\"></canvas>\n</div>\n","import {NgModule} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {WebcamComponent} from './webcam/webcam.component';\n\nconst COMPONENTS = [\n  WebcamComponent\n];\n\n@NgModule({\n  imports: [\n    CommonModule\n  ],\n  declarations: [\n    COMPONENTS\n  ],\n  exports: [\n    COMPONENTS\n  ]\n})\nexport class WebcamModule {\n}\n","export class WebcamInitError {\n  public message: string = null;\n  public mediaStreamError: DOMException = null;\n}\n","export class WebcamMirrorProperties {\n  public x: string;  // [\"auto\", \"always\", \"never\"]\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;MAIa,WAAW;IAEtB,YAAmB,cAAsB,EAAE,QAAgB,EAAE,SAAoB;QAMhE,cAAS,GAAW,IAAI,CAAC;QAClC,mBAAc,GAAW,IAAI,CAAC;QACrB,oBAAe,GAAW,IAAI,CAAC;QAC/B,eAAU,GAAc,IAAI,CAAC;QAR5C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;KAC7B;;;;;;IAaO,OAAO,kBAAkB,CAAC,OAAe,EAAE,QAAgB;QACjE,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,QAAQ,UAAU,EAAE,EAAE,CAAC,CAAC;KACxD;;;;;IAMD,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc;cAC5C,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;KAChG;;;;;IAMD,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;KAC7B;;;;;IAMD,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;K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