22 #ifndef MEDIASTATION_DATAFILE_H 23 #define MEDIASTATION_DATAFILE_H 25 #include "common/file.h" 26 #include "common/stream.h" 27 #include "common/path.h" 28 #include "common/rect.h" 29 #include "common/str.h" 50 kDatumTypeEmpty = 0x00,
51 kDatumTypeUint8 = 0x02,
52 kDatumTypeUint16 = 0x03,
53 kDatumTypeUint32 = 0x04,
54 kDatumTypeInt8 = 0x05,
55 kDatumTypeInt16 = 0x06,
56 kDatumTypeInt32 = 0x07,
57 kDatumTypeFloat = 0x08,
58 kDatumTypeDouble = 0x09,
59 kDatumTypeFilename = 0x0a,
60 kDatumTypeRect = 0x0d,
61 kDatumTypePoint = 0x0e,
62 kDatumTypeGraphicSize = 0x0f,
63 kDatumTypeGraphicUnit = 0x10,
64 kDatumTypeTime = 0x11,
65 kDatumTypeString = 0x12,
66 kDatumTypeVersion = 0x13,
67 kDatumTypeChannelIdent = 0x1b,
68 kDatumTypePolygon = 0x1d,
78 uint16 readTypedUint16();
79 uint32 readTypedUint32();
80 int8 readTypedSByte();
81 int16 readTypedSint16();
82 int32 readTypedSint32();
83 float readTypedFloat();
84 double readTypedDouble();
89 int16 readTypedGraphicUnit();
90 double readTypedTime();
93 uint32 readTypedChannelIdent();
96 void readAndVerifyType(DatumType type);
104 uint32 bytesRemaining();
105 uint32 startPos()
const {
return _dataStartOffset; }
111 virtual bool eos()
const {
return _parentStream->eos(); };
112 virtual bool err()
const {
return _parentStream->err(); };
113 virtual void clearErr() { _parentStream->clearErr(); };
114 virtual uint32 read(
void *dataPtr, uint32 dataSize);
115 virtual int64
pos()
const {
return _parentStream->pos(); };
116 virtual int64
size()
const {
return _parentStream->size(); };
117 virtual bool skip(uint32 offset) {
return seek(offset, SEEK_CUR); };
118 virtual bool seek(int64 offset,
int whence = SEEK_SET);
122 uint32 _dataStartOffset = 0;
123 uint32 _dataEndOffset = 0;
146 typedef uint32 ChannelIdent;
151 void openStream(uint streamId);
152 void closeStream() { close(); }
164 void setChannelIdent(ChannelIdent channelIdent) { _channelIdent = channelIdent; }
165 ChannelIdent channelIdent()
const {
return _channelIdent; }
167 virtual void readChunk(
Chunk &chunk) {};
169 void registerWithStreamManager();
170 void unregisterWithStreamManager();
173 ChannelIdent _channelIdent = 0;
181 virtual void openFeed(uint streamId, uint startOffset) = 0;
186 virtual void closeFeed() = 0;
187 virtual void stopFeed() = 0;
188 virtual void readData() = 0;
201 virtual void openFeed(uint streamId, uint startOffset)
override;
202 virtual void closeFeed()
override;
204 virtual void stopFeed()
override {};
205 virtual void readData()
override;
214 ChannelClient *channelClientForChannel(uint clientId) {
return _channelClients.getValOrDefault(clientId); }
216 ImtStreamFeed *openStreamFeed(uint streamId, uint offsetInStream = 0, uint maxBytesToRead = 0);