]> git.tdb.fi Git - xinema.git/blobdiff - source/client.cpp
Create an icon for the remote
[xinema.git] / source / client.cpp
index 604779662b5f0fc6944bf07542bd686ce390bdfb..353694e6d6109f943cd05649c59324ed4ad39af9 100644 (file)
@@ -74,6 +74,14 @@ XineStream &Client::get_stream() const
        throw runtime_error("No stream");
 }
 
+int Client::convert_channel(const string &arg)
+{
+       if(arg=="off")
+               return XineStream::OFF;
+       else
+               return lexical_cast<unsigned>(arg);
+}
+
 void Client::process_command(const string &cmd)
 {
        string::size_type space = cmd.find(' ');
@@ -95,9 +103,9 @@ void Client::process_command(const string &cmd)
        else if(keyword=="stop")
                get_stream().stop();
        else if(keyword=="select_audio")
-               set_audio_channel(args);
+               get_stream().select_audio_channel(convert_channel(args));
        else if(keyword=="select_spu")
-               set_spu_channel(args);
+               get_stream().select_spu_channel(convert_channel(args));
        else
                throw runtime_error("Invalid command");
 }
@@ -128,24 +136,8 @@ void Client::list_directory(const FS::Path &dn)
                else
                        send_reply("file "+*i);
        }
-}
-
-void Client::set_audio_channel(const string &arg)
-{
-       XineStream &stream = get_stream();
-       if(arg=="off")
-               stream.set_audio_off();
-       else
-               stream.set_audio_channel(lexical_cast<unsigned>(arg));
-}
 
-void Client::set_spu_channel(const string &arg)
-{
-       XineStream &stream = get_stream();
-       if(arg=="off")
-               stream.set_spu_off();
-       else
-               stream.set_spu_channel(lexical_cast<unsigned>(arg));
+       send_reply("directory_end");
 }
 
 void Client::stream_created(XineStream &stream)
@@ -154,7 +146,12 @@ 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));
+       stream.signal_video_size_changed.connect(sigc::mem_fun(this, &Client::stream_size_changed));
+       stream.signal_framerate_changed.connect(sigc::mem_fun(this, &Client::stream_framerate_changed));
+       stream.signal_codecs_changed.connect(sigc::mem_fun(this, &Client::stream_codecs_changed));
        stream.signal_channels_changed.connect(sigc::mem_fun(this, &Client::stream_channels_changed));
+       stream.signal_current_audio_channel_changed.connect(sigc::mem_fun(this, &Client::stream_audio_channel_changed));
+       stream.signal_current_spu_channel_changed.connect(sigc::mem_fun(this, &Client::stream_spu_channel_changed));
 
        MutexLock lock(stream.get_mutex());
        stream_state_changed(stream.get_state());
@@ -164,9 +161,18 @@ void Client::stream_created(XineStream &stream)
                send_reply("title "+title);
 
        if(const Time::TimeDelta &dur = stream.get_duration())
+       {
                stream_duration_changed(dur);
+               stream_position_changed(stream.get_position());
+       }
+
+       stream_size_changed(stream.get_video_width(), stream.get_video_height());
+       stream_framerate_changed(stream.get_framerate());
+       stream_codecs_changed(stream.get_video_codec(), stream.get_audio_codec());
 
        stream_channels_changed();
+       stream_audio_channel_changed(stream.get_current_audio_channel());
+       stream_spu_channel_changed(stream.get_current_spu_channel());
 }
 
 void Client::stream_destroyed()
@@ -198,6 +204,22 @@ void Client::stream_position_changed(const Time::TimeDelta &pos)
        }
 }
 
+void Client::stream_size_changed(unsigned w, unsigned h)
+{
+       send_reply(format("video_size %d %d", w, h));
+}
+
+void Client::stream_framerate_changed(float fps)
+{
+       send_reply(format("framerate %.2f", fps));
+}
+
+void Client::stream_codecs_changed(const string &vc, const string &ac)
+{
+       send_reply("video_codec "+vc);
+       send_reply("audio_codec "+ac);
+}
+
 void Client::stream_channels_changed()
 {
        XineStream &stream = get_stream();
@@ -214,3 +236,19 @@ void Client::stream_channels_changed()
 
        send_reply("channels_end");
 }
+
+void Client::stream_audio_channel_changed(int chan)
+{
+       if(chan==XineStream::OFF)
+               send_reply("current_audio off");
+       else
+               send_reply(format("current_audio %d", chan));
+}
+
+void Client::stream_spu_channel_changed(int chan)
+{
+       if(chan==XineStream::OFF)
+               send_reply("current_spu off");
+       else
+               send_reply(format("current_spu %d", chan));
+}