#ifndef MULTIFILERECORDER_H #define MULTIFILERECORDER_H #include #include #include #include #include #include #include #include "Recorder.h" class MultiFileRecorder { public: MultiFileRecorder(); virtual ~MultiFileRecorder(); void setFramerate (int fps); inline int framerate () const { return fps_; } void setProfile (VideoRecorder::Profile p); inline VideoRecorder::Profile profile () const { return profile_; } inline void setFiles (std::list list) { files_ = list; } inline std::list files () const { return files_; } // process control void start (); void cancel (); bool finished (); // result inline std::string filename () const { return filename_; } inline int width () const { return width_; } inline int height () const { return height_; } inline float progress () const { return progress_; } inline guint64 numFrames () const { return frame_count_; } protected: // gstreamer functions static std::string assemble (MultiFileRecorder *rec); bool start_record (const std::string &video_filename); bool add_image (const std::string &image_filename); bool end_record(); // gstreamer callbacks static void callback_need_data (GstAppSrc *, guint, gpointer user_data); static void callback_enough_data (GstAppSrc *, gpointer user_data); private: // video properties std::string filename_; VideoRecorder::Profile profile_; int fps_; int width_; int height_; int bpp_; // encoder std::list files_; GstElement *pipeline_; GstAppSrc *src_; guint64 frame_count_; GstClockTime timestamp_; GstClockTime frame_duration_; std::atomic cancel_; std::atomic endofstream_; std::atomic accept_buffer_; // progress and result float progress_; std::vector< std::future >promises_; }; #endif // MULTIFILERECORDER_H