X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fclient.cpp;h=f042c66b020b70d31e0c0348c098c25a04540321;hb=3bd92c1fa7a85b47356cd6f2bad23893955a0785;hp=dbe6091df0f6232c9bfb642663921d7505471297;hpb=8c7e5bd0d1f966af2b22293a3a0780c419fb9c95;p=xinema.git diff --git a/source/client.cpp b/source/client.cpp index dbe6091..f042c66 100644 --- a/source/client.cpp +++ b/source/client.cpp @@ -1,7 +1,9 @@ #include #include +#include #include "client.h" #include "xinema.h" +#include "xinestream.h" using namespace std; using namespace Msp; @@ -13,6 +15,8 @@ Client::Client(Xinema &x, Net::StreamSocket *s): { 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)); } void Client::data_available() @@ -83,3 +87,32 @@ void Client::list_directory(const FS::Path &dn) 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); +} + +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; + } +}