Download - Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Transcript
Page 1: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK 3.2

 PROGRAMMINGC5617M-E6/2013

Page 2: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Contents | Pelco SDK

2

Contents

Chapter 1: Introduction............................................................................... 7Getting Started with the Pelco SDK....................................................................................................7General Requirements.........................................................................................................................9Installing the Pelco SDK....................................................................................................................10System Environment Settings for the Pelco SDK............................................................................. 11Including Required SDK Components For Your Application.............................................................11Setting Up Sample Projects.............................................................................................................. 12

Registering the ActiveX Control..............................................................................................12Adding References to Managed Libraries for C#................................................................... 12

Chapter 2: Device Caching Using Object Model.................................... 17Overview.............................................................................................................................................17Device Caching..................................................................................................................................18Samples..............................................................................................................................................18

Chapter 3: Integrating Pelco Edge Systems and Devices..................... 22Overview.............................................................................................................................................22Adding a Pelco Edge System to a System Collection...................................................................... 22Adding a Pelco Edge Device to a Device Collection........................................................................ 22

Chapter 4: Using Network Displays.........................................................24Overview.............................................................................................................................................24Using a Network Display................................................................................................................... 24

Chapter 5: Displaying and Controlling Streams Using Object Model...26Overview.............................................................................................................................................26Initialize a Stream Object.................................................................................................................. 26Playback Recorded Video................................................................................................................. 27Play a Stream Forward......................................................................................................................28Play a Stream in Reverse................................................................................................................. 29Pause a Stream.................................................................................................................................29Resume Playback of a Paused Stream............................................................................................ 30Switch from Playback to Live............................................................................................................ 30Step Through a Video Stream...........................................................................................................30Take a Snapshot................................................................................................................................31Set the Stream Volume..................................................................................................................... 31Get the Stream State.........................................................................................................................31Get the Stream Mode........................................................................................................................ 32

Chapter 6: Displaying and Controlling Streams Using PelcoAPIViewer 33Overview.............................................................................................................................................33Initializing the Pelco API Viewer (C++)............................................................................................. 33Initializing the Pelco API Viewer (C#)............................................................................................... 34

Using the PelcoAPIViewer Component.................................................................................. 35

Page 3: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Contents

3

Using the PelcoAPIMPFViewerControl Component............................................................... 35Setting Size and Position of Video Display Area.............................................................................. 36Querying an RTP Stream.................................................................................................................. 37Opening, Playing, and Displaying a Live or Playback RTP Stream..................................................38Opening, Playing, and Displaying an RTSP Stream.........................................................................40Forward Playback of RTP and RTSP Streams.................................................................................41Reverse Playback of RTP and RTSP Streams.................................................................................41Fast Forward / Reverse Playback of RTP and RTSP Streams........................................................ 41Pausing RTP and RTSP Playback Streams..................................................................................... 42Frame Forward Playback of the RTP Stream...................................................................................42Frame Reverse Playback of the RTP Stream...................................................................................43Resuming the RTP or RTSP Stream from a Paused State.............................................................. 43Stopping the RTP and RTSP Stream............................................................................................... 43Start Manual Recording of RTP Stream........................................................................................... 44Stop Manual Recording of RTP Stream............................................................................................44Setting Audio Volume of a Live or Playback RTP stream................................................................ 45Displaying Analytic Events for an RTP Stream.................................................................................45Displaying Motion Events for an RTP Stream.................................................................................. 45Displaying a Timestamp Overlay for RTP and RTSP Streams.........................................................45Taking a Snapshot of the Current Video Frame for RTP and RTSP Streams.................................. 47Pan, Tilt, Zoom (PTZ) Control for RTP Stream Using PelcoAPIViewer............................................ 47

Chapter 7: Pan, Tilt, Zoom (PTZ) Control................................................48Overview.............................................................................................................................................48Initializing the PTZ Control Wrapper................................................................................................. 48Continuous Panning...........................................................................................................................50Continuous Tilting.............................................................................................................................. 51Continuous Diagonal Movement........................................................................................................51Stopping Continuous Movement........................................................................................................52Enabling Continuous Pan/Tilt/Move and Zoom APIs by UDP Instead of TCP..................................52Panning to a Specific Position...........................................................................................................53Tilting to a Specific Position.............................................................................................................. 53Moving to a Specific Position............................................................................................................ 54Moving to a Position Relative to the Current Location......................................................................54Getting the Camera’s Current Position............................................................................................. 55Managing the Magnification (Zoom) Value........................................................................................55Managing the Focus Value................................................................................................................56Iris Control..........................................................................................................................................57Scripting..............................................................................................................................................58Creating a Preset...............................................................................................................................59Updating an Existing Preset.............................................................................................................. 59Creating a Pattern..............................................................................................................................59Going to an Existing Preset...............................................................................................................60Removing an Existing Preset............................................................................................................ 60Updating an Existing Pattern.............................................................................................................61Executing an Existing Pattern........................................................................................................... 61Stopping a Pattern Currently Being Executed...................................................................................61

Chapter 8: Events and Alarms................................................................. 62Overview.............................................................................................................................................62

Where Does the Pelco SDK Fit?............................................................................................62Event Arbiter Library............................................................................................................... 63Event Manager........................................................................................................................63

Event Arbiter Library Compared to Event Manager.......................................................................... 64

Page 4: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Contents | Pelco SDK

4

Creating an Event Agent................................................................................................................... 64Returning the Event Subscription URL............................................................................................. 68Initializing the Event Arbiter Library...................................................................................................69

Initializing the Event Arbiter Library for C++...........................................................................69Initializing the Event Arbiter Library for C#.............................................................................69

Initializing the Event Manager........................................................................................................... 70Device or Service Specific Subscriptions..........................................................................................71

Using the Event Arbiter Library to Subscribe Using the Device’s IP Address........................ 71Using the Event Arbiter Library to Subscribe Using the Event Subscription URL...................71Using the Event Arbiter Library to Subscribe to All Instances of a Service............................ 72Using the Event Arbiter Library to Subscribe to a Device's Web Service...............................73Using the Event Arbiter Library to Unsubscribe from a Service............................................. 74

Mass Subscriptions by Category.......................................................................................................74Using the Event Manager to Subscribe to All Services..........................................................74Using the Event Manager to Unsubscribe from All Services..................................................75

Handling Incoming Events................................................................................................................. 76Polling Events.................................................................................................................................... 78

Chapter 9: Extracting Audio and Video Metadata.................................. 80Extracting Audio and Video Metadata...............................................................................................80Motion Detection Metadata................................................................................................................81Pelco Analytics Drawing Primitives................................................................................................... 81Timestamps........................................................................................................................................ 81Getting Started................................................................................................................................... 82Initializing the Metadata Parser Class...............................................................................................83Creating a Metadata Renderer Class................................................................................................83Retrieving the Current Timestamp Metadata.................................................................................... 84Motion Detection Metadata................................................................................................................84

Retrieving Motion Detection Metadata....................................................................................84Rendering Motion Detection Metadata................................................................................... 85

Drawing Metadata..............................................................................................................................85Retrieving Drawing Metadata..................................................................................................85Rendering Drawing Metadata................................................................................................. 86

Chapter 10: Exporting Video.................................................................... 87Overview.............................................................................................................................................87

Where Does the Pelco SDK Fit?............................................................................................87Custom Application Development......................................................................................................87Getting Started................................................................................................................................... 88Initializing the Exporter...................................................................................................................... 88Setting Up Overlay Data on Video to Be Exported...........................................................................89

OverlayData Parameters.........................................................................................................90Resetting Overlay Data...........................................................................................................93

Exporting Video..................................................................................................................................94Exporting a Single Video Clip.................................................................................................94Exporting Video Using a Playlist (PPX)..................................................................................95Stitching Multiple Clips into a Single Video Export................................................................ 97

Polling a Video Export....................................................................................................................... 99Stopping a Video Export....................................................................................................................99Exporting A JPEG Snapshot........................................................................................................... 100

Chapter 11: Web Service Proxies.......................................................... 101Web Service Proxies....................................................................................................................... 101

Page 5: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Contents

5

General Usage.................................................................................................................................101

Chapter 12: Discovery.............................................................................103Device and Service Discovery Overview.........................................................................................103Initializing the Pelco SDK System Manager Wrapper.....................................................................104Automatically Determining the System Manager’s IP Address and Port Number........................... 105Logging In and Logging Out............................................................................................................105Querying Available Devices from the System Manager..................................................................106

Retrieving the System Manager’s Time Zone...................................................................... 107Retrieving the Network Time Server Address...................................................................... 108Retrieving a Web Service’s ID..............................................................................................108Retrieving a Specific Web Service’s Control URL................................................................109Retrieving the NVR Associated with the Device.................................................................. 110Retrieving the Device’s Friendly Name................................................................................ 111Retrieving the Device’s Device Description File (DDF) URL................................................111Retrieving All Web Services Available on a Device............................................................. 112

Retrieving Device Attributes............................................................................................................ 113Retrieving a System Manager’s Attribute............................................................................. 114Retrieving a Web Service’s Attribute....................................................................................115

Creating an IDeviceStorage Class.................................................................................................. 116

Appendix A: Logging.............................................................................. 118

Appendix B: Product Compatibility....................................................... 120

Appendix C: Endura................................................................................ 122

Appendix D: General Event Messages.................................................. 126

Appendix E: Hardware Diagnostics Event Messages.......................... 128ConfigurationButton (20180)............................................................................................................ 128DriverFailure (20150)....................................................................................................................... 129Fans (20020)....................................................................................................................................130HardDrives (20060)..........................................................................................................................132ImproperShutdown (20070)............................................................................................................. 134LinkSpeed (20200)...........................................................................................................................135PowerSupply (20120).......................................................................................................................136UPS (20170).................................................................................................................................... 136

Appendix F: Software Diagnostics Event Messages........................... 138DataLoss 20040...............................................................................................................................138InputStreams 20160.........................................................................................................................139PacketLoss 20080............................................................................................................................140SEBs 20210..................................................................................................................................... 141StorageFull 20190............................................................................................................................143StorageTime 20130..........................................................................................................................144Temperature 20140..........................................................................................................................145

Page 6: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Contents | Pelco SDK

6

Appendix G: Video Streaming and Exporting Performance................ 147

Appendix H: Glossary............................................................................. 150

Page 7: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

7

Chapter

1Introduction

Getting Started with the Pelco SDKThe Pelco SDK enables third parties to use Pelco products, as well as use non-Pelco products andsoftware. The Pelco SDK uses methods in the Pelco API.

The following diagram shows how the SDK interacts with the API.

The API is an open, public interface that helps third party developers to take advantage of the power ofPelco products. The API is both flexible and powerful, but it can also potentially overwhelm some users. Ofcourse, developers can directly use the Pelco API. However, Pelco has found that many customers enjoythe ease of using the SDK.

NOTE: For more information about the Pelco API, refer to http://pdn.pelco.com/content/introduction-pelco-api.

The Pelco SDK provides the following functionality:

• Video rendering• Device and service discovery• User and role management• Pan, tilt, and zoom (PTZ) control• Eventing support• Video export• Audio and video metadata parsing• Object model

Page 8: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

8

Pelco SDK Components

The following table shows the major Pelco SDK components.

SDK Component1 Features / Functionality

System Manager Wrapper Device discovery

Service discovery

Viewer Display and control MPEG-4 and H.264 streams from Pelcocameras and DVRs / NVRs / NSMs.

Control Pan/Tilt/Zoom on Pelco PTZ-enabled cameras.

PTZ Control Wrapper Pan and tilt control

Zoom, iris, and focus control

Basic script management

Event Arbiter Library2 Advanced event subscription management:

Subscribe to individual web service events

Subscribe to events from all instances of a particular webservice

Cancel an active event subscription

Event Manager

Easy to use event subscription, that focuses on subscribing tocategories of events instead of web service specific events.

NOTE:

Event Manager requires an Endura System Manager.

Metadata Parser Parses Pelco Video Elementary Stream (VES) metadata:Timestamp, Motion Detection, Video Analytics Primitives

Render primitives and other data to video frame

Exporter Export video streams into a variety of popular video formats:AVI, MP4, 3GP, or PEF

Overlay data on exported video

Object Model The object model uses objects to communicate with networkedvideo management systems and devices. The object modeloperates in conjunction with device caching, which discoversnetworked devices and stores the device list on the localcomputer on which the program is running.

The Pelco SDK contains sample projects, as shown in the following table.

Code Sample Default Location

1 PelcoGsoap is not a separately installable library, but it is included in the other components as required.2 EventArbiter component also contains Event Manager. Therefore, Event Manager is not a separately

installable component.

Page 9: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

9

Event Arbiter Sample C:\Program Files\Pelco\API\SampleCode\EventArbiterSample

3

Event Manager Sample C:\Program Files\Pelco\API\SampleCode\EventArbiterSample 3

Exporter Sample C:\Program Files\Pelco\API\SampleCode\ExporterSample 3

MetaDataParser Sample C:\Program Files\Pelco\API\SampleCode\MetaDataParserSample 3

Pelco API Viewer Sample C:\Program Files\Pelco\API\SampleCode\PelcoAPIViewerSample 3

PTZ Control WrapperSample

C:\Program Files\Pelco\API\SampleCode\PTZControlWrapperSample 3

System Manager Sample C:\Program Files\Pelco\API\SampleCode\SystemManagerWrapperSample 3

Get Devices Sample C:\Program Files\Pelco\API\CPP\GetDevices 3

C:\Program Files\Pelco\API\DotNet\GetDevices 3

View Video Sample C:\Program Files\Pelco\API\DotNet\ViewVideo 3

The sample projects described in this document assume that the default target installation directory waschosen during installation.

There are additional Pelco SDK advanced sample projects, which show further scenarios for using thePelco SDK. The advanced sample projects are available in a separate download on the Pelco PDN Website. Refer to http://pdn.pelco.com/content/pelco-sdk-samples.

General Requirements

Hardware Requirements

The minimum hardware requirements for the client machine are as follows:

• CPU: Intel 2.4 GHz Core 2 Duo (or higher)• Memory: 2 GB• GPU: DirectX® 9-compatible; must be a dedicated graphics card with at least 128 MB of memory, and

use an AGP bus or a PCI Express bus• Hard disk: 1 GB free hard disk space

NOTE: Virtual machines are not supported for streaming video from Pelco cameras.

In addition to your client machine, a Pelco SDK-compatible Pelco device is required. A list of compatiblePelco hardware can be found in the appendix.

3 On 64-bit systems, C:\Program Files will change to C:\Program Files (x86)

Page 10: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

10

Software Requirements

The software requirements for the client machine are as follows:

• ONE of the following operating systems:

• Microsoft® Windows Server® 2003 32-bit• Microsoft Windows Server 2003 64-bit• Microsoft Windows Server 2008 32-bit• Microsoft Windows Server 2008 64-bit• Microsoft Windows Server 2012 64-bit• Microsoft Windows® XP 32-bit• Microsoft Windows XP 64-bit• Microsoft Windows Vista® 32-bit• Microsoft Windows Vista 64-bit• Microsoft Windows 7 32-bit• Microsoft Windows 7 64-bit• Microsoft Windows 8 32-bit• Microsoft Windows 8 64-bit

NOTE: Pelco does not support using the SDK in 64-bit mode applications. Applications must bebuilt using 32-bit mode, and will still run on 64-bit operating systems.

• The latest version of DirectX 9.0c must be installed even if DirectX 10 or 11 is already installed as partof Windows Vista or higher (refer to http://www.microsoft.com/en-us/download/details.aspx?id=8109)

• ONE of the following combinations of Visual Studio® and Microsoft.NET Framework:

• Visual Studio 2008 and Microsoft.NET Framework 3.5• Visual Studio 2010 and Microsoft.NET Framework 4.0

NOTE: Improper use of audio/visual recording equipment could subject you to civil and criminalpenalties. Applicable laws regarding the use of such capabilities vary between jurisdictions and canrequire, among other things, express written consent from the recorded subjects. You are solelyresponsible for insuring strict compliance with such laws and for strict adherence to any/all rights ofprivacy and personalty.

Installing the Pelco SDKTo install the Pelco SDK, perform the following steps:

1. Uninstall any SDK version 1.x, 2.x or 3.x prior to installing Pelco SDK 3.1.

NOTE: If versions prior to Pelco SDK 3.1 are left installed, they might affect the usability. Somesamples might not build out-of-the-box or might not run at all. A clean install is recommended. Ifthe problem continues, PATH and other env vars should be corrected. Try the following:

• Uninstall other Pelco software such as Workstation, Endura Utilities, or Digital Sentry• Delete \Program Files\Pelco\• Remove all Pelco-related env vars

2. Download the Pelco SDK from the Pelco Developer Network (PDN) at http://pdn.pelco.com. The PelcoSDK is in the Pelco SDK Related Downloads subsection inside the Downloads section. The Pelco SDKhas two separate downloads: One for Visual Studio 2010 (download Pelco SDK vc10), and one forVisual Studio 2008 (download Pelco SDK vc9). Select the appropriate download for your version ofVisual Studio.

3. After downloading the Pelco SDK, double-click the Pelco SDK installer executable. Follow the promptson the screen to perform the installation.

4. After installation, restart the system. This ensures that the environment variables are correctly set.

Page 11: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

11

Assuming the default installation path was chosen, the folders shown in the following table are created.

File Folder Path Description

C:\Program Files\Pelco\API\Include\C++\PelcoAPI 4

Header files for all of the Pelco SDK related classes can befound here.

C:\Program Files\Pelco\API\Include\C++\PelcoSDK 4

Header files for all of the Object Model related classes canbe found here.

C:\Program Files\Pelco\API\Libs\Release 4

Pelco SDK release module libraries can be found within theRelease directory.

C:\Program Files\Pelco\API\Libs\Debug 4

Pelco SDK debug module libraries can be found within theDebug directory.

C:\Program Files\Pelco\API\Libs\Release\Plugins 4

Pelco SDK release plugins can be found within the Pluginsdirectory.

C:\Program Files\Pelco\API\SampleCode 4

Contains all the sample code projects related to Pelco SDKcomponents.

C:\Program Files\Pelco\API\Logging 4

Contains an application called LoggingSetup.exe whichallows you to write a log file for debugging purposes. Youcan manage other logging related information by runningLoggingSetup.exe.

C:\Program Files\Pelco\API\Documentation 4

Contains documentation for Pelco SDK components.

System Environment Settings for the Pelco SDKThe Pelco SDK installer adds the following environment variables to the client machine:

EVEREST_BIN Location of the Pelco SDK binaries. By default, thisis set to C:\Program Files\Pelco\API\Libs.

EVEREST_ROOT Location of the Pelco SDK header files. By defaultthis is set to C:\Program Files\Pelco\API\Include\C++.

PATH This initially points to the C:\Program Files\Pelco\API\Libs\Debug folder.

NOTE: To build Pelco SDK applications in release mode, you must change the PATH variable topoint to the Release directory (for example, C:\Program Files\Pelco\API\Libs\Release).If any of the paths have been changed from the defaults, you must remove the path when the PelcoSDK is uninstalled.

Including Required SDK Components For Your ApplicationWhen distributing your Pelco SDK application, you must ensure that the required Pelco SDK componentre-distributables are installed on the target client machine. As is typical with other vendor re-distributables,

4 On 64-bit systems, C:\Program Files will change to C:\Program Files (x86)

Page 12: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

12

a user interface is not be presented to the user. The re-distributable itself can be called directly by anycustom installer you write for your applications.

Once the re-distributable installation is finished, your custom installer can verify the status of the installationand determine whether a restart of the client machine is required.

The client machines must have DirectX 9.0c installed, plus Visual C++ 2008 Runtime and .NET Framework3.5, or Visual C++ 2010 Runtime and .NET Framework 4.0, depending on your requirements.

As with the complete Pelco SDK, download individual Pelco SDK components and Pelco SDK re-distributables from the Pelco Developer Network (PDN) at http://pdn.pelco.com. Once finisheddownloading, double-click the Pelco SDK installer to begin installation. Follow the on-screen prompts tocomplete the installation.

NOTE: For the latest Pelco documentation, visit http://pdn.pelco.com.

Setting Up Sample ProjectsThis section describes how to set up the sample Pelco SDK projects.

WARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use.

The sample projects are located in the following default folder:

• On 32-bit computers: C:\Program Files\Pelco\API\SampleCode• On 64-bit computers: C:\Program Files (x86)\Pelco\API\SampleCode

NOTE:

On 64-bit computers, set Platform target to x86 before building the project as shown below.

Registering the ActiveX ControlBy default, on 32-bit systems the installer registers the Active X Component (OCX) in the C:\ProgramFiles\Pelco\API\Libs\Debug directory. On 64-bit systems, the directory is C:\Program Files(x86)\Pelco\API\Libs\Debug. To ensure that the OCX registration is successful, change the PATHvariable to point to this directory.

For release builds, you can manually register the Pelco API Viewer ActiveX Component:PelcoAPICOMViewer.ocx. To register the PelcoAPICOMViewer.ocx ActiveX Component, openthe command line and navigate to the Pelco SDK library release directory, which on 32-bit systems isby default: C:\Program Files\Pelco\API\Libs\Release. On 64-bit systems, the directory is C:\Program Files (x86)\Pelco\API\Libs\Release.

Once within the folder, run the Microsoft Register Server (Regsvr32.exe) to register the SDKcomponent as appropriate. This must be run with administrative permissions. For example, to register thePelcoAPICOMViewer.ocx file: Regsvr32 PelcoAPICOMViewer.ocx

Adding References to Managed Libraries for C#After you have registered the Pelco API COM Viewer ActiveX control, open the sample project you want tobuild in Visual Studio (for example, open the Pelco API Viewer Sample C# project).

The next step is to add the references to the Pelco managed library DLLs to the project.

Within Visual Studio’s Solution Explorer window, expand the References section.

Make a note of which of the following Pelco library references are present:

Page 13: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

13

• ManagedEnduraExport(9)• ManagedEventArbiter• ManagedEventManager• ManagedPelcoAPICommon• ManagedPTZControlWrapperNet• ManagedSystemManagerWrapper• Pelco.SDK• PelcoAPIMPFViewer

You will need the list of references shortly. Each Pelco reference might have a yellow exclamationmark (!) next to it. For the Pelco API Viewer Sample C# project, the references needed areManagedPelcoAPICommon and PelcoAPIMPFViewer.

Delete the existing Pelco references by right-clicking each Pelco reference and selecting Remove. Forthe Pelco API Viewer Sample C# project, remove the references to ManagedPelcoAPICommon andPelcoAPIMPFViewer.

From the File menu, select Save All.

From the Build menu, select Clean Solution.

Right-click References and select Add Reference.

Click the Browse tab. Navigate to the correct Pelco library folder. Assuming you used the defaultinstallation path, the folder containing the debug libraries on 32-bit computers is C:\Program Files\Pelco\API\Libs\Debug. On 64-bit computers, the folder is C:\Program Files (x86)\Pelco\API\Libs\Debug.

NOTE: If you are building an application for release, then you use the release libraries in thePelco\API\Libs\Release folder.

Page 14: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

14

Find the project library files that you made a note of earlier, and control-click each of the files. Forexample, the Pelco API Viewer Sample C# project requires the ManagedPelcoAPICommon.dll andPelcoAPIMPFViewer.dll files. Click OK to add the files.

On a 64-bit computer, set Platform target to x86.

Page 15: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

15

NOTE: Pelco does not support using the SDK in 64-bit mode applications. Applications must bebuilt in 32-bit mode, and will still run on 64-bit operating systems.

You can now build and then run the sample project.

NOTE: For projects that require the PelcoAPICOMViewer.ocx control, you might need to cleanand rebuild the project several times before the OCX control will work. This is a Visual Studio / OCXlimitation.

NOTE: For C++ projects, be sure to set the character set to Use Multi-Byte Character Set underthe project properties. Click the project, then select Properties > Configuration Properties >General. You will then see Character Set. Set it to Use Multi-Byte Character Set.

Page 16: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Introduction

16

Page 17: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

17

Chapter

2Device Caching Using Object Model

OverviewPelco SDK 3.0 introduced an object model, which simplifies development of applications that use the SDK.Future versions of the SDK will gradually phase out previous SDK components and replace them withobjects. The object model features the following:

• Uses objects to communicate with networked video management systems and devices• Consists of a group of classes for representing systems, devices connected to those systems, device

properties, and other items

Component Libraries

The following component libraries contain the functionality for the object model:

• PelcoSDK.dll, which is used for C++• Pelco.SDK.dll, which is used for C#

Public Classes

The following table shows the public classes used in the object model.

Table 1: Object Model Public Classes

Class Description

System A system for storing video

SystemCollection A collection of systems

Device A device connected to a system

DeviceCollection A collection of devices

Property A device property

PropertyCollection A collection of properties

Camera A camera for recording a stream

Display A window on a display device within which a stream can be viewed

NetworkDisplay A display device located on a network within which camera outputcan be viewed

Stream An audio visual stream

Event An unmanaged event

Events A collection of unmanaged events

Page 18: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Device Caching Using Object Model

18

Class Description

Exception An exception

Device CachingThe Device Cache is a feature of the Pelco SDK, where a cache of Device Objects is created for devicesthat are connected to the system running the Pelco SDK. The caching of device information results infaster response times and reduced network traffic.

The device information is stored in a database on the local computer. The first attempt to connect to a newPelco system retrieves all of the device information and device parameters, and stores the informationin the database. Future attempts to retrieve the same information is obtained from the database. Acontinuously running background task ensures the device information is the latest version. The minimumdevice cache database refresh interval is five minutes.

The directory where the device cache database is stored depends on the operating system used, asdescribed in the following table.

Table 2: Database Location

Operating System Directory

• Windows XP• Windows Server 2003• Windows Server 2008

C:\Documents and Settings\All Users\Application Data\Pelco\SDK

• Windows Vista• Windows 7• Windows 8• Windows Server 2012

C:\ProgramData\Pelco\SDK

SamplesComplete C# and C++ sample programs are supplied with the Pelco SDK.

• On 32-bit computers, the samples are in the directory C:\Program Files\Pelco\API\SampleCode

• On 64-bit computers, the samples are in the directory C:\Program Files (x86)\Pelco\API\SampleCode

The samples are contained in the subdirectories specified in the following table.

Table 3: Samples

Directory Description

SampleCode\CPP\GetDevices C++ sample that shows how to retrieve the list of connecteddevices.

SampleCode\DotNet\GetDevices C# sample that shows how to retrieve the list of connecteddevices.

When running the samples, the default user name is admin. The default password is also admin.

Page 19: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Device Caching Using Object Model

19

Display the List of Connected Devices

The following sample shows how to display the list of connected devices:

int _tmain(int argc, _TCHAR* argv[]){ try { // Create a system object PelcoSDK::System system("admin:admin@pelcosystem://10.220.196.187:60001?alias=Sample"); // Create a device collection object and populate it with the devices from the system object PelcoSDK::DeviceCollection deviceCollection(system.GetDeviceCollection()); // Loop over the device collection object and display each device name printf("\n\n> DEVICES =================================\n"); for (deviceCollection.Reset(); deviceCollection.MoveNext(); ) { // Retrieve the current device object PelcoSDK::Device device(deviceCollection.Current()); // Display the device name printf("\tDevice Name: %s\n", device.GetModelName()); } // Display the number of devices printf("=========================================\n"); printf("Total Devices: %d", deviceCollection.GetCount()); } catch (PelcoSDK::Exception ex) { printf("An error occurred\nError: %s", ex.Message().c_str()); } return 0;}

The following sections describe the sample details.

Connecting to a System

The following line connects to the system:

PelcoSDK::System system("admin:admin@pelcosystem://10.220.196.187:60001?alias=Sample");

The string passed to the constructor is a URL scheme. The scheme consists of four parts, which aredescribed in the following table.

Table 4: URL Scheme Components

Component Description Example

Credentials User name and password. If the user name and passwordare not provided, then the system object is read-only,which will prevent retrieval of a device collection andaccess to a device object through the GetDevice()method. Basic properties such as the display name, IPaddress, port, alias, and system refresh time can still be

admin:admin

Page 20: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Device Caching Using Object Model

20

Component Description Exampleretrieved. Any attempt to call GetDeviceCollection(),GetDevice(), SetRefreshTime(), SetAlias(), orRemove() will throw an exception with an error code ofPelcoSDK::NotAuthenticated.

System Provider System provider identifier. For an Endura system, the identifieris "pelcosystem". Other system providers might be supportedin the future.

pelcosystem

System Address IP address and port of the system to access. In the sample, a"direct discovery" operation is performed, where both the IPaddress and port are specified. An "autodiscovery" operationcan be performed by omitting the IP address and port. PelcoSDK 3.1 only supports autodiscovery of Endura systems.

10.220.196.187:60001

Parameter Optional parameter. Pelco SDK 3.1 only supports the aliasparameter. This parameter allows the developer to assign akey to the system, which enables easy retrieval at a futurepoint. The alias can be set to any unique value for a particularsystem.

alias=Sample

A system object can be created without first retrieving a system collection object. This provides aconvenient way to add or get a system object.

When the system object is created, a new entry in the Pelco device cache is created. The cachecontains details for the objects contained within the cache. There is a slight delay while the cache entryis populated. The next time the application containing the system object creation statement is started, theSDK will retrieve the system information from the cache and make the information immediately available.

Retrieving a Device Collection

The following line creates a device collection object and populates the object with the retrieved devices:

PelcoSDK::DeviceCollection deviceCollection(system.GetDeviceCollection());

The GetDeviceCollection() method of the system object returns the collection of devices retrievedfrom the system object.

Displaying Device Information

The following sample uses a loop to access the devices in the device collection object, and displays eachdevice name:

// Loop over the device collection object and display each device name printf("\n\n> DEVICES =================================\n");for (deviceCollection.Reset(); deviceCollection.MoveNext(); ){ // Retrieve the current device object PelcoSDK::Device device(deviceCollection.Current()); // Display the device name printf("\tDevice Name: %s\n", device.GetModelName());}

In the sample, deviceCollection.Current() returns an object of type PelcoSDK::Device(). Thesample then displays the name of the device using device.GetModelName().

As can be seen in the sample, the SDK contains methods for iterating over collection objects. A typical useof the iteration methods is to display a list of systems and devices.

Page 21: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Device Caching Using Object Model

21

The iteration methods are shown in the following table.

Table 5: Iteration Methods

Method Description

Reset() Moves back to the start of the collection.

MoveNext() Moves to the next item in the collection. This method must be called beforeCurrent(). Returns true or false (true means the end of the items has not beenreached, false means the end has been reached).

Current() Retrieves the current item in the collection.

The SDK also contains methods for directly accessing a collection. The methods are shown in the followingtable.

Table 6: Methods

Method Description

GetItem(index) Retrieves the item at the specified index.

GetItemByKey(key) Retrieves the item with the specified key. For a device, the key is thedevice UUID. For a system, the preferred key is the system alias.

NOTE: Another SDK method is GetVersion(), which returns the device version. The deviceis accessed directly to retrieve the version, and the retrieved value is not cached. Avoid callingGetVersion() in a loop because of the delay while a response is sent from the device.

Page 22: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Integrating Pelco Edge Systems and Devices

22

Chapter

3Integrating Pelco Edge Systems and Devices

OverviewPelco Edge Devices are

• A device on a network where no System Manager is present• Sarix 1.8.2 (or later) cameras that use camera-level authentication• Devices on an Endura network that bypass the System Manager

Pelco Edge Systems are containers for Pelco Edge Devices and support the ability to create distinctcollections of Pelco devices without requiring a Pelco System Manager. This section describes how to usePelco Edge Systems and Devices with the Pelco SDK object model.

Adding a Pelco Edge System to a System CollectionAdding a Pelco Edge system to a SystemCollection works the same way as creating a PelcoSystemsystem. You must gather the proper information for the Edge system, then call the appropriate method toadd it.

1. Use the Pelco Edge Device URL. This indicates which internal provider to use for system managementand caching. The format ispelcoedgedevices://

2. Determine aliases. This allows the user to create 1…n distinct Pelco Edge Devices systems. The formatis?alias=Name

3. Use a System construction method to construct the edge system. You can use one of two equivalentmethods:

• System system(“pelcoedgedevices://?alias=Mine”);

• System system = SystemCollection.Add( “pelcoedgedevices://?alias=Mine”);

Adding a Pelco Edge Device to a Device CollectionUse the DeviceCollection Add method to add Pelco Edge devices. Pelco Edge Devices are user directeddiscovery only, which is functionally opposite of Pelco System based discovery.

1. Determine the IP address and, optionally, the port. The format ispelcoedgedevices://IPAddress:Port

2. Provide an optional user name and password for those devices that require authentication. The formatis

Page 23: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Integrating Pelco Edge Systems and Devices

23

username:password

Once the data for the devices are determined, you can call the appropriate System function andDeviceCollection Add functions to add the device to the device collection, as shown in the followingexample.

C++ Example:

System system(“pelcoedgedevices://?alias=Mine”); DeviceCollection dc = system.DeviceCollection; DeviceCollection devicesAdded = dc.Add(“admin:admin@pelcoedgedevices://12.34.56.99”);

NOTE: If the device you are trying to add already exists in the collection, the Pelco SDK throwsa "Device already exists" exception. If the SDK cannot contact the device you specify, the SDKthrows "Device not found". If the SDK is able to find the device but it is not supported, the SDKthrows "Device unrecognized".

NOTE: Multiple logical devices can exist at the same IP address and port. For example,a multichannel encoder can have multiple cameras at the same IP address and port. TheDeviceCollection Add method can add all of them. Once you have added one or more devices,you iterate through the returned DeviceCollection to find the specific device you want. Thesedevices are in the system's DeviceCollection, in memory and on disk.

NOTE: Pelco Edge Devices have some limitations compared to PelcoSystem devices. WithPelco Edge Devices, you cannot stream video from a camera to a NetworkDisplay; you can onlystream video to a local Display attached to a local PC. Additinally, Pelco Edge Devices can onlystream live video, and not playback.

NOTE: The Pelco SDK only supports Sarix cameras as edge devices, not including IL 10cameras.

Page 24: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Using Network Displays

24

Chapter

4Using Network Displays

OverviewA Network Display is a device on a network that can display video. A Network Display is different from aDisplay in that the Network Display does not have to be a local device, but can be located anywhere on anetwork.

On Endura Systems, Network Displays are Monitors. The SDK uses the term Network Display to refer toan Endura Monitor device.

Using a Network DisplayTo use a Network Display, you initialize a Camera Object and bind it to a Channel Object on the NetworkDisplay.

Using the object model, it takes a combination of these objects to start the flow of video to the NetworkDisplay. The process is as follows

1. Find the Camera Object that needs to be displayed.

// Get a Camera Object from the DeviceCollection by its UUIDPelcoSDK::Camera cam = deviceColl.GetItemByKey(camUUID);

2. Create a Network Display Object to view the Camera.A Network Display Object represents a device on a network which can contain channels that candisplay video data.

// Create a Network Display ObjectPelcoSDK::NetworkDisplay* pNetworkDisplay = NULL;// Retrieve the device collection.PelcoSDK::DeviceCollection deviceCollection = system->GetDeviceCollection();deviceCollection.Reset();// Retrieve the first network display we findwhile (deviceCollection.MoveNext()){ try { PelcoSDK::Device device(deviceCollection.Current());// Check if we have a network display. If not, create one. if (NETWORK_DISPLAY == device.GetDeviceType()) { pNetworkDisplay = new PelcoSDK::NetworkDisplay(device); break; } }

Page 25: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Using Network Displays

25

catch (PelcoSDK::Exception x1) { REPORT_FAIL("NetworkDisplaySample failed to get Device\n"); }}

3. Retrieve a channel from the Network Display's channel collection. Bind the camera to the channelto view it. With the Camera, Network Display, and Channel Objects created, all the pieces requiredto display the Camera on a Network Display are present. The following example code shows how toretrieve a channel and bind a camera to it.

// Check if we found a Network Display from step 2if (pNetworkDisplay){ try { PelcoSDK::ChannelCollection channelCollection = pNetworkDisplay->GetChannelCollection();// Get the first Channel. PelcoSDK::Channel channel = channelCollection.GetItem(0); // Display the camera. channel.Show(cam); } catch (PelcoSDK::Exception x1) { REPORT_FAIL("NetworkDisplaySample failed to get ChannelCollection or Channel\n"); }// Delete the Network Display object when it is no longer needed. delete pNetworkDisplay; pNetworkDisplay = NULL; }}

Network Display ObjectA Network Display Object is a window on a device on a network.

ChannelA Channel is a portion of a Network Display object on which video from a Camera Objectcan be displayed.

Camera ObjectA Camera Object represents an individual camera device. It is derived from the Deviceclass.

NOTE: It is possible to get and set a camera number for the camera. It is important to notethat a Pelco system allows multiple cameras to have the same camera number. Therefore, acamera's number might not be unique.

Page 26: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

26

Chapter

5Displaying and Controlling Streams Using Object Model

OverviewA security operator must be able to view images that the system IP cameras are capturing. This is the mostimportant thing in any security imaging system. Therefore, displaying a video stream and controlling itsplayback are the first things to be made operational.

Pelco SDK 3.1 includes support for streaming of live and recorded video using the object model describedin the section Object Model. The SDK 3.1 release introduces three new objects: Display, Camera andStream. These objects display video streams from cameras to the local video display and hide thecomplexity seen in the PelcoAPIViewer. Live and playback streams are now treated as a single entity. Theoperator does not have to manage separate live and playback video stream instances but only needs tomanage a single instance of a Stream Object.

Complete C# and C++ sample programs are supplied with the Pelco SDK.

• On 32-bit computers, the samples are in the directory C:\Program Files\Pelco\API\SampleCode

• On 64-bit computers, the samples are in the directory C:\Program Files (x86)\Pelco\API\SampleCode

The samples are contained in the subdirectories specified in the following table.

Table 7: Samples

Directory Description

SampleCode\DotNet\ViewVideo C# sample that shows how to display and control video streams.

Initialize a Stream ObjectInitializing a Stream Object requires getting a Camera Object from the Device Collection. A new StreamObject is constructed after a Camera Object is acquired. The Stream Object is able to initialize itself usingthe given Camera Object.

Using the object model, it takes a combination of objects to start the flow of video to the display. Theprocess is as follows:

1. Find the Camera Object that needs to be displayed.

// Get a Camera Object from the DeviceCollection by its UUIDPelco.SDK.Camera cam = deviceColl.GetItemByKey(camUUID);

2. Create a Stream Object after a Camera is acquired.

// Create a Stream instance from a camera

Page 27: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

27

Pelco.SDK.Stream stream = new Pelco.SDK.Stream(cam);

3. Create a Display Object to view the Stream.A Display Object represents an area of application. The SDK uses a Windows HWND as the displayarea.

// Create a Display Object using the Handle to a pre-defined "videoPanel."Pelco.SDK.Display disp = new Pelco.SDK.Display((IntPtr)videoPanel.Handle);

4. Bind the Stream to the Display Object so it can be viewed.With the Camera, Stream and Display Objects created, all the pieces required to display the Stream arepresent. Class member variables must be declared for _stream and _display to proceed with creating astream instance and display the stream. The following example program:

• Creates a new Stream Object• Creates a new Display Object that binds the videoPanel's Handle to the display• Calls Play on the Stream (kFWD_1X in the call means to play live forward at standard speed)• Displays video on the user interface

private void CreateStreamAndPlay(Camera camera){ try { //Create a Stream instance from a Camera _stream = new Pelco.SDK.Stream(camera); // Create a new Display Object _display = new Pelco.SDK.Display((IntPtr)videoPanel.Handle); //Configure _display to Show _stream _display.Show(_stream); // Start playing the stream forward at 1X _stream.Play(Pelco.SDK.kFWD_1X); } catch (Pelco.SDK.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }}

Display ObjectA Display Object is a window on a local monitor used to view the streams; the DisplayObject is created using a WIN32 HWND.

Camera ObjectA Camera Object represents an individual camera device. It is derived from the Deviceclass. The CreateStream method is used for getting the Stream Object for a particularcamera.

NOTE: It is possible to get and set a camera number for the camera. It is important to notethat a Pelco system allows multiple cameras to have the same camera number. Therefore, acamera's number might not be unique.

Playback Recorded VideoThis section describes how a Stream Object is called for playback and how a specific date or time can bespecified for the start date/time of the stream. Recorded video can be played back in the forward directionor in reverse by using either a positive or negative speed constant respectively. Refer to the sections Playa Stream Forward and Play a Stream in Reverse for pre-defined speed constant definitions.

Page 28: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

28

1. After initializing a Stream Object, call the Stream Play method to playback recorded video. In thisexample, the playback is requested in reverse direction using a negative speed value. The speedconstant kREV_2X specifies reverse direction at two times standard speed.

// Start playing the stream reverse at 2x standard speed._stream.Play(Pelco.SDK.kREV_2X);

If the camera associated with the stream has an associated recorder (NVR/NSM) with recorded video,the stream will start playing in reverse at two times normal speed. If the associated recorder doesnot contain recorded video, there will be no playback stream. This will cause an exception of typePelco.SDK.Exception() to occur providing the following error code and message:

• Error code: NoRecordingFound• Error message: "No recording found on NVR or failed to connect"

The error will occur when the Play method is called. Following the error, the next call of the Play methodwill jump the stream to the dateTime that was previously set by Seek(dateTime).

2. Playback of a stream can be jumped to a specific date, or time, by calling the method Seek with aSystem.DateTime. The following example creates a dateTime that is 24-hours in the past and callsSeek on the Stream Object.

// Seek the stream to yesterdayDateTime yesterday = dateTime.UtcNow.AddDays(-1);_stream.Seek(yesterday);

The stream is automatically put into a paused state following the _stream.Seek call.

NOTE: The stream can restart by calling Play with a desired direction and speed, for example,kFWD_1X or kREV_1X for forward or reverse respectively, at standard speed (1X). If the'DateTime yesterday' location does not contain recorded video, there will be no playback stream.This will cause an exception as explained in the previous step.

Play a Stream ForwardA Stream Object can be played forward or in reverse. This section describes how to play it forward.

Use the method Play with a positive value to play a Stream Object forward. Positive value speedconstants contain kFWD indicating forward direction.

// Play the stream forward at 1x (standard speed)_stream.Play(Pelco.SDK.kFWD_1X);

The following example plays the stream forward at 60x the standard speed.

// Play the stream forward at 60x standard speed_stream.Play(Pelco.SDK.kFWD_60X);

There are predefined speed value constants for typical use described in the following table. Their use isdemonstrated in the above examples.

Table 8: Forward stream speed constants

Speed constant Value Resultant speed (forward direction)

kFWD_QUARTER 0.25 0.25x standard speed

kFWD_HALF 0.50 0.50x standard speed

kFWD_1X 1.0 1x standard speed = standard speed

Page 29: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

29

Speed constant Value Resultant speed (forward direction)

kFWD_2X 2.0 2x standard speed

kFWD_4X 4.0 4x standard speed

kFWD_8X 8.0 8x standard speed

kFWD_16X 16.0 16x standard speed

kFWD_60X 60.0 60x standard speed

kFWD_120X 120.0 120x standard speed

kFWD_300X 300.0 300x standard speed

Play a Stream in ReverseA Stream Object can be played forward or in reverse. This section describes how to play it in reverse.

Use the method Play with a negative value to play a Stream Object in reverse. Negative value speedconstants contain kREV indicating reverse direction.

// Play the stream in reverse at 2x (two times standard speed)_stream.Play(Pelco.SDK.kREV_2X);

The following code plays the stream in reverse at 16x the standard speed.

// Play the stream in reverse at 16x_stream.Play(Pelco.SDK.kREV_16X);

There are predefined speed value constants for typical use described in the following table. Their use isdemonstrated in the above examples. Note that a negative value results in reverse stream direction.

Table 9: Reverse stream speed constants

Speed constant Value Resultant speed (reverse direction)

kREV_QUARTER -0.25 0.25x standard speed

kREV_HALF -0.50 0.50x standard speed

kREV_1X -1.0 1x standard speed = standard speed

kREV_2X -2.0 2x standard speed

kREV_4X -4.0 4x standard speed

kREV_8X -8.0 8x standard speed

kREV_16X -16.0 16x standard speed

kREV_60X -60.0 60x standard speed

kREV_120X -120.0 120x standard speed

kREV_300X -300.0 300x standard speed

Pause a StreamThis section describes how to pause a stream.

Page 30: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

30

Use the Pause method to pause a stream.

// Pause the stream_stream.Pause();

NOTE: When a stream is paused, it will switch to playback automatically. CallingPlay(Pelco.SDK.kFWD_1X) will continue playing the playback stream forward atstandard speed. If the stream was paused in reverse direction playback, callingPlay(Pelco.SDK.kREV_1X) will continue playing the playback stream in reverse at standardspeed.

Resume Playback of a Paused StreamThis section describes how to resume playback of a paused stream.

Use the Play method to resume playback of a stream.

// Play the stream forward at 1x standard speed_stream.Play(Pelco.SDK.kFWD_1X); // Play the stream in reverse at 2x standard speed_stream.Play(Pelco.SDK.kREV_2X);

NOTE: Playback of a stream can be in reverse using _stream.Play(Pelco.SDK.kREV_2X)for two times standard speed. Speed constants containing kFWD play the stream forwardwhereas speed constants containing kREV play the stream in reverse. Refer to the sectionsPlay a Stream Forward and Play a Stream in Reverse for forward and reverse speed constantdefinitions.

Switch from Playback to LiveWhen a Stream is in playback mode, either by calling Seek to a time in the past or by calling the Pausemethod, the Stream can be returned to live mode by calling the GotoLive method.

Use the GotoLive method to return to live mode.

// Return the stream to live mode_stream.GotoLive();

Step Through a Video StreamStep through the video stream one frame at a time by calling the FrameForward or FrameReverse method.

1. To step forward one frame:

// Step forward one frame_stream.FrameForward();

2. To step back one frame:

// Step back one frame_stream.FrameReverse();

Page 31: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

31

Take a SnapshotThis section describes how to capture a snapshot of a single frame of video.

Use the Snapshot method to take a snapshot of a single frame of video.

// Create a snapshot of a single frame of video_stream.Snapshot(fileName);

NOTE: The Snapshot method call requires a fully qualified path and file name for saving thesnapshot.

Set the Stream VolumeThis section describes how to set the volume of a stream.

Use the SetVolume method to provide a volume level.

// Set the audio volume of a stream; in this case, it is set to 10._stream.SetVolume(10);

NOTE: The valid levels for volume are "0" to "100"; the higher the number, the higher thevolume.

Table 10: Stream volume level values

Value Description

0 Mute

1-100 Low volume (1); high volume (100); any level in between

Get the Stream StateThis section describes how to identify the current state of a stream.

Knowing the current state of a stream before performing an action can be helpful. Use the following callto identify the current stream state.

// Get the state of the streamPelcoSDK::STREAM_STATE GetState()

The stream state value returned can be "0", "1", "2" or "3." These values are defined in the followingtable.

Table 11: Stream state values

Value Stream state

0 Stopped

1 Forward

2 Reverse

3 Paused

Page 32: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using Object Model

32

Get the Stream ModeStream Mode returns a value that identifies whether the stream is in live mode or playback mode.

Knowing the current mode of a stream before performing an action can be helpful. Use the following callto identify the current stream mode.

// Get the mode of the streamPelcoSDK::STREAM_STATE GetMode()

The stream state value returned can be "0", "1", "2" or "3." These values are defined in the followingtable.

Table 12: Stream mode values

Value Stream mode

0 Unknown

1 Live; the live stream is active and displayed

2 Playback Seek; all streams (live and playback) are paused, the Seek() method was invokedand when Play() is called, the stream will be in playback mode

3 Playback; the playback stream is active and displayed

Page 33: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

33

Chapter

6Displaying and Controlling Streams UsingPelcoAPIViewer

OverviewThe most important thing in any security imaging system, is for the security operator to view what imagesthe IP cameras are capturing. Consequently displaying a video stream and controlling its playback is mostlikely what you will need to get working first.

This section contains sample C# and C++ that illustrates how to display and control video streams.Complete C# and C++ sample programs are contained in the following subdirectory where the Pelco SDKis installed: C:\Program Files\Pelco\API\SampleCode\PelcoAPIViewerSample

Where Does the Pelco SDK Fit?

To display and control video streams, use the Pelco API Viewer. The Pelco API Viewer is an easy to useWindows based tool for viewing MPEG-4 and H.264 streams from Pelco IP cameras and DVRs / NVRs /NSMs. It provides a Pelco supported player for integrating Pelco devices with 3rd party applications. Thisplayer can be configured to work in both RTP and RTSP mode. In RTP mode, the player uses one ofseveral Pelco API methods to initiate and control streams. While in RTSP mode, the player expects to workwith either devices, such as a Sarix IP camera, where RTSP is supported by default; or software solutionslike the RTSP Server.

The Pelco API Viewer can be used in three ways:

1. C++2. C#3. OCX (ActiveX Control)

Support is provided for viewing both MPEG-4 and H.264 streams, but changing a video configuration fromone format to the other causes the video to stop streaming.

What’s Ahead

There are two major tasks for viewing a video stream using the Pelco API Viewer:

• Opening, playing, displaying a stream• Controlling the stream

Initializing the Pelco API Viewer (C++)Before you can use the Pelco API Viewer, you need to declare and configure your new instance.

1. Declare the Pelco API Viewer instance.

Page 34: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

34

NOTE: The related source code for this entry can be found in main.cpp’s main function, whichresides in the PelcoAPIViewer sample project.

PelcoAPI::PelcoAPIViewer _pViewer;

2. Set the instance’s plug-in directory.Assuming that you did not change the default target installation directory, it can be found here: C:\Program Files\Pelco\API\Libs\Debug\Plugins

NOTE: If running in Release mode, change this path to C:\Program Files\Pelco\API\Libs\Release\Plugins.

The plug-in directory contains components that are key to the SDK’s encoding, decoding, andtranscoding capabilities. Without a proper reference, key features of the Pelco SDK could not functionproperly. Please note that the plug-in directory is dependent on where you installed the Pelco SDK.

NOTE: The related source code for this entry can be found in main.cpp’s main function, whichresides in the PelcoAPIViewer sample project.

_pViewer.SetPluginDir("C:\\Program Files\\Pelco\\API\\Libs\\Debug\\Plugins\\");

3. If required, set the authentication credentials to log into the camera.The following example verifies if authentication is enabled for the camera, and, if so, sets the user nameto "admin" and the password to "admin_password".

// Set example parameters#define CAMERA_IP_ADDRESS "10.220.196.179"#define PORT_NUMBER 80#define CAMERA_NUMBER 1

// Check if authentication is enabledif (_pViewer.IsAuthenticationEnabled(CAMERA_IP_ADDRESS, CAMERA_PORT, CAMERA_NUMBER)){ // Set the user name to "admin", the password to "admin_password", and use basic authentication PelcoAPI::AuthenticationCredentials authentication("admin", "admin_password", PelcoAPI::AuthenticationCredentials::BASIC); _pViewer.SetAuthenticationCredentials(&authentication);}

NOTE: To manage the camera authentication and the users, use the Pelco Web interface.

4. Create a new window handle and associate it to the Pelco API Viewer instance.Please note that logic to create the window handle can be found in the _DbgCreateParentWindowmethod.

HWND _hWndParent = NULL;//... Logic to create a window and display it. Refer to _DbgCreateParentWindow ...m_pViewer->SetWindowHandle((_hWnd ? _hWnd : this->m_hWnd));

Initializing the Pelco API Viewer (C#)NOTE: In release mode, you need to select the Enable unmanaged code debugging check boxin the project settings to view console output.

Page 35: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

35

Before you can use the Pelco API Viewer, you need to declare and configure your new instance.PelcoAPIMPFViewer contains two components: PelcoAPIMPFViewerControl, a convenient, prebuiltcontrol, or a managed version of the PelcoAPIViewer library that enables the developer to control thevideo stream programmatically. Both approaches are described below.

Using the PelcoAPIViewer ComponentTo use the more programmable PelcoAPIViewer library, complete the following steps.

1. Declare the PelcoAPIViewer instance, set the plugin directory, and set the window handle.

PelcoAPI.PelcoAPIViewerNet _pViewer = new PelcoAPI.PelcoAPIViewerNet();_pViewer.SetPluginDir(objstreamparam.PluginDir);_pViewer.SetWindowHandle(windowsviewerobj.Handle);

2. If required, set the authentication credentials to log into the camera.The following example verifies if authentication is enabled for the camera, and, if so, sets the user nameto "admin" and the password to "admin_password".

// Set example parametersconst String CAMERA_IP_ADDRESS = "10.220.196.179";const int PORT_NUMBER = 80;const int CAMERA_NUMBER = 1;

// Check if authentication is enabledif (_pViewer.IsAuthenticationEnabled(CAMERA_IP_ADDRESS, CAMERA_PORT, CAMERA_NUMBER)){ // Set the user name to "admin", the password to "admin_password", and use basic authentication AuthenticationCredentialsNet tmpAuthentication = new AuthenticationCredentialsNet("admin", "admin_password", PelcoAPI.AuthenticationSchemeTypeNet.Basic); _pViewer.SetAuthenticationCredentials(tmpAuthentication);}

NOTE: To manage the camera authentication and the users, use the Pelco Web interface.

Using the PelcoAPIMPFViewerControl ComponentTo use the prebuilt control PelcoAPIMPFViewerControl, complete the following steps.

NOTE: Example source code can be found in PelcoAPIViewerForm.designer.cs constructor, whichresides in the PelcoAPIViewerSample sample project.

1. Declare the Pelco API MPF Viewer instance.

private PelcoAPIMPFViewer.PelcoAPIMPFViewerControl _pViewer;this._pViewer = new PelcoAPIMPFViewer.PelcoAPIMPFViewerControl();

2. Listen for the user selected plug-in directory.Assuming that you did not change the default target installation directory, it can be found here: C:\Program Files\Pelco\API\Libs\Debug\Plugins

NOTE: The plug-in directory contains components that are key to the SDK’s encoding,decoding, and transcoding capabilities. Without a proper reference key features of the PelcoSDK could not function properly. Please note that the plug-in directory is dependent on whereyou installed the Pelco SDK.

private void BrowseForPluginDir(object sender, EventArgs e){

Page 36: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

36

try { this._pOpenFolder.ShowDialog(this); this._txtFolder.Text = _pOpenFolder.SelectedPath + "\\"; } catch(Exception /*ex*/){}}

3. If required, set the authentication credentials to log into the camera.The following example verifies if authentication is enabled for the camera, and, if so, sets the user nameto "admin" and the password to "admin_password".

// Set example parametersconst String CAMERA_IP_ADDRESS = "10.220.196.179";const int PORT_NUMBER = 80;const int CAMERA_NUMBER = 1;

// Check if authentication is enabledif (_pViewer.IsAuthenticationEnabled(CAMERA_IP_ADDRESS, CAMERA_PORT, CAMERA_NUMBER)){ // Set the user name to "admin", the password to "admin_password", and use basic authentication AuthenticationCredentialsNet tmpAuthentication = new AuthenticationCredentialsNet("admin", "admin_password", PelcoAPI.AuthenticationSchemeTypeNet.Basic); _pViewer.SetAuthenticationCredentials(tmpAuthentication);}

NOTE: To manage the camera authentication and the users, use the Pelco Web interface.

4. Save the stream settings.

private void SaveStreamSettings(object sender, EventArgs e){ try { _pViewer.SetPluginDir(_txtFolder.Text); _pViewer.SetupStream(_txtIP.Text, _txtPort.Text, _txtServiceId.Text,_txtTransport.Text); } catch (Exception /*ex*/) { } }

Setting Size and Position of Video Display AreaCalling the SetDisplayRect method to center the video stream display inside a window with marginsdoes not automatically center it. You need to set the size and position of the video display rectangle so thatits width and height are equal to the width and the height of the window.

The SetDisplayRect method allows resizing the video display area when the window is resized. Thus,SetDisplayRect would typically be called from a resize event procedure.

SetDisplayRect contains the following parameters:

topThe starting Y coordinate of the rectangle for its top side.

leftThe starting X coordinate of the rectangle for its left side.

Page 37: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

37

widthThe width of the rectangle.

heightThe height of the rectangle.

PELCO_API_EXPORT void SetDisplayRect(int top, int left, int width, int height)throw ();

For example:

TRACE_INFO("Calling SetDisplayRect\n");_pViewer.SetDisplayRect(75, 100, 824, 618);

Querying an RTP StreamThe VideoQuery function can be used to query the camera or the NSM to retrieve video properties of astream.

For example:

_pViewer.VideoQuery("NOW", "INFINITE", "10.220.196.169", "49153", "1", "4","uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15", "1", False, NULL);

NOTE: Another example usage of this function can be found in the main.cpp file's main function,which belongs to the PelcoAPIViewer sample project SampleConsole9.

The following list shows the parameters:

szStartTimeRequired. The start time within the stream to start play back. For play back of a recordedRTP stream, the start time must be specified in UTC using the following time format:YYYY-MM-DDTHH:MM:SS. For play back of a live RTP stream, set the time to the string"NOW".

szEndTimeRequired. The end time within the stream to end play back. For play back of a recordedRTP stream, the end time must be specified in UTC using the following time format:YYYY-MM-DDTHH:MM:SS. For play back of a live RTP stream, set the time to the string"INFINITE".

szIpAddressRequired. The IP address of the video stream source device for NSM, NVR, or EE500. Fora live RTP stream, this is the IP address of the camera. For play back of a recording, this isthe IP address of NSM/NVR.

szPortRequired. The port number of the video stream source device for NSM, NVR, or EE500.For a live RTP stream, this is the port number of the camera. For play back of a recording,this is the port number of NSM/NVR.

szNVRServiceIdThe NVR ID. Optional for a live RTP stream; required for manual recording of a live RTPstream, and for a play back of a RTP stream. For example, if an end point URL ends with“VideoOutput-1”, then the service ID must be set to 1.

szCameraServiceId

Page 38: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

38

The last number of the web service endpoint URL of a camera. For example, if an endpointURL ends with “VideoOutput-4” then 4 is the service ID.

szCameraUuidThe IP camera’s UPnP Unique Device Name (UDN). For example,"uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15".

NOTE: The IP camera’s UDN is required if you want to start manualrecording of a live stream. Otherwise, this parameter is optional.

bLowBandwidthSets the stream bandwidth from the camera to low. The camera must be configured tohave the secondary low bandwidth stream enabled. For backwards compatibility, thisparameter is set to FALSE by default.

NOTE: This parameter is only valid for live streams.

streamInfoNetStreaming data, which is to be filled in. This value can be passed back to a live or a playback call to StartStream for RTP only. For backwards compatibility, this parameter is setto NULL by default.

Opening, Playing, and Displaying a Live or Playback RTP StreamNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the PelcoAPIViewer sample project SampleConsole9. When in debug mode, if thevideo playback is paused during program execution, then RTCP messages are displayed in theconsole window. The messages provide information about the RTCP packets.

Before being able to control a video stream, you must first open the stream, and display it on a Windowinstance.

1. Initialize the Pelco API Viewer.Refer to Initializing the Pelco API Viewer (C++) for details.

2. Start the video stream to display, by calling the StartStream method, passing in the followingparameters:szStartTime

Required. The start time within the stream to start play back. For play back of a recordedRTP stream, the start time must be specified in UTC using the following time format:YYYY-MM-DDTHH:MM:SS. For play back of a live RTP stream, set the time to the string"NOW".

szEndTimeRequired. The end time within the stream to end play back. For play back of a recordedRTP stream, the end time must be specified in UTC using the following time format:YYYY-MM-DDTHH:MM:SS. For play back of a live RTP stream, set the time to the string"INFINITE".

szIpAddressRequired. The IP address of the video stream source device for NSM, NVR, or EE500. Fora live RTP stream, this is the IP address of the camera. For play back of a recording, this isthe IP address of NSM/NVR.

szPortRequired. The port number of the video stream source device for NSM, NVR, or EE500.For a live RTP stream, this is the port number of the camera. For play back of a recording,this is the port number of NSM/NVR.

Page 39: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

39

szServiceIdThe last number of the web service endpoint URL. For example, if an endpoint URL endswith “VideoOutput-4” then 4 is the service ID.

szTransportThe video stream’s transport (RTP) URL (optional for a live RTP stream, because thecamera starts a MULTICAST stream if no value is supplied. Required for playback.) TheIP address must be the IPv4 address of the machine on which the code is running, for thenetwork through which it will connect to the video source. The port number must be aneven number, and must not be in use.

Example:rtp://ip_of_local_machine:open_port_even

NOTE: When one RTP unicast stream is already playing, and anotheris started, be sure to set an RTP port that is at least four higher than theprevious stream. The port that is two higher than the previous port mightalready be in use by the previous stream’s audio channel.

szCamUuidThe IP camera’s UPnP Unique Device Name (UDN). For example,"uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15".

NOTE: The IP camera’s UDN is required if you want to start manualrecording of a live stream. Otherwise, this parameter is optional.

szNvrIdThe NVR ID. Optional for a live RTP stream; required for manual recording of a live RTPstream, and for a play back of a RTP stream. For example, if an end point URL ends with“VideoOutput-1”, then the service ID must be set to 1.

ITimeStampDelegateSignals if you want the timestamp returned by the API. If no timestamp is required, do notsupply a value for this parameter.

bVideoOnlyStream video without audio. By default, this parameter is set to FALSE for backwardscompatibility.

bLowBandwidthSets the stream bandwidth from the camera to low. The camera must be configured tohave the secondary low bandwidth stream enabled. For backwards compatibility, thisparameter is set to FALSE by default.

NOTE: This parameter is only valid for live streams.

streamInfoNetStreaming data, which is to be filled in. This value can be passed back to a live or a playback call to StartStream for RTP only. For backwards compatibility, this parameter is setto NULL by default.

For a live RTP stream:

MyAppNamespace::TimeStamp _pDelegate;const char* pszSesId = NULL;//... Other logic ...pszSesId = _pViewer.StartStream("NOW", "INFINITE","10.220.196.149", "49154", "1", "rtp://10.220.196.148:7162", "uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15", "1", &_pDelegate, False, False, NULL);

Page 40: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

40

where:

• StartTime is the time you want to start video. For live streams, use the value as "NOW",• endTime is the time you want the video to end. For live streams, use the value “INFINITE”.

NOTE: For NULL/optional values, use “” for strings and NULL for interface values.

• szServiceId is the camera service ID, etc,

For a playback RTP stream:

MyAppNamespace::TimeStamp _pDelegate;const char* pszSesId = NULL;//... Other logic ...pszSesId = _pViewer.StartStream("2010-08-08T18:02:00", "2010-08-08T18:28:00", "10.220.196.149", "49154", "1", "rtp://10.220.196.148:7162","uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15", "1", &_pDelegate, False, False, NULL);

where:

• szServiceId is the camera service ID,• szTransport and szCamUuid are required for playback.

If successful, these methods will return a session ID, pszSesId, of the stream. This will be usedthroughout this document for tasks related to the Pelco API Viewer.

Opening, Playing, and Displaying an RTSP StreamNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the PelcoAPIViewer sample project SampleConsole9.

1. Initialize the Pelco API Viewer.Refer to Initializing the Pelco API Viewer (C++) or Initializing the Pelco API Viewer (C#) entry for details.

2. Start the video stream to display, by calling the StartStream method, passing in the followingparameters:

The location of the RTSP stream

The username to use for authentication (Optional)

The password to use for authentication (Optional)

A boolean indicating whether or not the stream is multicast

The timestamp parameter is an object that implements the ITimeStampDelegate interface,or NULL if you don’t want to receive timestamps as the video plays. (Optional)

MyAppNamespace::TimeStamp _pDelegate;const char* pszSesId = NULL;//... Other logic for example, setting up windows, and so on ...//Live example:pszSesId = _pViewer.StartStream("rtsp://10.220.196.169/?deviceid=uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15", NULL, NULL, false, &_pDelegate);//Playback example:pszSesId = _pViewer.StartStream("rtsp://10.221.224.35/?deviceid=uuid:01b766f9-9d87-4613-a168-5e5d179d339d&starttime=2011-12-04T10:00:00&endtime=2011-12-04T11:00:00",

Page 41: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

41

NULL, NULL,false, &_pDelegate);

If successful, the method will return a session ID of the stream. Keep this in mind, as this will be usedthroughout for tasks related to the Pelco API Viewer.

Forward Playback of RTP and RTSP StreamsNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the PelcoAPIViewer sample project SampleConsole9.

This entry assumes that you have already completed the steps outlined in the Opening, Playing, andDisplaying an RTSP Stream entry.

To perform a forward or reverse playback of a currently running video stream, call the Pelco API Viewerinstance’s PlayForward or PlayReverse method passing in the following parameters:

The target video stream’s session ID. A successful call to the StartStream methodreturns this value.

A float value representing the desired playback speed. Valid possible playback speeds canrange from 0-300, with 0 representing a paused state and 1 representing regular playbackspeed. (Also, 1 represents the speed for live video.)

const char* pszSesId = NULL; //... Get pszSesId, the stream’s session ID, by starting a stream ... if(_pViewer.PlayForward(pszSesId, 8.0) !=0 ){ //... Handle error ... }

Reverse Playback of RTP and RTSP StreamsTo perform a reverse playback of a currently running video stream, call the Pelco API Viewer instance’sPlayReverse method; passing in the following parameters:

The target video stream’s session ID. A successful call to the StartStream methodreturns this value.

A float value representing the desired playback speed. Valid possible playback speedscan range from 0-300, with "0" representing a paused state and "1" representing regularplayback speed.

WARNING: Reverse playback is not possible for live streams.

const char* pszSesId = NULL; //... Get pszSesId, the stream’s session ID, by starting a stream ... if(_pViewer.PlayReverse(pszSesId, 8.0) !=0 ){ //... Handle error ... }

Fast Forward / Reverse Playback of RTP and RTSP StreamsTo perform a fast forward (using FrameForward, which advances by a single frame) or fast reverseplayback of a currently running video stream (using FrameReverse, which reverses by a single i-frame that might include multiple p-frames), call the Pelco API Viewer instance’s PlayForward orPlayReverse method (as appropriate), passing in the following parameters:

Page 42: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

42

The target video stream’s session ID. A successful call to the StartStream methodreturns this value.

A float value representing the desired playback speed. Valid possible playback speeds canrange from -300 to 300, with speed greater than 1 (regular playback speed). Slow motionis supported where the speed is set at half the regular speed (for example, -0.5 or 0.5).

Currently for RTP, PlayReverse only plays backward, and PlayForward only plays forward,regardless of whether the speed parameter is negative or positive. Therefore, call PlayForward forfast forward, and call PlayReverse for fast reverse.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.PlayForward(pszSesId, 8.0) !=0 ){//... Handle error ...}

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.PlayReverse(pszSesId, 8.0) !=0 ){//... Handle error ...}

Pausing RTP and RTSP Playback StreamsNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the PelcoAPIViewer sample project SampleConsole9.

WARNING: DO NOT pause live streams. Pausing a live stream could produce an unpredictableresult.

This entry assumes that you have already completed the steps outlined in the Opening, Playing, andDisplaying an RTSP Stream entry.

To pause currently running video stream, call the Pelco API Viewer instance’s Pause method; passingin the target video stream’s session ID.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.Pause(pszSesId) !=0 ){//... Handle error ...}

Frame Forward Playback of the RTP StreamA frame forward operation advances playback of a currently paused video stream by a single frame.

To perform this operation, call the Pelco API Viewer instance’s FrameForward method, passing in thefollowing parameter:

The target video stream’s session ID. A successful call to the StartStream method,returns this value.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.FrameForward(pszSesId) !=0 ){//... Handle error ...

Page 43: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

43

}

Frame Reverse Playback of the RTP StreamA frame reverse operation steps a currently paused video stream backward by a single i-frame, which caninclude multiple p-frames.

To perform this operation, call the Pelco API Viewer instance’s FrameReverse method; passing in thefollowing parameter:

The target video stream’s session ID. A successful call to the StartStream method,returns this value.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.FrameReverse(pszSesId) !=0 ){//... Handle error ...}

Resuming the RTP or RTSP Stream from a Paused StateNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the PelcoAPIViewer sample project SampleConsole9.

NOTE: This entry assumes that you have already completed the steps outlined in Opening,Playing, and Displaying a Live or Playback RTP Stream.

To resume a paused playback stream, call the Pelco API Viewer instance’s Resume method, passing inthe target video stream’s session ID.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.Resume(pszSesId) !=0 ){//... Handle error ...}

Stopping the RTP and RTSP StreamNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the PelcoAPIViewer sample project SampleConsole9.

This entry assumes that you have already completed the steps outlined in the Opening, Playing, andDisplaying the Stream entry.

To perform a stop playback of a currently running video stream, call the Pelco API Viewer instance’sStopStream method; passing in the target video stream’s session ID.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.StopStream(pszSesId) !=0 ){//... Handle error ...}

Page 44: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

44

Start Manual Recording of RTP StreamManual recording can only be done on a live RTP stream.

NOTE: The related source code for this entry can be found in the main.cpp file’s main function,which belongs to the PelcoAPIViewer sample project SampleConsole9.

To start manual recording of the RTP stream, call the Pelco API Viewer instance’sStartManualRecording method, passing in the following parameters:pszSesId

The target video stream's session ID.

cameraIdThe last number of the Web service endpoint URL of the camera. For example, if anendpoint URL ends with “VideoOutput-4”, then the ID number is 4.

nvrIpRequired. The IP address of the source of the video stream for NSM, NVR, or EE500. Forlive RTP, this is the IP address of the camera. For playback, this is the IP address of theNSM/NVR.

nvrPortRequired. The IP address and port number of the source of the video stream for NSM,NVR, or EE500. For a live RTP stream, this is the port number of the camera. For playbackof a recorded stream, this is the port number of the NSM/NVR (required).

nvrIdThe NVR ID. For example, if an endpoint URL ends with “VideoOutput-1”, then the serviceID is 1.

// Start a stream and obtain the session ID pszSesId...

// Start manual recording, passing in the session ID pszSesIdif (_pViewer.StartManualRecording(pszSesId, "4", "10.220.196.169", "49153", "1")) { // ... Handle error ...}

Stop Manual Recording of RTP StreamManual recording can only be done on a live RTP stream.

NOTE: The related source code for this entry can be found in the main.cpp file’s main function,which belongs to the PelcoAPIViewer sample project SampleConsole9.

To stop manual recording of the RTP stream, call the Pelco API Viewer instance’sStopManualRecording method, passing in the following parameters:pszSesId

The target video stream's session ID.

// Stop manual recording, passing in the session ID pszSesId_pViewer.StopManualRecording(pszSesId);

Page 45: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

45

Setting Audio Volume of a Live or Playback RTP streamAudio volume of a playback stream can be controlled using the SetAudioVolume method, by passingin the video stream’s session ID and an integer volume level, where the range is 0 to 100, with 0representing mute.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.SetAudioVolume(pszSesId, 10) !=0 ){//... Handle error ...}

Displaying Analytic Events for an RTP StreamTo display analytic events for the currently playing video stream, call the DisplayAnalyticEventsmethod, passing in the target video stream’s session ID and the bEnable set to true.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.DisplayAnalyticEvents(pszSesId, true) !=0 ){//... Handle error ...}

Displaying Motion Events for an RTP StreamTo display motion events for the currently playing video stream, call the DisplayMotionEventsmethod, passing in the target video stream’s session ID and the bEnable set to true.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...if(_pViewer.DisplayMotionEvents(pszSesId, true) !=0 ){//... Handle error ...}

Displaying a Timestamp Overlay for RTP and RTSP StreamsTo display a timestamp overlay for live/playback video streams, call the DisplayTimestampOverlaymethod, passing in the target video stream's session ID, bEnable set to true, and an instance ofViewerOverlayInfo struct.If the struct (the 3rd parameter) is set to null, the default style overlay appears. The default style wouldbe:

• Location: Bottom left• Date format: MMDDYYYY• Time format: HHMMSSTT• Font name: Arial• Font size: 9• Font color: Yellow• Background color: transparent to the current screen

Page 46: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

46

C++ Example:

PelcoAPI::ViewerOverlayInfo overlay; PelcoAPI::COLOR fontColor = {0xFF, 0xFF, 0xFF, 0xA0}; PelcoAPI::COLOR fontBgColor = {0x00, 0x00, 0x00, 0x00}; overlay.m_dateFormat = PelcoAPI::VIEWER_DATE_FORMAT_MMDDYY; overlay.m_timeFormat = PelcoAPI::VIEWER_TIME_FORMAT_TTHHMMSS; overlay.m_fontColor = fontColor; overlay.m_fontBgColor = fontBgColor; overlay.m_location = PelcoAPI::VIEWER_OVERLAY_LOCATION_TOP_LEFT; overlay.m_nFontSize = 12; overlay.m_fontNameStr = "Arial";bool bSuccess = _pViewer.DisplayTimestampOverlay(pszSesId, true, &overlay);

C# Example:

System.Drawing.Color fontColor = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF, 0xA0); System.Drawing.Color fontBgColor = System.Drawing.Color.FromArgb(0x00, 0x00, 0x00, 0x00);ViewerOverlayInfoNet overlay = new ViewerOverlayInfoNet();overlay.m_location = PelcoAPI.ViewerOverlayLocationNet.OVERLAY_LOCATION_BOTTOM_LEFT;overlay.m_dateFormat = PelcoAPI.ViewerDateFormatNet.DATE_FORMAT_MMDDYYYY;overlay.m_timeFormat = PelcoAPI.ViewerTimeFormatNet.TIME_FORMAT_HHMMSSTT;overlay.m_fontNameStr = "Arial";overlay.m_nFontSize = 16;overlay.m_fontColor = fontColor;overlay.m_fontBgColor = fontBgColor; Boolean bSuccess = _rtpViewer.DisplayTimestampOverlay(_rtpSessionId, true, overlay);

NOTE: Live and playback RTSP streams from Sarix cameras are unable to display timestampinformation.

Page 47: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Displaying and Controlling Streams Using PelcoAPIViewer

47

Taking a Snapshot of the Current Video Frame for RTP and RTSP StreamsTo take a snapshot of the current video frame, call the Pelco API Viewer instance’s TakeSnapShotmethod; passing in the target video stream’s session ID, and the desired resulting filename and filepath.

const char* pszSesId = NULL;//... Get pszSesId, the stream’s session ID, by starting a stream ...nResult = m_pViewer->TakeSnapShot(szSessionId, "C:\\snapshots.jpg");

Pan, Tilt, Zoom (PTZ) Control for RTP Stream Using PelcoAPIViewerCameras with PTZ functionality can also be controlled using the PelcoAPIViewer. For more information,refer to Pan, Tilt, Zoom (PTZ) Control.

NOTE: This only works with PelcoAPIViewer in RTP Live mode.

Page 48: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

48

Chapter

7Pan, Tilt, Zoom (PTZ) Control

OverviewWARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use without modification.

WARNING: The content below assumes that the default target installation directory was chosenduring installation.

For the latest Pelco documentation, visit http://pdn.pelco.com.

After you’ve found the IP camera on your network and displayed its live stream on your display, you willprobably want to start controlling your camera’s viewing position: up and down and left and right, as well asmagnification (zoom), focus, and camera iris.

This section contains sample C# and C++ that illustrates how to display and control video streams.Complete C# and C++ sample programs are contained in the following subdirectory where the Pelco SDKis installed: Pelco\API\SampleCode\PTZControlWrapperSample

The StopContinuous method is available to stop the camera from continually moving, and the Stop()call is available to stop Lens control (zoom, iris, and focus) actions. To stop continuous positioning calls,pass in a 0 value. For example, after executing ContinuousMove, call ContinuousMove(0, 0) to stopmoving.

Where Does the Pelco SDK Fit?

To move your IP camera’s current view, you need to start using the Pelco SDK’s PTZ Control Wrapper.The PTZ Control Wrapper is an easy to use tool for controlling various PTZ and lens related functionality.For this section we’ll only focus on panning and tilting the camera.

As in the previous section we’ll be examining the sample project code. Specifically, this section covers thePTZ Control Wrapper. This sample project exhibits PTZ Control Wrapper functionality.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

Initializing the PTZ Control WrapperNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: In release mode, select the Enable unmanaged code debugging check box in the projectsettings to view console output.

To create an instance of the managed PTZ Control Wrapper, use the following parameters:

Page 49: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

49

Your IP camera’s current IP address

Your IP camera’s port number

Your IP camera’s service ID (usually 1 unless this number represents a channel in a multi-channel encoder)

C++ Example

PelcoAPI::PTZControlWrapper ptzControlWrapper("10.220.196.144”, 49152, 1);

Verify that authentication is enabled for the camera, and if so, set the authentication credentials. Forexample:

// Check if authentication is enabledif (ptzControlWrapper.IsAuthenticationEnabled()){ // Set the user name to "admin", the password to "admin_user", and use basic authentication AuthenticationCredentials credentials("admin", "admin_password", PelcoAPI::AuthenticationCredentials::BASIC); ptzControlWrapper.SetAuthenticationCredentials(&credentials);}

NOTE: To manage the camera authentication and the users, use the Pelco Web interface.

After you are finished with the camera operations, stop all PTZ Control Wrapper actions:

bool bSuccess = ptzControlWrapper.Stop();

NOTE: The following stop actions are available:

• To stop Lens control actions such as zoom, iris, and focus, use the Stop() call.• To stop continuous movement triggered by ContinuousMove, ContinuousPan, and

ContinuousTilt, use the StopContinuous() call.

C# Example

ManagedPTZControlWrapperNet managedPTZControl = newManagedPTZControlWrapperNet("10.220.196.144”, 49152, 1);

Verify that authentication is enabled for the camera, and if so, set the authentication credentials. Forexample:

// Set example parameters#define CAMERA_IP_ADDRESS "10.220.196.179"#define PORT_NUMBER 80#define CAMERA_NUMBER 1

// Check if authentication is enabledif (managedPTZControl.IsAuthenticationEnabled(CAMERA_IP_ADDRESS, CAMERA_PORT, CAMERA_NUMBER)){ // Set the user name to "admin", the password to "admin_password", and use basic authentication PelcoAPI::AuthenticationCredentials authentication("admin", "admin_password", PelcoAPI::AuthenticationCredentials::BASIC); managedPTZControl.SetAuthenticationCredentials(&authentication);}

Page 50: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

50

After you are finished with the camera operations, stop all PTZ Control Wrapper actions:

Boolean bSuccess = managedPTZControl.Stop();

NOTE: The following stop actions are available:

• To stop Lens control actions such as zoom, iris, and focus, use the Stop() call.• To stop continuous movement triggered by ContinuousMove, ContinuousPan, and

ContinuousTilt, use the StopContinuous() call.

Continuous PanningNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with moving the camera left and right.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the PTZ Control Wrapper instance’s ContinuousPan method.

• To pan your IP camera left, pass in a negative rotational x parameter.• To pan the IP camera right, pass in a positive value for the rotational x parameter.

For more details on the ContinuousPan method, please refer to the PTZ Control Wrapper APIreference documentation.C++ Example:

//panning leftbool bSuccess = ptzControlWrapper.ContinuousPan(-10000);//panning rightbool bSuccess = ptzControlWrapper.ContinuousPan(10000);

C# Example:

//panning leftBoolean bSuccess = managedPTZControl.ContinuousPan(-10000);//panning rightBoolean bSuccess = managedPTZControl.ContinuousPan(10000);

3. When you want to stop the camera from continually moving, use the StopContinuous() method(refer to Continuous Stop for details), or pass in a 0 value to the ContinuousPan method as shown inthe following example.C++ Example:

bool bSuccess = ptzControlWrapper.ContinuousPan(0);

C# Example:

Boolean bSuccess = managedPTZControl.ContinuousPan(0);

Page 51: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

51

Continuous TiltingNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++)or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper C++ sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with moving the camera up and down.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the PTZ Control Wrapper instance’s ContinuousTilt method.

• To tilt the IP camera down, pass in a negative rotational y value for the second parameter.• To tilt the IP camera up, pass in a positive value for the rotational y parameter.

For more details on the ContinuousTilt method, please refer to the PTZ Control Wrapper APIreference documentation.C++ Example:

//tilting downbool bSuccess = ptzControlWrapper.ContinuousTilt(-9000);//tilting upbool bSuccess = ptzControlWrapper.ContinuousTilt(9000);

C# Example:

//tilting downBoolean bSuccess = managedPTZControl.ContinuousTilt(-9000);//tilting upBoolean bSuccess = managedPTZControl.ContinuousTilt(9000);

3. When you want to stop the camera from continually moving, use the StopContinuous() method(refer to Continuous Stop for details), or pass in a 0 value to the ContinuousTilt method as shownin the following example.C++ Example:

bool bSuccess = ptzControlWrapper.ContinuousTilt(0);

C# Example:

Boolean bSuccess = managedPTZControl.ContinuousTilt(0);

Continuous Diagonal MovementNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++)or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper C++ sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with continuously moving the camera in adiagonal manner.

1. Initialize the PTZ Control Wrapper.

Page 52: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

52

Refer to Initializing the PTZ Control Wrapper for details.2. Call the ContinuousMove method.

The first parameter represents both speed and direction on the X plane. Use a negative integer to panleft and a positive integer to pan right. The second parameter represents both speed and direction onthe Y plane. Use a negative integer to tilt down and a positive integer to tilt up. For more details on theContinuousMove method, pplease refer to the PTZ Control Wrapper API reference documentation.C++ Example:

//tilting downbool bSuccess = ptzControlWrapper.ContinuousMove(10000, -10000);//tilting upbool bSuccess = ptzControlWrapper.ContinuousMove(10000, 10000);

C# Example:

//tilting downBoolean bSuccess = managedPTZControl.ContinuousMove(10000, -10000);//tilting upBoolean bSuccess = managedPTZControl.ContinuousMove(10000, 10000);

3. When you want to stop the camera from continually moving, use the StopContinuous() method(refer to Continuous Stop for details), or pass in a 0 value to the ContinuousMove method as shownin the following example.C++ Example:

bool bSuccess = ptzControlWrapper.ContinuousMove(0,0);

C# Example:

Boolean bSuccess = managedPTZControl.ContinuousMove(0,0);

Stopping Continuous MovementTo stop the camera from continually moving, call the StopContinuous method.C++ Example:

bool bSuccess = ptzControlWrapper.StopContinuous();

C# Example:

Boolean bSuccess = managedPTZControl.StopContinuous();

Enabling Continuous Pan/Tilt/Move and Zoom APIs by UDP Instead of TCPCall the PTZ Control Wrapper's SetLowLatencyMode method, passing in true as an argument. Thiswill send the subsequent ContinuousMove, ContinuousTilt, ContinuousPan, StopContinuousand Zoom calls using UDP.C++ Example:

bool bSuccess = ptzControlWrapper.SetLowLatencyMode(true);

Page 53: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

53

C# Example:

Boolean bSuccess = managedPTZControl.SetLowLatencyMode(true);

Zoom API calls over UDP currently work on Sarix firmware 1.7.41 and higher.

Panning to a Specific PositionNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with moving the camera to a specific point in2D space. Units are shown in centidegrees (hundredths of a degree).

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the PTZ Control Wrapper’s AbsolutePan method, passing in the desired position on the rotationalX plane.

• Passing a negative value moves left of the home position.• Passing a positive value moves right of the home position.

For more details on the AbsolutePan method, please refer to the PTZ Control Wrapper API referencedocumentation.

Generally, the panning range is limited to 0 to 360 degrees (0 to 36,000 centidegrees). This limit mightdiffer, depending on the type of camera used.

C++ Example:

bool bSuccess = ptzControlWrapper.AbsolutePan(36000);

C# Example:

Boolean bSuccess = managedPTZControl.AbsolutePan(36000);

Tilting to a Specific PositionNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with moving the camera to a specific point in2D space. Units are shown in centidegrees (hundredths of a degree).

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the PTZ Control Wrapper’s AbsoluteTilt method, passing in the desired position on therotational X plane.

• Passing a negative value moves down from horizontal..

Page 54: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

54

• Passing a positive value moves up from horizontal..

For more details on the AbsoluteTilt method, refer to the PTZ Control Wrapper API referencedocumentation.

Generally, the tilting range is limited to 0 to -90 degrees (0 to -9000 centidegrees). This limit might differ,depending on the type of camera used.

C++ Example:

bool bSuccess = ptzControlWrapper.AbsoluteTilt(-9000);

C# Example:

Boolean bSuccess = managedPTZControl.AbsoluteTilt(-9000);

Moving to a Specific PositionNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with moving the camera to a specific point in2D space. Units are shown in centidegrees (hundredths of a degree).

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the PTZ Control Wrapper’s AbsoluteMove method, passing in the desired position on therotational X and Y planes.

• Passing a negative value for X moves the camera left of the home position.• Passing a positive value for X moves the camera right of the home position.• Passing a negative value for Y moves the camera down from horizontal.• Passing a positive value for Y moves the camera up from horizontal.

Refer to your camera model’s specifications for tilt position limits. For more details on theAbsoluteMove method, please refer to the PTZ Control Wrapper API reference documentation.C++ Example:

bool bSuccess = ptzControlWrapper.AbsoluteMove(20, 40);

C# Example:

Boolean bSuccess = managedPTZControl.AbsoluteMove(20, 40);

Moving to a Position Relative to the Current LocationCall the PTZ Control Wrapper's RelativeMove method, passing in the relative X and Y plane valuesthat the camera should move from the current location.Units are shown in centidegrees (hundredths of a degree).

Page 55: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

55

C++ Example:

bool bSuccess = ptzControlWrapper.RelativeMove(3000, 5000);

C# Example:

Boolean bSuccess = managedPTZControl.RelativeMove(3000, 5000);

Getting the Camera’s Current PositionNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This entry covers the portion of the sample project that deals with returning the camera current positionexpressed as a specific point in 3D space.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the PTZ Control Wrapper’s GetAbsolutePosition method.For more details on the GetAbsolutePosition method, please refer to the PTZ Control Wrapper APIreference documentation.C++ Example:

int positionX = 0;int positionY = 0;bool bSuccess = ptzControlWrapper.GetAbsolutePosition(&positionX, &positionY);

C# Example:

int positionX = 0;int positionY = 0;Boolean bSuccess = managedPTZControl.GetAbsolutePosition(ref positionX,ref positionY);

Managing the Magnification (Zoom) ValueNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This section describes how to change the camera’s current magnification level. Magnification refers tothe camera’s zoom level, which in turn describes the focal length for which the camera's lens is currentlyset. Zoom level is expressed as 100 times the level of magnification that you want. For example, 1xmagnification becomes 100, and 18x magnification becomes 1800.

To change the current magnification level, and to later retrieve the current magnification value, do thefollowing:

1. Initialize the PTZ Control Wrapper.

Page 56: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

56

Refer to Initializing the PTZ Control Wrapper for details.2. Call the PTZ Control Wrapper’s AbsoluteZoom method passing in the desired zoom level.

If the request was successful, your camera’s magnification level should now be changed. For moredetails on the AbsoluteZoom method, refer to the PTZ Control Wrapper API reference documentation.C++ Example:

bool bSuccess = ptzControlWrapper.AbsoluteZoom(150);

C# Example:

Boolean bSuccess = managedPTZControl.AbsoluteZoom(150);

3. Call the GetAbsoluteZoom method to return the camera’s current magnification setting.If the request was successful, your camera’s magnification level should be returned. For more details onthe GetAbsoluteZoom method, refer to the PTZ Control Wrapper API reference documentation.C++ Example:

int magnification = 0;bool bSuccess = ptzControlWrapper.GetAbsoluteZoom(magnification);

C# Example:

int magnification = 0;Boolean bSuccess = managedPTZControl.GetAbsoluteZoom(ref magnification);

Managing the Focus ValueNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

NOTE: We recommend that you let your IP camera manage focus automatically.

This portion of the documentation covers how to focus near the IP camera or focus far away from the IPcamera.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the SetFocus method, passing in the desired focus command.

For a little background, the SetFocus method takes in only the following values:0

To stop all focus related operations.

1To start focusing farther.

2To start focusing nearer.

If the request was successful, your camera’s focus should now be changing (unless you passed a0). This will not stop until a SetFocus request is made with a different value, or if you call the Stopmethod, which will stop movement or lens related action the camera is currently doing.

Page 57: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

57

C++ Example:

bool bSuccess = ptzControlWrapper.SetFocus(1);bool bSuccess = ptzControlWrapper.SetFocus(2);bool bSuccess = ptzControlWrapper.SetFocus(0);

C# Example:

Boolean bSuccess = managedPTZControl.Focus(1);Boolean bSuccess = managedPTZControl.Focus(2);Boolean bSuccess = managedPTZControl.Focus(0);

3. Alternatively the recommended way of controlling focus is to let your IP camera manage itautomatically. To enable this feature, call the AutoFocus method and pass a boolean value of true. Todisable it, just pass a boolean value of false.C++ Example:

bool bSuccess = ptzControlWrapper.AutoFocus(true);

C# Example:

Boolean bSuccess = managedPTZControl.AutoFocus(true);

Iris ControlNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

NOTE: We recommend that you let your IP camera manage its iris automatically.

This section demonstrates how to open and close your camera’s iris.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Call the SetIris method, passing in the desired iris command.

For a little background, the SetIris method takes only following values:0

To stop all iris related operations.

1To start closing the iris.

2To start opening the iris.

If the request was successful, your camera’s iris should now be changing (unless you passed a 0). Thiswill not stop until the SetIris request is made with a different value, or if you call the Stop method,which will stop movement or lens related action the camera is currently doing.

C++ Example:

bool bSuccess = ptzControlWrapper.SetIris(1);bool bSuccess = ptzControlWrapper.SetIris(2);

Page 58: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

58

C# Example:

Boolean bSuccess = managedPTZControl.Iris(1);Boolean bSuccess = managedPTZControl.Iris(2);

3. Alternatively the recommended way of controlling the iris is to let your IP camera manage itautomatically. To enable this feature, call the AutoIris method and pass a boolean value of true. Todisable it, just pass a boolean value of false.C++ Example:

bool bSuccess = ptzControlWrapper.AutoIris(true)

C# Example:

Boolean bSuccess = managedPTZControl.AutoIris(true)

ScriptingOne of Pelco’s most powerful features enables users to manage and run scripts. Scripts allow you toextend the behavior of Pelco devices with little effort. Before we show you how to use the SDK’s scriptingrelated features, it’s important to know about the different types of Pelco scripts:

Preset

A preset is a script that allows you to save a camera's stationary position, zoom, and other settings suchas auto iris and autofocus, collectively known as a bookmark. Users can save multiple presets per camera.For example if you’re monitoring several specific points using the same camera, you can set one preset foreach location that needs to be monitored; each with its own set of zoom, iris, and focus values.

Presets that you create must be names, such as “PRESETX”, where the keyword PRESET must be used(uppercase) followed by a positive integer. For example, PRESET9.

The number of presets that can be saved and activated is dependent on the Pelco device.

Pattern

A pattern is like a group of presets combined. For example, you might control an IP PTZ camera guardinga hallway with two entrances and a window. With patterns, you can set a bookmark for camera behaviorthat changes the camera’s view from one of the three points of interest to another every 15 seconds.

Patterns that you create must be names as “PATTERNX”, where the keyword PATTERN must be used(uppercase) followed by a positive integer. For example, PATTERN5.

NOTE: There are pre-configured patterns that cannot be created. You cannot create a Pattern bycombining existing Presets.

Like a preset, patterns are typically only relevant for IP cameras. The number of patterns that can berecorded and activated is dependent on the Pelco device. For example, the 16X and 18X models of theSpectra IV can store only a single pattern, while the 22X, 23X and 35X Spectra IV models can store up toeight patterns.

Normal Script

A general script consists of a group of commands that run over a set period of time. It is akin to a macro.

Page 59: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

59

Creating a PresetNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

These steps will show you how to create a preset.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Now set up your Pelco IP camera with a combination of settings that you want to save.For example, the IP camera’s current viewing position, iris setting, focus setting, zoom, and so on.

3. Then call the SetPreset method, passing in the desired name of the preset.Depending on whether the preset already exists or not, it will either create a new one or modify anexisting one by that name.C++ Example:

bool bSuccess = ptzControlWrapper.SetPreset("PRESET99");

C# Example:

Boolean bSuccess = managedPTZControl.SetPreset("PRESET99");

Updating an Existing PresetTo update an existing preset, just following the steps outlined in Creating a Preset, ensuring that youuse the name of the existing preset to modify as the parameter for the SetPreset method.

Creating a PatternNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

This is just like creating a preset, except you will be saving more than one camera state.

1. Initialize the PTZ Control Wrapper.Refer to Initializing the PTZ Control Wrapper for details.

2. Now set up your Pelco IP camera with a combination of settings that you want to save.For example, the IP camera’s current viewing position, iris setting, focus setting, zoom, and so on.

3. Then call the StartPatternRecording method, passing in the desired name of the preset.Depending on whether the pattern already exists or not, it will either create a new one or modify anexisting one by that name.C++ Example:

bool bSuccess = ptzControlWrapper.StartPatternRecording("PATTERN99");

Page 60: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

60

C# Example:

Boolean bSuccess = managedPTZControl.StartPatternRecording("PATTERN99");

4. At this point start performing the actions that you’d want your camera to remember as a pattern.For example, if you have three points of interest you would first go to the first point of interest with acertain zoom and focus level. After waiting for some predetermined time, you then move the camera’sview into the second point of interest which has a different zoom level and iris setting; and do the samefor the final point of interest.

5. Finally, call the EndPatternRecording method, passing in the same pattern name as you did before.C++ Example:

bool bSuccess = ptzControlWrapper.EndPatternRecording("PATTERN99");

C# Example:

Boolean bSuccess = managedPTZControl.EndPatternRecording("PATTERN99");

Going to an Existing PresetNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

To move the device to a specific preset state, call the PTZ Control Wrapper’s GotoPreset method,passing in the name of the preset.The camera or device will move to the preset and then stop.C++ Example:

bool bSuccess = ptzControlWrapper.GotoPreset("PRESET99");

C# Example:

Boolean bSuccess = managedPTZControl.GotoPreset("PRESET99");

Removing an Existing PresetNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

To remove an existing preset, call the PTZ Control Wrapper’s RemovePreset method, passing in thename of the preset.The preset will then be deleted.C++ Example:

bool bSuccess = ptzControlWrapper.RemovePreset("PRESET99");

Page 61: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Pan, Tilt, Zoom (PTZ) Control

61

C# Example:

Boolean bSuccess = managedPTZControl.RemovePreset("PRESET99");

Updating an Existing PatternTo update an existing pattern, just following the steps outlined in Creating a Pattern. Ensure that youuse the name of the pattern to modify as the parameter for both the StartPatternRecording andEndPatternRecording methods.

Executing an Existing PatternNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

To run a a script, call the PTZ Control Wrapper’s RunPattern method, passing in the name of thescript to run.The script will continue to run until stopped by the user using the HaltPattern method, detailedStopping a Pattern Currently Being Executed on page 61.C++ Example:

bool bSuccess = ptzControlWrapper.RunPattern("PATTERN99");

C# Example:

Boolean bSuccess = managedPTZControl.RunPattern("PATTERN99");

Stopping a Pattern Currently Being ExecutedNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the PTZ Control Wrapper sampleproject.

NOTE: PTZ control functionality is also available as part of the PelcoAPIViewer. For each of themethods described in this topic, there is an equivalent method in the PelcoAPIViewer API.

If you want to stop a script that is currently running, call the PTZ Control Wrapper’s HaltPatternmethod, passing in the name of the script to stop.C++ Example:

bool bSuccess = ptzControlWrapper.HaltPattern("PATTERN99");

C# Example:

Boolean bSuccess = managedPTZControl.HaltPattern("PATTERN99");

Page 62: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

62

Chapter

8Events and Alarms

OverviewWARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use without modification.

WARNING: The content in this section assumes that the default target installation directory waschosen during installation.

NOTE: For the latest Pelco documentation, visit http://pdn.pelco.com.

For a list of the latest special issues and problems regarding the Event Arbiter library, visit http://pdn.pelco.com/content/event-arbiter-library-issues

For a list of the latest special issues and problems regarding the Event Manager, visit http://pdn.pelco.com/content/event-manager-issues.

Events and alarms are essentially XML formatted messages triggered by Pelco products, when someparticular criteria is met. Specifically Pelco products, acting as event providers, send these events andalarms to their subscribers. Typically event providers are web services, while subscribers are softwareclients. For example, if an IP camera’s MotionDetection service detected movement within a particularregion in the video frame, it can send an event to all of its subscribers such as a VMS.

This section contains sample C# and C++ that illustrates how to use events and alarms. Complete C# andC++ sample programs are contained in the following subdirectory where the Pelco SDK is installed: Pelco\API\SampleCode\EventArbiterSample.

Where Does the Pelco SDK Fit?The Pelco SDK provides you with two components for eventing: the Event Arbiter Library and the EventManager. The Event Arbiter Library and Event Manager both allow you to subscribe, unsubscribe, andrenew subscriptions to events. However there are differences between the two components. The EventArbiter Library is the primary component for dealing with eventing. It is for users looking for the mostflexibility and control. Conversely, the Event Manager is a component that sits on top of the Event ArbiterLibrary. Its main purpose is to provide users with ease of use in exchange for decreased control.

Page 63: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

63

Event Arbiter LibraryThe Event Arbiter Library allows you to either subscribe directly to a device’s web service events orindirectly; allowing you to choose to subscribe to the particular web service from all devices providing theservice.

Once a subscription is established, the software client just has to wait for an event to fire. The web servicewill direct the event to your software client through the Pelco SDK. As for subscription renewals, it shouldbe noted that the Event Arbiter Library now also handles subscription renewals automatically. You will nolonger have to worry about renewing an event subscription.

The Event Arbiter Library allows subscriptions to all available web services for all devices on a givennetwork that fall under a specific category. To subscribe, all you have to provide is the event category. Thecategories are as follows:

• Alarm Array Configuration events. These events are sent when a physical alarm input on a device istriggered.

• Diagnostic Reporting events. These events are sent when a hardware alarm on a device is triggered(for example, a temperature alarm, video loss alarm, and so on).

• Motion Detection events. These events are sent when a motion alarm is triggered.• Video Analytics events. These events are sent when a video analytic alarm is triggered.• Relay Array Configuration events. These are included for backward compatibility only, no events are

generated.

Environment Pelco SDK Consequence

No System Manager Only direct device subscription available.

Not all event data will be parsed by Pelco SDK.

System Manager available; EventArbiter webservice active

Able to subscribe to all devices at once that providea specific web service.

All event data is available and parsed.

System Manager available; EventArbiter webservice NOT active

Only direct device subscription is available.

Event ManagerThe Event Manager represents a new tool for eventing and a new component within the Pelco SDK. TheEvent Manager provides another abstraction on top of the Event Arbiter Library, and simplifies eventoperations even further. It allows subscriptions to all available web services for all devices on a givennetwork that fall under a specific category. To subscribe, all you have to provide is the event category. Thecategories are as follows:

• Alarm Array Configuration events• Diagnostic Reporting events• Motion Detection events• Video Analytics events• Relay Array Configuration events (included for backward compatibility only, no events are generated)

Environment Pelco SDK Consequence

No System Manager Does not apply -- can’t use Event Manager.

System Manager available; EventArbiter webservice active

Able to subscribe to all available web servicesthat are under a specified category via the SMEventArbiter web service, in one subscription.

Page 64: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

64

System Manager available; EventArbiter webservice NOT active

All event data is available and parsed. If the SMEventArbiter web service is not active, however,or if you choose not to use it, the EventManagerlibrary will automatically subscribe to eachindividual device's web service in the specifiedcategory, resulting in many subscriptions.

Event Arbiter Library Compared to Event ManagerEvent Arbiter Event Manager

Harder to use, but with more options and flexibility. Easier to use, but not as flexible: the user onlyneeds to choose the category of events he isinterested in receiving.

Does not require a System Manager. Requires a System Manager.

Able to subscribe to a single device’s web serviceusing either an IP address or UDN.

Able to subscribe to all instances of a particularweb service. That is, a user can subscribe to allMotionDetection web services for all devices withjust one request.

NOTE: For more Endura specific information, refer to the Appendix.

What’s Ahead

This is a high level overview of what steps are needed for handling events.

1. Subscribe to the desired web service's events through the Event Arbiter Library or the Event Manager.2. Create the method that will handle the event. Associate that method with the Event Arbiter Library

instance’s event handler. Wait for an event to occur (or trigger an event to test), then handle it.3. When no longer interested in receiving events (or when finished testing), unsubscribe from the

subscribed web service.

Creating an Event AgentNOTE: The related source code for this entry (for C++) can be found in the MyEventAgentheader file, which belongs to the Event Arbiter Library C++ sample project. The relatedsource code for this entry (for C#) can be found in the class MyEventAgentNet in theManagedEventArbiterSample.cs file, which belongs to the Event Arbiter Library C# sampleproject.

The main purpose of an EventAgent class is to deal with any incoming events that have been subscribedto by the Event Arbiter.

NOTE: For complete details about the Event Arbiter, refer to the Pelco SDK Event Arbiterreference manual.

To create your own EventAgent class, implement the NotifyEvent method in the IEventAgentinterface. NotifyEvent includes parameters for the response and the event.Details of implementation are left to the user. However in the MyEventAgent sample class, wedemonstrate basic functionality for accessing event related data.

Page 65: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

65

C++ Example:

#include "PelcoAPI/Trace.h"#include "PelcoAPI/EventArbiterDefs.h"#include "MyEventAgent.h"

//=======================================================// Constructor//=======================================================MyEventAgent::MyEventAgent() : m_nCounter(0){}

//=======================================================// Destructor//=======================================================MyEventAgent::~MyEventAgent(){}

//=======================================================// NotifyEvent//=======================================================void MyEventAgent::NotifyEvent(const char * szResponse, const Event * pEvent){ TRACE_INFO("Notify EVENT %d: \n", ++m_nCounter);

// Record the event UDN TRACE_INFO("\tUDN: %s\n", pEvent->m_strUdn.c_str());

// Record the event service identifier TRACE_INFO("\tService ID: %s\n", pEvent->m_strServiceId.c_str()); // Record the event time in UTC format TRACE_INFO("\tUTC Time: %s\n", pEvent->m_strUtcEventTime.c_str());

// Record the event type TRACE_INFO("\tType: %d\n", (int) pEvent->m_nType); // Record the event friendly name TRACE_INFO("\tFriendly Name: %s\n", pEvent->m_strDeviceFriendlyName.c_str());

// If the event is for the alarm array if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_ALARM_ARRAY_CONFIGURATION) { // Record the event's associated camera UDN TRACE_INFO("\tAssociated Camera UDN: %s\n", pEvent->m_strAssociateCameraUdn.c_str()); for (size_t i = 0; i < pEvent ->m_alarmOrRelayInfo.size(); i++) { // Record the alarm identifier TRACE_INFO("\tAlarm ID: %d\n", pEvent->m_alarmOrRelayInfo[i]->m_nId); // Record the alarm severity TRACE_INFO("\t\tSeverity: %d\n", pEvent->m_alarmOrRelayInfo[i]->m_nSeverity); // Record whether the alarm was changed (m_bChanged is true or false, // depending on whether the event was changed)

Page 66: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

66

TRACE_INFO("\t\tChanged: %s\n", (pEvent->m_alarmOrRelayInfo[i]->m_bChanged ? "Yes" : "No")); // Record whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) TRACE_INFO("\t\tState: %s\n", (pEvent->m_alarmOrRelayInfo[i]->m_bAlarmState ? "On" : "Off")); } } // If the event is for the relay array else if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_RELAY_ARRAY_CONFIGURATION) { for (size_t i = 0; i < pEvent->m_alarmOrRelayInfo.size(); i++) { // Record the alarm identifier TRACE_INFO("\tRelay ID: %d\n", pEvent->m_alarmOrRelayInfo[i]->m_nId);

// Record whether the alarm was changed (m_bChanged is true or false, // depending on whether the event was changed) TRACE_INFO("\t\tChanged: %s\n", (pEvent->m_alarmOrRelayInfo[i]->m_bChanged ? "Yes" : "No"));

// Record whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) TRACE_INFO("\t\tState: %s\n", (pEvent->m_alarmOrRelayInfo[i]->m_bAlarmState ? "On" : "Off")); } } // If the event is for motion detection else if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_MOTION_DETECTION) { // Record whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) TRACE_INFO("\tAlarm State: %s\n", (pEvent->m_bAlarmState ? "On" : "Off")); } // If the event is for video analytics else if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_VIDEO_ANALYTICS) { // Record whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) TRACE_INFO("\tAlarm State: %s\n", (pEvent->m_bAlarmState ? "On" : "Off"));

// Record the alarm severity TRACE_INFO("\tSeverity: %d\n", pEvent->m_nVideoAnalyticsSeverity); }

TRACE_INFO("EVENT Details: \n%s\n", szResponse);}

C# Example:

class MyEventAgentNet:PelcoAPI.IEventAgentNet{ Int32 nCounter = 0;

Page 67: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

67

public void NotifyEvent(String sResponse, PelcoAPI.EventNet eventNet) { Console.Write("\nNotify EVENT {0}:\n", ++nCounter);

// Display the event UDN Console.Write("\tUDN: {0}\n", eventNet.m_sUdn);

// Display the event service identifier Console.Write("\tService ID: {0}\n", eventNet.m_sServiceId); // Display the event time in UTC format Console.Write("\tUTC Time: {0}\n", eventNet.m_sUtcTime); // Display the event type Console.Write("\tType: {0}\n", eventNet.m_nType); // Display the event friendly name Console.Write("\tFriendly Name: {0}\n", eventNet.m_sDeviceFriendlyName); // If the event is for the alarm array if (eventNet.m_nType == 1) { Console.Write("\tAssociated Camera UDN: {0}\n", eventNet.m_sAssociateCameraUdn); for (Int32 i = 0; i < eventNet.m_alarmOrRelayInfo.GetLength(0); i++) { // Display the alarm identifier Console.Write("\tAlarm ID: {0}\n", eventNet.m_alarmOrRelayInfo[i].m_nId); // Display the alarm severity Console.Write("\t\tSeverity: {0}\n", eventNet.m_alarmOrRelayInfo[i].m_nSeverity); // Display whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) Console.Write("\t\tState: {0}\n", (eventNet.m_alarmOrRelayInfo[i].m_bAlarmState ? "On" : "Off")); } } // If the event is for the relay array else if (eventNet.m_nType == 2) { for (Int32 i = 0; i < eventNet.m_alarmOrRelayInfo.GetLength(0); i++) { // Display the alarm identifier Console.Write("\tAlarm ID: {0}\n", eventNet.m_alarmOrRelayInfo[i].m_nId); // Display whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) Console.Write("\t\tState: {0}\n", (eventNet.m_alarmOrRelayInfo[i].m_bAlarmState ? "On" : "Off")); } } // If the event is for motion detection else if (eventNet.m_nType == 4) { // Display whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off)

Page 68: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

68

Console.Write("\tAlarm State: {0}\n", (eventNet.m_bAlarmState ? "On" : "Off")); } // If the event is for video analytics else if (eventNet.m_nType == 8) { // Display whether the alarm was on or off (m_bAlarmState is true or false, depending on // whether the alarm was on or off) Console.Write("\tAlarm State: {0}\n", (eventNet.m_bAlarmState ? "On" : "Off")); // Display the alarm severity Console.Write("\tSeverity: {0}\n", eventNet.m_nVideoAnalyticsSeverity); } Console.Write("EVENT Details:\n{0}\n", sResponse); }}

Returning the Event Subscription URLNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++),or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper C++ andC# sample project.

1. Initialize the System Manager Wrapper.Refer to Initializing the System Manager Wrapper for details.

2. Call the System Manager Wrapper instance’s GetDeviceServiceAttribute method, passing in thefollowing:login ID

A result returned from a successful call to the UserLogin method.

target device’s Unique Device Name (UDN)To retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

web service’s Service IDA URN value found in the web service’s corresponding WSDL file.

attribute name of SYS_UpnpEventSubUrl

pointer to the variable that will hold the result

PelcoAPI::xstring sEvntUrl;bSuccess = sm.GetDeviceServiceAttribute(loginId, "UUID:B11DBF247E984B9BB83B7E74497DE6CA", "urn:schemas-pelco-com:service:MotionDetection:1", "SYS_UpnpEventSubUrl", &sEvntUrl)

Page 69: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

69

Initializing the Event Arbiter Library

Initializing the Event Arbiter Library for C++NOTE: The related source code for this entry can be found in EventArbiterSample.cpp’smain function which belongs to the Event Arbiter Library sample project. This assumes that youhave already completed the steps outlined in Creating an Event Agent.

1. Initialize the System Manager Wrapper.Refer to Initializing the System Manager Wrapper for details.

2. Declare the Event Arbiter Library instance. Set the Event Arbiter Library instance's network location andport number, using the System Manager’s IP address and port number.Refer to Automatically Determining the System Manager’s IP Address and Port Number for moredetails.

PelcoAPI::IEventArbiter * pEventArbiter = new PelcoAPI::EventArbiter("10.220.196.187", "60001", true);

3. Set the Event Arbiter Library instance's network location and port number, using the local host IPaddress and port number.

pEventArbiter->SetupIPAndPort("10.220.196.200", "9716");

4. Register your Event Agent class with the Event Arbiter Library instance.For details on creating an Event Agent, refer to Creating an Event Agent.

MyEventAgent agent;pEventArbiter->RegisterEventAgent(&agent);

Initializing the Event Arbiter Library for C#NOTE: In release mode, you need to select the Enable unmanaged code debugging checkbox inthe project settings to view console output.

A System Manager Is Available on Your Network

NOTE: The related source code for this entry can be found inManagedEventArbiterSample.cs’s main function, which belongs to the Event Arbiter LibraryC# sample project. This assumes that you have already completed the steps outlined in Creating anEvent Agent.

1. Initialize the System Manager Wrapper.Refer to Initializing the System Manager Wrapper for details.

2. Initialize your implemented Event Agent.Refer to Creating an Event Agent for details.

MyEventAgentNet pAgent = new MyEventAgentNet();

3. Next, declare the Event Arbiter Library instance. Set the following parameters:Event Arbiter Library instance's network location and port number

The client machine where it resides.

Your implemented Event Agent to register

The System Manager’s IP address and port number.

Page 70: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

70

Refer to Automatically Determining the System Manager’s IP Address and Port Number formore details.

booleanTrue to force the EventArbiter library to use the System Manager, false otherwise.

PelcoAPI.EventArbiterNet pEventArbiter = new PelcoAPI.EventArbiterNet("10.220.196.200", "9716", pAgent, "10.220.196.187", "60001", true);

A System Manager Is Not Available on Your Network

1. Initialize your implemented Event Agent.Refer to Creating an Event Agent for details.

2. Next, declare the Event Arbiter Library instance. Set the following parameters:Event Arbiter Library instance's network location and port number

The client machine where it resides.

Your implemented Event Agent to register

Use empty strings for parameters representing the System Manager’s IP address and portnumber.

Set the last parameter to false.Explicitly not rely on the System Manager‘s EventArbiter service.

PelcoAPI.EventArbiterNet pEventArbiter = new PelcoAPI.EventArbiterNet("10.220.196.200", "9716", pAgent, "", "", false);

Initializing the Event ManagerThe related source code for this entry (for C++) can be found in EventManagerSample.cpp’s mainfunction, which belongs to the Event Manager Library C++ sample project. The related source code for thisentry (for C#) can be found in the ManagedEventManagerSample.cs’s main function, which belongs tothe Event Manager C# sample project.

This assumes that you have already completed the steps outlined in the Creating an Event Agent. Thesesteps also require the existence of a System Manager on your network.

1. Initialize the System Manager Wrapper.Refer to Initializing the System Manager Wrapper for details.

2. Initialize your implemented Event Agent.Refer to Creating an Event Agent for details.

MyEventAgentNet pAgent = new MyEventAgentNet();

3. Next, declare the Event Arbiter Library instance. Set the following parameters:Event Arbiter Library instance's network location and port number

The client machine where it resides.

Your implemented Event Agent to register

The System Manager’s IP address and port number.Refer to Automatically Determining the System Manager’s IP Address and Port Number formore details.

boolean

Page 71: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

71

True to stop the EventArbiter library from using the System Manager. False to start theEventArbiter library using the System Manager.

C++ Example:

MyEventAgent agent;PelcoAPI::IEventManager * pEventManager = new PelcoAPI::EventManager("10.220.196.200", "9716", &agent, false, "10.220.196.187", "60001");

C# Example:

PelcoAPI.EventManagerNet pEventManager = new PelcoAPI.EventManagerNet("10.220.196.200", "9716", pAgent, false, "10.220.196.187", "60001");

Device or Service Specific SubscriptionsIf you want to subscribe to events from a specific web service or device, then this section will show you themost common scenarios.

Using the Event Arbiter Library to Subscribe Using the Device’s IP AddressNOTE: This entry is relevant for users who are not relying on either the System Manageror its EventArbiter service. The related source code for this entry can be found inEventArbiterSample.cpp’s main function (for C++) or ManagedEventArbiterSample.cs’smain function (for C#), which belongs to the Event Arbiter Library sample project.

This topic describes how to use the Event Arbiter Library to subscribe to a specific device’s particular webservice using the device’s IP address. Having an event subscription simply tells a device that you wouldlike to receive its event notifications. To request a event subscription, the following must be done:

1. Initialize the Event Arbiter Library.Refer to Initializing the Event Arbiter Library for details.

2. Call the Event Arbiter wrapper instance's SubscribeToEvents method (SubscribeEvents in C#),passing the event subscription URL.For details, refer to Returning the Event Subscription URL. If the request was successful, the methodwill return the event subscription's unique ID which will allow users to either renew or unsubscribe theevent subscription. If unsuccessful, the method returns NULL.

NOTE: Pelco SDK now automatically handles subscription renewals.

C++ Example:

const char * szSid_1 = pEventArbiter->SubscribeToEvents("http://10.220.196.184:80/event/AlarmArrayConfiguration-1");

C# Example:

String strSid_1 = pEventArbiter.SubscribeEvents("http://10.220.196.184:80/event/AlarmArrayConfiguration-1”);

Using the Event Arbiter Library to Subscribe Using the Event Subscription URLThis topic describes how to use the Event Arbiter Library to subscribe to a specific device’s particular webservice using the Event Subscription URL.

Page 72: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

72

NOTE: This entry is ONLY relevant for users who use an Endura network, specifically with anactive System Manager and an enabled EventArbiter service on the System Manager. The relatedsource code for this entry can be found in EventArbiterSample.cpp’s main function (for C++) or ManagedEventArbiterSample.cs’s main function (for C#), which belongs to the EventArbiter Library sample project.

1. Initialize the Event Arbiter Library.Refer to Initializing the Event Arbiter Library for details.

2. Construct an event service ID.It consists of the device’s UDN and the web service’s URN, which is its namespace on its WSDL file.(For details on determining a web service’s ID, refer to Returning the Event Subscription URL.)C++ Example:

std::string strEventServiceId = "uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15/urn:pelco-com:serviceId:AlarmArrayConfiguration-1";

C# Example:

String strEventServiceId = "uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15/urn:pelcocom:serviceId:AlarmArrayConfiguration-1";

3. Call the Event Arbiter Library instance's SubscribeToEvents method (SubscribeEvents in C#),passing the event service ID.If the request was successful, the method will return the event subscription's unique ID which will allowusers to either renew or unsubscribe the event subscription.

NOTE: Pelco SDK now automatically handles subscription renewals.

C++ Example:

const char * szSid_1 = pEventArbiter->SubscribeToEvents(strEventServiceId.c_str());

C# Example:

String strSid_1 = pEventArbiter.SubscribeEvents(strEventServiceId);

Using the Event Arbiter Library to Subscribe to All Instances of a ServiceNOTE: This entry is ONLY relevant for users who use an Endura network, specifically with anactive System Manager and an enabled EventArbiter service on the System Manager. The relatedsource code for this entry can be found in EventArbiterSample.cpp’s main function (for C++) or ManagedEventArbiterSample.cs’s main function (for C#), which belongs to the EventArbiter Library sample project.

If you want to subscribe to all devices that provide a specific web service like MotionDetection (or any otherweb service that has events), do the following:

1. Initialize the Event Arbiter Library.Refer to Initializing the Event Arbiter Library for details.

2. Construct an event URN.It is essentially the SOAP web service URN. You can determine this URN value looking at the webservice’s associated WSDL file (it should be near the top of the file).

Page 73: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

73

C++ Example:

std::string strEventUrn = "urn:schemas-pelco-com:service:MotionDetection:1";

C# Example:

String strEventUrn = "urn:schemas-pelco-com:service:MotionDetection:1";

3. Call the Event Arbiter wrapper instance's SubscribeToEvents method (SubscribeEvents in C#),passing the event URN.If the request was successful, the method will return the event subscription's unique ID which will allowusers to either renew or unsubscribe the event subscription.

NOTE: Pelco SDK now automatically handles subscription renewals.

C++ Example:

const char * szSid_1 = pEventArbiter->SubscribeToEvents(strEventUrn.c_str());

C# Example:

String strSid_2 = pEventArbiter.SubscribeEvents(strEventUrn);

Using the Event Arbiter Library to Subscribe to a Device's Web ServiceThis topic describes how to use the Event Arbiter Library to subscribe to a specific device’s particular webservice using the Event Subscription URL.

NOTE: This entry is ONLY relevant for users who use an Endura network, specifically with anactive System Manager and an enabled EventArbiter service on the System Manager. The relatedsource code for this entry can be found in EventArbiterSample.cpp’s main function (for C++) or ManagedEventArbiterSample.cs’s main function (for C#), which belongs to the EventArbiter Library sample project.

1. Initialize the Event Arbiter Library.Refer to Initializing the Event Arbiter Library for details.

2. Construct an event service ID.It consists of the device’s UDN and the web service’s URN, which is its namespace on its WSDL file.(For details on determining a web service’s ID, refer to Returning the Event Subscription URL.)C++ Example:

std::string strEventServiceId = "uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15/urn:pelco-com:serviceId:VideoAnalytics-2";

C# Example:

String strEventServiceId = "uuid:d557efb9-3a2d-48a1-b2fa-b48231f62f15/urn:pelcocom:serviceId:VideoAnalytics-2";

3. Call the Event Arbiter Library instance's SubscribeToEvents method (SubscribeEvents in C#),passing the event service ID.If the request was successful, the method will return the event subscription's unique ID which will allowusers to either renew or unsubscribe the event subscription.

NOTE: Pelco SDK now automatically handles subscription renewals.

Page 74: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

74

C++ Example:

const char * szSid_1 = pEventArbiter->SubscribeToEvents(strEventServiceId.c_str());

C# Example:

String strSid_1 = pEventArbiter.SubscribeEvents(strEventServiceId);

Using the Event Arbiter Library to Unsubscribe from a ServiceNOTE: The related source code for this entry can be found in EventArbiterSample.cpp’smain function (for C++) or ManagedEventArbiterSample.cs’s main function (for C#), whichbelongs to the Event Arbiter Library sample project. This entry assumes that the user has alreadycompleted the steps outlined in any of the Event Arbiter subscription-related entries.

To unsubscribe from an existing event subscription, call the Event Arbiter wrapper instance'sUnSubscribeToEvents method (UnsubscribeEvents in C#), passing the subscription identifier.You should receive subscription IDs on successful calls to SubscribeToEvents. If the request wassuccessful, the method will return a 1 (for C++) or true (for C#). Otherwise it will return a 0 (for C++) orfalse (for C#).C++ Example:

const char * szSid_1 = pEventArbiter->SubscribeToEvents("urn:schemas-pelco-com:service:MotionDetection:1");// ... misc logic ...pEventArbiter->UnSubscribeToEvents(strSid_1);

C# Example:

String strSid_1 = pEventArbiter.SubscribeEvents("urn:schemas-pelco-com:service:MotionDetection:1");// ... misc logic ...Boolean ret = pEventArbiter.UnsubscribeEvents(strSid_1);

Mass Subscriptions by CategoryIf you don’t really know what particular events or devices where you would like a subscription, then thissection is for you. It will show you how to subscribe to all events that fall under your desired category.

Using the Event Manager to Subscribe to All ServicesNOTE: The related source code for this entry can be found in EventManagerSample.cpp’smain function (for C++) or ManagedEventManagerSample.cs’s main function (for C#), whichbelongs to the Event Manager Library sample project. Also note that the Event Manager requiresthe presence of a System Manager on the network.

The following steps will allow you to subscribe to all events that fall under one of several categories definedby the Pelco SDK.

1. Initialize the Event Manager.Refer to Initializing the Event Manager for details.

2. Call the Event Manager instance's Start method, passing the desired event type as defined by thePelco SDK.The Event Manager will now start ‘listening’ to events. Use one or more of the following options (youcan add several of these values together to subscribe to more than one category of event at a time):

Page 75: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

75

C++ Example:

enum EventType{ EVENT_TYPE_UNKNOW = 0x00000000, EVENT_TYPE_ALARM_ARRAY_CONFIGURATION = 0x000000001, EVENT_TYPE_RELAY_ARRAY_CONFIGURATION = 0x00000002, EVENT_TYPE_MOTION_DETECTION = 0x00000004, EVENT_TYPE_VIDEO_ANALYTICS = 0x00000008, EVENT_TYPE_DIAGNOSTIC_REPORTING = 0x00000010, EVENT_TYPE_MASK = 0x0000001F};

C# Example:

enum REGISTER_EVENTS{ ALARM_ARRAY_CONFIGURATION = 0x00000001, RELAY_ARRAY_CONFIGURATION = 0x00000002, MOTION_DETECTION = 0x00000004, VIDEO_ANALYTICS = 0x00000008, DIAGNOSTIC_REPORTING = 0x00000010}

Alarm Array ConfigurationEvents that are related to the AlarmArrayConfiguration web service, such as an alarmcircuit connected to the camera has been turned on or off.

Relay Array ConfigurationEvents that are related to the RelayArrayConfiguration web service. This web servicegenerates no events. The functionality is provided for backward compatibility only.

Motion DetectionEvents that are related to the MotionDetection web service, such as the camera started orstopped detecting motion.

UnknownThis is a system-reserved value and can be disregarded.

MaskA system-reserved value that combines all the different event categories, allowing you tosubscribe to all of them at once.

NOTE: Always refer to the EventArbiterDefs header for the latest options. If the request wassuccessful, the method will return true; false otherwise.

C++ Example:

bool ret = pEventManager->Start(PelcoAPI::EVENT_TYPE_MASK);

C# Example:

Boolean ret = pEventManager.Start(REGISTER_EVENTS.EVENT_TYPE_MASK);

NOTE: Pelco SDK now automatically handles subscription renewals.

Using the Event Manager to Unsubscribe from All ServicesNOTE: The related source code for this entry can be found in EventManagerSample.cpp’smain function (for C++) or ManagedEventManagerSample.cs’s main function (for C#), which

Page 76: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

76

belongs to the Event Manager Library sample project. Also note that the Event Manager requiresthe presence of a System Manager on the network. This entry assumes that the user has alreadycompleted the steps outlined in the Event Manager subscription-related entry.

To unsubscribe from an existing event subscription for Event Manager, call the Event Managerinstance’s Stop method.If successful it will return true, false otherwise. The following example unsubscribes from all active eventsubscriptions at once.C++ Example:

bool ret = pEventManager->Stop();

C# Example:

Boolean ret = pEventManager.Stop();

Handling Incoming EventsNOTE: The related source code for this entry can be found in MyEventAgent.cpp’sNotifyEvent function (for C++), or the NotifyEvent function in the class MyEventAgentNet(for C#), which belongs to the Event Arbiter Library sample project. The availability of some data isdependent on the availability of a System Manager on your network, that is, if a System Manager isnot online, then some event data will be missing.

The Pelco SDK already parses event related data for you. All that is required is for you to figure out how touse our provided Event struct.

1. Define a class that implements the EventAgent interface.For details, refer to Creating an Event Agent.

2. Within your EventAgent implementation is the NotifyEvent method.This is where you will process any incoming event notifications. Events will be represented by the Eventstruct as defined in the EventArbiterDefs header. (The raw event XML string data will be encapsulatedby the parameter.)

Common to most events are the following attributes (listed below respectively):

• Device UDN, web service ID• The timestamp in UTC• The event type as defined by the Pelco SDK• The device’s friendly name

C++ Example:

void MyEventAgent::NotifyEvent(const char * szResponse, const Event * pEvent) { //... other logic ... pEvent->m_strUdn.c_str(); pEvent->m_strServiceId.c_str(); pEvent->m_strUtcEventTime.c_str(); pEvent->m_nType; pEvent->m_strDeviceFriendlyName.c_str();

C# Example:

Int32 nCounter = 0; public void NotifyEvent(String sResponse, PelcoAPI.EventNet eventNet)

Page 77: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

77

{ Console.Write("\nNotify EVENT {0}:\n", ++nCounter); Console.Write("\tUDN: {0}\n", eventNet.m_sUdn); Console.Write("\tService ID: {0}\n", eventNet.m_sServiceId); Console.Write("\tUTC Time: {0}\n", eventNet.m_sUtcTime); Console.Write("\tType: {0}\n", eventNet.m_nType); Console.Write("\tFriendly Name: {0}\n", eventNet.m_sDeviceFriendlyName);

If the incoming event is an alarm from the AlarmArrayConfiguration web service, it will provideinformation on the camera it is associated with as well as general alarm data.

C++ Example:

if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_ALARM_ARRAY_CONFIGURATION) { //the camera associated to this event pEvent->m_strAssociateCameraUdn.c_str(); for (size_t i = 0; i < pEvent->m_alarmOrRelayInfo.size(); i++) { //alarm ID pEvent->m_alarmOrRelayInfo[i]->m_nId; //alarm severity pEvent->m_alarmOrRelayInfo[i]->m_nSeverity; //the state of the alarm 0 off 1 on pEvent->m_alarmOrRelayInfo[i]->m_bState; } }

C# Example:

if (eventNet.m_nType == 1) { Console.Write("\tAssociated Camera UDN: {0}\n", eventNet.m_sAssociateCameraUdn); for (Int32 i = 0; i < eventNet.m_alarmOrRelayInfo.GetLength(0); i++) { Console.Write("\tAlarm ID: {0}\n", eventNet.m_alarmOrRelayInfo[i].m_nId); Console.Write("\t\tSeverity: {0}\n", eventNet.m_alarmOrRelayInfo[i].m_nSeverity); Console.Write("\t\tState: {0}\n", (eventNet.m_alarmOrRelayInfo[i].m_bState ? "On" : "Off")); } }

The RelayArrayConfiguration web service does not generate events. The functionality is providedfor backwards compatibility only.

C++ Example:

if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_RELAY_ARRAY_CONFIGURATION) { for (size_t i = 0; i < pEvent->m_alarmOrRelayInfo.size(); i++) { pEvent->m_alarmOrRelayInfo[i]->m_nId; pEvent->m_alarmOrRelayInfo[i]->m_bState;

Page 78: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

78

} }

C# Example:

else if (eventNet.m_nType == 2) { for (Int32 i = 0; i < eventNet.m_alarmOrRelayInfo.GetLength(0); i++) { Console.Write("\tAlarm ID: {0}\n", eventNet.m_alarmOrRelayInfo[i].m_nId); Console.Write("\t\tState: {0}\n", (eventNet.m_alarmOrRelayInfo[i].m_bState ? "On" : "Off")); } }

If the incoming event is from the MotionDetection web service, it will show whether or not the motiondetection region is active or inactive.

C++ Example:

if (pEvent->m_nType == PelcoAPI::EVENT_TYPE_MOTION_DETECTION) { pEvent->m_bAlarmState; }

C# Example:

else if (eventNet.m_nType == 8) { Console.Write("\tAlarm State: {0}\n", (eventNet.m_bAlarmState ? "On" : "Off")); Console.Write("\tSeverity: {0}\n", eventNet.m_nVideoAnalyticsSeverity); }

The szResponse parameter contains the raw event data in XML format. This is useful for debugging, orXML data binding to your classes.

C++ Example:

TRACE_INFO("EVENT Details: \n%s\n", szResponse);

C# Example:

Console.Write("EVENT Details:\n{0}\n", sResponse);

Polling EventsNOTE: The related source code for this entry can be found in EventArbiterSample.cpp'smain function (for C++) or ManagedEventArbiterSample.cs's Main function (for C#), whichbelongs to the Event Arbiter Library sample project. The availability of some data is dependent onthe availability of a System Manager on your network, that is, if a System Manager is not online,then some event data will be missing.

This API allows you to poll events instead of having to perform a callback.

1. Set the EventAgent to NULL in the RegisterEventAgent method.

Page 79: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Events and Alarms

79

C++ Example:

pEventArbiter->RegisterEventAgent(NULL);

C# Example:

MyEventAgentNet pAgent = null;

2. To poll events one by one using Event Arbiter or Event Manager, call the Event Arbiter or EventManager instance's PollEvent method.

std::string strRawEvent;PelcoAPI::Event pelcoEvent// Additional logic...if (pEventArbiter->PollEvent(strRawEvent, pelcoEvent))// ...

String sRawEvent = "";PelcoAPI.EventNet pelcoEvent = null;// Additional logic... if (pEventManager.PollEvent(ref sRawEvent, ref pelcoEvent))// ...

Page 80: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

80

Chapter

9Extracting Audio and Video Metadata

Extracting Audio and Video MetadataWARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use without modification.

WARNING: The content below assumes that the default target installation directory was chosenduring installation.

NOTE: For the latest Pelco documentation, visit http://pdn.pelco.com.

There will always be special situations, such as custom video analytics, that call for processing video meta-data like timestamps.

This section contains sample C# and C++ that illustrates how to use meta-data. Complete C# and C++sample programs are contained in the following subdirectory where the Pelco SDK is installed: Pelco\API\SampleCode\MetaDataParserSample

Where Does the Pelco SDK Fit?

The Meta-data Parser is a utility for parsing Pelco Video Elementary Stream (VES) meta-data from Pelcostreams. Pelco VES frames contain the following meta-data:

• MotionDetection active areas• Timestamps• Pelco Analytics drawing primitives• RSA Signature and other information necessary to verify the frame

The Meta-data Parser consists of an interface that provides access to the various objects within theelementary stream.

Page 81: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

81

Motion Detection Metadata

Motion detection involves computing the difference between two images. If the difference between thecompared images crosses a certain threshold value, then motion is detected and the selected Alert istriggered.

The key to Pelco’s motion detection feature is the Region of Interest (ROI). The ROI denotes a motiondetection region within a video frame. A motion detection region is essentially a grid of motion detection16x16 pixel cell blocks. These cells have sensitivity and movement threshold limits. The sensitivity leveldictates the amounts of movement that are registered within the ROI, while the threshold dictates theamounts of blocks that are registered within the ROI before the selected alarm is triggered.

What motion detection metadata is available? Currently in terms of metadata, each video frame can onlyhold a single ROI. Consequently, for each frame, the metadata describes the length and width of the ROI,while also holding a Pelco base64 bit mask for the state of the ROI.

NOTE: The difference between Pelco base64 and standard base64 implementations is that thePelco version always appends an = character at the end of the encoded value.

Pelco Analytics Drawing Primitives

Drawing primitives are basic graphical elements. They encompass drawing points, fills, lines, arcs, andeven text. This basically contains information related to the points, lines, arcs, and so on.

TimestampsTimestamp metadata represents the exact date and time when the video frame was captured. TheMetadata Parser Library can return this data in a number of ways.

struct timevalThe timestamp represented as a struct timeval.tv_secThe time interval in seconds since the epoch.

tv_usecThe time interval in microseconds since the epoch.

typedef struct timeval {long tv_sec;long tv_usec;} timeval;

Page 82: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

82

struct tmThe timestamp represented as a struct tm.tv_secThe time interval in seconds. (0-59)

tv_minThe time interval in minutes. (0-59)

tv_hourThe time interval in hours. (0-23)

tv_mdayThe time interval in day of the current month. (1-31)

tv_monThe time interval in months since January. (0-11)

tv_yearThe time interval in years since 1900.

tv_wdayThe time interval in days since Sunday. (0-6)

tv_ydayThe time interval in days since January 1st. (0-365)

tv_isdstA boolean that is true if it is currently daylight savings time, false otherwise.

typedef struct tm {int tm_sec;int tm_min;int tm_hour;int tm_mday;int tm_mon;int tm_year;int tm_wday; int tm_yday;int tm_isdst;}

In addition to returning the data above, the Metadata Parser Library also returns the daylight savings offset,the current timezone, and values in local time.

Getting StartedFor more information about getting started and setting up the working directory, refer to Setting Up SampleProjects.

Depending on whether you would like to use the release version of the Pelco SDK libraries or the debugversion, change the Working Directory value as appropriate. Assuming that you did not change the defaultinstallation directory for the Pelco SDK, use C:\\Program Files\Pelco\API\Libs\Debug.

NOTE: If running in Release mode, change this path to C:\Program Files\Pelco\API\Libs\Release.

What’s Ahead

This is a high level overview of possible tasks related to metadata:

Page 83: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

83

1. Access the metadata from the stream.2. Render metadata onto a video frame.

Initializing the Metadata Parser ClassNOTE: The related source code for this entry can be found in main.cpp’s main function, whichbelongs to the Metadata Parser C++ sample project.

1. Create a MetaDataParser instance.2. Call its SetData method, passing the buffer containing the data to analyze and the buffer length as

parameters.

PelcoAPI::MetaDataParser parser;parser.SetData(videoBuffer, length);

Creating a Metadata Renderer ClassNOTE: The related source code for this entry can be found in SampleMetaDataRenderer.cpp,which belongs to the MetaDataParser C++ sample project. You are expected to implement theactual logic.

This class is used for drawing onto video frames.

1. Implement the following required protected methods:a) DrawLine to draw a line using two given points: 'v1' and 'v2'

virtual void DrawLine(const PelcoAPI::VECTOR &v1, const PelcoAPI::VECTOR &v2,PelcoAPI::COLOR color) throw();

b) DrawRectangle to draw a rectangle whose upper left corner is determined by the parameter v1,while the lower right corner is determined by the parameter v2. If the fill parameter is set to true, therectangle should be solid. Otherwise, it should only be an outline.

virtual void DrawRectangle(const PelcoAPI::VECTOR &v1, const PelcoAPI::VECTOR &v2, PelcoAPI::COLOR color, bool fill) throw();

c) DrawPolygon to draw a polygon with corners defined within the Vector array. If the fill parameter isset to true, the polygon should be solid. Otherwise, it should only be an outline.

virtual void DrawPolygon(PelcoAPI::VECTOR *vectors, unsigned int count,PelcoAPI::COLOR fillColor, PelcoAPI::COLOR borderColor, bool fill) throw();

d) DrawText

virtual void DrawText(const std::string &text, const PelcoAPI::VECTOR &location, PelcoAPI::COLOR color) throw();

2. (Optional) Implement the following protected methods:a) BeginDraw to perform any pre-drawing work.

virtual void BeginDraw() throw();

Page 84: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

84

b) EndDraw to perform any post-drawing work.

virtual void EndDraw() throw();

c) TransformVectorForDisplay to handle point translation and scaling.

virtual PelcoAPI::VECTOR TransformVectorForDisplay(const PelcoAPI::VECTOR &v) throw();

Retrieving the Current Timestamp MetadataNOTE: The related source code for this entry can be found in main.cpp’s ProcessTimestampfunction, which belongs to the Metadata Parser C++ sample project.

1. Initialize the MetaDataParser.For details, refer to Initializing the Metadata Parser Class.

2. Verify whether the parser has found a timestamp by calling the HasTimeStamp method, which willreturn true if found, false otherwise.

if(true == parser.HasTimestamp()){

3. If there is a timestamp, call the GetTimeStampAsString method, passing in a local time Booleanparameter, which if true returns the timestamp in local time, while false returns the UTC value:

std::string timestamp = parser.GetTimestampAsString(true, "%c");

Motion Detection Metadata

Retrieving Motion Detection MetadataNOTE: The related source code for this entry can be found in main.cpp’s ProcessMotionDatafunction, which belongs to the Metadata Parser C++ sample project.

1. Initialize the MetaDataParser. For details, refer to Initializing the Meta-Data Parser Class.2. Check if the parser has found motion detection data by calling the HasMotionData method, which will

return true if found, false otherwise.

if(true == parser.HasMotionData()){

3. If there is motion detection metadata, call the GetMotionData method and pull the result into a newMotionData instance.

PelcoAPI::MotionData *data = parser.GetMotionData();

4. Parse the resulting data from the MotionData instance.

if(NULL != data){unsigned int cols = data->Columns();unsigned int rows = data->Rows();unsigned char *mask = data->Bitmask(); // Do something with the data here // Delete the motion data object

Page 85: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

85

Rendering Motion Detection MetadataNOTE: The related source code for this entry can be found in main.cpp’s ProcessMotionDatafunction, which belongs to the Metadata Parser C++ sample project.

NOTE: This entry assumes that the user has already completed the steps outlined in Creating aMetadata Renderer Class.

1. Initialize the MetaDataParser. For details, refer to Initializing the Meta-Data Parser Class.2. Check if the parser has found motion detection data. Call the HasMotionData method, and if true,

retrieve the motion metadata.

if(true == parser.HasMotionData()){ PelcoAPI::MotionData *data = parser.GetMotionData();

3. After you retrieve the motion detection metadata, declare your MetaDataRenderer class.

SampleMetaDataRenderer renderer;

4. Create a new COLOR struct, setting the desired alpha transparency and colors to display on the screen.In this example, the colors (red, green, blue) are fully opaque with zero transparency.

PelcoAPI::COLOR color = {255,0,128,255};

5. Render the motion metadata onto the screen by calling the RenderMotionData method.

renderer.RenderMotionData();

Drawing Metadata

Retrieving Drawing MetadataNOTE: The related source code for this entry can be found in main.cpp’sProcessDrawingData function, which belongs to the Metadata Parser C++ sample project.

1. Initialize the MetaDataParser. For details, refer to Initializing the Meta-Data Parser Class.2. Determine if the parser has found drawing data by calling the HasDrawingData method, which will

return true if found, false otherwise.

if(true == parser.HasDrawingData()){

3. If drawing metadata is found, call the GetDrawingData method, pulling the result into aDrawingData instance.

PelcoAPI::DrawingData *data = parser.GetDrawingData();

4. Parse the resulting data by iterating through the returned drawing primitives.

PelcoAPI::DrawingPrimitive *primitive = data->GetNextPrimitive();;while(primitive != NULL){primitive->GetPrimitiveType();PelcoAPI::DrawingPrimitive::FreePrimitive(primitive);primitive = data->GetNextPrimitive();}

Page 86: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Extracting Audio and Video Metadata

86

Rendering Drawing MetadataNOTE: The related source code for this entry can be found in main.cpp’s RenderDrawingDatafunction, which belongs to the Metadata Parser C++ sample project.

This entry assumes that the user has already completed the steps outlined in Creating a MetadataRenderer Class.

1. Iinitialize the MetaDataParser. For details, refer to Initializing the Metadata Parser Class.2. Determine if the parser has found drawing data by calling the HasDrawingData method, and if true,

retrieve the drawing metadata by calling the GetDrawingData.

if(true == parser.HasDrawingData()){ PelcoAPI::DrawingData *data = parser.GetDrawingData();

3. After you grab the drawing metadata, declare your MetaDataRenderer class.

SampleMetaDataRenderer renderer;

4. Create a new COLOR struct, setting the desired alpha transparency and colors to show on the screen. Inthis example, the colors (red, green, and blue) are fully opaque with zero transparency.

PelcoAPI::COLOR color = {255,0,128,255};

5. Render the drawing metadata onto the screen by calling the RenderDrawingData method.

renderer.RenderDrawingData();

Page 87: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

87

Chapter

10Exporting Video

OverviewWARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use without modification.

NOTE: The content in this section assumes that the default target installation directory was chosenduring installation.

NOTE: For the latest Pelco documentation, visit http://pdn.pelco.com.

This section contains sample C# and C++ that illustrates how to perform exports. Complete C# and C++ sample programs are contained in the following subdirectory where the Pelco SDK is installed C:\Program Files\Pelco\API\SampleCode\ExporterSample

At some point, you’ll need to export your video into a variety of major formats.

Where Does the Pelco SDK Fit?The Exporter module is a Pelco API SDK component that can export playback video, and save it in eitherAVI, MP4, 3GP, or PEF format. It is multithreaded to help ensure good performance and to export as manystreams as possible at any given time. Moreover, users will be able to export or playback saved streamswithout having to initialize the stream. Consequently it provides the flexibility to specify the camera, thestart time and an end time value. This tool is also able to embed meta-data (timestamp, and so on) intostreams (this requires transcoding which affects performance and authentication). When available, audiowill be included in the export in either PEF or AVI format.

Custom Application DevelopmentUsing the Exporter, a simple application can be written to select, initiate, and receive these streams tosave them to a video file. The most common file format for such video files is AVI. However, AVI is onlya container format, not a compression format. From this point forward, there are two principally differentimplementations for video storage: re-coding and native.

Re-coding Video

To avoid a complicated process, decoding and re-encoding is often employed to allow the video to beplayed back using the standard codecs provided with the Windows Media Player.

The native video format is either MPEG-4 or H.264, depending on the camera settings. If the video streamcoming from the camera is encoded using MPEG-4, the exported file will generally use MPEG-4 as well.No re-coding will be necessary unless you add overlays to the export. If the video stream coming fromthe camera is encoded using H.264, the exported file can use H.264 or MPEG-4, depending on the

Page 88: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

88

container format (3GP, AVI, MP4, PEF) and whether you add overlays to the export. (There is relativelylittle difference in size between container formats and compression formats.)

By default, Windows Media® Player supports MPEG-4, but not H.264. VLC supports both MPEG-4 andH.264.

Native Video

For recording large amounts of video data, such as when building near line storage solutions, storage inthe original (or native) format is essential as it preserves the bit rate. To play back these native video files,a codec that supports the complete ISO MPEG-4 standard (or at least the ISO MPEG-4 SP profile) mustbe installed in the end-user's media player. If a codec does not support the ISO MPEG-4 SP profile, thereceived video will not play back. Fortunately there are many complete ISO MPEG-4 codecs available;ranging from free, open source versions to highly optimized commercial versions

Getting StartedFor more information about getting started and setting up the working directory, refer to Setting Up SampleProjects.

What’s Ahead

This is a high level overview of possible tasks related to export.

1. Set up desired video clips to export.

• Configure desired parameters for each video clip to export.• If overlays are desired, set up overlays for each video clip.

2. Start the export, and continue to poll its status until it finishes successfully or encounters an error.

Initializing the ExporterThe related source code for this entry (for C++) can be found in main.cpp’s main function, whichbelongs to the Export C++ sample project. The related source code for this entry (for C#) can be found inProgram.cs’s Main function, which belongs to the Export C# sample project.

NOTE: In release mode, you need to select the Enable unmanaged code debugging check boxin the project settings to view console output.

Create the EnduraExporter instance, and then call its Setup method, passing the following:The location of the plugins directory.

The plugin directory contains components that are key to the SDK’s encoding, decoding,and transcoding capabilities. Without a proper reference, key features of the PelcoSDK could not function properly. Assuming that you didn’t change the default targetinstallation directory, it can be found here: C:\Program Files\Pelco\API\Libs\Debug\Plugins

NOTE: If running in Release mode, change this path to C:\Program Files\Pelco\API\Libs\Release\Plugins.

The System Manager’s IP address.For details on the importance of the System Manager for the Exporter, refer to VideoExports in the Appendix.

The IP Address to use for receiving incoming streamsThe client machine using the Pelco SDK.

(Optional) The name of the user that is performing the export.

Page 89: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

89

(Optional) The initial local port to use for the export.

NOTE: If you are running simultaneous exports, you must provide differentport values.

(Optional) The end port to use if initial port is in use.The exporter will keep increasing port numbers starting with the initial port number until theend port is reached.

C++ Example:

PelcoAPI::EnduraExporter exporter;exporter.Setup("C:\\Program Files\\Pelco\\API\\Libs\\Debug\\Plugins", "10.220.196.187", "10.220.196.189", USERNAME, 8000, -1);

C# Example:

PelcoAPI.EnduraExporterNet pEnduraExporterNet = new PelcoAPI.EnduraExporterNet();pEnduraExporterNet.Setup("C:\\Program Files\\Pelco\\API\\Libs\\Debug\\Plugins",

"10.220.196.187", "10.220.196.189", USERNAME, 8000, -1);

Setting Up Overlay Data on Video to Be ExportedThe related source code for this entry (for C++) can be found in main.cpp’s main function, whichbelongs to the Export C++ sample project. The related source code for this entry (for C#) can be found inProgram.cs’s Main function, which belongs to the Export C# sample project.

NOTE: This entry assumes that you are already familiar with the content in Exporting Video.

NOTE: If you choose to embed overlays with your video export, regardless of input source stream’sformat, the resulting exported file will be in MPEG-4 format.

1. First decide on what type of overlay that you would like to create.There are several types as defined in the EnduraExporterDefines header file:

enum OverlayType { OVERLAY_TYPE_TIMESTAMP = 0, OVERLAY_TYPE_CAMERANAME = 1, OVERLAY_TYPE_TEXTSTRING = 2, OVERLAY_TYPE_PICTURE = 3 };

2. Next, create the overlay structure.

• If performing a single video clip export as described in Exporting A Single Video Clip, the user mustuse the OverlayData method for each desired overlay type before starting the export.

exporter.OverlayData(PelcoAPI::OVERLAY_TYPE_TIMESTAMP,PelcoAPI::OVERLAY_LOCATION_BOTTOM_LEFT, NULL, FONTNAME, 10,fontColor, fontBgColor, 0);

pEnduraExporterNet.OverlayData(PelcoAPI.OverlayTypeNet.OVERLAY_TYPE_TIMESTAMP,PelcoAPI.OverlayLocationNet.OVERLAY_LOCATION_BOTTOM_LEFT, "",FONTNAME, 10, FONTCOLOR, FONTBGCOLOR, 0, DATEFORMAT,TIMEFORMAT);

Page 90: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

90

• If performing a stitched video clip export described in Stitching Multiple Clips Into a Single VideoExport, the user must use an OverlayInfo/OverlayInfoNet instance for each overlay typewanted before starting the export.

exportInfo[i].overlayInfo = newPelcoAPI::OverlayInfo[overlayNum]; exportInfo[i].overlayInfo[0].type =PelcoAPI::OVERLAY_TYPE_TIMESTAMP; // configure other parameters for the 1st overlay

PelcoAPI.OverlayInfoNet overlayInfo_0 = newPelcoAPI.OverlayInfoNet(); overlayinfo_0.type =PelcoAPI.OverlayTypeNet.OVERLAY_TYPE_TIMESTAMP; // configure other parameters for the 1st overlay

OverlayData ParametersOverlayData contains the following parameters. (Note that PPX export does not currently supportoverlays.)

timestampThe overlay displays a timestamp that provides the time in local time.

cameranameThe overlay displays a camera’s name. Typically the camera name displayed is the sourceof the video stream.

textstringThe overlay displays text that the user specifies.

pictureThe overlay displays a picture that the user specifies.

Now create a new instance of OverlayInfoNet and, based on the type of overlay you chose, simply startassigning the desired values with it such the font to use, the color of the font, the location of the overlay,and so on.The following is a list of other overlay settings (some can apply to certain overlay types as noted):location

The general screen location of the overlay. (Refer to the DataMixerPluginDefinesheader for the latest definition of OverlayLocation.)

enum OverlayLocation { OVERLAY_LOCATION_UNKNOWN, OVERLAY_LOCATION_TOP_LEFT, OVERLAY_LOCATION_TOP_MIDDLE, OVERLAY_LOCATION_TOP_RIGHT, OVERLAY_LOCATION_CENTER, OVERLAY_LOCATION_BOTTOM_LEFT, OVERLAY_LOCATION_BOTTOM_MIDDLE, OVERLAY_LOCATION_BOTTOM_RIGHT, OVERLAY_LOCATION_COORDINATE };

unknownThis denotes that the overlay will not appear on the screen.

top_left

Page 91: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

91

The overlay will appear in the top left corner of the screen.

top_middleThe overlay will appear in the top of the screen.

top_rightThe overlay will appear in the top right corner of the screen.

centerThe overlay will appear in the center of the screen.

bottom_leftThe overlay will appear in the bottom left corner of the screen.

bottom_middleThe overlay will appear in the bottom of the screen.

bottom_rightThe overlay will appear in the bottom right corner of the screen.

coordinateThis is a system reserved value. Please disregard this value.

valueThe actual value to display. For picture overlays, this is the full path to the picture todisplay. While for cameraname overlays, this is the name of the camera. Finally fortextstring overlays, this is just the alphanumeric value to display on the overlay. (This doesnot apply to timestamp overlays.)

fontNameThis is the name of an available font to use for displaying overlays. (This does not apply topicture overlays. )

fontSizeThis is the size of a font. (This does not apply to picture overlays .)

fontColorThis is the color of a font. (This does not apply to picture overlays.)

fontBgColorThis is the font’s color. (This does not apply to picture overlays.)

pictureOpacityThe opacity of the overlay. This ranges from transparent (0% opacity) to solid (100%opacity). (This is only relevant for picture overlays.)

dateFormatThis is only relevant to the timestamp overlay.

enum DateFormat { DATE_FORMAT_MDYYYY = 0, DATE_FORMAT_MDYY = 1, DATE_FORMAT_MMDDYY = 2, DATE_FORMAT_MMDDYYYY = 3, DATE_FORMAT_YYMMDD = 4, DATE_FORMAT_YYYY_MM_DD = 5, DATE_FORMAT_DD_MM_YY = 6, DATE_FORMAT_DMYY = 7, DATE_FORMAT_DDMMYY = 8, DATE_FORMAT_DMYYYY = 9, DATE_FORMAT_DDMMYYYY = 10,

Page 92: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

92

DATE_FORMAT_YYMD = 11, DATE_FORMAT_YYYYMD = 12, DATE_FORMAT_YYYYMMDD = 13, DATE_FORMAT_YYYY_M_D = 14, };

mdyyyThis date format conforms to the following structure: m/d/yyyy (month/day/year), whereboth 'm' and 'd' could be either one or two digits, for example, 12/8/2001 or 2/23/2001

mdyyThis date format conforms to the following structure: m/d/yy (month/day/year), where both'm' and 'd' could be either one or two digits, for example, 12/8/01 or 2/23/01

mmddyyThis date format conforms to the following structure: mm/dd/yy. (month/day/year), forexample, 02/23/01

mmddyyyyThis date format conforms to the following structure: mm/dd/yyyy (month/day/year), forexample, 02/23/2001

yymmddThis date format conforms to the following structure: yy/mm/dd (year/month/day), forexample, 01/02/23

yyyy_mm_ddThis date format conforms to the following structure: yyyy_mm_dd (year_month_day), forexample, 2001-02-23

dd_mm_yyThis date format conforms to the following structure: dd_mm_yy (day_month_year), forexample, 02-23-01

dmyyThis date format conforms to the following structure: d/m/yy (day/month/year), where both'm' and 'd' could be either one or two digits, for example, 23/2/01 or 8/12/01

ddmmyyThis date format conforms to the following structure: dd/mm/yy (day/month/year), forexample, 08/12/01 or 23/02/01

dmyyyyThis date format conforms to the following structure: d/m/yyyy (day/month/year), whereboth 'm' and 'd' could be either one or two digits, for example, 23/2/2001 or 8/12/2001

ddmmyyyyThis date format conforms to the following structure: dd/mm/yyyy (day/month/year), forexample, 21/03/2001

yymdThis date format conforms to the following structure: yy/m/d (year/month/day), where both'm' and 'd' could be either one or two digits, for example, 54/1/31 or 73/12/1

yyyymdThis date format conforms to the following structure: yyyy/m/d (year/month/day), whereboth 'm' and 'd' could be either one or two digits, for example, 1954/1/31 or 1973/12/1

yyyymmddThis date format conforms to the following structure: yyyy/mm/dd (year/month/day), forexample, 2001/02/23

Page 93: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

93

yyyy_m_dThis date format conforms to the following structure: yyyy_m_d (year_month_day), whereboth 'm' and 'd' could be either one or two digits, for example, 1954-1-31 or 1973-12-1

timeFormatThis is only relevant to the timestamp overlay.

enum TimeFormat { TIME_FORMAT_HHMMSSTT = 10, TIME_FORMAT_HMMSSTT = 11, TIME_FORMAT_HMMSS = 12, TIME_FORMAT_HHMMSS = 13, TIME_FORMAT_HMSTT = 14, TIME_FORMAT_TTHMS = 15, TIME_FORMAT_TTHHMMSS = 16, TIME_FORMAT_HMS = 17, };

hhmmssttThis time format conforms to the following 12 hour structure: hh:mm:ss tt(hours:minutes:seconds AM/PM), for example, 06:07:12 AM or 12:07:12 PM

hmmssttThis time format conforms to the following 12 hour structure: h:mm:ss tt(hours:minutes:seconds AM/PM), where 'h' could be either one or two digits, for example,6:07:12 AM or 12:07:12 PM

hmmssThis time format conforms to the following 24 hour structure: h:mm:ss(hours:minutes:seconds), where 'h' could be either one or two digits, for example, 6:07:12or 18:07:12

hhmmssThis time format conforms to the following 24 hour structure: hh:mm:ss(hours:minutes:seconds), for example, 06:07:12 or 18:07:12

hmsttThis time format conforms to the following 12 hour structure: h:m:s tt(hours:minutes:seconds), where 'h', 'm', or 's' could be either one or two digits, for example,6:7:12 AM, 12:17:12 PM, or 12:3:2 PM

tthmsThis time format conforms to the following 12 hour structure: tt h:m:s (AM/PMhours:minutes:seconds), where 'h', 'm', or 's' could be either one or two digits, for example,AM 6:7:12, PM 12:17:12, or PM 12:3:2

tthhmmssThis time format conforms to the following 12 hour structure: tt hh:mm:ss (AM/PMhours:minutes:seconds), for example, AM 06:07:12, PM 12:17:12, or PM 12:03:02

hmsThis time format conforms to the following 24 hour structure: H:m:s(hours:minutes:seconds), where 'h', 'm', or 's' could be either one or two digits, for example,6:7:12, 12:17:12, or 12:3:2

Resetting Overlay DataTo reset overlay data to default values for the video being exported, call the ResetData method.

Page 94: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

94

C++ Example:

bool bSuccess = exporter.ResetData();

C# Example:

Boolean bSuccess = pEnduraExporterNet.ResetData();

Exporting VideoThis section describes various video export methods and scenarios.

Exporting a Single Video ClipThe related source code for this entry (for C++) can be found in main.cpp’s main function, whichbelongs to the Export C++ sample project. The related source code for this entry (for C#) can be found inProgram.cs’s Main function, which belongs to the Export C# sample project.

1. Determine the System Manager’s IP address.Refer to Automatically Determining the System Manager’s IP Address and Port Number in the Deviceand Service Discovery section for details.

2. Initialize the Exporter.Refer to Initializing the Exporter for details.

3. Optional: If you would like to overlay data onto the resulting export, do so now.Refer to Setting Up Overlay Data on Video to Be Exported

4. Begin the video export by calling the Exporter’s StartExport method, passing in the followingparameters:The path, including file name, of the resulting exported video.

The format changes based on the operating system, for example, Windows® or Linux®.

The UUID of the camera from which to export video

The desired resulting video format for the exportRefer to the EnduraExporterDefines header for the latest options.

enum VideoCodecType{CODEC_ID_NONE = 0,/* video codecs */CODEC_ID_MPEG1 = 1,CODEC_ID_MPEG2 = 2,CODEC_ID_MJPEG = 8,CODEC_ID_MPEG4 = 13,CODEC_ID_H264 = 28};

The starting time of the recorded video to export in UTC (GMT), not local time, using theformat yyyy-mm-ddThh:mm:ss

The ending time of the recorded video to export in UTC (GMT), not local time, using theformat yyyy-mm-ddThh:mm:ss

The videoOnly parameterSet to true to export only video, while setting this to false to include audio (if it is available).If you want audio to be included, it will be available in either PEF or AVI format.

Page 95: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

95

The UUID of the stream to export’s audio source, if separate from the video source of theexport

C++ Example:

bool bSuccess = exporter.StartExport("D:\\Video\\test123.avi", "uuid:691fd745-006c-4fc9-9262-23c13e977ce4",PelcoAPI::CODEC_ID_MPEG4, "2010-01-11T22:10:35", "2010-01-11T22:11:15", false, "uuid:691fd745-006c-4fc9-9822-23c13e977ce4");

C# Example:

Boolean bSuccess =exporter.StartExport("D:\\Video\\test123.avi", "uuid:691fd745-006c-4fc9-9262-23c13e977ce4",PelcoAPI::CODEC_ID_MPEG4, "2010-01-11T22:10:35", "2010-01-11T22:11:15", false, "uuid:691fd745-006c-4fc9-9822-23c13e977ce4");

5. Poll the status of the video export repeatedly, for example, once per second, until it is finished. For moreinformation, refer to Polling a Video Export.

Exporting Video Using a Playlist (PPX)The playlist (PPX) format supports advanced playback features, including synchronized and sequential(stitched) playback.

For the following play-list example consider the following scenario; we have a system with nine cameras,named “camera_x”, where “x” is the spelling of a number from zero to eight. We want to play the filesin the following way; camera_zero from 9:05-9:10, followed by camera_one and camera_three playedtogether in a 2x1 layout both from 9:11 to 9:15. Assume that the video from camera_one for 9:13 has beendeleted. Following this we want to play camera_four from 9:20 to 9:30, then we want to play camera_two,camera_six, and camera_seven from 9:30 to 9:45, assume that camera_two’s video for 9:31-9:33 hasbeen deleted, and that its video from 9:42 to 9:44 has been deleted. Finally, we want to view camera_eightfrom 9:42 to 10:00. The following diagram illustrates the view flow.

1. Determine the System Manager’s IP address.Refer to Automatically Determining the System Manager’s IP Address and Port Number in the Deviceand Service Discovery section for details.

2. Initialize the Exporter.Refer to Initializing the Exporter for details.

3. Call the PlaylistExportInfo method to set up the clip groups that will be played sequentially in theorder provided.

Page 96: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

96

PlaylistExportInfo contains the following parameters:

DeviceIDThe UUID of the camera from which to export video

AudioDeviceIDThe UUID of the stream to export’s audio source, if separate from the video source of theexport.

StartTimeThe start time in UTC (GMT), not local time, using the format yyyy-mm-ddthh:mm:ss

EndTimeThe end time in UTC (GMT), not local time, using the format yyyy-mm-ddThh:mm:ss

VideoOnlyA boolean indicating if the clip should be exported with video only. If false, audio will alsobe included.

ClipGroupAn integer representing the sequential order to play video clips. Up to four clips can be inthe same clip group which will play in sync within the export player.

C++ Example:

PelcoAPI::PlaylistExportInfo playlistExportInfo[ NUM_CLIPS ]; playlistExportInfo[0].sDeviceID = CAMERA_1; playlistExportInfo[0].sStartTime = START_TIME_1; playlistExportInfo[0].sEndTime = END_TIME_1; playlistExportInfo[0].bVideoOnly = false; playlistExportInfo[0].nClipGroup = 1;

C# Example:

ArrayList playlistExportInfo = new ArrayList( num_clips ); playlistExportInfo.Add( new PelcoAPI.PlaylistExportInfoNet( CAMERA_1,"", START_TIME_1, END_TIME_1, false, 1 ) );

4. Begin the video export by calling the Exporter’s StartExport method, passing in the followingparameters:exportFolder

The path of the folder for exports. (The format changes based on operating system.)

playlistNameThe name of the playlist. This should be a simple name with no extensions

playlistExportInfoAn array of playlist information for export.

exportInfoCountThe number of export info entries

C++ Example:

bool bSuccess = exporter.StartExport("D:\\Video\\test123",“PlaylistName”, PlaylistExportInfo, exportInfoCount);

C# Example:

Boolean bSuccess = pEnduraExporterNet.StartExport("D:\\Video\\test123",

Page 97: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

97

“PlaylistName”, PlaylistExportInfo, exportInfoCount);

5. Poll the status of the video export repeatedly, for example, once per second, until it is finished.For more information, refer to Polling a Video Export.

Stitching Multiple Clips into a Single Video ExportNOTE: This stitching procedure is DEPRECATED. Stitched video clips do not play correctly withPelco Export Player. Please use Exporting Video Using a Playlist (PPX).

NOTE: Enabling sequential stitching can be much slower than exporting a single video clip,depending on whether any of the clips need to be transcoded.

There are occasions where you will need to export a single video from multiple video clips.

• First initialize as many video clip export settings (ExportInfo) instances as you will need. For detailson how to set up one set of video clip export settings, refer toSetting Up Overlay Data on Video to BeExported .

• At this point determine if you want to associate any overlays to the video clips. If so, create andinitialize any overlays to associate with the video clip to export. In the example excerpt below, we haveassociated four previously created OverlayInfo instances with two ExportInfo instances.

1. Determine the System Manager’s IP address.Refer to Automatically Determining the System Manager’s IP Address and Port Number in the Deviceand Service Discovery section for details.

2. Initialize the Exporter.Refer to Initializing the Exporter for details.

3. Optional: If you would like to overlay data onto the resulting export, do so now.Refer to Setting Up Overlay Data on Video to Be Exported for details.

4. Begin the video export by calling the Exporter’s StartExport method, passing in the followingparameters:The path, including file name, of the resulting exported video.

The format changes based on operating system, for example, Linux or Windows.

The desired resulting video format for the export.Refer to the EnduraExporterDefines header for the latest options.

enum VideoCodecType { CODEC_ID_NONE = 0, /* video codecs */ CODEC_ID_MPEG1 = 1, CODEC_ID_MPEG2 = 2, CODEC_ID_MJPEG = 8, CODEC_ID_MPEG4 = 13, CODEC_ID_H264 = 28 };

An array of the ExportInfo instances, containing instances of OverlayInfo.

The number of ExportInfo instances, one for each clip to stitch.

Below is a stitched video export example:

C++ Example:

int i = 0; int clipNum = 2; int overlayNum = 4;

Page 98: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

98

PelcoAPI::ExportInfo * exportInfo = newPelcoAPI::ExportInfo[clipNum]; exportInfo[0].sDeviceID ="uuid:00047D01-4CA5-5370-6563-747261495605"; exportInfo[0].sStartTime = "2009-08-16T05:08:00"; exportInfo[0].sEndTime = "2009-08-16T05:09:00"; exportInfo[0].bVideoOnly = false; exportInfo[0].overlayNum = overlayNum; exportInfo[1].sDeviceID = "uuid:691fd745-006c-4fc9-9262-23c13e977ce4"; // configure other export settings for the 2nd clip to export if (overlayNum > 0) { for (i = 0; i < clipNum; i++) { exportInfo[i].overlayInfo = new PelcoAPI::OverlayInfo[overlayNum]; exportInfo[i].overlayInfo[0].type = PelcoAPI::OVERLAY_TYPE_TIMESTAMP; // configure other settings for the 1st overlay exportInfo[i].overlayInfo[1].type = PelcoAPI::OVERLAY_TYPE_CAMERANAME; // configure other settings for the 2nd overlay exportInfo[i].overlayInfo[2].type = PelcoAPI::OVERLAY_TYPE_PICTURE; // configure other settings for the 3rd overlay exportInfo[i].overlayInfo[3].type = PelcoAPI::OVERLAY_TYPE_TEXTSTRING; // configure other settings for the 4th overlay } } bool bSuccess = exporter.StartExport("D:\\Video\\test123.mp4", PelcoAPI::CODEC_ID_MPEG4, exportInfo, 2);

C# Example:

PelcoAPI.ExportInfoNet exportInfo_0 = new PelcoAPI.ExportInfoNet(); exportInfo_0.sDeviceID = "uuid:00047D01-4CA5-5370-6563-747261495605"; exportInfo_0.sStartTime = "2009-08-16T05:08:00"; exportInfo_0.sEndTime = "2009-08-16T05:09:00"; exportInfo_0.bVideoOnly = true; PelcoAPI.ExportInfoNet exportInfo_1 = new PelcoAPI.ExportInfoNet(); // initialize another export video clip setting exportInfo_0.overlayInfo = new ArrayList(); exportInfo_0.overlayInfo.Add(overlayInfo_0); // add any other overlay settings here exportInfo_1.overlayInfo = new ArrayList(); exportInfo_1.overlayInfo.Add(overlayInfo_0); // add any other overlay settings here ArrayList exportInfo = new ArrayList(2); exportInfo.Add(exportInfo_0); exportInfo.Add(exportInfo_1); Boolean bSuccess = pEnduraExporterNet.StartExport("C:\\test456.avi",

Page 99: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

99

PelcoAPI.VideoCodecTypeNet.CODEC_ID_MPEG4, exportInfo, 2);

5. Poll the status of the video export repeatedly, for example, once per second, until it is finished.For more information, refer to Polling a Video Export.

Polling a Video ExportTo poll the status of the video export until it is finished, perform the following:C++ Example:

for( int clipCounter = 0; clipCounter < NUM_CLIPS; ++clipCounter ) { int status = 0; while( status < 100 && status != -1 ) { int temp = exporter.PollStatus(); if (temp != status) { status = temp; TRACE_INFO("Polling status %d\n", status); } } }

C# Example:

Int32 clipCounter = 0; while (clipCounter < num_clips) { Int32 status = 0; Int32 temp = 0; while (status < 100 && status != -1) { temp = pEnduraExporterNet.PollStatus(60); if (temp != status) { status = temp; Console.WriteLine("Polling status - {0}\n", status); } } ++clipCounter; }

Stopping a Video ExportWhen you want to force a video export that is currently in progress to stop, just call the StopExportmethod.C++ Example:

bool bSuccess = exporter.StopExport();

C# Example:

Boolean bSuccess = exporter.StopExport();

Page 100: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Exporting Video

100

Exporting A JPEG SnapshotTo create a JPEG snapshot, call the ExportSnapshot method, passing in a .jpeg or .jpg file name,camera uuid, and timestring (use NOW for a live snapshot).The following is an example of a live snapshot.C++ Example:

bool bSuccess = exporter.ExportSnapshot("testSnapShot.jpeg", "uuid:00047D01-8994-5370-6563-747261495605", "NOW");

C# Example:

Boolean bSuccess = exporter.ExportSnapshot("testSnapShot.jpeg", "uuid:00047D01-8994-5370-6563-747261495605", "NOW");

The following is an example of a recorded snapshot.C++ Example:

bool bSuccess = exporter.ExportSnapshot("testSnapShot.jpeg", "uuid:00047D01-8994-5370-6563-747261495605", "2011-11-07T19:30:00");

C# Example:

Boolean bSuccess = exporter.ExportSnapshot("testSnapShot.jpeg", "uuid:00047D01-8994-5370-6563-747261495605", "2011-11-07T19:30:00");

Page 101: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

101

Chapter

11Web Service Proxies

Web Service ProxiesWARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use without modification.

WARNING: The content below assumes that the default target installation directory was chosenduring installation.

For the latest Pelco documentation, visit http://pdn.pelco.com.

Overview

PelcoGSoap is a static linked library generated by gSOAP tools, based on the WSDL files with minormodifications. The PelcoGSoap library provides an interface for SOAP clients to make SOAP calls toPelco devices. It accounts for most issues regarding making SOAP calls to Pelco devices.

General UsageNOTE: This entry assumes that users have already installed the Pelco SDK.

1. Include the stdsoap2 header and the web service proxy header. For example, if you want to use theCameraConfiguration web service, you should include the CameraConfigurationProxy header.

#include "PelcoAPI/stdsoap2.h"#include "PelcoAPI/CameraConfigurationProxy.h"

2. Declare your web service proxy. In this case, it will be CameraConfigurationProxy.

CameraConfigurationProxy CameraConfiguration;

3. Set the SOAP header.

pSoap->header = (struct SOAP_ENV__Header *) soap_malloc(CameraConfiguration, sizeof(struct SOAP_ENV__Header));

4. Set the web service’s control point URL. For details on the proper way to retrieve the control point URL,refer to Retrieving a Specific Web Service’s Control URL.

CameraConfiguration.soap_endpoint = strEndPointURL.c_str();

5. Create a new web service action request instance.This will hold your request parameters for the web service action ResetConfiguration.

Page 102: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Web Service Proxies

102

6. Create a new web service action response instance. In the below example, we create an instance ofCameraConfiguration’s ResetConfigurationResponse data type.

_CameraConfiguration__ResetConfigurationResponse * pResetConfigurationResponse = soap_new__CameraConfiguration__ResetConfigurationResponse(&CameraConfiguration, -1);

This will hold the web service’s response including related values to your request.7. Call the CameraConfiguration web service proxy ResetConfiguration action, passing in both

the earlier created ResetConfiguration and ResetConfigurationResponse parameters. Thendetermine if the operation was successful.

CameraConfiguration.ResetConfiguration(pResetConfiguration, pResetConfigurationResponse);#include "PelcoAPI/stdsoap2.h"#include "PelcoAPI/LensControlProxy.h" #include "GSOAPSample.h" using namespace PelcoAPI; void GSOAPSample::StopLens() throw(){LensControlProxy LensControl; std::string cameraAddress = "10.18.129.231";std::string cameraPort = "49152"; pSoap->header = (struct SOAP_ENV__Header *) soap_malloc(LensControl, sizeof(struct SOAP_ENV__Header)); std::string strEndPointURL = "http://" + cameraAddress + (cameraPort.empty() ? "" : ":" + cameraPort) + "/control/LensControl-1";LensControl.soap_endpoint = strEndPointURL.c_str(); _LensControl__Stop * pStop = soap_new__LensControl__Stop(&LensControl, -1); _LensControl__StopResponse * pStopResponse = soap_new__LensControl__StopResponse(&LensControl, -1);if (LensControl.Stop(pStop, pStopResponse) != SOAP_OK)

Page 103: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

103

Chapter

12Discovery

Device and Service Discovery OverviewWARNING: Any provided sample code is meant to be a reference implementation focused oneducating developers about Pelco devices. Though there are exceptions, in general Pelco samplecode is NOT intended for immediate production use without modification.

WARNING: The content below assumes that the default target installation directory was chosenduring installation.

For the latest Pelco documentation, visit http://pdn.pelco.com.

One of the most basic tasks is to programmatically determine what devices and services are available onyour network.

This section contains sample C# and C++ that illustrates how to discover devices and services. CompleteC# and C++ sample programs are contained in the following subdirectory where the Pelco SDK is installed:Pelco\API\SampleCode\SystemManagerWrapperSample

Where Does the Pelco SDK Fit?

The key to performing device and service discovery related tasks is the System Manager Wrapper. TheSystem Manager Wrapper is a component of the Pelco SDK. It provides users with convenience functionsfor device and service queries.

The majority of the tasks covered in this section can be found in the the System Manager Wrapper C++sample project. You should examine the sample project source code while reading this documentation.

NOTE: For more Endura specific information, refer to the Endura appendix.

Page 104: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

104

Getting Started

For more information about getting started and setting up the working directory, refer to Setting Up SampleProjects.

Change the Working Directory value as appropriate. Assuming that you did not change the defaultinstallation directory for the Pelco SDK, use C:\\Program Files\Pelco\API\Libs\Debug.

NOTE: If running in Release mode, change this path to C:\Program Files\Pelco\API\Libs\Release.

Next Steps

The following set of tasks are essential for using the Pelco SDK:

• Determine the System Manager’s IP address and port number, either manually, or automaticallythrough the Pelco SDK as described in Automatically Determining the System Manager’s IP Addressand Port Number.

• Create a class that implements the IDeviceStorageNet interface.• Query all available Pelco devices on your network.

Initializing the Pelco SDK System Manager WrapperNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++)or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

Before performing any of the tasks associated with the System Manager Wrapper, you must initialize aninstance of it. Then you can use the instance to log in to the System Manager, since most System ManagerWrapper methods require a login ID.

NOTE: In release mode, you need to select the Enable unmanaged code debugging check boxin the project settings to view console output.

1. Declare and initialize the System Manager Wrapper.a) If you need to determine the System Manager’s IP address, refer to Automatically Determining the

System Manager’s IP Address and Port Number.b) If you already know the System Manager’s IP address, enter it into the SetSMAddress method as

shown below.C++ Example:

PelcoAPI::SystemManagerWrapper sm; int nRet = sm.SetSMAddress((char *) sSMIPAddress);

C# Example:

PelcoAPI.SystemManagerWrapperNet sm = new PelcoAPI.SystemManagerWrapperNet(); int nRet = sm.SetSMAddress("192.168.1.1");

2. Log in to the System Manager with the proper credentials. Call the System Manager Wrapper instance’sUserLogin method, passing in the username and password.C++ Example:

int loginId = sm.UserLogin("brian", "pelco");

C# Example:

Int32 loginId = sm.UserLogin("brian", "pelco");

Page 105: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

105

If successful, this step should return an ID of your login session. Make a note of this login ID, because itis used for many of the System Manager Wrapper’s methods.

3. After you have logged in to System Manager, you will eventually have to log out. When you havefinished all System Manager related operations, log out by calling the System Manager Wrapperinstance’s UserLogout method, passing in your login ID as the parameter.For more details on authenticating to a Pelco system, refer to Logging In and Logging Out.C++ Example:

sysMgr.UserLogout(loginId);

C# Example:

sm.UserLogout(loginId);

Automatically Determining the System Manager’s IP Address and PortNumber

NOTE: The related source code for this entry can be found in main.cpp’s main function (for C++)or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

1. Initialize the System Manager Wrapper by calling its AutoDiscoverSM method to automaticallydetermine the System Manager's IP address and port number.The 120 parameter represents the duration in seconds before a timeout.

int nRet = sm.AutoDiscoverSM(120);

2. To access the System Manager’s IP address and port number, call the GetSMAddress method.C++ Example:

int rPort = 0; // ... Auto discover SM ...// Return the SM IP AddressPelcoAPI::xstring sIpAddress;sm.GetSMAddress(&sIpAddress,&rPort);TRACE_INFO("The SM IpAdress - %s and Port - %d\n", sIpAddress.data, rPort);PelcoAPI::xfree(&sIpAddress);

C# Example:

// ... Auto discover SM ...String sSmIpAddress = "";Int32 nPort = -1;if( sm.GetSMAddress(ref sSmIpAddress, ref nPort ) )Console.WriteLine("SM address -> {0}:{1}\n", sSmIpAddress, nPort); elseConsole.WriteLine( "Could not get SM address\n" );

Logging In and Logging OutNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++)or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

Page 106: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

106

In many cases, you might need to both log in and log out of System Manager.

1. To log in to the System Manager with the proper credentials, call the System Manager Wrapperinstance’s UserLogin method, passing in the username and password.

int loginId = sm.UserLogin("brian", "pelco");

If successful, this step should return an ID of your login session.

NOTE: Make a note of this login ID, because it is used for many of the System ManagerWrapper’s methods.

2. When you have finished all System Manager related operations, log out of the System Manager.Call the System Manager Wrapper instance’s UserLogout method, passing in your login ID as theparameter.

sysMgr.UserLogout(loginId);

Querying Available Devices from the System ManagerNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: Before proceeding with this entry, it is assumed that you have already completed the stepsoutlined in Creating an IDeviceStorage Class.

The first major task that you need to complete is to query all Pelco devices available on your network.Completing this enables you to access a device’s Unique Device Name (UDN) and many other device-related attributes that are needed for other Pelco SDK related tasks.

1. Initialize the System Manager Wrapper. Refer to Initializing the System Manager Wrapper for details.2. Make a call to the System Manager Wrapper's GetDevices method, passing in the following

parameters:

• Your login ID: This ID is returned after a successful login. Refer to Initializing the System ManagerWrapper for details.

• The sequence number: This is used to filter results, only returning newly added or changed devices.GetDevices calls return a new integer value once every few minutes during successive calls.New values are one larger than the one before, for example, if the 1st call returned 1, then thesubsequent call will return a 2.

• The device type you would like to use to filter the results. Known device types include the following:

• Camera• Encoder• Decoder• Monitor• a NULL value (to not filter results by type of device)

NOTE: This is not a definitive list of Pelco device types. This list will expand as Pelco expandsits product line.

• A pointer to your IDeviceStorage implementation.

C++ Example:

int seqNum = 0;MyStorage storage; // ... You must define this class ...int loginId = sm.UserLogin("brian", "pelco");sm.GetDevices(loginId, &seqNum, "Camera", &storage);

Page 107: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

107

C# Example:

int seqNum = 0;DeviceInformation devStore = new DeviceInformation(); // You must define this classint loginId = sm.UserLogin("brian", "pelco"); Boolean bSuccess = sm.GetDevices(loginId, seqNum, "Camera", devStore);

3. Perform the needed operations on the returned device data and store them into the IDeviceStorageclass instance. Refer to Creating an IDeviceStorage Class for further details.

4. To query any changes with available devices from the System Manager, use the returned sequencenumber value from your last call to the GetDevices method with your next call to the same method.This call returns Pelco devices that have changed or are new to the network. Every subsequent callreturns only new changes within your network.C++ Example:

int seqNum = 0;MyStorage storage; // ... You must define this class ...int loginId = sm.UserLogin("brian", "pelco");sm.GetDevices(loginId, &seqNum, "Camera", &storage); // ... seqNum changes here to 1 ...// ... Misc logic ...sm.GetDevices(loginId, &seqNum, "Camera", &storage); // ... seqNum changes here to 2 ...

C# Example:

int seqNum = 0;DeviceInformation devStore = new DeviceInformation(); // You must define this classint loginId = sm.UserLogin("brian", "pelco");sm.GetDevices(loginId, ref seqNum, "Camera", &storage); // seqNum changes here to 1 ...// ... Misc logic ...sm.GetDevices(loginId, ref seqNum, "Camera", &storage); // seqNum changes here to 2 ...

Retrieving the System Manager’s Time ZoneNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

To determine your System Manager’s current time zone, do the following:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetSystemAttribute method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

SYS_CFG_TzInfoThe time zone attribute’s ID.

sTimezoneInfoA pointer to your time zone variable.

Page 108: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

108

C++ Example:

PelcoAPI::xstring sTimezoneInfo;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetSystemAttribute(loginId, "SYS_CFG_TzInfo", &sTimezoneInfo);

C# Example:

int loginId = sm.UserLogin("brian", "pelco");String sTimeZone = "";Boolean bSuccess = sm.GetSystemAttribute(loginId, "SYS_CFG_TzInfo", ref sTimeZone);

Retrieving the Network Time Server AddressNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

To your network’s network time server’s IP Address, do the following:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetSystemAttribute method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

SYS_CFG_NtpAddrThe network time server's attribute’s ID.

sNtpAddressA pointer to your NTP address variable.

C++ Example:

PelcoAPI::xstring sNtpAddress; int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetSystemAttribute(loginId, "SYS_CFG_NtpAddr", &sNtpAddress);

C# Example:

int loginId = sm.UserLogin("brian", "pelco");String sNtpAddress = "";Boolean bSuccess = sm.GetSystemAttribute(loginId, "SYS_CFG_NtpAddr",ref sNtpAddress);

Retrieving a Web Service’s IDNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: This entry assumes that you have already completed the steps outlined in QueryingAvailable Devices from the System Manager, which provides you with UDNs for Pelco devicesavailable on your network.

Page 109: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

109

To determine your web service's ID, do the following:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetServiceID method, passing in the following parameters:

Your login IDThis ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

sServiceType

The name of desired web service, such as VideoOutput.

sServiceId

The pointer to the variable that will hold the result.

C++ Example:

PelcoAPI::xstring sServiceId;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetServiceID(loginId, "uuid:00047D01-4CA5-5370-6563-747261495605","VideoOutput", &sServiceId);

Retrieving a Specific Web Service’s Control URLNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: This entry assumes that you have already completed the steps outlined in QueryingAvailable Devices from the System Manager, which provides you with UDNs for Pelco devicesavailable on your network.

Obtaining a web service’s control URL is essential for many Pelco-related operations.

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetDeviceServiceAttribute method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

The target web service’s IDRefer to Retrieving a Web Service’s ID for details.

SYS_UpnpControlUrl

The control URL attribute’s ID.

sCtrlUrl

A pointer to the variable that will store the result of the web service control URL.

Page 110: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

110

C++ Example:

PelcoAPI::xstring sCtrlUrl;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetDeviceServiceAttribute(loginId, "urn:schemas-pelco-com:service:MotionDetection:1", "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpControlUrl", sCtrlUrl);

C# Example:

String sCtrlUrl = “”; int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm.GetDeviceServiceAttribute(loginId,"urn:schemas-pelco-com:service:MotionDetection:1", "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpControlUrl",ref sCtrlUrl);

Retrieving the NVR Associated with the DeviceNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: This entry assumes that you have already completed the steps outlined in QueryingAvailable Devices from the System Manager, which provides you with UDNs for Pelco devicesavailable on your network.

To determine to which NVR or NSM your camera is connected to record, complete the following steps:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetDeviceAttributeValue method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

SYS_NvrAssoc

The NVR association attribute’s ID.

sNvr

The pointer to the variable that will hold the result.

C++ Example:

PelcoAPI::xstring sNvr;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetDeviceAttributeValue(loginId, "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_NvrAssoc",&sNvr);

C# Example:

String sNvr = “”;int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm.GetDeviceAttributeValue(loginId,

Page 111: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

111

"uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_NvrAssoc", ref sNvr);

Retrieving the Device’s Friendly NameNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: This entry assumes that you have already completed the steps outlined in QueryingAvailable Devices from the System Manager, which provides you with UDNs for Pelco devicesavailable on your network.

To determine a device’s friendly name, you can simply parse through the results of a GetDevices methodcall, which includes both the device UDN and its accompanying attributes. Alternatively, you can completethe following steps:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetDeviceAttributeValue method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

SYS_UpnpFriendlyName

The attribute name.

sFriendlyName

The pointer to the variable that will hold the result.

C++ Example:

PelcoAPI::xstring sFriendlyName;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetDeviceAttributeValue(loginId, "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpFriendlyName", &sFriendlyName);

Retrieving the Device’s Device Description File (DDF) URLNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

What is DDF? The Device Descriptor File (DDF) is file containing device related data such asmanufacturer, model name, and so on, in XML format. To get the location of a specific device’s DDF, dothe following:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetDeviceAttributeValue method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

Page 112: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

112

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

SYS_UpnpDevDescUrl

The attribute ID.

sDdfUrl

The pointer to the variable that will hold the result.

C++ Example:

PelcoAPI::xstring sFriendlyName;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetDeviceAttributeValue(loginId, "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpDevDescUrl", &sDdfUrl);

C# Example:

String sFriendlyName = “”;int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm.GetDeviceAttributeValue(loginId,"uuid:00047D01-4CA5-5370-6563-747261495605","SYS_UpnpDevDescUrl", ref sDdfUrl);

Retrieving All Web Services Available on a DeviceNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

To show all available web services on a particular Pelco device, complete the following steps:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetServiceInfoSync method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

The sequence numberThis has the same function as other Pelco query methods, in that it can help limit theresults to only new or changed items. This makes sense for querying devices on anetwork. However, a device’s available web services does not change very often, if ever,without a new firmware update. Therefore, this value should almost always be a 0.

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

storage

The pointer to the variable that will hold the result.

C++ Example:

int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm. GetServiceInfoSync(loginId, 0,

Page 113: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

113

"uuid:00047D01-4CA5-5370-6563-747261495605", storage);

C# Example:

int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm. GetServiceInfoSync(loginId, 0,"uuid:00047D01-4CA5-5370-6563-747261495605", storage);

Retrieving Device AttributesNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: This entry assumes that you have already completed the steps outlined in QueryingAvailable Devices from the System Manager, which provides you with UDNs for Pelco devicesavailable on your network.

Device attributes are values that describe the device in some way such as its model number or its modelname. The following are the most common device attributes:

SYS_UpnpPelcoDeviceUdn

A Pelco device’s Unique Device Name (UDN); a special device identifier for networks.

SYS_UpnpFriendlyName

A more human readable version of the device’s name. A separate attribute,friendlyName, can be present. Users can customize this attribute. When present,friendlyName should be used in place of SYS_UpnpFriendlyName for displaypurposes.

SYS_UpnpDeviceType

A URN that denotes the device’s category.

SYS_UpnpDevDescUrl

This shows the location of the device’s UPnP Device Descriptor File (DDF).

SYS_UpnpSerialNumber

The device’s serial number.

SYS_UpnpModelNumber

The device’s model number.

SYS_UpnpModelDescription

A more detailed description of the device.

SYS_UpnpManufacturerUrl

The device manufacturer’s website.

SYS_UpnpModelName

The device’s model name.

This outlines the steps needed to return a specific device attribute:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetDeviceAttributeValue method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

Page 114: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

114

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

The name of the device attribute to query.

The pointer to the variable that will hold the result.

C++ Example:

PelcoAPI::xstring sModelNumber;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetDeviceAttributeValue(loginId, "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpModelNumber", &sModelNumber);

C# Example:

String sModelNumber = "";int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm.GetDeviceAttributeValue(loginId,"uuid:00047D01-4CA5-5370-6563-747261495605","SYS_UpnpModelNumber", ref sModelNumber);

Retrieving a System Manager’s AttributeNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

A System Manager’s attributes are similar to a generic Pelco device’s attributes, except in most casesa System Manager attribute is exclusive to Pelco System Managers. If you aren’t familiar with deviceattributes, System Manager attributes are simply values that describe the System Manager in some waysuch as its current time zone or its current security mode. The following are the more common SystemManager attributes:

SYS_CFG_NtpAddr

This value is used to indicate the location at which the NTP server (if any) can be located.The expected value is an IP address.

SYS_CFG_SecMode

This value is used to identify the system's current security mode.

SYS_CFG_SmtpAddr

This value is used to indicate the location at which the SMTP server (if any) can belocated. The expected value is an IP address.

SYS_CFG_TzInfo

This value is used to report time zone information. This value is comma delimited (withoutwhitespace). The following describes each number in the order in which they appear in thecomma-delimited list (for example, 1205056800,60,480):

Change Time

This number is the absolute daylight savings time (in time_t time() seconds). If this value iszero, there is no daylight savings time for the time zone and nothing will have to be doneto support daylight savings. If the value is nonzero, the time zone does support daylightsavings time. In this case, if the value is negative, the time value is being used to indicatethe time to turn off daylight savings time. If the value is positive, the value is being used toindicate the time at which daylight savings time is to be turned on.

Page 115: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

115

DST Offset

This number is the number of minutes to adjust the time when daylight savings time is inaffect. The offset should be added to the GMT time after adding the GMT offset (refer toGMT Offset).

GMT Offset

This value indicate the number of minutes to adjust the GMT time to get the local time(this is the minutes "west" of the GMT). To get the current local time, simply subtract thisnumber of minutes from the current GMT time.

SYS_CFG_UPNP_RENEWAL

The UPnP renewal value in seconds. The default setting is 1800 seconds (30 min).

SYS_CFG_UserLanguage

This value is used to indicate the default user language.

To determine a particular attribute value on your System Manager, do the following:

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetSystemAttribute method, passing in the following

parameters:Your login ID

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

systemAttribute

The name of the System Manager attribute. Parameter of type pointer to xstring, valueSYS_CFG_TzInfo.

A pointer to the variable that will hold the result.

C++ Example:

int iUpnpRenewal;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetSystemAttribute(loginId, "SYS_CFG_UPNP_RENEWAL", &iUpnpRenewal);

C# Example:

int iUpnpRenewal;int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm.GetSystemAttribute(loginId, "SYS_CFG_UPNP_RENEWAL",ref iUpnpRenewal);

Retrieving a Web Service’s AttributeNOTE: The related source code for this entry can be found in main.cpp’s main function (for C++) or Program.cs’s Main function (for C#), which belongs to the System Manager Wrapper sampleproject.

NOTE: This entry assumes that you have already completed the steps outlined in QueryingAvailable Devices from the System Manager, which provides you with UDNs for Pelco devicesavailable on your network.

1. Initialize the System Manager Wrapper. (Refer to Initializing the System Manager Wrapper for details.)2. Call the System Manager Wrapper’s GetDeviceServiceAttribute method, passing in the following

parameters:Your login ID

Page 116: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

116

This ID is returned after a successful login. (Refer to Initializing the System ManagerWrapper for details.)

The target device’s Unique Device Name (UDN) valueTo retrieve a deviceUDN, cycle through the stored results of a GetDevices call withinyour IDeviceStorage class instance. For details, refer to Querying Available Devicesfrom the System Manager.

The target web service’s IDRefer to Retrieving a Web Service’s ID for details.

The ID of the web service attributeFor example, SYS_UpnpControlUrl or SYS_UpnpEventSubUrl

A pointer to the variable that will store the result.

C++ Example:

PelcoAPI::xstring sCtrlUrl;int loginId = sm.UserLogin("brian", "pelco");bool bSuccess = sm.GetDeviceServiceAttribute(loginId, "urn:schemas-pelco-com:service:MotionDetection:1", "uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpControlUrl", &sCtrlUrl);

C# Example:

String sCtrlUrl = "";int loginId = sm.UserLogin("brian", "pelco");Boolean bSuccess = sm.GetDeviceServiceAttribute(loginId,"urn:schemas-pelco-com:service:MotionDetection:1","uuid:00047D01-4CA5-5370-6563-747261495605", "SYS_UpnpControlUrl",ref sCtrlUrl);

Creating an IDeviceStorage Class

NOTE: The related source code for this entry can be found in the MyStorage.h andMyStorage.cpp files (for C++) or DeviceInformation.cs file (for C#), which belongs to theSystem Manager Wrapper sample project.

What is the IDeviceStorageNet class? An IDeviceStorageNet is simply an interface that parsesXML responses from the System Manager and stores the resulting device data from the XML responseinternally. Users need an implementation of this interface if they want to manage device data using theSystem Manager Wrapper.

1. Ensure that the IDeviceStorageNet class implements the following methods:

• virtual bool AddDevice(const char* sUDN, const char* sAttributes): Thismethod adds a new device to the IDeviceStorageNet class. It takes the following parameters:

• The device’s Unique Device Name (UDN)• The devices’s attributes, given as XML

• virtual bool DeleteDevice(const char* sUDN): This method deletes an existing devicewithin IDeviceStorageNet.

• The device’s Unique Device Name (UDN)• virtual bool UpdateDevice(const char* sUDN, const char* sAttributes)

Page 117: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Discovery

117

The System Manager Wrapper will use these methods every time you call its GetDevices method,which in turn will update your IDeviceStorage instance contents.C++ Example:

#ifndef PELCO_API_IDEVICE_STORAGE_H#define PELCO_API_IDEVICE_STORAGE_H #include <string> namespace PelcoAPI{class IDeviceStorage{public:virtual ~IDeviceStorage(){}; virtual bool AddDevice(const char* sUDN, const char* sXmlAttributes)=0; virtual bool DeleteDevice(const char* sUDN)=0; virtual bool UpdateDevice(const char* sUDN, const char* sXmlAttributes)=0;}; } #endif

C# Example:

using System;using System.Collections.Generic;using System.Text;namespace SystemManagerWrapperNet{class DeviceInformation : PelcoAPI.IDeviceStorageNet{public void AddDevice(string sUDN, string sAttributes){// ... User implemented logic here ...}public void DeleteDevice(string sUDN){// ... User implemented logic here ...}}}

2. Note that the System Manager Wrapper sample project has an implementation of IDeviceStoragecalled MyStorage.MyStorage is a stub class. It does not implement anything that is essential for production usage, suchas parsing the System Manager’s XML response data (attributes). Nor does it associate the deviceUDN/attribute XML pairs into any constructs. Those exercises are left to the user.

Page 118: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Logging

118

Appendix

ALogging

Logging is specific to Endura, and is configurable.

1. To configure logging, run the LoggingSetup application in the C:\Program Files\Pelco\API\Logging folder.

2. Select the items that you want to log, as well as the folder where the logs should be stored and the maxlogfile size.

3. Click Set to save the settings.

NOTE: Logging should be run by an administrative account, because other users do not havewrite permissions to C:\Program Files (x86) or subdirectories by default.

4. To view the current log, run the LoggingSetup application in the C:\Program Files\Pelco\API\Logging folder. Click the View Log File button.

NOTE: The maximum log size is 50MB. Any settings over that value will be reset back tothe default 50MB restriction. Usually, logging should be off (no items checked) unless Pelcotechnical support asks for logging information when tracing issues.

In the Logging dialog box, the following settings are available:

ErrorLogs error messages. This is usually the most important item.

MemoryLogs memory allocation statistics. This should usually be not selected.

Info

Page 119: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Logging

119

The next level of severity below Error.

VerboseLogs actions that occur often and should normally not be logged because they fill up thelogfile quickly.

Page 120: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Product Compatibility

120

Appendix

BProduct Compatibility

The following table shows the compatibility of the Pelco SDK with Pelco products.

Product EventArbiter

EventManager

Exporter Meta-dataParser

PelcoAPIViewer

PTZControlWrapper

SMWrapper

DX 4700 HD /DX 4800HD Video Recorders(functionality will onlywork with DX version thatsupports Pelco API)

Y Y N N Y Y Y

DSSRV (functionality willonly work with DS versionthat supports Pelco API)

Y Y N N Y Y Y

DVR5100 Y Y Y Y Y Y5 Y

Endura Express Y Y6 Y6 Y Y N Y6

IP110 Y Y6 N Y Y N Y6

IP3701 Y Y6 N Y Y N Y6

NET5301R Y Y6 N Y Y N Y6

NET5402R-HD Y Y6 N Y Y N Y6

NET5301T Y Y6 N Y Y Y5 Y6

NET5308T Y Y6 N Y Y Y5 Y6

NET5301T-I Y Y6 N Y Y Y5 Y6

NET5400T-I Y Y6 N Y Y Y5 Y6

NSM5200 Y Y6 Y6 Y Y N Y6

Sarix Y Y6 N Y Y N Y6

Spectra HD 720p Y Y6 N Y Y Y Y6

Spectra HD 1080p Y Y6 N Y Y Y Y6

Spectra IV IP Y Y6 N Y Y Y Y6

Spectra Mini Y Y6 N Y Y Y Y6

Esprit IP Y Y6 N Y Y Y Y6

5 Active only if the attached IP camera is PTZ capable.6 Active only if an active System Manager is available on the network. Endura Express contains a built-in

System Manager, and therefore no additional System Manager is required.

Page 121: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Product Compatibility

121

SM5000 Y Y N Y N N Y

SM5200 Y Y N Y N N Y

Page 122: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Endura

122

Appendix

CEndura

In 2005, Endura provided a distributed architecture that delivered both flexibility and performance. Endurais a complete solution for high definition video encoding, recording, and display. It controls the origination,transport, recording, and display of integrated, security-related audio and video.

From a technical standpoint, what defines an Endura system?

System Manager + Endura Devices = Endura System

System Manager (SM)

First and foremost, an Endura system must have a System Manager (SM). The SM is the heart of Endura.It is responsible for the following:

• Managing devices such as cameras, decoders, and NVRs, including administering rights and privileges• Storing device information, like status• Administering users, which includes permissions management• Logging errors and alarms• Security key management

Endura Devices

Endura devices can be defined as IP cameras, encoders, decoders, NVRs, or even work stations. EachEndura device, including the SM itself, has an Application Programming Interface (API). An API is simply aspecified way for software clients to programmatically communicate with Endura devices, allowing accessto their functionality. All Endura devices provide an API through a set of related web services. These webservices adhere to the SOAP standard. (For more details on SOAP, please refer to the following http://en.wikipedia.org/wiki/SOAP.) It is beyond the scope of this documentation to fully describe all Endura webservices. For details, such as the SOAP web service API reference, please refer to the Pelco DeveloperNetwork (PDN) at http://pdn.pelco.com.

One of the main purposes of a System Manager is to provide a central place to retrieve information on allEndura devices. How does the System Manager collect all of this information?

Page 123: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Endura

123

1. The System Manager constantly provides a broadcast of its location on the Endura Network. Once adevice comes on line, it will listen for this broadcast. When the new device finds the SM, it will thenregister itself to the System Manager.

2. At some point the System Manager will query the device’s available web services and its attributes,using a variety of sources including the UPnP Device Description File (DDF). DDFs are files containingdevice attributes in XML format.

3. After the initial query, the System Manager will periodically update the device’s status. To be consideredon line, a device must constantly notify the SM that it is still ‘alive’.

4. At any point a client can make requests to the System Manager regarding devices, including the SMitself, and their web services.

Endura Events and Alarms

There are two major ways to subscribe to Endura web service events:

• Directly contacting the device on which the target web service resides• Using the System Manager as an intermediary to perform actual eventing related work

On later versions of Endura network deployments, the first option is the default. Users can enable theSystem Manager to act as an intermediary by enabling its EventArbiter web service (not to be confusedwith the Event Arbiter Library). The EventArbiter web service is used for receiving GENA events fromdevices within an Endura network. The Event Arbiter provides two ways for subscribing to events:

• Through control URLs• By subscribing to events with event URIs provided

Page 124: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Endura

124

Figure 1: Subscribing to Events through Control URLs

Figure 2: Subscribing to Events with Event URIs Provided

The URI is provided by the user through the System Manager's EventArbiter service.

What is the advantage of using the System Manager as an intermediary for Endura events? The SystemManager can help manage all event related network traffic, ensuring that an Endura network never getsoverwhelmed by eventing network traffic.

Page 125: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Endura

125

Video Exports

Currently the Exporter library requires a System Manager to be present to function. How does it work?The Exporter client sends its request for video clips to export with a timestamp range filter to the SystemManager; that is, it wants clips that fall within a starting date time and an ending date time. The SystemManager will then query all available NSMs for clips that meet both the starting timestamp and the endingtimestamp. Specifically, there can be instances where the API must ‘stitch’ the end result from more thanone NSM source of video clips to meet the filter.

Where Does the Pelco API SDK Fit Within Endura?

The Pelco API SDK is meant to make using Endura web services easier by providing conveniencemethods and utilities. It protects the user from all of the potentially overwhelming and complicated detailsof Endura SOAP web services. Of course users are still free to directly use Endura web services. HoweverPelco has found that many of our customers enjoy the convenience and ease of use that the Pelco APISDK provides.

Page 126: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | General Event Messages

126

Appendix

DGeneral Event Messages

LoggableEvent

This defines the general structure of logged data for events. It does not have a set of enclosing tags. Forfurther details, refer to the event message descriptions below.

<element name="deviceUdn" type="xs:int"/><element name="deviceUrn" type="xs:string"/><element name="serviceUrn" type="xs:string"/><element name="logId" type="xs:int"/><element name="major" type="xs:int"/><element name="minor" type="xs:int"/><element name="type" type="xs:int"/><element name="reason" type="xs:int"/><element name="parameters" type="tns:LoggableEventParameters"/>

deviceUdn

The unique device name. For example: uuid:AK-2

deviceUrn

The device's resource name. For example: urn:schemas-pelco-com:device:Pelco:1

serviceUrn

The service's resource name.

logId

The log item's unique identifier.

major

A major issue identifier.

minor

A minor issue identifier.

type

A event type identifier.

reason

An identifier that represents the cause of the event.

parameters

A LoggableEventParameters data type.

Page 127: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | General Event Messages

127

LoggableEventParameters

This contains a list of LoggableEventParameter data types. For further details, refer to the eventmessage descriptions below.

<complexType name="LoggableEventParameters"> <sequence> <element minOccurs="0" maxOccurs="unbounded" name="parameter" type="tns:LoggableEventParameter"/> </sequence></complexType>

parameter

A LoggableEventParameter data type.

LoggableEventParameter

This represents an event-related parameter. For further details, refer to the event message descriptionsbelow.

<complexType name="LoggableEventParameter"><sequence><element name="paramId" type="xs:int"/><element name="name" type="xs:string"/><element name="value" type="xs:int"/><element name="type" type="xs:int"/></sequence></complexType>

paramId

The parameter's unique identifier.

name

The parameter's name.

value

The parameter's value.

type

The parameter's type identifier.

Page 128: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

128

Appendix

EHardware Diagnostics Event Messages

ConfigurationButton (20180)This event triggers if the front panel configuration button has failed.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="ConfigurationButton"><sequence><element name="objGuid" type="xs:string" fixed="394af82c-2b05-4df8-b2a6-2caed9ad4fae"/><element name="objId" type="xs:int" fixed="20180"/><element name="current" type="xs:int"/><element name="previous" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to 394af82c-2b05-4df8-b2a6-2caed9ad4fae

objIdThe event's unique database identifier. The value must be 20180

currentThe current state of the button. Possible values are1 for BUTTON_CONFIGThe button is in "Configuration mode".

2 for BUTTON_REBOOTThe button is in "Reboot system".

3 for BUTTON_RESETThe button is in "Reset configuration".

4 for BUTTON_NORMALThe button currently does not have a state.

previousThe previous state of the button. For possible values, refer to current.

<pdDiagnostic> <objGuid>394af82c-2b05-4df8-b2a6-2caed9ad4fae</objGuid> <objId>20180</objId> <current>1</current>

Page 129: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

129

<previous>3</previous> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>4</type> <reason>1</reason> <parameters></parameters>

DriverFailure (20150)A DriverFailure PdDiagnostic object is only sent when a device's driver fails, so aLoggableEvent object is used to set the correct major, minor, type, and reason. This is typically used formultichannel encoder (MCE) devices.

PdDiagnostic

This is the data that subscribers receive when the event triggers.

<complexType name="DriverFailurePdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="94b6d2d3-c68e-4b13-974a-08f69f50cb67"/><element name="objId" type="xs:int" fixed="20150"/><element name="name" type="xs:string"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to 94b6d2d3-c68e-4b13-974a-08f69f50cb67

objIdThe event's unique database identifier. The value must be 20150

nameThe name of the device driver

<complexType name="DriverFailurePdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="94b6d2d3-c68e-4b13-974a-08f69f50cb67"/><element name="objId" type="xs:int" fixed="20150"/><element name="name" type="xs:string"/></sequence></complexType>

Page 130: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

130

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>5</type> <reason>1</reason> <parameters></parameters>

Fans (20020)Any device with any fans having a changed state will have a LoggableEvent fired.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="FanPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="31e41907-53be-4f57-8ae2-a56c12d98d0e"/><element name="objId" type="xs:int" fixed="20050"/><element name="states" type="tns:FanStates"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to31e41907-53be-4f57-8ae2-a56c12d98d0e

objIdThe event's unique database identifier. The value must be 20050

statesA FanStates data type.

FanStates

This contains list of one or more FanState data types.

<complexType name="FanStates"><sequence><element name="state" maxOccurs="unbounded" minOccurs="1" type="tns:FanState"/></sequence></complexType>

stateA FanState data type.

Page 131: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

131

FanState

This represents the current and previous condition of a fan.

<complexType name="FanState"><sequence><element name="cur" type="xs:int"/><element name="prev" type="xs:int"/></sequence></complexType>

curThe current state identifier. Possible values are the following:1 for FAN_OKThe fan is operating normally.

2 for FAN_FAILEDThe fan has failed.

3 for FAN_UNKNOWNThe state of the fan is currently unknown; this fan does not have an initial state registered.NOTE: This will always be the final stream state.

prevThe previous state identifier. This has the same possible values as cur.

<pdDiagnostic> <objGuid>31e41907-53be-4f57-8ae2-a56c12d98d0e</objGuid> <objId>20220</objId> <states> <state> <cur>1</cur> <prev>0</prev> </state> <state> <cur>0</cur> <prev>0</prev> </state> <state> <cur>0</cur> <prev>0</prev> </state> </states> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>5</type> <reason>1</reason> <parameters></parameters>

Page 132: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

132

HardDrives (20060)For each CPdDiagHarddrives object, you can send loggable events for hard drives that have a statechange. Set the state of the hard drive to the appropriate major, minor, type, and reason.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="HardDrivesPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="31e41907-53be-4f57-8ae2-a56c12d98d0e"/><element name="objId" type="xs:int" fixed="20060"/><element name="states" type="tns:HardDrivesStates"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to31e41907-53be-4f57-8ae2-a56c12d98d0e

objIdThe event's unique database identifier. The value must be 20060

statesA HardDrivesStates data type.

HardDrivesStates

This contains a list of one or more HardDrivesState data types.

<complexType name="HardDrivesStates"><sequence><element name="state" maxOccurs="unbounded" minOccurs="1" type="tns:HardDrivesState"/></sequence></complexType>

stateA HardDrivesState data type.

HardDrivesState

This represents the current and previous condition of a hard drive.

<complexType name="HardDrivesState"><sequence><element name="cur" type="xs:int"/><element name="prev" type="xs:int"/></sequence></complexType>

curThe current state identifier. Possible values are the following:1 for HDS_READYIndicates that the hard disk is currently in use.

Page 133: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

133

NOTE: This could indicate a problem if the disk is known to be currently NOTin use.

2 for HDS_ONLINEIndicates that a disk is on line and currently being used.

3 for HDS_FAILEDIndicates that a disk has failed.

4 for HDS_HOTSPAREIndicates that a disk is currently being used as a 'hot spare' within the array.

5 for HDS_REBUILDIndicates that a disk is currently being rebuilt.

6 for HDS_NONEShows that there is currently no hard drive connected, and there is room for a hard drive.

7 for HDS_UNKNOWNThe hard drive's state is currently unknown; this typically means that the hard drive has yetto register any state.

NOTE: This will always be the final stream state.

prevThe previous state identifier. This has the same possible values as cur.

<pdDiagnostic> <objGuid>8dda89bd-3c2c-4a35-aad4-1256cb5e1d27</objGuid> <objId>20060</objId> <states> <state> <cur>1</cur> <prev>2</prev> </state> <state> <cur>1</cur> <prev>1</prev> </state> <state> <cur>1</cur> <prev>1</prev> </state> </states> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn><deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn><serviceUrn></serviceUrn><logId></logId><major>7</major><minor>0</minor><type>9</type><reason>1</reason><parameters><param><paramId>6</paramId>

Page 134: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

134

<name>HardDriveId</name><value>0</value><type>1</type></param></parameters>

ImproperShutdown (20070)A ImproperShutdownPdDiagnostic object is sent when an improper shutdown occurs, so a LoggableEventobject can be initialized with the appropriate major, minor, type, and reason data.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="ImproperShutdownPdDiagnostic"><sequence> <element name="objGuid" type="xs:string" fixed="a44945e0-fa54-4fb0-a614-2e71886c508f"/><element name="objId" type="xs:int" fixed="20070"/><element name="mode" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to a44945e0-fa54-4fb0-a614-2e71886c508f

objIdThe event's unique database identifier. The value must be 20070

modeThe mode of the shutdown.

<pdDiagnostic> <objGuid>a44945e0-fa54-4fb0-a614-2e71886c508f</objGuid> <objId>20070</objId> <mode>4</mode> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>4</type> <reason>4</reason> <parameters></parameters>

Page 135: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

135

LinkSpeed (20200)This event triggers when the link speed changes. We then set the correct major, minor, type, and reasonfor LoggableEvent. The current LinkSpeed is sent as a parameter with the LoggableEvent object.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="LinkSpeedPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="b9359885-711a-4d71-b908-4bdf8753dbe8"/><element name="objId" type="xs:int" fixed="20200"/><element name="min" type="xs:int"/><element name="cur" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set tob9359885-711a-4d71-b908-4bdf8753dbe8

objIdThe device's unique database identifier. The value must be 20200

minThe minimum link speed. For example: 100

curThe current state. For example: 10

<pdDiagnostic> <objGuid>b9359885-711a-4d71-b908-4bdf8753dbe8</objGuid> <objId>20200</objId> <min>100</min> <cur>10</cur> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>6</type> <reason>0</reason> <parameters> <param> <paramId>5</paramId> <name>CurrentLinkSpeed</name> <value>10</value> <type>1</type> </param> </parameters>

Page 136: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

136

PowerSupply (20120)A PowerSupplyPdDiagnostic object is sent when a power supply encounters a problem so that aLoggableEvent object can be initialized with the appropriate major, minor, type, and reason data.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="PowerSupplyPdDiagnostic"><sequence> <element name="objGuid" type="xs:string" fixed="26f051aa-009b-4a5d-ab20-09b064a07a52"/><element name="objId" type="xs:int" fixed="20120"/><element name="inAlarm" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be: 26f051aa-009b-4a5d-ab20-09b064a07a52

objIdThe device's unique database identifier. The value must be: 20200

inAlarmThis represents whether or not a device is in a problem state. Possible values are0

The power supply is operating properly; not in an alarm state.

1

Problems with the power supply; in alarm state.

<pdDiagnostic> <objGuid>26f051aa-009b-4a5d-ab20-09b064a07a52</objGuid> <objId>20120</objId> <inAlarm></inAlarm> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>2</type> <reason>0</reason> <parameters></parameters>

UPS (20170)This event triggers if a UPS either fails or runs out of power.

Page 137: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Hardware Diagnostics Event Messages

137

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="UPSPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="e746c2c8-0b97-402e-abc3-c784890c8d99"/><element name="objId" type="xs:int" fixed="20170"/><element name="cur" type="xs:int"/><element name="pre" type="xs:int"/><element name="rem" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be e746c2c8-0b97-402e-abc3-c784890c8d99

objIdThe event's unique database identifier. The value must be 20170

curThe current state identifier. For example: 4

preThe previous state identifier. For example: 1

<pdDiagnostic> <objGuid>e746c2c8-0b97-402e-abc3-c784890c8d99</objGuid> <objId>20170</objId> <Cur>4</Cur> <Pre>1</Pre> <Rem>0</Rem> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>24</type> <reason>0</reason> <parameters> <param> <paramId>4</paramId> <name>TimeRemaining</name> <value>0</value> <type>1</type> </param> </parameters>

Page 138: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

138

Appendix

FSoftware Diagnostics Event Messages

DataLoss 20040When this is triggered by a data loss, set the correct major, minor, type, reason for the LoggableEvent.

PdDiagnostic

This is the data that subscribers will receive when the event triggers.

<complexType name="DataLossPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="94b6d2d3-c68e-4b13-974a-08f69f50cb67"/><element name="objId" type="xs:int" fixed="20040"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to 94b6d2d3-c68e-4b13-974a-08f69f50cb67

objIdThe event's unique database identifier. The value must be: 20040

<complexType name="DataLossPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="94b6d2d3-c68e-4b13-974a-08f69f50cb67"/><element name="objId" type="xs:int" fixed="20040"/></sequence></complexType>

LoggableEvent object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>8</type> <reason>0</reason> <parameters></parameters>

Page 139: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

139

InputStreams 20160For each stream entry that has its state changed from previous state, we send out a loggable event withappropriate major, minor, type and reason.

<complexType name="InputStreams"><sequence><element name="objGuid" type="xs:string" fixed="31e41907-53be-4f57-8ae2-a56c12d98d0e"/><element name="objId" type="xs:int" fixed="20160"/><element name="states" type="tns:InputStreamsEntries"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be set to31e41907-53be-4f57-8ae2-a56c12d98d0e

objIdThe event's unique database identifier. The value must be: 20160

entriesAn InputStreamsEntries data type.

<pdDiagnostic><objId>20160</objId><context>uuid:a58172d6-a22e-45b1-a67a-9a84515c3fa0</context> <entries> <entry> <id>uuid:a58172d6-a22e-45b1-a67a-9a84515c3fa0</id> <mediaType>0</mediaType> <hardwareId>1</hardwareId> <channelId>1</channelId> <stateCur>4</stateCur> <statePrev>2</statePrev> </entry> </entries> </pdDiagnostic>

InputStreamsEntries

A list of InputStreamsEntry data types.

<pdDiagnostic><objId>20160</objId><context>uuid:a58172d6-a22e-45b1-a67a-9a84515c3fa0</context> <entries> <entry> <id>uuid:a58172d6-a22e-45b1-a67a-9a84515c3fa0</id> <mediaType>0</mediaType> <hardwareId>1</hardwareId> <channelId>1</channelId> <stateCur>4</stateCur> <statePrev>2</statePrev> </entry> </entries> </pdDiagnostic>

entry

Page 140: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

140

An InputStreamsEntry data type.

InputStreamsEntry

<complexType name="InputStreamsEntry"><sequence><element name="id" type="xs:string"/><element name="mediaType" type="xs:int"/><element name="hardwareId" type="xs:string"/><element name="stateCur" type="xs:int"/><element name="statePrev" type="xs:int"/></sequence></complexType>

idThe entry's unique identifier, for example: 2

mediaType

A media type identifier, for example: 0

hardwareIdA hardware identifier, for example: hwidv1

stateCurThe current state identifier. Possible values are1 for ISS_RECORDINGCurrently recieving a stream and it is being recorded.

2 for ISS_RECORD_ERRORCurrently receiving a stream, but it is unable to be recorded due to an error.

3 for ISS_RECEIVINGCurrently recieving a stream.

4 for ISS_RECEIVE_ERRORUnable to receive a stream.

5 for ISS_MISSINGExpecting a stream but there is no available stream. In analog inputs, this means thedevice is unable to detect a connection.

6 for ISS_UNKNOWNThe state of the stream is currently unknown; this stream does not have an initial stateregistered.

NOTE: This will always be the final stream state.

statePrevThe previous state identifier. Refer to stateCur for possible valid values.

PacketLoss 20080This event is fired when there is data loss during video data writing. Sets the appropriate major, minor,type, and reason in Loggable Event.

Page 141: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

141

PdDiagnostic

This is the data that subscribers will receive when the event triggers.

<complexType name="PacketLossPdDiagnostic"> <sequence> <element name="objGuid" type="xs:string" fixed="ddfa09d6-64f1-4b39-a7e7-de0c5f7780cc"/> <element name="objId" type="xs:int" fixed="20080"/> <element name="max" type="xs:float"/> <element name="cur" type="xs:float"/> </sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be: ddfa09d6-64f1-4b39-a7e7-de0c5f7780cc

objIdThe event's unique database identifier. The value must be: 20080

maxThe maximum acceptable packet loss percentage, for example: 1.1235

curThe current packet loss percentage, for example: 5.1235

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>11</type> <reason>0</reason> <parameters> <param> <paramId>3</paramId> <name>PercentageOfCurrentPacketLoss</name> <value>5.1235</value> <type>0</type> </param> </parameters>

SEBs 20210For each PdDiagSebs object, loggable events are sent only when the state of a particular SEB changes.Set the state of the SEB to the appropriate major, minor, type, and reason.

PdDiagnostic

This is the data subscribers will receive when the event triggers.

<complexType name="SEBsPdDiagnostic"><sequence>

Page 142: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

142

<element name="objGuid" type="xs:string" fixed="31e41907-53be-4f57-8ae2-a56c12d98d0e"/><element name="objId" type="xs:int" fixed="20210"/><element name="entries" type="tns:SEBSEntries"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be:31e41907-53be-4f57-8ae2-a56c12d98d0e

objIdThe event's unique database identifier. The value must be: 20210

entriesAn SEBsEntries data type.

SEBsEntries

A list of SEBsEntry data types.

<complexType name="SEBsEntries"><sequence><element name="entry" maxOccurs="unbounded" minOccurs="1" type="tns:SEBsEntry"/></sequence></complexType>

entryAn SEBsEntry data type.

SEBsEntry

<complexType name="SEBsEntry"><sequence><element name="stateCur" type="xs:int"/><element name="statePrev" type="xs:int"/></sequence><attribute name="id" type="xs:string" fixed="US"/></complexType>

stateCurThe current state identifier.

statePrevThe previous state identifier. Refer to stateCur for valid possible values.

id(Attribute) The entry's identifier [string].

<pdDiagnostic><objGuid>2e9f0d2e-adf3-453b-aabc-a0223a604040</objGuid><objId>20210</objId><entries><entry id="hello0"><stateCur>0</stateCur><statePrev>0</statePrev></entry><entry id="hello1"><stateCur>0</stateCur>

Page 143: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

143

<statePrev>0</statePrev></entry><entry id="hello2"><stateCur>0</stateCur><statePrev>0</statePrev></entry><entry id="hello5"></entry></entries></pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>9</type> <reason>2</reason> <parameters> <param> <paramId>7</paramId> <name>SEBId</name> <value>hello4</value> <type>0</type> </param> </parameters>

StorageFull 20190When this event triggers from a device with fully used storage, the appropriate major, minor, type, andreason is set in the Loggable event.

PdDiagnostic

This is the data that subscribers receive when the event triggers.

<complexType name="StorageFullPdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="94b6d2d3-c68e-4b13-974a-08f69f50cb67"/><element name="objId" type="xs:int" fixed="20190"/><element name="inAlarm" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be: 94b6d2d3-c68e-4b13-974a-08f69f50cb67

objIdThe event's unique database identifier. The value must be: 20190

inAlarmThis represents whether or not a device is in a problem state. Possible values are0for storage is not full

Page 144: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

144

Not in an alarm state.

1 for full storageIn an alarm state.

<pdDiagnostic> <objGuid>3df223ee-8041-4c1a-be77-2d140e5588aa</objGuid> <objId>20190</objId> <inAlarm></inAlarm> </pdDiagnostic>

LoggableEvent Object

For more details, refer to DataLoss 20040 LoggableEvent above.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>13</type> <reason>0</reason>

StorageTime 20130This event is fired if the NVR/DVR is unable to achieve the user-configured video storage time.

PdDiagnostic

This is the data that subscribers will receive when the event triggers.

<complexType name="StorageTimePdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="e08fa1d1-9b30-4e62-bc8b-16cca0f57cb0"/><element name="objId" type="xs:int" fixed="20130"/><element name="min" type="xs:int"/><element name="cur" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be: e08fa1d1-9b30-4e62-bc8b-16cca0f57cb0

objIdThe event's unique database identifier. The value must be: 20130

minThe minimum number of hours of storage time allowed.

curThe current number of hours of storage time available.

<pdDiagnostic> <objGuid>e08fa1d1-9b30-4e62-bc8b-16cca0f57cb0</objGuid> <objId>20130</objId> <min>5</min>

Page 145: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

145

<cur>4</cur> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>12</type> <reason>0</reason> <parameters> <param> <paramId>8</paramId> <name>CurrentStorageTime</name> <value>4</value> <type>1</type> </param> </parameters>

Temperature 20140A Temperature PdDiagnostic object is triggered when temperature goes beyond specific range. Thecurrent range is set between 10° to 50° Celsius. This verifies if the current temperature is below minimumor above maximum threshold, and then determines whether to send Loggable Events, with reason setto either LOW or HIGH accordingly.

PdDiagnostic

This is the data that subscribers will receive when the event triggers.

<complexType name="TemperaturePdDiagnostic"><sequence><element name="objGuid" type="xs:string" fixed="26f051aa-009b-4a5d-ab20-09b064a07a52"/><element name="objId" type="xs:int" fixed="20140"/><element name="min" type="xs:int"/><element name="max" type="xs:int"/><element name="cur" type="xs:int"/></sequence></complexType>

objGuidThe event's Universally Unique Identifier. The value must be: 26f051aa-009b-4a5d-ab20-09b064a07a52

objIdThe event's unique database identifier. The value must be: 20140

minThe minimum allowable temperature.

maxThe maximum allowable temperature.

Page 146: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Software Diagnostics Event Messages

146

curThe current temperature.

<pdDiagnostic> <objGuid>7448f68a-de77-4ea9-b000-65b63bf54bd5</objGuid> <objId>20140</objId> <min>10</min> <max>20</max> <cur>5</cur> </pdDiagnostic>

LoggableEvent Object

For more details, refer to LoggableEvent.

<deviceUdn>uuid:AK-2</deviceUdn> <deviceUrn>urn:schemas-pelco-com:device:Pelco:1</deviceUrn> <serviceUrn></serviceUrn> <logId></logId> <major>7</major> <minor>0</minor> <type>3</type> <reason>0</reason> <parameters> <param> <paramId>1</paramId> <name>CurrentTemperature</name> <value>5</value> <type>1</type> </param> </parameters>

Page 147: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

147

Appendix

GVideo Streaming and Exporting Performance

This section shows the maximum number of supported streams for video streaming and video exportingoperations using the Pelco SDK.

Video streaming and exporting performance testing was conducted on two separate computers.

• One computer met the minimum hardware and network requirements shown in the Endura NetworkingGuide; this is called the 'minimum specification computer'.

• The second computer exceeded the requirements; this computer is called the 'high-end computer'.

Both sets of test results are presented in this section for comparison. Because there are many hardwareconfigurations, conclusions should not be drawn about the performance of any particular computer.

The following describes the specifications of both the minimum specification computer and the high-endcomputer that were subjected to the testing.

Table 13: Specifications of test computers

Minimum specification computer High-end computer

OperatingSystem

Windows Server 2008 R2 64-bit Windows XP SP3 32-bit

CPU 2.4 GHz Intel Core 2 Duo 2.8 GHz Intel Xeon (Quad Core)

RAM 2 GB 3 GB

HDD SATA HDD SATA HDD

Graphicscard

nVidia Quadro FX 550 PCI Express-128 MB nVidia Quadro FX 580 PCI Express-512 MB

• Video streaming and video exporting are CPU intensive operations, and were tested using variousscenarios.

• Event monitoring and normal operations of the Pelco SDK are not CPU intensive and were notmeasured.

• For the results shown in the following tables, each computer used no more than 60% of the availableCPU capacity. This allows for other processes executing concurrently during the test operations.

• Additional processes, especially CPU and GPU intensive processes, can decrease the performance ofthe Pelco SDK applications.

NOTE:

• The test video streams were 30 IPS.• Scene depicted is of medium complexity (the scene contained some motion).

Page 148: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Video Streaming and Exporting Performance

148

Maximum Number of Concurrent Video Streams (Minimum Specification Computer)

The maximum number of concurrent video streams supported by a computer with the minimumspecifications are shown in the following table.

Stream Transport

Stream Type RTP Live RTP Playback RTSP Live RTSP Playback

MPEG-4, 1SIF(352x240)

10 10 11 4

MPEG-4, 4SIF(704x480)

3 5 4 4

H.264, 1SIF(352x240)

4 10 8 4

H.264, 4SIF(704x480)

3 5 3 3

H.264, 720P(1280x720)

1 1 1 1

H.264, 1080P(1920x1080)

1 1 1 1

Maximum Number of Concurrent Video Streams (High-End Computer)

The maximum number of streams supported by a high-end computer that exceeds the minimumspecifications are shown in the following table.

Stream Transport

Stream Type RTP Live RTP Playback RTSP Live RTSP Playback

MPEG-4, 1SIF(352x240)

32 32 16 21

MPEG-4, 4SIF(704x480)

32 22 10 10

H.264, 1SIF(352x240)

32 20 12 12

H.264, 4SIF(704x480)

32 20 6 6

H.264, 720P(1280x720)

20 7 3 3

H.264, 1080P(1920x1080)

3 4 3 2

Maximum Number of Concurrent Export Streams

The exported video streams were 30 minutes in duration for single streams and 15 minutes for dual-stitched streams. The streams were PEF format, 30 IPS, and depicted a scene of medium complexity(contained some motion).

Maximum Number of Export Streams From a Minimum Specification Computer

The maximum number of concurrent export streams supported by a computer with the minimumspecifications are shown in the following table.

Page 149: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Video Streaming and Exporting Performance

149

Export Type

Stream Type Single Export (nooverlays)

Single Export(overlays)

Two-Clip Export(stitched, overlays)

MPEG-4, 1SIF(352x240)

6 1 1

MPEG-4, 4SIF(704x480)

9 1 1

H.264, 1SIF (352x240) 5 1 1

H.264, 4SIF (704x480) 6 1 1

H.264, 720P (1280x720) 8 1 1

H.264, 1080P(1920x1080)

10 1 1

Maximum Number of Export Streams From a High-End Computer

The maximum number of export streams supported by a high-end computer that exceeds the minimumspecifications are shown in the following table.

Export Type

Stream Type Single Export (overlays) Two-Clip Export (stitched,overlays)

MPEG-4, 1SIF (352x240) 4 5

MPEG-4, 4SIF (704x480) 3 4

H.264, 1SIF (352x240) 4 2

H.264, 4SIF (704x480) 3 2

H.264, 720P (1280x720) 2 1

H.264, 1080P (1920x1080) 2 1

Page 150: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

150

Appendix

HGlossary

ActiveX®

ActiveX® ActiveX® is an integration platform that provides developers, users, and Web producers a fast andeasy way to create integrated programs and content for Microsoft based Internet and Intranet software. Formore information, refer to http://support.microsoft.com/kb/154544

Advertisement (UPnP)In a UPnP network, advertisement is the act of one device presenting its services for another device touse. In Endura, the UPnP advertisement startup and renew intervals are set from the System Configurationtab of the Setup window.

AlarmIn video security: An alarm occurs when a camera detects motion or there is a change in a physical alarminput, such as a door opening or closing.

In card access: This is a condition caused by a system event or action to raise awareness to security staff.

Alarm relayThe alarm relay is the relay used to output an alarm condition based on a specific system or eventmessage criteria.

AutofocusAutofocus is the ability of the lens to remain in focus during zoom-in, zoom-out, and motion functions.

bitAbbreviation for binary digit; the smallest unit of information a computer can use. A bit is either a 1 or a 0 (ahigh or low voltage state).

bit rateBit rate is the number of bits that are transferred between devices in a specified amount of time, typicallyone second.

Page 151: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

151

BrightnessIn NTSC and PAL video signals, the brightness information at any particular instant in a picture isconveyed by the corresponding instantaneous DC level of active video. Brightness control should beadjusted so that the black picture content displays as true black on your monitor.

bpsBits per second. This is a bit rate measurement.

BpsBytes per second. Also abbreviated as B/s.

BroadcastIn an IP network environment, broadcast refers to sending information from one device to every deviceon the network. When broadcasting, it is not possible to control or specify which devices can receive thisinformation.

byteA byte is a string of bits processed as a unit by a digital computer. A byte is equal to eight bits (256possibilities) and is large enough to hold one character (like an “A”) or an unsigned integer from 0 to 255.

Camera groupIn an Endura system, a camera group is a collection of cameras associated with each other as part of thesetup process. Camera groups can be used in filtering cameras displayed in the Nav window, as well asthose selected for schedules, scripts, or permissions.

CoaxitronCoaxitron is the Pelco protocol that uses “up-the-coax” technology. Commands to control pan/tilt devicesare transmitted during the vertical blanking interval of the video signal. Instead of separate wiring forcontrol commands and video, Coaxitron uses the coaxial cable for both video and control.

Standard: This earlier technology uses 15 bits to send a command.

Extended: This later technology uses 32 bits to send a command.

codeccodec is an acronym for compression/decompression. This term is commonly used in the context ofmultimedia compression and decompression, such as video or audio.

Common Intermediate Format (CIF)A standard video and digital image size. Also refer to SIF.

Page 152: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

152

CIF: 352 x 288 for PAL

2CIF: 704 x 288 for PAL

4CIF: 704 x 480 for PAL

QCIF: 176 x 144 for PAL

CompressionCompression is any algorithm used to reduce the size of a file.

ContrastContrast is a common term used in reference to the difference between the darkest and the brightest partsof an image. Once brightness is set correctly, contrast should be set for comfortable viewing brightness.

D1D1 is a digital video format developed by Society of Motion Picture and Television Engineers (SMPTE).The D1 format resolution is 720 × 480 for NTSC and 720 × 576 for PAL.

DecoderIn an Endura system, the decoder is a high-performance video device that converts digital video streamsback into analog output for viewing on an analog video monitor, S-video monitor, or VGA monitor.

DecodingDecoding is the opposite of encoding: decompressing a compressed digital image and then turning it backinto an analog signal.

DeviceA device is a piece of hardware (camera, alarm, DVR, NVR, storage expansion box) that is part of anetwork.

Device IDA device ID is a unique identifier for an individual device on a network.

EncoderIn an Endura system, the encoder is a high-performance MPEG-4 device that takes analog video signalsthrough a standard BNC coaxial cable and digitizes, compresses, signs, and packetizes them for thenetwork. It also provides an interface for relays, alarms, and audio connections.

Page 153: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

153

EncodingEncoding is the process of taking an analog signal and converting it to a digital format (A to D conversion).Compression is applied at this point in the process.

FirmwareFirmware is a process or program that is embedded in a hardware platform that instructs the hardware unithow to behave and what action to perform.

FocusFocus means to adjust a lens to allow objects at various distances from the camera to be sharply defined.

Frame rateThe frame rate is the number of frames or images that are captured, stored, projected, or displayed persecond.

GammaGamma is the correction of the linear response of a camera to compensate for the nonlinear responseof a monitor’s phosphor screen. It is measured with the exponential value of the curve describing thenonlinearity. A typical monochrome monitor gamma is 2.2, and a camera needs to be set to the inversevalue of 2.2 (which is 0.45) for the overall system to respond linearly (that is, unity).

H.264Developed by the ITU-T Video Coding Experts Group (VCEG), H.264 is a low-bit-rate compressed videoformat standard.

HueHue is one of the characteristics that distinguishes one color from another. Hue defines color on the basisof its position in the spectrum, that is, whether red, blue, green or yellow, and so forth. Hue is one of thethree characteristics of television color; the other two are saturation and luminance. In NTSC and PALvideo signals, the hue information at any particular point in the picture is conveyed by the correspondinginstantaneous phase of the active video subcarrier.

I-frameIn a compressed digital image, I-frames (intraframes) are the frames that are compressed independently ofthe other frames in the sequence.

IPInternet Protocol. IP is the main method of transmitting data across the Internet.

Page 154: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

154

IP address(static and DHCP) The IP address identifies a particular computer on a network to other computers. AnIP address is similar to your home address. In a neighborhood, each house has a unique address; on anetwork each computer must have a unique address. An IP address is a four-byte number, usually writtenin dotted-decimal notation with periods separating the bytes (for example, 192.168.0.100). There are twotypes of IP addresses: static and DCHP. A static address is assigned when someone physically connectsto a computer and defines the IP address for that computer. A static address does not change unlesssomeone physically changes it. A DHCP (Dynamic Host Configuration Protocol) address is assigneddynamically from a server that contains a pool of addresses. The server leases the computer one of theavailable addresses for a specified amount of time. Once the time has expired, the computer renews thelease or requests a new IP address.

IP cameraAn IP camera is a digital video camera that outputs IP packets over Ethernet cabling. An IP camera canuse TCP protocol, as well as UDP or RTP.

IP headerAn IP packet can be divided into two main parts: the payload and the header. The header is the part of thepacket that contains the routing information, and is is comprised of many parts. The header contains all IPand MAC addressing information. The header is the only part of the packet that a router examines whentrying to determine where to send a packet.

IrisThe iris is a means of controlling the size of a lens aperture and therefore the amount of light passingthrough the lens.

marshallingMarshalling is synonymous with serialization.

MPEG-4Developed by Moving Picture Experts Group (MPEG), MPEG-4 expands the MPEG-1 specification tosupport AV ‘objects’, 3D content, low bit-rate encoding, and Digital Right Management (DRM).

MulticastA single device sends information across a network and that stream is received by all listening devices onthe network. A special IP address range has been reserved for this purpose: 224.0.0.1-239.255.255.255with a sub-net mask of 255.255.0.0. Each multicast transmitting device sends a data stream to an addressfrom the above range. Any device on the network can then listen for transmissions to that IP address andreceive the stream. Multicast offers a reduction of bandwidth consumption over the unicast and broadcastdelivery methods. Multicast also offers control over which devices on a network can receive a multicaststream. In an Endura system, only Endura devices can receive Endura multicast streams. Multicast trafficis not routable across the Internet without a specially reserved address or encapsulation.

Page 155: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

155

Multicast serverA multicast server is any server that takes a unicast transmission on behalf of a client and converts it to amulticast transmission on the network.

NamespaceNamespace is an identifier that denotes a group of names. It is used to prevent resource identifier conflicts.

Network Time Protocol (NTP)NTP is a protocol designed to synchronize the clocks of computers over a network. On systems that havean NTP server, you can use the WS5050 to configure the NTP settings (NTP server IP and renew interval).By default, time and date information is included with video streams and other device data. The softwarerelies on the PC system clock for other needed time information.

National Television System Committee (NTSC)NTSC developed the U.S. color TV specifications. It specifies 525 lines/screen. It also specifies 59.94fields per second, although most people refer to this frame rate as 30 frames per second. NTSC nowdescribes the American system of color telecasting. It is used in North America, Japan, and some parts ofSouth America.

Network Storage Manager (NSM)A combination of high performance, scalable hardware and advanced software for managing pooledstorage of recorded video and audio streams.

Phase Alternation by Line (PAL)PAL is the European (50 Hz) color TV standard. It is used by most countries outside the US. It specifies625 lines/screen, and 25 frames per second.

ParityParity is a method of checking the accuracy of data to identify whether the bits being moved arrivedsuccessfully. Parity bit checking can be based on odd or even bits. No parity means that a parity bit is nottransmitted or checked.

P-frameIn a compressed digital image, a P-frame (predicted frame) is a frame calculated based on the changefrom one frame to the next. An area of the display that does not change from one frame to the next doesnot need to be contained in the P-frame. If an area of the display does not change but does move on thescreen, then only the vector describing this movement is contained in the P-frame. This allows a reductionin overall file size.

Page 156: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

156

PINPersonal Identification Number. PIN is used to provide security in a system.

Power over Ethernet (PoE)PoE enables both power and video to transmit on a single cable.

ProtocolProtocol is a set of rules governing the transmission of data between equipment:

D Pelco protocol that uses seven bytes to send a command.

M Pelco protocol for communicating with M devices (KBD960/KBR960 keyboards, ALM2064 alarminterface units, and REL2064 relay interface units).

P Pelco protocol that uses a variable number of bytes to send a command. Eight bytes are used to sendcommands to dome systems.

Relay groupA relay group is a defined set of relays acting in a coordinated pattern.

Remote Procedure Calls (RPCs)RPC is a protocol that allows a computer program running on one host to cause code to be run on anotherhost.

Real-time Transport Protocol (RTP)A protocol that uses a standardized packet format for delivering data over networks.

Real Time Streaming Protocol (RTSP)A protocol for streaming data, which allows clients to remotely control the server streaming the data.

SaturationSaturation is the intensity of the colors in the active picture: the degree by which the eye perceives a coloras departing from a gray or white scale of the same brightness. A 100% saturated color does not containany white; adding white reduces saturation. In NTSC and PAL video signals, the color saturation at anyparticular instant in the picture is conveyed by the corresponding instantaneous amplitude of the activevideo subcarrier.

SequenceTo view a group of cameras, one after the other, either manually or automatically.

Page 157: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

157

ServerA server is a computer and its software that provides some service for other computers connected to itthrough a network.

ServiceService is the ability of a device within the Endura system to perform such functions as pan/tilt/zoom,record video, and playback video. When a device comes online, these services are automaticallyadvertised to other devices on the network. For a user to access these services, the user must be assigneda role with the proper permissions.

SharpnessSharpness refers to a function that allows a user to adjust the image between a “soft” look and a sharplook.

SIFSource Input Format. Resolution depends on the source: NTSC SIF equals 352 x 240 pixels. Also refer toCIF.

System Manager (SM)A piece of software that authenticates devices on the Endura network. This software runs on an EnduraDVR or NVR or as a standalone device.

TCP/IP connectionTransmission Control Protocol/Internet Protocol. TCP/IP is the standard way of communicating over anetwork that ensures all devices on a network can communicate and information is passed without anyerrors.

UDNUniversal Device Number.

UDPUser Data-gram Protocol is a connectionless protocol that, like TCP, runs on top of IP networks. UnlikeTCP/IP, UDP/IP provides very few error recovery services, offering instead a direct way to send andreceive data-grams over an IP network. It is used primarily for broadcasting messages over a network.

UIDUniversal Identification Number.

Page 158: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

Pelco SDK | Glossary

158

UnicastThe standard method to transport IP traffic. In a unicast transmission, information is sent from onecomputer directly to another computer on the network.

UPnPUPnP is a family of networking protocols used to create a “hands off” network. In a Universal Plug and Playnetwork, objects are plugged into a network and automatically recognized and configured. All IP addressesin a UPnP network are assigned dynamically through DHCP. If DHCP becomes unavailable in a UPnPnetwork, devices will default to Auto IP. Endura devices use the UPnP process when plugged into anEndura network.

Uniform Resource Identifier (URI)URI is used to identify a resource over a network.

Uniform Resource Name (URN)A URN identifies, or more specifically, names a resource within a namespace.

VarifocalVarifocal refers to a lens with a variable focal length. Varifocal lenses are low cost zoom lenses that can beadjusted (zoomed) over a range of focal lengths. These lenses are much lower in cost than normal zoomlenses because they have fewer elements in them.

Disadvantage: Unlike a zoom lens, a varifocal lens does not maintain focus when zoomed. It is practicalonly for use with cameras where the zoom is set once at installation.

Advantage: The installer can adjust a varifocal lens for optimum field of view without changing the lens.

WSDLWeb Services Description Languages (WSDLs).

Page 159: Pelco SDK 3.2 PROGRAMMINGpdn.pelco.com/sites/default/files/docs/PelcoSDK_C5617M-E.pdfPelco SDK | Introduction 8 Pelco SDK Components The following table shows the major Pelco SDK components.

3500 Pelco WayClovis, California 93612-5699United StatesUSA & Canada Tel (800) 289-9100International Tel +1 (559) 292-1981www.pelco.com Pelco, the Pelco logo, and other trademarks associated with Pelco products referred to in this publication are trademarks of Pelco, Inc. or its affiliates.All other product names and services are the property of their respective companies.Product specifications and availability are subject to change without notice. © 2013 Schneider Electric. All Rights Reserved.