YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
mjpeg.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/all.h>
7#include <yarp/os/Network.h>
8#include <yarp/sig/all.h>
9
10#include <catch2/catch_amalgamated.hpp>
11#include <harness.h>
12
13using namespace yarp::os;
14using namespace yarp::sig;
15
16TEST_CASE("carriers::mjpeg", "[carriers]")
17{
18 YARP_REQUIRE_PLUGIN("mjpeg", "carrier");
19
20#if defined(DISABLE_FAILING_VALGRIND_TESTS)
21 YARP_SKIP_TEST("Skipping failing tests under valgrind")
22#endif
23
24 Network::setLocalMode(true);
25
26 SECTION("test compression-decompression")
27 {
28 std::string inName {"/mjpeg/in"};
29 std::string outName {"/mjpeg/out"};
30
33
34 REQUIRE(in.open(inName));
35 REQUIRE(out.open(outName));
36 REQUIRE(Network::connect(out.getName(), in.getName(), "mjpeg"));
37
38 size_t width {160};
39 size_t height {120};
40 ImageOf<PixelRgb>& outImg = out.prepare();
41 outImg.resize(width, height);
42
43 out.write();
45
47 REQUIRE(inImg != nullptr);
48 CHECK(inImg->width() == width);
49 CHECK(inImg->height() == height);
50
51 in.interrupt();
52 in.close();
53 out.interrupt();
54 out.close();
55 }
56
57 Network::setLocalMode(false);
58}
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
TEST_CASE("carriers::mjpeg", "[carriers]")
Definition mjpeg.cpp:16
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
An interface to the operating system, including Port based communication.