{"version":3,"sources":["src/common.speech/AvatarSynthesisAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,YAAY,EAEZ,iBAAiB,EAGpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,2BAA2B,EAC3B,kBAAkB,EAElB,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,qBAAa,sBAAuB,SAAQ,oBAAoB;IAC5D,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoB;IAC1D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAe;gBAG5C,cAAc,EAAE,eAAe,EAC/B,iBAAiB,EAAE,2BAA2B,EAC9C,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY;IAU9B,SAAS,CAAC,mCAAmC,IAAI,IAAI;IAIrD,SAAS,CAAC,+BAA+B,IAAI,IAAI;IA2CjD,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAa9D","file":"AvatarSynthesisAdapter.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport {\n    AvatarConfig,\n    AvatarEventArgs,\n    AvatarSynthesizer,\n    PropertyId,\n    Synthesizer,\n} from \"../sdk/Exports.js\";\nimport {\n    ISynthesisConnectionFactory,\n    ISynthesisMetadata,\n    ISynthesisSectionVideo,\n    SynthesisAdapterBase,\n    SynthesizerConfig\n} from \"./Exports.js\";\nimport { IAuthentication } from \"./IAuthentication.js\";\n\nexport class AvatarSynthesisAdapter extends SynthesisAdapterBase {\n    private readonly privAvatarSynthesizer: AvatarSynthesizer;\n    private readonly privAvatarConfig: AvatarConfig;\n\n    public constructor(\n        authentication: IAuthentication,\n        connectionFactory: ISynthesisConnectionFactory,\n        synthesizerConfig: SynthesizerConfig,\n        avatarSynthesizer: AvatarSynthesizer,\n        avatarConfig: AvatarConfig,\n        ) {\n\n        super(authentication, connectionFactory,\n            synthesizerConfig, undefined);\n        this.privAvatarSynthesizer = avatarSynthesizer;\n        this.privSynthesizer = avatarSynthesizer as Synthesizer;\n        this.privAvatarConfig = avatarConfig;\n    }\n\n    protected setSynthesisContextSynthesisSection(): void {\n        this.privSynthesisContext.setSynthesisSection(undefined);\n    }\n\n    protected setSpeechConfigSynthesisSection(): void {\n        this.privSynthesizerConfig.synthesisVideoSection = {\n            format: {\n                bitrate: this.privAvatarConfig.videoFormat?.bitrate,\n                codec: this.privAvatarConfig.videoFormat?.codec,\n                crop: {\n                    bottomRight: {\n                        x: this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,\n                        y: this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y,\n                    },\n                    topLeft: {\n                        x: this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,\n                        y: this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y,\n                    },\n                },\n                resolution: {\n                    height: this.privAvatarConfig.videoFormat?.height,\n                    width: this.privAvatarConfig.videoFormat?.width,\n                },\n            },\n            protocol: {\n                name: \"WebRTC\",\n                webrtcConfig: {\n                    clientDescription: btoa(this.privSynthesizerConfig.parameters.getProperty(PropertyId.TalkingAvatarService_WebRTC_SDP)),\n                    iceServers: this.privAvatarConfig.remoteIceServers ?? this.privAvatarSynthesizer.iceServers,\n                },\n            },\n            talkingAvatar: {\n                background: {\n                    color: this.privAvatarConfig.backgroundColor,\n                    image: {\n                        url: this.privAvatarConfig.backgroundImage?.toString(),\n                    }\n                },\n                character: this.privAvatarConfig.character,\n                customized: this.privAvatarConfig.customized,\n                style: this.privAvatarConfig.style,\n                useBuiltInVoice: this.privAvatarConfig.useBuiltInVoice,\n            }\n        } as ISynthesisSectionVideo;\n    }\n\n\n    protected onAvatarEvent(metadata: ISynthesisMetadata): void {\n        if (!!this.privAvatarSynthesizer.avatarEventReceived) {\n            const avatarEventArgs: AvatarEventArgs = new AvatarEventArgs(\n                metadata.Data.Offset,\n                metadata.Data.Name);\n            try {\n                this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer, avatarEventArgs);\n            } catch (error) {\n                // Not going to let errors in the event handler\n                // trip things up.\n            }\n        }\n    }\n}\n"]}