openvidu-testapp: allow force publishing independently of role

pull/550/head
pabloFuente 2020-10-07 12:13:55 +02:00
parent b479cb2bac
commit b1801ae33c
4 changed files with 32 additions and 6 deletions

View File

@ -108,7 +108,8 @@
</div>
<div id="record-div">
<mat-checkbox class="checkbox-form" [(ngModel)]="tokenOptions.record" id="record-checkbox">Record</mat-checkbox>
<mat-checkbox class="checkbox-form" [(ngModel)]="tokenOptions.record" id="record-checkbox">Record
</mat-checkbox>
</div>
<label class="label">Token</label>
@ -117,6 +118,13 @@
<input matInput placeholder="Custom token" type="text" [(ngModel)]="customToken">
</mat-form-field>
</div>
<div id="force-publishing-div">
<mat-checkbox class="checkbox-form" [(ngModel)]="forcePublishing" id="force-publishing-checkbox">Force
publishing
</mat-checkbox>
</div>
</mat-dialog-content>
</div>
</div>
@ -124,6 +132,6 @@
<mat-dialog-actions>
<button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button>
<button id="save-btn" mat-button
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, tokenOptions: generateTokenOptions(), customToken: customToken}">SAVE</button>
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, tokenOptions: generateTokenOptions()}">SAVE</button>
</mat-dialog-actions>
</div>

View File

@ -14,6 +14,7 @@ export class SessionPropertiesDialogComponent {
turnConf: string;
manualTurnConf: RTCIceServer = { urls: [] };
customToken: string;
forcePublishing: boolean = false;
tokenOptions: TokenOptions;
filterName = 'GStreamerFilter';
@ -29,8 +30,9 @@ export class SessionPropertiesDialogComponent {
this.sessionProperties = data.sessionProperties;
this.turnConf = data.turnConf;
this.manualTurnConf = data.manualTurnConf;
this.tokenOptions = data.tokenOptions;
this.customToken = data.customToken;
this.forcePublishing = data.forcePublishing;
this.tokenOptions = data.tokenOptions;
}
enumToArray(enumerator: any) {

View File

@ -107,6 +107,9 @@
<div class="session-card-inner">
<div class="session-title">{{sessionName}}</div>
<div class="session-actions">
<button *ngIf="republishPossible" class="republish-error-btn" (click)="republishAfterError()" title="Re publish">
<mat-icon aria-label="Re publish video" style="font-size: 20px">linked_camera</mat-icon>
</button>
<button class="message-btn" (click)="sendMessage()" title="Broadcast message">
<mat-icon aria-label="Send message button" style="font-size: 20px">chat</mat-icon>
</button>

View File

@ -127,6 +127,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
turnConf = 'auto';
manualTurnConf: RTCIceServer = { urls: [] };
customToken: string;
forcePublishing: boolean;
tokenOptions: TokenOptions = {
role: OpenViduRole.PUBLISHER,
record: true,
@ -141,6 +142,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
events: OpenViduEvent[] = [];
republishPossible: boolean = false;
openviduError: any;
constructor(
@ -234,7 +236,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
.then(() => {
this.changeDetector.detectChanges();
if (this.publishTo && this.session.capabilities.publish) {
if (this.publishTo && this.session.capabilities.publish || this.forcePublishing) {
// this.asyncInitPublisher();
this.syncInitPublisher();
}
@ -493,9 +495,14 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.publisher.subscribeToRemote();
}
this.session.publish(this.publisher).catch((error: OpenViduError) => {
this.session.publish(this.publisher).then(() => {
this.republishPossible = false;
}).catch((error: OpenViduError) => {
console.error(error);
alert(error.name + ": " + error.message);
this.republishPossible = true;
this.session.unpublish(this.publisher);
delete this.publisher;
});
}
@ -558,7 +565,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
turnConf: this.turnConf,
manualTurnConf: this.manualTurnConf,
customToken: this.customToken,
tokenOptions: this.tokenOptions
forcePublishing: this.forcePublishing,
tokenOptions: this.tokenOptions,
},
width: '450px'
});
@ -572,6 +580,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.turnConf = result.turnConf;
this.manualTurnConf = result.manualTurnConf;
this.customToken = result.customToken;
this.forcePublishing = result.forcePublishing;
this.tokenOptions = result.tokenOptions;
}
document.getElementById('session-settings-btn-' + this.index).classList.remove('cdk-program-focused');
@ -715,4 +724,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.publisherProperties.videoSource !== 'screen');
}
republishAfterError() {
this.syncInitPublisher();
}
}