2 * Copyright 2017, Dario Casalinuovo. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 #include <SimpleMediaClient.h>
9 #include <MediaConnection.h>
10 #include <SupportDefs.h>
18 #define DELAYED_MODE 1
19 #define SNOOZE_FOR 10000000
23 static BSimpleMediaClient
* sProducer
= NULL
;
24 static BSimpleMediaClient
* sConsumer
= NULL
;
25 static BSimpleMediaClient
* sFilter
= NULL
;
29 _InitClients(bool hasFilter
)
31 sProducer
= new BSimpleMediaClient("MediaClientProducer");
32 sConsumer
= new BSimpleMediaClient("MediaClientConsumer");
35 sFilter
= new BSimpleMediaClient("MediaClientFilter");
51 _BuildRawAudioFormat()
54 format
.type
= B_MEDIA_RAW_AUDIO
;
55 format
.u
.raw_audio
= media_multi_audio_format::wildcard
;
62 _ConsumerProducerTest()
66 BSimpleMediaOutput
* output
= sProducer
->BeginOutput();
67 BSimpleMediaInput
* input
= sConsumer
->BeginInput();
69 output
->SetAcceptedFormat(_BuildRawAudioFormat());
70 input
->SetAcceptedFormat(_BuildRawAudioFormat());
72 assert(sConsumer
->Connect(input
, output
) == B_OK
);
78 assert(sConsumer
->Disconnect() == B_OK
);
85 _ProducerConsumerTest()
89 BMediaOutput
* output
= sProducer
->BeginOutput();
90 BMediaInput
* input
= sConsumer
->BeginInput();
92 assert(sProducer
->Connect(output
, input
) == B_OK
);
98 assert(sProducer
->Disconnect() == B_OK
);
105 _ProducerFilterConsumerTest()
109 BMediaOutput
* output
= sProducer
->BeginOutput();
110 BMediaInput
* input
= sConsumer
->BeginInput();
112 BMediaInput
* filterInput
= sFilter
->BeginInput();
113 BMediaOutput
* filterOutput
= sFilter
->BeginOutput();
115 assert(sFilter
->Bind(filterInput
, filterOutput
) == B_OK
);
117 assert(sProducer
->Connect(output
, filterInput
) == B_OK
);
118 assert(sFilter
->Connect(filterOutput
, input
) == B_OK
);
123 assert(sFilter
->Disconnect() == B_OK
);
132 printf("Testing Simple (1:1) Producer-Consumer configuration: ");
133 _ConsumerProducerTest();
134 _ProducerConsumerTest();
137 printf("Testing Simple (1:1:1) Producer-Filter-Consumer configuration: ");
138 _ProducerFilterConsumerTest();