diff --git a/demo-ng-firestore/src/app/webrtc/firebase.provider.ts b/demo-ng-firestore/src/app/webrtc/firebase.provider.ts index bb2b86b..43bfe6f 100644 --- a/demo-ng-firestore/src/app/webrtc/firebase.provider.ts +++ b/demo-ng-firestore/src/app/webrtc/firebase.provider.ts @@ -213,8 +213,8 @@ export class FirebaseProvider { snapshot.forEach((doc) => { iceCandidates.push(doc.data()); - resolve(iceCandidates); }); + resolve(iceCandidates); }) .catch((error) => { reject(error); }); }); diff --git a/demo-ng-firestore/src/app/webrtc/webrtc.model.ts b/demo-ng-firestore/src/app/webrtc/webrtc.model.ts index 763bcc8..37ddede 100644 --- a/demo-ng-firestore/src/app/webrtc/webrtc.model.ts +++ b/demo-ng-firestore/src/app/webrtc/webrtc.model.ts @@ -18,7 +18,7 @@ export interface WebRTCRoom { export interface WebRTCOffer { sdp: any; - type: string; // e.g. "offer" + type: string; // e.g. "offer" or "answer" } export interface WebRTCIceCandidate { diff --git a/src/angular/index.ts b/src/angular/index.ts index 98d525a..f34b43f 100644 --- a/src/angular/index.ts +++ b/src/angular/index.ts @@ -1,5 +1,5 @@ import { Directive, NgModule } from '@angular/core'; -import { registerElement } from 'nativescript-angular/element-registry'; +import { registerElement } from '@nativescript/angular'; import { WebRTCView } from '../'; registerElement('WebRTCView', () => WebRTCView); diff --git a/src/index.d.ts b/src/index.d.ts index 589c5a3..71e01e5 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,7 +1,7 @@ export { IceConnectionState, IceServer, IceGatheringState, Quality, SignalingState, WebRTCDataChannelMessageType, WebRTCDataChannelState, WebRTCIceCandidate, WebRTCOptions, WebRTCSdp, WebRTCSdpType, WebRTCState } from './webrtc.common'; +import { View } from '@nativescript/core'; import { Common, Quality, WebRTCDataChannelMessageType, WebRTCIceCandidate, WebRTCOptions, WebRTCSdp } from './webrtc.common'; -import { View } from 'tns-core-modules/ui/core/view'; export declare class WebRTC extends Common { private webrtc; diff --git a/src/package.json b/src/package.json index 1aa2f3d..646b748 100644 --- a/src/package.json +++ b/src/package.json @@ -59,12 +59,13 @@ "@angular/platform-browser": "~8.0.0", "@angular/platform-browser-dynamic": "~8.0.0", "@angular/router": "~8.0.0", - "nativescript-angular": "~8.0.0", + "@angular/animations": "^12.0.5", + "@nativescript/angular": "^12.0.2", + "@nativescript/core": "^8.0.8", "prompt": "^1.0.0", "rimraf": "^2.6.2", "rxjs": "~6.3.3", "semver": "^5.5.0", - "tns-core-modules": "^6.0.7", "tns-platform-declarations": "^6.0.7", "tslint": "~5.4.3", "typescript": "~3.4.5", diff --git a/src/platforms/android/include.gradle b/src/platforms/android/include.gradle index 960bb78..8900e33 100644 --- a/src/platforms/android/include.gradle +++ b/src/platforms/android/include.gradle @@ -1,4 +1,4 @@ dependencies { - implementation 'org.webrtc:google-webrtc:1.0.30039' + implementation 'org.webrtc:google-webrtc:1.0.32006' implementation 'com.google.code.gson:gson:2.8.5' } diff --git a/src/platforms/ios/Podfile b/src/platforms/ios/Podfile index a076a2e..224fbe2 100644 --- a/src/platforms/ios/Podfile +++ b/src/platforms/ios/Podfile @@ -1,6 +1,6 @@ platform :ios, '10.0' pod 'GoogleWebRTC', '~> 1.1.29400' -pod 'FancyWebRTC', :git => 'https://github.com/triniwiz/fancy-webrtc-ios.git' +pod 'FancyWebRTC', :git => 'https://github.com/ksteuer/fancy-webrtc-ios.git' post_install do |installer| installer.pods_project.targets.each do |target| diff --git a/src/src/android/TNSRTCMediaDevices.ts b/src/src/android/TNSRTCMediaDevices.ts index d332c3a..82df065 100644 --- a/src/src/android/TNSRTCMediaDevices.ts +++ b/src/src/android/TNSRTCMediaDevices.ts @@ -1,4 +1,4 @@ -import * as app from 'tns-core-modules/application'; +import * as app from '@nativescript/core/application'; import { TNSRTCMediaStreamConstraints } from './TNSRTCMediaStreamConstraints'; import { TNSRTCMediaStream } from './TNSRTCMediaStream'; import { TNSMediaDevicesInfo } from '../core/TNSMediaDevicesInfo'; diff --git a/src/src/android/TNSRTCPeerConnection.ts b/src/src/android/TNSRTCPeerConnection.ts index 92c2222..f009b13 100644 --- a/src/src/android/TNSRTCPeerConnection.ts +++ b/src/src/android/TNSRTCPeerConnection.ts @@ -13,7 +13,7 @@ import { TNSRTCTrackEvent } from './'; import { TNSRTCPeerConnectionState } from '../core/TNSRTCPeerConnectionState'; -import * as utils from 'tns-core-modules/utils/utils'; +import * as utils from '@nativescript/core/utils'; declare var co; @@ -248,7 +248,7 @@ export class TNSRTCPeerConnection { } public setLocalDescription(sdp: TNSRTCSessionDescription): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const ref = new WeakRef(this); this.android.setLocalDescription(sdp.instance, new co.fitcom.fancywebrtc.FancyRTCPeerConnection.SdpSetListener({ onSuccess(): void { @@ -265,7 +265,7 @@ export class TNSRTCPeerConnection { } public setRemoteDescription(sdp: TNSRTCSessionDescription): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const ref = new WeakRef(this); this.android.setRemoteDescription(sdp.instance, new co.fitcom.fancywebrtc.FancyRTCPeerConnection.SdpSetListener({ onSuccess(): void { diff --git a/src/src/android/TNSRTCVideoTrack.ts b/src/src/android/TNSRTCVideoTrack.ts index a546294..c9931b2 100644 --- a/src/src/android/TNSRTCVideoTrack.ts +++ b/src/src/android/TNSRTCVideoTrack.ts @@ -22,7 +22,7 @@ export class TNSRTCVideoTrack extends TNSRTCMediaStreamTrack { } public applyConstraints(constraints: TNSMediaTrackConstraints): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const nativeMap = new java.util.HashMap(); if (constraints.facingMode) { nativeMap.put('facingMode', constraints.facingMode); diff --git a/src/src/base/TNSRTCDTMFSenderBase.ts b/src/src/base/TNSRTCDTMFSenderBase.ts index 362ad3c..34376ca 100644 --- a/src/src/base/TNSRTCDTMFSenderBase.ts +++ b/src/src/base/TNSRTCDTMFSenderBase.ts @@ -3,7 +3,7 @@ export abstract class TNSRTCDTMFSenderBase { constructor(sender) { } - public toneBuffer: string; + public get toneBuffer(): string { return undefined; } public abstract dispose(): void; diff --git a/src/src/base/TNSRTCIceCandidateBase.ts b/src/src/base/TNSRTCIceCandidateBase.ts index 05ba470..6cd7d81 100644 --- a/src/src/base/TNSRTCIceCandidateBase.ts +++ b/src/src/base/TNSRTCIceCandidateBase.ts @@ -1,11 +1,11 @@ export abstract class TNSRTCIceCandidateBase { _iceCandidate; - candidate: string; - sdp: string; - sdpMid: string | null; - sdpMLineIndex: number; - usernameFragment: string; - serverUrl: string; + get candidate(): string { return undefined; } + get sdp(): string { return undefined; } + get sdpMid(): string | null { return undefined; } + get sdpMLineIndex(): number { return undefined; } + get usernameFragment(): string { return undefined; } + get serverUrl(): string { return undefined; } constructor(sdp: string, sdpMid: string | null, sdpMLineIndex: number) { } diff --git a/src/src/base/TNSRTCIceServerBase.ts b/src/src/base/TNSRTCIceServerBase.ts index 97df183..930a05a 100644 --- a/src/src/base/TNSRTCIceServerBase.ts +++ b/src/src/base/TNSRTCIceServerBase.ts @@ -8,12 +8,12 @@ export abstract class TNSRTCIceServerBase { public abstract toWebRtc(): void; - public iceServer; + public get iceServer() { return undefined; } - public credentialType; + public get credentialType() { return undefined; } - public urls: Array; + public get urls(): Array { return undefined; } - public username: string; + public get username(): string { return undefined; } } diff --git a/src/src/base/TNSRTCMediaStreamTrackBase.ts b/src/src/base/TNSRTCMediaStreamTrackBase.ts index eddc56f..e27041b 100644 --- a/src/src/base/TNSRTCMediaStreamTrackBase.ts +++ b/src/src/base/TNSRTCMediaStreamTrackBase.ts @@ -1,15 +1,15 @@ export abstract class TNSRTCMediaStreamTrackBase { - public id: string; + public get id(): string { return undefined; } - public enabled: boolean; + public get enabled(): boolean { return undefined; } - public kind: string; + public get kind(): string { return undefined; } - public mute: boolean; + public get mute(): boolean { return undefined; } public abstract dispose(): void; - public readyState: string; + public get readyState(): string { return undefined; } constructor(mediaStreamTrack: any) { } diff --git a/src/src/base/TNSRTCRtpSenderBase.ts b/src/src/base/TNSRTCRtpSenderBase.ts index c54cd41..767d094 100644 --- a/src/src/base/TNSRTCRtpSenderBase.ts +++ b/src/src/base/TNSRTCRtpSenderBase.ts @@ -6,15 +6,15 @@ export abstract class TNSRTCRtpSenderBase { constructor(sender) { } - public dtmf: TNSRTCDTMFSenderBase; + public get dtmf(): TNSRTCDTMFSenderBase { return undefined; } - public id: string; + public get id(): string { return undefined; } public abstract dispose(): void; - public track: TNSRTCMediaStreamTrackBase; + public get track(): TNSRTCMediaStreamTrackBase { return undefined; } - public parameters: TNSRTCRtpParametersBase; + public get parameters(): TNSRTCRtpParametersBase { return undefined; } public abstract replaceTrack(track: TNSRTCMediaStreamTrackBase): void ; } diff --git a/src/src/base/TNSRTCRtpTransceiverBase.ts b/src/src/base/TNSRTCRtpTransceiverBase.ts index b1ffb5c..2a6cb3b 100644 --- a/src/src/base/TNSRTCRtpTransceiverBase.ts +++ b/src/src/base/TNSRTCRtpTransceiverBase.ts @@ -6,18 +6,17 @@ export abstract class TNSRTCRtpTransceiverBase { constructor(transceiver) { } - public direction: TNSRTCRtpTransceiverDirection; + public get direction(): TNSRTCRtpTransceiverDirection { return undefined; } - public currentDirection: TNSRTCRtpTransceiverDirection; + public get currentDirection(): TNSRTCRtpTransceiverDirection { return undefined; } - public mid: string; + public get mid(): string { return undefined; } - public receiver: TNSRTCRtpReceiverBase; + public get receiver(): TNSRTCRtpReceiverBase { return undefined; } - public sender: TNSRTCRtpSenderBase; + public get sender(): TNSRTCRtpSenderBase { return undefined; } - - public stopped: boolean; + public get stopped(): boolean { return undefined; } public abstract stop(): void; } diff --git a/src/src/base/TNSRTCTrackEventBase.ts b/src/src/base/TNSRTCTrackEventBase.ts index d44ff95..8249b5c 100644 --- a/src/src/base/TNSRTCTrackEventBase.ts +++ b/src/src/base/TNSRTCTrackEventBase.ts @@ -4,10 +4,10 @@ import { TNSRTCRtpReceiverBase } from './TNSRTCRtpReceiverBase'; import { TNSRTCRtpTransceiverBase } from './TNSRTCRtpTransceiverBase'; export class TNSRTCTrackEventBase { - mediaTrack: TNSRTCMediaStreamTrackBase; - transceiver: TNSRTCRtpTransceiverBase; - receiver?: TNSRTCRtpReceiverBase; - streams?: Array; + public get mediaTrack(): TNSRTCMediaStreamTrackBase { return undefined; } + public get transceiver(): TNSRTCRtpTransceiverBase { return undefined; } + public get receiver(): TNSRTCRtpReceiverBase { return undefined; } + public get streams(): Array { return undefined; } constructor(event) { } diff --git a/src/src/ios/TNSRTCPeerConnection.ts b/src/src/ios/TNSRTCPeerConnection.ts index 8c9c803..475b115 100644 --- a/src/src/ios/TNSRTCPeerConnection.ts +++ b/src/src/ios/TNSRTCPeerConnection.ts @@ -254,7 +254,7 @@ export class TNSRTCPeerConnection { } public setLocalDescription(sdp: TNSRTCSessionDescription): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.ios.localDescriptionWithSdpListener(sdp.instance, (error) => { if (error) { reject(error); @@ -266,7 +266,7 @@ export class TNSRTCPeerConnection { } public setRemoteDescription(sdp: TNSRTCSessionDescription): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.ios.remoteDescriptionWithSdpListener(sdp.instance, (error) => { if (error) { reject(error); diff --git a/src/src/ios/TNSRTCVideoTrack.ts b/src/src/ios/TNSRTCVideoTrack.ts index 37dafc7..de0ed5f 100644 --- a/src/src/ios/TNSRTCVideoTrack.ts +++ b/src/src/ios/TNSRTCVideoTrack.ts @@ -22,7 +22,7 @@ export class TNSRTCVideoTrack extends TNSRTCMediaStreamTrack { } public applyConstraints(constraints: TNSMediaTrackConstraints): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const obj = {}; if (constraints.facingMode) { obj['facingMode'] = constraints.facingMode; diff --git a/src/webrtc.android.ts b/src/webrtc.android.ts index 2123b47..d945e06 100644 --- a/src/webrtc.android.ts +++ b/src/webrtc.android.ts @@ -12,12 +12,11 @@ import { WebRTCSdpType } from './webrtc.common'; -import { fromObject } from 'tns-core-modules/data/observable'; -import { View } from 'tns-core-modules/ui/core/view'; -import { ad } from 'tns-core-modules/utils/utils'; +import { fromObject,View } from '@nativescript/core'; import * as permissions from 'nativescript-permissions'; import { TNSRTCMediaStream, TNSRTCMediaStreamTrack } from './src/android'; -import * as app from 'tns-core-modules/application'; +import { ad } from '@nativescript/core/utils'; +import { AndroidApplication, AndroidActivityResultEventData, android as androidApp } from '@nativescript/core/application' export * from './src/android'; export { @@ -374,7 +373,7 @@ export class WebRTC extends Common { ); } - private static _callbackFn(args: app.AndroidActivityResultEventData) { + private static _callbackFn(args: AndroidActivityResultEventData) { co.fitcom.fancywebrtc.FancyRTCApplicationHelper.getInstance().handleResult(args.requestCode, args.resultCode, args.intent); } @@ -385,8 +384,8 @@ export class WebRTC extends Common { if (!this.callback) { this.callback = this._callbackFn.bind(this); } - app.android.off(app.AndroidApplication.activityResultEvent, this.callback); - app.android.on(app.AndroidApplication.activityResultEvent, this.callback); + androidApp.off(AndroidApplication.activityResultEvent, this.callback); + androidApp.on(AndroidApplication.activityResultEvent, this.callback); } public dataChannelSend( diff --git a/src/webrtc.common.ts b/src/webrtc.common.ts index 3dc2972..70d6856 100644 --- a/src/webrtc.common.ts +++ b/src/webrtc.common.ts @@ -1,4 +1,4 @@ -import { Observable } from 'tns-core-modules/data/observable'; +import { Observable } from '@nativescript/core'; export class Common extends Observable { defaultServers: Array = [ diff --git a/src/webrtc.ios.ts b/src/webrtc.ios.ts index 86132b7..3c58e57 100644 --- a/src/webrtc.ios.ts +++ b/src/webrtc.ios.ts @@ -11,8 +11,8 @@ import { WebRTCSdp, WebRTCSdpType } from './webrtc.common'; -import { layout, View } from 'tns-core-modules/ui/core/view'; -import { fromObject } from 'tns-core-modules/data/observable'; +import { layout } from '@nativescript/core/utils'; +import { fromObject, View } from '@nativescript/core'; import './async-await'; import { TNSRTCMediaStream, TNSRTCMediaStreamTrack } from './src/ios'; @@ -132,7 +132,7 @@ export class WebRTC extends Common { } private static requestCameraPermission() { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { AVCaptureDevice.requestAccessForMediaTypeCompletionHandler( AVMediaTypeVideo, granted => { @@ -147,7 +147,7 @@ export class WebRTC extends Common { } private static requestAudioPermission() { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { AVCaptureDevice.requestAccessForMediaTypeCompletionHandler( AVMediaTypeAudio, granted => { @@ -162,7 +162,7 @@ export class WebRTC extends Common { } public static requestPermissions(explanation?: string): Promise { - return new Promise(async (resolve, reject) => { + return new Promise(async (resolve, reject) => { try { await WebRTC.requestCameraPermission(); await WebRTC.requestAudioPermission();