Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
cd6487b
added lva sdk package
hivyas Nov 17, 2020
114b57e
removing tests and hardcoded strings
hivyas Nov 17, 2020
d5c5730
fixed tox errors
hivyas Nov 18, 2020
3badfa8
modifying readme to pass tests
hivyas Nov 19, 2020
8b91e11
fixed missing tests error
hivyas Nov 19, 2020
2419d1b
fixing dev requirments
hivyas Nov 19, 2020
34cd455
fixing readme and dev requirment
hivyas Nov 19, 2020
637974d
renaming readme file
hivyas Nov 20, 2020
99a9c27
fixed casing in read me file
hivyas Nov 20, 2020
86ec46b
fixing dependency requirments
hivyas Nov 20, 2020
ca8ce7d
updating README file
hivyas Dec 2, 2020
ca812fc
fixed broken links
hivyas Dec 2, 2020
b90a28a
fixed broken link
hivyas Dec 2, 2020
67d9f15
updated readme with examples
hivyas Dec 2, 2020
584198d
updating readme based on comments
hivyas Dec 2, 2020
f2b12d5
changing package name
hivyas Dec 3, 2020
aacf22a
fixing broken link
hivyas Dec 3, 2020
773fff7
missed one namespace update'
hivyas Dec 3, 2020
8c46e02
missed more namespace changes
hivyas Dec 3, 2020
250b393
changes based off PR comments
hivyas Dec 3, 2020
46e4fa5
sample changes and removing hardcoded strings
hivyas Dec 4, 2020
2cd1cd7
updated generated code
hivyas Dec 7, 2020
9d5573b
updating swagger and import statement
hivyas Dec 8, 2020
5acee23
Improve import system
lmazuel Dec 8, 2020
0909a8a
regenerated using public swagger
hivyas Dec 10, 2020
b3d6445
renaming package and folder
hivyas Dec 10, 2020
1f0a22c
updating ci file with new folder name
hivyas Dec 10, 2020
9b01c04
Merge remote-tracking branch 'upstream/master'
hivyas Dec 11, 2020
618a51e
updated package name correctly and test
hivyas Dec 11, 2020
96406a1
updating test with missing parameter and sampels with better placehol…
hivyas Dec 11, 2020
379967c
updating ci file
hivyas Dec 11, 2020
9297d4f
updating ci file
hivyas Dec 11, 2020
2d51142
removing tests and hardcoded strings
hivyas Nov 17, 2020
6363648
fixed tox errors
hivyas Nov 18, 2020
0507a37
modifying readme to pass tests
hivyas Nov 19, 2020
d197f20
fixed missing tests error
hivyas Nov 19, 2020
92f256a
fixing dev requirments
hivyas Nov 19, 2020
31826c3
fixing readme and dev requirment
hivyas Nov 19, 2020
a3df331
renaming readme file
hivyas Nov 20, 2020
9b38847
fixed casing in read me file
hivyas Nov 20, 2020
a9cbd5e
fixing dependency requirments
hivyas Nov 20, 2020
88913a7
updating README file
hivyas Dec 2, 2020
a7e4e39
fixed broken links
hivyas Dec 2, 2020
4249244
fixed broken link
hivyas Dec 2, 2020
14a5809
updated readme with examples
hivyas Dec 2, 2020
cd0cc32
updating readme based on comments
hivyas Dec 2, 2020
5314dd9
changing package name
hivyas Dec 3, 2020
5b9149f
fixing broken link
hivyas Dec 3, 2020
656f445
missed one namespace update'
hivyas Dec 3, 2020
c8f67d4
missed more namespace changes
hivyas Dec 3, 2020
1182a3c
changes based off PR comments
hivyas Dec 3, 2020
0a826b3
sample changes and removing hardcoded strings
hivyas Dec 4, 2020
0b6ae58
updated generated code
hivyas Dec 7, 2020
7993cfb
updating swagger and import statement
hivyas Dec 8, 2020
d41e14f
Improve import system
lmazuel Dec 8, 2020
bf7e61b
regenerated using public swagger
hivyas Dec 10, 2020
cfd53fd
renaming package and folder
hivyas Dec 10, 2020
5a6dade
updating ci file with new folder name
hivyas Dec 10, 2020
b78b798
updated package name correctly and test
hivyas Dec 11, 2020
a955d9f
updating test with missing parameter and sampels with better placehol…
hivyas Dec 11, 2020
a14b4ce
updating ci file
hivyas Dec 11, 2020
0cbefcf
merged nspkg
hivyas Dec 11, 2020
bde520e
fixing merge conflicts
hivyas Dec 11, 2020
0ae914e
addressing PR comments
hivyas Dec 11, 2020
0a9c549
fixing typo
hivyas Dec 11, 2020
439e9dc
adding media to nspkg ref
hivyas Dec 11, 2020
f8d218e
adding media-mspkg to shared_requirements
hivyas Dec 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sdk/media/azure-media-livevideoanalytics-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Release History

-------------------

## 0.0.1 (Unreleased)

- Training day!
4 changes: 4 additions & 0 deletions sdk/media/azure-media-livevideoanalytics-edge/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
recursive-include tests *.py
include *.md
include azure/__init__.py
recursive-include samples *.py *.md
135 changes: 135 additions & 0 deletions sdk/media/azure-media-livevideoanalytics-edge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Azure Live Video Analytics for IoT Edge client library for Python

Live Video Analytics on IoT Edge provides a platform to build intelligent video applications that span the edge and the cloud. The platform offers the capability to capture, record, and analyze live video along with publishing the results, video and video analytics, to Azure services in the cloud or the edge. It is designed to be an extensible platform, enabling you to connect different video analysis edge modules (such as Cognitive services containers, custom edge modules built by you with open-source machine learning models or custom models trained with your own data) to it and use them to analyze live video without worrying about the complexity of building and running a live video pipeline.

Use the client library for Live Video Analytics on IoT Edge to:

- Simplify interactions with the [Microsoft Azure IoT SDKs](https://github.com/azure/azure-iot-sdks)
- Programatically construct media graph topologies and instances

[Package (PyPi)][package] | [Product documentation][doc_product] | [Direct methods][doc_direct_methods] | [Media graphs][doc_media_graph] | [Source code][source] | [Samples][samples]

## Getting started

### Install the package

Install the Live Video Analytics client library for Python with pip:

```bash
pip install azure-media-livevideoanalytics--edge
```
### Prerequisites

* Python 2.7, or 3.5 or later is required to use this package.
* You need an active [Azure subscription][azure_sub], and a [IoT device connection string][iot_device_connection_string] to use this package.

### Creating a graph topology and making requests
Please visit the [Examples](#examples) for starter code
## Key concepts

### MediaGraph Topology vs MediaGraph Instance
A _graph topology_ is a blueprint or template of a graph. It defines the parameters of the graph using placeholders as values for them. A _graph instance_ references a graph topology and specifies the parameters. This way you are able to have multiple graph instances referencing the same topology but with different values for parameters. For more information please visit [Media graph topologies and instances][doc_media_graph]

### CloudToDeviceMethod

The `CloudToDeviceMethod` is part of the [azure-iot-hub SDk][iot-hub-sdk]. This method allows you to communicate one way notifications to a device in your IoT hub. In our case, we want to communicate various graph methods such as `MediaGraphTopologySetRequest` and `MediaGraphTopologyGetRequest`. To use `CloudToDeviceMethod` you need to pass in two parameters: `method_name` and `payload`.

The first parameter, `method_name`, is the name of the media graph request you are sending. Make sure to use each method's predefined `method_name` property. For example, `MediaGraphTopologySetRequest.method_name`.

The second parameter, `payload`, sends the entire serialization of the media graph request. For example, `MediaGraphTopologySetRequest.serialize()`

## Examples

### Creating a graph topology
To create a graph topology you need to define parameters, sources, and sinks.
```
#Parameters
user_name_param = MediaGraphParameterDeclaration(name="rtspUserName",type="String",default="dummyusername")
password_param = MediaGraphParameterDeclaration(name="rtspPassword",type="String",default="dummypassword")
url_param = MediaGraphParameterDeclaration(name="rtspUrl",type="String",default="rtsp://rtspsim:554/media/camera-300s.mkv")

#Source and Sink
source = MediaGraphRtspSource(name="rtspSource", endpoint=MediaGraphUnsecuredEndpoint(url="${rtspUrl}",credentials=MediaGraphUsernamePasswordCredentials(username="${rtspUserName}",password="${rtspPassword}")))
node = MediaGraphNodeInput(node_name="rtspSource")
sink = MediaGraphAssetSink(name="assetsink", inputs=[node],asset_name_pattern='sampleAsset-${System.GraphTopologyName}-${System.GraphInstanceName}', segment_length="PT0H0M30S",local_media_cache_maximum_size_mi_b=2048,local_media_cache_path="/var/lib/azuremediaservices/tmp/")

graph_properties = MediaGraphTopologyProperties(parameters=[user_name_param, password_param, url_param], sources=[source], sinks=[sink], description="Continuous video recording to an Azure Media Services Asset")

graph_topology = MediaGraphTopology(name=graph_topology_name,properties=graph_properties)

```

### Creating a graph instance
To create a graph instance, you need to have an existing graph topology.
```
url_param = MediaGraphParameterDefinition(name="rtspUrl", value=graph_url)
graph_instance_properties = MediaGraphInstanceProperties(description="Sample graph description", topology_name=graph_topology_name, parameters=[url_param])

graph_instance = MediaGraphInstance(name=graph_instance_name, properties=graph_instance_properties)

```

### Invoking a graph method request
To invoke a graph method on your device you need to first define the request using the lva sdk. Then send that method request using the iot sdk's `CloudToDeviceMethod`
```
set_method_request = MediaGraphTopologySetRequest(graph=graph_topology)
direct_method = CloudToDeviceMethod(method_name=set_method_request.method_name, payload=set_method_request.serialize())
registry_manager = IoTHubRegistryManager(connection_string)

registry_manager.invoke_device_module_method(device_id, module_d, direct_method)
```

To try different media graph topologies with the SDK, please see the official [Samples][samples].

## Troubleshooting

- When sending a method request using the IoT Hub's `CloudToDeviceMethod` remember to not type in the method request name directly. Instead use `[MethodRequestName.method_name]`
- Make sure to serialize the entire method request before passing it to `CloudToDeviceMethod`

## Next steps

- [Samples][samples]
- [Azure IoT Device SDK][iot-device-sdk]
- [Azure IoTHub Service SDK][iot-hub-sdk]

## Contributing

This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visit https://cla.microsoft.com.

If you encounter any issues, please open an issue on our [Github][github-page-issues].

When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only
need to do this once across all repos using our CLA.

This project has adopted the
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
see the Code of Conduct FAQ or contact [email protected] with any
additional questions or comments.

<!-- LINKS -->
[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/

[cla]: https://cla.microsoft.com
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:[email protected]

[package]: TODO://link-to-published-package
[source]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/media
[samples]: https://github.com/Azure-Samples/live-video-analytics-iot-edge-python

[doc_direct_methods]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/direct-methods
[doc_media_graph]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/media-graph-concept#media-graph-topologies-and-instances
[doc_product]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/

[iot-device-sdk]: https://pypi.org/project/azure-iot-device/
[iot-hub-sdk]: https://pypi.org/project/azure-iot-hub/
[iot_device_connection_string]: https://docs.microsoft.com/azure/media-services/live-video-analytics-edge/get-started-detect-motion-emit-events-quickstart

[github-page-issues]: https://github.com/Azure/azure-sdk-for-python/issues
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------

__path__ = __import__("pkgutil").extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
from azure.media.livevideoanalytics.edge._generated.models import (MediaGraphTopologySetRequestBody,
MediaGraphTopologySetRequest, MediaGraphInstanceSetRequest, MediaGraphInstanceSetRequestBody)

def _OverrideTopologySetRequestSerialize(self):
graph_body = MediaGraphTopologySetRequestBody(name=self.graph.name)
graph_body.system_data = self.graph.system_data
graph_body.properties = self.graph.properties

return graph_body.serialize()

MediaGraphTopologySetRequest.serialize = _OverrideTopologySetRequestSerialize

def _OverrideInstanceSetRequestSerialize(self):
graph_body = MediaGraphInstanceSetRequestBody(name=self.instance.name)
graph_body.system_data = self.instance.system_data
graph_body.properties = self.instance.properties

return graph_body.serialize()

MediaGraphInstanceSetRequest.serialize = _OverrideInstanceSetRequestSerialize
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "1.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmazuel, do we have a policy on what version to use for internal generated packages? Technically, I don't think it matters (it isn't part of the public API surface area), but I wasn't sure if we use it for any kind of internal bookkeeping.

Loading