Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Beta4 audio streaming apis. #29418

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -54,6 +54,7 @@ export interface AddParticipantSucceeded extends Omit<RestAddParticipantSucceede
// @public
export interface AnswerCallOptions extends OperationOptions {
callIntelligenceOptions?: CallIntelligenceOptions;
mediaStreamingConfiguration?: MediaStreamingConfiguration;
operationContext?: string;
}

Expand Down Expand Up @@ -162,14 +163,17 @@ export type CallLocatorType = "serverCallLocator" | "groupCallLocator";
export class CallMedia {
constructor(callConnectionId: string, endpoint: string, credential: KeyCredential | TokenCredential, options?: CallAutomationApiClientOptionalParams);
cancelAllOperations(): Promise<void>;
mediaStreamingState(): Promise<MediaStreamingStateResponse>;
play(playSources: (FileSource | TextSource | SsmlSource)[], playTo: CommunicationIdentifier[], options?: PlayOptions): Promise<void>;
playToAll(playSources: (FileSource | TextSource | SsmlSource)[], options?: PlayOptions): Promise<void>;
sendDtmfTones(tones: Tone[] | DtmfTone[], targetParticipant: CommunicationIdentifier, options?: SendDtmfTonesOptions): Promise<SendDtmfTonesResult>;
startContinuousDtmfRecognition(targetParticipant: CommunicationIdentifier, options?: ContinuousDtmfRecognitionOptions): Promise<void>;
startMediaStreaming(options?: StartMediaStreamingOptions): Promise<void>;
// @deprecated
startRecognizing(targetParticipant: CommunicationIdentifier, maxTonesToCollect: number, options: CallMediaRecognizeDtmfOptions): Promise<void>;
startRecognizing(targetParticipant: CommunicationIdentifier, options: CallMediaRecognizeDtmfOptions | CallMediaRecognizeChoiceOptions | CallMediaRecognizeSpeechOptions | CallMediaRecognizeSpeechOrDtmfOptions): Promise<void>;
stopContinuousDtmfRecognition(targetParticipant: CommunicationIdentifier, options?: ContinuousDtmfRecognitionOptions): Promise<void>;
stopMediaStreaming(options?: StopMediaStreamingOptions): Promise<void>;
}

// @public
Expand Down Expand Up @@ -347,6 +351,7 @@ export interface ContinuousDtmfRecognitionToneReceived extends Omit<RestContinuo
// @public
export interface CreateCallOptions extends OperationOptions {
callIntelligenceOptions?: CallIntelligenceOptions;
mediaStreamingConfiguration?: MediaStreamingConfiguration;
operationContext?: string;
sourceCallIdNumber?: PhoneNumberIdentifier;
sourceDisplayName?: string;
Expand Down Expand Up @@ -429,6 +434,32 @@ export interface ListParticipantsResult {
values?: CallParticipant[];
}

// @public
export type MediaStreamingAudioChannelType = "mixed" | "unmixed";

// @public
export interface MediaStreamingConfiguration {
audioChannelType: MediaStreamingAudioChannelType;
contentType: MediaStreamingContentType;
startMediaStreaming?: boolean;
transportType: MediaStreamingTransportType;
transportUrl: string;
}

// @public
export type MediaStreamingContentType = "audio";

// @public
export interface MediaStreamingStateResponse {
// Warning: (ae-forgotten-export) The symbol "MediaStreamingState" needs to be exported by the entry point index.d.ts
mediaStreamingState?: MediaStreamingState;
// Warning: (ae-forgotten-export) The symbol "MediaStreamingType" needs to be exported by the entry point index.d.ts
mediaStreamingType?: MediaStreamingType;
}

// @public
export type MediaStreamingTransportType = "websocket";

// @public
export interface MuteParticipantOption extends OperationOptions {
operationContext?: string;
Expand Down Expand Up @@ -755,6 +786,7 @@ export interface RestPlayCompleted {
export interface RestPlayFailed {
callConnectionId?: string;
correlationId?: string;
failedPlaySourceIndex?: number;
operationContext?: string;
resultInformation?: RestResultInformation;
serverCallId?: string;
Expand Down Expand Up @@ -785,6 +817,7 @@ export interface RestRecognizeCompleted {
export interface RestRecognizeFailed {
callConnectionId?: string;
correlationId?: string;
failedPlaySourceIndex?: number;
operationContext?: string;
resultInformation?: RestResultInformation;
serverCallId?: string;
Expand Down Expand Up @@ -916,6 +949,12 @@ export interface SsmlSource extends PlaySource {
ssmlText: string;
}

// @public
export interface StartMediaStreamingOptions extends OperationOptions {
operationCallbackUri?: string;
operationContext?: string;
}

// @public
export interface StartRecordingOptions extends OperationOptions {
audioChannelParticipantOrdering?: CommunicationIdentifier[];
Expand All @@ -929,6 +968,11 @@ export interface StartRecordingOptions extends OperationOptions {
recordingStorage?: RecordingStorage;
}

// @public
export interface StopMediaStreamingOptions extends OperationOptions {
operationCallbackUri?: string;
}

// @public
export type StopRecordingOptions = OperationOptions;

Expand Down
Expand Up @@ -208,6 +208,7 @@ export class CallAutomationClient {
targetParticipant.sourceCallIdNumber,
),
sourceDisplayName: targetParticipant.sourceDisplayName,
mediaStreamingConfiguration: options.mediaStreamingConfiguration,
};

return this.createCallInternal(request, options);
Expand All @@ -232,6 +233,7 @@ export class CallAutomationClient {
callIntelligenceOptions: options.callIntelligenceOptions,
sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(options.sourceCallIdNumber),
sourceDisplayName: options.sourceDisplayName,
mediaStreamingConfiguration: options.mediaStreamingConfiguration,
};

return this.createCallInternal(request, options);
Expand All @@ -248,13 +250,19 @@ export class CallAutomationClient {
callbackUrl: string,
options: AnswerCallOptions = {},
): Promise<AnswerCallResult> {
const { callIntelligenceOptions, operationContext, ...operationOptions } = options;
const {
callIntelligenceOptions,
operationContext,
mediaStreamingConfiguration,
...operationOptions
} = options;
const request: AnswerCallRequest = {
incomingCallContext,
callIntelligenceOptions,
operationContext,
callbackUri: callbackUrl,
answeredBy: this.sourceIdentity,
mediaStreamingConfiguration,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test cases for media streaming configuration?

};
const optionsInternal = {
...operationOptions,
Expand Down
Expand Up @@ -18,6 +18,8 @@ import {
SendDtmfTonesRequest,
Tone,
SpeechOptions,
StartMediaStreamingRequest,
StopMediaStreamingRequest,
} from "./generated/src";

import { CallMediaImpl } from "./generated/src/operations";
Expand All @@ -38,9 +40,11 @@ import {
SendDtmfTonesOptions,
CallMediaRecognizeSpeechOptions,
CallMediaRecognizeSpeechOrDtmfOptions,
StartMediaStreamingOptions,
StopMediaStreamingOptions,
} from "./models/options";
import { KeyCredential, TokenCredential } from "@azure/core-auth";
import { SendDtmfTonesResult } from "./models/responses";
import { MediaStreamingStateResponse, SendDtmfTonesResult } from "./models/responses";
import { v4 as uuidv4 } from "uuid";

/**
Expand Down Expand Up @@ -415,4 +419,47 @@ export class CallMedia {
};
return sendDtmfTonesResult;
}

/**
* Starts media streaming in the call.
* @param options - Additional attributes for start media streaming.
*/
public async startMediaStreaming(options: StartMediaStreamingOptions = {}): Promise<void> {
const startMediaStreamingRequest: StartMediaStreamingRequest = {
operationContext: options.operationContext,
operationCallbackUri: options.operationCallbackUri,
};
return this.callMedia.startMediaStreaming(
this.callConnectionId,
startMediaStreamingRequest,
options,
);
}

/**
* Stops media streaming in the call.
* @param options - Additional attributes for stop media streaming.
*/
public async stopMediaStreaming(options: StopMediaStreamingOptions = {}): Promise<void> {
const stopMediaStreamingRequest: StopMediaStreamingRequest = {
operationCallbackUri: options.operationCallbackUri,
};
return this.callMedia.stopMediaStreaming(
this.callConnectionId,
stopMediaStreamingRequest,
options,
);
}

/**
* Gets media streaming state in the call.
*/
public async mediaStreamingState(): Promise<MediaStreamingStateResponse> {
const response = await this.callMedia.mediaStreamingState(this.callConnectionId, {});
const mediaStreamingStateResponse: MediaStreamingStateResponse = {
mediaStreamingState: response.mediaStreamingState,
mediaStreamingType: response.mediaStreamingType,
};
return mediaStreamingStateResponse;
}
}
Expand Up @@ -231,3 +231,26 @@ export interface CallIntelligenceOptions {
/** The identifier of the Cognitive Service resource assigned to this call. */
cognitiveServicesEndpoint?: string;
}

/** Configuration of Media streaming. */
export interface MediaStreamingConfiguration {
/** Transport URL for media streaming */
transportUrl: string;
/** The type of transport to be used for media streaming, eg. Websocket */
transportType: MediaStreamingTransportType;
/** Content type to stream, eg. audio */
contentType: MediaStreamingContentType;
/** Audio channel type to stream, eg. unmixed audio, mixed audio */
audioChannelType: MediaStreamingAudioChannelType;
/** Determines if the media streaming should be started immediately after call is answered or not. */
startMediaStreaming?: boolean;
}

/** Defines values for MediaStreamingTransportType. */
export type MediaStreamingTransportType = "websocket";

/** Defines values for MediaStreamingContentType. */
export type MediaStreamingContentType = "audio";

/** Defines values for MediaStreamingAudioChannelType. */
export type MediaStreamingAudioChannelType = "mixed" | "unmixed";
Expand Up @@ -18,6 +18,7 @@ import {
CallIntelligenceOptions,
CustomCallingContext,
RecordingStorage,
MediaStreamingConfiguration,
} from "./models";

/** Options to configure the recognize operation. */
Expand Down Expand Up @@ -106,6 +107,8 @@ export interface CreateCallOptions extends OperationOptions {
callIntelligenceOptions?: CallIntelligenceOptions;
/** The operation Context. */
operationContext?: string;
/** Media Streaming Configuration. */
mediaStreamingConfiguration?: MediaStreamingConfiguration;
}

/**
Expand All @@ -116,6 +119,8 @@ export interface AnswerCallOptions extends OperationOptions {
callIntelligenceOptions?: CallIntelligenceOptions;
/** The operation context. */
operationContext?: string;
/** Media Streaming Configuration. */
mediaStreamingConfiguration?: MediaStreamingConfiguration;
}

/**
Expand Down Expand Up @@ -319,3 +324,23 @@ export interface CancelAddParticipantOperationOptions extends OperationOptions {
*/
operationCallbackUrl?: string;
}

/** Options for start media streaming request. */
export interface StartMediaStreamingOptions extends OperationOptions {
/**
* Set a callback URI that overrides the default callback URI set by CreateCall/AnswerCall for this operation.
* This setup is per-action. If this is not set, the default callback URI set by CreateCall/AnswerCall will be used.
*/
operationCallbackUri?: string;
/** The value to identify context of the operation. */
operationContext?: string;
}

/** Options for stop media streaming request. */
export interface StopMediaStreamingOptions extends OperationOptions {
/**
* Set a callback URI that overrides the default callback URI set by CreateCall/AnswerCall for this operation.
* This setup is per-action. If this is not set, the default callback URI set by CreateCall/AnswerCall will be used.
*/
operationCallbackUri?: string;
}
Expand Up @@ -3,7 +3,12 @@

import { CallConnection } from "../callConnection";
import { CallConnectionProperties, CallParticipant } from "./models";
import { RecordingState, RecordingKind } from "../generated/src";
import {
RecordingState,
RecordingKind,
MediaStreamingState,
MediaStreamingType,
} from "../generated/src";
/**
* The interface used as parent of [action]CallResult
*/
Expand Down Expand Up @@ -85,3 +90,11 @@ export interface CancelAddParticipantOperationResult {
/** The operation context provided by client. */
operationContext?: string;
}

/** Contains response data for the mediaStreamingState operation. */
export interface MediaStreamingStateResponse {
/** Defines values for MediaStreamingState. */
mediaStreamingState?: MediaStreamingState;
/** Defines values for MediaStreamingType. */
mediaStreamingType?: MediaStreamingType;
}