Skip to content

Commit

Permalink
Merge pull request #39 from microsoft/dev
Browse files Browse the repository at this point in the history
Dev - version 2.1.1
  • Loading branch information
xpouyat authored Sep 4, 2024
2 parents 869cf7a + d4198d9 commit e340f7b
Show file tree
Hide file tree
Showing 17 changed files with 1,006 additions and 155 deletions.
4 changes: 2 additions & 2 deletions MK.IO.Tests/MK.IO.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Moq" Version="4.20.71" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
6 changes: 3 additions & 3 deletions MK.IO/CsharpDotNet2/Model/FirstQuality.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace MK.IO.Models
public class FirstQuality
{
/// <summary>
/// Not yet implemented. Denotes the target video bitrate to be used when starting playback of an HLS video manifest. If the defined bitrate exactly matches a bitrate in the video manifest, that playlist will be presented first among the available representations in the manifest. If the defined bitrate is between quality levels, we take the closest of the adjacent playlists and move them to the top, ignoring sequencing for other playlists. If the defined quality exceeds that of the bitrates in the manifest, we order largest to smallest. If the defined bitrate underruns the bitrates in the manifest, we order smallest to largest.
/// Denotes the target video bitrate to be used when starting playback of an HLS manifest. The video representation with the bitrate closest to the defined bitrate will be presented first among the available representations in the HLS manifest.
/// </summary>
/// <value>Not yet implemented. Denotes the target video bitrate to be used when starting playback of an HLS video manifest. If the defined bitrate exactly matches a bitrate in the video manifest, that playlist will be presented first among the available representations in the manifest. If the defined bitrate is between quality levels, we take the closest of the adjacent playlists and move them to the top, ignoring sequencing for other playlists. If the defined quality exceeds that of the bitrates in the manifest, we order largest to smallest. If the defined bitrate underruns the bitrates in the manifest, we order smallest to largest. </value>
/// <value>Denotes the target video bitrate to be used when starting playback of an HLS manifest. The video representation with the bitrate closest to the defined bitrate will be presented first among the available representations in the HLS manifest.</value>
[DataMember(Name = "bitrate", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "bitrate")]
[Obsolete] public int? Bitrate { get; set; }
public int? Bitrate { get; set; }


/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions MK.IO/CsharpDotNet2/Model/LiveEventSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class LiveEventSchema
public LiveEventProperties Properties { get; set; }

/// <summary>
/// A dictionary of tags associated with the live event. Maximum number of tags: 16. Maximum length of a tag: 256 characters.
/// A dictionary of tags associated with the live event. Maximum number of tags: 16. Maximum length of a tag: 64 characters.
/// </summary>
/// <value>A dictionary of tags associated with the live event. Maximum number of tags: 16. Maximum length of a tag: 256 characters.</value>
/// <value>A dictionary of tags associated with the live event. Maximum number of tags: 16. Maximum length of a tag: 64 characters.</value>
[DataMember(Name = "tags", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "tags")]
public Dictionary<string, string> Tags { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions MK.IO/MK.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<Description>A .NET client SDK for MediaKind MK.IO.</Description>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<RepositoryUrl>https://github.com/microsoft/MK.IO</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/microsoft/MK.IO/blob/main/README.md</PackageProjectUrl>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<FileVersion>2.1.0.0</FileVersion>
<AssemblyVersion>2.1.1.0</AssemblyVersion>
<FileVersion>2.1.1.0</FileVersion>
<Title>A .NET client SDK for MediaKind MK.IO.</Title>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down Expand Up @@ -53,7 +53,7 @@

<ItemGroup>
<PackageReference Include="JsonSubTypes" Version="2.0.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions MK.IO/MKIOClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public MKIOClient(string subscriptionName, string jwtToken)
Argument.AssertNotNullOrEmpty(subscriptionName, nameof(subscriptionName));
Argument.AssertNotNullOrEmpty(jwtToken, nameof(jwtToken));
Argument.AssertJwtToken(jwtToken, nameof(jwtToken));

_subscriptionName = subscriptionName;
_apiToken = jwtToken;

Expand Down Expand Up @@ -219,7 +219,7 @@ internal async Task<string> CreateObjectInternalAsync(string url, string amsJSON
HttpResponseMessage amsRequestResultWait = await _httpClient.GetAsync(monitorUrl, cancellationToken).ConfigureAwait(false);
string responseContentWait = await amsRequestResultWait.Content.ReadAsStringAsync().ConfigureAwait(false);
dynamic data = JsonConvert.DeserializeObject(responseContentWait);

Check warning on line 221 in MK.IO/MKIOClient.cs

View workflow job for this annotation

GitHub Actions / run_test

Converting null literal or possible null value to non-nullable type.
notComplete = data.status == "InProgress";
notComplete = (data != null && data!.status == "InProgress");
}
while (notComplete);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

namespace MK.IO.Models
{
public class TrackInserterPresetTextTrack : TrackInserter
public class TextTrack : TrackInserter
{

/// <summary>
/// The discriminator for derived types. Must be set to #MediaKind.TextTrack
/// </summary>
/// <value>The discriminator for derived types. Must be set to #MediaKind.TextTrack</value>
[JsonProperty("@odata.type")]
internal override string OdataType => "#MediaKind.TextTrack";

Expand Down Expand Up @@ -42,7 +45,7 @@ public class TrackInserterPresetTextTrack : TrackInserter
/// <value>When PlayerVisibility is set to 'Visible', the track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to 'Hidden', the track will not be available to the client. The default value is 'Visible'.</value>
[DataMember(Name = "playerVisibility", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "playerVisibility")]
public TrackInserterPresetTextTrackPlayerVisibility PlayerVisibility { get; set; } = TrackInserterPresetTextTrackPlayerVisibility.Visible;
public TextTrackPlayerVisibility PlayerVisibility { get; set; } = TextTrackPlayerVisibility.Visible;

/// <summary>
/// The name of the track in the manifest.
Expand All @@ -60,7 +63,7 @@ public class TrackInserterPresetTextTrack : TrackInserter
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class TrackInserterPresetTextTrack {\n");
sb.Append("class TextTrack {\n");
sb.Append(" OdataType: ").Append(OdataType).Append("\n");
sb.Append(" DisplayName: ").Append(DisplayName).Append("\n");
sb.Append(" HlsSettings: ").Append(HlsSettings).Append("\n");
Expand All @@ -72,6 +75,7 @@ public override string ToString()
}



/// <summary>
/// Get the JSON string presentation of the object
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MK.IO.Models
/// </summary>
/// <value>When PlayerVisibility is set to 'Visible', the track will be present in the DASH manifest or HLS playlist when requested by a client. When the PlayerVisibility is set to 'Hidden', the track will not be available to the client. The default value is 'Visible'.</value>
[JsonConverter(typeof(StringEnumConverter))]
public enum TrackInserterPresetTextTrackPlayerVisibility
public enum TextTrackPlayerVisibility
{
[EnumMember(Value = "Visible")]
Visible,
Expand Down
2 changes: 1 addition & 1 deletion MK.IO/Transform/Models/ThumbnailGeneratorPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ThumbnailGeneratorPreset : TransformPreset
/// </summary>
/// <param name="thumbnails">The set of thumbnails to be produced.</param>
/// <param name="baseFileName">Used to create the output filename as `{BaseFilename}_{Label}{Index}{Extension}`. The default is the name of the input file. If the name of the input file is too long then it will be truncated to 64 characters.</param>
public ThumbnailGeneratorPreset(List<ThumbnailGeneratorConfiguration> thumbnails, string baseFileName = null)
public ThumbnailGeneratorPreset(List<ThumbnailGeneratorConfiguration> thumbnails, string? baseFileName = null)
{
Argument.AssertNotMoreThanLength(baseFileName, nameof(baseFileName), 64);
Argument.AssertRespectRegex(baseFileName, nameof(baseFileName), @"^[A-Za-z0-9_-]+$");
Expand Down
3 changes: 2 additions & 1 deletion MK.IO/Transform/Models/TrackInserter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

using JsonSubTypes;
using Newtonsoft.Json;

namespace MK.IO.Models
{

[JsonConverter(typeof(JsonSubtypes), "@odata.type")]
[JsonSubtypes.KnownSubType(typeof(TrackInserterPresetTextTrack), "#MediaKind.TextTrack")]
[JsonSubtypes.KnownSubType(typeof(TextTrack), "#MediaKind.TextTrack")]

//
// Summary:
Expand Down
4 changes: 2 additions & 2 deletions MK.IO/Transform/Models/TrackInserterPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TrackInserterPreset : TransformPreset
/// </summary>
/// <param name="tracks">The set of tracks to be inserted. Currently limited to one.</param>
/// <param name="baseFileName">Used to create the output filename as `{BaseFilename}.cmft`. The default is the name of the input .vtt file minus the extension, e.g. `subtitles.vtt` -> `subtitles.cmft`.</param>
public TrackInserterPreset(List<TrackInserter> tracks, string baseFileName = null)
public TrackInserterPreset(List<TrackInserter> tracks, string? baseFileName = null)
{
Argument.AssertNotMoreThanLength(baseFileName, nameof(baseFileName), 64);
Argument.AssertRespectRegex(baseFileName, nameof(baseFileName), @"^[A-Za-z0-9_-]+$");
Expand All @@ -36,7 +36,7 @@ public TrackInserterPreset(List<TrackInserter> tracks, string baseFileName = nul
/// <value>Used to create the output filename as `{BaseFilename}.cmft`. The default is the name of the input .vtt file minus the extension, e.g. `subtitles.vtt` -> `subtitles.cmft`.</value>
[DataMember(Name = "baseFilename", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "baseFilename")]
public string BaseFilename { get; set; }
public string? BaseFilename { get; set; }

/// <summary>
/// The set of tracks to be inserted. Currently limited to one.
Expand Down
1 change: 1 addition & 0 deletions MK.IO/Transform/Models/TransformPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using JsonSubTypes;
using Newtonsoft.Json;

namespace MK.IO.Models
{

Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,36 @@ In the current version, operations are supported for :

### End-to-end sample code

#### File encoding
#### Video encoding and publishing

There is a documented end-to-end sample code available in the SampleNet8.0 project, in file [SimpleEncodingAndPublishing.cs](https://github.com/microsoft/MK.IO/blob/main/SampleNet8.0/SimpleEncodingAndPublishing.cs).

This sample code does the following :

- upload a mp4 file to a new asset using authentication in the browser (you need contribution role on the storage)
- create the output asset
- create/update a transform
- create/update an encoding transform
- submit an encoding job
- create a streaming locator for the encoded asset
- create and start a streaming endpoint if there is none
- list the streaming urls and test player urls.
- clean the created resources if the user accepts

Run the `SampleNet8.0` project to execute this sample code.

#### Advanced video encoding and publishing

There is a documented end-to-end sample code available in the SampleNet8.0 project, in file [AdvancedEncodingAndPublishing.cs](https://github.com/microsoft/MK.IO/blob/main/SampleNet8.0/AdvancedEncodingAndPublishing.cs).

This sample code does the following :

- upload a mp4 file to a new asset using authentication in the browser (you need contribution role on the storage)
- create the output asset
- create/update an encoding transform
- submit an encoding job
- create/update a transform for vtt file insertion as text track
- upload a [WebVTT file](https://github.com/microsoft/MK.IO/blob/main/SampleNet8.0/Ignite.vtt) to a new asset (file was generated separately using [Azure AI Video Indexer](https://vi.microsoft.com))
- submit a job to generate the text track in the encoded asset
- create/update a transform for thumbnails
- submit a job to generate a thumbnails sprite
- create a download locator for the thumbnails sprite and thumbnails vtt and list the Urls
Expand All @@ -59,7 +79,7 @@ This sample code does the following :
- list the streaming urls and test player urls.
- clean the created resources if the user accepts

Run the SampleNet8.0 project to execute this sample code.
Edit Program.cs file in SampleNet8.0 to uncomment the line `await AdvancedEncodingAndPublishing.RunAsync();`, comment `await SimpleEncodingAndPublishing.RunAsync();`, and run the `SampleNet8.0` project.

#### Live streaming

Expand All @@ -76,7 +96,7 @@ What the sample does :
- propose to the user to convert the live asset to a mp4 asset and create a download locator to download the mp4 file(s)
- clean the created resources if the user accepts

Edit Program.cs file in SampleNet8.0 to uncomment line `await SimpleLiveStreaming.RunAsync();`, comment `await SimpleEncodingAndPublishing.RunAsync();`, and run the sample project.
Edit Program.cs file in SampleNet8.0 to uncomment the line `await SimpleLiveStreaming.RunAsync();`, comment `await SimpleEncodingAndPublishing.RunAsync();`, and run the `SampleNet8.0` project.

### Other examples

Expand Down
Loading

0 comments on commit e340f7b

Please sign in to comment.