#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
+#include <msp/strings/format.h>
#include "client.h"
#include "xinema.h"
+#include "xinestream.h"
using namespace std;
using namespace Msp;
{
socket->signal_data_available.connect(sigc::mem_fun(this, &Client::data_available));
socket->signal_end_of_file.connect(sigc::mem_fun(this, &Client::end_of_stream));
+
+ xinema.signal_stream_created.connect(sigc::mem_fun(this, &Client::stream_created));
+ XineStream *stream = xinema.get_stream();
+ if(stream)
+ stream_created(*stream);
}
void Client::data_available()
catch(const exception &e)
{
send_reply(string("error ")+e.what());
- return;
}
start = newline+1;
send_reply("file "+*i);
}
}
+
+void Client::stream_created(XineStream &stream)
+{
+ stream.signal_title_changed.connect(sigc::mem_fun(this, &Client::stream_title_changed));
+ stream.signal_duration_changed.connect(sigc::mem_fun(this, &Client::stream_duration_changed));
+ stream.signal_position_changed.connect(sigc::mem_fun(this, &Client::stream_position_changed));
+ string title = stream.get_title();
+ if(!title.empty())
+ send_reply("title "+title);
+ if(const Time::TimeDelta &dur = stream.get_duration())
+ stream_duration_changed(dur);
+}
+
+void Client::stream_title_changed(const string &title)
+{
+ send_reply("title "+title);
+}
+
+void Client::stream_duration_changed(const Time::TimeDelta &dur)
+{
+ send_reply(format("duration %.3f", dur/Time::sec));
+}
+
+void Client::stream_position_changed(const Time::TimeDelta &pos)
+{
+ if(abs(pos-last_position)>=Time::sec)
+ {
+ send_reply(format("position %.3f", pos/Time::sec));
+ last_position = pos;
+ }
+}