Integration of MultiFileRecorder in UI for sequence creation

This commit is contained in:
Bruno Herbelin
2022-07-04 00:07:23 +02:00
parent af009e03a0
commit 85194c7f4f
6 changed files with 235 additions and 104 deletions

View File

@@ -4,6 +4,8 @@
#include <list>
#include <string>
#include <atomic>
#include <vector>
#include <future>
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
@@ -12,47 +14,35 @@
class MultiFileRecorder
{
std::string filename_;
VideoRecorder::Profile profile_;
int fps_;
int width_;
int height_;
int bpp_;
GstElement *pipeline_;
GstAppSrc *src_;
guint64 frame_count_;
GstClockTime timestamp_;
GstClockTime frame_duration_;
std::atomic<bool> endofstream_;
std::atomic<bool> accept_buffer_;
float progress_;
std::list<std::string> files_;
public:
MultiFileRecorder(const std::string &filename);
MultiFileRecorder();
virtual ~MultiFileRecorder();
void setFramerate (int fps);
inline int framerate () const { return fps_; }
void setProfile (VideoRecorder::Profile profil);
void setProfile (VideoRecorder::Profile p);
inline VideoRecorder::Profile profile () const { return profile_; }
void assemble (std::list<std::string> list);
inline float progress () const { return progress_; }
inline void setFiles (std::list<std::string> list) { files_ = list; }
inline std::list<std::string> 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_; }
// std::thread(MultiFileRecorder::assembleImages, sourceSequenceFiles, "/home/bhbn/test.mov").detach();
static void assembleImages(std::list<std::string> list, const std::string &filename);
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();
@@ -60,6 +50,31 @@ protected:
// 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<std::string> files_;
GstElement *pipeline_;
GstAppSrc *src_;
guint64 frame_count_;
GstClockTime timestamp_;
GstClockTime frame_duration_;
std::atomic<bool> cancel_;
std::atomic<bool> endofstream_;
std::atomic<bool> accept_buffer_;
// progress and result
float progress_;
std::vector< std::future<std::string> >promises_;
};
#endif // MULTIFILERECORDER_H