Skip to content

Commit

Permalink
Updating Media Streaming Packet's Contracts. (#31695)
Browse files Browse the repository at this point in the history
* Modifying media streaming contracts

* Export API

* Fixing wrong updates

* Moving to nested fields

* Removing versions

* Getting rid of Newtonsoft

* Export API

* Fixing tests
  • Loading branch information
cochi2 authored Oct 12, 2022
1 parent 9618cd8 commit 98d7fa9
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,6 @@ public HangUpOptions(bool forEveryone) { }
public bool ForEveryone { get { throw null; } }
public Azure.Communication.CallAutomation.RepeatabilityHeaders RepeatabilityHeaders { get { throw null; } set { } }
}
public partial class MediaStreamingAudio : Azure.Communication.CallAutomation.MediaStreamingPackageBase
{
internal MediaStreamingAudio() { }
public byte[] Data { get { throw null; } }
public bool IsSilent { get { throw null; } }
public Azure.Communication.CommunicationIdentifier Participant { get { throw null; } }
public System.DateTime Timestamp { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct MediaStreamingAudioChannel : System.IEquatable<Azure.Communication.CallAutomation.MediaStreamingAudioChannel>
{
Expand All @@ -443,6 +435,14 @@ internal MediaStreamingAudio() { }
public static bool operator !=(Azure.Communication.CallAutomation.MediaStreamingAudioChannel left, Azure.Communication.CallAutomation.MediaStreamingAudioChannel right) { throw null; }
public override string ToString() { throw null; }
}
public partial class MediaStreamingAudioData : Azure.Communication.CallAutomation.MediaStreamingPackageBase
{
internal MediaStreamingAudioData() { }
public string Data { get { throw null; } }
public bool IsSilent { get { throw null; } }
public Azure.Communication.CommunicationIdentifier Participant { get { throw null; } }
public System.DateTime Timestamp { get { throw null; } }
}
public partial class MediaStreamingConfiguration
{
public MediaStreamingConfiguration(System.Uri transportUrl, Azure.Communication.CallAutomation.MediaStreamingTransport transportType, Azure.Communication.CallAutomation.MediaStreamingContent contentType, Azure.Communication.CallAutomation.MediaStreamingAudioChannel audioChannelType) { }
Expand All @@ -468,20 +468,6 @@ public MediaStreamingConfiguration(System.Uri transportUrl, Azure.Communication.
public static bool operator !=(Azure.Communication.CallAutomation.MediaStreamingContent left, Azure.Communication.CallAutomation.MediaStreamingContent right) { throw null; }
public override string ToString() { throw null; }
}
public partial class MediaStreamingFormat
{
internal MediaStreamingFormat() { }
public int Channels { get { throw null; } }
public string Encoding { get { throw null; } }
public double Length { get { throw null; } }
public int SampleRate { get { throw null; } }
}
public partial class MediaStreamingMetadata : Azure.Communication.CallAutomation.MediaStreamingPackageBase
{
internal MediaStreamingMetadata() { }
public Azure.Communication.CallAutomation.MediaStreamingFormat Format { get { throw null; } }
public string MediaSubscriptionId { get { throw null; } }
}
public partial class MediaStreamingOptions
{
public MediaStreamingOptions(System.Uri transportUri, Azure.Communication.CallAutomation.MediaStreamingTransport transportType, Azure.Communication.CallAutomation.MediaStreamingContent contentType, Azure.Communication.CallAutomation.MediaStreamingAudioChannel audioChannelType) { }
Expand Down Expand Up @@ -759,3 +745,20 @@ public TransferToParticipantOptions(Azure.Communication.CommunicationIdentifier
public string UserToUserInformation { get { throw null; } set { } }
}
}
namespace Azure.Communication.CallAutomation.Models.MediaStreaming
{
public partial class MediaStreamingMetadata : Azure.Communication.CallAutomation.MediaStreamingPackageBase
{
public MediaStreamingMetadata() { }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("channels")]
public int Channels { get { throw null; } set { } }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("encoding")]
public string Encoding { get { throw null; } set { } }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("length")]
public int Length { get { throw null; } set { } }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("subscriptionId")]
public string MediaSubscriptionId { get { throw null; } set { } }
[System.Text.Json.Serialization.JsonPropertyNameAttribute("sampleRate")]
public int SampleRate { get { throw null; } set { } }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>
This client library enables working with the Microsoft Azure Communication CallAutomation service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ namespace Azure.Communication.CallAutomation
/// <summary>
/// Streaming audio.
/// </summary>
public class MediaStreamingAudio : MediaStreamingPackageBase
public class MediaStreamingAudioData : MediaStreamingPackageBase
{
internal MediaStreamingAudio(byte[] data, DateTime timestamp, string participantId, bool isSilence)
internal MediaStreamingAudioData(string data, DateTime timestamp, string participantId, bool silent)
{
Data = data;
Timestamp = timestamp;
Participant = new CommunicationUserIdentifier(participantId);
IsSilent = isSilence;
IsSilent = silent;
}

/// <summary>
/// The audio data.
/// The audio data in base64 string.
/// </summary>
public byte[] Data { get; }
public string Data { get; }

/// <summary>
/// The timestamp of thwn the media was sourced.
Expand All @@ -33,6 +33,7 @@ internal MediaStreamingAudio(byte[] data, DateTime timestamp, string participant
/// Participant ID
/// </summary>
public CommunicationIdentifier Participant { get; }

/// <summary>
/// Indicates if the received audio buffer contains only silence.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
// Licensed under the MIT License.

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Azure.Communication.CallAutomation
{
/// <summary>
/// Streaming audio.
/// </summary>
internal class MediaStreamingAudioInternal
internal class MediaStreamingAudioDataInternal
{
/// <summary>
/// The audio data.
/// The audio data in base64 string.
/// </summary>
[JsonPropertyName("data")]
public byte[] Data { get; set; }
public string Data { get; set; }

/// <summary>
/// The timestamp of thwn the media was sourced.
/// </summary>
[JsonPropertyName("timestamp")]
public DateTime Timestamp { get; set; }

/// <summary>
/// Participant ID
/// Participant ID.
/// </summary>
[JsonPropertyName("participantId")]
public string ParticipantId { get; set; }
[JsonPropertyName("participantRawId")]
public string ParticipantRawId { get; set; }
/// <summary>
/// Indicates if the received audio buffer contains only silence.
/// </summary>
[JsonPropertyName("isSilence")]
public bool IsSilence { get; set; }
[JsonPropertyName("silent")]
public bool Silent { get; set; }
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Communication.CallAutomation
using System.Text.Json.Serialization;

namespace Azure.Communication.CallAutomation.Models.MediaStreaming
{
/// <summary>
/// Streaming metadata
/// Metadata package for Media Streaming.
/// </summary>
public class MediaStreamingMetadata : MediaStreamingPackageBase
{
/// <summary>
/// Subscription Id.
/// </summary>
public string MediaSubscriptionId { get; }
[JsonPropertyName("subscriptionId")]
public string MediaSubscriptionId { get; set; }

/// <summary>
/// Format.
/// The Encoding.
/// </summary>
public MediaStreamingFormat Format { get; }

internal MediaStreamingMetadata(string mediaSubscriptionId, MediaStreamingFormat format)
{
MediaSubscriptionId = mediaSubscriptionId;
Format = format;
}
[JsonPropertyName("encoding")]
public string Encoding { get; set; }
/// <summary>
/// Sample Rate.
/// </summary>
[JsonPropertyName("sampleRate")]
public int SampleRate { get; set; }
/// <summary>
/// Channels.
/// </summary>
[JsonPropertyName("channels")]
public int Channels { get; set; }
/// <summary>
/// Length.
/// </summary>
[JsonPropertyName("length")]
public int Length { get; set; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ public static MediaStreamingPackageBase Parse(byte[] receivedBytes)
/// <exception cref="NotImplementedException"></exception>
public static MediaStreamingPackageBase Parse(string stringJson)
{
if (stringJson.Contains("format"))
JsonElement package = JsonDocument.Parse(stringJson).RootElement;
if (package.GetProperty("kind").ToString() == "AudioMetadata")
{
MediaStreamingMetadataInternal metadataInternal = JsonSerializer.Deserialize<MediaStreamingMetadataInternal>(stringJson);
MediaStreamingFormat mediaStreamingFormat = new MediaStreamingFormat(
metadataInternal.Format.Encoding, metadataInternal.Format.SampleRate, metadataInternal.Format.Channels, metadataInternal.Format.Length);
return new MediaStreamingMetadata(metadataInternal.MediaSubscriptionId, mediaStreamingFormat);
return JsonSerializer.Deserialize<MediaStreamingMetadata>(package.GetProperty("audioMetadata").ToString());
}
else if (stringJson.Contains("data"))
else if (package.GetProperty("kind").ToString() == "AudioData")
{
MediaStreamingAudioInternal audioInternal = JsonSerializer.Deserialize<MediaStreamingAudioInternal>(stringJson);
return new MediaStreamingAudio(
audioInternal.Data, audioInternal.Timestamp, audioInternal.ParticipantId, audioInternal.IsSilence);
MediaStreamingAudioDataInternal audioInternal = JsonSerializer.Deserialize<MediaStreamingAudioDataInternal>(package.GetProperty("audioData").ToString());
return new MediaStreamingAudioData(
audioInternal.Data, audioInternal.Timestamp, audioInternal.ParticipantRawId, audioInternal.Silent);
}
else
throw new NotSupportedException(stringJson);
Expand Down
Loading

0 comments on commit 98d7fa9

Please sign in to comment.