Change how video timing is done.
[dcpomatic.git] / test / client_server_test.cc
index 7a99f72274758a1bace8f1e9f637fe7e1c61d502..4f5015fc843ffd04b2f81a1c07f87d60216d573a 100644 (file)
@@ -51,6 +51,7 @@ using std::weak_ptr;
 using boost::thread;
 using boost::optional;
 using dcp::ArrayData;
+using namespace dcpomatic;
 
 
 void
@@ -105,7 +106,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
                ColourConversion(),
                VideoRange::FULL,
                weak_ptr<Content>(),
-               optional<Frame>(),
+               optional<ContentTime>(),
                false
                );
 
@@ -121,9 +122,9 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
 
        auto locally_encoded = frame->encode_locally ();
 
-       auto server = new EncodeServer (true, 2);
+       auto server = make_shared<EncodeServer>(true, 2);
 
-       auto server_thread = new thread (boost::bind(&EncodeServer::run, server));
+       thread server_thread(boost::bind(&EncodeServer::run, server));
 
        /* Let the server get itself ready */
        dcpomatic_sleep_seconds (1);
@@ -131,23 +132,19 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
        /* "localhost" rather than "127.0.0.1" here fails on docker; go figure */
        EncodeServerDescription description ("127.0.0.1", 1, SERVER_LINK_VERSION);
 
-       list<thread*> threads;
+       list<thread> threads;
        for (int i = 0; i < 8; ++i) {
-               threads.push_back (new thread (boost::bind (do_remote_encode, frame, description, locally_encoded)));
+               threads.push_back(thread(boost::bind(do_remote_encode, frame, description, locally_encoded)));
        }
 
-       for (auto i: threads) {
-               i->join ();
+       for (auto& i: threads) {
+               i.join();
        }
 
-       for (auto i: threads) {
-               delete i;
-       }
+       threads.clear();
 
        server->stop ();
-       server_thread->join ();
-       delete server_thread;
-       delete server;
+       server_thread.join();
 }
 
 
@@ -188,7 +185,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
                ColourConversion(),
                VideoRange::FULL,
                weak_ptr<Content>(),
-               optional<Frame>(),
+               optional<ContentTime>(),
                false
                );
 
@@ -204,9 +201,9 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
 
        auto locally_encoded = frame->encode_locally ();
 
-       auto server = new EncodeServer (true, 2);
+       auto server = make_shared<EncodeServer>(true, 2);
 
-       auto server_thread = new thread(boost::bind(&EncodeServer::run, server));
+       thread server_thread(boost::bind(&EncodeServer::run, server));
 
        /* Let the server get itself ready */
        dcpomatic_sleep_seconds (1);
@@ -214,23 +211,19 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
        /* "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;
+       list<thread> threads;
        for (int i = 0; i < 8; ++i) {
-               threads.push_back (new thread(boost::bind(do_remote_encode, frame, description, locally_encoded)));
+               threads.push_back(thread(boost::bind(do_remote_encode, frame, description, locally_encoded)));
        }
 
-       for (auto i: threads) {
-               i->join ();
+       for (auto& i: threads) {
+               i.join();
        }
 
-       for (auto i: threads) {
-               delete i;
-       }
+       threads.clear();
 
        server->stop ();
-       server_thread->join ();
-       delete server_thread;
-       delete server;
+       server_thread.join();
 }
 
 
@@ -258,7 +251,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k)
                ColourConversion(),
                VideoRange::FULL,
                weak_ptr<Content>(),
-               optional<Frame>(),
+               optional<ContentTime>(),
                false
                );
 
@@ -283,7 +276,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k)
                PresetColourConversion::all().front().conversion,
                VideoRange::FULL,
                weak_ptr<Content>(),
-               optional<Frame>(),
+               optional<ContentTime>(),
                false
                );
 
@@ -297,9 +290,9 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k)
 
        auto j2k_locally_encoded = j2k_frame->encode_locally ();
 
-       auto server = new EncodeServer (true, 2);
+       auto server = make_shared<EncodeServer>(true, 2);
 
-       auto server_thread = new thread (boost::bind (&EncodeServer::run, server));
+       thread server_thread(boost::bind (&EncodeServer::run, server));
 
        /* Let the server get itself ready */
        dcpomatic_sleep_seconds (1);
@@ -307,21 +300,19 @@ BOOST_AUTO_TEST_CASE (client_server_test_j2k)
        /* "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;
+       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)));
+               threads.push_back(thread(boost::bind(do_remote_encode, j2k_frame, description, j2k_locally_encoded)));
        }
 
-       for (auto i: threads) {
-               i->join ();
+       for (auto& i: threads) {
+               i.join();
        }
 
-       for (auto i: threads) {
-               delete i;
-       }
+       threads.clear();
 
        server->stop ();
-       server_thread->join ();
-       delete server_thread;
-       delete server;
+       server_thread.join();
 }
+
+