From 91b079461d026bed4171d0034e6a7ac495a018c1 Mon Sep 17 00:00:00 2001
From: Mohammad Amoush <mohammad_amoush@brown.edu>
Date: Tue, 1 Oct 2019 17:32:21 -0400
Subject: WebRTC protocol trials

---
 src/client/views/webcam/DashWebRTC.tsx | 47 ++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 src/client/views/webcam/DashWebRTC.tsx

(limited to 'src/client/views/webcam/DashWebRTC.tsx')

diff --git a/src/client/views/webcam/DashWebRTC.tsx b/src/client/views/webcam/DashWebRTC.tsx
new file mode 100644
index 000000000..451437429
--- /dev/null
+++ b/src/client/views/webcam/DashWebRTC.tsx
@@ -0,0 +1,47 @@
+import { observer } from "mobx-react";
+import React = require("react");
+import { CollectionFreeFormDocumentViewProps } from "../nodes/CollectionFreeFormDocumentView";
+import { FieldViewProps } from "../nodes/FieldView";
+import { observable } from "mobx";
+
+
+const mediaStreamConstaints = {
+    video: true,
+};
+
+
+@observer
+export class DashWebRTC extends React.Component<{}> {
+
+    @observable private videoEl: HTMLVideoElement | undefined;
+    @observable private localStream: MediaStream | undefined;
+
+
+    gotLocalMediaStream = (mediaStream: MediaStream) => {
+        this.localStream = mediaStream;
+        if (this.videoEl) {
+            this.videoEl.srcObject = mediaStream;
+        }
+    }
+
+    handleLocalMediaStreamError = (error: string) => {
+        console.log("navigator.getUserMedia error: ", error);
+    }
+
+    componentDidUpdate() {
+        navigator.mediaDevices.getUserMedia(mediaStreamConstaints).then(this.gotLocalMediaStream).catch(this.handleLocalMediaStreamError);
+    }
+
+
+
+
+    render() {
+        return (
+            <div>
+                <video autoPlay playsInline ref={(e) => this.videoEl = e!}></video>
+            </div>
+        );
+    }
+
+
+}
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

