video_playback.h
Go to the documentation of this file.
00001 //=================================================================================================
00002 // Copyright (c) 2013, Johannes Meyer, TU Darmstadt
00003 // All rights reserved.
00004 
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are met:
00007 //     * Redistributions of source code must retain the above copyright
00008 //       notice, this list of conditions and the following disclaimer.
00009 //     * Redistributions in binary form must reproduce the above copyright
00010 //       notice, this list of conditions and the following disclaimer in the
00011 //       documentation and/or other materials provided with the distribution.
00012 //     * Neither the name of the Flight Systems and Automatic Control group,
00013 //       TU Darmstadt, nor the names of its contributors may be used to
00014 //       endorse or promote products derived from this software without
00015 //       specific prior written permission.
00016 
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //=================================================================================================
00028 
00029 #ifndef RQT_VIDEO_PLAYBACK_VIDEO_PLAYBACK_H
00030 #define RQT_VIDEO_PLAYBACK_VIDEO_PLAYBACK_H
00031 
00032 #include <rqt_gui_cpp/plugin.h>
00033 #include <ui_video_playback.h>
00034 
00035 #include <ros/ros.h>
00036 #include <rosgraph_msgs/Clock.h>
00037 
00038 #include <Phonon/MediaObject>
00039 #include <Phonon/MediaNode>
00040 
00041 namespace rqt_video_playback {
00042 
00043 class VideoPlayback
00044   : public rqt_gui_cpp::Plugin
00045 {
00046   Q_OBJECT
00047 
00048 public:
00049   VideoPlayback();
00050   virtual ~VideoPlayback();
00051 
00052   virtual void initPlugin(qt_gui_cpp::PluginContext& context);
00053 
00054   virtual bool eventFilter(QObject* watched, QEvent* event);
00055 
00056   virtual void shutdownPlugin();
00057 
00058   virtual void saveSettings(qt_gui_cpp::Settings& plugin_settings, qt_gui_cpp::Settings& instance_settings) const;
00059 
00060   virtual void restoreSettings(const qt_gui_cpp::Settings& plugin_settings, const qt_gui_cpp::Settings& instance_settings);
00061 
00062 protected slots:
00063   void openClicked();
00064   void playClicked();
00065   void previousClicked();
00066   void nextClicked();
00067   void sliderValueChanged(int);
00068 
00069   void sync();
00070 
00071   void tick(qint64);
00072   void stateChanged(Phonon::State newstate, Phonon::State oldstate);
00073   void totalTimeChanged(qint64);
00074   void currentSourceChanged(Phonon::MediaSource);
00075 
00076 signals:
00077   void clockUpdated();
00078 
00079 protected:
00080   virtual void callbackClock(const rosgraph_msgs::Clock::ConstPtr& msg);
00081   Phonon::MediaObject *mediaObject() const { return ui_.videoPlayer->mediaObject(); }
00082 
00083 private:
00084   ros::Duration toRos(qint64 time);
00085   qint64 fromRos(const ros::Duration& duration);
00086 
00087   Ui_VideoPlayback ui_;
00088 
00089   QWidget* widget_;
00090 
00091   ros::Subscriber subscriber_;
00092 
00093   ros::Time clock_;
00094   ros::Time start_;
00095 
00096 private:
00097   qint64 step_time_;
00098   qint64 time_tolerance_;
00099 };
00100 
00101 } // namespace rqt_video_playback
00102 
00103 #endif // RQT_VIDEO_PLAYBACK_VIDEO_PLAYBACK_H


rqt_video_playback
Author(s): Johannes Meyer
autogenerated on Mon Oct 6 2014 00:35:50