]> git.sesse.net Git - bmusb/blob - main.cpp
Add yet another PAL mode.
[bmusb] / main.cpp
1 #include <stdio.h>
2 #include <unistd.h>
3 #include "bmusb.h"
4
5 using namespace std;
6         
7 BMUSBCapture *usb;
8
9 void check_frame_stability(uint16_t timecode,
10                            FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format,
11                            FrameAllocator::Frame audio_frame, size_t audio_offset, uint16_t audio_format)
12 {
13         //printf("0x%04x: %d video bytes (format 0x%04x), %d audio bytes (format 0x%04x)\n",
14         //      timecode, video_end - video_start, video_format, audio_end - audio_start, audio_format);
15
16         static uint16_t last_timecode = 0;
17         static size_t last_video_bytes = 0;
18         static size_t last_audio_bytes = 0;
19
20         if (!(last_timecode == 0 && last_video_bytes == 0 && last_audio_bytes == 0)) {
21                 if (timecode != (uint16_t)(last_timecode + 1)) {
22                         printf("0x%04x: Dropped %d frames\n", timecode, timecode - last_timecode - 1);
23                 } else if (last_video_bytes != video_frame.len - video_offset) {
24                         printf("0x%04x: Video frame size changed (old=%d, cur=%d)\n", timecode,
25                                 last_video_bytes, video_frame.len - video_offset);
26                 } else if (last_audio_bytes != audio_frame.len - audio_offset) {
27                         printf("0x%04x: Audio block size changed (old=%d, cur=%d)\n", timecode,
28                                 last_audio_bytes, audio_frame.len - audio_offset);
29                 }
30         }
31         last_timecode = timecode;
32         last_video_bytes = video_frame.len - video_offset;
33         last_audio_bytes = audio_frame.len - audio_offset;
34
35         usb->get_video_frame_allocator()->release_frame(video_frame);
36         usb->get_audio_frame_allocator()->release_frame(audio_frame);
37 }
38
39 int main(int argc, char **argv)
40 {
41         usb = new BMUSBCapture;
42         usb->set_frame_callback(check_frame_stability);
43         usb->configure_card();
44         BMUSBCapture::start_bm_thread();
45         usb->start_bm_capture();
46         sleep(1000000);
47 }
48