ADTF  3.18.2
cScriptWriter

A Runner that is returned by cScriptFilter::createOutputPin. More...

Inheritance diagram for cScriptWriter:
[legend]

Public Member Functions

Q_INVOKABLE void write (qint64 tmTimeStamp, const QJSValue &oValue)
 Writes a new sample to the connected Sample Stream. More...
 
Q_INVOKABLE void writeSubStream (qint64 tmTimeStamp, const QString &strSubStream, const QJSValue &oValue)
 Writes a new sample with a given substream id to the connected Sample Stream. More...
 
Q_INVOKABLE void manualTrigger ()
 Trigger all child runners manually. More...
 
Q_INVOKABLE void changeType (const QJSValue &oStreamType)
 Changes the type of the output stream. More...
 

Detailed Description

Member Function Documentation

◆ changeType()

Q_INVOKABLE void changeType ( const QJSValue &  oStreamType)

Changes the type of the output stream.

Parameters
oStreamTypeThe new type.

◆ manualTrigger()

Q_INVOKABLE void manualTrigger ( )

Trigger all child runners manually.

Warning
{ You are calling from the Qt GUI Thread. On huge workload you are blocking the display }

Example Usage

import QtQuick 2.9
import QtQuick.Controls 2.0
Item
{
property var output;
Component.onCompleted:
{
var outputType = types.createDefinition("my_data")
.add("value", "tUInt32")
output = filter.createOutputPin("manual_trigger", outputType);
}
Button
{
text: "Send"
anchors.fill: parent
onClicked:
{
output.write(clock.getStreamTime(),
{value: 1})
output.manualTrigger();
}
}
}

◆ write()

Q_INVOKABLE void write ( qint64  tmTimeStamp,
const QJSValue &  oValue 
)

Writes a new sample to the connected Sample Stream.

Example Usage

var outputType = types.createDefinition("my_data")
.add("value1", "tUInt32")
.add("value2", "tFloat32")
var output = filter.createOutputPin("output", outputType)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
output.write(timestamp, {value1: counter, value2: counter})
++counter
})

or for untyped data

var type = types.createStreamType("demo/my_special_type")
type.setProperty("my_property", 3.1415)
var output = filter.createOutputPin("output", type)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
// the stream type does not contain a media description so we can only send raw data
var data = new Int32Array(1);
data[0] = counter
output.write(timestamp, data.buffer)
++counter
})

◆ writeSubStream()

Q_INVOKABLE void writeSubStream ( qint64  tmTimeStamp,
const QString &  strSubStream,
const QJSValue &  oValue 
)

Writes a new sample with a given substream id to the connected Sample Stream.

Example Usage

var outputType = types.createDefinition("my_data")
.add("value", "tUInt32")
var sub_streams = types.createSubStreamsType()
sub_streams.setSubStream("stream1", 1, outputType)
sub_streams.setSubStream("stream2", 2, outputType)
var output = filter.createOutputPin("output", sub_streams)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
output.writeSubStream(timestamp, "stream1", {value: counter})
output.writeSubStream(timestamp, "stream2", {value: counter * 2})
++counter
})