Ed Tanous | e2fc45a | 2017-04-26 09:19:10 -0700 | [diff] [blame] | 1 | #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 | |
| 16 | TEST(AstvideoPuller, BasicRead) { |
Ed Tanous | e2fc45a | 2017-04-26 09:19:10 -0700 | [diff] [blame] | 17 | AstVideo::RawVideoBuffer out; |
| 18 | bool have_hardware = false; |
| 19 | if (access("/dev/video", F_OK) != -1) { |
| 20 | AstVideo::SimpleVideoPuller p; |
| 21 | p.initialize(); |
| 22 | out = p.read_video(); |
| 23 | } 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); |
| 33 | out.mode = AstVideo::YuvMode::YUV444; |
| 34 | out.width = 800; |
| 35 | out.height = 600; |
| 36 | out.y_selector = 0; |
| 37 | out.uv_selector = 0; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | FILE *fp = fopen("/tmp/screendata.bin", "wb"); |
| 42 | fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp); |
| 43 | |
| 44 | AstVideo::AstJpegDecoder d; |
Ed Tanous | e2fc45a | 2017-04-26 09:19:10 -0700 | [diff] [blame] | 45 | d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector, |
| 46 | out.uv_selector); |
| 47 | } |