Ed Tanous | 1ccd57c | 2017-03-21 13:15:58 -0700 | [diff] [blame] | 1 | #include <video.h> |
| 2 | #include <fstream> |
| 3 | #include <iostream> |
| 4 | #include <iomanip> |
| 5 | |
| 6 | namespace AstVideo { |
| 7 | class VideoPuller { |
| 8 | public: |
| 9 | VideoPuller() {} |
| 10 | |
| 11 | void initialize() { |
| 12 | std::cout << "Opening /dev/video\n"; |
| 13 | file.open("/dev/video", std::ios::out | std::ios::in | std::ios::binary); |
| 14 | if (!file.is_open()) { |
| 15 | std::cout << "Failed to open /dev/video\n"; |
| 16 | } |
| 17 | IMAGE_INFO image_info{}; |
| 18 | |
| 19 | file.write(reinterpret_cast<char*>(&image_info), sizeof(image_info)); |
| 20 | |
| 21 | file.read(reinterpret_cast<char*>(&image_info), sizeof(image_info)); |
| 22 | |
| 23 | if (file){ |
| 24 | std::cout << "Read succeeded\n"; |
| 25 | } |
| 26 | |
| 27 | auto pt = reinterpret_cast<char*>(&image_info); |
| 28 | |
| 29 | for(int i=0; i<sizeof(image_info); i++){ |
| 30 | std::cout << std::hex << std::setfill('0') << std::setw(2) << int(*(pt + i)) << " "; |
| 31 | } |
| 32 | |
| 33 | std::cout << "\n"; |
| 34 | |
| 35 | std::cout << "typedef struct _video_features {\n"; |
| 36 | std::cout << "short jpg_fmt: " << image_info.parameter.features.jpg_fmt << "\n"; |
| 37 | std::cout << "short lumin_tbl;" << image_info.parameter.features.lumin_tbl << "\n"; |
| 38 | std::cout << "short chrom_tbl;" << image_info.parameter.features.chrom_tbl << "\n"; |
| 39 | std::cout << "short tolerance_noise;" << image_info.parameter.features.tolerance_noise << "\n"; |
| 40 | std::cout << "int w;" << image_info.parameter.features.w << "\n"; |
| 41 | std::cout << "int h;" << image_info.parameter.features.h << "\n"; |
| 42 | //std::cout << "unsigned char *buf;" << image_info.parameter.features.buf << "\n"; |
| 43 | std::cout << "} FEATURES_TAG;\n"; |
| 44 | |
| 45 | std::cout << "typedef struct _image_info {"; |
| 46 | std::cout << "short do_image_refresh;" << image_info.do_image_refresh << "\n"; |
| 47 | std::cout << "char qc_valid;" << image_info.qc_valid << "\n"; |
| 48 | std::cout << "unsigned int len;" << image_info.len << "\n"; |
| 49 | std::cout << "int crypttype;" << image_info.crypttype << "\n"; |
| 50 | std::cout << "char cryptkey[16];" << image_info.cryptkey << "\n"; |
| 51 | std::cout << "union {\n"; |
| 52 | std::cout << " FEATURES_TAG features;\n"; |
| 53 | std::cout << " AST_CURSOR_TAG cursor_info;\n"; |
| 54 | std::cout << "} parameter;\n"; |
| 55 | std::cout << "} IMAGE_INFO;\n"; |
| 56 | std::cout << std::endl; |
| 57 | } |
| 58 | std::fstream file; |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | int main() { |
| 63 | AstVideo::VideoPuller p; |
| 64 | p.initialize(); |
| 65 | |
| 66 | return 1; |
| 67 | } |