blob: ef1cbe3b6dc7b7f86263cc92938517741cf72386 [file] [log] [blame]
Ed Tanouse2fc45a2017-04-26 09:19:10 -07001#include <fcntl.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <unistd.h>
5#include <ast_jpeg_decoder.hpp>
6#include <ast_video_puller.hpp>
7#include <chrono>
8#include <fstream>
9#include <iomanip>
10#include <iostream>
11#include <thread>
12#include <vector>
13#include <gmock/gmock.h>
14#include <gtest/gtest.h>
15
16TEST(AstvideoPuller, BasicRead) {
17 std::cout << "Started\n";
18 AstVideo::RawVideoBuffer out;
19 bool have_hardware = false;
20 if (access("/dev/video", F_OK) != -1) {
21 AstVideo::SimpleVideoPuller p;
22 p.initialize();
23 out = p.read_video();
24 } else {
25 FILE *fp = fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
26 if (fp) {
27 size_t newLen = fread(out.buffer.data(), sizeof(char),
28 out.buffer.size() * sizeof(long), fp);
29 if (ferror(fp) != 0) {
30 fputs("Error reading file", stderr);
31 }
32 fclose(fp);
33 out.buffer.resize(newLen);
34 out.mode = AstVideo::YuvMode::YUV444;
35 out.width = 800;
36 out.height = 600;
37 out.y_selector = 0;
38 out.uv_selector = 0;
39 }
40 }
41
42 FILE *fp = fopen("/tmp/screendata.bin", "wb");
43 fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp);
44
45 AstVideo::AstJpegDecoder d;
46 std::cout << "MODE " << static_cast<int>(out.mode);
47 d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
48 out.uv_selector);
49}