- _empty_condition.notify_all ();
- }
-
- for (vector<boost::thread*>::iterator i = _worker_threads.begin(); i != _worker_threads.end(); ++i) {
- (*i)->join ();
- delete *i;
- }
-
- _io_service.stop ();
-
- _broadcast.io_service.stop ();
- _broadcast.thread->join ();
-}
-
-/** @param after_read Filled in with gettimeofday() after reading the input from the network.
- * @param after_encode Filled in with gettimeofday() after encoding the image.
- */
-int
-Server::process (shared_ptr<Socket> socket, struct timeval& after_read, struct timeval& after_encode)
-{
- uint32_t length = socket->read_uint32 ();
- scoped_array<char> buffer (new char[length]);
- socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
-
- string s (buffer.get());
- shared_ptr<cxml::Document> xml (new cxml::Document ("EncodingRequest"));
- xml->read_string (s);
- /* This is a double-check; the server shouldn't even be on the candidate list
- if it is the wrong version, but it doesn't hurt to make sure here.
- */
- if (xml->number_child<int> ("Version") != SERVER_LINK_VERSION) {
- cerr << "Mismatched server/client versions\n";
- LOG_ERROR_NC ("Mismatched server/client versions");
- return -1;
- }
-
- shared_ptr<PlayerVideo> pvf (new PlayerVideo (xml, socket));
-
- DCPVideo dcp_video_frame (pvf, xml, _log);
-
- gettimeofday (&after_read, 0);
-
- shared_ptr<Data> encoded = dcp_video_frame.encode_locally (boost::bind (&Log::dcp_log, _log.get(), _1, _2));
-
- gettimeofday (&after_encode, 0);
-
- try {
- socket->write (encoded->size ());
- socket->write (encoded->data ().get (), encoded->size ());
- } catch (std::exception& e) {
- cerr << "Send failed; frame " << dcp_video_frame.index() << "\n";
- LOG_ERROR ("Send failed; frame %1", dcp_video_frame.index());
- throw;