Yamaha MusicCast™ v0.2.2 MusicCast.UPnP.Service

A module for working with UPnP compliant services.

  • It can automatically generate UPnP compliant clients from XML specifications.
  • It provides pub/sub cababilities to subscribe and forward UPnP event notifcations.
  • It provides a mechanism to define custom behavior for specific notification types.

Example

defmodule AVTransport do
  use MusicCast.UPnP.Service, type: "AVTransport:1"
end

By default, the service will be generated from the priv/<transport_1.xml> file of the current application but it can be configured to be any subdirectory of priv by specifying the :priv option.

The MusicCast.UPnP.Serializable protocol provides a way to define your own casting implementation based on the concret event notification type. See cast_event/2 for more details about event serialization.

Summary

Functions

Execute the given action on the given UPnP service

Returns a service event struct from the given XML payload

Returns a map representing the UPnP service

Unsubscribes from a UPnP service

Types

subscription()
subscription() :: {id :: String.t, timeout :: Integer.t}
t()
t() :: %MusicCast.UPnP.Service{device: %{device_type: String.t, device_type: String.t, friendly_name: String.t, manufacturer: String.t, manufacturer_url: String.t, model_description: String.t, model_name: String.t, model_number: String.t, model_url: String.t, udn: String.t, presentation_url: String.t, icon_list: %{width: Integer.t, height: Integer.t, depth: Integer.t, mime_type: String.t, url: String.t}, service_list: %{service_type: String.t, service_id: String.t, scpd_url: String.t, control_url: String.t, event_sub_url: String.t}}, url: String.t, version: %{major: Integer.t, minor: Integer.t}}

Functions

call_action(control_url, service_type, action, params)
call_action(String.t, String.t, String.t | Atom.t, Map.t) ::
  {:ok, term} |
  {:error, term}

Execute the given action on the given UPnP service.

cast_event(service, payload)
cast_event(Module.t, String.t) :: Map.t

Returns a service event struct from the given XML payload.

By implementing the MusicCast.UPnP.Serializable protocol for the given service, you can provide your casting implementation. Have a look at MusicCast.UPnP.AVTransport for a concret example.

describe(service_url)
describe(String.t) :: {:ok, Map.t} | {:error, term}

Returns a map representing the UPnP service.

subscribe(event_url, callback_url_or_session_id, timeout \\ 300)
subscribe(String.t, String.t, Integer.t) ::
  {:ok, subscription} |
  {:error, term}

Subscribes to a UPnP service.

unsubscribe(event_url, session_id)
unsubscribe(String.t, String.t) :: :ok | {:error, term}

Unsubscribes from a UPnP service.