+
+BOOST_AUTO_TEST_CASE (client_server_test_j2k)
+{
+ auto image = make_shared<Image>(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), Image::Alignment::PADDED);
+
+ for (int i = 0; i < image->planes(); ++i) {
+ uint8_t* p = image->data()[i];
+ for (int j = 0; j < image->line_size()[i]; ++j) {
+ *p++ = j % 256;
+ }
+ }
+
+ LogSwitcher ls (make_shared<FileLog>("build/test/client_server_test_j2k.log"));
+
+ auto raw_pvf = std::make_shared<PlayerVideo> (
+ std::make_shared<RawImageProxy>(image),
+ Crop(),
+ optional<double>(),
+ dcp::Size(1998, 1080),
+ dcp::Size(1998, 1080),
+ Eyes::BOTH,
+ Part::WHOLE,
+ ColourConversion(),
+ VideoRange::FULL,
+ weak_ptr<Content>(),
+ optional<Frame>(),
+ false
+ );
+
+ auto raw_frame = make_shared<DCPVideo> (
+ raw_pvf,
+ 0,
+ 24,
+ 200000000,
+ Resolution::TWO_K
+ );
+
+ auto raw_locally_encoded = raw_frame->encode_locally ();
+
+ auto j2k_pvf = std::make_shared<PlayerVideo> (
+ std::make_shared<J2KImageProxy>(raw_locally_encoded, dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE),
+ Crop(),
+ optional<double>(),
+ dcp::Size(1998, 1080),
+ dcp::Size(1998, 1080),
+ Eyes::BOTH,
+ Part::WHOLE,
+ PresetColourConversion::all().front().conversion,
+ VideoRange::FULL,
+ weak_ptr<Content>(),
+ optional<Frame>(),
+ false
+ );
+
+ auto j2k_frame = make_shared<DCPVideo> (
+ j2k_pvf,
+ 0,
+ 24,
+ 200000000,
+ Resolution::TWO_K
+ );
+
+ auto j2k_locally_encoded = j2k_frame->encode_locally ();
+
+ auto server = new EncodeServer (true, 2);
+
+ auto server_thread = new thread (boost::bind (&EncodeServer::run, server));
+
+ /* Let the server get itself ready */
+ dcpomatic_sleep_seconds (1);
+
+ /* "localhost" rather than "127.0.0.1" here fails on docker; go figure */
+ EncodeServerDescription description ("127.0.0.1", 2, SERVER_LINK_VERSION);
+
+ list<thread*> threads;
+ for (int i = 0; i < 8; ++i) {
+ threads.push_back (new thread(boost::bind(do_remote_encode, j2k_frame, description, j2k_locally_encoded)));
+ }
+
+ for (auto i: threads) {
+ i->join ();
+ }
+
+ for (auto i: threads) {
+ delete i;
+ }
+
+ server->stop ();
+ server_thread->join ();
+ delete server_thread;
+ delete server;
+}