--- /dev/null
+mediaserv
+libScheduler.a
+libSocket.a
+libUtils.a
+libServer.a
--- /dev/null
+import sys, glob
+sys.path.append('satscons')
+import SatSCons
+
+###########################################################################
+
+SatSCons.UseBoost();
+SatSCons.UseSTLPort();
+SatSCons.UseDoxygen();
+env = SatSCons.MakeEnvironment();
+
+env.Append(
+ CPPPATH = [ '#' ],
+ LIBS = [ 'iberty' ]
+)
+
+Export('env')
+
+SConscript(glob.glob("*/SConscript"))
+
+SatSCons.StandardTargets(env)
+SatSCons.GlobalTargets(env)
+
+SatSCons.Binary(env, binary='mediaserv', sources=SatSCons.GlobSources(),
+ LIBS = [ 'Server', 'Scheduler', 'Socket', 'Utils' ])
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+// Definition of non-inline non-template functions
+
+#include "Connection.hh"
+//#include "Connection.ih"
+
+// Custom includes
+
+//#include "Connection.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+prefix_ g0dil::mediaserv::Connection::Connection(int fileFd, unsigned bytesPerSecond,
+ ClientHandle client, unsigned bufferMSecs)
+ : fileFd_(fileFd), bytesPerSecond_(bytesPerSecond), client_(client),
+ bufferMSecs_(bufferMSecs), bytesWritten_(0), start_(satcom::lib::now()),
+ bufferSize_(0), terminate_(false)
+{
+ registerCallback();
+ fillBuffer();
+}
+
+prefix_ void g0dil::mediaserv::Connection::fillBuffer()
+{
+ bufferSize_ = ::read(fileFd_,buffer_,packetSize);
+ if (bufferSize_ < packetSize)
+ terminate_ = true;
+ // TODO: Check error;
+}
+
+prefix_ void g0dil::mediaserv::Connection::callback(ClientHandle client,
+ satcom::lib::Scheduler::EventId)
+{
+ unsigned target (targetBytes());
+ if (target - bytesWritten_ >= bufferSize_) {
+ if (client_.write(buffer_,bufferSize_) < bufferSize_)
+ // TODO: Destroy client handle ..
+ ;
+ bytesWritten_ += bufferSize_;
+ if (terminate_) {
+ unregisterCallback();
+ // TODO: Destroy client handle
+ } else
+ fillBuffer();
+ } else {
+ unregisterCallback();
+ registerTimeout(((bufferSize_-(target-bytesWritten_))*1000)/bytesPerSecond_);
+ }
+}
+
+prefix_ void g0dil::mediaserv::Connection::timeout()
+{
+ registerCallback();
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "Connection.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+// Definition of inline non-template functions
+
+// Custom includes
+#include "Utils/membind.hh"
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+prefix_ void g0dil::mediaserv::Connection::registerCallback()
+{
+ satcom::lib::Scheduler::instance().add(client_,satcom::lib::membind(&Connection::callback,this),
+ satcom::lib::Scheduler::EV_WRITE);
+}
+
+prefix_ void g0dil::mediaserv::Connection::unregisterCallback()
+{
+ satcom::lib::Scheduler::instance().remove(client_,satcom::lib::Scheduler::EV_WRITE);
+}
+
+prefix_ void g0dil::mediaserv::Connection::registerTimeout(unsigned timeout)
+{
+ satcom::lib::Scheduler::instance().timeout(timeout,satcom::lib::membind(&Connection::timeout,this));
+}
+
+prefix_ unsigned g0dil::mediaserv::Connection::targetBytes()
+{
+ return ((bufferMSecs_ + ((satcom::lib::now()-start_)/1000u))*bytesPerSecond_)/1000u;
+}
+
+///////////////////////////////cci.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+#ifndef HH_Connection_
+#define HH_Connection_ 1
+
+// Custom includes
+#include <boost/utility.hpp>
+#include "Utils/MicroTime.hh"
+#include "Scheduler/Scheduler.hh"
+#include "Socket/ClientSocketHandle.hh"
+#include "Socket/CommunicationPolicy.hh"
+#include "Socket/FramingPolicy.hh"
+#include "Socket/BufferingPolicy.hh"
+#include "Socket/ReadWritePolicy.hh"
+
+//#include "Connection.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace g0dil {
+namespace mediaserv {
+
+ class Connection : boost::noncopyable
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // Types
+
+ typedef satcom::lib::ClientSocketHandle<
+ satcom::lib::MakeSocketPolicy<satcom::lib::ConnectedCommunicationPolicy,
+ satcom::lib::StreamFramingPolicy,
+ satcom::lib::WriteablePolicy,
+ satcom::lib::SocketBufferingPolicy>::policy> ClientHandle;
+
+ static const unsigned packetSize = 1400;
+
+ ///////////////////////////////////////////////////////////////////////////
+ ///\name Structors and default members
+ ///@{
+
+ Connection(int fileFd, unsigned bytesPerSecond, ClientHandle client,
+ unsigned bufferMSecs);
+
+ ///@}
+
+ protected:
+
+ private:
+ void registerCallback();
+ void unregisterCallback();
+ void registerTimeout(unsigned timeout);
+ unsigned targetBytes();
+ void fillBuffer();
+
+ void callback(ClientHandle client, satcom::lib::Scheduler::EventId);
+ void timeout();
+
+
+ int fileFd_;
+ unsigned bytesPerSecond_;
+ ClientHandle client_;
+ unsigned bufferMSecs_;
+
+ unsigned bytesWritten_;
+ satcom::lib::MicroTime start_;
+ unsigned bufferSize_;
+ char buffer_[packetSize];
+ bool terminate_;
+ };
+
+}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "Connection.cci"
+//#include "Connection.ct"
+//#include "Connection.cti"
+//#include "Connection.mpp"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+// Unit tests
+
+//#include "Connection.test.hh"
+//#include "Connection.test.ih"
+
+// Custom includes
+#include "Connection.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(connection)
+{}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+Import('env')
+import SatSCons
+
+###########################################################################
+
+SatSCons.StandardTargets(env)
+
+SatSCons.Lib(env, library = 'Server', sources = SatSCons.GlobSources(),
+ LIBS = [ 'Socket', 'Scheduler', 'Utils' ])
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+// Unit tests
+
+//#include "main.test.hh"
+//#include "main.test.ih"
+
+// Custom includes
+
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2006
+
+// Definition of non-inline non-template functions
+
+//#include "main.hh"
+//#include "main.ih"
+
+// Custom includes
+
+//#include "main.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+int main(int argc, char** argv)
+{
+ return 0;
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "main.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// End: