Skip to content

Commit ede01cb

Browse files
Merge pull request #106439 from Juliako/deliver
added a topic
2 parents 336afe0 + 9025b52 commit ede01cb

File tree

7 files changed

+179
-9
lines changed

7 files changed

+179
-9
lines changed

articles/media-services/latest/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@
307307
items:
308308
- name: Publish an asset - CLI
309309
href: cli-publish-asset.md
310+
- name: Create a streaming locator and build URLs
311+
href: create-streaming-locator-build-url.md
310312
- name: Download results
311313
href: download-results-howto.md
312314
- name: Signal descriptive audio

articles/media-services/latest/assets-concept.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ To protect your Assets at rest, the assets should be encrypted by the storage si
7373

7474
[Manage assets in Media Services](manage-asset-concept.md)
7575

76-
## Also see
76+
## See also
7777

7878
[Differences between Media Services v2 and v3](migrate-from-v2-to-v3.md)
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: Create a streaming locator and build URLs - Azure Media Services
3+
description: This article demonstrates how to create a streaming locator and build URLs.
4+
services: media-services
5+
documentationcenter: ''
6+
author: Juliako
7+
manager: femila
8+
editor: ''
9+
10+
ms.service: media-services
11+
ms.workload:
12+
ms.topic: article
13+
ms.date: 03/04/2020
14+
ms.author: juliako
15+
---
16+
17+
# Create a streaming locator and build URLs
18+
19+
In Azure Media Services, to build a streaming URL, you need to first create a [Streaming Locator](streaming-locators-concept.md). You then concatenate the [Streaming Endpoint](https://docs.microsoft.com/rest/api/media/streamingendpoints) host name and the **Streaming Locator** path. In this sample, the *default* **Streaming Endpoint** is used. When you first create a Media Service account, this *default* **Streaming Endpoint** will be in a stopped state, so you need to call **Start** to start streaming.
20+
21+
This article demonstrates how to create a streaming locator and build a streaming URL using Java and .NET SDKs.
22+
23+
## Prerequisite
24+
25+
Preview [Dynamic packaging](dynamic-packaging-overview.md)
26+
27+
## Java
28+
29+
```java
30+
/**
31+
* Creates a StreamingLocator for the specified asset and with the specified streaming policy name.
32+
* Once the StreamingLocator is created the output asset is available to clients for playback.
33+
* @param manager The entry point of Azure Media resource management
34+
* @param resourceGroup The name of the resource group within the Azure subscription
35+
* @param accountName The Media Services account name
36+
* @param assetName The name of the output asset
37+
* @param locatorName The StreamingLocator name (unique in this case)
38+
* @return The locator created
39+
*/
40+
private static StreamingLocator getStreamingLocator(MediaManager manager, String resourceGroup, String accountName,
41+
String assetName, String locatorName) {
42+
// Note that we are using one of the PredefinedStreamingPolicies which tell the Origin component
43+
// of Azure Media Services how to publish the content for streaming.
44+
System.out.println("Creating a streaming locator...");
45+
StreamingLocator locator = manager
46+
.streamingLocators().define(locatorName)
47+
.withExistingMediaservice(resourceGroup, accountName)
48+
.withAssetName(assetName)
49+
.withStreamingPolicyName("Predefined_ClearStreamingOnly")
50+
.create();
51+
52+
return locator;
53+
}
54+
55+
/**
56+
* Checks if the streaming endpoint is in the running state, if not, starts it.
57+
* @param manager The entry point of Azure Media resource management
58+
* @param resourceGroup The name of the resource group within the Azure subscription
59+
* @param accountName The Media Services account name
60+
* @param locatorName The name of the StreamingLocator that was created
61+
* @param streamingEndpoint The streaming endpoint.
62+
* @return List of streaming urls
63+
*/
64+
private static List<String> getStreamingUrls(MediaManager manager, String resourceGroup, String accountName,
65+
String locatorName, StreamingEndpoint streamingEndpoint) {
66+
List<String> streamingUrls = new ArrayList<>();
67+
68+
ListPathsResponse paths = manager.streamingLocators().listPathsAsync(resourceGroup, accountName, locatorName)
69+
.toBlocking().first();
70+
71+
for (StreamingPath path: paths.streamingPaths()) {
72+
StringBuilder uriBuilder = new StringBuilder();
73+
uriBuilder.append("https://")
74+
.append(streamingEndpoint.hostName())
75+
.append("/")
76+
.append(path.paths().get(0));
77+
78+
streamingUrls.add(uriBuilder.toString());
79+
}
80+
return streamingUrls;
81+
}
82+
```
83+
84+
See the full code sample: [EncodingWithMESPredefinedPreset](https://github.com/Azure-Samples/media-services-v3-java/blob/master/VideoEncoding/EncodingWithMESPredefinedPreset/src/main/java/sample/EncodingWithMESPredefinedPreset.java)
85+
86+
## .NET
87+
88+
```csharp
89+
/// <summary>
90+
/// Creates a StreamingLocator for the specified asset and with the specified streaming policy name.
91+
/// Once the StreamingLocator is created the output asset is available to clients for playback.
92+
/// </summary>
93+
/// <param name="client">The Media Services client.</param>
94+
/// <param name="resourceGroupName">The name of the resource group within the Azure subscription.</param>
95+
/// <param name="accountName"> The Media Services account name.</param>
96+
/// <param name="assetName">The name of the output asset.</param>
97+
/// <param name="locatorName">The StreamingLocator name (unique in this case).</param>
98+
/// <returns>A task.</returns>
99+
private static async Task<StreamingLocator> CreateStreamingLocatorAsync(
100+
IAzureMediaServicesClient client,
101+
string resourceGroup,
102+
string accountName,
103+
string assetName,
104+
string locatorName)
105+
{
106+
Console.WriteLine("Creating a streaming locator...");
107+
StreamingLocator locator = await client.StreamingLocators.CreateAsync(
108+
resourceGroup,
109+
accountName,
110+
locatorName,
111+
new StreamingLocator
112+
{
113+
AssetName = assetName,
114+
StreamingPolicyName = PredefinedStreamingPolicy.ClearStreamingOnly
115+
});
116+
117+
return locator;
118+
}
119+
120+
/// <summary>
121+
/// Checks if the streaming endpoint is in the running state,
122+
/// if not, starts it. Then, builds the streaming URLs.
123+
/// </summary>
124+
/// <param name="client">The Media Services client.</param>
125+
/// <param name="resourceGroupName">The name of the resource group within the Azure subscription.</param>
126+
/// <param name="accountName"> The Media Services account name.</param>
127+
/// <param name="locatorName">The name of the StreamingLocator that was created.</param>
128+
/// <param name="streamingEndpoint">The streaming endpoint.</param>
129+
/// <returns>A task.</returns>
130+
private static async Task<IList<string>> GetStreamingUrlsAsync(
131+
IAzureMediaServicesClient client,
132+
string resourceGroupName,
133+
string accountName,
134+
String locatorName,
135+
StreamingEndpoint streamingEndpoint)
136+
{
137+
IList<string> streamingUrls = new List<string>();
138+
139+
ListPathsResponse paths = await client.StreamingLocators.ListPathsAsync(resourceGroupName, accountName, locatorName);
140+
141+
foreach (StreamingPath path in paths.StreamingPaths)
142+
{
143+
UriBuilder uriBuilder = new UriBuilder
144+
{
145+
Scheme = "https",
146+
Host = streamingEndpoint.HostName,
147+
148+
Path = path.Paths[0]
149+
};
150+
streamingUrls.Add(uriBuilder.ToString());
151+
}
152+
153+
return streamingUrls;
154+
}
155+
```
156+
157+
See the full code sample: [EncodingWithMESPredefinedPreset](https://github.com/Azure-Samples/media-services-v3-dotnet/blob/master/VideoEncoding/EncodingWithMESPredefinedPreset/Program.cs)
158+
159+
## See also
160+
161+
* [Create filters with .NET](filters-dynamic-manifest-dotnet-howto.md)
162+
* [Create filters with REST](filters-dynamic-manifest-rest-howto.md)
163+
* [Create filters with CLI](filters-dynamic-manifest-cli-howto.md)
164+
165+
## Next steps
166+
167+
[Protect your content with DRM](protect-with-drm.md).

articles/media-services/latest/download-results-howto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ editor: ''
1010
ms.service: media-services
1111
ms.workload:
1212
ms.topic: article
13-
ms.date: 02/18/2019
13+
ms.date: 03/04/2020
1414
ms.author: juliako
1515
---
1616

articles/media-services/latest/live-events-outputs-concept.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ When creating a Live Event, you can specify the following options:
8585
* Max live event name is 32 characters.
8686
* The name should follow this [regex](https://docs.microsoft.com/dotnet/standard/base-types/regular-expression-language-quick-reference) pattern: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`.
8787

88-
Also see, [Streaming Endpoints naming conventions](streaming-endpoint-concept.md#naming-convention).
88+
Also see [Streaming Endpoints naming conventions](streaming-endpoint-concept.md#naming-convention).
8989

9090
> [!TIP]
9191
> To guarantee uniqueness of your live event name, you can generate a GUID then remove all the hyphens and curly brackets (if any). The string will be unique across all live events and its length is guaranteed to be 32.
@@ -103,7 +103,7 @@ You can either use non-vanity URLs or vanity URLs.
103103

104104
Non-vanity URL is the default mode in Media Services v3. You potentially get the Live Event quickly but ingest URL is known only when the live event is started. The URL will change if you do stop/start the Live Event. <br/>Non-Vanity is useful in scenarios when an end user wants to stream using an app where the app wants to get a live event ASAP and having a dynamic ingest URL isn't a problem.
105105

106-
If a client app doesnt need to pre-generate an ingest URL before the Live Event is created, let Media Services autogenerate the Access Token for the live event.
106+
If a client app doesn't need to pre-generate an ingest URL before the Live Event is created, let Media Services autogenerate the Access Token for the live event.
107107

108108
* Vanity URL
109109

@@ -125,7 +125,7 @@ You can either use non-vanity URLs or vanity URLs.
125125

126126
* The *random* string below is a 128-bit hex number (which is composed of 32 characters of 0-9 a-f).
127127
* *your access token*: The valid GUID string you set when using the vanity mode. For example, `"1fce2e4b-fb15-4718-8adc-68c6eb4c26a7"`.
128-
* *stream name*: Indicates the stream name for a specific connection. The stream name value is usually added by the live encoder you use. You can configure the live encoder to use any name to describe the connection, for example: video1_audio1”, “video2_audio1”, “stream.
128+
* *stream name*: Indicates the stream name for a specific connection. The stream name value is usually added by the live encoder you use. You can configure the live encoder to use any name to describe the connection, for example: "video1_audio1", "video2_audio1", "stream".
129129

130130
#### Non-vanity URL
131131

articles/media-services/latest/manage-asset-concept.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ curl -X PUT \
9292
Asset asset = await client.Assets.CreateOrUpdateAsync(resourceGroupName, accountName, assetName, new Asset());
9393
```
9494

95-
### Also see
95+
### See also
9696

9797
* [Create a job input from a local file](job-input-from-local-file-how-to.md)
9898
* [Create a job input from an HTTPS URL](job-input-from-http-how-to.md)

articles/media-services/latest/streaming-locators-concept.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ editor: ''
1111
ms.service: media-services
1212
ms.workload:
1313
ms.topic: article
14-
ms.date: 05/26/2019
14+
ms.date: 03/04/2020
1515
ms.author: juliako
1616
---
1717

@@ -95,12 +95,13 @@ To get Streaming Locators based on the associated Asset name, use the following
9595
|Java|[AssetStreamingLocator](https://docs.microsoft.com/rest/api/media/assets/liststreaminglocators#assetstreaminglocator)|
9696
|Node.js|[listStreamingLocators](https://docs.microsoft.com/javascript/api/@azure/arm-mediaservices/assets#liststreaminglocators-string--string--string--msrest-requestoptionsbase-)|
9797

98-
## Also see
98+
## See also
9999

100100
* [Assets](assets-concept.md)
101101
* [Streaming Policies](streaming-policy-concept.md)
102102
* [Content Key Policies](content-key-policy-concept.md)
103+
* [Tutorial: Upload, encode, and stream videos using .NET](stream-files-tutorial-with-api.md)
103104

104105
## Next steps
105106

106-
[Tutorial: Upload, encode, and stream videos using .NET](stream-files-tutorial-with-api.md)
107+
[How to create a streaming locator and build URLs](create-streaming-locator-build-url.md)

0 commit comments

Comments
 (0)