GIFT-Grab  1708
Copyright (c) 2015-7, University College London (UCL)
gg::VideoSourceFactory Class Reference

This class implements the factory design pattern for creating connections to supported video sources. More...

#include <videosourcefactory.h>

Public Member Functions

virtual ~VideoSourceFactory ()
 Free all connected devices. More...
 
IVideoSourceget_device (enum Device device, enum ColourSpace colour)
 Try to connect to specified device for capturing video with specified colour space. More...
 
void free_device (enum Device device)
 Close connection to specified device, if existing. More...
 
IVideoSourceconnect_network_source (std::string address, enum ColourSpace colour)
 Open connection to network connection specified by given address. More...
 
IVideoSourcecreate_file_reader (const std::string filepath, enum ColourSpace colour_space)
 Create a reader to read colour_space frames format from filepath. More...
 

Static Public Member Functions

static VideoSourceFactoryget_instance ()
 Get reference to singleton instance of this class. More...
 

Protected Member Functions

 VideoSourceFactory ()
 The constructor should never be publicly called. More...
 
 DISALLOW_COPY_AND_ASSIGNMENT (VideoSourceFactory)
 

Protected Attributes

IVideoSource_devices [Device::COUNT]
 So that can keep track of everything opened and in use. More...
 
ColourSpace _device_colours [Device::COUNT]
 At a single point in time, only one connection using only one colour space may exist. More...
 

Detailed Description

This class implements the factory design pattern for creating connections to supported video sources.

It ensures no duplicate connection is created to any one supported video source, and in addition takes care of properly garbage-collecting all video source connections created during the lifetime of the singleton factory.

See also
IVideoSource
Device

Constructor & Destructor Documentation

§ VideoSourceFactory()

gg::VideoSourceFactory::VideoSourceFactory ( )
protected

The constructor should never be publicly called.

See also
get_instance

§ ~VideoSourceFactory()

gg::VideoSourceFactory::~VideoSourceFactory ( )
virtual

Free all connected devices.

See also
free_device

Member Function Documentation

§ connect_network_source()

IVideoSource * gg::VideoSourceFactory::connect_network_source ( std::string  address,
enum ColourSpace  colour 
)

Open connection to network connection specified by given address.

Parameters
address
colour
Returns
pointer to the created video source. The ownership of this object passes to the caller. So the caller is responsible for garbage-collecting it.
Exceptions
NetworkSourceUnavailableif no connection can be established
VideoSourceErrorif GIFT-Grab not built with options required for the passed device and colour combination OR if there was a problem constructing the requested video source

§ create_file_reader()

IVideoSource * gg::VideoSourceFactory::create_file_reader ( const std::string  filepath,
enum ColourSpace  colour_space 
)

Create a reader to read colour_space frames format from filepath.

Parameters
filepathAttempting to open an already open video file leads to undefined behaviour. However once the returned video source used for reading the file is destroyed, it can be re-opened.
colour_space
Returns
a polymorphic video file reader. The ownership of this returned object passes to the caller. The reader behaves like other video sources as far the callback paradigm (observer pattern) is concerned. Calling the get_frame method on this object leads to undefined behaviour, and hence should be avoided. The reader keeps sending out data with all pixels black after all video frames in the opened file are exhausted.
Exceptions
VideoSourceErrorwith a detailed error message if opening of filepath fails for any reason

§ DISALLOW_COPY_AND_ASSIGNMENT()

gg::VideoSourceFactory::DISALLOW_COPY_AND_ASSIGNMENT ( VideoSourceFactory  )
protected

§ free_device()

void gg::VideoSourceFactory::free_device ( enum Device  device)

Close connection to specified device, if existing.

Parameters
device
Exceptions
DeviceNotFoundif type not recognised
See also
get_device the IVideoSource object get_device returns will be destroyed by this, and hence the previously returned pointer will become unusable

§ get_device()

IVideoSource * gg::VideoSourceFactory::get_device ( enum Device  device,
enum ColourSpace  colour 
)

Try to connect to specified device for capturing video with specified colour space.

Note that the availability of capturing video with specified colour space depends on the custom build options selected. Cf. documentation (README file) for details.

Parameters
device
colour
Returns
pointer to the device's framegrabber. Client should not delete this pointer on its own. The factory will take care of properly garbage-collecting this at the end of the factory singleton's lifetime.
Exceptions
DeviceAlreadyConnectedif device already connected (i.e. using another colour space)
DeviceNotFoundif connection attempt fails
DeviceOfflineif connection attempt OK, but device offline (i.e. getting no frames)
See also
free_device if the intention is to connect to device with another colour than the one device is currently connected to
Exceptions
VideoSourceErrorif GIFT-Grab not built with options required for the passed device and colour combination OR if there was a problem constructing the requested video source

§ get_instance()

VideoSourceFactory & gg::VideoSourceFactory::get_instance ( )
static

Get reference to singleton instance of this class.

Returns

Member Data Documentation

§ _device_colours

ColourSpace gg::VideoSourceFactory::_device_colours[Device::COUNT]
protected

At a single point in time, only one connection using only one colour space may exist.

§ _devices

IVideoSource* gg::VideoSourceFactory::_devices[Device::COUNT]
protected

So that can keep track of everything opened and in use.

See also
Device the length of this pointer array is to be kept in sync with the number of devices supported

The documentation for this class was generated from the following files: