MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
flow.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3
4#include "mxl/flow.h"
5#include <cstdint>
6#include <exception>
7#include <filesystem>
8#include <string>
9#include <uuid.h>
10#include <sys/file.h>
11#include <mxl/mxl.h>
15
16namespace
17{
18 mxl::lib::Timepoint toDeadline(std::uint64_t timeoutNs) noexcept
19 {
20 return currentTime(mxl::lib::Clock::Realtime) + mxl::lib::Duration{static_cast<std::int64_t>(timeoutNs)};
21 }
22}
23
24using namespace mxl::lib;
25
26extern "C"
28mxlStatus mxlIsFlowActive(mxlInstance instance, char const* flowId, bool* isActive)
29{
30 try
31 {
32 if (isActive != nullptr)
33 {
34 if (auto const cppInstance = to_Instance(instance); cppInstance != nullptr)
35 {
36 if ((flowId != nullptr) && uuids::uuid::is_valid_uuid(flowId))
37 {
38 auto const id = uuids::uuid::from_string(flowId);
39 if (id.has_value())
40 {
41 auto const domain = cppInstance->getDomain();
42
43 // Try to obtain an exclusive lock on the flow data file. If we can obtain one it means that no
44 // other process is writing to the flow.
45 auto flowDataFile = mxl::lib::makeFlowDataFilePath(domain, flowId);
46
47 auto const fd = ::open(flowDataFile.c_str(), O_RDONLY | O_CLOEXEC);
48 if (fd < 0)
49 {
50 auto const error = errno;
51 if (error == ENOENT)
52 {
54 }
55
56 MXL_ERROR("Failed to open flow data file {} : {}", flowDataFile.string(), std::strerror(error));
58 }
59
60 // Try to obtain an exclusive lock on the file descriptor. Do not block if the lock cannot be obtained.
61 auto const active = ::flock(fd, LOCK_EX | LOCK_NB) < 0;
62 close(fd);
63
64 *isActive = active;
65 return MXL_STATUS_OK;
66 }
67 }
68 }
70 }
72 }
73 catch (std::exception const& e)
74 {
75 MXL_ERROR("Failed to check if flow is active : {}", e.what());
76 }
77 catch (...)
78 {
79 MXL_ERROR("Failed to check if flow is active : {}", "An unknown error occured.");
80 }
81 return MXL_ERR_UNKNOWN;
82}
83
84extern "C"
86mxlStatus mxlGetFlowDef(mxlInstance instance, char const* flowId, char* buffer, size_t* bufferSize)
87{
88 if (flowId == nullptr || bufferSize == nullptr)
89 {
91 }
92
93 try
94 {
95 if (auto const cppInstance = to_Instance(instance); cppInstance != nullptr)
96 {
97 if (auto const id = uuids::uuid::from_string(flowId); id.has_value())
98 {
99 auto const flowDef = cppInstance->getFlowDef(*id);
100 auto const requiredSize = flowDef.size() + 1; // +1 for the null terminator
101 if (buffer == nullptr || *bufferSize < requiredSize)
102 {
103 *bufferSize = requiredSize;
104 return MXL_ERR_INVALID_ARG;
105 }
106 *bufferSize = requiredSize;
107 std::strncpy(buffer, flowDef.c_str(), requiredSize);
108 return MXL_STATUS_OK;
109 }
110 }
111 return MXL_ERR_INVALID_ARG;
112 }
113 catch (std::filesystem::filesystem_error const& e)
114 {
115 if (e.code().value() == ENOENT)
116 {
118 }
119
120 MXL_ERROR("Failed to get flow definition : {}", e.what());
121 return MXL_ERR_UNKNOWN;
122 }
123 catch (std::exception const& e)
124 {
125 MXL_ERROR("Failed to get flow definition : {}", e.what());
126 }
127 catch (...)
128 {
129 MXL_ERROR("Failed to get flow definition : {}", "An unknown error occured.");
130 }
131 return MXL_ERR_UNKNOWN;
132}
133
134extern "C"
136mxlStatus mxlCreateFlowReader(mxlInstance instance, char const* flowId, char const* /*options*/, mxlFlowReader* reader)
137{
138 try
139 {
140 if (reader != nullptr)
141 {
142 if (auto const cppInstance = to_Instance(instance); cppInstance != nullptr)
143 {
144 if ((flowId != nullptr) && uuids::uuid::is_valid_uuid(flowId))
145 {
146 *reader = reinterpret_cast<mxlFlowReader>(cppInstance->getFlowReader(flowId));
147 return MXL_STATUS_OK;
148 }
149 }
150 }
151
152 return MXL_ERR_INVALID_ARG;
153 }
154 catch (std::filesystem::filesystem_error const& e)
155 {
156 auto const code = e.code();
157 if (code.value() == ENOENT)
158 {
160 }
161
162 MXL_ERROR("Failed to create flow reader: {}", e.what());
163 if ((code == std::errc::permission_denied) || (code == std::errc::operation_not_permitted))
164 {
166 }
167 return MXL_ERR_UNKNOWN;
168 }
169 catch (...)
170 {
171 return MXL_ERR_UNKNOWN;
172 }
173}
174
175extern "C"
178{
179 try
180 {
181 auto const cppInstance = to_Instance(instance);
182 auto const cppReader = to_FlowReader(reader);
183 if ((cppInstance != nullptr) && (cppReader != nullptr))
184 {
185 cppInstance->releaseReader(cppReader);
186 return MXL_STATUS_OK;
187 }
188 return MXL_ERR_INVALID_ARG;
189 }
190 catch (...)
191 {
192 return MXL_ERR_UNKNOWN;
193 }
194}
195
196extern "C"
199 bool* created)
200{
201 if ((instance == nullptr) || (flowDef == nullptr) || (writer == nullptr))
202 {
203 return MXL_ERR_INVALID_ARG;
204 }
205
206 auto flowData = std::unique_ptr<FlowData>{};
207 auto cppInstance = to_Instance(instance);
208
209 if (cppInstance == nullptr)
210 {
211 return MXL_ERR_INVALID_ARG;
212 }
213
214 try
215 {
216 static_assert(std::is_trivially_copy_assignable_v<mxlFlowConfigInfo>, "The type mxlFlowConfigInfo must be trivially copy assignable.");
217 static_assert(std::is_nothrow_copy_assignable_v<mxlFlowConfigInfo>, "Copying mxlFlowConfigInfo cannot throw.");
218
219 auto [flowConfigInfo, flowWriter, flowCreated] = cppInstance->createFlowWriter(flowDef,
220 (options == nullptr) ? std::nullopt : std::make_optional(options));
221
222 *writer = reinterpret_cast<mxlFlowWriter>(flowWriter);
223
224 if (configInfo != nullptr)
225 {
226 *configInfo = flowConfigInfo;
227 }
228 if (created != nullptr)
229 {
230 *created = flowCreated;
231 }
232 }
233 catch (std::filesystem::filesystem_error const& e)
234 {
235 MXL_ERROR("Failed to create flow writer: {}", e.what());
236 auto const code = e.code();
237 if ((code == std::errc::permission_denied) || (code == std::errc::operation_not_permitted) || (code == std::errc::read_only_file_system))
238 {
240 }
241 else
242 {
243 MXL_ERROR("Filesystem error: {}", code.message());
244 return MXL_ERR_UNKNOWN;
245 }
246 }
247 catch (std::exception const& e)
248 {
249 MXL_ERROR("Failed to create flow : {}", e.what());
250 return MXL_ERR_UNKNOWN;
251 }
252 catch (...)
253 {
254 return MXL_ERR_UNKNOWN;
255 }
256
257 return MXL_STATUS_OK;
258}
259
260extern "C"
263{
264 if ((instance == nullptr) || (writer == nullptr))
265 {
266 return MXL_ERR_INVALID_ARG;
267 }
268
269 auto err = MXL_STATUS_OK;
270 auto const cppInstance = to_Instance(instance);
271 auto const cppWriter = to_FlowWriter(writer);
272
273 if ((cppInstance == nullptr) || (cppWriter == nullptr))
274 {
275 return MXL_ERR_INVALID_ARG;
276 }
277
278 try
279 {
280 cppInstance->releaseWriter(cppWriter);
281 }
282 catch (std::exception const& ex)
283 {
284 MXL_ERROR("Failed to release writer: {}", ex.what());
285 return MXL_ERR_UNKNOWN;
286 }
287
288 return err;
289}
290
291extern "C"
294{
295 try
296 {
297 if (info != nullptr)
298 {
299 if (auto const cppReader = to_FlowReader(reader); cppReader != nullptr)
300 {
301 *info = cppReader->getFlowInfo();
302 return MXL_STATUS_OK;
303 }
305 }
306 return MXL_ERR_INVALID_ARG;
307 }
308 catch (...)
309 {
310 return MXL_ERR_UNKNOWN;
311 }
312}
313
314extern "C"
317{
318 try
319 {
320 if (info != nullptr)
321 {
322 if (auto const cppReader = to_FlowReader(reader); cppReader != nullptr)
323 {
324 *info = cppReader->getFlowInfo().config;
325 return MXL_STATUS_OK;
326 }
328 }
329 return MXL_ERR_INVALID_ARG;
330 }
331 catch (...)
332 {
333 return MXL_ERR_UNKNOWN;
334 }
335}
336
337extern "C"
340{
341 try
342 {
343 if (info != nullptr)
344 {
345 if (auto const cppReader = to_FlowReader(reader); cppReader != nullptr)
346 {
347 *info = cppReader->getFlowInfo().runtime;
348 return MXL_STATUS_OK;
349 }
351 }
352 return MXL_ERR_INVALID_ARG;
353 }
354 catch (...)
355 {
356 return MXL_ERR_UNKNOWN;
357 }
358}
359
360extern "C"
362mxlStatus mxlFlowReaderGetGrain(mxlFlowReader reader, uint64_t index, uint64_t timeoutNs, mxlGrainInfo* grainInfo, uint8_t** payload)
363{
364 return mxlFlowReaderGetGrainSlice(reader, index, MXL_GRAIN_VALID_SLICES_ALL, timeoutNs, grainInfo, payload);
365}
366
367extern "C"
369mxlStatus mxlFlowReaderGetGrainSlice(mxlFlowReader reader, uint64_t index, uint16_t minValidSlices, uint64_t timeoutNs, mxlGrainInfo* grainInfo,
370 uint8_t** payload)
371{
372 try
373 {
374 if ((grainInfo != nullptr) && (payload != nullptr))
375 {
376 if (auto const cppReader = dynamic_cast<DiscreteFlowReader*>(to_FlowReader(reader)); cppReader != nullptr)
377 {
378 return cppReader->getGrain(index, minValidSlices, toDeadline(timeoutNs), grainInfo, payload);
379 }
381 }
382 return MXL_ERR_INVALID_ARG;
383 }
384 catch (...)
385 {
386 return MXL_ERR_UNKNOWN;
387 }
388}
389
390extern "C"
396
397extern "C"
400 uint8_t** payload)
401{
402 try
403 {
404 if ((grainInfo != nullptr) && (payload != nullptr))
405 {
406 if (auto const cppReader = dynamic_cast<DiscreteFlowReader*>(to_FlowReader(reader)); cppReader != nullptr)
407 {
408 return cppReader->getGrain(index, minValidSlices, grainInfo, payload);
409 }
411 }
412 return MXL_ERR_INVALID_ARG;
413 }
414 catch (...)
415 {
416 return MXL_ERR_UNKNOWN;
417 }
418}
419
420extern "C"
423{
424 try
425 {
426 if (grainInfo != nullptr)
427 {
428 if (auto const cppWriter = dynamic_cast<DiscreteFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
429 {
430 *grainInfo = cppWriter->getGrainInfo(index);
431 return MXL_STATUS_OK;
432 }
433
435 }
436 return MXL_ERR_INVALID_ARG;
437 }
438 catch (...)
439 {
440 return MXL_ERR_UNKNOWN;
441 }
442}
443
444extern "C"
447{
448 try
449 {
450 if ((grainInfo != nullptr) && (payload != nullptr))
451 {
452 if (auto const cppWriter = dynamic_cast<DiscreteFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
453 {
454 return cppWriter->openGrain(index, grainInfo, payload);
455 }
456
458 }
459 return MXL_ERR_INVALID_ARG;
460 }
461 catch (...)
462 {
463 return MXL_ERR_UNKNOWN;
464 }
465}
466
467extern "C"
470{
471 try
472 {
473 if (auto const cppWriter = dynamic_cast<DiscreteFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
474 {
475 return cppWriter->cancel();
476 }
478 }
479 catch (...)
480 {
481 return MXL_ERR_UNKNOWN;
482 }
483}
484
485extern "C"
488{
489 if (grainInfo == nullptr)
490 {
491 return MXL_ERR_INVALID_ARG;
492 }
493
494 try
495 {
496 if (auto const cppWriter = dynamic_cast<DiscreteFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
497 {
498 return cppWriter->commit(*grainInfo);
499 }
501 }
502 catch (...)
503 {
504 return MXL_ERR_UNKNOWN;
505 }
506}
507
508extern "C"
511{
512 try
513 {
514 if (maxReadLength != nullptr)
515 {
516 if (auto const cppReader = dynamic_cast<ContinuousFlowReader*>(to_FlowReader(reader)); cppReader != nullptr)
517 {
518 *maxReadLength = cppReader->getMaxReadLength();
519 return MXL_STATUS_OK;
520 }
521
523 }
524 return MXL_ERR_INVALID_ARG;
525 }
526 catch (...)
527 {
528 return MXL_ERR_UNKNOWN;
529 }
530}
531
532extern "C"
534mxlStatus mxlFlowReaderGetSamples(mxlFlowReader reader, uint64_t index, size_t count, uint64_t timeoutNs,
535 mxlWrappedMultiBufferSlice* payloadBuffersSlices)
536{
537 try
538 {
539 if (payloadBuffersSlices != nullptr)
540 {
541 if (auto const cppReader = dynamic_cast<ContinuousFlowReader*>(to_FlowReader(reader)); cppReader != nullptr)
542 {
543 return cppReader->getSamples(index, count, toDeadline(timeoutNs), *payloadBuffersSlices);
544 }
545
547 }
548 return MXL_ERR_INVALID_ARG;
549 }
550 catch (...)
551 {
552 return MXL_ERR_UNKNOWN;
553 }
554}
555
556extern "C"
559{
560 try
561 {
562 if (payloadBuffersSlices != nullptr)
563 {
564 if (auto const cppReader = dynamic_cast<ContinuousFlowReader*>(to_FlowReader(reader)); cppReader != nullptr)
565 {
566 return cppReader->getSamples(index, count, *payloadBuffersSlices);
567 }
568
570 }
571 return MXL_ERR_INVALID_ARG;
572 }
573 catch (...)
574 {
575 return MXL_ERR_UNKNOWN;
576 }
577}
578
579extern "C"
582{
583 try
584 {
585 if (maxWriteLength != nullptr)
586 {
587 if (auto const cppWriter = dynamic_cast<ContinuousFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
588 {
589 *maxWriteLength = cppWriter->getMaxWriteLength();
590 return MXL_STATUS_OK;
591 }
592
594 }
595 return MXL_ERR_INVALID_ARG;
596 }
597 catch (...)
598 {
599 return MXL_ERR_UNKNOWN;
600 }
601}
602
603extern "C"
606{
607 try
608 {
609 if (payloadBuffersSlices != nullptr)
610 {
611 if (auto const cppWriter = dynamic_cast<ContinuousFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
612 {
613 return cppWriter->openSamples(index, count, *payloadBuffersSlices);
614 }
615
617 }
618 return MXL_ERR_INVALID_ARG;
619 }
620 catch (...)
621 {
622 return MXL_ERR_UNKNOWN;
623 }
624}
625
626extern "C"
629{
630 try
631 {
632 if (auto const cppWriter = dynamic_cast<ContinuousFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
633 {
634 return cppWriter->cancel();
635 }
637 }
638 catch (...)
639 {
640 return MXL_ERR_UNKNOWN;
641 }
642}
643
644extern "C"
647{
648 try
649 {
650 if (auto const cppWriter = dynamic_cast<ContinuousFlowWriter*>(to_FlowWriter(writer)); cppWriter != nullptr)
651 {
652 return cppWriter->commit();
653 }
655 }
656 catch (...)
657 {
658 return MXL_ERR_UNKNOWN;
659 }
660}
661
662extern "C"
665{
666 if ((info == nullptr) || (payload == nullptr))
667 {
668 return MXL_ERR_INVALID_ARG;
669 }
670 try
671 {
672 if (auto object = dynamic_cast<EventFlowWriter*>(to_FlowWriter(handle)); object != nullptr)
673 {
674 return object->openEvent(info, payload);
675 }
677 }
678 catch (...)
679 {
680 return MXL_ERR_UNKNOWN;
681 }
682}
683
684extern "C"
687{
688 if (info == nullptr)
689 {
690 return MXL_ERR_INVALID_ARG;
691 }
692 try
693 {
694 if (auto object = dynamic_cast<EventFlowWriter*>(to_FlowWriter(handle)); object != nullptr)
695 {
696 return object->commit(*info);
697 }
699 }
700 catch (...)
701 {
702 return MXL_ERR_UNKNOWN;
703 }
704}
705
706extern "C"
709{
710 try
711 {
712 if (auto object = dynamic_cast<EventFlowWriter*>(to_FlowWriter(handle)); object != nullptr)
713 {
714 return object->cancel();
715 }
717 }
718 catch (...)
719 {
720 return MXL_ERR_UNKNOWN;
721 }
722}
723
724extern "C"
726mxlStatus mxlFlowReaderGetEvent(mxlFlowReader handle, uint64_t timeoutNs, mxlEventInfo* info, uint8_t** payload)
727{
728 if ((info == nullptr) || (payload == nullptr))
729 {
730 return MXL_ERR_INVALID_ARG;
731 }
732 try
733 {
734 if (auto object = dynamic_cast<EventFlowReader*>(to_FlowReader(handle)); object != nullptr)
735 {
736 return object->getEvent(toDeadline(timeoutNs), info, payload);
737 }
739 }
740 catch (...)
741 {
742 return MXL_ERR_UNKNOWN;
743 }
744}
745
746extern "C"
749{
750 if ((info == nullptr) || (payload == nullptr))
751 {
752 return MXL_ERR_INVALID_ARG;
753 }
754 try
755 {
756 if (auto object = dynamic_cast<EventFlowReader*>(to_FlowReader(handle)); object != nullptr)
757 {
758 return object->getEvent(toDeadline(0), info, payload);
759 }
761 }
762 catch (...)
763 {
764 return MXL_ERR_UNKNOWN;
765 }
766}
767
768extern "C"
771{
772 try
773 {
774 auto const cppInstance = to_Instance(instance);
775 if (cppInstance != nullptr)
776 {
777 *group = reinterpret_cast<mxlFlowSynchronizationGroup>(cppInstance->createFlowSynchronizationGroup());
778 return MXL_STATUS_OK;
779 }
780
781 return MXL_ERR_INVALID_ARG;
782 }
783 catch (...)
784 {
785 return MXL_ERR_UNKNOWN;
786 }
787}
788
789extern "C"
792{
793 try
794 {
795 auto const cppInstance = to_Instance(instance);
796 auto const cppGroup = to_FlowSynchronizationGroup(group);
797 if ((cppInstance != nullptr) && (cppGroup != nullptr))
798 {
799 cppInstance->releaseFlowSynchronizationGroup(cppGroup);
800 return MXL_STATUS_OK;
801 }
802
803 return MXL_ERR_INVALID_ARG;
804 }
805 catch (...)
806 {
807 return MXL_ERR_UNKNOWN;
808 }
809}
810
811extern "C"
814{
815 try
816 {
817 if (auto const cppGroup = to_FlowSynchronizationGroup(group); cppGroup != nullptr)
818 {
819 if (auto const cppReader = to_FlowReader(reader); cppReader != nullptr)
820 {
821 if (auto const discreteReader = dynamic_cast<DiscreteFlowReader const*>(cppReader); discreteReader != nullptr)
822 {
823 cppGroup->addReader(*discreteReader, MXL_GRAIN_VALID_SLICES_ALL);
824 return MXL_STATUS_OK;
825 }
826 if (auto const continuousReader = dynamic_cast<ContinuousFlowReader const*>(cppReader); continuousReader != nullptr)
827 {
828 cppGroup->addReader(*continuousReader);
829 return MXL_STATUS_OK;
830 }
831 }
832
834 }
835
836 return MXL_ERR_INVALID_ARG;
837 }
838 catch (...)
839 {
840 return MXL_ERR_UNKNOWN;
841 }
842}
843
844extern "C"
847{
848 try
849 {
850 if (auto const cppGroup = to_FlowSynchronizationGroup(group); cppGroup != nullptr)
851 {
852 if (auto const cppReader = dynamic_cast<DiscreteFlowReader const*>(to_FlowReader(reader)); cppReader != nullptr)
853 {
854 cppGroup->addReader(*cppReader, minValidSlices);
855 return MXL_STATUS_OK;
856 }
857
859 }
860
861 return MXL_ERR_INVALID_ARG;
862 }
863 catch (...)
864 {
865 return MXL_ERR_UNKNOWN;
866 }
867}
868
869extern "C"
872{
873 try
874 {
875 auto const cppGroup = to_FlowSynchronizationGroup(group);
876 auto const cppReader = to_FlowReader(reader);
877 if ((cppGroup != nullptr) && (cppReader != nullptr))
878 {
879 cppGroup->removeReader(*cppReader);
880 return MXL_STATUS_OK;
881 }
882
883 return MXL_ERR_INVALID_ARG;
884 }
885 catch (...)
886 {
887 return MXL_ERR_UNKNOWN;
888 }
889}
890
891extern "C"
894{
895 try
896 {
897 if (auto const cppGroup = to_FlowSynchronizationGroup(group); cppGroup != nullptr)
898 {
899 return cppGroup->waitForDataAt(Timepoint{static_cast<std::int64_t>(timestamp)}, toDeadline(timeoutNs));
900 }
901
902 return MXL_ERR_INVALID_ARG;
903 }
904 catch (...)
905 {
906 return MXL_ERR_UNKNOWN;
907 }
908}
#define MXL_ERROR(...)
Definition Logging.hpp:67
Paths and filenames utilities used by the MXL SDK.
Backend contract for reading complete event entries or fragments in queue order. Each reader has one ...
Backend contract for a single event producer with private write staging. Callers guarantee one writer...
MXL_EXPORT mxlStatus mxlCreateFlowReader(mxlInstance instance, char const *flowId, char const *, mxlFlowReader *reader)
Definition flow.cpp:136
MXL_EXPORT mxlStatus mxlFlowWriterCommitGrain(mxlFlowWriter writer, mxlGrainInfo const *grainInfo)
Definition flow.cpp:487
MXL_EXPORT mxlStatus mxlFlowReaderGetEvent(mxlFlowReader handle, uint64_t timeoutNs, mxlEventInfo *info, uint8_t **payload)
Definition flow.cpp:726
MXL_EXPORT mxlStatus mxlReleaseFlowReader(mxlInstance instance, mxlFlowReader reader)
Definition flow.cpp:177
MXL_EXPORT mxlStatus mxlFlowSynchronizationGroupRemoveReader(mxlFlowSynchronizationGroup group, mxlFlowReader reader)
Definition flow.cpp:871
MXL_EXPORT mxlStatus mxlFlowReaderGetGrainSlice(mxlFlowReader reader, uint64_t index, uint16_t minValidSlices, uint64_t timeoutNs, mxlGrainInfo *grainInfo, uint8_t **payload)
Definition flow.cpp:369
MXL_EXPORT mxlStatus mxlFlowSynchronizationGroupWaitForDataAt(mxlFlowSynchronizationGroup group, uint64_t timestamp, uint64_t timeoutNs)
Definition flow.cpp:893
MXL_EXPORT mxlStatus mxlFlowReaderGetMaxReadLengthSamples(mxlFlowReader reader, size_t *maxReadLength)
Definition flow.cpp:510
MXL_EXPORT mxlStatus mxlCreateFlowSynchronizationGroup(mxlInstance instance, mxlFlowSynchronizationGroup *group)
Definition flow.cpp:770
MXL_EXPORT mxlStatus mxlFlowReaderGetGrainSliceNonBlocking(mxlFlowReader reader, uint64_t index, uint16_t minValidSlices, mxlGrainInfo *grainInfo, uint8_t **payload)
Definition flow.cpp:399
MXL_EXPORT mxlStatus mxlFlowReaderGetSamplesNonBlocking(mxlFlowReader reader, uint64_t index, size_t count, mxlWrappedMultiBufferSlice *payloadBuffersSlices)
Definition flow.cpp:558
MXL_EXPORT mxlStatus mxlFlowReaderGetGrain(mxlFlowReader reader, uint64_t index, uint64_t timeoutNs, mxlGrainInfo *grainInfo, uint8_t **payload)
Definition flow.cpp:362
MXL_EXPORT mxlStatus mxlFlowWriterCommitSamples(mxlFlowWriter writer)
Definition flow.cpp:646
MXL_EXPORT mxlStatus mxlReleaseFlowSynchronizationGroup(mxlInstance instance, mxlFlowSynchronizationGroup group)
Definition flow.cpp:791
MXL_EXPORT mxlStatus mxlFlowWriterGetGrainInfo(mxlFlowWriter writer, uint64_t index, mxlGrainInfo *grainInfo)
Definition flow.cpp:422
MXL_EXPORT mxlStatus mxlFlowSynchronizationGroupAddReader(mxlFlowSynchronizationGroup group, mxlFlowReader reader)
Definition flow.cpp:813
MXL_EXPORT mxlStatus mxlFlowSynchronizationGroupAddPartialGrainReader(mxlFlowSynchronizationGroup group, mxlFlowReader reader, uint16_t minValidSlices)
Definition flow.cpp:846
MXL_EXPORT mxlStatus mxlFlowWriterCancelSamples(mxlFlowWriter writer)
Definition flow.cpp:628
MXL_EXPORT mxlStatus mxlFlowReaderGetSamples(mxlFlowReader reader, uint64_t index, size_t count, uint64_t timeoutNs, mxlWrappedMultiBufferSlice *payloadBuffersSlices)
Definition flow.cpp:534
MXL_EXPORT mxlStatus mxlFlowWriterGetMaxWriteLengthSamples(mxlFlowWriter writer, size_t *maxWriteLength)
Definition flow.cpp:581
MXL_EXPORT mxlStatus mxlFlowWriterCommitEvent(mxlFlowWriter handle, mxlEventInfo const *info)
Definition flow.cpp:686
MXL_EXPORT mxlStatus mxlReleaseFlowWriter(mxlInstance instance, mxlFlowWriter writer)
Definition flow.cpp:262
MXL_EXPORT mxlStatus mxlFlowReaderGetRuntimeInfo(mxlFlowReader reader, mxlFlowRuntimeInfo *info)
Definition flow.cpp:339
MXL_EXPORT mxlStatus mxlFlowReaderGetConfigInfo(mxlFlowReader reader, mxlFlowConfigInfo *info)
Definition flow.cpp:316
MXL_EXPORT mxlStatus mxlFlowWriterOpenGrain(mxlFlowWriter writer, uint64_t index, mxlGrainInfo *grainInfo, uint8_t **payload)
Definition flow.cpp:446
MXL_EXPORT mxlStatus mxlFlowReaderGetInfo(mxlFlowReader reader, mxlFlowInfo *info)
Definition flow.cpp:293
MXL_EXPORT mxlStatus mxlFlowWriterOpenEvent(mxlFlowWriter handle, mxlEventInfo *info, uint8_t **payload)
Definition flow.cpp:664
MXL_EXPORT mxlStatus mxlFlowWriterCancelGrain(mxlFlowWriter writer)
Definition flow.cpp:469
MXL_EXPORT mxlStatus mxlCreateFlowWriter(mxlInstance instance, char const *flowDef, char const *options, mxlFlowWriter *writer, mxlFlowConfigInfo *configInfo, bool *created)
Definition flow.cpp:198
MXL_EXPORT mxlStatus mxlFlowWriterOpenSamples(mxlFlowWriter writer, uint64_t index, size_t count, mxlMutableWrappedMultiBufferSlice *payloadBuffersSlices)
Definition flow.cpp:605
MXL_EXPORT mxlStatus mxlFlowReaderGetEventNonBlocking(mxlFlowReader handle, mxlEventInfo *info, uint8_t **payload)
Attempt to read one event entry without waiting for publication.
Definition flow.cpp:748
MXL_EXPORT mxlStatus mxlFlowWriterCancelEvent(mxlFlowWriter handle)
Cancel the open event without publishing or changing timestamp ordering.
Definition flow.cpp:708
MXL_EXPORT mxlStatus mxlFlowReaderGetGrainNonBlocking(mxlFlowReader reader, uint64_t index, mxlGrainInfo *grainInfo, uint8_t **payload)
Definition flow.cpp:392
MXL_EXPORT mxlStatus mxlIsFlowActive(mxlInstance instance, char const *flowId, bool *isActive)
Definition flow.cpp:28
MXL_EXPORT mxlStatus mxlGetFlowDef(mxlInstance instance, char const *flowId, char *buffer, size_t *bufferSize)
Definition flow.cpp:86
Public flow reader, writer, payload and synchronization APIs.
struct mxlFlowReader_t * mxlFlowReader
Definition flow.h:205
struct mxlGrainInfo_t mxlGrainInfo
struct mxlEventInfo_t mxlEventInfo
Metadata for one event queue entry, either a complete event or a fragment.
struct mxlWrappedMultiBufferSlice_t mxlWrappedMultiBufferSlice
struct mxlFlowWriter_t * mxlFlowWriter
Definition flow.h:206
struct mxlMutableWrappedMultiBufferSlice_t mxlMutableWrappedMultiBufferSlice
struct mxlFlowSynchronizationGroup_t * mxlFlowSynchronizationGroup
Definition flow.h:208
#define MXL_GRAIN_VALID_SLICES_ALL
Definition flow.h:45
struct mxlFlowRuntimeInfo_t mxlFlowRuntimeInfo
struct mxlFlowConfigInfo_t mxlFlowConfigInfo
struct mxlFlowInfo_t mxlFlowInfo
mxlStatus
MXL SDK Status codes.
Definition mxl.h:22
@ MXL_ERR_UNKNOWN
Definition mxl.h:27
@ MXL_ERR_PERMISSION_DENIED
Definition mxl.h:37
@ MXL_ERR_FLOW_NOT_FOUND
Definition mxl.h:29
@ MXL_ERR_INVALID_ARG
Definition mxl.h:35
@ MXL_ERR_INVALID_FLOW_WRITER
Definition mxl.h:33
@ MXL_STATUS_OK
Definition mxl.h:23
@ MXL_ERR_INVALID_FLOW_READER
Definition mxl.h:32
struct mxlInstance_t * mxlInstance
Definition mxl.h:74
FlowWriter * to_FlowWriter(mxlFlowWriter writer) noexcept
Utility function to convert from a C mxlFlowWriter handle to a C++ FlowWriter instance.
Definition Instance.hpp:257
std::filesystem::path makeFlowDataFilePath(std::filesystem::path const &flowDirectory)
Definition PathUtils.cpp:17
FlowReader * to_FlowReader(mxlFlowReader reader) noexcept
Utility function to convert from a C mxlFlowReader handle to a C++ FlowReader instance.
Definition Instance.hpp:252
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.
FlowSynchronizationGroup * to_FlowSynchronizationGroup(mxlFlowSynchronizationGroup group) noexcept
Utility function to convert from a C mxlFlowSynchronizationGroup handle to a C++ FlowSynchronizationG...
Definition Instance.hpp:262
Instance * to_Instance(mxlInstance instance) noexcept
Utility function to convert from a C mxlInstance handle to a C++ Instance class.
Definition Instance.hpp:247
#define MXL_EXPORT
Definition platform.h:9
bool active
uint8_t * buffer
Set a mark at the beginning and the end of the grain payload.
mxlFlowConfigInfo configInfo
mxlFlowReader reader
mxlFlowWriter writer
auto const flowId
uint64_t index
auto flowDef
auto const timestamp
Definition test_time.cpp:61
auto const currentTime
Definition test_time.cpp:58