CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #include "SDIFCollection.hxx" 00023 #include "SDIFFrame.hxx" 00024 #include "SDIFStream.hxx" 00025 #include "SDIFMatrix.hxx" 00026 00027 namespace SDIF 00028 { 00029 00030 Collection::Collection(bool autoStreamAdding) 00031 :mAutoStreamAdding(autoStreamAdding) 00032 { 00033 } 00034 00035 void Collection::Add(Frame* pFrame) 00036 { 00037 mFrameList.push_back(pFrame); 00038 00039 if (mAutoStreamAdding) { 00040 Stream* pStream = FindStream(pFrame->mHeader.mStreamId); 00041 if (!pStream) 00042 { 00043 pStream = 00044 new Stream(pFrame->mHeader.mType,pFrame->mHeader.mStreamId); 00045 Add(pStream); 00046 } 00047 CLAM_ASSERT(pFrame->mHeader.mType==pStream->StreamType(), 00048 "Trying to add a frame to a stream with the same ID but a different type"); 00049 pStream->Add(pFrame); 00050 } 00051 } 00052 00053 void Collection::Add(Stream* pStream) 00054 { 00055 mStreamList.push_back(pStream); 00056 } 00057 00058 void Collection::ParseStreams(void) 00059 { 00060 typedef std::list<Frame*>::iterator iterator; 00061 00062 iterator it = mFrameList.begin(); 00063 iterator end = mFrameList.end(); 00064 00065 while (it!=end) 00066 { 00067 Frame* pFrame = *it; 00068 00069 Stream* pStream = FindStream(pFrame->mHeader.mStreamId); 00070 if (!pStream) { 00071 pStream = 00072 new Stream(pFrame->mHeader.mType,pFrame->mHeader.mStreamId); 00073 00074 Add(pStream); 00075 } 00076 pStream->Add(pFrame); 00077 00078 it++; 00079 } 00080 } 00081 00082 Stream* Collection::FindStream(CLAM::TInt32 streamId) 00083 { 00084 typedef std::list<Stream*>::iterator iterator; 00085 00086 iterator it = mStreamList.begin(); 00087 iterator end = mStreamList.end(); 00088 00089 while (it!=end) 00090 { 00091 Stream* pStream = *it; 00092 if (pStream->StreamId()==streamId) return pStream; 00093 00094 it++; 00095 } 00096 00097 return 0; 00098 } 00099 00100 Stream* Collection::FindStream(TypeId streamTypeId) 00101 { 00102 typedef std::list<Stream*>::iterator iterator; 00103 00104 iterator it = mStreamList.begin(); 00105 iterator end = mStreamList.end(); 00106 00107 while (it!=end) 00108 { 00109 Stream* pStream = *it; 00110 if (pStream->StreamType()==streamTypeId) return pStream; 00111 00112 it++; 00113 } 00114 00115 return 0; 00116 } 00117 00118 00119 } 00120