1 // V4L2 is incompatible with large file support
2 #undef _FILE_OFFSET_BITS
3 #undef _LARGEFILE_SOURCE
4 #undef _LARGEFILE64_SOURCE
9 #include "chantables.h"
11 #include "condition.h"
15 #include "preferences.h"
16 #include "quicktime.h"
17 #include "recordconfig.h"
18 #include "vdevicev4l2jpeg.h"
19 #include "vdevicev4l2.h"
21 #include "videodevice.h"
23 #ifdef HAVE_VIDEO4LINUX2
27 #include <sys/ioctl.h>
38 VDeviceV4L2JPEG::VDeviceV4L2JPEG(VideoDevice *device)
44 VDeviceV4L2JPEG::~VDeviceV4L2JPEG()
49 int VDeviceV4L2JPEG::initialize()
55 int VDeviceV4L2JPEG::open_input()
57 return VDeviceV4L2::get_sources(device,
58 device->in_config->v4l2jpeg_in_device);
61 int VDeviceV4L2JPEG::close_all()
63 if(thread) delete thread;
68 int VDeviceV4L2JPEG::get_best_colormodel(Asset_GC asset)
73 int VDeviceV4L2JPEG::read_buffer(VFrame *frame)
77 if((device->channel_changed || device->picture_changed) && thread)
85 device->channel_changed = 0;
86 device->picture_changed = 0;
87 thread = new VDeviceV4L2Thread(device, BC_COMPRESSED);
92 // Get buffer from thread
94 VFrame *buffer = thread->get_buffer(&timed_out);
100 frame->allocate_compressed_data(buffer->get_compressed_size());
101 frame->set_compressed_size(buffer->get_compressed_size());
103 // Transfer fields to frame
104 if(device->odd_field_first)
106 int field2_offset = mjpeg_get_field2((unsigned char*)buffer->get_data(),
107 buffer->get_compressed_size());
108 int field1_len = field2_offset;
109 int field2_len = buffer->get_compressed_size() -
112 memcpy(frame->get_data(),
113 buffer->get_data() + field2_offset,
115 memcpy(frame->get_data() + field2_len,
121 bcopy(buffer->get_data(),
123 buffer->get_compressed_size());
126 thread->put_buffer();
130 // Driver in 2.6.3 needs to be restarted when it loses sync.
151 // c-file-style: "linux"