Beispiel #1
0
        private Uri GetAccountApiEndpoint(OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter versionAdapter, Uri apiServer, UserAgentAdapter userAgentAdapter, ClientRequestIdAdapter clientRequestIdAdapter)
        {
            MediaRetryPolicy retryPolicy = new MediaRetryPolicy(
                GetWebRequestTransientErrorDetectionStrategy(),
                RetryStrategyFactory.DefaultStrategy());

            Uri apiEndpoint = null;

            retryPolicy.ExecuteAction(
                () =>
            {
                HttpWebRequest request    = (HttpWebRequest)WebRequest.Create(apiServer);
                request.AllowAutoRedirect = false;
                dataServiceAdapter.AddAccessTokenToRequest(request);
                versionAdapter.AddVersionToRequest(request);
                userAgentAdapter.AddUserAgentToRequest(request);
                clientRequestIdAdapter.AddClientRequestId(request);

                using (WebResponse response = request.GetResponse())
                {
                    apiEndpoint = GetAccountApiEndpointFromResponse(response);
                }
            }
                );

            return(apiEndpoint);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudMediaContext"/> class.
        /// </summary>
        /// <param name="apiServer">A <see cref="Uri"/> representing a the API endpoint.</param>
        /// <param name="accountName">The Microsoft WindowsAzure Media Services account name to authenticate with.</param>
        /// <param name="accountKey">The Microsoft WindowsAzure Media Services account key to authenticate with.</param>
        /// <param name="scope">The scope of authorization.</param>
        /// <param name="acsBaseAddress">The access control endpoint to authenticate against.</param>
        public CloudMediaContext(Uri apiServer, string accountName, string accountKey, string scope, string acsBaseAddress)
        {
            this.ParallelTransferThreadCount = 10;
            this.NumberOfConcurrentTransfers = 2;

            OAuthDataServiceAdapter dataServiceAdapter =
                new OAuthDataServiceAdapter(accountName, accountKey, scope, acsBaseAddress, NimbusRestApiCertificateThumbprint, NimbusRestApiCertificateSubject);
            ServiceVersionAdapter versionAdapter = new ServiceVersionAdapter(KnownApiVersions.Current);

            this._dataContextFactory = new AzureMediaServicesDataServiceContextFactory(apiServer, dataServiceAdapter, versionAdapter, this);

            this._jobs                  = new JobBaseCollection(this);
            this._jobTemplates          = new JobTemplateBaseCollection(this);
            this._assets                = new AssetCollection(this);
            this._files                 = new AssetFileCollection(this);
            this._accessPolicies        = new AccessPolicyBaseCollection(this);
            this._contentKeys           = new ContentKeyCollection(this);
            this._notificationEndPoints = new NotificationEndPointCollection(this);
            this._mediaProcessors       = new MediaProcessorBaseCollection(this);
            this._locators              = new LocatorBaseCollection(this);
            this._ingestManifests       = new IngestManifestCollection(this);
            this._ingestManifestAssets  = new IngestManifestAssetCollection(this, null);
            this._ingestManifestFiles   = new IngestManifestFileCollection(this, null);
            this._storageAccounts       = new StorageAccountBaseCollection(this);
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaServicesClassFactory" /> class.
 /// </summary>
 /// <param name="azureMediaServicesEndpoint">The Windows Azure Media Services endpoint to use.</param>
 /// <param name="dataServiceAdapter">The data service adapter.</param>
 /// <param name="serviceVersionAdapter">The service version adapter.</param>
 /// <param name="mediaContext">The <seealso cref="CloudMediaContext" /> instance.</param>
 /// <param name="userAgentAdapter">The user agent request adapter</param>
 public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter serviceVersionAdapter, MediaContextBase mediaContext, UserAgentAdapter userAgentAdapter)
 {
     _dataServiceAdapter         = dataServiceAdapter;
     _serviceVersionAdapter      = serviceVersionAdapter;
     _mediaContext               = mediaContext;
     _userAgentAdapter           = userAgentAdapter;
     _azureMediaServicesEndpoint = CreateAzureMediaServicesEndPoint(azureMediaServicesEndpoint, mediaContext);
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaServicesClassFactory" /> class.
 /// </summary>
 /// <param name="azureMediaServicesEndpoint">The Windows Azure Media Services endpoint to use.</param>
 /// <param name="mediaContext">The <seealso cref="CloudMediaContext" /> instance.</param>
 public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, CloudMediaContext mediaContext)
 {
     _dataServiceAdapter         = new OAuthDataServiceAdapter(mediaContext.Credentials, NimbusRestApiCertificateThumbprint, NimbusRestApiCertificateSubject);
     _serviceVersionAdapter      = new ServiceVersionAdapter(KnownApiVersions.Current);
     _userAgentAdapter           = new UserAgentAdapter(KnownClientVersions.Current);
     _mediaContext               = mediaContext;
     _azureMediaServicesEndpoint = CreateAzureMediaServicesEndPoint(azureMediaServicesEndpoint, mediaContext);
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaServicesClassFactory" /> class.
 /// </summary>
 /// <param name="azureMediaServicesEndpoint">The Windows Azure Media Services endpoint to use.</param>
 /// <param name="mediaContext">The <seealso cref="CloudMediaContext" /> instance.</param>
 public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, CloudMediaContext mediaContext)
 {
     _dataServiceAdapter         = new OAuthDataServiceAdapter(mediaContext.TokenProvider);
     _serviceVersionAdapter      = new ServiceVersionAdapter(KnownApiVersions.Current);
     _userAgentAdapter           = new UserAgentAdapter(KnownClientVersions.Current);
     _mediaContext               = mediaContext;
     _azureMediaServicesEndpoint = CreateAzureMediaServicesEndPoint(azureMediaServicesEndpoint, mediaContext);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureMediaServicesDataServiceContextFactory"/> class.
        /// </summary>
        /// <param name="azureMediaServicesEndpoint">The Windows Azure Media Services endpoint to use.</param>
        /// <param name="dataServiceAdapter">The data service adapter.</param>
        /// <param name="serviceVersionAdapter">The service version adapter.</param>
        /// <param name="cloudMediaContext">The <seealso cref="CloudMediaContext"/> instance.</param>
        public AzureMediaServicesDataServiceContextFactory(Uri azureMediaServicesEndpoint, OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter serviceVersionAdapter, CloudMediaContext cloudMediaContext)
        {
            this._dataServiceAdapter    = dataServiceAdapter;
            this._serviceVersionAdapter = serviceVersionAdapter;
            this._cloudMediaContext     = cloudMediaContext;

            this._azureMediaServicesEndpoint = GetAccountApiEndpoint(this._dataServiceAdapter, this._serviceVersionAdapter, azureMediaServicesEndpoint);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudMediaContext"/> class.
 /// </summary>
 /// <param name="apiServer">A <see cref="Uri"/> representing the API endpoint.</param>
 /// <param name="credentials">Microsoft WindowsAzure Media Services credentials.</param>
 public CloudMediaContext(Uri apiServer, MediaServicesCredentials credentials)
 {
     this.apiServer = apiServer;
     this.ParallelTransferThreadCount = 10;
     this.NumberOfConcurrentTransfers = 2;
     this.Credentials   = credentials;
     dataServiceAdapter = new OAuthDataServiceAdapter(credentials, NimbusRestApiCertificateThumbprint, NimbusRestApiCertificateSubject);
     versionAdapter     = new ServiceVersionAdapter(KnownApiVersions.Current);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MediaServicesClassFactory"/> class.
        /// </summary>
        /// <param name="azureMediaServicesEndpoint">The Windows Azure Media Services endpoint to use.</param>
        /// <param name="dataServiceAdapter">The data service adapter.</param>
        /// <param name="serviceVersionAdapter">The service version adapter.</param>
        /// <param name="mediaContext">The <seealso cref="CloudMediaContext"/> instance.</param>
        public AzureMediaServicesClassFactory(Uri azureMediaServicesEndpoint, OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter serviceVersionAdapter, MediaContextBase mediaContext)
        {
            this._dataServiceAdapter    = dataServiceAdapter;
            this._serviceVersionAdapter = serviceVersionAdapter;
            this._mediaContext          = mediaContext;

            string cacheKey = string.Format(
                "{0},{1}",
                mediaContext.Credentials.ClientId,
                azureMediaServicesEndpoint.ToString());

            this._azureMediaServicesEndpoint = _endpointCache.GetOrAdd(
                cacheKey,
                () => GetAccountApiEndpoint(this._dataServiceAdapter, this._serviceVersionAdapter, azureMediaServicesEndpoint),
                () => mediaContext.Credentials.TokenExpiration);
        }