X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fclip_list.h;h=5373ce03219cb9308c06f36664565ec8e0acd5dd;hb=refs%2Fheads%2Fmaster;hp=8dead831106e74783704ad5fab8ea6b9eb9eb675;hpb=eeda8995329601f9f4e35047358400833eeae68e;p=nageru diff --git a/futatabi/clip_list.h b/futatabi/clip_list.h index 8dead83..5373ce0 100644 --- a/futatabi/clip_list.h +++ b/futatabi/clip_list.h @@ -5,16 +5,23 @@ #include "state.pb.h" #include -#include #include +#include #include #include struct Clip { int64_t pts_in = -1, pts_out = -1; // pts_in is inclusive, pts_out is exclusive. - std::string descriptions[NUM_CAMERAS]; - unsigned stream_idx = 0; // For the playlist only. - double fade_time_seconds = 0.5; // For the playlist only. + std::string descriptions[MAX_STREAMS]; + + // These are for the playlist only. + unsigned stream_idx = 0; + double fade_time_seconds = 0.5; + double speed = 0.5; +}; +struct ClipWithID { + Clip clip; + uint64_t id; // Used for progress callback only. Immutable. }; class DataChangedReceiver { @@ -47,17 +54,14 @@ class ClipList : public QAbstractTableModel, public DataChangedReceiver { Q_OBJECT public: - explicit ClipList(const ClipListProto &serialized); + ClipList(const ClipListProto &serialized); enum class Column { IN, OUT, DURATION, - CAMERA_1, - CAMERA_2, - CAMERA_3, - CAMERA_4, - NUM_COLUMNS + CAMERA_1, // Then CAMERA_2, CAMERA_3, etc. as needed. + NUM_NON_CAMERA_COLUMNS = CAMERA_1 }; int rowCount(const QModelIndex &parent) const override; @@ -79,13 +83,20 @@ public: ClipListProto serialize() const; + void change_num_cameras(size_t num_cameras); // Defaults to 2. Cannot decrease. void emit_data_changed(size_t row) override; + bool is_camera_column(int column) const + { + return (column >= int(Column::CAMERA_1) && column < int(Column::CAMERA_1) + int(num_cameras)); + } + signals: void any_content_changed(); private: std::vector clips; + size_t num_cameras = 2; }; class PlayList : public QAbstractTableModel, public DataChangedReceiver { @@ -102,6 +113,7 @@ public: CAMERA, DESCRIPTION, FADE_TIME, + SPEED, NUM_COLUMNS }; @@ -123,30 +135,33 @@ public: size_t size() const { return clips.size(); } bool empty() const { return clips.empty(); } - ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); } - const Clip *clip(size_t index) const { return &clips[index]; } + ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index].clip, this, index); } + const Clip *clip(size_t index) const { return &clips[index].clip; } + const ClipWithID *clip_with_id(size_t index) const { return &clips[index]; } ClipProxy mutable_back() { return mutable_clip(size() - 1); } const Clip *back() const { return clip(size() - 1); } - // TODO: Move these out of PlayList. - void set_currently_playing(int index, double progress); // -1 = none. - int get_currently_playing() const { return currently_playing_index; } - - void set_progress(const std::map &progress); + void set_progress(const std::map &progress); ClipListProto serialize() const; + void change_num_cameras(size_t num_cameras) // Defaults to 2. Cannot decrease. + { + this->num_cameras = num_cameras; + } + void emit_data_changed(size_t row) override; signals: void any_content_changed(); private: - std::vector clips; - int currently_playing_index = -1; + std::vector clips; double play_progress = 0.0; - std::map current_progress; + std::map current_progress; + size_t num_cameras = 2; + uint64_t clip_counter = 1000000; // Used for generating IDs. Starting at a high number to avoid any kind of bugs treating IDs as rows. }; #endif // !defined (_CLIP_LIST_H)