| 137 | } |
| 138 | |
| 139 | bool OggInputStream::init() |
| 140 | { |
| 141 | if( !mStream->hasCapability( Stream::StreamPosition ) ) |
| 142 | return false; |
| 143 | |
| 144 | mStream->setPosition( 0 ); |
| 145 | |
| 146 | // Read all beginning-of-stream pages and construct decoders |
| 147 | // for all streams we recognize. |
| 148 | |
| 149 | while( 1 ) |
| 150 | { |
| 151 | // Read next page. |
| 152 | |
| 153 | ogg_page startPage; |
| 154 | _pullNextPage( &startPage ); |
| 155 | |
| 156 | // If not a beginning-of-stream page, push it to the decoders |
| 157 | // and stop reading headers. |
| 158 | |
| 159 | if( !ogg_page_bos( &startPage ) ) |
| 160 | { |
| 161 | _pushNextPage( &startPage ); |
| 162 | break; |
| 163 | } |
| 164 | |
| 165 | // Try the list of constructors for one that consumes |
| 166 | // the page. |
| 167 | |
| 168 | for( U32 i = 0; i < mConstructors.size(); ++ i ) |
| 169 | { |
| 170 | OggDecoder* decoder = mConstructors[ i ]( this ); |
| 171 | if( decoder->_detect( &startPage ) ) |
| 172 | mDecoders.push_back( decoder ); |
| 173 | else |
| 174 | delete decoder; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // Initialize decoders and let all them finish up header processing. |
| 179 | |
| 180 | for( U32 i = 0; i < mDecoders.size(); ++ i ) |
| 181 | if( !mDecoders[ i ]->_init() ) |
| 182 | { |
| 183 | delete mDecoders[ i ]; |
| 184 | mDecoders.erase( i ); |
| 185 | -- i; |
| 186 | } |
| 187 | |
| 188 | if( !mDecoders.size() ) |
| 189 | return false; |
| 190 | |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | void OggInputStream::_freeDecoders() |
| 195 | { |
nothing calls this directly
no test coverage detected