├── src
├── assets
│ └── .gitkeep
├── app
│ ├── app.component.scss
│ ├── pages
│ │ ├── create-room
│ │ │ ├── create-room.component.scss
│ │ │ ├── create-room.component.html
│ │ │ ├── create-room.component.spec.ts
│ │ │ └── create-room.component.ts
│ │ ├── enter-room
│ │ │ ├── enter-room.component.scss
│ │ │ ├── enter-room.component.html
│ │ │ ├── enter-room.component.spec.ts
│ │ │ └── enter-room.component.ts
│ │ └── room
│ │ │ ├── room.component.html
│ │ │ ├── room.component.spec.ts
│ │ │ ├── room.component.scss
│ │ │ └── room.component.ts
│ ├── domain
│ │ ├── room.ts
│ │ └── room.access.ts
│ ├── app.component.html
│ ├── app.component.ts
│ ├── services
│ │ ├── capture-audio.service.ts
│ │ └── capture-screen.service.ts
│ ├── app-routing.module.ts
│ ├── app.component.spec.ts
│ └── app.module.ts
├── favicon.ico
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── styles.scss
├── tsconfig.app.json
├── tsconfig.spec.json
├── index.html
├── tslint.json
├── main.ts
├── browserslist
├── test.ts
├── karma.conf.js
└── polyfills.ts
├── e2e
├── tsconfig.e2e.json
├── src
│ ├── app.po.ts
│ └── app.e2e-spec.ts
└── protractor.conf.js
├── .editorconfig
├── tsconfig.json
├── .gitignore
├── LICENSE
├── package.json
├── tslint.json
├── README.md
└── angular.json
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/pages/create-room/create-room.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/pages/enter-room/enter-room.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lucassklp/ng-rtc-call-app/HEAD/src/favicon.ico
--------------------------------------------------------------------------------
/src/app/domain/room.ts:
--------------------------------------------------------------------------------
1 | export type Room = {
2 | name: string;
3 | password: string;
4 | }
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/app/domain/room.access.ts:
--------------------------------------------------------------------------------
1 | export type RoomAccess = {
2 | name: string;
3 | password: string;
4 | nickname: string;
5 | }
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "types": []
6 | },
7 | "exclude": [
8 | "test.ts",
9 | "**/*.spec.ts"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss']
7 | })
8 | export class AppComponent {
9 | title = 'ng-rtc-call-app';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/pages/room/room.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get(browser.baseUrl) as Promise;
6 | }
7 |
8 | getTitleText() {
9 | return element(by.css('app-root h1')).getText() as Promise;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "test.ts",
12 | "polyfills.ts"
13 | ],
14 | "include": [
15 | "**/*.spec.ts",
16 | "**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/services/capture-audio.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | @Injectable({
4 | providedIn: 'root'
5 | })
6 | export class CaptureAudioService {
7 |
8 | constructor() { }
9 |
10 | capture(): Promise {
11 | return navigator.mediaDevices.getUserMedia({
12 | audio: true
13 | });
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NgRtcCallApp
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | #
5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
6 |
7 | > 0.5%
8 | last 2 versions
9 | Firefox ESR
10 | not dead
11 | not IE 9-11
--------------------------------------------------------------------------------
/src/app/pages/create-room/create-room.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "module": "es2015",
9 | "moduleResolution": "node",
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "importHelpers": true,
13 | "target": "es5",
14 | "typeRoots": [
15 | "node_modules/@types"
16 | ],
17 | "lib": [
18 | "es2018",
19 | "dom"
20 | ]
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app/services/capture-screen.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | @Injectable({
4 | providedIn: 'root'
5 | })
6 | export class CaptureScreenService {
7 |
8 | constructor() { }
9 |
10 | capture(): Promise{
11 | let nav = navigator;
12 | if (nav.getDisplayMedia) {
13 | return nav.getDisplayMedia({video: true});
14 | } else if (nav.mediaDevices.getDisplayMedia) {
15 | return nav.mediaDevices.getDisplayMedia({video: true});
16 | } else {
17 | return nav.mediaDevices.getUserMedia({video: {mediaSource: 'screen'}});
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/pages/enter-room/enter-room.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 | import { browser, logging } from 'protractor';
3 |
4 | describe('workspace-project App', () => {
5 | let page: AppPage;
6 |
7 | beforeEach(() => {
8 | page = new AppPage();
9 | });
10 |
11 | it('should display welcome message', () => {
12 | page.navigateTo();
13 | expect(page.getTitleText()).toEqual('Welcome to ng-rtc-call-app!');
14 | });
15 |
16 | afterEach(async () => {
17 | // Assert that there are no errors emitted from the browser
18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19 | expect(logs).not.toContain(jasmine.objectContaining({
20 | level: logging.Level.SEVERE,
21 | }));
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/src/app/pages/room/room.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { RoomComponent } from './room.component';
4 |
5 | describe('RoomComponent', () => {
6 | let component: RoomComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ RoomComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(RoomComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { CreateRoomComponent } from './pages/create-room/create-room.component';
4 | import { EnterRoomComponent } from './pages/enter-room/enter-room.component';
5 | import { RoomComponent } from './pages/room/room.component';
6 |
7 | const routes: Routes = [
8 | {
9 | path: 'create-room',
10 | component: CreateRoomComponent
11 | },
12 | {
13 | path: 'enter-room',
14 | component: EnterRoomComponent
15 | },
16 | {
17 | path: 'room/:id',
18 | component: RoomComponent
19 | },
20 | ];
21 |
22 | @NgModule({
23 | imports: [RouterModule.forRoot(routes)],
24 | exports: [RouterModule]
25 | })
26 | export class AppRoutingModule { }
27 |
--------------------------------------------------------------------------------
/src/app/pages/enter-room/enter-room.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { EnterRoomComponent } from './enter-room.component';
4 |
5 | describe('EnterRoomComponent', () => {
6 | let component: EnterRoomComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ EnterRoomComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(EnterRoomComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/pages/create-room/create-room.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { CreateRoomComponent } from './create-room.component';
4 |
5 | describe('CreateRoomComponent', () => {
6 | let component: CreateRoomComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ CreateRoomComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(CreateRoomComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # profiling files
12 | chrome-profiler-events.json
13 | speed-measure-plugin.json
14 |
15 | # IDEs and editors
16 | /.idea
17 | .project
18 | .classpath
19 | .c9/
20 | *.launch
21 | .settings/
22 | *.sublime-workspace
23 |
24 | # IDE - VSCode
25 | .vscode/*
26 | !.vscode/settings.json
27 | !.vscode/tasks.json
28 | !.vscode/launch.json
29 | !.vscode/extensions.json
30 | .history/*
31 |
32 | # misc
33 | /.sass-cache
34 | /connect.lock
35 | /coverage
36 | /libpeerconnection.log
37 | npm-debug.log
38 | yarn-error.log
39 | testem.log
40 | /typings
41 |
42 | # System Files
43 | .DS_Store
44 | Thumbs.db
45 |
46 | #Package lock
47 | package-lock.json
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | firebase: {
8 | apiKey: 'AIzaSyCyzKauqAXLWFOJpXd3Ah8bdx0BDCdicVs',
9 | authDomain: 'chat-5aa35.firebaseapp.com',
10 | databaseURL: 'https://chat-5aa35.firebaseio.com',
11 | projectId: 'chat-5aa35',
12 | storageBucket: 'chat-5aa35.appspot.com',
13 | messagingSenderId: '328802266059'
14 | }
15 | };
16 |
17 | /*
18 | * For easier debugging in development mode, you can import the following file
19 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
20 | *
21 | * This import should be commented out in production mode because it will have a negative impact
22 | * on performance if an error is thrown.
23 | */
24 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
25 |
--------------------------------------------------------------------------------
/src/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage/ng-rtc-call-app'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Lucas Simas
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/app/pages/create-room/create-room.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms';
3 | import { AngularFirestore } from '@angular/fire/firestore';
4 | import { Room } from 'src/app/domain/room';
5 |
6 | @Component({
7 | selector: 'app-create-room',
8 | templateUrl: './create-room.component.html',
9 | styleUrls: ['./create-room.component.scss']
10 | })
11 | export class CreateRoomComponent implements OnInit {
12 |
13 | form: FormGroup
14 | constructor(fb: FormBuilder, private afs: AngularFirestore) {
15 | this.form = fb.group({
16 | 'roomName': ['', Validators.required],
17 | 'password': ['', Validators.required]
18 | })
19 | }
20 |
21 | ngOnInit() {
22 | }
23 |
24 |
25 | createRoom(){
26 | console.log('Creating the room...')
27 |
28 | let room: Room = {
29 | name: this.form.controls['roomName'].value,
30 | password: this.form.controls['password'].value
31 | }
32 |
33 | console.log(room);
34 |
35 | this.afs.collection('room').add(room).then(x => {
36 |
37 | });
38 |
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | imports: [
9 | RouterTestingModule
10 | ],
11 | declarations: [
12 | AppComponent
13 | ],
14 | }).compileComponents();
15 | }));
16 |
17 | it('should create the app', () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.debugElement.componentInstance;
20 | expect(app).toBeTruthy();
21 | });
22 |
23 | it(`should have as title 'ng-rtc-call-app'`, () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | const app = fixture.debugElement.componentInstance;
26 | expect(app.title).toEqual('ng-rtc-call-app');
27 | });
28 |
29 | it('should render title in a h1 tag', () => {
30 | const fixture = TestBed.createComponent(AppComponent);
31 | fixture.detectChanges();
32 | const compiled = fixture.debugElement.nativeElement;
33 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to ng-rtc-call-app!');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/src/app/pages/enter-room/enter-room.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { FormGroup, Validators, FormBuilder } from '@angular/forms';
3 | import { AngularFirestore } from '@angular/fire/firestore';
4 | import { RoomAccess } from 'src/app/domain/room.access';
5 | import { Router } from '@angular/router';
6 |
7 | @Component({
8 | selector: 'app-enter-room',
9 | templateUrl: './enter-room.component.html',
10 | styleUrls: ['./enter-room.component.scss']
11 | })
12 | export class EnterRoomComponent {
13 |
14 | form: FormGroup;
15 | constructor(fb: FormBuilder, private afs: AngularFirestore, private router: Router) {
16 | this.form = fb.group({
17 | 'roomName': ['', Validators.required],
18 | 'password': ['', Validators.required],
19 | 'nickname': ['', Validators.required]
20 | })
21 | }
22 |
23 | enterRoom(){
24 | let roomAccess: RoomAccess = {
25 | name: this.form.controls['roomName'].value,
26 | password: this.form.controls['password'].value,
27 | nickname: this.form.controls['nickname'].value,
28 | }
29 |
30 | const rooms = this.afs.collection('rooms', r => r.where('name', '==', roomAccess.name)
31 | .where('password', '==', roomAccess.password))
32 |
33 | rooms.get().subscribe(x => {
34 | let id = x.docs[0].id;
35 | this.router.navigate([`room/${id}`]);
36 | });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/app/pages/room/room.component.scss:
--------------------------------------------------------------------------------
1 | .slidecontainer {
2 | width: 100%; /* Width of the outside container */
3 | }
4 |
5 | /* The slider itself */
6 | .slider {
7 | -webkit-appearance: none; /* Override default CSS styles */
8 | appearance: none;
9 | width: 100%; /* Full-width */
10 | height: 25px; /* Specified height */
11 | background: #d3d3d3; /* Grey background */
12 | outline: none; /* Remove outline */
13 | opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
14 | -webkit-transition: .2s; /* 0.2 seconds transition on hover */
15 | transition: opacity .2s;
16 | }
17 |
18 | /* Mouse-over effects */
19 | .slider:hover {
20 | opacity: 1; /* Fully shown on mouse-over */
21 | }
22 |
23 | /* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
24 | .slider::-webkit-slider-thumb {
25 | -webkit-appearance: none; /* Override default look */
26 | appearance: none;
27 | width: 25px; /* Set a specific slider handle width */
28 | height: 25px; /* Slider handle height */
29 | background: #4CAF50; /* Green background */
30 | cursor: pointer; /* Cursor on hover */
31 | }
32 |
33 | .slider::-moz-range-thumb {
34 | width: 25px; /* Set a specific slider handle width */
35 | height: 25px; /* Slider handle height */
36 | background: #4CAF50; /* Green background */
37 | cursor: pointer; /* Cursor on hover */
38 | }
39 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ng-rtc-call-app",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve --port=6200",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~7.2.0",
15 | "@angular/common": "~7.2.0",
16 | "@angular/compiler": "~7.2.0",
17 | "@angular/core": "~7.2.0",
18 | "@angular/fire": "^5.1.1",
19 | "@angular/forms": "~7.2.0",
20 | "@angular/platform-browser": "~7.2.0",
21 | "@angular/platform-browser-dynamic": "~7.2.0",
22 | "@angular/router": "~7.2.0",
23 | "@hackages/ngxerrors": "^7.0.0",
24 | "@types/dom-mediacapture-record": "^1.0.1",
25 | "core-js": "^2.5.4",
26 | "firebase": "^5.8.4",
27 | "rxjs": "~6.3.3",
28 | "tslib": "^1.9.0",
29 | "zone.js": "~0.8.26"
30 | },
31 | "devDependencies": {
32 | "@angular-devkit/build-angular": "~0.13.0",
33 | "@angular/cli": "~7.3.1",
34 | "@angular/compiler-cli": "~7.2.0",
35 | "@angular/language-service": "~7.2.0",
36 | "@types/node": "~8.9.4",
37 | "@types/jasmine": "~2.8.8",
38 | "@types/jasminewd2": "~2.0.3",
39 | "codelyzer": "~4.5.0",
40 | "jasmine-core": "~2.99.1",
41 | "jasmine-spec-reporter": "~4.2.1",
42 | "karma": "~3.1.1",
43 | "karma-chrome-launcher": "~2.2.0",
44 | "karma-coverage-istanbul-reporter": "~2.0.1",
45 | "karma-jasmine": "~1.1.2",
46 | "karma-jasmine-html-reporter": "^0.2.2",
47 | "protractor": "~5.4.0",
48 | "ts-node": "~7.0.0",
49 | "tslint": "~5.11.0",
50 | "typescript": "~3.2.2"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppRoutingModule } from './app-routing.module';
5 | import { AppComponent } from './app.component';
6 |
7 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'
8 | import { NgxErrorsModule } from '@hackages/ngxerrors';
9 |
10 | import { AngularFireModule } from '@angular/fire';
11 | import { AngularFirestoreModule } from '@angular/fire/firestore';
12 | import { AngularFireStorageModule } from '@angular/fire/storage';
13 | import { AngularFireAuthModule } from '@angular/fire/auth';
14 | import { environment } from '../environments/environment';
15 | import { CreateRoomComponent } from './pages/create-room/create-room.component';
16 | import { RoomComponent } from './pages/room/room.component';
17 | import { EnterRoomComponent } from './pages/enter-room/enter-room.component';
18 | import { CaptureAudioService } from './services/capture-audio.service';
19 | import { CaptureScreenService } from './services/capture-screen.service';
20 |
21 |
22 | @NgModule({
23 | declarations: [
24 | AppComponent,
25 | CreateRoomComponent,
26 | RoomComponent,
27 | EnterRoomComponent
28 | ],
29 | imports: [
30 | BrowserModule,
31 | AppRoutingModule,
32 | FormsModule,
33 | ReactiveFormsModule,
34 | NgxErrorsModule,
35 | AngularFireModule.initializeApp(environment.firebase),
36 | AngularFirestoreModule, // imports firebase/firestore, only needed for database features
37 | AngularFireAuthModule, // imports firebase/auth, only needed for auth features,
38 | AngularFireStorageModule // imports firebase/storage only needed for storage features
39 | ],
40 | providers: [
41 | CaptureAudioService,
42 | CaptureScreenService
43 | ],
44 | bootstrap: [AppComponent]
45 | })
46 | export class AppModule { }
47 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rulesDirectory": [
4 | "codelyzer"
5 | ],
6 | "rules": {
7 | "array-type": false,
8 | "arrow-parens": false,
9 | "deprecation": {
10 | "severity": "warn"
11 | },
12 | "import-blacklist": [
13 | true,
14 | "rxjs/Rx"
15 | ],
16 | "interface-name": false,
17 | "max-classes-per-file": false,
18 | "max-line-length": [
19 | true,
20 | 140
21 | ],
22 | "member-access": false,
23 | "member-ordering": [
24 | true,
25 | {
26 | "order": [
27 | "static-field",
28 | "instance-field",
29 | "static-method",
30 | "instance-method"
31 | ]
32 | }
33 | ],
34 | "no-consecutive-blank-lines": false,
35 | "no-console": [
36 | true,
37 | "debug",
38 | "info",
39 | "time",
40 | "timeEnd",
41 | "trace"
42 | ],
43 | "no-empty": false,
44 | "no-inferrable-types": [
45 | true,
46 | "ignore-params"
47 | ],
48 | "no-non-null-assertion": true,
49 | "no-redundant-jsdoc": true,
50 | "no-switch-case-fall-through": true,
51 | "no-use-before-declare": true,
52 | "no-var-requires": false,
53 | "object-literal-key-quotes": [
54 | true,
55 | "as-needed"
56 | ],
57 | "object-literal-sort-keys": false,
58 | "ordered-imports": false,
59 | "quotemark": [
60 | true,
61 | "single"
62 | ],
63 | "trailing-comma": false,
64 | "no-output-on-prefix": true,
65 | "use-input-property-decorator": true,
66 | "use-output-property-decorator": true,
67 | "use-host-property-decorator": true,
68 | "no-input-rename": true,
69 | "no-output-rename": true,
70 | "use-life-cycle-interface": true,
71 | "use-pipe-transform-interface": true,
72 | "component-class-suffix": true,
73 | "directive-class-suffix": true
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/app/pages/room/room.component.ts:
--------------------------------------------------------------------------------
1 | ///
2 | import { Component, OnInit } from '@angular/core';
3 | import { ActivatedRoute } from '@angular/router';
4 | import { CaptureAudioService } from 'src/app/services/capture-audio.service';
5 | import { CaptureScreenService } from 'src/app/services/capture-screen.service';
6 |
7 | @Component({
8 | selector: 'app-room',
9 | templateUrl: './room.component.html',
10 | styleUrls: ['./room.component.scss']
11 | })
12 | export class RoomComponent implements OnInit {
13 |
14 | id: string;
15 | gainNode: GainNode;
16 |
17 | constructor(private route: ActivatedRoute,
18 | private audioService: CaptureAudioService,
19 | private screenService: CaptureScreenService) { }
20 |
21 |
22 | changeVolume(value: number) {
23 | this.gainNode.gain.value = value;
24 | }
25 |
26 | ngOnInit() {
27 | this.id = this.route.snapshot.paramMap.get('id');
28 | console.log(`You are in the room with id ${this.id}`)
29 |
30 | let audioPromise = this.audioService.capture()
31 |
32 | audioPromise.then(audioStream => {
33 | //O script abaixo é responsável por processar audio streams..
34 | //Nesse exemplo, eu estou reproduzindo minha propria voz no browser
35 | //(ele captura o áudio do mic e simplesmente reproduz)
36 | const audioContext = new AudioContext();
37 | this.gainNode = audioContext.createGain();
38 | this.gainNode.connect(audioContext.destination);
39 |
40 | const microphoneStream = audioContext.createMediaStreamSource(audioStream);
41 | microphoneStream.connect(this.gainNode);
42 | })
43 |
44 | audioPromise.catch((x) => {
45 | console.log('Not Worked');
46 | console.log(x);
47 | });
48 |
49 | //Script para captura de tela
50 | this.screenService.capture().then(stream => {
51 | let mediaRecorder = new MediaRecorder(stream, {mimeType: 'video/webm'});
52 | let video = document.querySelector('video');
53 | video.srcObject = stream;
54 | video.onloadedmetadata = function() {
55 | video.play();
56 | };
57 | mediaRecorder.start(10);
58 | });
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NgRtcCallApp
2 |
3 | ### This application was made for learning purpose.
4 |
5 | **What this application does? (or what it is intended to do)**
6 |
7 | - An individual chat between two person
8 |
9 | - A chat group between many people
10 |
11 | - The chat can be understood as: text, audio (optional), video (optional), and screen recording (optional) communication
12 |
13 | ### Articles used to make this application
14 |
15 | I will put here all articles that helped me to develop and all doubts that I faced when I was developing it.
16 |
17 | #### Articles
18 | - https://blog.sessionstack.com/how-javascript-works-webrtc-and-the-mechanics-of-peer-to-peer-connectivity-87cc56c1d0ab
19 | - https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/
20 | - https://www.html5rocks.com/en/tutorials/webrtc/basics/
21 | - https://w3c.github.io/webrtc-pc/#simple-peer-to-peer-example
22 | - https://www.webrtc-experiment.com/ and https://github.com/muaz-khan/WebRTC-Experiment
23 | - https://webrtc.github.io/samples/
24 | - https://www.tutorialspoint.com/webrtc/index.htm
25 | - https://codelabs.developers.google.com/codelabs/webrtc-web/#0
26 |
27 | #### Doubts
28 | - Where can I find STUN + TURN servers?
29 | - https://gist.github.com/yetithefoot/7592580
30 | - https://gist.github.com/mondain/b0ec1cf5f60ae726202e
31 |
32 |
33 | # NgRtcCallApp (How to build)
34 |
35 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.1.
36 |
37 | ## Development server
38 |
39 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
40 |
41 | ## Code scaffolding
42 |
43 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
44 |
45 | ## Build
46 |
47 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
48 |
49 | ## Running unit tests
50 |
51 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
52 |
53 | ## Running end-to-end tests
54 |
55 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
56 |
57 | ## Further help
58 |
59 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
60 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags.ts';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 |
61 | /***************************************************************************************************
62 | * APPLICATION IMPORTS
63 | */
64 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "ng-rtc-call-app": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {
12 | "@schematics/angular:component": {
13 | "style": "sass"
14 | }
15 | },
16 | "architect": {
17 | "build": {
18 | "builder": "@angular-devkit/build-angular:browser",
19 | "options": {
20 | "outputPath": "dist/ng-rtc-call-app",
21 | "index": "src/index.html",
22 | "main": "src/main.ts",
23 | "polyfills": "src/polyfills.ts",
24 | "tsConfig": "src/tsconfig.app.json",
25 | "assets": [
26 | "src/favicon.ico",
27 | "src/assets"
28 | ],
29 | "styles": [
30 | "src/styles.scss"
31 | ],
32 | "scripts": [],
33 | "es5BrowserSupport": true
34 | },
35 | "configurations": {
36 | "production": {
37 | "fileReplacements": [
38 | {
39 | "replace": "src/environments/environment.ts",
40 | "with": "src/environments/environment.prod.ts"
41 | }
42 | ],
43 | "optimization": true,
44 | "outputHashing": "all",
45 | "sourceMap": false,
46 | "extractCss": true,
47 | "namedChunks": false,
48 | "aot": true,
49 | "extractLicenses": true,
50 | "vendorChunk": false,
51 | "buildOptimizer": true,
52 | "budgets": [
53 | {
54 | "type": "initial",
55 | "maximumWarning": "2mb",
56 | "maximumError": "5mb"
57 | }
58 | ]
59 | }
60 | }
61 | },
62 | "serve": {
63 | "builder": "@angular-devkit/build-angular:dev-server",
64 | "options": {
65 | "browserTarget": "ng-rtc-call-app:build"
66 | },
67 | "configurations": {
68 | "production": {
69 | "browserTarget": "ng-rtc-call-app:build:production"
70 | }
71 | }
72 | },
73 | "extract-i18n": {
74 | "builder": "@angular-devkit/build-angular:extract-i18n",
75 | "options": {
76 | "browserTarget": "ng-rtc-call-app:build"
77 | }
78 | },
79 | "test": {
80 | "builder": "@angular-devkit/build-angular:karma",
81 | "options": {
82 | "main": "src/test.ts",
83 | "polyfills": "src/polyfills.ts",
84 | "tsConfig": "src/tsconfig.spec.json",
85 | "karmaConfig": "src/karma.conf.js",
86 | "styles": [
87 | "src/styles.scss"
88 | ],
89 | "scripts": [],
90 | "assets": [
91 | "src/favicon.ico",
92 | "src/assets"
93 | ]
94 | }
95 | },
96 | "lint": {
97 | "builder": "@angular-devkit/build-angular:tslint",
98 | "options": {
99 | "tsConfig": [
100 | "src/tsconfig.app.json",
101 | "src/tsconfig.spec.json"
102 | ],
103 | "exclude": [
104 | "**/node_modules/**"
105 | ]
106 | }
107 | }
108 | }
109 | },
110 | "ng-rtc-call-app-e2e": {
111 | "root": "e2e/",
112 | "projectType": "application",
113 | "prefix": "",
114 | "architect": {
115 | "e2e": {
116 | "builder": "@angular-devkit/build-angular:protractor",
117 | "options": {
118 | "protractorConfig": "e2e/protractor.conf.js",
119 | "devServerTarget": "ng-rtc-call-app:serve"
120 | },
121 | "configurations": {
122 | "production": {
123 | "devServerTarget": "ng-rtc-call-app:serve:production"
124 | }
125 | }
126 | },
127 | "lint": {
128 | "builder": "@angular-devkit/build-angular:tslint",
129 | "options": {
130 | "tsConfig": "e2e/tsconfig.e2e.json",
131 | "exclude": [
132 | "**/node_modules/**"
133 | ]
134 | }
135 | }
136 | }
137 | }
138 | },
139 | "defaultProject": "ng-rtc-call-app"
140 | }
--------------------------------------------------------------------------------