Show codec.cpp syntax highlighted
/***************************************************************************
codec.cpp - Ogg Vorbis 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, NeoACVorbis, 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 NeoACVorbis
{
#define VORBISEXPORT
ModuleStatic *g_pkStaticModule = 0;
VORBISEXPORT NeoEngine::SoundCodec *LoadSoundCodec()
{
vector<string> vstrExtensions;
vstrExtensions.push_back( "ogg" );
vstrExtensions.push_back( "OGG" );
return new NeoACVorbis::Codec( "Ogg Vorbis audio", vstrExtensions );
}
VORBISEXPORT int Initialize()
{
return 0;
}
VORBISEXPORT int Shutdown()
{
delete g_pkStaticModule;
return 0;
}
VORBISEXPORT void GetVersion( std::string *pstrName, int *piMajor, int *piMinor, int *piRevision )
{
*pstrName = "NeoACVorbis";
*piMajor = NEOENGINEVERSION_MAJOR;
*piMinor = NEOENGINEVERSION_MINOR;
*piRevision = NEOENGINEVERSION_REVISION;
}
Link::Link()
{
#if defined(WIN32) && defined(_DEBUG)
g_pkStaticModule = new ModuleStatic( "neoacvorbis_debug" );
#else
g_pkStaticModule = new ModuleStatic( "neoacvorbis" );
#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 bIs = true;
OggVorbis_File ogg;
ov_callbacks cb;
cb.read_func = read_stream;
cb.seek_func = seek_stream;
cb.close_func = close_stream;
cb.tell_func = tell_stream;
if( ov_open_callbacks( pkFile, &ogg, 0, 0, cb ) )
{
bIs = false;
}
ov_clear( &ogg );
return bIs;
}
NeoEngine::SoundStream *Codec::GetStream( NeoEngine::File *pkFile )
{
return new Stream( pkFile );
}
};
See more files for this project here