Alex Bikfalvi
SimStream Documentation
StreamSegment.cpp
00001 #include "Headers.h" 00002 #include "StreamSegment.h" 00003 00004 CStreamSegment::CStreamSegment( 00005 __uint32 size 00006 ) 00007 { 00008 this->stream = 0xFFFFFFFF; 00009 this->index = 0xFFFFFFFF; 00010 this->size = size; 00011 this->completed = 0; 00012 00013 // Allocate frames 00014 this->frames = new CStreamFrame[this->size]; 00015 } 00016 00017 CStreamSegment::~CStreamSegment() 00018 { 00019 // If the frames do not point to the frame for single frame segment, release the memory 00020 delete[] this->frames; 00021 } 00022 00023 void CStreamSegment::Add(CStreamFrame frame) 00024 { 00025 assert(frame.Stream() == this->stream); 00026 assert(frame.SegmentIndex() < this->size); 00027 assert(frame.SegmentSize() == this->size); 00028 00029 this->completed += this->frames[frame.SegmentIndex()].Valid()?0:1; 00030 00031 this->frames[frame.SegmentIndex()] = frame; 00032 } 00033 00034 void CStreamSegment::Reset(__uint32 stream, __uint32 index) 00035 { 00036 // Reset segment to the specified stream and index 00037 this->stream = stream; 00038 this->index = index; 00039 this->completed = 0; 00040 this->receiving = false; 00041 00042 // Clear the frames 00043 for(__uint32 idx = 0; idx < this->size; idx++) 00044 this->frames[idx] = CStreamFrame(); 00045 }
Last updated: February 8, 2011