MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
event_ipc_worker.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3
7
8#include <string>
9#include <unistd.h>
10#include <mxl/flow.h>
11
19int main(int argc, char** argv)
20{
21 if (argc != 7)
22 {
23 return 1;
24 }
25 auto const offset = std::stoull(argv[3]);
26 auto const count = std::stoull(argv[4]);
27 auto instance = mxlCreateInstance(argv[1], "{}");
28 auto reader = mxlFlowReader{};
29 if ((instance == nullptr) || (mxlCreateFlowReader(instance, argv[2], "", &reader) != MXL_STATUS_OK))
30 {
31 return 2;
32 }
33 auto ready = 'R';
34 if ((::write(std::stoi(argv[5]), &ready, 1) != 1) || (::read(std::stoi(argv[6]), &ready, 1) != 1))
35 {
36 return 3;
37 }
38 for (auto i = std::uint64_t{0}; i < count; ++i)
39 {
40 auto info = mxlEventInfo{};
41 auto payload = static_cast<std::uint8_t*>(nullptr);
42 if ((mxlFlowReaderGetEvent(reader, 5000000000ULL, &info, &payload) != MXL_STATUS_OK) || (info.timestamp != offset + i) ||
43 (info.offset != 0) || (info.complete != 1) || (info.eventSize != info.timestamp % (MXL_DATA_FORMAT_GRAIN_SIZE + 1)))
44 {
45 return 4;
46 }
47 for (auto byte = std::uint32_t{0}; byte < info.eventSize; ++byte)
48 {
49 if (payload[byte] != static_cast<std::uint8_t>((info.timestamp * 29) + (std::uint64_t{byte} * 7)))
50 {
51 return 5;
52 }
53 }
54 }
55 if ((mxlReleaseFlowReader(instance, reader) != MXL_STATUS_OK) || (mxlDestroyInstance(instance) != MXL_STATUS_OK))
56 {
57 return 6;
58 }
59 return 0;
60}
int main(void)
Definition all_headers.c:9
#define MXL_DATA_FORMAT_GRAIN_SIZE
Definition dataformat.h:15
Public flow reader, writer, payload and synchronization APIs.
MXL_EXPORT mxlStatus mxlFlowReaderGetEvent(mxlFlowReader reader, uint64_t timeoutNs, mxlEventInfo *event, uint8_t **payload)
Definition flow.cpp:726
MXL_EXPORT mxlStatus mxlReleaseFlowReader(mxlInstance instance, mxlFlowReader reader)
Definition flow.cpp:177
struct mxlFlowReader_t * mxlFlowReader
Definition flow.h:205
struct mxlEventInfo_t mxlEventInfo
Metadata for one event queue entry, either a complete event or a fragment.
MXL_EXPORT mxlStatus mxlCreateFlowReader(mxlInstance instance, char const *flowId, char const *options, mxlFlowReader *reader)
Definition flow.cpp:136
MXL_EXPORT mxlStatus mxlDestroyInstance(mxlInstance in_instance)
Definition mxl.cpp:106
@ MXL_STATUS_OK
Definition mxl.h:23
MXL_EXPORT mxlInstance mxlCreateInstance(char const *in_mxlDomain, char const *in_options)
Definition mxl.cpp:45
mxlFlowReader reader