Make CamFrame a subclass of BMallocIO to add a timestamp field.
Set the field on allocation and pass it around. Still disabled as CodyCam drops everything, I should probably drop old frames from the buffer... for now it uses system_time() to make CodyCam happy. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23307 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7815f565dc
commit
6bb8b29f48
@ -108,7 +108,7 @@ CamDeframer::GetFrame(CamFrame **frame, bigtime_t *stamp)
|
||||
if (!f)
|
||||
return ENOENT;
|
||||
*frame = f;
|
||||
*stamp = 0LL;
|
||||
*stamp = f->Stamp();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,14 @@ ST_FRAME
|
||||
|
||||
|
||||
/* should have a real Frame class someday */
|
||||
#define CamFrame BMallocIO
|
||||
class CamFrame : public BMallocIO
|
||||
{
|
||||
public:
|
||||
CamFrame() : BMallocIO() { fStamp = system_time(); };
|
||||
virtual ~CamFrame() {};
|
||||
bigtime_t Stamp() const { return fStamp; };
|
||||
bigtime_t fStamp;
|
||||
};
|
||||
|
||||
class CamDeframer : public CamFilterInterface
|
||||
{
|
||||
|
@ -242,14 +242,14 @@ CamDevice::WaitFrame(bigtime_t timeout)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
status_t
|
||||
CamDevice::GetFrameBitmap(BBitmap **bm)
|
||||
CamDevice::GetFrameBitmap(BBitmap **bm, bigtime_t *stamp)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
status_t
|
||||
CamDevice::FillFrameBuffer(BBuffer *buffer)
|
||||
CamDevice::FillFrameBuffer(BBuffer *buffer, bigtime_t *stamp)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ class CamDevice {
|
||||
|
||||
// several ways to get raw frames
|
||||
virtual status_t WaitFrame(bigtime_t timeout);
|
||||
virtual status_t GetFrameBitmap(BBitmap **bm);
|
||||
virtual status_t FillFrameBuffer(BBuffer *buffer);
|
||||
virtual status_t GetFrameBitmap(BBitmap **bm, bigtime_t *stamp=NULL);
|
||||
virtual status_t FillFrameBuffer(BBuffer *buffer, bigtime_t *stamp=NULL);
|
||||
|
||||
// locking
|
||||
bool Lock();
|
||||
|
@ -744,10 +744,12 @@ VideoProducer::FrameGenerator()
|
||||
/* For a buffer originating from a device, you might want to calculate
|
||||
* this based on the PerformanceTimeFor the time your buffer arrived at
|
||||
* the hardware (plus any applicable adjustments). */
|
||||
/*
|
||||
h->start_time = fPerformanceTimeBase +
|
||||
(bigtime_t)
|
||||
((fFrame - fFrameBase) *
|
||||
(1000000 / fConnectedFormat.field_rate));
|
||||
*/
|
||||
h->file_pos = 0;
|
||||
h->orig_size = 0;
|
||||
h->data_offset = 0;
|
||||
@ -771,19 +773,24 @@ VideoProducer::FrameGenerator()
|
||||
//NO! must be called without lock!
|
||||
//BAutolock lock(fCamDevice->Locker());
|
||||
|
||||
bigtime_t stamp;
|
||||
//#ifdef UseFillFrameBuffer
|
||||
err = fCamDevice->FillFrameBuffer(buffer);
|
||||
err = fCamDevice->FillFrameBuffer(buffer, &stamp);
|
||||
if (err < B_OK) {
|
||||
;//XXX handle error
|
||||
}
|
||||
//#endif
|
||||
#ifdef UseGetFrameBitmap
|
||||
BBitmap *bm;
|
||||
err = fCamDevice->GetFrameBitmap(&bm);
|
||||
err = fCamDevice->GetFrameBitmap(&bm, &stamp);
|
||||
if (err >= B_OK) {
|
||||
;//XXX handle error
|
||||
}
|
||||
#endif
|
||||
//PRINTF(1, ("FrameGenerator: stamp %Ld vs %Ld\n", stamp, h->start_time));
|
||||
//XXX: that's what we should be doing, but CodyCam drops all frames as they are late. (maybe add latency ??)
|
||||
//h->start_time = TimeSource()->PerformanceTimeFor(stamp);
|
||||
h->start_time = TimeSource()->PerformanceTimeFor(system_time());
|
||||
|
||||
PRINTF(1, ("FrameGenerator: SendBuffer...\n"));
|
||||
/* Send the buffer on down to the consumer */
|
||||
|
@ -415,18 +415,17 @@ SonixCamDevice::ValidateEndOfFrameTag(const uint8 *tag, size_t taglen, size_t da
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
status_t
|
||||
SonixCamDevice::GetFrameBitmap(BBitmap **bm)
|
||||
SonixCamDevice::GetFrameBitmap(BBitmap **bm, bigtime_t *stamp=NULL)
|
||||
{
|
||||
BBitmap *b;
|
||||
CamFrame *f;
|
||||
bigtime_t stamp;
|
||||
status_t err;
|
||||
PRINT((CH "()" CT));
|
||||
err = fDeframer->WaitFrame(200000);
|
||||
if (err < B_OK) { PRINT((CH ": WaitFrame: %s" CT, strerror(err))); }
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
err = fDeframer->GetFrame(&f, &stamp);
|
||||
err = fDeframer->GetFrame(&f, stamp);
|
||||
if (err < B_OK) { PRINT((CH ": GetFrame: %s" CT, strerror(err))); }
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
@ -446,10 +445,9 @@ SonixCamDevice::GetFrameBitmap(BBitmap **bm)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
status_t
|
||||
SonixCamDevice::FillFrameBuffer(BBuffer *buffer)
|
||||
SonixCamDevice::FillFrameBuffer(BBuffer *buffer, bigtime_t *stamp)
|
||||
{
|
||||
CamFrame *f;
|
||||
bigtime_t stamp;
|
||||
status_t err;
|
||||
PRINT((CH "()" CT));
|
||||
|
||||
@ -459,7 +457,7 @@ SonixCamDevice::FillFrameBuffer(BBuffer *buffer)
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
||||
err = fDeframer->GetFrame(&f, &stamp);
|
||||
err = fDeframer->GetFrame(&f, stamp);
|
||||
if (err < B_OK) { PRINT((CH ": GetFrame: %s" CT, strerror(err))); }
|
||||
if (err < B_OK)
|
||||
return err;
|
||||
|
@ -68,8 +68,8 @@ class SonixCamDevice : public CamDevice
|
||||
virtual bool ValidateStartOfFrameTag(const uint8 *tag, size_t taglen);
|
||||
virtual bool ValidateEndOfFrameTag(const uint8 *tag, size_t taglen, size_t datalen);
|
||||
|
||||
virtual status_t GetFrameBitmap(BBitmap **bm);
|
||||
virtual status_t FillFrameBuffer(BBuffer *buffer);
|
||||
virtual status_t GetFrameBitmap(BBitmap **bm, bigtime_t *stamp=NULL);
|
||||
virtual status_t FillFrameBuffer(BBuffer *buffer, bigtime_t *stamp=NULL);
|
||||
|
||||
|
||||
void DumpRegs();
|
||||
|
Loading…
Reference in New Issue
Block a user