5 // Definition of non-inline non-template functions
7 #include "StreamConnection.hh"
8 //#include "StreamConnection.ih"
12 #include "SimpleHTTPServer.hh"
14 //#include "StreamConnection.mpp"
16 ///////////////////////////////cc.p////////////////////////////////////////
18 prefix_ g0dil::mediaserv::StreamConnection::StreamConnection(int fileFd,
19 unsigned bytesPerSecond,
23 : fileFd_(fileFd), bytesPerSecond_(bytesPerSecond), client_(client),
24 bufferMSecs_(bufferMSecs), callback_(callback), bytesWritten_(0),
25 start_(senf::now()), bufferSize_(0), terminate_(false)
31 prefix_ void g0dil::mediaserv::StreamConnection::start()
36 prefix_ g0dil::mediaserv::StreamConnection::~StreamConnection()
39 // FIXME: unregisterTimeout
42 prefix_ void g0dil::mediaserv::StreamConnection::fillBuffer()
44 bufferSize_ = ::read(fileFd_,buffer_,packetSize);
47 else if (bufferSize_ < packetSize)
51 prefix_ void g0dil::mediaserv::StreamConnection::callback(ClientHandle client,
52 senf::Scheduler::EventId event)
54 if (event != senf::Scheduler::EV_WRITE) {
58 unsigned target (targetBytes());
59 if (target - bytesWritten_ >= bufferSize_) {
60 if (client_.write(buffer_,buffer_+bufferSize_) < buffer_+bufferSize_) {
64 bytesWritten_ += bufferSize_;
72 registerTimeout(((bufferSize_-(target-bytesWritten_))*1000)/bytesPerSecond_);
76 prefix_ void g0dil::mediaserv::StreamConnection::timeout()
81 ///////////////////////////////cc.e////////////////////////////////////////
83 //#include "StreamConnection.mpp"