Skip to content

Commit

Permalink
Create Media Streaming package parser with updated contracts (#31309)
Browse files Browse the repository at this point in the history
* add media streaming package parser

* fix build errors

* change types of length and audiodata to int and str, respectively

* resolve pr comments

* remove public constructors

* flatten contract
  • Loading branch information
atazimsft authored Oct 11, 2022
1 parent 6f7b298 commit c85090e
Show file tree
Hide file tree
Showing 7 changed files with 542 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.communication.callautomation.implementation.models;

import com.fasterxml.jackson.annotation.JsonProperty;

/** The MediaStreamingAudioInternal model. */
public final class MediaStreamingAudioInternal {

/*
* The audio data.
*/
@JsonProperty(value = "data")
private String audioData;

/*
* The timestamp of when the media was sourced.
*/
@JsonProperty(value = "timestamp")
private String timestamp;

/*
* The participantId.
*/
@JsonProperty(value = "participantRawID")
private String participantRawID;

/*
* Indicates if the received audio buffer contains only silence.
*/
@JsonProperty(value = "silent")
private boolean silent;

/**
* Get the data property.
*
* @return the data value.
*/
public String getAudioData() {
return audioData;
}

/**
* Get the timestamp property.
*
* @return the timestamp value.
*/
public String getTimestamp() {
return timestamp;
}

/**
* Get the participantRawID property.
*
* @return the participantRawID value.
*/
public String getParticipantRawID() {
return participantRawID;
}

/**
* Get the silent property.
*
* @return the silent value.
*/
public boolean isSilent() {
return silent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.communication.callautomation.implementation.models;

import com.fasterxml.jackson.annotation.JsonProperty;

/** The MediaStreamingMetadataInternal model. */
public final class MediaStreamingMetadataInternal {

/*
* The mediaSubscriptionId.
*/
@JsonProperty(value = "subscriptionId")
private String mediaSubscriptionId;

/*
* The encoding.
*/
@JsonProperty(value = "encoding")
private String encoding;

/*
* The sampleRate.
*/
@JsonProperty(value = "sampleRate")
private int sampleRate;

/*
* The channels.
*/
@JsonProperty(value = "channels")
private int channels;

/*
* The length.
*/
@JsonProperty(value = "length")
private int length;

/**
* Get the mediaSubscriptionId property.
*
* @return the mediaSubscriptionId value.
*/
public String getMediaSubscriptionId() {
return mediaSubscriptionId;
}

/**
* Get the encoding property.
*
* @return the encoding value.
*/
public String getEncoding() {
return encoding;
}

/**
* Get the sampleRate property.
*
* @return the sampleRate value.
*/
public int getSampleRate() {
return sampleRate;
}

/**
* Get the channels property.
*
* @return the channels value.
*/
public int getChannels() {
return channels;
}

/**
* Get the length property.
*
* @return the length value.
*/
public int getLength() {
return length;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.communication.callautomation.models;

import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;

import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/** The MediaStreamingAudio model. */
public class MediaStreamingAudio extends MediaStreamingPackageBase {

/*
* The audio data.
*/
private final String audioData;

/*
* The timestamp of when the media was sourced.
*/
private final OffsetDateTime timestamp;

/*
* The participantId.
*/
private final CommunicationIdentifier participant;

/*
* Indicates if the received audio buffer contains only silence.
*/
private final boolean silent;

/**
* The constructor
*
* @param audioData The audio data.
* @param timestamp The timestamp of when the media was sourced.
* @param participantRawID The participantId.
* @param silent Indicates if the received audio buffer contains only silence.
*/
MediaStreamingAudio(String audioData, String timestamp, String participantRawID, boolean silent) {
this.audioData = audioData;
this.timestamp = OffsetDateTime.parse(timestamp, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
this.participant = new CommunicationUserIdentifier(participantRawID);
this.silent = silent;
}

/**
* Get the data property.
*
* @return the data value.
*/
public String getAudioData() {
return audioData;
}

/**
* Get the timestamp property.
*
* @return the timestamp value.
*/
public OffsetDateTime getTimestamp() {
return timestamp;
}

/**
* Get the participantRawID property.
*
* @return the participantRawID value.
*/
public CommunicationIdentifier getParticipant() {
return participant;
}

/**
* Get the silent property.
*
* @return the silent value.
*/
public boolean isSilent() {
return silent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.communication.callautomation.models;

/** The MediaStreamingMetadata model. */
public class MediaStreamingMetadata extends MediaStreamingPackageBase {

/*
* The mediaSubscriptionId.
*/
private final String mediaSubscriptionId;

/*
* The encoding.
*/
private final String encoding;

/*
* The sampleRate.
*/
private final int sampleRate;

/*
* The channels.
*/
private final int channels;

/*
* The length.
*/
private final int length;

/**
* The constructor
*
* @param mediaSubscriptionId The mediaSubscriptionId.
* @param encoding The encoding.
* @param sampleRate The sampleRate.
* @param channels The channels.
* @param length The length.
*/
MediaStreamingMetadata(String mediaSubscriptionId, String encoding, int sampleRate, int channels, int length) {
this.mediaSubscriptionId = mediaSubscriptionId;
this.encoding = encoding;
this.sampleRate = sampleRate;
this.channels = channels;
this.length = length;
}

/**
* Get the mediaSubscriptionId property.
*
* @return the mediaSubscriptionId value.
*/
public String getMediaSubscriptionId() {
return mediaSubscriptionId;
}

/**
* Get the encoding property.
*
* @return the encoding value.
*/
public String getEncoding() {
return encoding;
}

/**
* Get the sampleRate property.
*
* @return the sampleRate value.
*/
public int getSampleRate() {
return sampleRate;
}

/**
* Get the channels property.
*
* @return the channels value.
*/
public int getChannels() {
return channels;
}

/**
* Get the length property.
*
* @return the length value.
*/
public int getLength() {
return length;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.communication.callautomation.models;

/** The abstract classed used as parent of MediaStreaming[package type]. */
public abstract class MediaStreamingPackageBase {
}
Loading

0 comments on commit c85090e

Please sign in to comment.