Show codec.cpp syntax highlighted
/***************************************************************************
codec.cpp - WAV codec
-------------------
begin : Wed Mar 17 2004
copyright : (C) 2004 by Reality Rift Studios
email : mattias@realityrift.com
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the NeoEngine, NeoACWAV, codec.cpp
The Initial Developer of the Original Code is Mattias Jansson.
Portions created by Mattias Jansson are Copyright (C) 2004
Reality Rift Studios. All Rights Reserved.
***************************************************************************/
#include "codec.h"
#include "stream.h"
#include "link.h"
#include <neoengine/core.h>
#include <neoengine/module.h>
#include <vector>
using namespace std;
using namespace NeoEngine;
namespace NeoACWAV
{
#define WAVEXPORT
ModuleStatic *g_pkStaticModule = 0;
WAVEXPORT NeoEngine::SoundCodec *LoadSoundCodec()
{
vector<string> vstrExtensions;
vstrExtensions.push_back( "wav" );
vstrExtensions.push_back( "WAV" );
return new NeoACWAV::Codec( "WAVE audio", vstrExtensions );
}
WAVEXPORT int Initialize()
{
return 0;
}
WAVEXPORT int Shutdown()
{
delete g_pkStaticModule;
return 0;
}
WAVEXPORT void GetVersion( std::string *pstrName, int *piMajor, int *piMinor, int *piRevision )
{
*pstrName = "NeoACWAV";
*piMajor = NEOENGINEVERSION_MAJOR;
*piMinor = NEOENGINEVERSION_MINOR;
*piRevision = NEOENGINEVERSION_REVISION;
}
Link::Link()
{
#if defined(WIN32) && defined(_DEBUG)
g_pkStaticModule = new ModuleStatic( "neoacwav_debug" );
#else
g_pkStaticModule = new ModuleStatic( "neoacwav" );
#endif
g_pkStaticModule->m_Symbols.Insert( "LoadSoundCodec", (void**)LoadSoundCodec );
g_pkStaticModule->m_Symbols.Insert( "Initialize", (void**)Initialize );
g_pkStaticModule->m_Symbols.Insert( "Shutdown", (void**)Shutdown );
g_pkStaticModule->m_Symbols.Insert( "GetVersion", (void**)GetVersion );
NeoEngine::Core::GetModuleManager()->InsertModule( g_pkStaticModule );
}
Codec::Codec( const std::string &rstrFiletypeName, const std::vector< std::string > &rvstrExtensions ) :
NeoEngine::SoundCodec( rstrFiletypeName, rvstrExtensions )
{
}
Codec::~Codec()
{
}
bool Codec::IsType( NeoEngine::File *pkFile )
{
bool bBinary = pkFile->SetBinary( true );
int iOffset = pkFile->Tellg();
pkFile->Seekg( 0, ios_base::beg );
RiffChunk riffChunk;
FormatChunk formatChunk;
DataChunk dataChunk;
pkFile->Read( &riffChunk, sizeof( riffChunk ) );
pkFile->Read( &formatChunk, sizeof( formatChunk ) );
pkFile->Read( &dataChunk, sizeof( dataChunk ) );
pkFile->Seekg( iOffset, ios_base::beg );
pkFile->SetBinary( bBinary );
if( strncmp( riffChunk.chunkID, "RIFF", 4 ) ) return false;
if( strncmp( riffChunk.format, "WAVE", 4 ) ) return false;
if( strncmp( formatChunk.chunkID, "fmt ", 4 ) ) return false;
if( strncmp( dataChunk.chunkID, "data", 4 ) ) return false;
return true;
}
NeoEngine::SoundStream *Codec::GetStream( NeoEngine::File *pkFile )
{
return new Stream( pkFile );
}
};
See more files for this project here
NeoenEngine NG (Next Generation) is the evolution of neoengine one,it\'s a different development from NeoEngine2, it\'s a direct inherits from NeoEngine one.\n
Project homepage:
http://sourceforge.net/projects/neoengineng
Programming language(s): C,C++
License: other
Makefile.am
SConscript
codec.cpp
codec.h
link.h
neoacwav-static.dev
neoacwav.cbp
neoacwav.dev
neoacwav.dsp
neoacwav.layout
neoacwav.vcproj
stream.cpp
stream.h