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.
30 #include "dcp_video_frame.h"
33 #include "exceptions.h"
36 #include "decoder_factory.h"
39 using namespace boost;
41 static Server* server;
42 static Log log_ ("servomatictest.log");
45 process_video (shared_ptr<Image> image, bool, int frame)
47 shared_ptr<DCPVideoFrame> local (new DCPVideoFrame (image, Size (1024, 1024), 0, Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_));
48 shared_ptr<DCPVideoFrame> remote (new DCPVideoFrame (image, Size (1024, 1024), 0, Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_));
50 cout << "Frame " << frame << ": ";
53 shared_ptr<EncodedData> local_encoded = local->encode_locally ();
54 shared_ptr<EncodedData> remote_encoded;
58 remote_encoded = remote->encode_remotely (server);
59 } catch (NetworkError& e) {
60 remote_error = e.what ();
63 if (!remote_error.empty ()) {
64 cout << "\033[0;31mnetwork problem: " << remote_error << "\033[0m\n";
68 if (local_encoded->size() != remote_encoded->size()) {
69 cout << "\033[0;31msizes differ\033[0m\n";
73 uint8_t* p = local_encoded->data();
74 uint8_t* q = remote_encoded->data();
75 for (int i = 0; i < local_encoded->size(); ++i) {
77 cout << "\033[0;31mdata differ\033[0m at byte " << i << "\n";
82 cout << "\033[0;32mgood\033[0m\n";
88 cerr << "Syntax: " << n << " [--help] --film <film> --server <host>\n";
93 main (int argc, char* argv[])
99 static struct option long_options[] = {
100 { "help", no_argument, 0, 'h'},
101 { "server", required_argument, 0, 's'},
102 { "film", required_argument, 0, 'f'},
106 int option_index = 0;
107 int c = getopt_long (argc, argv, "hs:f:", long_options, &option_index);
118 server_host = optarg;
126 if (server_host.empty() || film_dir.empty()) {
133 server = new Server (server_host, 1);
134 Film film (film_dir, true);
136 shared_ptr<Options> opt (new Options ("fred", "jim", "sheila"));
137 opt->out_size = Size (1024, 1024);
138 opt->decode_audio = false;
140 shared_ptr<Decoder> decoder = decoder_factory (film.state_copy(), opt, 0, &log_);
142 decoder->Video.connect (sigc::ptr_fun (process_video));
144 } catch (std::exception& e) {
145 cerr << "Error: " << e.what() << "\n";