summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-09-23 16:51:10 +0100
committerCarl Hetherington <cth@carlh.net>2012-09-23 16:51:10 +0100
commit6726393a4b186333b8e1080f3f1c5c4b77d4c2e6 (patch)
tree0efd32aadfd6ea20f1829da5f401971de0c76155 /test
parent46f1b3106ab959e21946fe1f035efc6dc1743b49 (diff)
Multi-thread test.
Diffstat (limited to 'test')
-rw-r--r--test/test.cc53
1 files changed, 36 insertions, 17 deletions
diff --git a/test/test.cc b/test/test.cc
index 2a99c862f..b77eb2b51 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -254,6 +254,17 @@ BOOST_AUTO_TEST_CASE (paths_test)
BOOST_CHECK_EQUAL (s.content_path(), "build/test/a/b/c/d/e/foo/bar/baz");
}
+void
+do_remote_encode (shared_ptr<DCPVideoFrame> frame, ServerDescription* description, shared_ptr<EncodedData> locally_encoded)
+{
+ shared_ptr<EncodedData> remotely_encoded;
+ BOOST_CHECK_NO_THROW (remotely_encoded = frame->encode_remotely (description));
+ BOOST_CHECK (remotely_encoded);
+
+ BOOST_CHECK_EQUAL (locally_encoded->size(), remotely_encoded->size());
+ BOOST_CHECK (memcmp (locally_encoded->data(), remotely_encoded->data(), locally_encoded->size()) == 0);
+}
+
BOOST_AUTO_TEST_CASE (client_server_test)
{
shared_ptr<SimpleImage> image (new SimpleImage (PIX_FMT_RGB24, Size (1998, 1080)));
@@ -271,29 +282,37 @@ BOOST_AUTO_TEST_CASE (client_server_test)
FileLog log ("build/test/client_server_test.log");
- DCPVideoFrame frame (
- image,
- Size (1998, 1080),
- 0,
- Scaler::from_id ("bicubic"),
- 0,
- 24,
- "",
- 0,
- 200000000,
- &log
+ shared_ptr<DCPVideoFrame> frame (
+ new DCPVideoFrame (
+ image,
+ Size (1998, 1080),
+ 0,
+ Scaler::from_id ("bicubic"),
+ 0,
+ 24,
+ "",
+ 0,
+ 200000000,
+ &log
+ )
);
- shared_ptr<EncodedData> locally_encoded = frame.encode_locally ();
+ shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
Config::instance()->set_server_port (61920);
Server* server = new Server (&log);
- new thread (boost::bind (&Server::run, server, 1));
+ new thread (boost::bind (&Server::run, server, 2));
- ServerDescription description ("localhost", 1);
- shared_ptr<EncodedData> remotely_encoded = frame.encode_remotely (&description);
+ ServerDescription description ("localhost", 2);
- BOOST_CHECK_EQUAL (locally_encoded->size(), remotely_encoded->size());
- BOOST_CHECK (memcmp (locally_encoded->data(), remotely_encoded->data(), locally_encoded->size()) == 0);
+ thread* a = new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded));
+ thread* b = new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded));
+ thread* c = new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded));
+ thread* d = new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded));
+
+ a->join ();
+ b->join ();
+ c->join ();
+ d->join ();
}