-void decode_packs(const libusb_transfer *xfr, const char *sync_pattern, int sync_length, function<void(const uint8_t *start, const uint8_t *end)> add_callback, function<void(const uint8_t *start)> start_callback)
+void add_to_frame(FrameAllocator::Frame *current_frame, const char *frame_type_name, const uint8_t *start, const uint8_t *end)
+{
+ if (current_frame->data == nullptr ||
+ current_frame->len > current_video_frame.size ||
+ start == end) {
+ return;
+ }
+
+ int bytes = end - start;
+ if (current_frame->len + bytes > current_frame->size) {
+ printf("%d bytes overflow after last %s frame\n", current_frame->len + bytes - current_frame->size, frame_type_name);
+ //dump_frame();
+ } else {
+ memcpy(current_frame->data + current_frame->len, start, bytes);
+ current_frame->len += bytes;
+ }
+}
+
+void decode_packs(const libusb_transfer *xfr,
+ const char *sync_pattern,
+ int sync_length,
+ FrameAllocator::Frame *current_frame,
+ const char *frame_type_name,
+ function<void(const uint8_t *start)> start_callback)