2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 do_remote_encode (shared_ptr<DCPVideoFrame> frame, ServerDescription* description, shared_ptr<EncodedData> locally_encoded)
23 shared_ptr<EncodedData> remotely_encoded;
24 BOOST_CHECK_NO_THROW (remotely_encoded = frame->encode_remotely (description));
25 BOOST_CHECK (remotely_encoded);
27 BOOST_CHECK_EQUAL (locally_encoded->size(), remotely_encoded->size());
28 BOOST_CHECK (memcmp (locally_encoded->data(), remotely_encoded->data(), locally_encoded->size()) == 0);
31 BOOST_AUTO_TEST_CASE (client_server_test)
33 shared_ptr<Image> image (new SimpleImage (PIX_FMT_RGB24, libdcp::Size (1998, 1080), true));
34 uint8_t* p = image->data()[0];
36 for (int y = 0; y < 1080; ++y) {
38 for (int x = 0; x < 1998; ++x) {
43 p += image->stride()[0];
46 shared_ptr<Image> sub_image (new SimpleImage (PIX_FMT_RGBA, libdcp::Size (100, 200), true));
47 p = sub_image->data()[0];
48 for (int y = 0; y < 200; ++y) {
50 for (int x = 0; x < 100; ++x) {
56 p += sub_image->stride()[0];
59 shared_ptr<Subtitle> subtitle (new Subtitle (Position (50, 60), sub_image));
61 shared_ptr<FileLog> log (new FileLog ("build/test/client_server_test.log"));
63 shared_ptr<DCPVideoFrame> frame (
74 shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
75 BOOST_ASSERT (locally_encoded);
77 Server* server = new Server (log);
79 new thread (boost::bind (&Server::run, server, 2));
81 /* Let the server get itself ready */
84 ServerDescription description ("localhost", 2);
86 list<thread*> threads;
87 for (int i = 0; i < 8; ++i) {
88 threads.push_back (new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded)));
91 for (list<thread*>::iterator i = threads.begin(); i != threads.end(); ++i) {
95 for (list<thread*>::iterator i = threads.begin(); i != threads.end(); ++i) {