Skip to content

Commit 52f89f5

Browse files
Media connector updates (#112)
Updates to media connector sample including those from #111 --------- Co-authored-by: Sam Chang <[email protected]>
1 parent f2c1644 commit 52f89f5

File tree

52 files changed

+908
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+908
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
azure-iot-operations
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
azure-iot-operations
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${PSScriptRoot}/resources
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#Requires -Version 7
2+
<#
3+
Install a resource file.
4+
#>
5+
param (
6+
[Parameter(
7+
Mandatory=$true,
8+
HelpMessage="The resource file.")]
9+
[string]$resourceFile
10+
)
11+
12+
Write-Host "`n"
13+
Write-Host (Split-Path -Path $PSCommandPath -Leaf).ToUpper() -ForegroundColor White
14+
15+
$aioConnectorsNamespace = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath ".config_aio_connectors_namespace") -Raw).Trim()
16+
Write-Host "AIO connectors namespace: $aioConnectorsNamespace"
17+
18+
$resourcesDirectory = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath ".config_resources_path") -Raw).Trim()
19+
$resourcesDirectory = $ExecutionContext.InvokeCommand.ExpandString(${resourcesDirectory})
20+
Write-Host "Resources directory: $resourcesDirectory"
21+
22+
Write-Host "Resource file: $resourceFile"
23+
24+
$fileFullPath=(Join-Path -Path $resourcesDirectory -ChildPath $resourceFile)
25+
Write-Host "Resource file full path: ${fileFullPath}"
26+
27+
Write-Host "Applying the resource..."
28+
. kubectl apply -n ${aioConnectorsNamespace} -f ${fileFullPath}
29+
If ($LastExitCode -ne 0) {
30+
Write-Host "Error: The resource could not be applied."
31+
Exit $LastExitCode
32+
} Else {
33+
Write-Host "The resource was applied successfully.`n"
34+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#Requires -Version 7
2+
<#
3+
Install a resource pair (aep/asset), monitor it, and uninstall it.
4+
#>
5+
param (
6+
[Parameter(
7+
Mandatory,
8+
HelpMessage="The AEP name.")]
9+
[string]$aepName = "",
10+
[Parameter(
11+
Mandatory,
12+
HelpMessage="The asset name.")]
13+
[string]$assetName = "",
14+
[Parameter(
15+
Mandatory,
16+
HelpMessage="The datapoint name.")]
17+
[string]$datapointName = "",
18+
[Parameter(
19+
Mandatory,
20+
HelpMessage="The monitor expression.")]
21+
[string]$monitorExpresion = ""
22+
)
23+
24+
Write-Host "`n"
25+
Write-Host (Split-Path -Path $PSCommandPath -Leaf).ToUpper() -ForegroundColor White
26+
27+
. (Join-Path $PSScriptRoot "Test-Prerequisites.ps1") | Out-Null
28+
29+
$aioNamespace = (Get-Content -Path (Join-Path $PSScriptRoot ".config_aio_namespace") -Raw).Trim()
30+
Write-Host "AIO namespace: $aioNamespace"
31+
32+
$aioConnectorsNamespace = (Get-Content -Path (Join-Path $PSScriptRoot ".config_aio_connectors_namespace") -Raw).Trim()
33+
Write-Host "AIO connectors namespace: $aioConnectorsNamespace"
34+
35+
Write-Host "AEP Name: $aepName"
36+
37+
Write-Host "Asset Name: $assetName"
38+
39+
Write-Host "Datapoint Name: $datapointName"
40+
41+
Write-Host "Installing the resource files..."
42+
. (Join-Path $PSScriptRoot "Install-ResourceFile.ps1") -resourceFile "${aepName}.yaml"
43+
. (Join-Path $PSScriptRoot "Install-ResourceFile.ps1") -resourceFile "${assetName}.yaml"
44+
45+
Write-Host "Waiting for the snapshot-to-mqtt task to be ready...`n"
46+
Start-Sleep -Seconds 3
47+
48+
try {
49+
Write-Host "Starting the monitor command...`n"
50+
$monitorExpresion = $ExecutionContext.InvokeCommand.ExpandString(${monitorExpresion})
51+
Invoke-Expression "${monitorExpresion}"
52+
53+
} finally {
54+
55+
Write-Host "Uninstalling the resource files...`n"
56+
. (Join-Path $PSScriptRoot "Uninstall-ResourceFile.ps1") -resourceFile "${assetName}.yaml"
57+
. (Join-Path $PSScriptRoot "Uninstall-ResourceFile.ps1") -resourceFile "${aepName}.yaml"
58+
59+
Write-Host "Snapshot-to-mqtt task test completed.`n"
60+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Requires -Version 7
2+
3+
$aioConnectorsNamespace = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath ".config_aio_connectors_namespace") -Raw).Trim()
4+
Write-Host "AIO connectors namespace: $aioConnectorsNamespace"
5+
6+
$aepName = "aep-public-http-anonymous-1"
7+
Write-Host "AEP name: $aepName"
8+
9+
$assetName = "asset-public-http-anonymous-1-clip-to-fs-autostart"
10+
Write-Host "Asset name: $assetName"
11+
12+
$datapointName = "clip-to-fs"
13+
Write-Host "Datapoint name: $datapointName"
14+
15+
. (Join-Path -Path $PSScriptRoot -ChildPath "Invoke-ResourceInstallMonitorAndUninstall.ps1") `
16+
-aepName $aepName `
17+
-assetName $assetName `
18+
-datapointName $datapointName `
19+
-monitorExpresion `
20+
"& (Join-Path -Path $PSScriptRoot -ChildPath `"Start-FileSystemMonitor.ps1`") -pathToMonitor /tmp/$aioConnectorsNamespace/data/$assetName/"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Requires -Version 7
2+
3+
$aioConnectorsNamespace = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath ".config_aio_connectors_namespace") -Raw).Trim()
4+
Write-Host "AIO connectors namespace: $aioConnectorsNamespace"
5+
6+
$aepName = "aep-public-http-anonymous-1"
7+
Write-Host "AEP name: $aepName"
8+
9+
$assetName = "asset-public-http-anonymous-1-snapshot-to-fs-autostart"
10+
Write-Host "Asset name: $assetName"
11+
12+
$datapointName = "snapshot-to-fs"
13+
Write-Host "Datapoint name: $datapointName"
14+
15+
. (Join-Path -Path $PSScriptRoot -ChildPath "Invoke-ResourceInstallMonitorAndUninstall.ps1") `
16+
-aepName $aepName `
17+
-assetName $assetName `
18+
-datapointName $datapointName `
19+
-monitorExpresion `
20+
"& (Join-Path -Path $PSScriptRoot -ChildPath `"Start-FileSystemMonitor.ps1`") -pathToMonitor /tmp/$aioConnectorsNamespace/data/$assetName/"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Requires -Version 7
2+
3+
$aioConnectorsNamespace = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath ".config_aio_connectors_namespace") -Raw).Trim()
4+
Write-Host "AIO connectors namespace: $aioConnectorsNamespace"
5+
6+
$aepName = "aep-public-http-anonymous-1"
7+
Write-Host "AEP name: $aepName"
8+
9+
$assetName = "asset-public-http-anonymous-1-snapshot-to-mqtt-autostart"
10+
Write-Host "Asset name: $assetName"
11+
12+
$datapointName = "snapshot-to-mqtt"
13+
Write-Host "Datapoint name: $datapointName"
14+
15+
. (Join-Path -Path $PSScriptRoot -ChildPath "Invoke-ResourceInstallMonitorAndUninstall.ps1") `
16+
-aepName $aepName `
17+
-assetName $assetName `
18+
-datapointName $datapointName `
19+
-monitorExpresion `
20+
"& (Join-Path -Path $PSScriptRoot -ChildPath `"Start-MqttListener.ps1`") -listenTopics $aioConnectorsNamespace/data/$assetName/#"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#Requires -Version 7
2+
3+
$aioConnectorsNamespace = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath ".config_aio_connectors_namespace") -Raw).Trim()
4+
Write-Host "AIO connectors namespace: $aioConnectorsNamespace"
5+
6+
$aepName = "aep-public-http-anonymous-1"
7+
Write-Host "AEP name: $aepName"
8+
9+
$assetName = "asset-public-http-anonymous-1-stream-to-rtsp-autostart"
10+
Write-Host "Asset name: $assetName"
11+
12+
$datapointName = "stream-to-rtsp"
13+
Write-Host "Datapoint name: $datapointName"
14+
15+
. (Join-Path -Path $PSScriptRoot -ChildPath "Invoke-ResourceInstallMonitorAndUninstall.ps1") `
16+
-aepName $aepName `
17+
-assetName $assetName `
18+
-datapointName $datapointName `
19+
-monitorExpresion `
20+
"& (Join-Path -Path $PSScriptRoot -ChildPath `"Start-RtspStreamViewer.ps1`") -assetName $assetName ; `
21+
try { Write-Host `"`nHit Ctrl+C to terminate`" ; Start-Sleep -Seconds 3600 } finally { Write-Host `"`nContinuing...`n`" }"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# What is the media connector?
2+
3+
The media connector makes media from media sources such as edge attached cameras available to other Azure IoT Operations components. The media connector is secure, performant, and can connect to the following media sources:
4+
5+
| Media source | Example URLs | Notes |
6+
|--------------| ---------------|-------|
7+
| Edge attached camera | `file://host/dev/video0`<br/>`file://host/dev/usb0` | No authentication required. The URL refers to the device file. Connects to a node using USB, FireWire, MIPI, or proprietary interface. |
8+
| IP camera | `rtsp://192.168.178.45:554/stream1` | JPEG over HTTP for snapshots, RTSP/RTCP/RTP/MJPEG-TS for video streams. An IP camera might also expose a standard ONVIF control interface. |
9+
| Media server | `rtsp://192.168.178.45:554/stream1` | JPEG over HTTP for snapshots, RTSP/RTCP/RTP/MJPEG-TS for video streams. A media server can also serve images and videos using URLs such as `ftp://host/path` or `smb://host/path` |
10+
| Media file | `http://camera1/snapshot/profile1`<br/>`nfs://server/path/file.extension`<br/>` file://localhost/media/path/file.mkv` | Any media file with a URL accessible from the cluster. |
11+
| Media folder | `file://host/path/to/folder/`<br/>`ftp://server/path/to/folder/` | A folder, accessible from the cluster, that contain media files such as snapshots or clips. |
12+
13+
Example uses of the media connector include:
14+
15+
- Capture snapshots from a video stream or from an image URL and publish them to an MQTT topic. A subscriber to the MQTT topic can use the captured images for further processing or analysis.
16+
17+
- Save video streams to a local file system on your cluster. [Edge Storage Accelerator](https://learn.microsoft.com/azure/azure-arc/edge-storage-accelerator/) can provide a reliable and fault-tolerant solution for uploading the captured video to the cloud for storage or processing.
18+
19+
- Proxy a live video stream from a camera to an endpoint that an operator can access. For security and performance reasons, only the media connector should have direct access to an edge camera. The media connector uses a separate media server component to stream video to an operator's endpoint. This media server can transcode to a variety of protocols such as RTSP, RTCP, SRT, and HLS.
20+
21+
## How does it relate to Azure IoT Operations?
22+
23+
The media connector component is part of Azure IoT Operations. The connector deploys to an Arc-enabled Kubernetes cluster on the edge as part of an Azure IoT Operations deployment. The connector interacts with other Azure IoT Operations elements, such as:
24+
25+
- _Asset endpoints_, which are custom resources in your Kubernetes cluster that define connections to resources such as cameras. An asset endpoint configuration includes the URL of the media source, the type of media source, and any credentials that are needed to access the media source. The media connector uses an asset endpoint to access the media source.
26+
27+
- _Assets_, which in Azure IoT Operations Preview are logical entities that you create to represent a real assets such as cameras. An Azure IoT Operations camera asset can have properties, tags, and video streams.
28+
29+
- The Azure IoT Operations portal, which is a web UI that provides a unified experience for you to manage assets such as cameras. You can use the portal to configure the assets and asset endpoints that the media connector uses to access media sources.

0 commit comments

Comments
 (0)