| 1 | #include <stdio.h> |
|---|
| 2 | #include <stdlib.h> |
|---|
| 3 | |
|---|
| 4 | #include "bcmplayer.h" |
|---|
| 5 | |
|---|
| 6 | int main(int argc, char **argv) { |
|---|
| 7 | if (argc < 4) { |
|---|
| 8 | printf("Usage: ./indexfrompts_test INDEXFILE HEXPTS DECIMAL_SEARCH_WINDOW\n"); |
|---|
| 9 | exit(1); |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | const char *indexfile = argv[1]; |
|---|
| 13 | unsigned long gotopts = strtoul(argv[2], NULL, 16); |
|---|
| 14 | unsigned long searchwindow = atoi(argv[3]); |
|---|
| 15 | unsigned long pts; |
|---|
| 16 | |
|---|
| 17 | printf("Params:\n"); |
|---|
| 18 | printf(" bcmindex file: %s\n", indexfile); |
|---|
| 19 | printf(" goto pts: %#x\n", gotopts); |
|---|
| 20 | printf(" search window: %d\n", searchwindow); |
|---|
| 21 | |
|---|
| 22 | FILE *f = fopen(argv[1], "rw"); |
|---|
| 23 | |
|---|
| 24 | BNAV_Player_Handle bcmp; |
|---|
| 25 | BNAV_Player_Settings settings; |
|---|
| 26 | |
|---|
| 27 | BNAV_Player_GetDefaultSettings(&settings); |
|---|
| 28 | settings.readCb = (BP_READ_CB)fread; |
|---|
| 29 | settings.seekCb = (BP_SEEK_CB)fseek; |
|---|
| 30 | settings.tellCb = (BP_TELL_CB)ftell; |
|---|
| 31 | settings.filePointer = f; |
|---|
| 32 | settings.videoPid = 1; // doesn't matter |
|---|
| 33 | |
|---|
| 34 | if (BNAV_Player_Open(&bcmp, &settings)) |
|---|
| 35 | exit(1); |
|---|
| 36 | |
|---|
| 37 | long index = BNAV_Player_FindIndexFromPts(bcmp, gotopts, searchwindow); |
|---|
| 38 | if (index != -1) { |
|---|
| 39 | BNAV_Player_Position pos; |
|---|
| 40 | BNAV_Player_GetPosition(bcmp, &pos); |
|---|
| 41 | printf("Found: %d, pts %#x\n", index, pos.pts); |
|---|
| 42 | } |
|---|
| 43 | else |
|---|
| 44 | printf("Failed.\n"); |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | BNAV_Player_Close(bcmp); |
|---|
| 48 | return 0; |
|---|
| 49 | } |
|---|