Pelco Developer Network (PDN)

Exporting from a Pelco Aggregation System

Pelco Aggregation allows Endura customers to monitor multiple Endura installation sites via a common user interface. Pelco Aggregation supports a number of monitoring tasks, including the exporting of video. Exporting video from a Pelco Aggregation system can also be accomplished from within an Integration application using the Exporter object in the Pelco SDK. Figure 1 shows the topology for a hypothetical Pelco Aggregation system.
Figure 1. Pelco Aggregation system topology.
 If you need to export from a standalone Endura system you should use the Exporter component in the SDK. The Exporter component is discussed in the SDK Programming Guide, and on PDN.
This is the sequence for exporting from an aggregation system:
  1. Create a System instance that references an existing aggregation system.
  2. Query the system for available devices.
  3. Select a device (camera).
  4. Create a clip from the camera.
  5. Create an Exporter instance that references the clip.
  6. Export the clip.
The Exporter object only works with Pelco Aggregation at this time. To obtain the list of cameras and other devices, treat the Aggregation system as an Endura system and request the device list. Locate the first camera in the list.
PelcoSDK::System system( PelcoSDK::PString( 
  "admin:admin@pelcosystem://" ) );

PelcoSDK::DeviceCollection collection = system.GetDeviceCollection();


PelcoSDK::Device device = NULL;

bool found = false;

while ( collection.MoveNext() && found == false )
    device = collection.Current();

    // CAMERA is defined in DeviceTypeGeneric.h
    if ( device.GetDeviceType() == PelcoSDK::CAMERA )
        found = true;
If a camera was found, generate a fifteen second clip. Use the PTime class to specify the time range. The final parameter to the Clip constructor is a boolean indicating whether audio should be included in the clip.
if ( found == true )
    PelcoSDK::Camera camera = device;

    // Request time one hour ago, of 15 second duration.
    time_t tempStartTime = PelcoSDK::PTime::Now().GetUnixTime() - 3600;

    PelcoSDK::PTime startTime( tempStartTime );

    PelcoSDK::PTime endTime( tempStartTime + 15 );

    PelcoSDK::Clip clip = PelcoSDK::Clip( camera, startTime, endTime, false );

    PelcoSDK::Exporter exporter( PelcoSDK::PString( "c:\\" ), clip );

If you follow the reference chain in the SDK header files, the sequence makes sense: Exporter knows about a Clip, which knows about a Camera, which knows about the System to which it belongs. The System object performs the actual export of the video. The status of the export displays in the console, as shown in Figure 2.
Figure 2. Export status.
In Figure 3 the exported clip is playing in VLC.
Figure 3. Exported clip.
 The schema type pelcoaggregationdirect only returns a list containing one device of type CONTROLLER. This device cannot be used as a camera or system or other type of device.

PelcoSDK::System system( PelcoSDK::PString( 
  "admin:admin@pelcoaggregationdirect://" ) );

printf( "Type: %d\t", system.GetDeviceCollection().GetItem( 0 ).GetDeviceType() );

results in:

    Type: 6

This is not a camera!



PTime is a SDK class that accepts both time_t and Windows SYSTEMTIME formats. Although you cannot create a new PTime instance using an ISO-formatted string, you can retrieve the string representation using the ToISOExtString() method. See Figure 4.
PelcoSDK::PString timeString = startTime.ToISOExtString();

printf( “Start time is %s\n”, timeString.c_str() );
Figure 4. PTime ISO string output.
When using PTime in a project, remember to include the _USE_32BIT_TIME_T Preprocessor definition, as shown in Figure 5.
Figure 5. Preprocessor definition required for PTime.
Using the techniques outlined here your application can easily export video from a Pelco Aggregation system.

For More Information…

The links below provide additional information regarding Pelco Aggregation and exporting video using the Pelco SDK.