ADTF  3.18.2
cScriptTypes

Provides the global 'types' object within scripts. More...

Inheritance diagram for cScriptTypes:
[legend]

Public Member Functions

Q_INVOKABLE QObject * createDefinition (const QString &strStructName)
 Create a new cScriptStructure definition. More...
 
Q_INVOKABLE QObject * getDefinition (const QString &strStructName)
 Returns a stream type with a media description set from the Media Description Service. More...
 
Q_INVOKABLE QObject * createStreamType (const QString &strMetaType)
 Create a new cStreamTypeWrapper instance with the given Stream Meta Type. More...
 
Q_INVOKABLE QObject * createPlainStreamType (const QString &strCType)
 Create a new cStreamTypeWrapper instance for a adtf/plain stream type with the a given c-type. More...
 
Q_INVOKABLE QObject * createSubStreamsType ()
 Creates a stream type that can handle Substreams. More...
 
Q_INVOKABLE QObject * fromDescriptionFile (const QString &strStructName, const QString &strFileName, bool bResolveStruct=true)
 Creates an 'adtf/default' Stream Type from the given media description file. More...
 
Q_INVOKABLE QObject * fromDescriptionString (const QString &strStructName, const QString &strMediaDescription, bool bResolveStruct=true)
 Creates an 'adtf/default' Stream Type from the given media description string. More...
 

Private Attributes

QJSEngine & m_oEngine
 
adtf::util::cFilepath m_strScriptFolder
 

Detailed Description

Provides the global 'types' object within scripts.

Definition at line 138 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/javascriptfiltersdk/src/types.h.

Member Function Documentation

◆ createDefinition()

Q_INVOKABLE QObject* createDefinition ( const QString &  strStructName)

Create a new cScriptStructure definition.

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
})
Parameters
[in]strStructNameThe name of the structure.
Returns
a cScriptStructure instance.

◆ createPlainStreamType()

Q_INVOKABLE QObject* createPlainStreamType ( const QString &  strCType)

Create a new cStreamTypeWrapper instance for a adtf/plain stream type with the a given c-type.

Example Usage

Parameters
[in]strCTypeThe c-type name ( bool, int8, uint8, int16, uint16, " "int32, uint32, int64, uint64, float, double)
Returns
a cStreamTypeWrapper instance.

◆ createStreamType()

Q_INVOKABLE QObject* createStreamType ( const QString &  strMetaType)

Create a new cStreamTypeWrapper instance with the given Stream Meta Type.

This allows you to create any stream type manually by setting the Properties.

Example Usage

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
})
Parameters
[in]strMetaTypeThe Stream Meta Type.
Returns
a cStreamTypeWrapper instance.

◆ createSubStreamsType()

Q_INVOKABLE QObject* createSubStreamsType ( )

Creates a stream type that can handle Substreams.

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
})
Returns
a cSubStreamsTypeWrapper instance.

◆ fromDescriptionFile()

Q_INVOKABLE QObject* fromDescriptionFile ( const QString &  strStructName,
const QString &  strFileName,
bool  bResolveStruct = true 
)

Creates an 'adtf/default' Stream Type from the given media description file.

Example Usage

var type = types.fromDescriptionFile("my_data", "my_description.description")
var output = filter.createOutputPin("output", type)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
output.write(timestamp, {element_from_description: counter})
++counter
})
Parameters
[in]strStructNameThe name of the struct within the .description file
[in]strFileNameThe filename of the .description file. You can use macros as well. Relative filenames are resolved with respect to the script file.
[in]bResolveStructIf true, the DDL will be reduced to contain only the definition of strStructName and its dependencies.
Returns
a cStreamTypeWrapper instance.

◆ fromDescriptionString()

Q_INVOKABLE QObject* fromDescriptionString ( const QString &  strStructName,
const QString &  strMediaDescription,
bool  bResolveStruct = true 
)

Creates an 'adtf/default' Stream Type from the given media description string.

Example Usage

var type = types.fromDescriptionString("my_data",
"<structs>\
<struct name=\"my_data\" version=\"1\" ddlversion=\"4.0\">\
<element name=\"element_from_description\" type=\"tUInt32\" arraysize=\"1\">\
<deserialized alignment=\"1\"/>\
<serialized bytepos=\"0\" byteorder=\"LE\"/>\
</element>\
</struct>\
</structs>")
var output = filter.createOutputPin("output", type)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
output.write(timestamp, {element_from_description: counter})
++counter
})
Parameters
[in]strStructNameThe name of the struct within the .description file
[in]strMediaDescriptionThe string containing the media description.
[in]bResolveStructIf true, the DDL will be reduced to contain only the definition of strStructName and its dependencies.
Returns
a cStreamTypeWrapper instance.

◆ getDefinition()

Q_INVOKABLE QObject* getDefinition ( const QString &  strStructName)

Returns a stream type with a media description set from the Media Description Service.

Please mind that the prefered way to use description files in scripting is via the fromDescriptionFile() method.

Example Usage

// this defintion must be loaded from a description file by the Media Description Service.
var type = types.getDefinition("my_data_from_service")
var output = filter.createOutputPin("output", type)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
output.write(timestamp, {element_from_description: counter})
++counter
})
Parameters
[in]strStructNameThe name of the structure that should be retrieved from the service..
Returns
a cStreamTypeWrapper instance.