|
MXL : Media eXchange Layer
MXL
|
#include <chrono>#include <cstdint>#include <cstdlib>#include <cstring>#include <ctime>#include <filesystem>#include <fstream>#include <memory>#include <string>#include <thread>#include <utility>#include <uuid.h>#include <catch2/catch_test_macros.hpp>#include <picojson/wrapper.h>#include <mxl/flow.h>#include <mxl/mxl.h>#include <mxl/time.h>#include "../internal/include/mxl-internal/MediaUtils.hpp"#include "PcapReader.hpp"#include "Utils.hpp"
Go to the source code of this file.
Classes | |
| struct | BatchIndexAndSize |
Variables | |
| bool | active = false |
| uint8_t * | buffer = nullptr |
| Set a mark at the beginning and the end of the grain payload. | |
| mxlFlowConfigInfo | configInfo |
| auto | fillPayloadSize = fillPayloadStrideSize * h |
| auto | fillPayloadStrideSize = mxl::lib::getV210LineLength(w) |
| gInfo | flags = MXL_GRAIN_FLAG_INVALID |
| Mark the grain as invalid. | |
| auto | flowDef = mxl::tests::readFile("data/v210a_flow.json") |
| auto const | flowId = "5fbec3b1-1b0f-417d-9059-8b94a47197ed" |
| bool | flowWasCreated = false |
| mxlGrainInfo | gInfo |
| Open the grain. | |
| constexpr auto | h = 1080 |
| uint64_t | index = mxlTimestampToIndex(&rate, now) |
| auto | instanceReader = mxlCreateInstance(domain.string().c_str(), opts) |
| auto | instanceWriter = mxlCreateInstance(domain.string().c_str(), opts) |
| auto | keyPayloadSize = keyPayloadStrideSize * h |
| auto | keyPayloadStrideSize = static_cast<std::size_t>((w + 2) / 3 * 4) |
| auto const | now = mxlGetTime() |
| auto const | rate = mxlRational{60000, 1001} |
| Compute the grain index for the flow rate and current TAI time. | |
| mxlFlowReader | reader |
| mxlFlowRuntimeInfo | runtimeInfo1 |
| Get some info about the freshly created flow. Since no grains have been commited, the head should still be at 0. | |
| mxlFlowRuntimeInfo | runtimeInfo2 |
| Get the updated flow info. | |
| constexpr auto | w = 1920 |
| mxlFlowWriter | writer |
| mxlDestroyInstance | ( | instanceReader | ) |
| mxlDestroyInstance | ( | instanceWriter | ) |
| std::vector< BatchIndexAndSize > planAudioBatches | ( | std::size_t | numOfBatches, |
| std::size_t | numOfSamples, | ||
| std::uint64_t | lastBatchIndex ) |
Prepares reading or writing batches in a way that the given numOfSamples are split into numOfBatches batches, which can be read or written. The batch with the lowest index (containing the "oldest" data) is the first one.
Definition at line 879 of file test_flows.cpp.
| REQUIRE | ( | active | = =true | ) |
| REQUIRE | ( | buffer | [0] = =0xCA | ) |
Confirm that the marks are still present.
| REQUIRE | ( | buffer | [gInfo.grainSize - 1] = =0xFE | ) |
| REQUIRE | ( | configInfo.common.grainRate. | numerator = =48000U | ) |
| REQUIRE | ( | configInfo.continuous. | bufferLength, |
| 128U | ) |
| REQUIRE | ( | configInfo.continuous. | channelCount = =2U | ) |
| REQUIRE | ( | configInfo.discrete. | sliceSizes[0] = =fillPayloadStrideSize | ) |
| REQUIRE | ( | configInfo.discrete. | sliceSizes[1] = =keyPayloadStrideSize | ) |
| REQUIRE | ( | configInfo.discrete. | sliceSizes[2] = =0 | ) |
| REQUIRE | ( | configInfo.discrete. | sliceSizes[3] = =0 | ) |
| REQUIRE | ( | flowWasCreated | ) |
| REQUIRE | ( | gInfo. | grainSize = =(fillPayloadSize+keyPayloadSize) | ) |
Confirm that the flags are preserved.
| REQUIRE | ( | index ! | = MXL_UNDEFINED_INDEX | ) |
| REQUIRE | ( | instanceReader ! | = nullptr | ) |
| REQUIRE | ( | instanceWriter ! | = nullptr | ) |
| REQUIRE | ( | mxlCreateFlowReader(instanceReader, flowId, "", &reader) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlCreateFlowWriter(instanceWriter, flowDef.c_str(), "", &writer, &configInfo, &flowWasCreated) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlCreateFlowWriter(instanceWriter, flowDef.c_str(), opts, &writer, &configInfo, &flowWasCreated) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlFlowReaderGetGrain(reader, index, 16, &gInfo, &buffer) | = =MXL_STATUS_OK | ) |
Read back the grain using a flow reader.
| REQUIRE | ( | mxlFlowReaderGetRuntimeInfo(reader, &runtimeInfo1) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlFlowReaderGetRuntimeInfo(reader, &runtimeInfo2) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlFlowReaderGetSamplesNonBlocking(reader, index, 64U, &payloadBuffersSlices) | = =MXL_ERR_FLOW_INVALID | ) |
| REQUIRE | ( | mxlFlowWriterCommitGrain(writer, &gInfo) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlFlowWriterOpenGrain(writer, index, &gInfo, &buffer) | = =MXL_STATUS_OK | ) |
Open the grain for writing.
| REQUIRE | ( | mxlFlowWriterOpenGrain(writer,++index, &gInfo, &buffer) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlIsFlowActive(instanceReader, flowId, &active) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | mxlReleaseFlowReader(instanceReader, reader) | = =MXL_STATUS_OK | ) |
Release the reader.
| REQUIRE | ( | mxlReleaseFlowWriter(instanceWriter, writer) | = =MXL_STATUS_OK | ) |
| REQUIRE | ( | runtimeInfo1. | headIndex = =0 | ) |
| REQUIRE | ( | runtimeInfo2. | headIndex = =index | ) |
Confirm that that head has moved.
| REQUIRE | ( | runtimeInfo2. | lastReadTime, |
| runtimeInfo1. | lastReadTime ) |
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Audio Flow : Create/Destroy" | , | ||
| "" | [mxl flows] ) |
Compute the grain index for the flow rate and current TAI time.
Open a range of samples for writing
Get some info about the freshly created flow. Since no grains have been commited, the head should still be at 0.
Commit the sample range
Open a range of samples for reading
Release the reader
Definition at line 701 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Audio Flow : Different writer / reader batch size" | , | ||
| "" | [mxl flows] ) |
Definition at line 898 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Audio Flow : Jump forward" | , | ||
| "" | [mxl flows] ) |
Definition at line 1193 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Audio Flow : Options" | , | ||
| "" | [mxl flows] ) |
Definition at line 969 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Data Flow : Create/Destroy" | , | ||
| "" | [mxl flows] ) |
Compute the grain index for the flow rate and current TAI time.
Open the grain.
Open the grain for writing.
ANC Grains are always 4KiB
Get some info about the freshly created flow. Since no grains have been commited, the head should still be at 0.
Mark the grain as invalid
Read back the grain using a flow reader.
Confirm that the flags are preserved.
Confirm that our original RFC-8331 packet is still there
Get the updated flow info
Confirm that that head has moved.
Delete the reader
Definition at line 468 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Flow definitions and options with numbers that do not fit" | , | ||
| "" | [mxl flows] ) |
Definition at line 289 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Flow definitions with a non-positive rate" | , | ||
| "" | [mxl flows] ) |
Definition at line 1377 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Invalid flow definitions" | , | ||
| "" | [mxl flows] ) |
Definition at line 364 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "mxlCreateFlow: unwritable domain" | , | ||
| "" | [mxl flows] ) |
Definition at line 1064 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "mxlCreateFlowReader: unreadable continuous flow descriptor" | , | ||
| "" | [mxl flows] ) |
Definition at line 1114 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "mxlCreateFlowReader: unreadable flow directory" | , | ||
| "" | [mxl flows] ) |
Definition at line 1085 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "mxlFlowWriterCommitSamples should notify the reader" | , | ||
| "" | [mxl flows][futex] ) |
Definition at line 1140 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "mxlGetFlowDef" | , | ||
| "" | [mxl flows] ) |
Definition at line 1017 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : commit rejects an inconsistent grain header" | , | ||
| "" | [mxl flows] ) |
Definition at line 1423 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : Create/Destroy" | , | ||
| "" | [mxl flows] ) |
Compute the grain index for the flow rate and current TAI time.
Open the grain.
Open the grain for writing.
Set a mark at the beginning and the end of the grain payload.
Get some info about the freshly created flow. Since no grains have been commited, the head should still be at 0.
Mark the grain as invalid
Read back the grain using a flow reader.
Confirm that the flags are preserved.
Confirm that the marks are still present.
Get the updated flow info
Confirm that that head has moved.
Release the reader
Set a mark at the beginning and the end of the grain payload.
Definition at line 27 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : Jump forward" | , | ||
| "" | [mxl flows] ) |
Definition at line 1305 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : Options" | , | ||
| "" | [mxl flows] ) |
Definition at line 567 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : reader rejects an inconsistent grain header" | , | ||
| "" | [mxl flows] ) |
Definition at line 1477 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : Reopen an incomplete grain after a jump of a full ring" | , | ||
| "" | [mxl flows] ) |
Definition at line 1613 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : Slices" | , | ||
| "" | [mxl flows] ) |
Compute the grain index for the flow rate and current TAI time.
Open the grain.
Get some info about the freshly created flow. Since no grains have been commited, the head should still be at 0.
Write a slice to the grain.
Read back the partial grain using the flow reader.
Definition at line 615 of file test_flows.cpp.
| TEST_CASE_PERSISTENT_FIXTURE | ( | mxl::tests::mxlDomainFixture | , |
| "Video Flow : validSlices on grain open" | , | ||
| "" | [mxl flows] ) |
Definition at line 1540 of file test_flows.cpp.
| bool active = false |
Definition at line 141 of file test_flows.cpp.
| uint8_t * buffer = nullptr |
Set a mark at the beginning and the end of the grain payload.
Definition at line 170 of file test_flows.cpp.
| mxlFlowConfigInfo configInfo |
Definition at line 150 of file test_flows.cpp.
| auto fillPayloadSize = fillPayloadStrideSize * h |
Definition at line 179 of file test_flows.cpp.
| auto fillPayloadStrideSize = mxl::lib::getV210LineLength(w) |
Definition at line 178 of file test_flows.cpp.
| gInfo flags = MXL_GRAIN_FLAG_INVALID |
Mark the grain as invalid.
Definition at line 200 of file test_flows.cpp.
| auto const flowDef = mxl::tests::readFile("data/v210a_flow.json") |
Definition at line 140 of file test_flows.cpp.
| auto const flowId = "5fbec3b1-1b0f-417d-9059-8b94a47197ed" |
Definition at line 139 of file test_flows.cpp.
| bool flowWasCreated = false |
Definition at line 151 of file test_flows.cpp.
| mxlGrainInfo gInfo |
Open the grain.
Definition at line 169 of file test_flows.cpp.
|
constexpr |
Definition at line 176 of file test_flows.cpp.
| auto const index = mxlTimestampToIndex(&rate, now) |
Definition at line 165 of file test_flows.cpp.
| auto instanceReader = mxlCreateInstance(domain.string().c_str(), opts) |
Definition at line 143 of file test_flows.cpp.
| auto instanceWriter = mxlCreateInstance(domain.string().c_str(), opts) |
Definition at line 146 of file test_flows.cpp.
| auto keyPayloadSize = keyPayloadStrideSize * h |
Definition at line 183 of file test_flows.cpp.
| auto keyPayloadStrideSize = static_cast<std::size_t>((w + 2) / 3 * 4) |
Definition at line 182 of file test_flows.cpp.
| auto const now = mxlGetTime() |
Definition at line 164 of file test_flows.cpp.
| auto const rate = mxlRational{60000, 1001} |
Compute the grain index for the flow rate and current TAI time.
Definition at line 163 of file test_flows.cpp.
| mxlFlowReader reader |
Definition at line 155 of file test_flows.cpp.
| mxlFlowRuntimeInfo runtimeInfo1 |
Get some info about the freshly created flow. Since no grains have been commited, the head should still be at 0.
Definition at line 195 of file test_flows.cpp.
| mxlFlowRuntimeInfo runtimeInfo2 |
Get the updated flow info.
Definition at line 217 of file test_flows.cpp.
|
constexpr |
Definition at line 175 of file test_flows.cpp.
| mxlFlowWriter writer |
Definition at line 149 of file test_flows.cpp.