# Presentation: 230494

## How to build a Node Service

## Node Composition

**AGNodeService**
-   Node Configuration &  Management

**AGServiceManager**
-   AGService “Hosting Environment”

**AGService**
-   Base Class for Services
-    on Nodes that provide
-    access to collaboration
-    resources, these are referred to
-    as “Node Services”

## Service Details

- An AGService deals in the following data:
- Capabilities
- Configurable parameters
- Stream descriptions

## Capabilities

- Each service describes its capabilities

## Capabilities

- Each service describes its capabilities
- The Node Service aggregates the capabilities of its services to send to the venue
- The venue matches the capabilities of the user with its current media streams
- allocates a new stream description when a match is not found
- returns appropriate stream descriptions

- aggregated
- capabilities

- matching
- stream
- descriptions

- Venue
- Client

## Capabilities

- Capabilities are set in the constructor of the service
-  self.capabilities = [ Capability( Capability.PRODUCER, Capability.VIDEO ) ]
- Venue Client retrieves Capabilities using AGService.GetCapabilities method

## Configurable Parameters

- The operation of a service is likely configurable
- For example, the VideoProducerService runs vic internally, so many vic parameters are configurable through the VideoProducerService

## Configurable Parameters

- Configurable parameters are set in the constructor of the service
- Example: VideoProducerService
-  self.streamname = TextParameter( "streamname", "Video" )
-  self.port = TextParameter( "port", "" )
-  self.encoding = OptionSetParameter( "encoding", "h261", 		VideoProducerService.encodings )
-  self.bandwidth = RangeParameter( "bandwidth", 800, 0, 3072 )
-  self.framerate = RangeParameter( "framerate", 25, 1, 30 )
-  self.configuration.append( self.streamname )
-  self.configuration.append( self.port )
-  self.configuration.append( self.encoding )
-  self.configuration.append( self.bandwidth )
-  self.configuration.append( self.framerate )
- UI presentation depends on parameter type
- Node Management retrieves configurable parameters with AGService.GetConfiguration method, and sets parameters with AGService.SetConfiguration method

## Stream Descriptions

- When the venue client has entered a venue, and received stream descriptions from the venue, it passes the stream descriptions to the Node Service
- The Node Service passes the stream descriptions to the individual services via the AGService.ConfigureStream method
- Services reconfigure internally to use new stream descriptions
- In our case, that means restarting the media tools with the new multicast addresses

- aggregated
- capabilities

- matching
- stream
- descriptions

- Venue
- Client

## AGService Interface

- Interface for Services to implement
- def __init__()
- def Start()
- def Stop()
- def ConfigureStream(streamDescription)
- def GetCapabilities()
- def GetConfiguration()
- def SetConfiguration(configuration)
- def SetAuthorizedUsers(authorizedUsers)
- def GetResource()
- def SetResource(resource)
- def GetExecutable()
- def SetExecutable(executable)
- def IsStarted()
- def SetIdentity(profile)

## Specialization of AGService.py

- Using Python
- AGService base class implements most of the AGService interface
- Minimum specialization includes the following methods:
- __init__ – to set configuration parameters and capabilities for the Node Service
- Start – to start underlying software

## Services to consider

- High/Low resolution audio/video services
- Display service
- Describe display dimensions, windows thereon, free space
- Video service with camera control
- Cameras swing into prescribed positions when node configuration is loaded

## Example

- Venue allocates multicast addresses based on Capabilities
- Current Capability description is sooo simplified
- Alternate video producer service
- New video service:
- Assign a new Capability.type (e.g.  video_h263)
- Alter AGService.Start method to send h263
- Implementation of a new service should be nearly as simple as this example
- Capabilities need to be described more richly

## With richer capabilities

- VideoProducerService might claim capability to produce video in multiple encodings (h261, h263, jpeg)
- Venue would resolve which encoding this user should use, by comparing with capabilities of other users in the venue
- According to some policy, like ‘enable highest bandwidth collaboration’, or ‘ensure that all participants can see each other’
- User’s services would be configured using the venue-brokered encoding
- Extend this example from encoding to other parameters

## Service Packaging

- Node Services are provided as packages
- The package is a zip file of:
- a .svc file that describes the service
- [ServiceDescription]
- name = VideoProducerService
- description = Vic-based video service to send video to multicast address
- capabilities = Capability1
- executable = VideoProducerService.py
- platform = neutral
- [Capability1]
- role = producer
- type = video
- an implementation file
- Package location is defined in SystemConfigDir/AGNodeService.cfg