1 #include "VideoSource_DV.hh"
3 #include <Image/Camera.hh>
43 BIASERR(
"VideoSource_DV::VideoSource_DV(int Card): requested card #"<<
IEEE1394Card_<<
" exceeds maximum of "<<MAX_1394_CARDS);
48 BIASDOUT(D_DV,
"Initializing Instances_[] and IEEE1394Handle_[]");
49 for (
int i=0; i<MAX_1394_CARDS; i++) {
53 for (
int i=0; i<MAX_1394_CHANNELS; i++)
54 videosourcefromchannel[i] = NULL;
65 perror(
"raw1394 - couldn't get handle");
66 BIASERR(
"This error usually means that the ieee1394 drivers are not loaded or that /dev/raw1394 not exist.\n");
71 BIASERR(
"raw1394 - couldn't set port");
77 videosourcefromchannel[
Channel_] =
this;
88 BIASDOUT(D_DV,
"I am the last Instance on this bus, so shutting the lights.");
90 videosourcefromchannel[
Channel_] = NULL;
128 cout<<
"GrabSingle()"<<endl;
133 gettimeofday(&time,NULL);
134 image.
SetTime(time.tv_sec,time.tv_usec);
164 int BIAS::raw_dv_handler(raw1394handle_t handle,
int channel,
size_t length,
167 static int packetcount = 0;
172 cout <<
"length >16"<<endl;
173 unsigned char *p = (
unsigned char*) & data[3];
174 int section_type = p[0] >> 5;
175 int dif_sequence = p[1] >> 4;
176 int dif_block = p[2];
179 if (section_type == 0 && dif_sequence == 0) {
180 if (!videosourcefromchannel[channel]->FrameFinished_)
181 if (videosourcefromchannel[channel]->FrameStarted_)
190 if (videosourcefromchannel[channel]->FrameStarted_ &&
191 !videosourcefromchannel[channel]->FrameFinished_) {
193 switch (section_type) {
195 memcpy(videosourcefromchannel[channel]->GrabBuffer_
196 + dif_sequence * 150 * 80, p, 480);
200 memcpy(videosourcefromchannel[channel]->GrabBuffer_
201 + dif_sequence * 150 * 80 + (1 + dif_block) * 80,p, 480);
205 memcpy(videosourcefromchannel[channel]->GrabBuffer_+
206 dif_sequence * 150 * 80 + (3 + dif_block) * 80, p, 480);
210 memcpy(videosourcefromchannel[channel]->GrabBuffer_
211 + dif_sequence * 150 * 80 + (6 + dif_block * 16) * 80,p, 480);
215 memcpy(videosourcefromchannel[channel]->GrabBuffer_+
216 dif_sequence * 150 * 80 + (7 + (dif_block / 15) + dif_block)
221 cout <<
"raw_dv_tomem_handler(): unknown data"<<endl;
224 cout << packetcount <<
" " ;
228 if (packetcount == 300 && !videosourcefromchannel[channel]->FrameFinished_) {
241 iso_handler_t g_oldhandler;
242 BIASDOUT(D_DV,
"PreGrab(), channel: "<<
Channel_);
247 BIASERR(
"raw1394 - couldn't start iso receive");
252 BIASDOUT(D_DV,
"PreGrab() done");
261 BIASDOUT(D_DV,
"PostGrab()");
Defines a common interface to different devices.
static int Instances_[MAX_1394_CARDS]
DV, color model used for digital video cameras such as Mini-DV.
BIAS::ImageBase::EColorModel ColorMode_
Color mode used by camera.
unsigned char * GrabBuffer_
int UseChannel(int channel)
static int InstancesTotal_
static raw1394handle_t IEEE1394Handle_[MAX_1394_CARDS]
int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
void VideoSource_DV_Internal_Init_(int card)
void SetDebugLevel(const long int lv)
void InvalidateUID()
sets the image's uid to invalid
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
int GrabSingle(BIAS::Camera< unsigned char > &image)
int OpenDevice()
selects the first available device to open (e.g.
int PostGrab()
Stop anything started in PreGrab()
void SetTime(unsigned long long int sec, unsigned long long int usec)
Set time and ensure correct format (seconds and useconds after 'sec')
friend int raw_dv_handler(raw1394handle_t handle, int channel, size_t length, quadlet_t *data)
This class extends VideoSource for the use of IEEE1394-connected DV-camcorders.