-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fed5df6
commit f45a75b
Showing
12 changed files
with
10,327 additions
and
1,831 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,72 @@ | ||
import filesize from 'rollup-plugin-filesize' | ||
import typescript from '@rollup/plugin-typescript' | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import strip from '@rollup/plugin-strip' | ||
import eslint from '@rollup/plugin-eslint' | ||
import babel from '@rollup/plugin-babel' | ||
import terser from '@rollup/plugin-terser' | ||
import postcss from 'rollup-plugin-postcss' | ||
import autoprefixer from 'autoprefixer' | ||
import cssnano from 'cssnano' | ||
// import sass from 'rollup-plugin-sass' | ||
|
||
const output = [ | ||
{ | ||
format: 'esm', | ||
file: 'dist/webrtc-streamer-helper.esm.js' | ||
}, | ||
{ | ||
format: 'umd', | ||
name: 'webrtc-streamer-helper', | ||
file: 'dist/webrtc-streamer-helper.umd.js' | ||
}, | ||
{ | ||
format: 'iife', | ||
file: 'dist/webrtc-streamer-helper.browser.js' | ||
}, | ||
{ | ||
format: 'esm', | ||
file: 'dist/webrtc-streamer-helper.esm.min.js', | ||
plugins: [terser()] | ||
}, | ||
{ | ||
format: 'umd', | ||
name: 'webrtc-streamer-helper', | ||
file: 'dist/webrtc-streamer-helper.umd.min.js', | ||
plugins: [terser()] | ||
}, | ||
{ | ||
format: 'iife', | ||
file: 'dist/webrtc-streamer-helper.browser.min.js', | ||
plugins: [terser()] | ||
} | ||
] | ||
|
||
export default [ | ||
{ | ||
input: 'src/main.ts', | ||
output: [ | ||
{ | ||
file: 'dist/webrtc-streamer-helper.esm.js', | ||
format: 'esm' | ||
} | ||
], | ||
output, | ||
plugins: [ | ||
eslint({ | ||
throwOnError: true, | ||
throwOnWarning: true, | ||
include: ['src/**'], | ||
exclude: ['node_modules/**'] | ||
exclude: ['node_modules/**', 'src/style/**'] | ||
}), | ||
resolve(), | ||
strip(), | ||
typescript() | ||
typescript(), | ||
postcss({ | ||
plugins: [ | ||
autoprefixer(), | ||
cssnano() | ||
] | ||
}), | ||
// sass({ | ||
// insert: true | ||
// }), | ||
babel({ babelHelpers: 'runtime', exclude: ['node_modules/**'] }), | ||
filesize() | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { WebRTCStreamerOptions } from '../types' | ||
// import { initialOptions } from '../utils/initialization' | ||
|
||
export default class WebRTCStreamer { | ||
// private element: Element | ||
// private options: WebRTCStreamerOptions | ||
// | ||
// private pc: any | ||
// private mediaConstraints = { offerToReceiveAudio: true, offerToReceiveVideo: true } | ||
// private iceServers = null | ||
// private earlyCandidates = [] | ||
constructor (args: Partial<WebRTCStreamerOptions> = {}) { | ||
const a = 1 | ||
const b = 1 | ||
const c = a + b | ||
document.title = c.toString() | ||
// this.options = Object.assign({}, initialOptions, args) | ||
// this.changeElement(this.options.element) | ||
} | ||
|
||
// connect (videURL, audioURL, options, localStream) { | ||
// this.disconnect() | ||
// | ||
// if (!this.iceServers) { | ||
// fetch(`${this.options.url}/api/getIceServers`) | ||
// .then(this.handleHttpErrors) | ||
// .then((res) => (res.json())) | ||
// .then((resp) => this.onReceiveGetIceServers(resp, videURL, audioURL, options, localStream)) | ||
// .catch((error) => this.onError(`getIceServers ${error}`)) | ||
// } else { | ||
// this.onReceiveGetIceServers(this.iceServers, videURL, audioURL, options, localStream); | ||
// } | ||
// } | ||
// | ||
// disconnect () { | ||
// if (this.element?.srcObject) { | ||
// this.element.srcObject.getTracks().forEach(track => { | ||
// track.stop() | ||
// this.element.srcObject.removeTrack(track) | ||
// }) | ||
// } | ||
// if (this.pc) { | ||
// fetch(`${this.options.url}/api/hangup?peerid=${this.pc.peerid}`) | ||
// .then(this.handleHttpErrors) | ||
// .catch((error) => this.onError(`hangup ${error}`)) | ||
// | ||
// try { | ||
// this.pc.close() | ||
// } | ||
// catch (e) { | ||
// console.log(`Failure close peer connection:${e}`) | ||
// } | ||
// this.pc = null | ||
// } | ||
// } | ||
// | ||
// private changeElement (ele: Element | string) { | ||
// if (typeof ele === 'string') { | ||
// const dom = document.querySelector(ele) | ||
// dom && (this.element = dom) | ||
// } else { | ||
// this.element = ele | ||
// } | ||
// } | ||
// | ||
// private handleHttpErrors (resp) { | ||
// if (!resp.ok) { | ||
// throw Error(resp.statusText) | ||
// } | ||
// return resp | ||
// } | ||
// | ||
// private onReceiveGetIceServers (iceServers, videourl, audiourl, options, stream) { | ||
// this.iceServers = iceServers; | ||
// this.pcConfig = iceServers || {"iceServers": [] }; | ||
// try { | ||
// this.createPeerConnection(); | ||
// | ||
// var callurl = this.srvurl + "/api/call?peerid=" + this.pc.peerid + "&url=" + encodeURIComponent(videourl); | ||
// if (audiourl) { | ||
// callurl += "&audiourl="+encodeURIComponent(audiourl); | ||
// } | ||
// if (options) { | ||
// callurl += "&options="+encodeURIComponent(options); | ||
// } | ||
// | ||
// if (stream) { | ||
// this.pc.addStream(stream); | ||
// } | ||
// | ||
// // clear early candidates | ||
// this.earlyCandidates.length = 0; | ||
// | ||
// // create Offer | ||
// this.pc.createOffer(this.mediaConstraints).then((sessionDescription) => { | ||
// console.log("Create offer:" + JSON.stringify(sessionDescription)); | ||
// | ||
// this.pc.setLocalDescription(sessionDescription) | ||
// .then(() => { | ||
// fetch(callurl, { method: "POST", body: JSON.stringify(sessionDescription) }) | ||
// .then(this.handleHttpErrors) | ||
// .then( (response) => (response.json()) ) | ||
// .catch( (error) => this.onError("call " + error )) | ||
// .then( (response) => this.onReceiveCall(response) ) | ||
// .catch( (error) => this.onError("call " + error )) | ||
// | ||
// }, (error: any) => { | ||
// console.log ("setLocalDescription error:" + JSON.stringify(error)); | ||
// }); | ||
// | ||
// }, (error: any) => { | ||
// alert("Create offer error: " + JSON.stringify(error)); | ||
// }); | ||
// | ||
// } catch (e) { | ||
// this.disconnect() | ||
// alert('connect error: ' + e) | ||
// } | ||
// } | ||
// | ||
// private onError(status: any) { | ||
// console.log(`onError:${status}`) | ||
// } | ||
// | ||
// private onReceiveCall(dataJson) { | ||
// console.log("offer: " + JSON.stringify(dataJson)); | ||
// var descr = new RTCSessionDescription(dataJson); | ||
// this.pc.setRemoteDescription(descr).then(() => { | ||
// console.log ("setRemoteDescription ok"); | ||
// while (this.earlyCandidates.length) { | ||
// var candidate = this.earlyCandidates.shift(); | ||
// this.addIceCandidate(this.pc.peerid, candidate); | ||
// } | ||
// | ||
// this.getIceCandidate() | ||
// }, (error) => { | ||
// console.log ("setRemoteDescription error:" + JSON.stringify(error)) | ||
// }) | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export default { | ||
text: 'hello world!' | ||
} | ||
import WebRTCStreamer from './core/webRTCStreamer' | ||
import './style' | ||
|
||
export default WebRTCStreamer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
body { | ||
background-color: red; | ||
display: flex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './foo.scss' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface WebRTCStreamerOptions { | ||
element: Element | string; | ||
url: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"//": "this file is here to make typescript happy when moduleResolution=node16+" | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const initialOptions = { | ||
} |