From 95836a3e6f42e07b326b26127e16efdc9fa03cbb Mon Sep 17 00:00:00 2001 From: Xavier Pouyat Date: Thu, 16 Nov 2023 15:11:00 +0100 Subject: [PATCH] Support for audioanalyzerpreset and batter management of job input start and end --- MK.IO/CsharpDotNet2/Model/TransformOutput.cs | 2 +- .../Model => Job/Models}/AbsoluteClipTime.cs | 14 ++++-------- MK.IO/Job/Models/JobInputHttp.cs | 13 +++++++++++ MK.IO/Job/Models/JobInputTime.cs | 22 +++++++++++++++++++ .../Model => Job/Models}/UtcClipTime.cs | 16 +++++--------- MK.IO/Script/notes.md | 4 ++-- .../Models}/AudioAnalyzerPreset.cs | 11 +++++----- .../Models/AudioAnalyzerPresetMode.cs | 12 ++++++++++ .../Models/BuiltInStandardEncoderPreset.cs | 3 ++- ...oderPreset.cs => TransformOutputPreset.cs} | 5 +++-- 10 files changed, 69 insertions(+), 33 deletions(-) rename MK.IO/{CsharpDotNet2/Model => Job/Models}/AbsoluteClipTime.cs (78%) create mode 100644 MK.IO/Job/Models/JobInputTime.cs rename MK.IO/{CsharpDotNet2/Model => Job/Models}/UtcClipTime.cs (74%) rename MK.IO/{CsharpDotNet2/Model => Transform/Models}/AudioAnalyzerPreset.cs (91%) create mode 100644 MK.IO/Transform/Models/AudioAnalyzerPresetMode.cs rename MK.IO/Transform/Models/{EncoderPreset.cs => TransformOutputPreset.cs} (68%) diff --git a/MK.IO/CsharpDotNet2/Model/TransformOutput.cs b/MK.IO/CsharpDotNet2/Model/TransformOutput.cs index 4b45c97..9d84fdb 100644 --- a/MK.IO/CsharpDotNet2/Model/TransformOutput.cs +++ b/MK.IO/CsharpDotNet2/Model/TransformOutput.cs @@ -25,7 +25,7 @@ public class TransformOutput /// Preset that describes the operations that will be used to modify, transcode, or extract insights from the source file to generate the output. Only BultiInStandardEncoderPreset is supported currently. [DataMember(Name = "preset", EmitDefaultValue = false)] [JsonProperty(PropertyName = "preset")] - public EncoderPreset Preset { get; set; } + public TransformOutputPreset Preset { get; set; } /// /// Sets the relative priority of the TransformOutputs within a Transform diff --git a/MK.IO/CsharpDotNet2/Model/AbsoluteClipTime.cs b/MK.IO/Job/Models/AbsoluteClipTime.cs similarity index 78% rename from MK.IO/CsharpDotNet2/Model/AbsoluteClipTime.cs rename to MK.IO/Job/Models/AbsoluteClipTime.cs index 6eeff57..3f288f6 100644 --- a/MK.IO/CsharpDotNet2/Model/AbsoluteClipTime.cs +++ b/MK.IO/Job/Models/AbsoluteClipTime.cs @@ -2,22 +2,16 @@ using System.Runtime.Serialization; using System.Text; -namespace MK.IO.Models +namespace MK.IO { /// /// /// - [DataContract] - public class AbsoluteClipTime + public class AbsoluteClipTime : JobInputTime { - /// - /// The discriminator for derived types. - /// - /// The discriminator for derived types. - [DataMember(Name = "@odata.type", EmitDefaultValue = false)] - [JsonProperty(PropertyName = "@odata.type")] - public string OdataType { get; set; } + [JsonProperty("@odata.type")] + internal string OdataType => "#Microsoft.Media.AbsoluteClipTime"; /// /// The time position on the timeline of the input media. It is usually specified as an ISO8601 period. e.g PT30S for 30 seconds. diff --git a/MK.IO/Job/Models/JobInputHttp.cs b/MK.IO/Job/Models/JobInputHttp.cs index 257152f..84579c7 100644 --- a/MK.IO/Job/Models/JobInputHttp.cs +++ b/MK.IO/Job/Models/JobInputHttp.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using Newtonsoft.Json; +using System.Runtime.Serialization; namespace MK.IO { @@ -24,6 +25,18 @@ public JobInputHttp(string baseUri, List files) [JsonProperty("baseUri")] public string BaseUri { get; set; } + /// + /// Gets or Sets Start + /// + [JsonProperty("start")] + public JobInputTime Start { get; set; } + + /// + /// Gets or Sets End + /// + [JsonProperty("end")] + public JobInputTime End { get; set; } + /// /// List of files. Required for JobInputHttp. /// diff --git a/MK.IO/Job/Models/JobInputTime.cs b/MK.IO/Job/Models/JobInputTime.cs new file mode 100644 index 0000000..9b54241 --- /dev/null +++ b/MK.IO/Job/Models/JobInputTime.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using JsonSubTypes; +using Newtonsoft.Json; +namespace MK.IO +{ + + [JsonConverter(typeof(JsonSubtypes), "@odata.type")] + [JsonSubtypes.KnownSubType(typeof(UtcClipTime), "#Microsoft.Media.UtcClipTime")] + [JsonSubtypes.KnownSubType(typeof(AbsoluteClipTime), "#Microsoft.Media.AbsoluteClipTime")] + + // + // Summary: + // Base class for Job Start. A derived class must be used + // to create a configuration. + public class JobInputTime + { + [JsonProperty("@odata.type")] + internal virtual string OdataType { get; set; } + } +} \ No newline at end of file diff --git a/MK.IO/CsharpDotNet2/Model/UtcClipTime.cs b/MK.IO/Job/Models/UtcClipTime.cs similarity index 74% rename from MK.IO/CsharpDotNet2/Model/UtcClipTime.cs rename to MK.IO/Job/Models/UtcClipTime.cs index c5d349a..665df4c 100644 --- a/MK.IO/CsharpDotNet2/Model/UtcClipTime.cs +++ b/MK.IO/Job/Models/UtcClipTime.cs @@ -2,22 +2,16 @@ using System.Runtime.Serialization; using System.Text; -namespace MK.IO.Models +namespace MK.IO { /// /// /// - [DataContract] - public class UtcClipTime + public class UtcClipTime : JobInputTime { - /// - /// The discriminator for derived types. - /// - /// The discriminator for derived types. - [DataMember(Name = "@odata.type", EmitDefaultValue = false)] - [JsonProperty(PropertyName = "@odata.type")] - public string OdataType { get; set; } + [JsonProperty("@odata.type")] + internal string OdataType => "#Microsoft.Media.UtcClipTime"; /// /// The time position on the timeline of the input media based on Utc time. @@ -25,7 +19,7 @@ public class UtcClipTime /// The time position on the timeline of the input media based on Utc time. [DataMember(Name = "time", EmitDefaultValue = false)] [JsonProperty(PropertyName = "time")] - public TimeSpan Time { get; set; } + public DateTime Time { get; set; } /// diff --git a/MK.IO/Script/notes.md b/MK.IO/Script/notes.md index 7bba378..5754522 100644 --- a/MK.IO/Script/notes.md +++ b/MK.IO/Script/notes.md @@ -2,11 +2,11 @@ Classes generated from Swagger. Namespace changed with ps1 script. -In TransformOutput.cs, public OneOfTransformOutputPreset Preset { get; set; } changed to public EncoderPreset Preset { get; set; } +In TransformOutput.cs, public OneOfTransformOutputPreset Preset { get; set; } changed to public TransformOutputPreset Preset { get; set; } In JobProperties.cs, public OneOfJobPropertiesInput Input { get; set; } changed to public JobInput Input { get; set; } In JobProperties.cs, public OneOfJobPropertiesInput Input { get; set; } changed to public JobInput Input { get; set; } -Deleted : OneOfTransformOutputPreset.cs, OneOfJobPropertiesInput.cs, BuiltInStandardEncoderPreset.cs, JobInputAsset.cs, JobInputHttp.cs, ContentKeyPolicyOption +Deleted : AbsoluteClipTime, AudioAnalyzerPreset, UtcClipTime, OneOfTransformOutputPreset.cs, OneOfJobPropertiesInput.cs, BuiltInStandardEncoderPreset.cs, JobInputAsset.cs, JobInputHttp.cs, ContentKeyPolicyOption and all OneOfJobInput....cs In JobOutputAsset.cs, public string EndTime changed to public DateTime? EndTime, and public string StartTime changed to public DateTime? StartTime diff --git a/MK.IO/CsharpDotNet2/Model/AudioAnalyzerPreset.cs b/MK.IO/Transform/Models/AudioAnalyzerPreset.cs similarity index 91% rename from MK.IO/CsharpDotNet2/Model/AudioAnalyzerPreset.cs rename to MK.IO/Transform/Models/AudioAnalyzerPreset.cs index d9c664a..39899ac 100644 --- a/MK.IO/CsharpDotNet2/Model/AudioAnalyzerPreset.cs +++ b/MK.IO/Transform/Models/AudioAnalyzerPreset.cs @@ -2,22 +2,21 @@ using System.Runtime.Serialization; using System.Text; -namespace MK.IO.Models +namespace MK.IO { /// /// /// [DataContract] - public class AudioAnalyzerPreset + public class AudioAnalyzerPreset : TransformOutputPreset { /// /// The discriminator for derived types. /// /// The discriminator for derived types. - [DataMember(Name = "@odata.type", EmitDefaultValue = false)] - [JsonProperty(PropertyName = "@odata.type")] - public string OdataType { get; set; } + [JsonProperty("@odata.type")] + internal string OdataType => "#Microsoft.Media.AudioAnalyzerPreset"; /// /// The language for the audio payload in the input using the BCP-47 format of 'language tag-region' (e.g: 'en-US') @@ -37,13 +36,13 @@ public class AudioAnalyzerPreset /// /// Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen. + /// Use AudioAnalyzerPresetMode to list values. /// /// Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen. [DataMember(Name = "mode", EmitDefaultValue = false)] [JsonProperty(PropertyName = "mode")] public string Mode { get; set; } - /// /// Get the string presentation of the object /// diff --git a/MK.IO/Transform/Models/AudioAnalyzerPresetMode.cs b/MK.IO/Transform/Models/AudioAnalyzerPresetMode.cs new file mode 100644 index 0000000..58c3d4d --- /dev/null +++ b/MK.IO/Transform/Models/AudioAnalyzerPresetMode.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace MK.IO +{ + /// The modes to use with Audio Analyzer. + public readonly partial struct AudioAnalyzerPresetMode + { + public static readonly string Standard = "Standard"; + public static readonly string Basic = "Basic"; + } +} \ No newline at end of file diff --git a/MK.IO/Transform/Models/BuiltInStandardEncoderPreset.cs b/MK.IO/Transform/Models/BuiltInStandardEncoderPreset.cs index 9c2d188..d5f0c57 100644 --- a/MK.IO/Transform/Models/BuiltInStandardEncoderPreset.cs +++ b/MK.IO/Transform/Models/BuiltInStandardEncoderPreset.cs @@ -5,7 +5,7 @@ namespace MK.IO { - public class BuiltInStandardEncoderPreset : EncoderPreset + public class BuiltInStandardEncoderPreset : TransformOutputPreset { public BuiltInStandardEncoderPreset(string presetName) @@ -16,6 +16,7 @@ public BuiltInStandardEncoderPreset(string presetName) [JsonProperty("@odata.type")] internal string OdataType => "#Microsoft.Media.BuiltInStandardEncoderPreset"; + // Use EncoderNamedPreset to list possible values for this property [JsonProperty("presetName")] public string PresetName { get; set; } } diff --git a/MK.IO/Transform/Models/EncoderPreset.cs b/MK.IO/Transform/Models/TransformOutputPreset.cs similarity index 68% rename from MK.IO/Transform/Models/EncoderPreset.cs rename to MK.IO/Transform/Models/TransformOutputPreset.cs index 9c294d3..b3ee503 100644 --- a/MK.IO/Transform/Models/EncoderPreset.cs +++ b/MK.IO/Transform/Models/TransformOutputPreset.cs @@ -8,12 +8,13 @@ namespace MK.IO [JsonConverter(typeof(JsonSubtypes), "@odata.type")] [JsonSubtypes.KnownSubType(typeof(BuiltInStandardEncoderPreset), "#Microsoft.Media.BuiltInStandardEncoderPreset")] + [JsonSubtypes.KnownSubType(typeof(AudioAnalyzerPreset), "#Microsoft.Media.AudioAnalyzerPreset")] // // Summary: - // Base class for Encoder preset configuration. A derived class must be used + // Base class for Transform Output preset configuration. A derived class must be used // to create a configuration. - public class EncoderPreset + public class TransformOutputPreset { [JsonProperty("@odata.type")] internal virtual string OdataType { get; set; }