blob: 58adda9697ed58cc7e6089205aa4384023a5059c [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) {
Ed Tanous55c7b7a2018-05-22 15:27:24 -070017 ast_video::RawVideoBuffer out;
Ed Tanouse2fc45a2017-04-26 09:19:10 -070018 bool have_hardware = false;
19 if (access("/dev/video", F_OK) != -1) {
Ed Tanous55c7b7a2018-05-22 15:27:24 -070020 ast_video::SimpleVideoPuller p;
Ed Tanouse2fc45a2017-04-26 09:19:10 -070021 p.initialize();
Ed Tanous55c7b7a2018-05-22 15:27:24 -070022 out = p.readVideo();
Ed Tanouse2fc45a2017-04-26 09:19:10 -070023 } else {
24 FILE *fp = fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
25 if (fp) {
26 size_t newLen = fread(out.buffer.data(), sizeof(char),
27 out.buffer.size() * sizeof(long), fp);
28 if (ferror(fp) != 0) {
29 fputs("Error reading file", stderr);
30 }
31 fclose(fp);
32 out.buffer.resize(newLen);
Ed Tanous55c7b7a2018-05-22 15:27:24 -070033 out.mode = ast_video::YuvMode::YUV444;
Ed Tanouse2fc45a2017-04-26 09:19:10 -070034 out.width = 800;
35 out.height = 600;
Ed Tanous55c7b7a2018-05-22 15:27:24 -070036 out.ySelector = 0;
37 out.uvSelector = 0;
Ed Tanouse2fc45a2017-04-26 09:19:10 -070038 }
39 }
40
41 FILE *fp = fopen("/tmp/screendata.bin", "wb");
42 fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp);
43
Ed Tanous55c7b7a2018-05-22 15:27:24 -070044 ast_video::AstJpegDecoder d;
45 d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
46 out.uvSelector);
Ed Tanouse2fc45a2017-04-26 09:19:10 -070047}