ADTF
Loading...
Searching...
No Matches
requestable_writer.h
Go to the documentation of this file.
1
7#pragma once
13#include <adtf_utils.h>
14#include <memory>
15#include <functional>
16
17namespace adtf
18{
19namespace streaming
20{
21namespace hollow
22{
23
27class cRequestBroker: public ucom::object<IStreamingRequests>
28{
29 public:
34 cRequestBroker(cSampleWriter* pWriter = nullptr);
35
39 ~cRequestBroker() override;
40
46 void SetCallbacks(std::function<void(uint32_t, const base::IProperties*)> fnEnable,
47 std::function<void(uint32_t)> fnDisable);
48
54
59 void DisableCurrentRequests(bool bCallDisableCallback = false);
60
61 // IStreamingRequests implementation
63 uint32_t nSubStreamId,
64 const base::ant::IProperties* pRequestProperties = nullptr) override;
65 void RegisterStreamTypeHandler(IStreamTypeHandler& oHandler) override;
66 void UnregisterStreamTypeHandler(IStreamTypeHandler& oHandler) override;
67
68 private:
69 class cImplementation;
70 std::unique_ptr<cImplementation> m_pImplementation;
71};
72
77template <typename BaseWriter = adtf::streaming::cSampleWriter>
79 public BaseWriter
80{
81 public:
87 {
88 m_pBroker.Reset(pBroker);
89 }
90
92 {
93 auto pHollowStream = ucom::ucom_cast<IInternalBindingProxy*>(&oSampleStream);
94 RETURN_IF_POINTER_NULL_DESC(pHollowStream, "Sample Stream does not implement IInternalBindingProxy");
95 RETURN_IF_FAILED(pHollowStream->GetInternalBindingProxy(m_pProxy));
97 RETURN_IF_FAILED(m_pProxy->BindServerObject(m_pBroker, pType));
98
99 return BaseWriter::BeginStreaming(oSampleStream);
100 }
101
103 {
104 BaseWriter::EndStreaming();
105 if (m_pProxy)
106 {
107 m_pProxy->UnbindServerObject(m_pBroker);
108 m_pProxy.Reset();
109 }
111 }
112
113 private:
116};
117
124template <typename BaseWriter = adtf::streaming::cSampleWriter>
126{
127 public:
136
145 void SetCallbacks(std::function<void(uint32_t, const base::IProperties*)> fnEnable,
146 std::function<void(uint32_t)> fnDisable)
147 {
148 m_pBroker->SetCallbacks(fnEnable, fnDisable);
149 }
150
152 {
153 m_pBroker->UpdateType(pType);
154 return BaseWriter::SetType(pType);
155 }
156
158 {
159 return ChangeType(pType, true, false);
160 }
161
172 bool bDisableCurrentRequests,
173 bool bCallDisableCallback)
174 {
175 RETURN_IF_FAILED(ChangeType(pType, bDisableCurrentRequests, bCallDisableCallback, true));
176 RETURN_IF_FAILED(ChangeType(pType, false, false, false));
178 }
179
181 bool bDisableCurrentRequests,
182 bool bCallDisableCallback,
183 bool bSync)
184 {
185 if (bDisableCurrentRequests)
186 {
187 m_pBroker->DisableCurrentRequests(bCallDisableCallback);
188 }
189
190 if (bSync)
191 {
192 m_pBroker->UpdateType(pType);
193 }
194 else
195 {
196 RETURN_IF_FAILED(BaseWriter::ChangeType(pType));
197 }
198
200 }
201
203 {
205 m_pBroker->DisableCurrentRequests(false);
207 }
208
209 private:
211
212};
213
214}
215
216using hollow::requestable_writer;
217
218}
219}
220
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_IF_POINTER_NULL_DESC(_ptr,...)
Definition result.h:57
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Definition property_intf.h:213
Definition samplestream_intf.h:30
Definition samplewriter.h:361
Definition streamingrequests_intf.h:26
Definition requestable_writer.h:28
void SetCallbacks(std::function< void(uint32_t, const base::IProperties *)> fnEnable, std::function< void(uint32_t)> fnDisable)
cRequestBroker(cSampleWriter *pWriter=nullptr)
void DisableCurrentRequests(bool bCallDisableCallback=false)
void UpdateType(const ucom::ant::iobject_ptr< const IStreamType > &pType)
tResult SetType(const ucom::ant::iobject_ptr< const ant::IStreamType > &pType) override
Definition requestable_writer.h:151
tResult EndStreaming() override
Definition requestable_writer.h:202
void SetCallbacks(std::function< void(uint32_t, const base::IProperties *)> fnEnable, std::function< void(uint32_t)> fnDisable)
Definition requestable_writer.h:145
tResult ChangeType(const ucom::ant::iobject_ptr< const ant::IStreamType > &pType) override
Definition requestable_writer.h:157
requestable_writer()
Definition requestable_writer.h:131
tResult ChangeType(const ucom::ant::iobject_ptr< const ant::IStreamType > &pType, bool bDisableCurrentRequests, bool bCallDisableCallback)
Definition requestable_writer.h:171
Definition requestable_writer.h:80
tResult BeginStreaming(streaming::ant::ISampleStream &oSampleStream) override
Definition requestable_writer.h:91
tResult EndStreaming() override
Definition requestable_writer.h:102
void SetBroker(const ucom::ant::iobject_ptr< IStreamingRequests > &pBroker)
Definition requestable_writer.h:86
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 functionality of the ADTF Streaming SDK provided since v3.7.
Definition filtergraphport.h:443
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
InterfacePointerType ucom_cast(ObjectPointerType i_pObject) noexcept
Alias always bringing the latest version of ant::ucom_cast() into scope.
Definition ucom_cast.h:157
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:104
object_ptr< Implementation > make_object_ptr(Args &&... args)
Alias always bringing the latest version of ant::make_object_ptr() into scope.
Definition object_ptr_utilities.h:129
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14