+ All Categories
Home > Software > Managing PTZ cameras using Elixir and the Phoenix Framework

Managing PTZ cameras using Elixir and the Phoenix Framework

Date post: 22-Jan-2018
Category:
Upload: jose-garcia-sacristan
View: 4,407 times
Download: 1 times
Share this document with a friend
56
Manage PTZ Cameras with Phoenix José C García-Sacristán @jgsacristan
Transcript
Page 1: Managing PTZ cameras using Elixir and the Phoenix Framework

Manage PTZ Cameras with Phoenix

José C García-Sacristán

@jgsacristan

Page 2: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 3: Managing PTZ cameras using Elixir and the Phoenix Framework

“Phoenix is a framework for building HTML5 apps, API backends and distributed systems to take on the modern Web.”

“Written in Elixir, you get beautiful syntax, productive tooling and a fast runtime”

Page 4: Managing PTZ cameras using Elixir and the Phoenix Framework

2 million connections per server

400 million users, 30 engineers

Page 5: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 6: Managing PTZ cameras using Elixir and the Phoenix Framework

Erlang

• Created in 1986

- Windows in 1985

- Linux in 1991

• Handles 50% of the worlds telecom traffic

• Reported 99.9999999% availability (nine nines)

Page 7: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 8: Managing PTZ cameras using Elixir and the Phoenix Framework

Elixir

Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM). Elixir builds on top of Erlang to provide distributed, fault-tolerant, soft real-time, non-stop applications but also extends it to support metaprogramming with macros and polymorphism via protocols.

Page 9: Managing PTZ cameras using Elixir and the Phoenix Framework

Productivity in Phoenix

• Short term productivity

- Documentation / Guides / Generators

- Eliminates trivial choices

• Long term productivity

- Maintainability

- Introspection

Page 10: Managing PTZ cameras using Elixir and the Phoenix Framework

Easy installation

• $mix local.hex

• $ mix archive.installhttps://github.com/phoenixframework/phoenix/releases/download/v1.0.2/phoenix_new-1.0.2.ez

• $mix phoenix.new my_app

Page 11: Managing PTZ cameras using Elixir and the Phoenix Framework

Endpoints

Page 12: Managing PTZ cameras using Elixir and the Phoenix Framework

Routers

Page 13: Managing PTZ cameras using Elixir and the Phoenix Framework

Controllers

Page 14: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 15: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 16: Managing PTZ cameras using Elixir and the Phoenix Framework

Generators

$ mix phoenix.gen.html

$ mix phoenix.gen.json

$ mix phoenix.gen.channel

Page 17: Managing PTZ cameras using Elixir and the Phoenix Framework

Views & Templates

• Precompiled. Fast

• Views render templates.

• Views serve as a presentation layer

• Beyond HTML

Page 18: Managing PTZ cameras using Elixir and the Phoenix Framework

Performance

Page 19: Managing PTZ cameras using Elixir and the Phoenix Framework

Robust Concurrency Model

• “processes” – extreme lightweight units of concurrency

• Garbage collection is per process

- No global pauses

• Load balances on IO and CPU

Page 20: Managing PTZ cameras using Elixir and the Phoenix Framework

Channels

Trivial realtime communication for connected devices

Page 21: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 22: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 23: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 24: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 25: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 26: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 27: Managing PTZ cameras using Elixir and the Phoenix Framework

But there is more ..

• Form builders

• Static build tools with ES6 by default

• Live reloading

• First class test tools

• Packages via hex.pm (+2MM downloads)

Page 28: Managing PTZ cameras using Elixir and the Phoenix Framework

Applications

• Package and run our code

• Can be started and stopped as a unit

• Provide unified configuration

• Hold processes and state in the supervision tree

Page 29: Managing PTZ cameras using Elixir and the Phoenix Framework

:observer.start

Page 30: Managing PTZ cameras using Elixir and the Phoenix Framework

:observer.start

Page 31: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 32: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 33: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 34: Managing PTZ cameras using Elixir and the Phoenix Framework

• The ONVIF specification defines a common protocol for the exchange of information between network video devices including automatic device discovery, video streaming and intelligence metadata.

Page 35: Managing PTZ cameras using Elixir and the Phoenix Framework

Onvif Specification

Based on relevant Web Services standards including security and IP configuration requirements. Areas covered:• IP configuration• Device discovery• Device management• Media configuration• Real time viewing• Event handling• PTZ camera control• Video analytics• Security

Page 36: Managing PTZ cameras using Elixir and the Phoenix Framework

http://www.onvif.org/onvif/ver20/util/operationIndex.html

Page 37: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

Problems:

• Poor SOAP support in Erlang/Elixir.

• WS-Security not implemented.

• SOAP operations return XML.

• evercam-media needs JSON responses.

Page 38: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

Solution:

• HTTPotion for HTTP requests

Page 39: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 40: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

Solution:

• HTTPotion for HTTP requests

• Own implementation of SOAP Envelope and WS-Security headers.

Page 41: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 42: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 43: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

Solution:

• HTTPotion for HTTP requests

• Own implementation of SOAP Envelope and WS-Security headers.

• Own implementation of XML to Elixir Map transformations using Erlang xmerl library

Page 44: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 45: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

• Definition of needed operations using onvif_client methods.

Page 46: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 47: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

• Definition of needed operations using onvif_client methods.

• Add REST routes to web/router.ex

Page 48: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 49: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 50: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

• Definition of needed operations using onvif_client methods.

• Add REST routes to web/router.ex

• Implement controllers that will invoke ONVIF operations and return the responses as Elixir Map structures.

Page 51: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 52: Managing PTZ cameras using Elixir and the Phoenix Framework

Integration with evercam-media

• Definition of needed operations using onvif_client methods.

• Add REST routes to web/router.ex

• Implement controllers that will invoke ONVIF operations and return the responses as Elixir Map structures.

• Phoenix translate these Maps into JSON structures without the need of extra coding

Page 53: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 54: Managing PTZ cameras using Elixir and the Phoenix Framework

Demo

Page 55: Managing PTZ cameras using Elixir and the Phoenix Framework
Page 56: Managing PTZ cameras using Elixir and the Phoenix Framework

Recommended