#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ast_jpeg_decoder.hpp>
#include <ast_video_puller.hpp>
#include <chrono>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <thread>
#include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

TEST(AstvideoPuller, BasicRead) {
  ast_video::RawVideoBuffer out;
  bool have_hardware = false;
  if (access("/dev/video", F_OK) != -1) {
    ast_video::SimpleVideoPuller p;
    p.initialize();
    out = p.readVideo();
  } else {
    FILE *fp = fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
    if (fp) {
      size_t newLen = fread(out.buffer.data(), sizeof(char),
                            out.buffer.size() * sizeof(long), fp);
      if (ferror(fp) != 0) {
        fputs("Error reading file", stderr);
      }
      fclose(fp);
      out.buffer.resize(newLen);
      out.mode = ast_video::YuvMode::YUV444;
      out.width = 800;
      out.height = 600;
      out.ySelector = 0;
      out.uvSelector = 0;
    }
  }

  FILE *fp = fopen("/tmp/screendata.bin", "wb");
  fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp);

  ast_video::AstJpegDecoder d;
  d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
           out.uvSelector);
}
