/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/drivers/wintel32/video/smpeg/smpeg_videomanager.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/video/video.hpp"
#include "domains/graphics/graphics.hpp"
#include "drivers/wintel32/video/smpeg/smpeg.hpp"

CVideoFormatManager *
CVideoFormatManager_SMPEG::create()
{
	return get();
}

CVideoFormatManager *
CVideoFormatManager_SMPEG::get()
{
	if (!m_pSingleton) {
		m_pSingleton = new CVideoFormatManager_SMPEG();
	}

	return m_pSingleton;
}

CVideoFormatManager_SMPEG::CVideoFormatManager_SMPEG()
{
	// Prepare the globals for all SMPEG handling
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		m_bValid = FALSE;
	} else {
		m_bValid = TRUE;
		CSGXVideoManager::get()->registerObject("mpeg", this);
	}
}

CVideoFormatManager_SMPEG::~CVideoFormatManager_SMPEG()
{
	SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

CVideo *
CVideoFormatManager_SMPEG::createVideo(const sgxString &name, const CVideo::CMovieParameters &params)
{
	CSGXMovieSMPEG *pSmpeg = new CSGXMovieSMPEG();
	if (pSmpeg->create(name, params)) {
		return pSmpeg;
	}

	return NULL;
}
