Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
output-slot-protocol-test.cpp
Go to the documentation of this file.
1/*
2 OutputSlotProtocol(Test) - covering the basic usage cycle of an output slot
3
4 Copyright (C)
5 2011, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
20
25
26
27
28namespace steam {
29namespace play {
30namespace test {
31
35
36
37
38
39 /***************************************************************/
46 class OutputSlotProtocol_test : public Test
47 {
48 virtual void
49 run (Arg)
50 {
52 }
53
54
55 void
57 {
58 // Create Test fixture.
59 // In real usage, the OutputSlot will be preconfigured
60 // (Media format, number of channels, physical connections)
61 // and then registered with / retrieved from an OutputManager
63
64 // Client claims the OutputSlot
65 // and opens it for exclusive use.
66 OutputSlot::Allocation& alloc = oSlot.allocate();
67
68 // Now the client is able to prepare
69 // "calculation streams" for the individual
70 // Channels to be output through this slot.
72 DataSink sink1 = *sinks;
73 DataSink sink2 = *++sinks;
74
75 // within the frame-calculation "loop"
76 // we perform a data exchange cycle
77 FrameCnt frameNr = 123;
78 BuffHandle buff00 = sink1.lockBufferFor (frameNr);
79 BuffHandle buff10 = sink2.lockBufferFor (frameNr);
80
81 // rendering process calculates content....
82 buff00.accessAs<TestFrame>() = testData(0,0);
83
84 // while further frames might be processed in parallel
85 BuffHandle buff11 = sink2.lockBufferFor (++frameNr);
86 buff11.accessAs<TestFrame>() = testData(1,1);
87 buff10.accessAs<TestFrame>() = testData(1,0);
88
89 // Now it's time to emit the output
90 sink2.emit (frameNr-1, buff10);
91 sink2.emit (frameNr , buff11);
92 sink1.emit (frameNr-1, buff00);
93 // that's all for the client
94
95 // Verify sane operation....
97 CHECK ( checker.frame_was_allocated (0,123));
98 CHECK (!checker.frame_was_allocated (0,124));
99 CHECK ( checker.frame_was_allocated (1,123));
100 CHECK ( checker.frame_was_allocated (1,124));
101
102 CHECK (checker.output_was_closed (0,0));
103 CHECK (checker.output_was_closed (1,0));
104 CHECK (checker.output_was_closed (1,1));
105
106 CHECK ( checker.output_was_emitted (0,0));
107 CHECK (!checker.output_was_emitted (0,1));
108 CHECK ( checker.output_was_emitted (1,0));
109 CHECK ( checker.output_was_emitted (1,1));
110
111 DiagnosticOutputSlot::OutFrames stream0 = checker.getChannel(0);
112 DiagnosticOutputSlot::OutFrames stream1 = checker.getChannel(1);
113
114 CHECK ( stream0);
115 CHECK (*stream0 == testData(0,0)); ++stream0;
116 CHECK (!stream0);
117
118 CHECK ( stream1);
119 CHECK (*stream1 == testData(1,0)); ++stream1;
120 CHECK (*stream1 == testData(1,1)); ++stream1;
121 CHECK (!stream1);
122 }
123 };
124
125
128
129
130
131}}} // namespace steam::play::test
Extension to allow placing objects right into the buffers, taking ownership.
A front-end to support the buffer management within the render nodes.
Handle for a buffer for processing data, abstracting away the actual implementation.
BU & accessAs()
convenience shortcut: access the buffer contents casted to a specific type.
Mock data frame for simulated rendering.
Definition testframe.hpp:69
denotes an opened connection ready to receive media data for output.
BuffHandle lockBufferFor(FrameID)
void emit(FrameID, BuffHandle const &, TimeValue currentTime=Time::ANYTIME)
Helper for unit tests: Mock output sink.
bool output_was_emitted(uint channel, FrameID outputFrame)
static OutputSlot & build()
build a new Diagnostic Output Slot instance, discard the existing one.
bool frame_was_allocated(uint channel, FrameID nominalFrame)
bool output_was_closed(uint channel, FrameID outputFrame)
static DiagnosticOutputSlot & access(OutputSlot &to_investigate)
virtual OpenedSinks getOpenedSinks()=0
Interface: Generic output sink.
Allocation & allocate()
claim this slot for exclusive use
An facility for writing unit-tests against the OutputSlot interface.
TestFrame & testData(uint seqNr, uint chanNr)
Helper to access a specific frame of test data at a fixed memory location.
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Unit test helper to generate fake test data frames.