ADTF
javascriptfiltersdk/src/filter.h
Go to the documentation of this file.
1 
8 /*
9  * This file depends on Qt which is licensed under LGPLv3.
10  * See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
11  */
12 #pragma once
13 #include <adtffiltersdk/filter.h>
14 
15 #include <QQmlEngine>
16 #include <QJsonValue>
17 #include <QQmlPropertyMap>
18 #include <vector>
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <unordered_set>
23 
24 namespace adtf
25 {
26 
30 namespace javascript
31 {
32 
36 namespace scripting
37 {
38 
40 // Predeclaration of internal class
41 class cPropertiesQtMapper;
42 class cScriptReader;
44 
48 class cScriptFilter: public QObject
49 {
50  Q_OBJECT
51 
56  Q_PROPERTY(QQmlPropertyMap* properties READ GetProperties NOTIFY propertiesChanged)
57 
58  public:
60  cScriptFilter(filter::flash::cFilter& oFilter, QJSEngine& oEngine);
61  ~cScriptFilter() override;
62  tResult Check();
64 
75  Q_INVOKABLE QObject* createInputPin(const QString& strName, bool bForwardTriggerViaOutputPins = true);
76 
87  Q_INVOKABLE QObject* createOutputPin(const QString& strName, const QJSValue& oStreamType = QJSValue());
88 
99  Q_INVOKABLE QObject* createRunner(const QString& strName, bool bForwardTriggerViaOutputPins = true);
100 
114  Q_INVOKABLE QObject* createInterfaceClient(const QString& strName, const QString& strInterface);
115 
121  Q_INVOKABLE void linkTrigger(const QString& strSource, const QString& strDestination);
122 
130  Q_INVOKABLE QVariant getProperty(const QString& strName);
131 
139  Q_INVOKABLE void setProperty(const QString& strName, const QVariant& oValue, const QString& strType = "");
140 
141  void enablePropertyValueOverride();
142 
143  signals:
147  void connected();
148 
149  /*
150  * Emited if the properties changed
151  */
152  void propertiesChanged();
153 
159  void propertyChanged(const QString& strName, const QVariant& oValue);
160 
162  private:
163  void FlushWriters();
164  void ForwardTrigger(base::tNanoSeconds tmTrigger);
165 
166  void PostTriggerHandler(bool bForwardTriggerViaOutputPins, qint64 tmTrigger);
167 
168  QQmlPropertyMap* GetProperties();
169 
170  private:
171  filter::flash::cFilter& m_oFilter;
172  QJSEngine& m_oEngine;
173  bool m_bUseAsyncSlotConnections;
174  std::mutex m_oProcessingLock;
175  std::vector<QPointer<cScriptReader>> m_oScriptReader;
176  std::vector<streaming::ISampleWriter*> m_oWriters;
177  std::unique_ptr<cPropertiesQtMapper> m_pProperties;
178  bool m_bEnablePropertyValueOverride = false;
180 };
181 
182 }
183 }
184 }
185 
187 namespace filter_properties
188 {
189 
190 static constexpr auto strSynchronousTriggerProcessingProperty = "__synchronous_trigger_processing";
191 
192 }
194 
Provides the global 'filter' object within scripts.
void connected()
Emited after all Pins have been connected.
void propertyChanged(const QString &strName, const QVariant &oValue)
Emited for each property change.
Q_INVOKABLE void linkTrigger(const QString &strSource, const QString &strDestination)
Creates an internal Trigger Pipe between two Runners.
Q_INVOKABLE QObject * createInterfaceClient(const QString &strName, const QString &strInterface)
Create a new interface client.
Q_INVOKABLE QObject * createOutputPin(const QString &strName, const QJSValue &oStreamType=QJSValue())
Creates a new Output Pin.
Q_INVOKABLE QObject * createRunner(const QString &strName, bool bForwardTriggerViaOutputPins=true)
Creates a new Runner.
Q_INVOKABLE QVariant getProperty(const QString &strName)
Q_INVOKABLE QObject * createInputPin(const QString &strName, bool bForwardTriggerViaOutputPins=true)
Creates a new Input Pin.
Q_INVOKABLE void setProperty(const QString &strName, const QVariant &oValue, const QString &strType="")
Copyright © Audi Electronics Venture GmbH.
Namespace for entire ADTF SDK.