using namespace std;
using namespace boost;
+void
+setup_test_config ()
+{
+ Config::instance()->set_num_local_encoding_threads (1);
+ Config::instance()->set_colour_lut_index (0);
+ Config::instance()->set_j2k_bandwidth (200000000);
+ Config::instance()->set_servers (vector<ServerDescription*> ());
+ Config::instance()->set_server_port (61920);
+}
+
BOOST_AUTO_TEST_CASE (film_metadata_test)
{
dvdomatic_setup ();
+ setup_test_config ();
string const test_film = "build/test/film";
BOOST_AUTO_TEST_CASE (paths_test)
{
FilmState s;
- s.directory = "build/test/a/b/c/d/e";
- s.thumbs.push_back (42);
+ s.set_directory ("build/test/a/b/c/d/e");
+ vector<int> thumbs;
+ thumbs.push_back (42);
+ s.set_thumbs (thumbs);
BOOST_CHECK_EQUAL (s.thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.png");
- s.content = "/foo/bar/baz";
+ s._content = "/foo/bar/baz";
BOOST_CHECK_EQUAL (s.content_path(), "/foo/bar/baz");
- s.content = "foo/bar/baz";
+ s._content = "foo/bar/baz";
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)
+do_remote_encode (shared_ptr<DCPVideoFrame> frame, ServerDescription* description, shared_ptr<EncodedData> locally_encoded, int N)
{
shared_ptr<EncodedData> remotely_encoded;
BOOST_CHECK_NO_THROW (remotely_encoded = frame->encode_remotely (description));
BOOST_AUTO_TEST_CASE (client_server_test)
{
- shared_ptr<Image> image (new SimpleImage (PIX_FMT_RGB24, Size (1998, 1080)));
-
+ shared_ptr<Image> image (new CompactImage (PIX_FMT_RGB24, Size (1998, 1080)));
uint8_t* p = image->data()[0];
for (int y = 0; y < 1080; ++y) {
}
}
+ shared_ptr<Image> sub_image (new CompactImage (PIX_FMT_RGBA, Size (100, 200)));
+ p = sub_image->data()[0];
+ for (int y = 0; y < 200; ++y) {
+ for (int x = 0; x < 100; ++x) {
+ *p++ = y % 256;
+ *p++ = x % 256;
+ *p++ = (x + y) % 256;
+ *p++ = 1;
+ }
+ }
+
+ shared_ptr<Subtitle> subtitle (new Subtitle (Position (50, 60), sub_image));
+
FileLog log ("build/test/client_server_test.log");
shared_ptr<DCPVideoFrame> frame (
new DCPVideoFrame (
image,
- shared_ptr<Subtitle> (),
+ subtitle,
Size (1998, 1080),
0,
0,
- 0,
+ 1,
Scaler::from_id ("bicubic"),
0,
24,
);
shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
+ BOOST_ASSERT (locally_encoded);
- Config::instance()->set_server_port (61920);
Server* server = new Server (&log);
new thread (boost::bind (&Server::run, server, 2));
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 (new thread (boost::bind (do_remote_encode, frame, &description, locally_encoded, i)));
}
for (list<thread*>::iterator i = threads.begin(); i != threads.end(); ++i) {
(*i)->join ();
}
+
+ for (list<thread*>::iterator i = threads.begin(); i != threads.end(); ++i) {
+ delete *i;
+ }
}
BOOST_AUTO_TEST_CASE (make_dcp_test)
BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
{
FilmState fs;
- fs.frames_per_second = 24;
+ fs.set_frames_per_second (24);
- fs.audio_sample_rate = 48000;
- BOOST_CHECK_EQUAL (fs.target_sample_rate(), 48000);
+ fs.set_audio_sample_rate (48000);
+ BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 48000);
- fs.audio_sample_rate = 44100;
- BOOST_CHECK_EQUAL (fs.target_sample_rate(), 48000);
+ fs.set_audio_sample_rate (44100);
+ BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 48000);
- fs.audio_sample_rate = 80000;
- BOOST_CHECK_EQUAL (fs.target_sample_rate(), 96000);
+ fs.set_audio_sample_rate (80000);
+ BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 96000);
- fs.frames_per_second = 23.976;
- fs.audio_sample_rate = 48000;
- BOOST_CHECK_EQUAL (fs.target_sample_rate(), 47952);
+ fs.set_frames_per_second (23.976);
+ fs.set_audio_sample_rate (48000);
+ BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 47952);
- fs.frames_per_second = 29.97;
- fs.audio_sample_rate = 48000;
- BOOST_CHECK_EQUAL (fs.target_sample_rate(), 47952);
+ fs.set_frames_per_second (29.97);
+ fs.set_audio_sample_rate (48000);
+ BOOST_CHECK_EQUAL (fs.target_audio_sample_rate(), 47952);
}
class TestJob : public Job
{
public:
- TestJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
- : Job (s, o, l, req)
+ TestJob (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
+ : Job (s, l, req)
{
}
BOOST_AUTO_TEST_CASE (job_manager_test)
{
shared_ptr<const FilmState> s;
- shared_ptr<const Options> o;
FileLog log ("build/test/job_manager_test.log");
/* Single job, no dependency */
- shared_ptr<TestJob> a (new TestJob (s, o, &log, shared_ptr<Job> ()));
+ shared_ptr<TestJob> a (new TestJob (s, &log, shared_ptr<Job> ()));
JobManager::instance()->add (a);
dvdomatic_sleep (1);
BOOST_CHECK_EQUAL (a->finished_ok(), true);
/* Two jobs, dependency */
- a.reset (new TestJob (s, o, &log, shared_ptr<Job> ()));
- shared_ptr<TestJob> b (new TestJob (s, o, &log, a));
+ a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
+ shared_ptr<TestJob> b (new TestJob (s, &log, a));
JobManager::instance()->add (a);
JobManager::instance()->add (b);
BOOST_CHECK_EQUAL (b->finished_ok(), true);
/* Two jobs, dependency, first fails */
- a.reset (new TestJob (s, o, &log, shared_ptr<Job> ()));
- b.reset (new TestJob (s, o, &log, a));
+ a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
+ b.reset (new TestJob (s, &log, a));
JobManager::instance()->add (a);
JobManager::instance()->add (b);
BOOST_CHECK_EQUAL (a->finished_in_error(), true);
BOOST_CHECK_EQUAL (b->running(), false);
}
+
+BOOST_AUTO_TEST_CASE (stream_test)
+{
+ AudioStream a ("4 9 hello there world");
+ BOOST_CHECK_EQUAL (a.id(), 4);
+ BOOST_CHECK_EQUAL (a.channels(), 9);
+ BOOST_CHECK_EQUAL (a.name(), "hello there world");
+ BOOST_CHECK_EQUAL (a.to_string(), "4 9 hello there world");
+
+ SubtitleStream s ("5 a b c");
+ BOOST_CHECK_EQUAL (s.id(), 5);
+ BOOST_CHECK_EQUAL (s.name(), "a b c");
+}