Skip to content

Commit

Permalink
Add enableTranscoding ingress option for WHIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Nov 21, 2024
1 parent 18343fa commit a4b010f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ mat-chip-row {
margin-bottom: 7px;
}

#ingress-simulcast {
margin-right: 6px;
#ingress-video-codec-select {
margin-left: 6px;
}

#ingress-video-codec-select {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ <h2 mat-dialog-title>API REST</h2>
<mat-checkbox id="ingress-simulcast" [(ngModel)]="ingressSimulcast"
[disabled]="!ingressWithVideo || ingressVideoEncodingPresetSelected != undefined">Simulcast</mat-checkbox>
</span>
<span style="display: inline-block" matTooltip="Only for WHIP" [matTooltipDisabled]="inputTypeSelected === 1">
<mat-checkbox id="ingress-transcoding" [(ngModel)]="ingressEnableTranscoding" [disabled]="inputTypeSelected !== 1">Transcoding</mat-checkbox>
</span>
<span style="display: inline-block" [matTooltip]="!ingressWithVideo ? 'Only with video' : 'Preset overrides this value'"
[matTooltipDisabled]="!!ingressWithVideo && ingressVideoEncodingPresetSelected == undefined">
<mat-form-field id="ingress-video-codec-select">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class RoomApiDialogComponent {
ingressWithAudio: boolean = false;
ingressVideoCodecSelected: VideoCodec = VideoCodec.H264_BASELINE;
ingressSimulcast: boolean = true;
ingressEnableTranscoding: boolean = false;
ingressVideoEncodingPresetSelected?: IngressVideoEncodingPreset = undefined;

response: string;
Expand Down Expand Up @@ -306,6 +307,7 @@ export class RoomApiDialogComponent {
this.ingressWithVideo,
this.ingressVideoCodecSelected,
this.ingressSimulcast,
this.ingressEnableTranscoding,
this.ingressVideoEncodingPresetSelected
);
this.response = JSON.stringify(ingress, null, 4);
Expand Down
87 changes: 46 additions & 41 deletions openvidu-testapp/src/app/services/room-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ export class RoomApiService {

async createIngress(
room_name: string,
input_type: IngressInput,
inputType: IngressInput,
withAudio: boolean,
withVideo: boolean,
codec: VideoCodec,
simulcast: boolean,
enableTranscoding: boolean,
preset?: IngressVideoEncodingPreset
): Promise<IngressInfo> {
let url;
Expand All @@ -224,59 +225,63 @@ export class RoomApiService {
: 'https://s3.eu-west-1.amazonaws.com/public.openvidu.io/bbb_sunflower_1080p_60fps_normal_noaudio.mp4';
}
let options: CreateIngressOptions = {
name: input_type + '-' + room_name,
name: inputType + '-' + room_name,
roomName: room_name,
participantIdentity: 'IngressParticipantIdentity',
participantName: 'MyIngress',
participantMetadata: 'IngressParticipantMetadata',
url,
video: {
};
if (inputType === IngressInput.WHIP_INPUT) {
options.enableTranscoding = enableTranscoding;
}
if (inputType != IngressInput.WHIP_INPUT || enableTranscoding) {
options.video = {
encodingOptions: {
case: preset != undefined ? 'preset' : 'options',
value: {},
},
} as any,
};
if (preset != undefined) {
options.video!.encodingOptions.value = preset;
} else {
const encodingOptions = options.video!.encodingOptions
.value! as IngressVideoEncodingOptions;
encodingOptions.videoCodec = codec;
encodingOptions.frameRate = 30;
let layers: VideoLayer[] = [];
if (simulcast) {
layers = [
{
quality: VideoQuality.HIGH,
width: 1920,
height: 1080,
},
{
quality: VideoQuality.MEDIUM,
width: 1280,
height: 720,
},
{
quality: VideoQuality.LOW,
width: 640,
height: 360,
},
] as VideoLayer[];
} as any;
if (preset != undefined) {
options.video!.encodingOptions.value = preset;
} else {
layers = [
{
quality: VideoQuality.HIGH,
width: 1920,
height: 1080,
} as VideoLayer,
];
const encodingOptions = options.video!.encodingOptions
.value! as IngressVideoEncodingOptions;
encodingOptions.videoCodec = codec;
encodingOptions.frameRate = 30;
let layers: VideoLayer[] = [];
if (simulcast) {
layers = [
{
quality: VideoQuality.HIGH,
width: 1920,
height: 1080,
},
{
quality: VideoQuality.MEDIUM,
width: 1280,
height: 720,
},
{
quality: VideoQuality.LOW,
width: 640,
height: 360,
},
] as VideoLayer[];
} else {
layers = [
{
quality: VideoQuality.HIGH,
width: 1920,
height: 1080,
} as VideoLayer,
];
}
encodingOptions.layers = layers;
}
encodingOptions.layers = layers;
}

const ingressInfo = await this.ingressClient.createIngress(
input_type,
inputType,
options
);
return ingressInfo;
Expand Down

0 comments on commit a4b010f

Please sign in to comment.