Skip to content

Commit

Permalink
Merge pull request #126 from Azure/dev
Browse files Browse the repository at this point in the history
3.4.0.0 release
  • Loading branch information
gtrifonov committed Jul 17, 2015
2 parents 783bb8a + 2462e77 commit fa207ce
Show file tree
Hide file tree
Showing 85 changed files with 3,547 additions and 828 deletions.
4 changes: 2 additions & 2 deletions .nuget/windowsazure.mediaservices.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>windowsazure.mediaservices</id>
<version>3.3.0.0</version>
<version>3.4.0.0</version>
<title>Windows Azure Media Services .NET SDK</title>
<authors>Microsoft Corporation</authors>
<owners>Microsoft Corporation</owners>
<licenseUrl>http://go.microsoft.com/fwlink/?LinkID=272666&amp;clcid=0x409</licenseUrl>
<projectUrl>http://aka.ms/wamsmsdn</projectUrl>
<iconUrl>http://nimbuspmteam.blob.core.windows.net/nuget/Media Services 150.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>This package contains Windows Azure Media Service library 3.3.0.0 for .NET.</description>
<description>This package contains Windows Azure Media Service library 3.4.0.0 for .NET.</description>
<releaseNotes>For more information, please check our forum: http://social.msdn.microsoft.com/Forums/en-US/MediaServices/threads

For MSDN documentation please visit http://aka.ms/wamsmsdn
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Windows Azure Media Services allows you to build a media distribution solution that can stream audio and video to Windows, iOS, Android, and other devices and platforms.To learn more, visit our [Developer Center](http://www.windowsazure.com/en-us/develop/media-services/).


## Release Notes

Please read the latest note here: https://github.com/Azure/azure-sdk-for-media-services/releases.
Expand Down
4 changes: 2 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<Target Name="Build" DependsOnTargets="RestorePackages;Clean;BuildDebug;BuildRelease" />

<!-- Publish any build artificates to the Publish directory -->
<Target Name="Publish" DependsOnTargets="Build">
<Target Name="Publish" DependsOnTargets="UnitTestRun">

<!-- Copy code artifacts -->
<Message Importance="high" Text="Publishing ..." ContinueOnError="false" />
Expand Down Expand Up @@ -149,7 +149,7 @@
ContinueOnError="false" />
</Target>

<Target Name="UnitTestRun" DependsOnTargets="Clean;BuildDebug;BuildRelease">
<Target Name="UnitTestRun" DependsOnTargets="Build">
<Message Importance="high" Text="Running Unit tests..." />
<Message Importance="high" Text="You are required to have installed a version of Visual Studio with support for MSTest (and MSTest on your path)." />
<MakeDir Directories="$(TestOutputDirectory)" ContinueOnError="false" />
Expand Down
35 changes: 5 additions & 30 deletions ci/SignMedia.bat
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
@echo off

echo Cleaning signed and packages directories
del /q c:\signing\signed\*.*
del /q c:\packages\*.*

echo Copying managed desktop library DLLs to signing source directory
copy /y .\Publish\Build\Release\Microsoft.WindowsAzure.MediaServices.Client.dll c:\signing\tosign\
copy /y .\Publish\Build\Release\Microsoft.WindowsAzure.MediaServices.Client.Common.FileEncryption.dll c:\signing\tosign\
copy /y .\Publish\Build\Release\Microsoft.WindowsAzure.MediaServices.Client.Common.BlobTransfer.dll c:\signing\tosign\
if %ERRORLEVEL% neq 0 goto copyfailed
echo OK

echo Signing managed desktop library DLLs...
%CI_SIGNING%\CodeSignUtility\csu.exe /c1=72 /c2=10006 "/d=.NET SDK" "/kw=MediaServices"
if %ERRORLEVEL% neq 0 goto signfailed
echo OK

echo Removing all unsigned files from \\adksdksign\unsigned...
del /q c:\signing\tosign\*.*
echo OK

echo Copying Media SDK signed managed DLLs and the pdbs to the final drop location...
echo Creating \drop\WAMSSDK\lib\net45
md .\drop\WAMSSDK\lib\net45

echo Copy MediaServices.Client.dll
copy /y c:\signing\signed\Microsoft.WindowsAzure.MediaServices.Client.dll .\drop\WAMSSDK\lib\net45\
copy /y \\adxsdkbuilder\Signed\Microsoft.WindowsAzure.MediaServices.Client.dll .\drop\WAMSSDK\lib\net45\
echo Copy Microsoft.WindowsAzure.MediaServices.Client.Common.FileEncryption.dll
copy /y c:\signing\signed\Microsoft.WindowsAzure.MediaServices.Client.Common.FileEncryption.dll .\drop\WAMSSDK\lib\net45\
copy /y \\adxsdkbuilder\Signed\Microsoft.WindowsAzure.MediaServices.Client.Common.FileEncryption.dll .\drop\WAMSSDK\lib\net45\
echo Copy Microsoft.WindowsAzure.MediaServices.Client.Common.BlobTransfer.dll
copy /y c:\signing\signed\Microsoft.WindowsAzure.MediaServices.Client.Common.BlobTransfer.dll .\drop\WAMSSDK\lib\net45\
copy /y \\adxsdkbuilder\Signed\Microsoft.WindowsAzure.MediaServices.Client.Common.BlobTransfer.dll .\drop\WAMSSDK\lib\net45\
echo Copy MediaServices.Client.pdb
copy /y .\Publish\Build\Release\Microsoft.WindowsAzure.MediaServices.Client.pdb .\drop\WAMSSDK\lib\net45\

echo Copy Nuget spec
copy /y .\.nuget\windowsazure.mediaservices.nuspec .\drop\WAMSSDK\
if %ERRORLEVEL% neq 0 goto copyfailed
Expand All @@ -46,13 +27,7 @@ copy .\drop\*.* c:\packages
if %ERRORLEVEL% neq 0 goto copyfailed
echo OK

echo Removing all signed files from \\adksdksign\unsigned...
del /q c:\signing\signed\*.*
echo OK

echo Removing all unsigned files from \\adksdksign\unsigned...
del /q c:\signing\tosign\*.*
echo OK

echo SUCCESS. Signed files are available at \\adxsdksign\packages

Expand Down
63 changes: 43 additions & 20 deletions src/net/Client/AzureMediaServicesClassFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
// limitations under the License.
// </license>

using Microsoft.WindowsAzure.MediaServices.Client.OAuth;
using Microsoft.WindowsAzure.MediaServices.Client.RequestAdapters;
using Microsoft.WindowsAzure.MediaServices.Client.TransientFaultHandling;
using System;
using System.Collections.Generic;
using System.Data.Services.Client;
using System.Data.Services.Common;
using System.Linq;
using System.Net;
using Microsoft.WindowsAzure.MediaServices.Client.OAuth;
using Microsoft.WindowsAzure.MediaServices.Client.RequestAdapters;
using Microsoft.WindowsAzure.MediaServices.Client.TransientFaultHandling;


namespace Microsoft.WindowsAzure.MediaServices.Client
{
Expand Down Expand Up @@ -49,7 +52,7 @@ public class AzureMediaServicesClassFactory : MediaServicesClassFactory
private const int ConnectionRetrySleepQuantum = 100;

private static Cache<Uri> _endpointCache = new Cache<Uri>();
private IWebRequestAdapter _clientRequestIdAdapter ;
private IWebRequestAdapter _clientRequestIdAdapter;
public AzureMediaServicesClassFactory()
{

Expand All @@ -61,7 +64,7 @@ public AzureMediaServicesClassFactory()
/// <param name="mediaContext">The <seealso cref="CloudMediaContext" /> instance.</param>
public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, CloudMediaContext mediaContext)
{
_dataServiceAdapter = new OAuthDataServiceAdapter(mediaContext.Credentials, NimbusRestApiCertificateThumbprint,NimbusRestApiCertificateSubject);
_dataServiceAdapter = new OAuthDataServiceAdapter(mediaContext.Credentials, NimbusRestApiCertificateThumbprint, NimbusRestApiCertificateSubject);
_serviceVersionAdapter = new ServiceVersionAdapter(KnownApiVersions.Current);
_userAgentAdapter = new UserAgentAdapter(KnownClientVersions.Current);
_mediaContext = mediaContext;
Expand All @@ -78,18 +81,30 @@ public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, CloudMedia
/// <param name="userAgentAdapter">The user agent request adapter</param>
public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter serviceVersionAdapter, MediaContextBase mediaContext, UserAgentAdapter userAgentAdapter)
{
this._dataServiceAdapter = dataServiceAdapter;
this._serviceVersionAdapter = serviceVersionAdapter;
this._mediaContext = mediaContext;
_dataServiceAdapter = dataServiceAdapter;
_serviceVersionAdapter = serviceVersionAdapter;
_mediaContext = mediaContext;
_userAgentAdapter = userAgentAdapter;
_azureMediaServicesEndpoint = CreateAzureMediaServicesEndPoint(azureMediaServicesEndpoint, mediaContext);
}

/// <summary>
/// Creates a data service context.
/// Creates instance of <see cref="IMediaDataServiceContext"/>.Deafault list of <see cref="IDataServiceContextAdapter"/> applied .
/// </summary>
/// <returns>The new DataServiceContext instance.</returns>
/// <returns>The new <see cref="IMediaDataServiceContext"/> instance.</returns>
public override IMediaDataServiceContext CreateDataServiceContext()
{

return CreateDataServiceContext(new List<IDataServiceContextAdapter>());

}

/// <summary>
/// Creates instance of <see cref="IMediaDataServiceContext"/> with contains additional applyed <see cref="IDataServiceContextAdapter"/> adapters
/// </summary>
/// <param name="adapters"></param>
/// <returns><see cref="IMediaDataServiceContext"/></returns>
public override IMediaDataServiceContext CreateDataServiceContext(IEnumerable<IDataServiceContextAdapter> adapters)
{
DataServiceContext dataContext = new DataServiceContext(_azureMediaServicesEndpoint, DataServiceProtocolVersion.V3)
{
Expand All @@ -98,19 +113,16 @@ public override IMediaDataServiceContext CreateDataServiceContext()
MergeOption = MergeOption.PreserveChanges,
};

var clientRequestIdAdapter = new ClientRequestIdAdapter();
List<IDataServiceContextAdapter> dataServiceContextAdapters = GetDefaultDataContextAdapters().ToList();
dataServiceContextAdapters.AddRange(adapters.ToList());
dataServiceContextAdapters.ForEach(c => c.Adapt(dataContext));

this._dataServiceAdapter.Adapt(dataContext);
this._serviceVersionAdapter.Adapt(dataContext);
this._userAgentAdapter.Adapt(dataContext);
clientRequestIdAdapter.Adapt(dataContext);

dataContext.ReadingEntity += this.OnReadingEntity;
ClientRequestIdAdapter clientRequestIdAdapter = dataServiceContextAdapters.FirstOrDefault(c => c is ClientRequestIdAdapter) as ClientRequestIdAdapter;
dataContext.ReadingEntity += OnReadingEntity;
var queryRetryPolicy = GetQueryRetryPolicy(null);
var context = new MediaDataServiceContext(dataContext, queryRetryPolicy, clientRequestIdAdapter);
queryRetryPolicy.RetryPolicyAdapter = context;
return context;

}

/// <summary>
Expand All @@ -125,6 +137,17 @@ public override IWebRequestAdapter CreateClientRequestIdAdapter()
}
return _clientRequestIdAdapter;
}

/// <summary>
/// Returns IEnumerable of type <see cref="IDataServiceContextAdapter"/> which applied by default for each request
/// </summary>
/// <returns></returns>
public override IEnumerable<IDataServiceContextAdapter> GetDefaultDataContextAdapters()
{
var clientRequestIdAdapter = new ClientRequestIdAdapter();
return new IDataServiceContextAdapter[]{ _dataServiceAdapter, _serviceVersionAdapter, _userAgentAdapter, clientRequestIdAdapter };
}

/// <summary>
/// Creates retry policy for working with Azure blob storage.
/// </summary>
Expand Down Expand Up @@ -239,7 +262,7 @@ private void OnReadingEntity(object sender, ReadingWritingEntityEventArgs args)
IMediaContextContainer mediaContextContainer = args.Entity as IMediaContextContainer;
if (mediaContextContainer != null)
{
mediaContextContainer.SetMediaContext(this._mediaContext);
mediaContextContainer.SetMediaContext(_mediaContext);
}
}

Expand All @@ -252,7 +275,7 @@ private Uri CreateAzureMediaServicesEndPoint(Uri azureMediaServicesEndpoint, Med

return (_endpointCache.GetOrAdd(
cacheKey,
() => GetAccountApiEndpoint(_dataServiceAdapter,_serviceVersionAdapter, azureMediaServicesEndpoint, _userAgentAdapter,CreateClientRequestIdAdapter()),
() => GetAccountApiEndpoint(_dataServiceAdapter, _serviceVersionAdapter, azureMediaServicesEndpoint, _userAgentAdapter, CreateClientRequestIdAdapter()),
() => mediaContext.Credentials.TokenExpiration));
}
}
Expand Down
28 changes: 17 additions & 11 deletions src/net/Client/CloudMediaContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ namespace Microsoft.WindowsAzure.MediaServices.Client
/// </summary>
public partial class CloudMediaContext : MediaContextBase
{
/// <summary>
/// The certificate thumbprint for Nimbus services.
/// </summary>
internal const string NimbusRestApiCertificateThumbprint = "AC24B49ADEF9D6AA17195E041D3F8D07C88EC145";

/// <summary>
/// The certificate subject for Nimbus services.
/// </summary>
internal const string NimbusRestApiCertificateSubject = "CN=NimbusRestApi";

private static readonly Uri _mediaServicesUri = new Uri("https://media.windows.net/");

private AssetCollection _assets;
Expand All @@ -53,7 +43,7 @@ public partial class CloudMediaContext : MediaContextBase
private EncodingReservedUnitCollection _encodingReservedUnits;
private MediaServicesClassFactory _classFactory;
private Uri apiServer;

private StreamingFilterBaseCollection _streamingFilters;

/// <summary>
/// Initializes a new instance of the <see cref="CloudMediaContext"/> class.
Expand Down Expand Up @@ -360,5 +350,21 @@ public override EncodingReservedUnitCollection EncodingReservedUnits
return this._encodingReservedUnits;
}
}

/// <summary>
/// Gets the collection of Filters (account level Filter)
/// </summary>
public override StreamingFilterBaseCollection Filters
{
get
{
if (_streamingFilters == null)
{
Interlocked.CompareExchange(ref _streamingFilters, new StreamingFilterBaseCollection(this), null);
}
return this._streamingFilters;

}
}
}
}
92 changes: 92 additions & 0 deletions src/net/Client/Collections/AssetFilterBaseCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//-----------------------------------------------------------------------
// <copyright file="AssetFilterBaseCollection.cs" company="Microsoft">Copyright 2015 Microsoft Corporation</copyright>
// <license>
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </license>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.MediaServices.Client.TransientFaultHandling;

namespace Microsoft.WindowsAzure.MediaServices.Client
{
public class AssetFilterBaseCollection : BaseCollection<IStreamingAssetFilter>
{
public static readonly string AssetFilterSet = "AssetFilters";
private IAsset _parentAsset;
private List<IStreamingAssetFilter> _filterData;

internal AssetFilterBaseCollection(MediaContextBase cloudMediaContext, IAsset parentAsset, List<AssetFilterData> filterDatas)
: base(cloudMediaContext)
{
_parentAsset = parentAsset;
_filterData = filterDatas.Select(af => af as IStreamingAssetFilter).ToList();
}

/// <summary>
/// Gets the queryable collection of programs.
/// </summary>
protected override IQueryable<IStreamingAssetFilter> Queryable
{
get { return _filterData.AsQueryable(); }
set { throw new NotSupportedException(); }
}

/// <summary>
/// Creates new Filter
/// </summary>
/// <param name="name">filter name</param>
/// <param name="timeRange">streaming time range</param>
/// <param name="trackConditions">filter track conditions</param>
/// <returns>The created filter.</returns>
public IStreamingAssetFilter Create(string name, PresentationTimeRange timeRange, IList<FilterTrackSelectStatement> trackConditions)
{
return AsyncHelper.Wait(CreateAsync(name, timeRange, trackConditions));
}

/// <summary>
/// Asynchronously creates new StreamingFilter.
/// </summary>
/// <param name="name">filter name</param>
/// <param name="timeRange">filter boundaries</param>
/// <param name="trackConditions">filter track conditions</param>
/// <returns>The task to create the filter.</returns>
public Task<IStreamingAssetFilter> CreateAsync(string name, PresentationTimeRange timeRange, IList<FilterTrackSelectStatement> trackConditions)
{
if (String.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
}

AssetFilterData filter = new AssetFilterData(_parentAsset.Id, name, timeRange, trackConditions);

filter.SetMediaContext(MediaContext);

IMediaDataServiceContext dataContext = MediaContext.MediaServicesClassFactory.CreateDataServiceContext();
dataContext.AddObject(AssetFilterSet, filter);

MediaRetryPolicy retryPolicy = MediaContext.MediaServicesClassFactory.GetSaveChangesRetryPolicy(dataContext as IRetryPolicyAdapter);

return retryPolicy.ExecuteAsync(() => dataContext.SaveChangesAsync(filter))
.ContinueWith<IStreamingAssetFilter>(
t =>
{
t.ThrowIfFaulted();
return (AssetFilterData)t.Result.AsyncState;
},
TaskContinuationOptions.ExecuteSynchronously);
}
}
}
Loading

0 comments on commit fa207ce

Please sign in to comment.