/****************************************************************************************

		IExMovie.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Emil (from RD code)
		Date:	1/21/99

		Revision History

		when		who			what & why
		==========	==========	======================================================
		02/08/99	Nba			Removed unnecessary includes

*****************************************************************************************/
#ifndef __IExMovie__
#define __IExMovie__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "COMTypes.h"
#include "MCBasicDefines.h"
#include "IEx2DExportFilter.h"

struct IMFPart;
class  TMCString;
struct IShRasterLayer;
struct IExSound;
struct TSequencedMovieInfos;
struct ImageExportCapabilities;
struct IShLayerList;


//****** Globally Unique Ids *************************************************
MCDEFINE_GUID2(IID_IExMovie, R_IID_IExMovie);


// ****************************************************************************
//							IExMovieOptions	
// 
/// Interface used for movie compression options
///
struct IExMovieCompressionOptions : public IMCUnknown
{
	// ****************************************************************************
	//								IsEqualTo
	// 
	/// Returns true if the two options are identical (not that you can only compare
	/// options between two movies that have the same format (AVI,QuickTime...)
	/// 
	/// \param options  
	/// 
	virtual boolean	MCCOMAPI IsEqualTo(IExMovieCompressionOptions* options) = 0;

	// ****************************************************************************
	//								IsLossless
	// 
	/// Returns true if the compression used for this movie is lossless (meaning it
	/// does not change the movie).
	/// 
	virtual boolean MCCOMAPI IsLossless() = 0;
};


/*****************************************************************************\
*                                                                             *
*  IExMovie                                                                   *
*                                                                             *
\*****************************************************************************/

/// \addtogroup ExternalInterface
///
/// \{

/// Information about the abilities of a movie plugin
///
class TMovieCaps : public ImageExportCapabilities
{

public:
	TMovieCaps()
	{
		fCanRead = false;
		fCanWrite = false;
		fMustShowOptionsBeforeWrite = false;
	}

	boolean fCanRead;
	boolean fCanWrite;
	boolean fMustShowOptionsBeforeWrite;
};

/// \}


#ifndef qDemoVersion //regular interface

/// \addtogroup ExternalInterface
///
/// \{


struct IExMovie: public IMCUnknown
{   
	// ****************************************************************************
	//								CreateMovieController
	// 
	/// Creates a movie controller.
	/// Return MC_E_NOTIMPL and a standard movie controller will be provided.
	/// 
	/// \param movieController  A pointer to a movie controller part.
	/// 
	virtual MCCOMErr MCCOMAPI CreateMovieController(IMFPart** movieController) = 0;
	
	// ****************************************************************************
	//								SelfStartPlaying
	// 
	/// Called only when the standard movie controller is used
	/// 
	virtual MCCOMErr MCCOMAPI SelfStartPlaying(uint32 frameIndex) = 0;
	
	// ****************************************************************************
	//								SelfStopPlaying
	// 
	/// Called only when the standard movie controller is used
	/// 
	virtual MCCOMErr MCCOMAPI SelfStopPlaying(uint32 frameIndex) = 0;

	virtual MCCOMErr MCCOMAPI Initialize(const TMCString& fullPathName, const TSequencedMovieInfos* infos= NULL) = 0;
	virtual MCCOMErr MCCOMAPI BeginRead() = 0;
	virtual MCCOMErr MCCOMAPI GetFrameRate(real32& frameRate) = 0;
	virtual MCCOMErr MCCOMAPI GetFrameCount(uint32& frameCount) = 0;
	virtual MCCOMErr MCCOMAPI GetFrame(IShRasterLayer** rasterLayer, uint32 frameIndex) = 0;
	virtual MCCOMErr MCCOMAPI GetFrame(IShLayerList** layerList, uint32 frameIndex, boolean forceLoad) = 0;
	virtual MCCOMErr MCCOMAPI EndRead() = 0;

	//methods for writing
	virtual boolean	 MCCOMAPI HasOptionsDialog() = 0;
	virtual MCCOMErr MCCOMAPI ShowOptionsDialog(uint32 depth, real32& frameRate) = 0;	
	virtual MCCOMErr MCCOMAPI BeginWrite(const TMCString& fullPathName, uint32 sizeH, uint32 sizeV, uint32 depth, real32 frameRate, boolean append) = 0;
	virtual MCCOMErr MCCOMAPI PutFrame(IShRasterLayer* rasterLayer,const TGBuffer32List* gBuffers, uint32 frameIndex) = 0;
	virtual MCCOMErr MCCOMAPI PutFrame(IShLayerList* layerList,const TGBuffer32List* gBuffers, uint32 frameIndex) = 0;

	// ****************************************************************************
	//								PutSound
	// 
	/// Adds a sound to the movie. Don't forget to call FinishAddingSound once you
	/// are done adding all the sounds.
	/// 
	/// \param inSound			The sound that should be added to the movie.
	/// \param startTime		Start time of the sound in the animation
	/// \param offsetInSound    Offset into the sound where it actually starts
	/// 
	virtual MCCOMErr MCCOMAPI PutSound(IExSound* inSound, uint32 startTime, int32 offsetInSound) =0;

	// ****************************************************************************
	//								Flush
	// 
	/// Calling flush insures that the movie file is valid up to the last PutFrame.
	/// 
	/// 
	virtual MCCOMErr MCCOMAPI Flush() = 0;

	// ****************************************************************************
	//								GetMovieFullPathName
	// 
	/// Sometimes the file name can change between open and save.
	/// More specifically, when using numbered files. you save "Movie.jpg"
	/// but you reopen "Movie001.jpg" because this is the actual file.
	/// Return MC_E_NOTIMPL and the shell will provide a default implementation
	/// 
	/// \param fullPathName  
	/// 
	virtual MCCOMErr MCCOMAPI GetMovieFullPathName(TMCString& fullPathName) = 0;

	virtual MCCOMErr MCCOMAPI EndWrite() = 0;
	
	virtual MCCOMErr MCCOMAPI PostWrite() = 0;

	// ****************************************************************************
	//								GetCapabilities
	// 
	/// Returns which buffers can be saved with this file format
	/// 
	/// \param capabitilities  Flags that are returned.
	/// 
	virtual void MCCOMAPI GetCapabilities(ImageExportCapabilities& capabitilities)=0;


	// ****************************************************************************
	//								CopySoundtrack
	// 
	/// Copies the soundtrack from the current movie to the movie at outMovie.
	/// Currently only implemented for Quicktime to Quicktime movie copies. 
	///
	/// \param outMovie  
	/// 
	virtual MCCOMErr MCCOMAPI CopySoundtrack(IExMovie** outMovie) =0;
	
	// ****************************************************************************
	//								MakeCopy
	// 
	/// Makes an exact copy of the movie to the location given by fullPathName.
	/// Returns the name of the first written file (equals fullPathName if non sequenced)
	/// Return MC_E_NOTIMPL and the shell will provide a default implementation.
	/// 
	/// \param fullPathName      
	/// \param outFirstFileName  
	/// 
	virtual MCCOMErr MCCOMAPI MakeCopy(const TMCString& fullPathName, TMCString& outFirstFileName) = 0;

	// ****************************************************************************
	//								DeleteMovie
	// 
	/// Deletes the movie
	/// 
	virtual MCCOMErr MCCOMAPI DeleteMovie() = 0;

	// ****************************************************************************
	//								GetCompressionOptions
	// 
	/// Returns a pointer to the compression options used for this movie
	/// 
	/// \param movieOptions  
	/// 
	virtual void	 MCCOMAPI GetCompressionOptions(IExMovieCompressionOptions** movieOptions) = 0;

	// ****************************************************************************
	//								SetCompressionOptions
	// 
	/// Sets the compression options used for this movie
	/// 
	virtual void	 MCCOMAPI SetCompressionOptions(IExMovieCompressionOptions* movieOptions) = 0;

	// ****************************************************************************
	//								CanHaveSounds
	// 
	/// Returns true if the Movie format supports sounds.
	/// 
	virtual boolean	MCCOMAPI CanHaveSounds() = 0;

	// ****************************************************************************
	//								HasSounds
	// 
	/// Returns true if the Movie has sounds in it
	/// 
	/// 
	virtual boolean MCCOMAPI HasSounds() = 0;


	// ****************************************************************************
	//								FinishAddingSound
	// 
	/// Should be called after all the called to PutSound to get the changes written
	/// to disk.
	/// 
	virtual MCCOMErr FinishAddingSound() = 0;

};

/// \}

#else 	//(qDemoVersion) begin scrambled interface

struct IExMovie: public IMCUnknown
{   	
	virtual MCCOMErr MCCOMAPI PutSound(IExSound* inSound, uint32 startTime, int32 offsetInSound) =0;
	virtual void	 MCCOMAPI SetCompressionOptions(IExMovieCompressionOptions* movieOptions) = 0;
	virtual void	 MCCOMAPI GetCompressionOptions(IExMovieCompressionOptions** movieOptions) = 0;
	virtual MCCOMErr MCCOMAPI PostWrite() = 0;
	virtual MCCOMErr MCCOMAPI PutFrame(IShRasterLayer* rasterLayer,const TGBuffer32List* gBuffers, uint32 frameIndex) = 0;
	virtual MCCOMErr MCCOMAPI SelfStopPlaying(uint32 frameIndex) = 0;
	virtual MCCOMErr MCCOMAPI SelfStartPlaying(uint32 frameIndex) = 0;
	virtual MCCOMErr MCCOMAPI Initialize(const TMCString& fullPathName, const TSequencedMovieInfos* infos= NULL) = 0;
	virtual MCCOMErr MCCOMAPI BeginWrite(const TMCString& fullPathName, uint32 sizeH, uint32 sizeV, uint32 depth, real32 frameRate, boolean append) = 0;
	virtual MCCOMErr MCCOMAPI GetMovieFullPathName(TMCString& fullPathName) = 0;	
	virtual MCCOMErr MCCOMAPI GetFrameCount(uint32& frameCount) = 0;
	virtual MCCOMErr MCCOMAPI CreateMovieController(IMFPart** movieController) = 0;	
	virtual MCCOMErr MCCOMAPI EndWrite() = 0;		
	virtual boolean	 MCCOMAPI HasOptionsDialog() = 0;
	virtual MCCOMErr MCCOMAPI ShowOptionsDialog(uint32 depth, real32& frameRate) = 0;	
	virtual MCCOMErr MCCOMAPI BeginRead() = 0;	
	virtual MCCOMErr MCCOMAPI GetFrame(IShRasterLayer** rasterLayer, uint32 frameIndex) = 0;	
	virtual MCCOMErr MCCOMAPI Flush() = 0;
	virtual MCCOMErr MCCOMAPI GetFrameRate(real32& frameRate) = 0;
	virtual MCCOMErr MCCOMAPI EndRead() = 0;	
	virtual MCCOMErr MCCOMAPI CopySoundtrack(IExMovie** outMovie) =0;
	virtual MCCOMErr MCCOMAPI MakeCopy(const TMCString& fullPathName, TMCString& outFirstFileName) = 0;
	virtual MCCOMErr MCCOMAPI DeleteMovie() = 0;
	virtual void MCCOMAPI GetCapabilities(ImageExportCapabilities& capabitilities)=0;
	virtual boolean	 MCCOMAPI HasSounds() =0;
	virtual boolean  MCCOMAPI CanHaveSounds() =0;
};
#endif	//(qDemoVersion) end scrambled

#endif

