libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TestPatternNode Class Reference

Source node that generates video and audio test patterns. More...

#include <testpatternnode.h>

Inheritance diagram for TestPatternNode:
Collaboration diagram for TestPatternNode:

Public Types

enum  Pattern {
  ColorBars , ColorBars75 , Ramp , Grid ,
  Crosshatch , Checkerboard , SolidColor , White ,
  Black , Noise , ZonePlate
}
 Video test pattern type. More...
 
enum  AudioMode { Tone , Silence , LTC }
 Audio generation mode. More...
 
- Public Types inherited from MediaNode
enum  State { Idle , Configured , Running , ErrorState }
 Node lifecycle state. More...
 
enum  ThreadingPolicy { UseGraphPool , DedicatedThread , CustomPool }
 Threading policy for this node. More...
 
- Public Types inherited from ObjectBase
using SlotVariantFunc = std::function< void(const VariantList &)>
 Function type for invoking a slot with a list of Variants.
 

Public Member Functions

 TestPatternNode (ObjectBase *parent=nullptr)
 Constructs a TestPatternNode.
 
virtual ~TestPatternNode ()
 Destructor.
 
void setPattern (Pattern p)
 Sets the video test pattern.
 
Pattern pattern () const
 Returns the current pattern.
 
void setVideoDesc (const VideoDesc &desc)
 Sets the video description (frame rate, resolution, pixel format).
 
const VideoDescvideoDesc () const
 Returns the video description.
 
void setSolidColor (uint16_t r, uint16_t g, uint16_t b)
 Sets the solid color for SolidColor pattern.
 
void setMotion (double speed)
 Sets the pattern motion speed.
 
double motion () const
 Returns the motion speed.
 
TimecodeGeneratortimecodeGenerator ()
 Returns a mutable reference to the internal timecode generator.
 
const TimecodeGeneratortimecodeGenerator () const
 Returns a const reference to the internal timecode generator.
 
void setStartTimecode (const Timecode &tc)
 Sets the starting timecode.
 
void setDropFrame (bool df)
 Enables or disables drop-frame timecode.
 
Timecode currentTimecode () const
 Returns the current timecode value.
 
uint64_t frameCount () const
 Returns the total number of frames generated.
 
void setAudioDesc (const AudioDesc &desc)
 Sets the audio description.
 
const AudioDescaudioDesc () const
 Returns the audio description.
 
void setAudioEnabled (bool enable)
 Enables or disables audio generation.
 
bool audioEnabled () const
 Returns true if audio generation is enabled.
 
void setAudioMode (AudioMode mode)
 Sets the audio generation mode.
 
AudioMode audioMode () const
 Returns the current audio mode.
 
void setChannelConfig (size_t chan, AudioGen::Config config)
 Sets per-channel audio configuration (Tone mode).
 
void setToneFrequency (double hz)
 Sets all channels to a sine tone at the given frequency.
 
void setToneAmplitude (double amplitude)
 Sets the amplitude for all tone channels.
 
void setLtcLevel (float level)
 Sets the LTC output amplitude.
 
void setLtcChannel (int chan)
 Sets which channel carries LTC.
 
Error configure () override
 Validates ports and allocates resources.
 
Error start () override
 Begins processing.
 
void process () override
 Processes one cycle of data.
 
void stop () override
 Stops processing.
 
Map< String, VariantextendedStats () const override
 Returns additional node-specific statistics.
 
- Public Member Functions inherited from MediaNode
 MediaNode (ObjectBase *parent=nullptr)
 Constructs a MediaNode.
 
virtual ~MediaNode ()
 Virtual destructor.
 
State state () const
 Returns the current state.
 
const Stringname () const
 Returns the node name.
 
void setName (const String &name)
 Sets the node name.
 
const MediaPort::PtrListinputPorts () const
 Returns the list of input ports.
 
const MediaPort::PtrListoutputPorts () const
 Returns the list of output ports.
 
MediaPort::Ptr inputPort (int index) const
 Returns the input port at the given index.
 
MediaPort::Ptr outputPort (int index) const
 Returns the output port at the given index.
 
MediaPort::Ptr inputPort (const String &name) const
 Returns the input port with the given name.
 
MediaPort::Ptr outputPort (const String &name) const
 Returns the output port with the given name.
 
int inputPortCount () const
 Returns the number of input ports.
 
int outputPortCount () const
 Returns the number of output ports.
 
void setThreadingPolicy (ThreadingPolicy policy)
 Sets the threading policy.
 
void setThreadingPolicy (ThreadPool *pool)
 Sets a custom thread pool and switches policy to CustomPool.
 
ThreadingPolicy threadingPolicy () const
 Returns the current threading policy.
 
ThreadPoolcustomThreadPool () const
 Returns the custom thread pool, or nullptr if not using CustomPool.
 
void setIdealQueueSize (int size)
 Sets the ideal input queue depth.
 
int idealQueueSize () const
 Returns the ideal input queue size.
 
int queuedFrameCount () const
 Returns the current input queue depth.
 
virtual void starvation ()
 Called when the node's input queue is empty and data is needed.
 
virtual Map< String, Variantproperties () const
 Returns all configurable properties as key-value pairs.
 
virtual Error setProperty (const String &name, const Variant &value)
 Sets a property by name.
 
Variant property (const String &name) const
 Gets a single property value by name.
 
NodeStats stats () const
 Returns a snapshot of the node's performance statistics.
 
void resetStats ()
 Resets all statistics counters to zero.
 
 PROMEKI_SIGNAL (stateChanged, State)
 Emitted when the node's state changes.
 
 PROMEKI_SIGNAL (errorOccurred, Error)
 Emitted when an error occurs.
 
 PROMEKI_SIGNAL (messageEmitted, NodeMessage)
 Emitted when the node produces a message.
 
- Public Member Functions inherited from ObjectBase
 ObjectBase (ObjectBase *p=nullptr)
 Default ObjectBase constructor.
 
virtual ~ObjectBase ()
 Destructor. Emits aboutToDestroy, detaches from parent, and destroys children.
 
ObjectBaseparent () const
 Returns the parent object, if one. nullptr if none.
 
void setParent (ObjectBase *p)
 Sets the parent of this object. If the object already has a parent, it will be removed as a child from the old parent and added as a child to the new one.
 
const ObjectBaseListchildList () const
 Returns a list of children of this object.
 
template<typename... Args>
int registerSlot (Slot< Args... > *slot)
 Registers a slot with this object and assigns it an ID.
 
EventLoopeventLoop () const
 Returns the EventLoop this object is affiliated with.
 
void moveToThread (EventLoop *loop)
 Changes the EventLoop affinity of this object.
 
int startTimer (unsigned int intervalMs, bool singleShot=false)
 Starts a timer on this object's EventLoop.
 
void stopTimer (int timerId)
 Stops a timer previously started with startTimer().
 
template<typename... Args>
PROMEKI_NAMESPACE_BEGIN void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaNode
static void registerNodeType (const String &typeName, std::function< MediaNode *()> factory)
 Registers a node type for runtime creation.
 
static MediaNodecreateNode (const String &typeName)
 Creates a node by registered type name.
 
static List< StringregisteredNodeTypes ()
 Returns the list of all registered node type names.
 
- Static Public Member Functions inherited from ObjectBase
static const MetaInfometaInfo ()
 Returns the MetaInfo for the ObjectBase class.
 
template<typename... Args>
static void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 connects a signal and slot together. This function assumes both the signal and slot exist in a ObjectBase or derived object
 
- Public Attributes inherited from ObjectBase
Signal< ObjectBase * > aboutToDestroySignal = Signal< ObjectBase * >(this, aboutToDestroySignalName)
 
- Static Public Attributes inherited from ObjectBase
static constexpr const charaboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")"
 
static SignalMeta aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName)
 
- Protected Member Functions inherited from MediaNode
void enqueueInput (Frame::Ptr frame)
 Enqueues a frame into this node's input queue.
 
void recordProcessTiming (double duration)
 Records timing for a process() call.
 
void recordStarvation ()
 Records a starvation event.
 
void addInputPort (MediaPort::Ptr port)
 Adds an input port to this node.
 
void addOutputPort (MediaPort::Ptr port)
 Adds an output port to this node.
 
void setState (State state)
 Sets the node state and emits stateChanged.
 
Frame::Ptr dequeueInput ()
 Dequeues a frame from this node's input queue.
 
void deliverOutput (int portIndex, Frame::Ptr frame)
 Delivers a frame to all outgoing links on the given output port.
 
void deliverOutput (Frame::Ptr frame)
 Delivers a frame to all outgoing links on all output ports.
 
void emitMessage (Severity severity, const String &message, uint64_t frameNumber=0)
 Emits a message with the given severity and text.
 
void emitWarning (const String &message)
 Emits a Warning-severity message.
 
void emitError (const String &message)
 Emits an Error-severity message.
 
- Protected Member Functions inherited from ObjectBase
ObjectBasesignalSender ()
 Returns the ObjectBase that emitted the signal currently being handled.
 
virtual void event (Event *e)
 Called by EventLoop to deliver events to this object.
 
virtual void timerEvent (TimerEvent *e)
 Called when a timer fires for this object.
 

Detailed Description

Source node that generates video and audio test patterns.

Produces complete Frame objects with synchronized video, audio, and timecode metadata on each process cycle. The video pattern, audio mode, and timecode are all configurable.

This is a source node: no inputs, one Frame output.

Example
src->setVideoDesc(videoDesc);
src->setAudioDesc(audioDesc);
src->setStartTimecode(Timecode(Timecode::NDF24, 1, 0, 0, 0));
Dynamic array container wrapping std::vector.
Definition list.h:40
Source node that generates video and audio test patterns.
Definition testpatternnode.h:40
const AudioDesc & audioDesc() const
Returns the audio description.
Definition testpatternnode.h:152
@ ColorBars
SMPTE 100% color bars.
Definition testpatternnode.h:45
const VideoDesc & videoDesc() const
Returns the video description.
Definition testpatternnode.h:92
Class for holding and manipulating timecode.
Definition timecode.h:45
@ NDF24
24 fps non-drop-frame (maps to VTC_FORMAT_24)
Definition timecode.h:53

Member Enumeration Documentation

◆ AudioMode

Audio generation mode.

Enumerator
Tone 

Sine tone (configurable frequency).

Silence 

Silence.

LTC 

LTC timecode audio.

◆ Pattern

Video test pattern type.

Enumerator
ColorBars 

SMPTE 100% color bars.

ColorBars75 

SMPTE 75% color bars.

Ramp 

Luminance gradient ramp.

Grid 

White grid lines on black.

Crosshatch 

Diagonal crosshatch lines.

Checkerboard 

Alternating black/white squares.

SolidColor 

Solid fill with configured color.

White 

Solid white.

Black 

Solid black.

Noise 

Random pixel noise.

ZonePlate 

Circular zone plate.

Constructor & Destructor Documentation

◆ TestPatternNode()

TestPatternNode::TestPatternNode ( ObjectBase parent = nullptr)

Constructs a TestPatternNode.

Parameters
parentOptional parent object.

Member Function Documentation

◆ configure()

Error TestPatternNode::configure ( )
overridevirtual

Validates ports and allocates resources.

Transitions the node from Idle to Configured on success.

Returns
Error::Ok on success, or an error code.

Reimplemented from MediaNode.

◆ extendedStats()

Map< String, Variant > TestPatternNode::extendedStats ( ) const
overridevirtual

Returns additional node-specific statistics.

Override in concrete nodes to expose custom statistics (e.g., "packetsSent", "bytesSent" for RTP nodes).

Returns
A map of stat names to Variant values.

Reimplemented from MediaNode.

◆ process()

void TestPatternNode::process ( )
overridevirtual

Processes one cycle of data.

Pure virtual — must be implemented by concrete node subclasses.

Implements MediaNode.

◆ setAudioDesc()

void TestPatternNode::setAudioDesc ( const AudioDesc desc)
inline

Sets the audio description.

Parameters
descThe audio format description.

◆ setAudioEnabled()

void TestPatternNode::setAudioEnabled ( bool  enable)
inline

Enables or disables audio generation.

Parameters
enabletrue to enable audio output.

◆ setAudioMode()

void TestPatternNode::setAudioMode ( AudioMode  mode)
inline

Sets the audio generation mode.

Parameters
modeTone, Silence, or LTC.

◆ setChannelConfig()

void TestPatternNode::setChannelConfig ( size_t  chan,
AudioGen::Config  config 
)

Sets per-channel audio configuration (Tone mode).

Parameters
chanChannel index.
configThe audio generator config for that channel.

◆ setDropFrame()

void TestPatternNode::setDropFrame ( bool  df)
inline

Enables or disables drop-frame timecode.

Parameters
dftrue for drop-frame (only effective at 30000/1001 fps).

◆ setLtcChannel()

void TestPatternNode::setLtcChannel ( int  chan)
inline

Sets which channel carries LTC.

Parameters
chanChannel index, or -1 for all channels.

◆ setLtcLevel()

void TestPatternNode::setLtcLevel ( float  level)
inline

Sets the LTC output amplitude.

Parameters
levelLevel (0.0-1.0).

◆ setMotion()

void TestPatternNode::setMotion ( double  speed)
inline

Sets the pattern motion speed.

Parameters
speed0.0 = static, positive = forward, negative = reverse. 1.0 = one pattern-width per second.

◆ setPattern()

void TestPatternNode::setPattern ( Pattern  p)
inline

Sets the video test pattern.

Parameters
pThe pattern to generate.

◆ setSolidColor()

void TestPatternNode::setSolidColor ( uint16_t  r,
uint16_t  g,
uint16_t  b 
)
inline

Sets the solid color for SolidColor pattern.

Parameters
rRed component (0-65535).
gGreen component (0-65535).
bBlue component (0-65535).

◆ setStartTimecode()

void TestPatternNode::setStartTimecode ( const Timecode tc)
inline

Sets the starting timecode.

Parameters
tcThe starting timecode value.

◆ setToneAmplitude()

void TestPatternNode::setToneAmplitude ( double  amplitude)
inline

Sets the amplitude for all tone channels.

Parameters
amplitudeAmplitude (0.0-1.0).

◆ setToneFrequency()

void TestPatternNode::setToneFrequency ( double  hz)
inline

Sets all channels to a sine tone at the given frequency.

Parameters
hzFrequency in Hz.

◆ setVideoDesc()

void TestPatternNode::setVideoDesc ( const VideoDesc desc)
inline

Sets the video description (frame rate, resolution, pixel format).

Parameters
descThe video description.

◆ start()

Error TestPatternNode::start ( )
overridevirtual

Begins processing.

Transitions the node from Configured to Running on success.

Returns
Error::Ok on success, or an error code.

Reimplemented from MediaNode.

◆ stop()

void TestPatternNode::stop ( )
overridevirtual

Stops processing.

Transitions the node from Running to Idle.

Reimplemented from MediaNode.


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