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

Burns timecode text into video frames using FontPainter. More...

#include <timecodeoverlaynode.h>

Inheritance diagram for TimecodeOverlayNode:
Collaboration diagram for TimecodeOverlayNode:

Public Types

enum  Position {
  TopLeft , TopCenter , TopRight , BottomLeft ,
  BottomCenter , BottomRight , Custom
}
 Named position presets for text placement. 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

 TimecodeOverlayNode (ObjectBase *parent=nullptr)
 Constructs a TimecodeOverlayNode.
 
virtual ~TimecodeOverlayNode ()=default
 Destructor.
 
void setFontPath (const FilePath &path)
 Sets the path to the TrueType font file.
 
const FilePathfontPath () const
 Returns the font path.
 
void setFontSize (int points)
 Sets the font size in points.
 
int fontSize () const
 Returns the font size in points.
 
void setPosition (Position pos)
 Sets the text position using a named preset.
 
void setPosition (int x, int y)
 Sets a custom text position.
 
Position position () const
 Returns the current position preset.
 
void setTextColor (uint16_t r, uint16_t g, uint16_t b)
 Sets the text color.
 
void setDrawBackground (bool enable)
 Enables or disables drawing a dark background behind the text.
 
bool drawBackground () const
 Returns true if background drawing is enabled.
 
void setCustomText (const String &text)
 Sets additional custom text to render below the timecode.
 
const StringcustomText () const
 Returns the custom text.
 
Error configure () override
 Validates the font path and initializes the FontPainter.
 
void process () override
 Reads timecode from the input image's metadata and renders it as text.
 
- 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 Error start ()
 Begins processing.
 
virtual void stop ()
 Stops processing.
 
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.
 
virtual Map< String, VariantextendedStats () const
 Returns additional node-specific statistics.
 
 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

Burns timecode text into video frames using FontPainter.

Processing node with one Image input and one Image output. Reads timecode from the Image's own Metadata and renders it as text onto the image buffer. Optionally renders additional custom text.

Requires a TrueType font file to be set via setFontPath() before configure() is called.

Example
overlay->setFontPath("/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf");
overlay->setFontSize(48);
Dynamic array container wrapping std::vector.
Definition list.h:40
Burns timecode text into video frames using FontPainter.
Definition timecodeoverlaynode.h:37
@ BottomCenter
Bottom center.
Definition timecodeoverlaynode.h:46

Member Enumeration Documentation

◆ Position

Named position presets for text placement.

Enumerator
TopLeft 

Top-left corner.

TopCenter 

Top center.

TopRight 

Top-right corner.

BottomLeft 

Bottom-left corner.

BottomCenter 

Bottom center.

BottomRight 

Bottom-right corner.

Custom 

Custom x/y coordinates.

Constructor & Destructor Documentation

◆ TimecodeOverlayNode()

TimecodeOverlayNode::TimecodeOverlayNode ( ObjectBase parent = nullptr)

Constructs a TimecodeOverlayNode.

Parameters
parentOptional parent object.

Member Function Documentation

◆ configure()

Error TimecodeOverlayNode::configure ( )
overridevirtual

Validates the font path and initializes the FontPainter.

Transitions to Configured on success. Fails if the font path is not set or does not exist on disk.

Returns
Error::Ok on success, or Error::Invalid.

Reimplemented from MediaNode.

◆ process()

void TimecodeOverlayNode::process ( )
overridevirtual

Reads timecode from the input image's metadata and renders it as text.

Dequeues a Frame from the input port, ensures exclusive buffer ownership via copy-on-write, renders the timecode (and optional custom text), then delivers the modified Frame to the output port.

Implements MediaNode.

◆ setCustomText()

void TimecodeOverlayNode::setCustomText ( const String text)
inline

Sets additional custom text to render below the timecode.

Parameters
textThe custom text string (e.g., "TEST SIGNAL").

◆ setDrawBackground()

void TimecodeOverlayNode::setDrawBackground ( bool  enable)
inline

Enables or disables drawing a dark background behind the text.

Parameters
enabletrue to draw a background rectangle for legibility.

◆ setFontPath()

void TimecodeOverlayNode::setFontPath ( const FilePath path)
inline

Sets the path to the TrueType font file.

Parameters
pathPath to a .ttf font file (required).

◆ setFontSize()

void TimecodeOverlayNode::setFontSize ( int  points)
inline

Sets the font size in points.

Parameters
pointsFont size (default: 36).

◆ setPosition() [1/2]

void TimecodeOverlayNode::setPosition ( int  x,
int  y 
)
inline

Sets a custom text position.

Switches the position mode to Custom.

Parameters
xX coordinate of the text origin.
yY coordinate of the text origin.

◆ setPosition() [2/2]

void TimecodeOverlayNode::setPosition ( Position  pos)
inline

Sets the text position using a named preset.

The actual x/y coordinates are computed during process() based on the frame dimensions and font size.

Parameters
posThe position preset.

◆ setTextColor()

void TimecodeOverlayNode::setTextColor ( uint16_t  r,
uint16_t  g,
uint16_t  b 
)
inline

Sets the text color.

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

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