00001 // cstrmbuf.h : interface of bidirectional bit operations of packeted bitstream file
00002 //
00003 // This class provides a set of bit-based and byte-based functions
00004 // to read information from packeted bitstream file in two direction and manage buffer.
00005 //
00006 //*****************************************************************************
00007 //
00008 // MPEG Developing Classes
00009 //
00010 // Copyright (C) 1998, Vision and Neural Networks Laboratory, Computer Science
00011 // Department, Wayne State University, All Rights Reserved;
00012 //
00013 // Disclaimer of Warranty
00014 //
00015 // MPEG Developing Classes, both binary and source (hereafter, Software)
00016 // is copyrighted by Vision and Neural Networks Laboratory, Computer Science
00017 // Department, Wayne State University (WSU), and ownership remains with WSU.
00018 //
00019 // Permission is hereby granted, free of charge, to any person obtaining
00020 // a copy of this software and associated documentation files to use, copy,
00021 // and distribute the software, provided that no charge is associated with
00022 // such copies and that the copyright notice and this statement appears on
00023 // all copies.
00024 //
00025 // THE SOFTWARE IS AVAILABLE TO THE USER ON AN "AS IS" BASIS, WITHOUT WARRANTY
00026 // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE
00027 // IMPLIED WARRANTIES OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00028 // IN NO EVENT SHALL THE COPYRIGHT-HOLDER BE LIABLE FOR ANY CLAIMS, DAMAGES, OR
00029 // OTHER LIABILITIES OF ANY KIND WHATSOEVER ARISING FROM, OUT OF OR IN CONNECTION
00030 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THIS
00031 // DISCLAIMAER OF WARRANTY EXTENDS TO THE USER OF THIS SOFTWARE. ALSO THE WSU
00032 // DOES NOT REPRESENT OR WARRANT THAT THE SOFTWARE FURNISHED HEREUNDER ARE FREE OF
00033 // INFRINGMENT OF ANY THIRD-PARTY PATENTS.
00034 //
00035 // Many patents of MPEG-1 and MPEG-2 are general enough such that commercial
00036 // implementations, including shareware, are unavoidable subject to royalty fees to
00037 // patent holders, regardless of implementation design.
00038 //
00039 //
00040 // Vision and Neural Networks Laboratory,
00041 // Computer Science Department,
00042 // Wayne State University,
00043 // Detroit, MI 48202.
00044 // Dongge Li(dil@cs.wayne.edu) and Ishwar K. Sethi(sethi@cs.wayne.edu).
00045 //
00047
00048 #if !defined CSTREAMBUF_H
00049 #define CSTREAMBUF_H
00050
00051 #include <stdio.h>
00052 #include "datatype.h"
00053 #include "mpegdata.h"
00054 #include "cobitbuf.h"
00055 #include "cdlist.h"
00056
00057 const int MAX_PACKET_NUM=80;
00058 const int SEARCH_BUF_SIZE=1024;
00059
00060 typedef struct packetpos_tag
00061 {
00062 long lPckHeadLength;
00063 long lDataFilePos;
00064 long lDataLength;
00065 } PACKETPOS;
00066
00067 class CStreamBuf : public COBitBuf
00068 {
00069 // constructor and destructor
00070 public:
00071 CStreamBuf();
00072 ~CStreamBuf();
00073
00074 // attributes
00075 protected:
00076 FILE *pfFile;
00077 DWORD dwStreamID;
00078 CDList<PACKETPOS, MAX_PACKET_NUM> PacketList;
00079 long lBufStartPckPos, lBufEndPckPos;
00080 BYTE *pnSearchBuf; // for packet searching;
00081
00082 // operation
00083 public:
00084 int InitBuffer(FILE *pfTheFile, BYTE nStreamID, DWORD dwBufferSize);
00085 void SearchNextPckData(long lStartFilePos,PACKETPOS *pPckPos);
00086 void SearchPreviousPckData(long lStartFilePos,PACKETPOS *pPckPos);
00087 long FlushBuf(const PACKETPOS &PacketPos, long lPckOffset);
00088 long GetCurPacketPos(PACKETPOS *pPacketPos);
00089 bool IsPacketedStream(void) {return (dwStreamID==0) ? false : true;};
00090
00091 // override
00092 public:
00093 void ResetBuffer(void);
00094
00095 protected:
00096 virtual long FwdLoadData(long lLoadStartPos, DWORD dwItemNum); // used by other functions
00097 virtual long BackLoadData(long lLoadEndPos, DWORD dwItemNum);
00098 virtual long FlushBuf(long lOffset, BUFPOS *pBufPos);
00099 };
00100
00101 #endif // CSTREAMBUF_H
1.2.12 written by Dimitri van Heesch,
© 1997-2001