Ocean
Ocean::Media::LiveVideo Class Reference

This class is the base class for all live videos. More...

Inheritance diagram for Ocean::Media::LiveVideo:

Data Structures

class  StreamConfiguration
 This class holds the relevant information describing a video stream configuration. More...
 

Public Types

enum  ControlMode : uint32_t { CM_INVALID = 0u , CM_FIXED , CM_DYNAMIC }
 Definition of individual control modes. More...
 
enum  StreamType : uint32_t { ST_INVALID = 0u , ST_FRAME , ST_MJPEG , ST_CODEC }
 Definition of individual stream types. More...
 
enum  CodecType : uint32_t { CT_INVALID = 0u , CT_H264 , CT_H265 }
 Definition of individual codec types. More...
 
using StreamTypes = std::vector< StreamType >
 Definition of a vector holding stream types. More...
 
using StreamConfigurations = std::vector< StreamConfiguration >
 Definition of a vector holding stream configurations. More...
 
- Public Types inherited from Ocean::Media::FrameMedium
typedef double FrameFrequency
 Definition of a frame frequency defined in Hz. More...
 
typedef std::function< void(const Frame &frame, const SharedAnyCamera &camera)> FrameCallbackFunction
 Definition of a callback function for frame events. More...
 
typedef ScopedSubscriptionHandler::ScopedSubscriptionType FrameCallbackScopedSubscription
 Definition of a subscription object for frame callback events. More...
 
- Public Types inherited from Ocean::Media::Medium
enum  Type : uint32_t {
  MEDIUM = 0u , FRAME_MEDIUM = 1u << 0u , SOUND_MEDIUM = 1u << 1u , FINITE_MEDIUM = 1u << 2u ,
  LIVE_MEDIUM = 1u << 3u , CONFIG_MEDIUM = 1u << 4u , AUDIO = (1u << 5u) | FINITE_MEDIUM | SOUND_MEDIUM , IMAGE = (1u << 6u) | FRAME_MEDIUM ,
  PIXEL_IMAGE = (1u << 7u) | FRAME_MEDIUM , BUFFER_IMAGE = (1u << 8u) | FRAME_MEDIUM , IMAGE_SEQUENCE = (1u << 9u) | FRAME_MEDIUM | FINITE_MEDIUM , LIVE_AUDIO = (1u << 10u) | LIVE_MEDIUM | SOUND_MEDIUM ,
  LIVE_VIDEO = (1u << 11u) | LIVE_MEDIUM | FRAME_MEDIUM , MICROPHONE = (1u << 12u) | LIVE_MEDIUM , MOVIE = (1u << 13u) | FINITE_MEDIUM | FRAME_MEDIUM | SOUND_MEDIUM
}
 Definition of different medium types. More...
 
- Public Types inherited from Ocean::Media::ConfigMedium
typedef std::vector< std::string > ConfigNames
 Definition of a vector holding configuration names. More...
 

Public Member Functions

virtual StreamTypes supportedStreamTypes () const
 Returns the supported stream types. More...
 
virtual StreamConfigurations supportedStreamConfigurations (const StreamType streamType=ST_INVALID) const
 Returns the supported stream configurations for a given stream type. More...
 
virtual double exposureDuration (double *minDuration=nullptr, double *maxDuration=nullptr, ControlMode *exposureMode=nullptr) const
 Returns the current exposure duration of this device. More...
 
virtual float iso (float *minISO=nullptr, float *maxISO=nullptr, ControlMode *isoMode=nullptr) const
 Returns the current ISO of this device. More...
 
virtual float focus (ControlMode *focusMode=nullptr) const
 Returns the current focus of this device. More...
 
virtual bool setPreferredStreamType (const StreamType streamType)
 Sets the preferred stream type. More...
 
virtual bool setPreferredStreamConfiguration (const StreamConfiguration &streamConfiguration)
 Sets the preferred stream configuration. More...
 
virtual bool setExposureDuration (const double duration)
 Sets the exposure duration of this device. More...
 
virtual bool setISO (const float iso)
 Sets the ISO of this device. More...
 
virtual bool setFocus (const float position)
 Sets the focus of this device. More...
 
- Public Member Functions inherited from Ocean::Media::FrameMedium
 ~FrameMedium () override
 Destructs a frame object. More...
 
bool hasFrame () const
 Returns whether the object holds a frame. More...
 
FrameFrequency frameFrequency () const
 Returns the frequency of the frame in Hz. More...
 
virtual FrameRef frame (SharedAnyCamera *anyCamera=nullptr) const
 Returns the most recent frame. More...
 
virtual FrameRef frame (const Timestamp timestamp, SharedAnyCamera *anyCamera=nullptr) const
 Returns the frame with a specific timestamp. More...
 
virtual FrameRef frameTimeout (const double timeout, SharedAnyCamera *anyCamera=nullptr) const
 Waits until the first frame is available. More...
 
virtual bool hasFrame (const Timestamp timestamp) const
 Returns whether this media object currently holds a frame with specified timestamp. More...
 
unsigned int preferredFrameWidth () const
 Returns the preferred width of the frame in pixel. More...
 
unsigned int preferredFrameHeight () const
 Returns the preferred height of the frame in pixel. More...
 
FrameType::PixelFormat preferredFramePixelFormat () const
 Returns the preferred frame pixel format. More...
 
FrameFrequency preferredFrameFrequency () const
 Returns the preferred frame frequency in Hz. More...
 
virtual HomogenousMatrixD4 device_T_camera () const
 Returns the transformation between the camera and device. More...
 
virtual bool setPreferredFrameDimension (const unsigned int width, const unsigned int height)
 Sets the preferred frame dimension. More...
 
virtual bool setPreferredFramePixelFormat (const FrameType::PixelFormat format)
 Sets the preferred frame pixel format. More...
 
virtual bool setPreferredFrameFrequency (const FrameFrequency frequency)
 Sets the preferred frame frequency in Hz. More...
 
size_t capacity () const
 Returns the capacity of the frame history of this frame medium object. More...
 
bool setCapacity (const size_t capacity)
 Sets or changes the capacity of the frame history of this frame medium object. More...
 
FrameCallbackScopedSubscription addFrameCallback (FrameCallbackFunction &&frameCallbackFunction)
 Adds a callback function which is called whenever a new frame arrives. More...
 
- Public Member Functions inherited from Ocean::Media::Medium
const std::string & url () const
 Returns the url of the medium. More...
 
bool isValid () const
 Returns whether the medium is valid. More...
 
const std::string & library () const
 Returns the name of the owner library. More...
 
Type type () const
 Returns the type of the medium. More...
 
bool isType (const Type type) const
 Returns whether a medium has a given type. More...
 
virtual bool isStarted () const =0
 Returns whether the medium is started currently. More...
 
bool isExclusive () const
 Returns whether this medium can be use exclusively. More...
 
virtual bool start ()=0
 Starts the medium. More...
 
virtual bool pause ()=0
 Pauses the medium. More...
 
virtual bool stop ()=0
 Stops the medium. More...
 
virtual Timestamp startTimestamp () const =0
 Returns the start timestamp. More...
 
virtual Timestamp pauseTimestamp () const =0
 Returns the pause timestamp. More...
 
virtual Timestamp stopTimestamp () const =0
 Returns the stop timestamp. More...
 
virtual MediumRef clone () const
 Clones this medium and returns a new independent instance of this medium. More...
 
- Public Member Functions inherited from Ocean::Media::ConfigMedium
virtual bool configuration (const std::string &name, long long data)
 Starts a configuration possibility. More...
 
virtual ConfigNames configs () const
 Returns the names of the configuration possibilities. More...
 

Static Public Member Functions

static std::string translateControlMode (const ControlMode controlMode)
 Translates a control mode to a string. More...
 
static std::string translateStreamType (const StreamType streamType)
 Translates a stream type to a string. More...
 
static std::string translateCodecType (const CodecType codecType)
 Translates a codec type to a string. More...
 
- Static Public Member Functions inherited from Ocean::Media::FrameMedium
static bool syncedFrames (const FrameMediumRefs &frameMediums, const Timestamp lastTimestamp, FrameRefs &frames, SharedAnyCameras &cameras, const unsigned int waitTime=2u, bool *timedOut=nullptr, HomogenousMatricesD4 *device_T_cameras=nullptr)
 Extracts most recent frames from several frame medium objects and ensures that the timestamps of all frames are identical. More...
 
- Static Public Member Functions inherited from Ocean::Media::Medium
static std::string convertType (const Type type)
 Converts a medium type to a unique string. More...
 
static Type convertType (const std::string &type)
 Converts a medium type string to a medium type. More...
 

Protected Member Functions

 LiveVideo (const std::string &url)
 Creates a new live video source by a given url. More...
 
- Protected Member Functions inherited from Ocean::Media::FrameMedium
 FrameMedium (const std::string &url)
 Creates a new frame medium by a given url. More...
 
virtual bool deliverNewFrame (Frame &&frame, SharedAnyCamera &&anyCamera=SharedAnyCamera())
 Delivers a new frame to this FrameMedium. More...
 
- Protected Member Functions inherited from Ocean::Media::Medium
 Medium (const Medium &medium)=delete
 Disabled copy constructor. More...
 
 Medium (const std::string &url)
 Creates a new medium by a given url. More...
 
virtual ~Medium ()
 Destructs a medium. More...
 
Mediumoperator= (const Medium &medium)=delete
 Disabled copy operator. More...
 
- Protected Member Functions inherited from Ocean::Media::LiveMedium
 LiveMedium (const std::string &url)
 Creates a new live medium by a given url. More...
 
- Protected Member Functions inherited from Ocean::Media::ConfigMedium
 ConfigMedium (const std::string &url)
 Creates a new ConfigMedium object by a given url. More...
 

Additional Inherited Members

- Protected Types inherited from Ocean::Media::FrameMedium
typedef ScopedSubscriptionCallbackHandlerT< FrameCallbackFunction, FrameMedium, true > FrameCallbackHandler
 Definition of a thread-safe subscription handler for frame callback functions. More...
 
typedef std::vector< MediaFrameTypeFrameTypes
 Definition of a vector holding frame types. More...
 
- Protected Attributes inherited from Ocean::Media::FrameMedium
FrameCollection frameCollection_
 Frame collection storing several frames with different timestamps. More...
 
FrameCallbackHandler frameCallbackHandler_
 The handler for frame callback functions. More...
 
FrameFrequency recentFrameFrequency_ = FrameFrequency(0)
 Frame frequency. More...
 
MediaFrameType preferredFrameType_
 Preferred frame type of the medium. More...
 
- Protected Attributes inherited from Ocean::Media::Medium
std::string url_
 Url of the medium. More...
 
std::string libraryName_
 Name of the owner library. More...
 
bool isValid_ = false
 Determines whether the medium is valid. More...
 
Type type_ = MEDIUM
 Type of the medium. More...
 
Lock lock_
 Medium lock. More...
 

Detailed Description

This class is the base class for all live videos.

Member Typedef Documentation

◆ StreamConfigurations

Definition of a vector holding stream configurations.

◆ StreamTypes

Definition of a vector holding stream types.

Member Enumeration Documentation

◆ CodecType

Definition of individual codec types.

Enumerator
CT_INVALID 

An invalid codec type.

CT_H264 

Codec using H.264 for encoding or decoding.

CT_H265 

Codec using H.265 for encoding or decoding.

◆ ControlMode

Definition of individual control modes.

The modes are used for exposure, ISO, and focus.

Enumerator
CM_INVALID 

An invalid control mode.

CM_FIXED 

The control is fixed (e.g., because the exposure, ISO, or focus was set manually).

CM_DYNAMIC 

The control is dynamic (e.g., because auto exposure, ISO, or focus is enabled).

◆ StreamType

Definition of individual stream types.

Enumerator
ST_INVALID 

An invalid stream type.

ST_FRAME 

A stream composed of individual uncompressed frames with individual pixel formats (e.g., FORMAT_RGB24, FORMAT_YUYV16, etc.).

ST_MJPEG 

A stream composed of Motion JPEG frames.

ST_CODEC 

A stream composed of compressed frames with individual codecs (e.g., H264, H265).

Constructor & Destructor Documentation

◆ LiveVideo()

Ocean::Media::LiveVideo::LiveVideo ( const std::string &  url)
explicitprotected

Creates a new live video source by a given url.

Parameters
urlUrl of the live video source

Member Function Documentation

◆ exposureDuration()

virtual double Ocean::Media::LiveVideo::exposureDuration ( double *  minDuration = nullptr,
double *  maxDuration = nullptr,
ControlMode exposureMode = nullptr 
) const
virtual

Returns the current exposure duration of this device.

Parameters
minDurationOptional resulting minimal duration to set, in seconds, with range (0, infinity), -1 if unknown
maxDurationOptional resulting maximal duration to set, in seconds, with range [minDuration, infinity), -1 if unknown
exposureModeOptional resulting exposure mode, nullptr if not of interest
Returns
The duration in seconds, with range [minDuration, maxDuration], -1 if unknown
See also
setExposureDuration().

Reimplemented in Ocean::Media::USB::USBLiveVideo, Ocean::Media::AVFoundation::AVFLiveVideo, and Ocean::Media::Android::ALiveVideo.

◆ focus()

virtual float Ocean::Media::LiveVideo::focus ( ControlMode focusMode = nullptr) const
virtual

Returns the current focus of this device.

Returns
The device's focus, with range [0, 1] with 0 shortest distance and 1 furthest distance
Parameters
focusModeOptional resulting focus mode, nullptr if not of interest

Reimplemented in Ocean::Media::USB::USBLiveVideo, Ocean::Media::AVFoundation::AVFLiveVideo, and Ocean::Media::Android::ALiveVideo.

◆ iso()

virtual float Ocean::Media::LiveVideo::iso ( float *  minISO = nullptr,
float *  maxISO = nullptr,
ControlMode isoMode = nullptr 
) const
virtual

Returns the current ISO of this device.

Parameters
minISOOptional resulting minimal ISO to set, with range (0, infinity), -1 if unknown
maxISOOptional resulting maximal ISO to set, with range (0, infinity), -1 if unknown
isoModeOptional resulting ISO mode, nullptr if not of interest
Returns
The current ISO, with range [minISO, maxISO], -1 if unknown

Reimplemented in Ocean::Media::AVFoundation::AVFLiveVideo, and Ocean::Media::Android::ALiveVideo.

◆ setExposureDuration()

virtual bool Ocean::Media::LiveVideo::setExposureDuration ( const double  duration)
virtual

Sets the exposure duration of this device.

Parameters
durationThe exposure duration to be set, in seconds, with range (0, infinity), 0 for auto exposure, -1 for a one-time auto exposure
Returns
True, if succeeded
See also
exposureDuration().

Reimplemented in Ocean::Media::USB::USBLiveVideo, Ocean::Media::AVFoundation::AVFLiveVideo, and Ocean::Media::Android::ALiveVideo.

◆ setFocus()

virtual bool Ocean::Media::LiveVideo::setFocus ( const float  position)
virtual

Sets the focus of this device.

Parameters
positionThe focus position to be set, with range [0, 1] with 0 shortest distance and 1 furthest distance, -1 for auto focus
Returns
True, if succeeded
See also
focus().

Reimplemented in Ocean::Media::USB::USBLiveVideo, Ocean::Media::AVFoundation::AVFLiveVideo, and Ocean::Media::Android::ALiveVideo.

◆ setISO()

virtual bool Ocean::Media::LiveVideo::setISO ( const float  iso)
virtual

Sets the ISO of this device.

Parameters
isoThe ISO to be set, with range (0, infinity), -1 for auto ISO
Returns
True, if succeeded
See also
iso().

Reimplemented in Ocean::Media::AVFoundation::AVFLiveVideo, and Ocean::Media::Android::ALiveVideo.

◆ setPreferredStreamConfiguration()

virtual bool Ocean::Media::LiveVideo::setPreferredStreamConfiguration ( const StreamConfiguration streamConfiguration)
virtual

Sets the preferred stream configuration.

Using this function will forward some settings to the underlying FrameMedium object via setPreferredFrameDimension(), setPreferredFramePixelFormat(), and setPreferredFrameFrequency(). There is no guarantee that the device will use this stream type.

Parameters
streamConfigurationThe preferred stream configuration to be set, must be valid
Returns
True, if succeeded
See also
setPreferredStreamType(), FrameMedium::setPreferredFrameDimension(), FrameMedium::setPreferredFramePixelFormat(), and FrameMedium::setPreferredFrameFrequency()

Reimplemented in Ocean::Media::USB::USBLiveVideo.

◆ setPreferredStreamType()

virtual bool Ocean::Media::LiveVideo::setPreferredStreamType ( const StreamType  streamType)
virtual

Sets the preferred stream type.

There is no guarantee that the device will use this stream type.

Parameters
streamTypeThe preferred stream type to be set, must be valid
Returns
True, if succeeded
See also
setPreferredStreamConfiguration().

Reimplemented in Ocean::Media::USB::USBLiveVideo.

◆ supportedStreamConfigurations()

virtual StreamConfigurations Ocean::Media::LiveVideo::supportedStreamConfigurations ( const StreamType  streamType = ST_INVALID) const
virtual

Returns the supported stream configurations for a given stream type.

Parameters
streamTypeThe type of the stream for which the supported stream configurations will be returned, ST_INVALID to return all stream configurations for all stream types
Returns
The supported stream configurations

Reimplemented in Ocean::Media::USB::USBLiveVideo, and Ocean::Media::MediaFoundation::MFLiveVideo.

◆ supportedStreamTypes()

virtual StreamTypes Ocean::Media::LiveVideo::supportedStreamTypes ( ) const
virtual

Returns the supported stream types.

Returns
The types of all supported streams, empty if this object does not allow (or does not need) to select the stream type.

Reimplemented in Ocean::Media::USB::USBLiveVideo, and Ocean::Media::MediaFoundation::MFLiveVideo.

◆ translateCodecType()

static std::string Ocean::Media::LiveVideo::translateCodecType ( const CodecType  codecType)
static

Translates a codec type to a string.

Parameters
codecTypeThe stream type to be translated
Returns
The translated string, 'Invalid' if the codec type is invalid or unknown

◆ translateControlMode()

static std::string Ocean::Media::LiveVideo::translateControlMode ( const ControlMode  controlMode)
static

Translates a control mode to a string.

Parameters
controlModeThe control mode to translate
Returns
The translated string, 'Invalid' if the control mode is invalid or unknown

◆ translateStreamType()

static std::string Ocean::Media::LiveVideo::translateStreamType ( const StreamType  streamType)
static

Translates a stream type to a string.

Parameters
streamTypeThe stream type to be translated
Returns
The translated string, 'Invalid' if the stream type is invalid or unknown

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