blob: f84b302ebfdf5efe2a3ad7c16c4c813e893a01bd [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>
Ed Tanous1abe55e2018-09-05 08:30:59 -07005
Ed Tanouse2fc45a2017-04-26 09:19:10 -07006#include <ast_jpeg_decoder.hpp>
7#include <ast_video_puller.hpp>
8#include <chrono>
9#include <fstream>
10#include <iomanip>
11#include <iostream>
12#include <thread>
13#include <vector>
Ed Tanous1abe55e2018-09-05 08:30:59 -070014
Ed Tanouse2fc45a2017-04-26 09:19:10 -070015#include <gmock/gmock.h>
16#include <gtest/gtest.h>
17
Ed Tanous1abe55e2018-09-05 08:30:59 -070018TEST(AstvideoPuller, BasicRead)
19{
20 ast_video::RawVideoBuffer out;
21 bool have_hardware = false;
22 if (access("/dev/video", F_OK) != -1)
23 {
24 ast_video::SimpleVideoPuller p;
25 p.initialize();
26 out = p.readVideo();
Ed Tanouse2fc45a2017-04-26 09:19:10 -070027 }
Ed Tanous1abe55e2018-09-05 08:30:59 -070028 else
29 {
30 FILE *fp =
31 fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
32 if (fp)
33 {
34 size_t newLen = fread(out.buffer.data(), sizeof(char),
35 out.buffer.size() * sizeof(long), fp);
36 if (ferror(fp) != 0)
37 {
38 fputs("Error reading file", stderr);
39 }
40 fclose(fp);
41 out.buffer.resize(newLen);
42 out.mode = ast_video::YuvMode::YUV444;
43 out.width = 800;
44 out.height = 600;
45 out.ySelector = 0;
46 out.uvSelector = 0;
47 }
48 }
Ed Tanouse2fc45a2017-04-26 09:19:10 -070049
Ed Tanous1abe55e2018-09-05 08:30:59 -070050 FILE *fp = fopen("/tmp/screendata.bin", "wb");
51 fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp);
Patrick Venture6141c8b2018-10-16 13:11:39 -070052 fclose(fp);
Ed Tanouse2fc45a2017-04-26 09:19:10 -070053
Ed Tanous1abe55e2018-09-05 08:30:59 -070054 ast_video::AstJpegDecoder d;
55 d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
56 out.uvSelector);
Ed Tanouse2fc45a2017-04-26 09:19:10 -070057}