2 * Copyright 2004-2008, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
5 #ifndef _CAM_DEFRAMER_H
6 #define _CAM_DEFRAMER_H
12 #include "CamFilterInterface.h"
15 #define CAMDEFRAMER_MAX_TAG_LEN 16
16 #define CAMDEFRAMER_MAX_QUEUED_FRAMES 50
19 ST_SYNC
, /* waiting for start of frame */
24 /* should have a real Frame class someday */
25 class CamFrame
: public BMallocIO
{
27 CamFrame() : BMallocIO() { fStamp
= system_time(); };
28 virtual ~CamFrame() {};
29 bigtime_t
Stamp() const { return fStamp
; };
33 class CamDeframer
: public CamFilterInterface
{
35 CamDeframer(CamDevice
*device
);
36 virtual ~CamDeframer();
37 // BPositionIO interface
38 // read from translators/cs transforms
39 virtual ssize_t
Read(void *buffer
, size_t size
);
40 virtual ssize_t
ReadAt(off_t pos
, void *buffer
, size_t size
);
41 virtual off_t
Seek(off_t position
, uint32 seek_mode
);
42 virtual off_t
Position() const;
43 virtual status_t
SetSize(off_t size
);
44 // write from usb transfers
45 virtual ssize_t
Write(const void *buffer
, size_t size
);
46 virtual ssize_t
WriteAt(off_t pos
, const void *buffer
, size_t size
);
48 virtual status_t
WaitFrame(bigtime_t timeout
);
49 virtual status_t
GetFrame(CamFrame
**frame
, bigtime_t
*stamp
); // caller deletes
50 virtual status_t
DropFrame();
52 status_t
RegisterSOFTags(const uint8
**tags
, int count
, size_t len
, size_t skip
);
53 status_t
RegisterEOFTags(const uint8
**tags
, int count
, size_t len
, size_t skip
);
57 int FindTags(const uint8
*buf
, size_t buflen
, const uint8
**tags
, int tagcount
, size_t taglen
, size_t skiplen
, int *which
=NULL
);
58 int FindSOF(const uint8
*buf
, size_t buflen
, int *which
=NULL
);
59 int FindEOF(const uint8
*buf
, size_t buflen
, int *which
=NULL
);
61 CamFrame
*AllocFrame();
70 CamFrame
*fCurrentFrame
; /* the one we write to*/
73 const uint8
**fSOFTags
;
74 const uint8
**fEOFTags
;
87 #endif /* _CAM_DEFRAMER_H */