AdaptorChain Class Reference

<class description="" goes="" here=""> <short description=""> More...

#include <AdaptorChain.hpp>

Inheritance diagram for AdaptorChain:

Adaptor AudioAdaptorChain VideoAdaptorChain ColorReductionAdaptor QualityReductionAdaptor SpatialReductionAdaptor List of all members.

Public Member Functions

 AdaptorChain ()
 Constructor.
virtual ~AdaptorChain ()
 Destructor.
virtual list< Frame * > adapt (Frame *frm)
 Virtual method, used to adapt a input Frame object to a list of output Frame objects.
virtual bool addAdaptor (Adaptor *pAdaptor)
 Add a new Adaptor to the adaptor chain.
bool pushFrontAdaptor (Adaptor *pAdaptor)
 adds an adaptor to the front of the adaptor list!
list< Adaptor * > * getAdaptors ()
virtual list< Frame * > close ()
 Close the adaptor chain, and flush all buffered Frame objects (if any).
virtual void initialize ()
 Initialize internal data structures.
virtual u32 getTranscodingCosts () const
 returns adaptation costs (CPU only)

Protected Attributes

list< Adaptor * > mAdaptorList
 List of Adaptor objects.

Detailed Description

<class description="" goes="" here=""> <short description="">

Author:
Michael Kropfberger and Peter Schojer
Version:
Id
AdaptorChain.hpp,v 1.9 2005/06/19 14:47:22 mkropfbe Exp

Definition at line 60 of file AdaptorChain.hpp.


Constructor & Destructor Documentation

AdaptorChain::AdaptorChain  ) 
 

Constructor.

Definition at line 48 of file AdaptorChain.cpp.

00049 { 00050 initialized = false; 00051 strcpy(name,"AdaptorChain"); 00052 }

AdaptorChain::~AdaptorChain  )  [virtual]
 

Destructor.

Definition at line 55 of file AdaptorChain.cpp.

References mAdaptorList.

00056 { 00057 dprintf_full("AdaptorChain::~AdaptorChain()\n"); 00058 list < Adaptor * >::iterator adaptorIterator; 00059 for (adaptorIterator = mAdaptorList.begin(); 00060 adaptorIterator != mAdaptorList.end(); adaptorIterator++) { 00061 if (*adaptorIterator != NULL) 00062 delete *adaptorIterator; 00063 } 00064 00065 }


Member Function Documentation

list< Frame * > AdaptorChain::adapt Frame frm  )  [virtual]
 

Virtual method, used to adapt a input Frame object to a list of output Frame objects.

Reimplemented from Adaptor.

Definition at line 120 of file AdaptorChain.cpp.

References Adaptor::adapt(), initialize(), and mAdaptorList.

00121 { 00122 list < Frame * >*inFrameList=NULL; 00123 list < Frame * >*outFrameList=NULL; 00124 list < Frame * >retFrameList; 00125 list < Adaptor * >::iterator adaptorIterator; 00126 Adaptor *adaptor=NULL; 00127 Frame *frame=NULL; 00128 Frame *tmpFrame=NULL; 00129 00130 if (!initialized) 00131 initialize(); 00132 00133 dprintf_full("AdaptorChain::adapt Input Frame is %p\n",frm); 00134 00135 if (!initialized) { 00136 list<Frame*> tmp; 00137 return tmp; 00138 } 00139 00140 inFrameList = new list < Frame * >; 00141 outFrameList = new list < Frame * >; 00142 inFrameList->push_back(frm); 00143 00144 for (adaptorIterator = mAdaptorList.begin(); 00145 adaptorIterator != mAdaptorList.end(); adaptorIterator++) { 00146 adaptor = *adaptorIterator; 00147 //dprintf_full("AdaptorChain::adapt will use sub-adaptor %s\n",adaptor->getName()); 00148 00149 // WARNING: 00150 // we never delete input frames 00151 // only intermediate frames created by an adaptor are deleted 00152 frame=NULL; 00153 while (!inFrameList->empty()) { 00154 frame = inFrameList->front(); 00155 //dprintf_full("AdaptorChain::adapt getting from inList Frame %p\n",frame); 00156 00157 retFrameList = adaptor->adapt(frame); 00158 tmpFrame=NULL; 00159 while (!retFrameList.empty()) { 00160 tmpFrame=retFrameList.front(); 00161 retFrameList.pop_front(); 00162 //dprintf_full("AdaptorChain::adapt getting adaptation result Frame %p\n",tmpFrame); 00163 outFrameList->push_back(tmpFrame); 00164 if(frame && frame!=tmpFrame && frame!=frm) { 00165 dprintf_full("AdaptorChain::adapt deleting Frame %p\n",frame); 00166 delete frame; 00167 frame=NULL; 00168 } 00169 } 00170 if(frame && frame!=tmpFrame && frame!=frm) { 00171 // caching adaptors have to deep-copy 00172 dprintf_full("AdaptorChain::adapt deleting cached Frame %p\n",frame); 00173 delete frame; 00174 frame=NULL; 00175 } 00176 inFrameList->pop_front(); 00177 } 00178 delete inFrameList; 00179 00180 // moving to next adaptor, outFrameList is going to be the new inFrameList 00181 inFrameList = outFrameList; 00182 outFrameList = new list < Frame * >; 00183 } 00184 00185 delete outFrameList; 00186 list<Frame*> resultList=*inFrameList; 00187 00188 delete inFrameList; 00189 return resultList; 00190 }

bool AdaptorChain::addAdaptor Adaptor pAdaptor  )  [virtual]
 

Add a new Adaptor to the adaptor chain.

FIXME: check for valid chain not implemented!

Parameters:
pAdaptor Pointer to Adaptor which should be added.
Returns:
true if adding pAdaptor creates a valid adaptor chain, false otherwise
Definition at line 193 of file AdaptorChain.cpp.

References mAdaptorList.

Referenced by VideoAdaptorChain::clone(), AudioAdaptorChain::clone(), SpatialReductionAdaptor::initialize(), QualityReductionAdaptor::initialize(), ColorReductionAdaptor::initialize(), and DataChannel::visualizeCaching().

00194 { 00195 // Some tricky check if inserting pAdaptor creates 00196 // a valid chain should be done here! 00197 mAdaptorList.push_back(pAdaptor); 00198 return true; 00199 }

list< Frame * > AdaptorChain::close  )  [virtual]
 

Close the adaptor chain, and flush all buffered Frame objects (if any).

Returns:
List of Frame objects.

Reimplemented from Adaptor.

Definition at line 80 of file AdaptorChain.cpp.

References mAdaptorList.

00081 { 00082 list < Frame * >l; 00083 list < Adaptor * >::iterator adaptorIterator; 00084 list < Frame * >::iterator li; 00085 for (adaptorIterator = mAdaptorList.begin(); 00086 adaptorIterator != mAdaptorList.end(); adaptorIterator++) { 00087 int size = l.size(); 00088 00089 // feed all from l into the next adaptor 00090 // and store the returned results at the end of l 00091 while (size > 0) { 00092 li = l.begin(); 00093 list < Frame * >l2 = (*adaptorIterator)->adapt(*li); 00094 00095 if( (*li) != (*(l2.begin())) ) 00096 delete (*li); 00097 list < Frame * >::iterator li2; 00098 while (!l2.empty()) { 00099 li2 = l2.begin(); 00100 l.push_back(*li2); 00101 l2.pop_front(); 00102 } 00103 l.pop_front(); // remove the first element, which is already adapted 00104 --size; 00105 } 00106 // after we have sent all frames returned from the previous close, 00107 // close this adaptor so that it is guaranteed empty 00108 list < Frame * >l2 = (*adaptorIterator)->close(); 00109 list < Frame * >::iterator li2; 00110 while (!l2.empty()) { 00111 li2 = l2.begin(); 00112 l.push_back(*li2); 00113 l2.pop_front(); 00114 } 00115 } 00116 return l; 00117 }

void AdaptorChain::initialize  )  [virtual]
 

Initialize internal data structures.

Implements Adaptor.

Reimplemented in ColorReductionAdaptor, QualityReductionAdaptor, and SpatialReductionAdaptor.

Definition at line 68 of file AdaptorChain.cpp.

References mAdaptorList.

Referenced by adapt().

00069 { 00070 list < Adaptor * >::iterator adaptorIterator; 00071 00072 initialized = true; 00073 for (adaptorIterator = mAdaptorList.begin(); 00074 adaptorIterator != mAdaptorList.end(); adaptorIterator++) { 00075 (*adaptorIterator)->initialize(); 00076 } 00077 };


Member Data Documentation

list< Adaptor * > AdaptorChain::mAdaptorList [protected]
 

List of Adaptor objects.

Definition at line 111 of file AdaptorChain.hpp.

Referenced by adapt(), addAdaptor(), close(), getTranscodingCosts(), initialize(), pushFrontAdaptor(), and ~AdaptorChain().


The documentation for this class was generated from the following files: