ADTF
Loading...
Searching...
No Matches
filtergraphport.h
Go to the documentation of this file.
1
7#pragma once
8
9#include "triggerpipe.h"
10#include "runner_intf.h"
11#include "pin_intf.h"
12#include "inpin_intf.h"
13#include "outpin_intf.h"
16
18
19#include <algorithm>
20#include <memory>
21#include <type_traits>
22
23namespace adtf
24{
25namespace streaming
26{
27namespace ant
28{
29namespace detail
30{
34template<typename T, typename U = T>
36{
46
50 std::vector<tDestination> m_oTos;
54
56 port_router() = default;
59 {
60 RemoveTos();
61 }
62
68 {
69 if (m_pFrom.Get() == pFrom.Get())
70 {
71 // we do nothing ... already routing
72 // or nullptr == nullptr
73 }
74 else
75 {
76 if (m_pFrom)
77 {
78 if (pFrom.Get())
79 {
80 RETURN_ERROR_DESC(ERR_DEVICE_IN_USE,
81 "This port is already connected to a sample stream / binding proxy.");
82 }
83
84 for (const auto& sTo : m_oTos)
85 {
87 }
88 }
89 m_pFrom = pFrom;
90 if (m_pFrom)
91 {
92 for (const auto& sTo : m_oTos)
93 {
94 RETURN_IF_FAILED(ConnectRouting(m_pFrom, sTo));
95 }
96 }
97 }
99 }
100
107 {
108 if (FindTo(pTo) != m_oTos.end())
109 {
110 // we do nothing ... already forwarding
111 // or nullptr == nullptr
112 }
113 else
114 {
115 if (pTo.Get())
116 {
117 tDestination sTo;
118 sTo.pTo = pTo;
119
120 if (m_pFrom)
121 {
122 RETURN_IF_FAILED(ConnectRouting(m_pFrom, sTo));
123 }
124
125 m_oTos.push_back(sTo);
126 }
127 }
129 }
130
131 void RemoveTos()
132 {
133 for (const auto& sTo : m_oTos)
134 {
136 }
137
138 m_oTos.clear();
139 }
140
148 {
149 if (pFrom.Get() != nullptr && sTo.pTo.Get() != nullptr)
150 {
151 LOG_DETAIL("Attach routing '%s' -> '%s'", get_named_graph_object_full_name(*pFrom.Get()).GetPtr(),
152 get_named_graph_object_full_name(*sTo.pTo.Get()).GetPtr());
153 RETURN_IF_FAILED(pFrom->AttachRouting(sTo.pTo));
154
156 {
157 RETURN_IF_FAILED(SetTriggerForwarding(pFrom, sTo.pTo, true));
158 }
159 }
160
162 }
163
170 {
171 if (pFrom.Get() != nullptr && sTo.pTo.Get() != nullptr)
172 {
174 {
175 RETURN_IF_FAILED(SetTriggerForwarding(pFrom, sTo.pTo, false));
176 }
177
178 RETURN_IF_FAILED(pFrom->DetachRouting(sTo.pTo));
179 }
180
182 }
183
188 {
189 if (m_bTriggerForwardingFromParent != bForwarded)
190 {
192 for (const auto& sTo : m_oTos)
193 {
194 if (sTo.bTriggerForwarding)
195 {
196 RETURN_IF_FAILED(SetTriggerForwarding(m_pFrom, sTo.pTo, m_bTriggerForwardingFromParent));
197 }
198 }
199 }
200
202 }
203
208 {
209 if (!pTo.Get())
210 {
211 // nothing was ever routed to, @see AddTo
213 }
214
215 const auto itTo = FindTo(pTo);
216 if (itTo == m_oTos.end())
217 {
218 if (bForwarded)
219 {
220 RETURN_ERROR_DESC(ERR_NOT_FOUND, "This port does not route to the given destination.");
221 }
222
223 // a disconnect tears the routing down before it gets here, so there is nothing left to undo
225 }
226
227 if (itTo->bTriggerForwarding != bForwarded)
228 {
229 itTo->bTriggerForwarding = bForwarded;
231 {
232 RETURN_IF_FAILED(SetTriggerForwarding(m_pFrom, itTo->pTo, m_bTriggerForwardingFromParent));
233 }
234 }
235
237 }
238
239private:
241 typename std::vector<tDestination>::iterator FindTo(const adtf::ucom::ant::iobject_ptr<U>& pTo) noexcept
242 {
243 return std::find_if(m_oTos.begin(), m_oTos.end(), [&pTo](const tDestination& sTo) noexcept
244 {
245 return sTo.pTo.Get() == pTo.Get();
246 });
247 }
248
251 static tResult SetTriggerForwarding(const adtf::ucom::ant::iobject_ptr<T>& pFrom,
253 bool bRoute)
254 {
255 if constexpr (std::is_base_of_v<ITriggerPipeSource, T> && std::is_base_of_v<ITriggerPipeItem, U>)
256 {
257 if (pFrom.Get() != nullptr && pTo.Get() != nullptr)
258 {
260 RETURN_IF_FAILED(bRoute ?
261 pFrom->RegisterSubItem(pSubItem, ITriggerPipeSource::tPriority::Normal) :
262 pFrom->UnregisterSubItem(pSubItem));
263 }
264 }
265
267 }
268};
269} // namespace detail
270
276 public trigger_pipe_item<INamedGraphObject,
277 IPin,
278 IInPin,
279 IFilterGraphPort,
280 IFilterGraphDataPort,
281 IFilterGraphDataInPort>
282{
283private:
285 std::atomic_bool m_bActive;
286
287public:
292 cFilterGraphDataInPort(const char* strName);
294 virtual ~cFilterGraphDataInPort() override;
295
296public:
297 tResult InnerConnect(const adtf::ucom::ant::iobject_ptr<ISampleStream>& pSampleStream) override;
298 tResult InnerDisconnect() override;
299
300public:
301 tResult GetType(adtf::ucom::ant::iobject_ptr<const IStreamType>& pStreamType) const override;
302
303 bool IsConnected() const override;
304 tResult SetActive() override;
305 tResult SetInactive() override;
306
307 tResult Disconnect() override;
308 tResult GetSampleStream(adtf::ucom::ant::iobject_ptr<ISampleStream>& pSampleStream) const override;
309
310public:
311 tResult Connect(const adtf::ucom::ant::iobject_ptr<ISampleStream>& pSampleStream) override;
312
313public:
315 tResult SetTriggerForwardingFromParent(bool bForwarded) override;
318 bool bForwarded) override;
319};
320
326 public trigger_pipe_item<INamedGraphObject,
327 IPin,
328 IOutPin,
329 IFilterGraphPort,
330 IFilterGraphDataPort,
331 IFilterGraphDataOutPort>
332{
333public:
334 template<typename T>
335 using iobject_ptr = adtf::ucom::ant::iobject_ptr<T>;
336
337private:
339 std::atomic_bool m_bActive;
340
341public:
346 cFilterGraphDataOutPort(const char* strName);
348 virtual ~cFilterGraphDataOutPort() override;
349
350public:
351 tResult InnerConnect(const iobject_ptr<ISampleStream>& pSampleStream);
352 tResult InnerDisconnect();
353
354public:
355 tResult Connect(const iobject_ptr<ISampleStream>& pSampleStream) override;
356
357public:
358 tResult GetType(iobject_ptr<const IStreamType>& pStreamType) const override;
359
360 bool IsConnected() const override;
361 tResult SetActive() override;
362 tResult SetInactive() override;
363
364 tResult Disconnect() override;
365 tResult GetSampleStream(iobject_ptr<ISampleStream>& pSampleStream) const override;
366
367public:
369 tResult SetTriggerForwardingFromParent(bool bForwarded) override;
372 bool bForwarded) override;
373};
374
380 public ucom::catwo::object<IBindingObject,
381 IBindingServer,
382 IFilterGraphPort,
383 IFilterGraphInterfacePort,
384 named_graph_object<IFilterGraphInterfaceServerPort>>
385{
386public:
388 template<typename T>
390
391private:
393
394public:
399 cFilterGraphServerPort(const char* strName);
401 virtual ~cFilterGraphServerPort() override;
402
403public:
404 tResult InnerBind(const iobject_ptr<IBindingProxy>& pSampleStream);
405 tResult InnerUnbind();
406
407public:
408 tResult Bind(const iobject_ptr<IBindingProxy>& pBindingProxy);
409
410public:
411 tResult GetBindingType(iobject_ptr<const IBindingType>& pBindingType) const;
412 tResult GetServerObject(iobject_ptr<IObject>& pServerObject) const;
413 tResult GetBindingProxy(iobject_ptr<IBindingProxy>& pBindingProxy) const;
414 tResult Unbind();
415};
416
422 public ucom::catwo::object<IBindingObject,
423 IBindingClient,
424 IFilterGraphPort,
425 IFilterGraphInterfacePort,
426 named_graph_object<IFilterGraphInterfaceClientPort>>
427{
428public:
430 template<typename T>
432
433private:
436
437public:
442 cFilterGraphClientPort(const char* strName);
444 virtual ~cFilterGraphClientPort() override;
445
446public:
447 tResult InnerBind(const iobject_ptr<IBindingClient>& pClientForward) override;
448 tResult InnerUnbind() override;
449
450public:
451 tResult Bind(const iobject_ptr<IBindingProxy>& pBindingProxy) override;
452
453public:
454 tResult GetBindingType(iobject_ptr<const IBindingType>& pBindingType) const override;
455 tResult GetServerObject(iobject_ptr<IObject>& pServerObject) const override;
456 tResult GetBindingProxy(iobject_ptr<IBindingProxy>& pBindingProxy) const override;
457 tResult Unbind() override;
458};
459
465 public trigger_pipe_item<INamedGraphObject, IFilterGraphPort, IRunner, IFilterGraphRunnerPort>
466{
467public:
469 template<typename T>
471
472public:
477 cFilterGraphRunnerPort(const char* strName);
479 virtual ~cFilterGraphRunnerPort() override;
480
481public:
482 tResult InnerRegisterSubItem(const iobject_ptr<IRunner>& pRunner) override;
483 tResult InnerUnregisterSubItem(const iobject_ptr<IRunner>& pRunner) override;
484};
485
486} // namespace ant
487
488namespace flash
489{
490
492
493class cFilterGraphDataInPort :
494 public trigger_pipe_item<INamedGraphObject,
495 IPin,
496 IInPin,
497 IFilterGraphPort,
498 IFilterGraphDataPort,
499 IFilterGraphDataInPort>
500{
501public:
502 cFilterGraphDataInPort();
503 cFilterGraphDataInPort(const char* strName);
504 ~cFilterGraphDataInPort() override;
505
506public:
507 tResult InnerConnect(const ucom::ant::iobject_ptr<ant::ISampleStream>& pSampleStream) override;
508 tResult InnerDisconnect() override;
509
510public:
511 tResult GetType(ucom::ant::iobject_ptr<const ant::IStreamType>& pStreamType) const override;
512
513 bool IsConnected() const override;
514 tResult SetActive() override;
515 tResult SetInactive() override;
516
517 tResult Disconnect() override;
518 tResult GetSampleStream(ucom::ant::iobject_ptr<ant::ISampleStream>& pSampleStream) const override;
519
520public:
521 tResult Connect(const ucom::ant::iobject_ptr<ant::ISampleStream>& pSampleStream) override;
522
523public:
525 tResult SetTriggerForwardingFromParent(bool bForwarded) override;
528 bool bForwarded) override;
529
530protected:
531 class cImplementation;
532 std::unique_ptr<cImplementation> m_pImplementation;
533};
534
535class cFilterGraphDataOutPort :
536 public trigger_pipe_item<INamedGraphObject,
537 IPin,
538 IOutPin,
539 IFilterGraphPort,
540 IFilterGraphDataPort,
541 IFilterGraphDataOutPort>
542{
543public:
544 cFilterGraphDataOutPort();
545 cFilterGraphDataOutPort(const char* strName);
546 ~cFilterGraphDataOutPort() override;
547
548public:
549 tResult InnerConnect(const ucom::ant::iobject_ptr<ant::ISampleStream>& pSampleStream) override;
550 tResult InnerDisconnect() override;
551
552public:
553 tResult GetType(ucom::ant::iobject_ptr<const ant::IStreamType>& pStreamType) const override;
554
555 bool IsConnected() const override;
556 tResult SetActive() override;
557 tResult SetInactive() override;
558
559 tResult Disconnect() override;
560 tResult GetSampleStream(ucom::ant::iobject_ptr<ant::ISampleStream>& pSampleStream) const override;
561
562public:
563 tResult Connect(const ucom::ant::iobject_ptr<ant::ISampleStream>& pSampleStream) override;
564
565public:
567 tResult SetTriggerForwardingFromParent(bool bForwarded) override;
570 bool bForwarded) override;
571
572protected:
573 class cImplementation;
574 std::unique_ptr<cImplementation> m_pImplementation;
575};
576
577} // namespace flash
578
579namespace hollow
580{
581
588 public ucom::catwo::object<IBindingObject,
589 IBindingClient,
590 IFilterGraphPort,
591 IFilterGraphInterfacePort,
592 named_graph_object<IFilterGraphInterfaceClientPort>>
593{
594public:
599 cFilterGraphClientPort(const char* strName);
601 virtual ~cFilterGraphClientPort() override;
602
603public:
604 tResult InnerBind(const ucom::ant::iobject_ptr<IBindingClient>& pClientForward) override;
605 tResult InnerUnbind() override;
606
607public:
608 tResult Bind(const ucom::ant::iobject_ptr<IBindingProxy>& pBindingProxy) override;
609
610public:
611 tResult GetBindingType(ucom::ant::iobject_ptr<const IBindingType>& pBindingType) const override;
612 tResult GetServerObject(ucom::ant::iobject_ptr<IObject>& pServerObject) const override;
613 tResult GetBindingProxy(ucom::ant::iobject_ptr<IBindingProxy>& pBindingProxy) const override;
614 tResult Unbind() override;
615
616protected:
617 class cImplementation;
618 std::unique_ptr<cImplementation> m_pImplementation;
619};
620
621} // namespace hollow
622
623namespace quiet
624{
625
630
635
640
641} // namespace quiet
642
653} // namespace streaming
654} // namespace adtf
#define LOG_DETAIL(...)
Logs additional information.
Definition log.h:461
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:775
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
Definition result.h:44
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
@ Normal
Normal Priority.
Definition triggerpipe_intf.h:49
adtf::ucom::ant::iobject_ptr< T > iobject_ptr
used type for iobject_ptr
Definition filtergraphport.h:431
virtual ~cFilterGraphClientPort() override
DTOR.
tResult SetTriggerForwardingToChild(const adtf::ucom::ant::iobject_ptr< ISampleStream > &pSampleStream, bool bForwarded) override
tResult SetTriggerForwardingFromParent(bool bForwarded) override
virtual ~cFilterGraphDataInPort() override
DTOR.
tResult SetTriggerForwardingFromParent(bool bForwarded) override
tResult SetTriggerForwardingToChild(const adtf::ucom::ant::iobject_ptr< ISampleStream > &pSampleStream, bool bForwarded) override
virtual ~cFilterGraphDataOutPort() override
DTOR.
Definition filtergraphport.h:466
virtual ~cFilterGraphRunnerPort() override
DTOR.
adtf::ucom::ant::iobject_ptr< T > iobject_ptr
used type for iobject_ptr
Definition filtergraphport.h:470
Definition filtergraphport.h:385
adtf::ucom::ant::iobject_ptr< T > iobject_ptr
used type for iobject_ptr
Definition filtergraphport.h:389
virtual ~cFilterGraphServerPort() override
DTOR.
Definition filtergraphport.h:500
tResult SetTriggerForwardingToChild(const ucom::ant::iobject_ptr< ant::ISampleStream > &pSampleStream, bool bForwarded) override
tResult SetTriggerForwardingFromParent(bool bForwarded) override
Definition filtergraphport.h:542
tResult SetTriggerForwardingFromParent(bool bForwarded) override
tResult SetTriggerForwardingToChild(const ucom::ant::iobject_ptr< ant::ISampleStream > &pSampleStream, bool bForwarded) override
Definition filtergraphport.h:593
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
Definition object.h:397
Namespace for all internally used functionality implemented.
Definition filtergraphport.h:30
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Definition bindingproxyoutport.h:16
adtf_util::cString get_named_graph_object_full_name(const INamedGraphObject &oGraphObject)
Namespace for all functionality of the ADTF Streaming SDK provided since v3.5.
Definition filterbase.h:255
Namespace for all functionality of the ADTF Streaming SDK provided since v3.7.
Definition filtergraphport.h:580
Namespace for all functionality of the ADTF Streaming SDK provided since v3.16.
Definition filtergraphport.h:624
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
object_ptr< T > ucom_object_ptr_cast(object_ptr< T > oCasted)
Alias always bringing the latest version of ant::ucom_object_ptr_cast() into scope.
Definition object_ptr_utilities.h:135
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
bool bTriggerForwarding
whether the trigger has to be handed on to this destination.
Definition filtergraphport.h:44
adtf::ucom::object_ptr< U > pTo
the to reference.
Definition filtergraphport.h:42
Definition filtergraphport.h:36
tResult DisconnectRouting(const adtf::ucom::ant::iobject_ptr< T > &pFrom, const tDestination &sTo)
Definition filtergraphport.h:169
std::vector< tDestination > m_oTos
the to references.
Definition filtergraphport.h:50
tResult ResetFrom(const adtf::ucom::ant::iobject_ptr< T > &pFrom)
Definition filtergraphport.h:67
tResult AddTo(const adtf::ucom::ant::iobject_ptr< U > &pTo)
Definition filtergraphport.h:106
tResult SetTriggerForwardingToChild(const adtf::ucom::ant::iobject_ptr< U > &pTo, bool bForwarded)
Definition filtergraphport.h:207
~port_router()
DTOR.
Definition filtergraphport.h:58
tResult ConnectRouting(const adtf::ucom::ant::iobject_ptr< T > &pFrom, const tDestination &sTo)
Definition filtergraphport.h:147
tResult SetTriggerForwardingFromParent(bool bForwarded)
Definition filtergraphport.h:187
bool m_bTriggerForwardingFromParent
Definition filtergraphport.h:53
adtf::ucom::object_ptr< T > m_pFrom
the from reference.
Definition filtergraphport.h:48