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));
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_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();
void stream_title_changed(const std::string &);
void stream_duration_changed(const Msp::Time::TimeDelta &);
void stream_position_changed(const Msp::Time::TimeDelta &);
+ void stream_size_changed(unsigned, unsigned);
+ void stream_framerate_changed(float);
+ void stream_codecs_changed(const std::string &, const std::string &);
void stream_channels_changed();
void stream_audio_channel_changed(int);
void stream_spu_channel_changed(int);
filename(mrl.substr(mrl.rfind('/')+1)),
state(STOPPED),
title(filename),
+ video_width(0),
+ video_height(0),
+ framerate(0.0f),
current_audio(0),
current_spu(OFF),
channels_changed(false)
update_info();
}
+bool XineStream::equals(const string &s1, const char *s2)
+{
+ if(!s2)
+ return s1.empty();
+ return !s1.compare(s2);
+}
+
void XineStream::update_info()
{
const char *xt = xine_get_meta_info(stream, XINE_META_INFO_TITLE);
- if((xt && title.compare(xt)) || (!xt && !title.empty()))
+ if(!equals(title, xt))
{
MutexLock lock(mutex);
title = (xt ? xt : string());
signal_title_changed.emit(get_title());
}
+ unsigned w = xine_get_stream_info(stream, XINE_STREAM_INFO_VIDEO_WIDTH);
+ unsigned h = xine_get_stream_info(stream, XINE_STREAM_INFO_VIDEO_HEIGHT);
+ if(w!=video_width || h!=video_height)
+ {
+ MutexLock lock(mutex);
+ video_width = w;
+ video_height = h;
+ signal_video_size_changed.emit(video_width, video_height);
+ }
+
+ float fps = 90000.0f/xine_get_stream_info(stream, XINE_STREAM_INFO_FRAME_DURATION);
+ if(fps!=framerate)
+ {
+ MutexLock lock(mutex);
+ framerate = fps;
+ signal_framerate_changed.emit(framerate);
+ }
+
+ const char *xvc = xine_get_meta_info(stream, XINE_META_INFO_VIDEOCODEC);
+ const char *xac = xine_get_meta_info(stream, XINE_META_INFO_AUDIOCODEC);
+ if(!equals(video_codec, xvc) || !equals(audio_codec, xac))
+ {
+ MutexLock lock(mutex);
+ video_codec = (xvc ? xvc : string());
+ audio_codec = (xac ? xac : string());
+ signal_codecs_changed.emit(video_codec, audio_codec);
+ }
+
int dur_msec, pos_msec;
xine_get_pos_length(stream, 0, &pos_msec, &dur_msec);
Time::TimeDelta dur = dur_msec*Time::msec;
sigc::signal<void, const std::string &> signal_title_changed;
sigc::signal<void, const Msp::Time::TimeDelta &> signal_duration_changed;
sigc::signal<void, const Msp::Time::TimeDelta &> signal_position_changed;
+ sigc::signal<void, unsigned, unsigned> signal_video_size_changed;
+ sigc::signal<void, float> signal_framerate_changed;
+ sigc::signal<void, const std::string &, const std::string &> signal_codecs_changed;
sigc::signal<void> signal_channels_changed;
sigc::signal<void, int> signal_current_audio_channel_changed;
sigc::signal<void, int> signal_current_spu_channel_changed;
std::string title;
Msp::Time::TimeDelta duration;
Msp::Time::TimeDelta position;
+ unsigned video_width;
+ unsigned video_height;
+ float framerate;
+ std::string video_codec;
+ std::string audio_codec;
std::vector<std::string> audio_channels;
std::vector<std::string> spu_channels;
int current_audio;
const Msp::Time::TimeDelta &get_duration() const { return duration; }
const Msp::Time::TimeDelta &get_position() const { return position; }
const std::string &get_title() const;
+ unsigned get_video_width() const { return video_width; }
+ unsigned get_video_height() const { return video_height; }
+ float get_framerate() const { return framerate; }
+ const std::string &get_video_codec() const { return video_codec; }
+ const std::string &get_audio_codec() const { return audio_codec; }
void play();
void seek(const Msp::Time::TimeDelta &);
void tick();
private:
+ static bool equals(const std::string &, const char *);
void update_info();
void update_channels();
void handle_event(const xine_event_t &);