// Emits the exact bytes hyperion.c would put on the wire, so the FlatBuffers // encoding can be checked against the reference implementation. // // ./fb_dump register out.bin // ./fb_dump image out.bin #include "../native/src/net/hyperion.h" #include #include #include int main(int argc, char** argv) { if (argc < 3) { fprintf(stderr, "usage: %s \n", argv[0]); return 2; } size_t len = 0; uint8_t* buf = NULL; if (strcmp(argv[1], "register") == 0) { buf = hyperion_build_register("lgtv-audio-cap", 150, &len); } else if (strcmp(argv[1], "image") == 0) { // 4x2 RGB gradient: distinctive enough that a wrong vector offset or // a swapped width/height shows up immediately. const int w = 4, h = 2; uint8_t rgb[4 * 2 * 3]; for (int i = 0; i < w * h; i++) { rgb[i * 3 + 0] = (uint8_t)(i * 10); rgb[i * 3 + 1] = (uint8_t)(i * 10 + 1); rgb[i * 3 + 2] = (uint8_t)(i * 10 + 2); } buf = hyperion_build_image(rgb, w, h, &len); } else { fprintf(stderr, "unknown message '%s'\n", argv[1]); return 2; } if (!buf) { fprintf(stderr, "build failed\n"); return 1; } FILE* f = fopen(argv[2], "wb"); if (!f) { perror("fopen"); free(buf); return 1; } fwrite(buf, 1, len, f); fclose(f); free(buf); fprintf(stderr, "wrote %zu bytes to %s\n", len, argv[2]); return 0; }