| 452 | //----------------------------------------------------------------------------- |
| 453 | |
| 454 | bool TheoraTexture::setFile( const String& filename, SFXDescription* desc ) |
| 455 | { |
| 456 | _reset(); |
| 457 | |
| 458 | if( filename.isEmpty() ) |
| 459 | return true; |
| 460 | |
| 461 | // Check SFX profile. |
| 462 | |
| 463 | if( desc && !desc->mIsStreaming ) |
| 464 | { |
| 465 | Con::errorf( "TheoraTexture::setFile - Not a streaming SFXDescription" ); |
| 466 | return false; |
| 467 | } |
| 468 | mSFXDescription = desc; |
| 469 | |
| 470 | // Open the Theora file. |
| 471 | |
| 472 | Stream* stream = FileStream::createAndOpen( filename, Torque::FS::File::Read ); |
| 473 | if( !stream ) |
| 474 | { |
| 475 | Con::errorf( "TheoraTexture::setFile - Theora file '%s' not found.", filename.c_str() ); |
| 476 | return false; |
| 477 | } |
| 478 | |
| 479 | // Create the OGG stream. |
| 480 | |
| 481 | Con::printf( "TheoraTexture - Loading file '%s'", filename.c_str() ); |
| 482 | |
| 483 | ThreadSafeRef< OggInputStream > oggStream = new OggInputStream( stream ); |
| 484 | oggStream->addDecoder< OggTheoraDecoder >(); |
| 485 | #ifndef SPLIT_VORBIS |
| 486 | oggStream->addDecoder< OggVorbisDecoder >(); |
| 487 | #endif |
| 488 | |
| 489 | if( !oggStream->init() ) |
| 490 | { |
| 491 | Con::errorf( "TheoraTexture - Failed to initialize OGG stream" ); |
| 492 | return false; |
| 493 | } |
| 494 | |
| 495 | mFilename = filename; |
| 496 | mAsyncState = new AsyncState( oggStream, desc ? desc->mIsLooping : false ); |
| 497 | |
| 498 | // Set up video. |
| 499 | |
| 500 | OggTheoraDecoder* theoraDecoder = _getTheora(); |
| 501 | if( !theoraDecoder ) |
| 502 | { |
| 503 | Con::errorf( "TheoraTexture - '%s' is not a Theora file", filename.c_str() ); |
| 504 | mAsyncState = NULL; |
| 505 | return false; |
| 506 | } |
| 507 | |
| 508 | Con::printf( " - Theora: %ix%i pixels, %.02f fps, %s format", |
| 509 | theoraDecoder->getFrameWidth(), |
| 510 | theoraDecoder->getFrameHeight(), |
| 511 | theoraDecoder->getFramesPerSecond(), |
nothing calls this directly
no test coverage detected