-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathb_playback_capture.c
executable file
·84 lines (70 loc) · 2.15 KB
/
b_playback_capture.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "b_playback.h"
#include "bstd.h"
#include "bkni.h"
#include "bdbg.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
Sample app that uses bcmplayer to read and play an MPEG2 TS file w/ trick codes.
Could be the basis for a server-based stream player.
**/
int main(int argc, char **argv)
{
b_playback_t p;
struct b_playback_start_settings start_settings;
struct b_playback_trick_mode trick_mode;
FILE *outputfile;
int rc;
int i;
if (argc < 5) {
printf("Usage: b_playback_capture inputfile.ts inputfile.nav 0x11 outputfile.ts\n");
return -1;
}
BKNI_Init();
BDBG_Init();
p = b_playback_create(NULL);
BDBG_ASSERT(p);
b_playback_get_default_start_settings(&start_settings);
start_settings.datafile = argv[1];
start_settings.indexfile = argv[2];
start_settings.video_pid = strtoul(argv[3], NULL, 0);
rc = b_playback_start(p, &start_settings);
BDBG_ASSERT(!rc);
outputfile = fopen(argv[4], "w");
BDBG_ASSERT(outputfile);
/* first pass w/ normal play */
for (i=0;i<10;i++) {
void *buffer;
unsigned size;
rc = b_playback_get_buffer(p, &buffer, &size);
BDBG_ASSERT(!rc);
if (size == 0) break;
fwrite(buffer, size, 1, outputfile);
rc = b_playback_read_complete(p, size);
BDBG_ASSERT(!rc);
}
rc = b_playback_seek(p, 0, SEEK_SET);
BDBG_ASSERT(!rc);
printf("goto trick mode\n");
b_playback_get_default_trick_mode(&trick_mode);
trick_mode.rate = B_PLAYBACK_NORMAL_RATE * 10;
rc = b_playback_trick_mode(p, &trick_mode);
BDBG_ASSERT(!rc);
/* second pass as trick mode */
for (i=0;i<1000;i++) {
void *buffer;
unsigned size;
rc = b_playback_get_buffer(p, &buffer, &size);
BDBG_ASSERT(!rc);
if (size == 0) break;
fwrite(buffer, size, 1, outputfile);
rc = b_playback_read_complete(p, size);
BDBG_ASSERT(!rc);
}
fclose(outputfile);
b_playback_stop(p);
b_playback_destroy(p);
/* you can now decode the file. be sure to decode in vsync mode because of the embedded trick mode. */
return 0;
}