真正能编译通过的神龙卡驱动源代码!不使用打包好的控件。 ( 积分: 200 )

  • 主题发起人 主题发起人 18200098
  • 开始时间 开始时间
1

18200098

Unregistered / Unconfirmed
GUEST, unregistred user!
前辈:
你好!
[:)]我要购买真正能编译通过,不使用打包好的控件,采用神龙SDK API函数方式直接驱动的源代码。
天下没有免费的!我手上有D版的VOD(就是以前花钱购买的成熟整套程序,Delphi+SQL前台、后台功能比较齐备的系统),用它也接了几个小单子,蛮稳定好用,就是歌库不好。这方面就不多交待了。后来爱好、兴趣(可能是技术成瘾)总驱使我想搞明白用Delphi直接驱动神龙卡,用接口声明直接调用神龙卡(网上有关资料说根据神龙SDK照作写就行),但我就是找不到入门钥匙!网上有好多这方面的免费的源代码,但大都是使用控件、或者是有问题的代码。不能拿来学习。哪位前辈有这方面的源代码,真正能编译通过,不要留一手,代码完全公开,真正能拿来学习!我出钱用来交换!目的就是为了节省学习时间,少走弯路,通个这个我所熟悉、并且生动有趣的编程项目入手,入门。提高学Delphi的兴趣!前辈们 你们有的不要吝舍,兴许再过段时间你手上的东东,时间一长就是垃圾文件啦。分享下:让我也进入Delphi世界吧,我要学成也要好多年之后的事。根本不可能对前辈们构成威协。想拿出同我分享的,请与我联系 电话:13712129150 QQ:18200098 真诚、诚信!技术永无止境! 谢谢! 感谢你能关注我的发言! 再次感谢!
 
下面有些自己在网上收集的有关调用神龙卡的源代码(神龙SDK开发包全部内容、新艺点歌系统源代码神龙卡接口部份源码)。恳请路过的老师指点迷津!怎样在Delphi里拼凑这些代码,真正能调用神龙卡。不另用其他封装过的控件、包。万分感谢!如教会了我,让我入了门,送分+汇现金给你。
 
要是有跟我一样想法的Delphi新手,请多顶下。不要让贴沉了。多谢!多顶下![:D]
 
在大富翁看到最工整诚恳的一贴.[:D]
大富翁有个 问题提前的 按钮, 不用回贴就可以顶上来的啦~
 
谢谢指导
 
谢谢指导
 
FMPDEFS.PAS


{*******************************************************************************
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
* FILENAME : FMPDefs.h
* DESCRIPTION : This header file contains FMP specific definitions.
* PLATFORM : do
S, Windows
* PROGRAMMER : ECY
* COMMENTS : NONE
* NOTES : NONE
* CHANGES :
* 08/10/95 - Created.
* (ECY)
*******************************************************************************}

unit fmpdefs;

interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
const
// FMP Commands
//*******************************************************************************/
FMP_OPEN=$01;
FMP_CLOSE=$02;
FMP_PLAY=$03;
FMP_PAUSE=$04;
FMP_STOP=$05;
FMP_SEEK=$06;
FMP_STEP=$07;
FMP_GROUP=$08;
FMP_SET=$09;
FMP_GET=$0A;
FMP_CALLBACK=$0B;
FMP_SIGNAL=$0C;
FMP_UNLOAD=$0D;
FMP_INIT=$0E;
FMP_CAPTURE=$0F;
FMP_UPDATE=$10;
FMP_FREEZE=$12;

// FMP Errors
//*******************************************************************************/
FMPE_DOS=$0100;
FMPE_INVALID_FLAGS=$0200;
FMPE_HANDLE=$0300;
FMPE_NOT_IMPLEMENT=$0400;
FMPE_INVALID_CMD=$0500;
FMPE_OUT_OF_MEM=$0600;
FMPE_INDEX=$0700;
FMPE_TYPE=$0800;
FMPE_WRITE=$0900;
FMPE_TOO_MANY=$0A00;
FMPE_ITEM_INDEX=$0B00;
FMPE_ITEM_HANDLE=$0C00;
FMPE_ERROR=$0D00;
FMPE_STREAM_DATA=$0E00;
FMPE_NOT_CDXA_DRV=$0F00;
FMPE_HARDWARE=$1000;
FMPE_NA=$1100;
FMPE_VALUE=$1200;
FMPE_TIME_FMT=$1300;
FMPE_NOT_READY=$1400;
FMPE_POS=$1500;
FMPE_REFUSE=$1600;
FMPE_INVALID_INDEX=$1700;

//* FMP Messages
//*******************************************************************************/
FMPM_BUF_POS=$01;
FMPM_BUF_EMPTY=$02;
FMPM_BUF_SEEK=$03;
FMPM_BUF_CREATE=$04;
FMPM_BUF_CLOSE=$05;
FMPM_BUF_TOTALSIZE=$06;
FMPM_COMPLETED=$07;
FMPM_CANCELED=$08;
FMPM_ERROR=$09;
FMPM_MEM_ALLOC=$0A;
FMPM_MEM_FREE=$0B;
FMPM_SIGNAL=$0C;
FMPM_FIFO_START=$0D;
FMPM_FIFO_LOW=$0E;
FMPM_FIFO_HIGH=$0F;
FMPM_FIFO_DROP=$10;
FMPM_PUSH_READ=$11;
FMPM_PUSH_SEEK=$12;
FMPM_PUSH_CREATE=$13;

{ FMPM_PUSH_READ=$11;
FMPM_PUSH_SEEK=$12;
FMPM_PUSH_INIT=$13;
FMPM_PUSH_CLOSE=$14;
}

//* FMP Flags
//*******************************************************************************/
FMPF_BUF_LOW=$00000000;//L;
FMPF_BUF_EMS=$00010000;//L;
FMPF_BUF_XMS=$00020000;//L;

FMPF_PASCAL=$1000;
FMPF_C=$2000;

FMPF_TEST=$8000;

FMPF_INSERT =$0001;
FMPF_REMOVE =$0002;
FMPF_GET =$0003;
FMPF_SELECT =$0004;
FMPF_UNSELECT=$0005;
FMPF_HANDLE =$0000;
FMPF_INDEX =$0020;

FMPF_FILE =$0001;
FMPF_BUFFERS=$0002;
FMPF_GROUP =$0003;
FMPF_BROADCAST=$0004;
// FMPF_DVD=$0005;
FMPF_EXTEND=$0010;
FMPF_NOACCESS=$0100;

FMPF_UNKNOWN=$0000;
FMPF_AUDIO=$0001;
FMPF_VIDEO=$0002;

FMPF_POS_START=$0100;
FMPF_POS_SET=$0200;
FMPF_POS_END=$0300;
FMPF_POS_CUR=$0400;

FMPF_DONT_UPDATE=$1000;
FMPF_UPDATE_ALL=$2000;

FMPF_SIG_AT =$0001;
FMPF_SIG_EVERY=$0002;
FMPF_SIG_REMOVE=$0003;
FMPF_SIG_REMOVE_AT=$0004;
FMPF_SIG_REMOVE_ALL=$0005;

FMPE_HRD=$2000;
FMPE_HRD_NO_DMA=$2100;
FMPE_HRD_NO_INT=$2200;
FMPE_HRD_NO_PORT=$2300;
FMPE_HRD_NOT_FOUND=$2400;
FMPE_HRD_DONT_USE=$2500;

FMPF_END_STOP=$0000;
FMPF_END_PAUSE=$0001;
FMPF_END_KEEP=$0002;
FMPF_END_REPEAT=$0004;
FMPF_END_CLOSE=$0005;

FMPF_PAUSED =$0001;
FMPF_STOPPED=$0002;
FMPF_PLAYING=$0004;
FMPF_SEEKING=$0008;
FMPF_STEPPING=$0010;
FMPF_CLOSED =$0020;
FMPF_READY=(FMPF_PAUSED or FMPF_STOPPED);

FMPF_BYTES=$0001;
FMPF_SAMPLES=$0002;
FMPF_MSEC=$0003;
FMPF_HMSF=$0004;
FMPF_HMSC=$0005;
FMPF_FRAMES=FMPF_SAMPLES;
FMPF_TIME=FMPF_HMSC;
FMPF_SMPTE=FMPF_HMSF;

FMPF_BUF_32_BITS=$0001;
FMPF_BUF_LOOP=$0002;

FMPF_VID_UNKNOWN=$0000;
FMPF_VID_MPEG=$0001;
FMPF_VID_AVI=$0002;
FMPF_VID_MPEG2=$0004;

FMPF_ALL_VGA=$0001;
FMPF_ALL_VID=$0002;
FMPF_KEY_VGA=$0004;
FMPF_KEY_VID=$0008;
FMPF_KEY_MIX=$000C;
FMPF_KEY_CALIBRATE=$000D;
FMPF_KEY_VIDCLEAR=$000E;

FMPF_AUD_UNKNOWN=$0000;
FMPF_AUD_MPEG=$0001;
FMPF_AUD_MPEG_L1=$0002;
FMPF_AUD_MPEG_L2=$0004;
FMPF_AUD_MPEG_L3=$0008;
FMPF_AUD_MPEG2=$0010;
FMPF_AUD_MPEG2_L1=$0020;
FMPF_AUD_MPEG2_L2=$0040 ;
FMPF_AUD_MPEG2_L3=$0080;
FMPF_AUD_DOLBY_AC3=$0100;

FMPF_AUD_WAVE=$0010;
FMPF_AUD_VOC=$0020;
FMPF_AUD_PCM=$0040;
FMPF_AUD_ADPCM=$0080;

FMPF_AUD_STEREO=$0001;
FMPF_AUD_JSTEREO=$0002;
FMPF_AUD_DUAL=$0003;
FMPF_AUD_SINGLE=$0004;

FMPF_AUD_NO_EMPH=$0001;
FMPF_AUD_EMPH_50=$0002;
FMPF_AUD_EMPH_J17=$0003;

FMPF_AUD_COPYRIGHT=$0001;
FMPF_AUD_ORIGINAL=$0002;

FMPF_GRP_UNKNOWN=$0000;
FMPF_GRP_MPEG=$0001;
FMPF_GRP_AVI=$0002;
FMPF_GRP_CUSTOM=$0004;
FMPF_GRP_MPEG2_PROGRAM=$0008;
FMPF_GRP_MPEG2_TRANSPORT=$0010;

FMPF_PIC_BMP=$0001;
FMPF_PIC_DIB24 =$0002;
FMPF_PIC_TOFILE =$0004;
FMPF_PIC_DIB8 =$0008;

FMPF_REFUSE =$0001;
FMPF_IGNORE =$0002;

// FMP Index
//*******************************************************************************/
FMPI_DRV_PRODUCT =$0101;
FMPI_DRV_VERSION =$0102;
FMPI_DRV_MAX_CHAN =$0103;
FMPI_DRV_VID_SUP =$0104;
FMPI_DRV_AUD_SUP =$0105;
FMPI_DRV_GRP_SUP =$0106;
FMPI_DRV_HDR_STAT =$0107;
FMPI_DRV_MEMORY =$0108;
FMPI_DRV_ID =$0109;
FMPI_DRV_CAPABILITY =$010A;

FMPI_STM_TYPE =$0202;
FMPI_STM_SOURCE =$0203;
FMPI_STM_MODE =$0204;
FMPI_STM_TIME_FMT =$0205;
FMPI_STM_POSITION =$0206;
FMPI_STM_SPEED =$0207;
FMPI_STM_USER =$0208;
FMPI_STM_SIZE =$0209 ;
FMPI_STM_SLIDE =$020A;
FMPI_STM_PASSWD =$0210;
FMPI_STM_FILETYPE =$0211;
FMPI_STM_MEMFLAGS =$0212;
FMPI_STM_FILESIZE =$0213;
FMPI_STM_FILEORG =$0214;
FMPI_STM_BIT_RATE =$0215;
FMPI_STM_NOCACHE =$0216;
FMPI_STM_DEV_POS =$0217;

FMPI_BUF_LEFT =$0301;
FMPI_BUF_POS=$0302;
FMPI_BUF_ADDRESS =$0303;
FMPI_BUF_SIZE =$0304;
FMPI_BUF_MODE =$0305;
FMPI_BUF_TOTALSIZE =$0306;

FMPI_VID_TYPE =$0401;
FMPI_VID_RATE =$0402;
FMPI_VID_SIZE =$0403;
FMPI_VID_ASPECT =$0404;
FMPI_VID_BIT_RATE =$0405;
FMPI_VID_SRC_POS =$0406;
FMPI_VID_SRC_SIZE =$0407;
FMPI_VID_DEST_POS =$0408;
FMPI_VID_DEST_SIZE =$0409;
FMPI_VID_KEY_MIN =$040A;
FMPI_VID_KEY_MAX =$040B;
FMPI_VID_KEY_MASK =$040C;
FMPI_VID_KEY_COL =$040D;
FMPI_VID_KEY_MODE =$040E;
FMPI_VID_KEY_TYPE =$040F;
FMPI_VID_CONTRAST =$0410;
FMPI_VID_BRIGHTNESS =$0411;
FMPI_VID_SATURATION =$0412;
FMPI_VID_SLIDE =$0420;
FMPI_VID_HWND =$0413;
FMPI_VID_KEY_COL_INDEX =$0414;
FMPI_VID_DISPLAY_AREA =$0415;
FMPI_VID_USER_PALETTE =$0416;
FMPI_VID_PALETTE_HWND =$0417;
FMPI_VID_REALIZE =$0418;
FMPI_VID_GAMMA =$0419;

FMPI_VID_DEFAULTS =$1000;
FMPI_VID_REGISTRY =$2000;

FMPI_AUD_TYPE =$0501;
FMPI_AUD_RATE =$0502 ;
FMPI_AUD_VOLUME =$0503;
FMPI_AUD_BIT_RATE =$0504;
FMPI_AUD_TREBLE =$0505;
FMPI_AUD_BASS =$0506;
FMPI_AUD_CHANNELS =$0507;
FMPI_AUD_EMPH =$0508;
FMPI_AUD_RIGHTS =$0509;
FMPI_AUD_SHIFT =$0510;
FMPI_AUD_BAL_L =$0511;
FMPI_AUD_BAL_R =$0512;

FMPI_AUD_DEFAULTS =$1000;
FMPI_AUD_REGISTRY =$2000;

FMPI_GRP_TYPE =$0601;
FMPI_GRP_NB =$0602;

FMPI_FIFO_FCNTRL =$0701;
FMPI_FIFO_SIZE =$0702 ;
FMPI_FIFO_MAX =$0703;
FMPI_FIFO_VID_SIZE =$0704;
FMPI_FIFO_AUD_SIZE =$0705;
FMPI_FIFO_START =$0706;
FMPI_FIFO_LOW =$0707;
FMPI_FIFO_HIGH =$0708;
FMPI_FIFO_DROP =$0709;
FMPI_FIFO_UNIT =$070A ;
FMPI_FIFO_VID_LEFT =$070B;
FMPI_FIFO_AUD_LEFT =$070C;
FMPI_FIFO_SUBPICTURE_LEFT =$070D;
FMPI_FIFO_PCI_LEFT =$070E;
FMPI_FIFO_SUBPICTURE_SIZE =$070F;
FMPI_FIFO_PCI_SIZE =$0710;

FMPI_PUSH_ASYNC =$0801;
FMPI_PUSH_SYNC =$0802;

// Overlay specific settings (does not appky to rm 1 &
2)
FMPI_OVLY_XOFFSET =$0901;
FMPI_OVLY_YOFFSET =$0902;
FMPI_OVLY_VGACORRECTION =$0903;
FMPI_OVLY_STABILITY =$0904;
FMPI_OVLY_HFREQUENCY =$0905;
FMPI_OVLY_USEDEFAULTFREQ =$0906;
FMPI_OVLY_COLOR_SETTING =$0907;
FMPI_OVLY_LOWERLEVEL =$0908;
FMPI_OVLY_UPPERLEVEL =$0909;
FMPI_OVLY_DELTA_CALIBRATE =$090A ;
FMPI_OVLY_COLOR_CALIBRATION =$090B;
FMPI_OVLY_JITTERING =$090C;

// Hoolywood (IBM MPEG 2) specific settings
FMPI_OVLY_CROPLEFT =$0B01;
FMPI_OVLY_CROPTOP =$0B02;
FMPI_OVLY_CROPRIGHT =$0B03;
FMPI_OVLY_CROPBOTTOM =$0B04;
FMPI_OVLY_INDELAY =$0B05;
FMPI_OVLY_OUTDELAY =$0B06 ;

// Values used for developpment purpose only
FMPI_ADJUSTMENT_A =$0F01;
FMPI_ADJUSTMENT_B =$0F02 ;
FMPI_ADJUSTMENT_C =$0F03;
FMPI_ADJUSTMENT_D =$0F04;
FMPI_ADJUSTMENT_E =$0F05;
FMPI_ADJUSTMENT_F =$0F06;

FMPI_OVLY_DEFAULTS =$1000;
FMPI_OVLY_REGISTRY =$2000;
FMPI_OVLY_RESET =$4000;

FMPI_UPD_PALETTE =$0001;
FMPI_UPD_VGA_MODE =$0007;
FMPI_UPD_FRAME_POS =$0008;
FMPI_UPD_FRAME_SIZE =$0009;

//* FMP Constants
//*******************************************************************************/

FMP_MIN_AUD_VOLUME =0;
FMP_MAX_AUD_VOLUME =100;
FMP_DEF_AUD_VOLUME =50 ;

FMP_MIN_BSC =0;
// Brightness, Saturation &
Contrast
FMP_MAX_BSC =1000;
FMP_DEF_BSC =500;

FMP_MIN_GAMMA =200; // Gamma correction values
FMP_MAX_GAMMA =1400;
FMP_DEF_GAMMA =800;

FMP_DEF_SPEED =$00010001; // Default speed value (1:1)

// REALmagic capabilities
FMP_CAPABILITY_BORDER_ADJUST =$0001;
FMP_CAPABILITY_KEYCOLOR_ADJUST =$0002;
FMP_CAPABILITY_BSC_ADJUST =$0004; // Brightness, Saturation &
contrast
FMP_CAPABILITY_AUTO_CALIBRATE =$0008;
FMP_CAPABILITY_SPECIFIC_ADJUST =$0010;
FMP_CAPABILITY_GAMMA_ADJUST =$0020;
FMP_CAPABILITY_HIRES =$0040;

// RGB values used for min. medium and max color calibration
FMP_MIN_COLOR_LEVEL =$00000000;
FMP_MEDIUM_COLOR_LEVEL =$00808080;
FMP_MAX_COLOR_LEVEL =$00FFFFFF;
FMP_MEDIUM_COLOR =$80;

FMP_LOWER_RED =$01;
FMP_LOWER_GREEN =$02;
FMP_LOWER_BLUE =$04;
FMP_UPPER_RED =$10;
FMP_UPPER_GREEN =$20;
FMP_UPPER_BLUE =$40;

// Max sizes for low resolution
FMP_MAX_LOW_RES_WIDTH =640;
FMP_MAX_LOW_RES_HEIGHT =400;

FMPI_VID_TV =$041B;
SET_VGA =$0000;
SET_TV =$0001;

type
//* FMP Structures
//*******************************************************************************/

FMP_OPEN_STRUCT=record
lpFileName:LPTSTR;
dwCallBack:DWORD;
Reserved:BYTE ;
end;

FMP_PUSH_STRUCT=record
dwSize:DWORD ;
lpBuffer:pchar;//void* ;
end;


FMP_COLOR_SETTING_STRUCT=record
RGBColorKey:COLORREF;
RGBUpper:COLORREF;
RGBLower:COLORREF;
Mask:short;//USHORT ;
end;


FMP_DISPLAY_AREA_STRUCT=record
context:DWORD ;
dwContextSpecific:DWORD ;
rect:TRECT ;
hBrush:HBRUSH ;
end;


implementation

end.
 
REALmagic DirectShow interface
REALmagic DirectShow 接口
Everyone interested in Directshow programming should firstdo
wnload the DirectX SDK, read the Directshowdo
cumentation and start with a few samples.
Theorical part...
It is quite simple to get the XCard to read a MPEG I, II or 4 with Directshow.
用Directshow可以十分简单的获取 Xcard 去读取一个MPEG1/2/4.

We need to create a FilterGraph manager object, which instantiates all the
necessary filters, so we can:
我们必须去创建一个FilterGraph 管理器对象,和实例的全部必要的解码器,我们就可以:

- Read the physical file 读取物理文件
- Separate the audio and video streams 分离音视频流
- Use the Sigma MPEG2 Hardware decoder 使用 Sigma MPEG2 硬件解码器
- Use the lc3codec filter to decompress the mp3 audio stream (in a Divx movie)
- Use the Sigma PCM swapper (Which converts the little endian byte order of the
mp3 decoder to the big endian byte order expected by the EM8475 XCard chipset audio input)
- Render the video stream
Here is the GraphEdit filtergraph to read a divx movie with the XCard:


For a Mpeg I or II movie, the schematic is simpler :


Practical part...
Let's see how to implement the graphedit representation. I will first explain how todo
this in VB which, in my opinion, is easier.
VB
You must first add the quartz dll reference in your VB project :

then
, declare the IMediaControl object :
Dim MonControlGraph as IMediaControl
This object is the control interface of the FilterGraph that you're about to build (This interface will then
give you the methods to play, pause or stop your movie)
To instantiate it, type :
Set MonControlGraph = New FilgraphManager
This creates a Filtergraph object. It internally calls the
CoCreateInstance and QueryInterface methods to extract the IMediaControl Interface
in order to pass the reference to your "MonControlGraph"
object.
Now, you have to create all the necessary objects to read your Divx AVI file.
In VB, you can create these objects using the IFilterInfo type. You have to declare a IFilterInfo object for each filter you need inside your graph :
Dim pSourceFilter As IFilterInfoDim pAVISplitter As IFilterInfoDim pXCARDFilter As IFilterInfoDim pSPCMFilter As IFilterInfoDim pMP3Filter As IFilterInfoDim pVidRenderer As IFilterInfo
The first filter can be created using the "AddSourceFilter"
method of the FilterGraph :
MonControlGraph.AddSourceFilter "fichier.AVI", pSourceFilter
if everything is OK (check if your object is not nothing after this call), you can go on with the instantiation of the other objects :
To create the other filters, you will have to look among all the filters registered on your system. Todo
that, the FilterGraph objects provides a collection of all the available filters in the Windows registry. To get the reference of the filter we are looking for, we just enumerate this collection, and when we find the correct name, we just assign the reference to our IFilterInfo object.
To make things easier, here is a method I use to find and assign a filter whose name is given in argument :

This is a simple adaptation of an example provided in the Directshow SDK.
Now let's call this method to create the instance of all our objects :
AppendFilterToGraph "Sigma Designs AVI Splitter", pAVISplitter, MonControlGraphAppendFilterToGraph "Sigma Designs MPEG-2 hardware decoder", pXCARDFilter, MonControlGraphAppendFilterToGraph "Video Renderer", pVidRenderer, MonControlGraphAppendFilterToGraph "Sigma Designs PCM swapper", pSPCMFilter, MonControlGraphAppendFilterToGraph "MPEG layer-3 decoder", pMP3Filter, MonControlGraph
Of course,do
n't forget each time to check that your object is different from "nothing".
And now, let's connect those elements each other.
To achieve that, you can use two methods. The first is easier and works most of the time :
You have to find the output plug of your source filter. There are a collection of plugs (or pins) on each filter. Pins can be input type or output type. By enumerating the pin name on our filters, we can get references to the pin objects. The pins are connected to link the filters together.
To use the first method, we have to find the only pin on the source filter. If we call the method "Render"
on this pin, the filtergraph will try to connect all the other pins of the different filters we instantiate.
Todo
that, declare a pPin object and a pSourceFilterPin :
dim pPin as iPinInfo
dim pSourceFilterPin as iPinInfo
pPin will be used to enumerate the pins on the source filter, and pSourceFilterPin will get the reference of the pin we find.
We now have to look inside the pins collection of the source filter :
if not pSourceFilter is nothing then
for each pPin in pSourcefilter.pins if pPin.name = "Output"
then
Set pSourceFilterPin = pPin end if nextend if
Now, by calling the method : pSourceFilterPin.Render, connection between all the filters will bedo
ne automatically.
The other way to realize the connections between filters is a little more complex : we have to find all the pins of each filter and manually connect them (the "connect"
method on the IPinInfo object). Unfortunaltely, some filters expose their output pins only when their input pin is connected. That's why we have to enumerate the pin collection twice on some filters.
Here is the method I use in VB to create a filtergraph that reads a Divx :
Public Function Render_Divx(AVIfilename As String, filgrph As IMediaControl) As Boolean Dim pPin As IPinInfo ' déclaré pour la recherche des "pins"
des différents filtres Dim pSourceFilter As IFilterInfo ' filtre "source"
: lecture dans un buffer du fichier Dim SourceOutputPin As IPinInfo ' pin de sortie du filtre source Dim pAVISplitter As IFilterInfo ' filtre "splitter"
: permet de séparer le stream audio et vidéo Dim SplitterInPin As IPinInfo ' pin d'entrée du filtre splitter Dim SplitterOut00Pin As IPinInfo ' pin de sortie du stream vidéo du filtre splitter Dim SplitterOut01Pin As IPinInfo ' pin de sortie du stream audio du filtre splitter Dim pXCARDFilter As IFilterInfo ' filtre du décodeur hardware XCard Dim XCARDInVideoPin As IPinInfo ' pin d'entrée du flux vidéo Dim XCARDInAudioPin As IPinInfo ' pin d'entrée du flux audio Dim XCARDOutOverlayPin As IPinInfo ' pin de sortie "overlay"
de la XCard Dim pSPCMFilter As IFilterInfo ' filtre "PCM swapper"
de Sigma Designs Dim SPCMInPin As IPinInfo ' pin d'entrée du swapper Dim SPCMOutPin As IPinInfo ' pin de sortie du swapper Dim pMP3Filter As IFilterInfo ' filtre du décodeur MP3 audio Dim MP3InPin As IPinInfo ' pin d'entrée du décodeur MP3 Dim MP3OutPin As IPinInfo ' pin de sortie du décodeur MP3 Dim pVidRenderer As IFilterInfo ' filtre du vidéo renderer Dim VidRendInPin As IPinInfo ' pin d'entrée du vidéo renderer On Local Error GoTo ErrLine ' on vérifie que la chaine contenant le nom du fichier à lire ne soit pas vide ' et on demande au filtergraph de nous instancier un filtre pour lire ce fichier If AVIfilename <> vbNullString then
filgrph.AddSourceFilter AVIfilename, pSourceFilter else
: Exit Function End If ' On retrouve le pin de sortie du filtre d'entrée For Each pPin In pSourceFilter.Pins If pPin.Name = &quot;Output&quot;
then
Set SourceOutputPin = pPin End If Next ' On ajoute ensuite l'AVI splitter, chargé de séparer les canaux ' audio et vidéo If pAVISplitter Is Nothing then
AppendFilterToGraph &quot;Sigma Designs AVI Splitter&quot;, pAVISplitter, filgrph End If ' On recherche seulement le pin d'entrée du spliter afin de pouvoir le connecter ' au filtre source, et voir apparaitre ensuite ses pin de sortie If Not pAVISplitter Is Nothing then
If Not pAVISplitter.Pins Is Nothing then
For Each pPin In pAVISplitter.Pins If pPin.Name = &quot;Input&quot;
then
Set SplitterInPin = pPin End If Next End If End If ' On connecte ensuite, puisque l'on a obtenu la pin de sortie du filtre source ' et la pin d'entrée du splitter If Not SourceOutputPin Is Nothing And Not SplitterInPin Is Nothing then
SourceOutputPin.Connect SplitterInPin else
GoTo ErrLine End If ' Maintenant le Splitter a fait apparaitre dans sa liste les pin de sortie qu'il était ' possible de connecter, puisqu'il connait le contenu du fichier source If Not pAVISplitter Is Nothing then
If Not pAVISplitter.Pins Is Nothing then
For Each pPin In pAVISplitter.Pins If pPin.Name = &quot;Video&quot;
then
Set SplitterOut00Pin = pPin else
If pPin.Name = &quot;Audio&quot;
then
Set SplitterOut01Pin = pPin End If Next End If End If ' On ajoute le décodeur Hardware de la XCard (il se nomme MPEG-2 hardware decoder, ' mais sait aussi décoder du mpeg 1 et 4, rassurez-vous...) If pXCARDFilter Is Nothing then
AppendFilterToGraph &quot;Sigma Designs MPEG-2 hardware decoder&quot;, pXCARDFilter, filgrph End If ' on essaye maintenant de retrouver les deux pins d'entrée ' du décodeur de la XCard (on ne verra la pin de sortie qu'une ' fois que l'on aura connecté la pin vidéo) If Not pXCARDFilter Is Nothing then
If Not pXCARDFilter.Pins Is Nothing then
For Each pPin In pXCARDFilter.Pins If pPin.Name = &quot;Video In&quot;
then
Set XCARDInVideoPin = pPin End If If pPin.Name = &quot;Audio In&quot;
then
Set XCARDInAudioPin = pPin End If Next End If End If ' instanciation de l'objet vidéoRenderer (même si ce filtre n'est pas utilisé ' pour afficher l'image... d'ailleurs je ne vois pas bien pourquoi on a besoin de ' le mettre dans le filtre...) AppendFilterToGraph &quot;Video Renderer&quot;, pVidRenderer, filgrph ' recherche de la pin d'entrée du filtre de rendu vidéo DirectX For Each pPin In pVidRenderer.Pins If pPin.Name = &quot;Input&quot;
then
Set VidRendInPin = pPin End If Next ' On ajoute le filtre d'inversion de l'ordre des octets audio ' (format little <-> big endian) If pSPCMFilter Is Nothing then
AppendFilterToGraph &quot;Sigma Designs PCM swapper&quot;, pSPCMFilter, filgrph End If ' et on recherche les pin de connexion de ce filtre If Not pSPCMFilter Is Nothing then
If Not pSPCMFilter.Pins Is Nothing then
For Each pPin In pSPCMFilter.Pins If InStr(pPin.Name, &quot;Input&quot;) then
Set SPCMInPin = pPin End If If InStr(pPin.Name, &quot;Output&quot;) then
Set SPCMOutPin = pPin End If Next End If End If ' Enfin, on instancie le codec de décompression audio MP3 If pMP3Filter Is Nothing then
AppendFilterToGraph &quot;MPEG layer-3 decoder&quot;, pMP3Filter, filgrph End If ' puis on recherche sa pin d'entrée et sa pin de sortie If Not pMP3Filter Is Nothing then
If Not pMP3Filter.Pins Is Nothing then
For Each pPin In pMP3Filter.Pins If InStr(pPin.Name, &quot;XForm In&quot;) then
Set MP3InPin = pPin End If If InStr(pPin.Name, &quot;XForm Out&quot;) then
Set MP3OutPin = pPin End If Next End If End If ' Maintenant que tout ces objets sont instanciées, on va les relier entre-eux... ' on connecte la sortie vidéo du splitter avec l'entrée vidéo de la XCard If Not XCARDInVideoPin Is Nothing And Not SplitterOut00Pin Is Nothing then
SplitterOut00Pin.Connect XCARDInVideoPin else
GoTo ErrLine End If ' Maintenant que la XCard est contente, elle a un flux vidéo reconnu en entrée, ' on peut lui demander sa pin de sortie &quot;overlay&quot; If Not pXCARDFilter Is Nothing then
If Not pXCARDFilter.Pins Is Nothing then
For Each pPin In pXCARDFilter.Pins If pPin.Name = &quot;Overlay Out&quot;
then
Set XCARDOutOverlayPin = pPin End If Next End If End If ' voilà, on peut (on pourrait) connecter cette sortie &quot;overlay&quot;
au filtre de rendu directX qui ' est censé, sur une vidéo lue par les décodeurs software (comme le divx5.02 par exemple) ' afficher la vidéo finale en fenêtre ou en plein écran sur votre moniteur VGA. Le truc c'est que ' le filtre XCard est déjà un filtre de rendu terminal... je ne voisdo
nc pas pourquoi cette ' liaison est permise... enfin de toute fa&amp;ccedil;on, si vous voulez décommenter cette partie, vous ' verrez aparaitre une fenêtre active movie noire sur votre moniteur et le film qui ' apparait sur votre télé... mais à mon avis cette liaison n'est pas necessaire car &amp;ccedil;a a l'air ' de très bien marcher sans... 'If Not XCARDOutOverlayPin Is Nothing And Not VidRendInPin Is Nothing then
' XCARDOutOverlayPin.Connect VidRendInPin 'End If ' Pour la partie audio maintenant (la partie vidéo est reliée) ' on va connecter la pin de sortie du stream audio issue du filtre AVI Splitter ' à la pin d'entrée du décodeur MP3 audio... If Not MP3InPin Is Nothing And Not SplitterOut01Pin Is Nothing then
SplitterOut01Pin.Connect MP3InPin else
GoTo ErrLine End If ' ensuite, la pin de sortie du décodeur MP3do
it être reliée à la pin d'entrée du ' filtre de transformation audio (little <-> bif endian) &quot;PCM swapper&quot; If Not SPCMInPin Is Nothing And Not MP3OutPin Is Nothing then
MP3OutPin.Connect SPCMInPin else
GoTo ErrLine End If ' enfin, on connecte la pin de sortie du PCM Swapper à la pin d'entrée ' du décodeur Hardware de la XCard If Not XCARDInAudioPin Is Nothing And Not SPCMOutPin Is Nothing then
SPCMOutPin.Connect XCARDInAudioPin else
GoTo ErrLine End If Render_Divx = True ' on nettoie de la mémoire tous les objets instanciés ' (c'est nécessaire si vous voulez sortir du programme de fa&amp;ccedil;on propre ' en libérant complètement DirectShow et la XCard) Set pSourceFilter = Nothing Set SourceOutputPin = Nothing Set pAVISplitter = Nothing Set SplitterInPin = Nothing Set SplitterOut00Pin = Nothing Set SplitterOut01Pin = Nothing Set pXCARDFilter = Nothing Set XCARDInVideoPin = Nothing Set XCARDInAudioPin = Nothing Set XCARDOutOverlayPin = Nothing Set pSPCMFilter = Nothing Set SPCMInPin = Nothing Set SPCMOutPin = Nothing Set pMP3Filter = Nothing Set MP3InPin = Nothing Set MP3OutPin = Nothing Set pVidRenderer = Nothing Set VidRendInPin = Nothing Exit FunctionErrLine: ' ondo
it se retrouver ici si quelque chose va mal Render_Divx = False ' de même que quand &amp;ccedil;a va bien, il faut libérer les objets ' devenus inutiles Set pSourceFilter = Nothing Set SourceOutputPin = Nothing Set pAVISplitter = Nothing Set SplitterInPin = Nothing Set SplitterOut00Pin = Nothing Set SplitterOut01Pin = Nothing Set pXCARDFilter = Nothing Set XCARDInVideoPin = Nothing Set XCARDInAudioPin = Nothing Set XCARDOutOverlayPin = Nothing Set pSPCMFilter = Nothing Set SPCMInPin = Nothing Set SPCMOutPin = Nothing Set pMP3Filter = Nothing Set MP3InPin = Nothing Set MP3OutPin = Nothing Set pVidRenderer = Nothing Set VidRendInPin = NothingEnd Function
This method takes a AVI file name, and a previously created iMediaControl object.
If this method returns true, you can start to read the movie by calling MonControlGraph.run.
You can then
pause the movie with the method MonControlGraph.pause and stop it with MonControlGraph.stop.
If you want to get the total length, the reading position or to seek in the movie, you will need the iMediaPosition interface from the FilterGraph.
For this, declare a IMediaPosition object and get the interface by assigning a reference on the IMediaControl object.
Dim MaPosition as IMediaPositionSet MaPosition = MonControlGraph' les temps sont exprimés en secondes dans un typedo
UBLE tempsTotalSecondes = CLong(MaPosition.duration)tempsTotalMinutes = tempsTotalSecondes / 60tempsTotalSecondes = tempsTotalSecondes Mod 60tempsTotalHeures = tempsTotalMinutes / 60tempsTotalMinutes = tempsTotalMinutes Mod 60LabeltempsTotal.caption = format(tempsTotalHeure, &quot;00&quot;) &amp;
&quot;:&quot;
&amp;
_ format(tempsTotalMinutes, &quot;00&quot;) &amp;
&quot;:&quot;
&amp;
_ format(tempstotalSecondes, &quot;00&quot;)
This code shows how to display the total duration of a movie in a VB Label control.
On the IMediaPosition, the property &quot;duration&quot;
gives you the total length of the movie, and the property &quot;CurrentPosition&quot;
gives you playback position.
Those times are in seconds, with a decimal part (ado
UBLE type).
The CurrentPosition property can be read but also write. That means that you can assign a value to change the playback position.

C++
If you want to program the directshow interface in C++, you will have to find the GUID of the filters you want to use (you can also use pure C programming, but accessing the COM objects is less convenient : you will have to use some macro provided by Microsoft to access the objects' vtables - check the Microsoft COM architecturedo
cumentation for more information).
The Divx player for my machine is programmed in C/C++. The source code will be provided quite soon.
First, you have to add the libraries winmm.lib and strmbase.lib in the link settings of your project.
In a C++ file (XXX.cpp), start with the GUID definitions (XCard hardware decoder, MP3 audio decoder, Sigma Designs PCM Swapper and Sigma Designs AVI Splitter) :
DEFINE_MY_GUID(CLSID_SDMPEG2HardwarePlayer,0x4E3ABD41, 0x458E, 0x11D1, 0x91, 0x7E, 0x00, 0x00, 0x1B, 0x4F, 0x00, 0x6F);DEFINE_MY_GUID(CLSID_MP3SoftDecoder,0x38BE3000, 0xDBF4, 0x11D0, 0x86, 0x0E, 0x00, 0xA0, 0x24, 0xCF, 0xEF, 0x6D);DEFINE_MY_GUID(CLSID_SDPCMSwapper,0x1236F6AF, 0x1A72, 0x4A62, 0x9B, 0x2B, 0xC5, 0xF7, 0xB6, 0x2C, 0x6B, 0x1C);DEFINE_MY_GUID(CLSID_SDAVISplitter,0xDFD5043E, 0xB0C1, 0x4406, 0xBF, 0x29, 0x32, 0x75, 0x57, 0x3E, 0xAE, 0xEF);
then
, declare your filters :
IFilterGraph *pSDGraph = NULL;IGraphBuilder *pSDBuilder = NULL;
ifileSourceFilter *pSourceFilter = NULL;IBaseFilter *pAVISplitter = NULL;IBaseFilter *pHardwareDecoder = NULL;IBaseFilter *pMP3Codec = NULL;IBaseFilter *pPCMSwapper = NULL;
Now, before using the COM layer from Microsoft, you have to initialize it :
CoInitialize(NULL);
Instantiation of the filtergraph object :
if (FAILED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IFilterGraph, (void**) &amp;pSDGraph))){ /* nettoyage */ CoUninitialize(); return 0;}
NOTE : FAILED is a macro provided that tests the return code. It is declared inside Winerror.h
Now, let's instantiate all the other filters :
if (FAILED(CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**) &amp;pSourceFilter))){ /* nettoyage */ if (pSDGraph) pSDGraph->release(); CoUninitialize(); return 0;}if (FAILED(CoCreateInstance(CLSID_SDAVISplitter, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**) &amp;pAVISplitter))){ /* nettoyage */ if (pSDGraph) pSDGraph->release(); if (pSourceFilter) pSourceFilter->release(); CoUninitialize(); return 0;}if (FAILED(CoCreateInstance(CLSID_SDMPEG2HardwarePlayer, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**) &amp;pHardwareDecoder))){ /* nettoyage */ if (pSDGraph) pSDGraph->release(); if (pSourceFilter) pSourceFilter->release(); if (pAVISplitter) pAVISplitter->release(); CoUninitialize(); return 0;}if (FAILED(CoCreateInstance(CLSID_MP3SoftDecoder, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**) &amp;pMP3Codec))){ /* nettoyage */ if (pSDGraph) pSDGraph->release(); if (pSourceFilter) pSourceFilter->release(); if (pAVISplitter) pAVISplitter->release(); if (pHardwareDecoder) pHardwareDecoder->release(); CoUninitialize(); return 0;}if (FAILED(CoCreateInstance(CLSID_SDPCMSwapper, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**) &amp;pPCMSwapper))){ /* nettoyage */ if (pSDGraph) pSDGraph->release(); if (pSourceFilter) pSourceFilter->release(); if (pAVISplitter) pAVISplitter->release(); if (pHardwareDecoder) pHardwareDecoder->release(); if (pMP3Codec) pMP3Codec->release(); CoUninitialize(); return 0;}
And now, we have to start the graph by adding the source filter to the filtergraph object :
if (FAILED(pSDGraph->AddFilter(pSourceFilter, NULL))){ /* nettoyage */ if (pSDGraph) pSDGraph->release(); if (pSourceFilter) pSourceFilter->release(); if (pAVISplitter) pAVISplitter->release(); if (pHardwareDecoder) pHardwareDecoder->release(); if (pMP3Codec) pMP3Codec->release(); if (pPCMSwapper) pPCMSwapper->release(); CoUninitialize(); return 0;}
In the rest of thedo
cument, I will not write the cleanup code, butdo
n't forget it !
We now have to find the GraphBuilder interface :
if (FAILED(pSDGraph->QueryInterface(IID_IGraphBuilder, (void **) &amp;pSDBuilder))){ /* nettoyage */ ...}
And now, all the other filters must be added on the GraphBuilder interface :
if (FAILED(pSDBuilder->AddFilter(pAVISplitter, NULL))){ /* nettoyage */ ...}if (FAILED(pSDBuilder->AddFilter(pHardwareDecoder, NULL))){ /* nettoyage */ ...}if (FAILED(pSDBuilder->AddFilter(pMP3Codec, NULL))){ /* nettoyage */ ...}if (FAILED(pSDBuilder->AddFilter(pPCMSwapper, NULL))){ /* nettoyage */ ...}
Now we can give the name of the file we want to play to the Source filter. (The source filter expects a string in a wide char format. If you have a string of type char[],do
n't forget to convert it first) :
if (szMonFichierAVI){ unsigned short szFileName[256]; MultiByteToWideChar(GetACP(), 0, szMonFichierAVI, strlen(szMonFichierAVI) + 1, szFileName, 256); if (FAILED(pSourceFilter->Load(szFileName, NULL))) { /* nettoyage */ ... }}
Now, like we did in the VB code, we have to find the output pin of the source filter.
For that, we declare two interfaces : IPin and IEnumPins
IPin *pPin = NULL;IEnumPin *pEnumPins = NULL;
Now, we can get the pin collection of the source filter :
if (FAILED(pSourceFilter->EnumPins(&amp;pEnumPins))){ /* nettoyage */ ...}
We look in this collection for a pin named &quot;Output&quot;
:
pEnumPins->Reset();ULONG nPlaced = 0;
if (FAILED(pEnumPins->Next(1, &amp;pPin, &amp;nPlaced))){ /* nettoyage */ ...}if (FAILED(pEnumPins->FindPin(L&quot;Output&quot;, &amp;pPin))){ /* nettoyage */ ...}
Last step is to call the &quot;Render&quot;
method on the pin we found, so the GraphBuilder will try to connect all the other filters to each other.
if (FAILED(pSDBuilder->Render(pPin))){ /* nettoyage */ ...}
Now the graph is build and ready to run. To play the movie, we have to query our filtergraph for its IMediaControl interface :
IMediaControl *pMonControlGraph = NULL;
if (FAILED(pSDGraph->QueryInterface(IID_IMediaControl, (void **) &amp;pMonControlGraph))){ /* nettoyage */ ...}
Once we have it, we just have to call the &quot;Run&quot;, &quot;pause&quot;
or &quot;stop&quot;
methods on it to start, pause or stop the movie playback.
pMonControlGraph->Run();pMonControlGraph->Pause();pMonControlGraph->Stop();
To get or set the playback position, just declare and ask the filtergraph to instantiate the IMediaPosition interface :
IMediaPosition *pCurPosition = NULL;
if (FAILED(pSDGraph->QueryInterface(IID_IMediaPosition, (void **) &amp;pCurPosition))){ /* nettoyage */ ...}
and use pCurPosition->get_Duration() to get the total duration of your movie, pCurPosition->get_CurrentPosition() to get the current playback position. If you want to quickly move your playback position, just use pCurPosition->put_CurrentPosition().
Times are in seconds with a decimal part (double type).
When youdo
n't need your objects anymore,do
n't forget to clean everything by calling the &quot;Release&quot;
method on each COM object you instantiate. When you quit the program,do
n't forget also to call the function CoUninitialize().
 
unit Fmpfctw;

interface

uses mmsystem, Windows;

var
hReelDrv:HDRVR;
// REALmagic driver handle

function FMPOpenDriver:integer;
procedure FMPCloseDriver;
function FMPCommand(Command:BYTE;hMPEGStream:BYTE;Flags:WORD;Value:DWORD):DWord;
function FMPGetLastError(a:WORD):DWORD;

implementation

uses winfmp;

{*******************************************************************************
*
* FUNCTION : FMPOpenDriver()
*
* DESCRIPTION : Opens IMPEG32.DLL
*
* RETURN : non-zero if successful, 0 if failed.
*
* NOTES :
*
*******************************************************************************}
function FMPOpenDriver:integer;
var
a,b:PWideChar;
begin

GetMem(a,10);
GetMem(b,10);
a:='reeldrv';
b:='Drivers32';
hReelDrv:=HDRVR(OpenDriver(a,b,0));//(LPCWSTR)TEXT(&quot;Reeldrv&quot;),(LPCWSTR)TEXT(&quot;Driver32&quot;),0L);
if hReelDrv<>0 then

result:=0
else

result:=1; // successfully opened driver
end;


{*******************************************************************************
*
* FUNCTION : FMPCloseDriver()
*
* DESCRIPTION : Closes IMPEG32.DLL
*
* RETURN : NONE
*
* NOTES :
*
*******************************************************************************}
procedure FMPCloseDriver;
begin

CloseDriver(hReelDrv,0,0);
hReelDrv := 0;
end;


{*******************************************************************************
*
* FUNCTION : FMPCommand()
*
* DESCRIPTION : This function interfaces with the FMP MPEG support driver
* and sends out the requested command.
*
* RETURN : value from SendDriverMessage
*
* NOTES :
*
*******************************************************************************}
function FMPCommand(Command:BYTE;hMPEGStream:BYTE;Flags:WORD;Value:DWORD):DWORD;
begin

result:=DWORD(SendDriverMessage(hReelDrv,DRV_USER+1,
MAKELPARAM(MAKEWORD(Command,hMPEGStream),Flags),Value));
end;


{*******************************************************************************
*
* FUNCTION : FMPGetLastError()
*
* DESCRIPTION : Returns last command error code.
*
* RETURN : last REALmagic command error code
*
* NOTES :
*
*******************************************************************************}
function FMPGetLastError(a:WORD):DWORD;
begin

result:=DWORD(SendDriverMessage(hReelDrv,DRV_USER+2,DWORD(a),0));
end;

end.
 
unit RealMagic;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
FMPDEFS, Fmpfctw, Resource, Winfmp, Fmpmacs;
{*******************************************************************************
* RealMagic控制VCL *
* *
*
*注:错误事件,代码说明
* code String
* 1 open
* 2 setfilename
* 3 openfile
*******************************************************************************}
type
TRMStatus=(rmREADY,rmPLAY,rmNOTREADY);
TRMErrorNotify=procedure (ErrorString:String;ErrorCode:Integer) of object;
TPlayEndEvent=procedure (Sender:TObject) of object;
TPlayMidEvent=procedure (Sender:TObject) of object;
TRealMagic = class(TComponent)
private
FCount:Integer;
FOnError:TRMErrorNotify;
FFileName:String;
FStatus:TRMStatus;
FMpegStream:BYTE;
FPlayEnd:TPlayEndEvent;
FPlayMid:TPlayMidEvent;
procedure SetFileName(Value:String);
procedure SetPlayEnd(PPlayEnd:TPlayEndEvent);
procedure SetPlayMid(PPlayMid:TPlayMidEvent);
{ Private declarations }
protected
{ Protected declarations }
public
IsPlay:Boolean;
CurStream:String;
CurTrack:String;
procedure Open;
procedure Close;
procedure Play;
procedure pause;
procedure stop;
procedure Step;
procedure Prior;
procedure OpenDrive;
procedure CloseDrive;
procedure SetAudioStream(Value:Integer);
procedure SetVcdTrack(Value:String);
procedure SetOutPut(Value:String);
procedure ConverOutPut;
procedure SetVol(Value:Integer);
procedure RePlay;
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
property Status:TRMStatus read FStatus write FStatus;
property Count:Integer read FCount write FCount;
{ Public declarations }
published
property OnError:TRMErrorNotify read FONError write FONError;
property FileName:String read FFileName write SetFileName;
property PlayEnd:TPlayEndEvent read FPlayEnd write SetPlayend;

property PlayMid:TPlayMidEvent read FPlayMid write SetPlayMid;
{ Published declarations }
end;

var
GPlayEnd:TPlayEndEvent;
GPlayMid:TPlayMidEvent;
GMpegStream:BYTE;

function CallBack(bMsg:BYTE;hMPEGStream:BYTE;dwValue:DWORD):word;stdcall;

procedure Register;

implementation

procedure Register;
begin

RegisterComponents('Samples', [TRealMagic]);
end;


function CallBack(bMsg:BYTE;hMPEGStream:BYTE;dwValue:DWORD):word;stdcall;
begin

Case bMsg of
FMPM_SIGNAL:begin

if Assigned(GPlayMid) then
GPlayMid(nil);
end;

FMPM_COMPLETED:begin

if (FMPGet(GMpegStream,FMPI_STM_MODE)=FMPF_STOPPED) and Assigned(GPlayEnd) then
GPlayEnd(nil);
end;

end;

end;


procedure TRealMagic.RePlay;
begin

FMPSeek(FMpegStream,FMPF_POS_START or FMPF_END_KEEP,0)
end;


procedure TRealMagic.SetPlayEnd(PPlayEnd:TPlayEndEvent);
begin

FPlayEnd := PPlayend;

GPlayEnd := FPlayend;

IsPlay := false;
end;


procedure TRealMagic.SetPlayMid(PPlayMid:TPlayMidEvent);
begin

FPlayMid := PPlayMid;
GPlayMid := FPlayMid;
end;


procedure TRealMagic.Step;
var
Temp:Integer;
begin

// if (FStatus=rmREADY) or (FStatus=rmPLAY) then

begin

Temp:=FMPGet(FMpegStream,FMPI_STM_DEV_POS);
Temp:=Temp+100;

// FMPStep(FMpegStream,FMPF_END_KEEP,200);
if Temp>=FCount then

FMPSeek(FMpegStream,FMPF_POS_END,Temp)
else

FMPSeek(FMpegStream,FMPF_POS_SET or FMPF_END_KEEP,Temp);
end;

end;


procedure TRealMagic.Prior;
var
Temp:Integer;
begin

// if (Status=rmREADY) or (Status=rmPLAY) then

begin

Temp:=FMPGet(FMpegStream,FMPI_STM_DEV_POS);
Temp:=Temp-200;
if Temp<=0 then

FMPSeek(FMpegStream,FMPF_POS_START,Temp)
else

FMPSeek(FMpegStream,FMPF_POS_SET or FMPF_END_KEEP,Temp);
end;

end;


procedure TRealMagic.SetVol(Value:Integer);
begin

FMPSet(FMpegStream, FMPI_AUD_VOLUME, MAKEDWORD(Value,Value));
end;


procedure TRealMagic.SetVcdTrack(Value:String);
begin

if Value = '' then

Exit;
CurTrack := Value[1];
if UpperCase(CurTrack)='L' then

begin

FMPSet(FMpegStream, FMPI_AUD_BAL_L, MAKEDWORD(100, 0));
FMPSet(FMpegStream, FMPI_AUD_BAL_R, MAKEDWORD(100, 0));
end;

if UpperCase(CurTrack)='R' then

begin

FMPSet(FMpegStream, FMPI_AUD_BAL_L, MAKEDWORD(0, 100));
FMPSet(FMpegStream, FMPI_AUD_BAL_R, MAKEDWORD(0, 100));
end;

if UpperCase(CurTrack)='S' then

begin

FMPSet(FMpegStream, FMPI_AUD_BAL_L, MAKEDWORD(100, 0));
FMPSet(FMpegStream, FMPI_AUD_BAL_R, MAKEDWORD(0, 100));
end;

end;


procedure TRealMagic.ConverOutPut;
begin

if FMPGet(FMpegStream, FMPI_VID_TV)=FMPF_VGA then

FMPSet(FMpegStream, FMPI_VID_TV, FMPF_TV)
else

FMPSet(FMpegStream, FMPI_VID_TV, FMPF_VGA);
end;


procedure TRealMagic.SetOutPut(Value:String);
begin

if UpperCase(Value)='TV' then

FMPSet(FMpegStream, FMPI_VID_TV, FMPF_TV);
if UpperCase(Value)='VGA' then

FMPSet(FMpegStream, FMPI_VID_TV, FMPF_VGA);
end;


procedure TRealMagic.Open;
begin

// if (Status=rmPLAY) or (Status=rmNOTREADY) then

// Exit;
FMpegStream := FMPOpen(FMPF_FILE, DWORD(LPSTR(PChar(FFileName))));
if FMpegStream<=0 then

begin

if Assigned(FOnError) then
FOnError('open file',3);
if Assigned(FPlayEnd) then
FPlayEnd(nil);
Exit;
end;

GMpegStream := FMpegStream;
FMPCallBack(FMpegStream,Integer(@CallBack));
FMPSet(FMpegStream,FMPI_STM_TIME_FMT,FMPF_FRAMES);
FCount:=FMPGet(FMpegStream,FMPI_STM_FILESIZE);
FMPSignal(FMpegStream,FMPF_SIG_AT,FCount div 2);
// set video keying mode
FMPSet(FMpegStream, FMPI_VID_KEY_MODE, FMPF_KEY_VGA );
// set video keying color
FMPSet(FMpegStream, FMPI_VID_KEY_COL, 0 );
// set video destination position
// SendMessage( handle, WM_MOVE, 0, 0 );
// set video destination size
// SendMessage( handle, WM_SIZE, 0, 0 );
// SendMessage(handle, WM_COMMAND, IDM_PLAY, 0);
Status:=rmREADY;
end;


procedure TRealMagic.Close;
begin

FMPClose( FMpegStream );
end;


procedure TRealMagic.Play;
begin

// if Status=rmREADY then

// begin

FMPPlay( FMpegStream,FMPF_POS_END or FMPF_END_STOP, 0);
IsPlay := true;
Status:=rmPLAY;
// end
end;


procedure TRealMagic.pause;
begin

// if Status=rmPLAY then

begin

FMPPause( FMpegStream );
Status:=rmREADY;
end;

end;


procedure TRealMagic.stop;
begin

// if (Status=rmPLAY) OR (Status=rmREADY) then

begin

FMPStop( FMpegStream );
Status:=rmREADY;
end;

end;


procedure TRealMagic.SetAudioStream(Value:Integer);
begin

//if (FStatus=rmREADY) or (FStatus=rmPLAY) then

FMPGroup(FMpegStream, FMPF_SELECT or FMPF_INDEX, Value);
CurStream := IntToStr(Value);
end;


procedure TRealMagic.SetFileName(Value:String);
begin

// if (Status<>rmPLAY) and (Status<>rmNOTREADY) then

begin

FFileName:=Value;
Open;
end;

// else

if Assigned(FOnError) then
FOnError('setfilename',2);
end;


constructor TRealMagic.Create(AOwner: TComponent);
begin

inherited Create(AOwner);
IsPlay := false;
end;


destructor TRealMagic.Destroy;
begin

inherited Destroy;
end;


procedure TRealMagic.OpenDrive;
begin

if FMPOpenDriver<>0 then

if Assigned(FOnError) then
FOnError('open',1);
Status:=rmNOTREADY;
end;


procedure TRealMagic.CloseDrive;
begin

FMPStop(FMpegStream);
FMPClose(FMpegStream);
FMPCloseDriver;
end;


end.
 
unit Resource;

interface

Const
RM_ICON = 101;
RM_ABOUTBOX = 102;
RM_MENU = 103;
IDD_DIALOG1 = 104;
IDC_PORT = 1000;
IDC_FILETOOPEN = 1001;
IDC_ADDRESS = 1002;
IDM_OPEN = 40001;
IDM_EXIT = 40002;
IDM_PLAY = 40003;
IDM_ABOUT = 40004;
IDM_STOP = 40005;
IDM_CLOSE = 40006;
IDM_PAUSE = 40007;
IDM_SEEK = 40008;
IDM_LEFT = 40013;
IDM_RIGHT = 40014;
IDM_VOICE = 40016;
IDM_AUDIOCHANNEL1 = 40016;
IDM_NOVOICE = 40017;
IDM_AUDIOCHANNEL2 = 40017;
IDM_VGA = 40020;
IDM_TV = 40021;
IDM_AUDIOCHANNEL3 = 40022;
IDM_AUDIOCHANNEL4 = 40023;
IDM_AUDIOLEFT = 40024;
IDM_AUDIORIGHT = 40025;
IDM_AUDIOSTEREO = 40026;
implementation

end.
 
unit Winfmp;

interface

uses FMPDefs,FMPMacs,FMPFctw,windows;

function MAKEDWORD(wLow,wHigh:WORD):LPARAM;

implementation

function MAKEDWORD(wLow,wHigh:WORD):LPARAM;
begin

result:=MAKELPARAM( wLow,wHigh);
end;

end.
 
Software Developer Program






2002-1-1






INSTALLATION 3
WINDOWS NT 3
WINDOWS 95 3
USE GUIDELINES 4
STREAMS 5
BASIC STREAMS - AUDIO AND VIDEO STREAMS. 5
GROUP STREAMS 5
SOURCE OF THE STREAM DATA 6
BUFFERED STREAMS 6
BROADCASTED STREAMS 7
AUTOMATIC FLOW CONTROL - CLIENT/SERVER SYNCHRONIZATION. 7
FILE TYPE ANALYSIS 8
THE FRAME BUFFER - SOURCE AND DESTINATION WINDOWS 10
CALLBACK FUNCTIONS 11
TROUBLESHOOTING 13
WHAT’S NEW 14
VERSION 4.00B2: 14
COMMAND SET 15
FMPCALLBACK 16
FMPCAPTURE 17
FMPCLOSE 18
FMPCLOSEDRIVER 19
FMPCOMMAND 20
FMPFREEZE 21
FMPGET 22
FMPGETLASTERROR 23
FMPGROUP 24
FMPOPEN 25
FMPOPENDRIVER 27
FMPPAUSE 28
FMPPLAY 29
FMPSEEK 30
FMPSET 32
FMPSIGNAL 33
FMPSTEP 34
FMPSTOP 35
USING FMP COMMANDS FROM WINDOWS NT&amp;#8482;
&amp;
WINDOWS 95&amp;#8482; 41
APPENDIX A - SYMBOLS 43
FMPMACS.H 43
FMPDRV.H 45
FMPFCTW.C 52

Installation


WINDOWS NT

The driver is registered as :
/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Drivers32

ReelDrv ‘’IMPEG32.DLL’’

To load it use the function FMPOpenDriver().

This function opens the 32-bit MPEG driver (IMPEG32.DLL) under Windows NT and prepares it to receive other FMP commands.
This function is implemented in FMPFCTW.C.

then
, you can get information about the driver (name, version) and the state of the hardware with the FMP_GET command.

WINDOWS 95

In SYSTEM.INI add

ReelDrv=C :/REALMAGC/IMPGE32.DLL

in the [drivers32] section.

To load it use the function FMPOpenDriver().

This function opens the 32-bit MPEG driver (IMPEG32.DLL) under Windows NT and prepares it to receive other FMP commands.
This function is implemented in FMPFCTW.C.


Use Guidelines

1. Programming Notes

Stream manipulations
The stream formats supported by this version are :
n MPEG1 and MPEG2 Video
n MPEG1 Audio Layer I and II, MPEG2 Audio Layer I and II,do
lby AC3
n MPEG1 System streams
n MPEG2 Program streams
n MPEG2 Transport streams

When a stream is opened, the driver will try to recognize its format and extract information from it. The file extension is not considered during the identification process.

Samples
Some samples in C are included with the driver. Please, refer to them for more information on how to use the driver.

2. Technical support
If you need additional information, if you encounter problems or if you have any suggestions, please contact REALmagic developer support at:


Fax : 510-770-2640
Streams

Independent of the hardware resources (you will generally be able to play only one video sequence and one audio sequence at a time) this driver provides the capability to manage several streams.
Basic streams - Audio and video streams.

The two basic streams are streams containing only a video channel or an audio channel.

The driver can open up to 255 streams. Each of them can have its own characteristics of speed, window, volume, time format, ... depending on its type (video or audio).

A stream can be in one of these five modes :
* stop mode : the stream is stopped, no display for video streams
* pause mode : the stream is paused. For audio streams it's the same as a stop mode. For video streams, the last frame is frozen in the frame window.
* play mode : the stream is playing. Audio and video.
* seek mode : the stream is reaching a given position. Audio and video
* step mode : the stream is stepping. Video only.

The ready modes are the pause and the stop modes. While initiating a play, seek or step mode, you can specify the mode to enter when the command will be completed : pause, stop, or the ready mode before the command.

If you send a command and the stream is not in a ready mode, the current command is canceled and you will receive a message indicating the cancel.

When initiating a command, control will be returned to you as soon as possible, usually before the command is completed. You can get the current mode of the stream with the FMP_GET-FMPI_STM_MODE command and wait for it to be completed.

When a command is completed, you will receive a FMPM_COMPLETED message (see callback functions pg.Error! Bookmark not defined.).

If a stream is currently playing and you want to play another stream and the hardware is unable todo
so, the new play command has the priority and the play mode of the first stream will be canceled and this stream will enter the mode it would have normally entered after the play.

You can program signals to know for example when a stream has reached a position or at every period you specify. You have only one signal at a time per stream.
Group Streams

Group streams are specials streams containing basic streams. A group stream, like any other stream can be played, stepped, or seeked and commands will apply to all streams contained in the Group.

When you open an interleaved stream, for example an MPEG1 system stream file or an MPEG2 program stream file, it will be opened as a group stream. If you then
play it, video and audio will be played and synchronized together.

You can select or deselect streams in a group. If a file is not selected, it will not be played.
This is useful , for example, when you have several audio tracks, you can select the one you want.

You can create your own group stream . You use open command (FMP_OPEN, pg. Error! Bookmark not defined.) to open a new empty group. then
you can use the group command (FMP_GROUP, pg.Error! Bookmark not defined.) to add, remove, select, deselect streams in it.

Source of the stream data

Basic stream data can be provided in three ways:
- from a file : the driver directly processes the file format and buffers. We call them file streams.
- from pull model buffers (buffered streams) : the calling application provides the stream data.
- from push model buffers (broadcasted streams) : the network provides the stream data.

Buffered streams

On-Demand application are generally pull implementations.
· Standard Pull Model (exists in previous version of the driver) - Driver asks for data when it is needed. When no data is available, the drivers just wait until the application gives a new buffer.

In the case of buffered streams, the user is responsible for providing valid data.
Use the open command (FMP_OPEN with the flag FMPF_BUFFERS, pg.Error! Bookmark not defined.) to open a buffered stream.

If a callback function is installed for the driver, it will be called with the FMPF_BUF_CREATE message with the parameter you gave with FMP_OPEN. (If no callback function is defined for the stream initially, then
FMPF_BUF_CREATE message will be sent once the callback function is installed .)

A buffered stream will use a buffer in user’s application. No copy of buffer data will be made, so user should be careful not to overwrite data not yet read from the buffer. A buffer is a segment of linear memory anywhere in the physical memory space. You give the driver the address, the size, the mode of access of your buffer, by using FMP_SET command. You can use the FMP_GET command to get status as to how many bytes are left (or have not been read) in the buffer. The driver uses a message (see callback function) to tell the user when all of his buffer has been read (FMPM_BUF_EMPTY). At this time, you can use the FMP_SET command to give new buffer parameters to the driver. If the user decides to ignore the callback message, the buffer will be read again from the start if the flag FMPF_BUF_LOOP is set in FMPI_BUF_MODE.

You can specify a position that will generate a FMPM_BUF_POS message. This can be used to implement a FIFO or to begin
preparing data for a ping pong buffer. For example, your buffer has a size of 10kb. You can tell the driver to signal when there are less than 1kb left in the buffer ( pos=1024 ). The message FMPM_BUF_POS will be issued when the position is r7eached. (see Callback functions).



If you write a zero value for the size, the driver will assume the stream has ended and will then
set the size of the stream.

The callback function can receive the message FMPM_BUF_SEEK indicating that your next packet of data will have to start at the given offset (specified in bytes) within your stream file.

Youdo
n't need to pre-fill your buffers, because at the begin
ning, the FMPM_BUF_POS message (when you normally prepare the next buffer) will be sent before the FMPM_BUF_EMPTY (where you give a prepared buffer).

With the messages defined, you can manage your buffers inside the callback function, without external initialization or destruction or pre-fill.

Moreover, streams have a user information field FMPI_STM_USER that you can use to store information about the streams buffers, so you can use this and a single callback function for all your streams.
Broadcasted streams

In broadcast applications, the server drives the bitrate of the stream and pushes the data to the client. We can make the job of the programmer easier by providing an API that allow the user to push data to our driver rather than its native pull.

· User supplies data at the rate that the user defines. A FIFO is maintained by the driver and it tries to maintain half-fullness with it. Playback is triggered when it reaches a start threshold. Callbacks signal the application when data overflows or underflows.
· User defines a start threshold, a low threshold and a high threshold via and API call. User will receive callback to the application if the start, low or high threshold is traversed, allowing the user to take necessary action.
· Another API call allows the user to pass buffer pointers to the driver.
· Buffering algorithm implements flow control. (see below)

In the case of buffered streams, the user is responsible for providing valid data.
Use the open command (FMP_OPEN with the flag FMPF_BROADCAST, pg.Error! Bookmark not defined.) to open a broadcasted stream.

You can push buffers to the driver by using FMP_SET command with two different settings:
· FMPI_PUSH_SYNC The driver copy the buffer before returning, so you can use it immediately
· FMPI_PUSH_ASYNC No copy of buffer data will be made, so user should be careful not to overwrite data not yet read from the buffer. When the driver has read the buffer, it sends a FMPM_PUSH_READ message to the callback routine (value is a pointer to the FMP_PUSH_BUF read).
In both cases, the third value of FMPSet is a pointer to a FMP_PUSH_BUF structure.
If the FMPSet returns FMPE_REFUSE :
1. The stream is not in play mode but you are feeding the FIFO.
2. The FiFo is full : in this case you should send a stop and a play or the driver will refuse data until it has emptied the FiFo.

Youdo
n't need to pre-fill your buffers before opening the stream : the driver will open by default a Group Stream and as soon as you push data, the driver will analyze them to find the type of the stream and will begin
to play.



Automatic Flow Control - Client/Server Synchronization.
The synchronization may become an issue in the broadcast case if the client and server clocks are slightly out of sync. Although the server always sends the MPEG stream over the network at the bitrate that the stream is encoded for, if the client clock is only slightly faster than that of the server, the MPEG decoder will consume data slightly faster than the broadcast rate. This would eventually result in buffer underflow. On the other hand, if the client clock is slightly slower than the server clock, the decoder will not consume data fast enough and data overflow will eventually occur.

Buffered API implementation implements some sort of flow control mechanism for passing data to the decoder. The flow control mechanism maintains that data is always available to the decoder. That’s the way the decoder likes it.

One method of flow control is implemented: Auto Start/Stop :
· Start/Stop - The driver automatically pauses streaming when it detects underflow condition in FIFO. When a start threshold is met, it will automatically start. Overflow will be managed by dropping video packets. Audio to remain in sync.

User can set start, low and high threshold by using FMPSet command.
















File type analysis
The following rules are only information on reader’s discretion and are subject to changes:
· The extension is not used to determine the file type.
· After opening the input file and reading MPEG data, the FMP driver will search for a MPEG pack header (0x000001BA), for a MPEG2 transport syncbyte (0x47), for a sequence header (0x000001B3) or for an audio syncword (0xFFF). The driver will consider immediately the file as a MPEG1 system file or a MPEG2 program file when a pack header is found. In the case of a MPEG2 transport stream, the driver will try to find at least 10 MPEG2 transport packets (188 bytes length, begin
ning with 0x47). In the last two cases, the diver will keep on searching for a header in order to verify the sequence header or the audio syncword is not inside a packet. When a minimum number of bytes has been looked (around 3000 bytes), the driver will decide whether the file is a video file (first choice) or an audio file (no sequence header has been found).
· When the file is considered as a MPEG1 system file or MPEG2 program system , the driver will start searching for information on the different video and audio streams. When a sequence header is found (there can be more than one to describe the streams), the driver will use it to calculate the number of video and audio streams. then
, the driver will try to retrieve information for those streams in the first 20 packets. If some streams remain not initialized (i.e. declare inside a sequence header, but no matching packets) the driver will keep on looking in the next 80 packets or until the first matching packet is found. If some streams are unknown (i.e. not declare in a sequence header), they will be treated the same way. Note that the driver will stop searching for streams when an invalid packet is found (i.e. the next packet headerdo
es not match with the previous packet header after adding the position of the previous packet and its size).
· When the file is considered as a MPEG2 transport stream, the driver will start searching for a program association table, then
for the program map tables to get the elementary streams. The, the driver will try to retrieve information for the elementary streams by using the random_access_indicator bit.
· When the file is considered as an audio file, the first audio syncword found will be considered as the begin
ning of an audio frame (which may not be true: audio syncword are allowed inside audio data).
· The first packet of a stream is used to determine some of its characteristics. Thus, the first video packet needs to have a sequence header fully contained inside the packet (itdo
es not have to be at the begin
ning of the packet). Same thing for the audio: the first audio syncword found in the packet - there must be at least one - will be considered as the begin
ning of a valid audio frame.


The Frame Buffer - Source and destination windows

This concerns video streams.

* The frame buffer is a hardware buffer containing an entire decompressed picture.
* The source window is the area in the buffer that will be effectively displayed.
* The destination window is the area in the VGA display where the piece of picture will be placed.
* The visual content of the source window is scaled to fit in the destination window.
* The video window uses RGB pixels and so can display 16 million colors.



There are several ways to control the way VGA pixels are replaced by video pixels in the destination window. This is the keying mode (FMPI_VID_KEY_MODE)

* FMPF_ALL_VGA : The destination window is hidden.

* FMPF_ALL_VID: Video is always displayed in the destination window.

* FMPF_KEY_VGA (default): All the pixels in the VGA destination window matching the key color (FMPI_VID_KEY_COL, color 0 - usually black - is default) after the key mask (FMPI_VID_KEY_MASK, default mask=0xFFFF) are transparent and replaced by video. This is useful to keep the mouse visible over the video window. Todo
this, you paint the destination window area with a color not used by the mouse pointer or other objects you want to keep visible and you specify this color as the key color. The key color is an index in the palette or an RGB color, depending of the current VGA mode. With the mask, you can select more colors because the mask is applied on the VGA pixel before being compared to the key color. The equation is (in C syntax) :
if ( (VGAPixelColor &amp;
VGAKeyMask) == (VGAKeyColor &amp;
VGAKeyMask) ) Show the video pixel

* FMPF_KEY_VID : All the pixels in the video destination window are compared to a min. and a max. R8G8B8 color. If they are inside the range, they are not shown. This can be used for example to display an animated object over the VGA. Todo
this, the video animation can have an object moving on a background whose colors is between the two values. So, the background will not be displayed and the object will move over the VGA display. The equation for this mode is (in C syntax) :
if (VideoPixelColor >= FMPI_VID_KEY_MIN) &amp;&amp;
VideoPixelColor <= FMPI_VID_KEY_MAX)) Show the VGA pixel
The RGB comparison is made on each R, G and B value. The previous equation must be true for each component.
* FMPF_KEY_MIX : a combination of VGA Key and Video Key.

Callback Functions

A callback function is a function of your application called by the driver in some situations.

You use the FMP_CALLBACK command to define callback functions. You can define a callback function per stream. If a stream has no callback function defined, the default driver callback function will be called (defined with the FMP_CALLBACK command with a zero handle for the stream).

Depending on the flags specified when declaring your function, the return status is passed in DWORD ’Value’

Your function should look like this:
DWORD MyCallBack(BYTE bMsg, BYTE hStream, DWORD dwValue);


You should return a zero value if successful.

The CallBack is called asynchronously from the driver, so you can use any command to re-enter the driver (Asynchronous messages are not re-entrant in the callback : you need to finish to treat a message before receiving a new one)..
For optimal performance, all FMPM_BUF_* messages are sent to the callback synchronously (the driver waits for the callback to finish before continuing). You can only use FMPGet and FMPSet from these messages.

The defined messages are :

FMPM_ERROR [async]
Specifies that an error occurred while executing a command. The error in Value may be one of the following:
FMPE_ERROR System error occurred while reading the stream
FMPE_INVALID_FLAG Flag in command is invalid
FMPE_HANDLE Handle in command is invalid
FMPE_NOT_IMPLEMENT Command not implemented
FMPE_INVALID_CMD Command is invalid
FMPE_OUT_OF_MEM Not enough memory to execute the command
FMPE_INDEX Index is invalid (in FMPGroup command)
FMPE_TYPE Invalid command for this type of stream
FMPE_TOO_MANY Too many open streams
FMPE_POS No more data to execute the command
FMPE_HARDWARE Problem occurred with the hardware
FMPE_STREAM_DATA The stream contains invalid data

FMPM_SIGNAL [async]
Message issued when the stream has reached the specified position with the (FMP_SIGNAL) command or when a period has completed (see FMP_SIGNAL). Value is the current stream position in frames.

FMPM_COMPLETED [async]
Message issued when a command has completed, for example when a play command is ended.
The stream is in a ready mode (paused or stopped) . Value is the completed command

FMPM_CANCELED [async]
Message issued when a new command is sent before a previous one has completed. Value is the
canceled command.

FMPM_BUF_CREATE (Buffered streams) [sync]
This message is sent when a buffered stream is opened. You can allocate your buffers and initialize the stream parameters when receiving this message. Value is the value passed in the
FMP_OPEN command. (Pointer to a FMP_OPEN_STRUCT structure

FMPM_BUF_CLOSE (Buffered streams) [sync]
This message is sent when the stream is about to be closed. This is the point where you can release stream resources (memory etc.)

FMPM_BUF_SEEK (Buffered streams) [sync]
This message is sent to ask you to seek to a given position in bytes. Value is the position to reach in bytes.

FMPM_BUF_EMPTY (Buffered streams) [sync]
This message is sent when a buffered stream's buffer is empty and more data is needed to complete the actual command. You can specify a new buffer with the FMP_SET-FMPI_BUF_ADDRESS command. If not then
the stream is stopped unless FMPF_BUF_LOOP flag is set In which case current buffer is scanned again. Value is the current position of the stream in bytes.

FMPM_BUF_POS (Buffered streams) [sync]
This message is sent when a buffered stream's buffer has reached the position specified with FMPI_BUF_POS.
Note: when the stream begin
s to play, you will receive this message before FMPF_BUF_EMPTY, so youdo
n't have to prepare the first buffer when opening the stream.

FMPM_FIFO_START [async]
This message is sent when the flow control is enabled and when FiFo has reached FMPI_FIFO_START position. The stream starts to play.

FMPM_FIFO_LOW [async]
This message is sent when the flow control is enabled and when FiFo is below FMPI_FIFO_LOW threshold. If FiFo reaches 0, it will pause untill it reaches FMPI_FIFO_START position.
dwValue is FMPF_AUDIO if the Audio FiFo is below low threshold, FMPF_VIDEO if it is the Video FiFo.

FMPM_FIFO_HIGH [async]
This message is sent when the flow control is enabled and when FiFo is over FMPI_FIFO_HIGH threshold. If FiFo reaches maximum size and FMPI_FIFO_DROP is enabled, the driver will drop packets to reduce the flow. If not, the FiFo will grow indefinitely and you will receive FMPM_BUF_HIGH message every time FiFo reaches a multiple of the maximum size.
dwValue is FMPF_AUDIO if the Audio FiFo has reached high threshold, FMPF_VIDEO if it is the Video FiFo.

FMPM_FIFO_DROP [async]
This message is sent when the driver has to drop packets to prevent overflow.(Flow Control and Drop Packets must be enabled)
dwValue is the number of dropped packets

FMPM_PUSH_INIT (broadcasted streams) [async]
This message is sent when a broadcasted stream has been opened and enough packets have been sent to the driver to determine all the parameters of the streams. You can initialize the stream parameters when receiving this message. Value is the value passed in the FMP_OPEN command. (Pointer to a FMP_OPEN_STRUCT structure)

FMPM_PUSH_READ (broadcasted streams) [sync]
This message is sent when the driver has read a broadcasted stream buffer.
DwValue is a pointer to the FMP_BROADCAST_BUF that has been read.

FMPM_PUSH_SEEK (broadcasted streams) [async]
This message is sent to ask you to seek to a given position in bytes. Value is the position to reach in bytes. (broadcasted streams)

FMPM_PUSH_CLOSE (Buffered streams) [async]
This message is sent when the stream is about to be closed. This is the point where you can release stream resources (memory etc.)

Troubleshooting

If you experience troubles using the callback functions, here are a few tips:
1. The first message you have to treat is FMPE_ERROR. If not, you can overflow the stack if you generate an error in the callback.
2. Your callback is called using the C calling convention. Make sure your callback uses this convention (if not, you can experience stack problems or reverse order arguments).
3. Verify youdo
n’t erase or rewrite memory blocks the driver has not finished to read.
4. If the callback receives FMPM_BUF_* or some FMPM_PUSH_* messages, you can only execute FMPGet or FMPSet from the callback. (You cando
what you want from others messages).
5. You should treat fastly any message you receive: if you lock the callback in a synchronous message, you also lock the driver (which waits the callback to return). If you lock the callback in an asynchronous message, you won’t receive any other asynchronous messages (but you can receive synchronous messages).
6. After opening a Broadcasted stream, since no information is available for the driver, it is possible that some settings related to video or audio streams will fail (FMPSet will fail). You need to send some packets to the decoder. You can only initialize the Stream Parameters only after receiving the FMP_PUSH_INIT message.

What’s New


Version 4.00b2:

· FMPM_PUSH_INIT and FMPM_PUSH_CLOSE have been added for broadcasted streams support.
· Improved Flow Control of the Fifos (no more division by zero).
· The driver should not hang when closing a broadcast stream.
· FMPI_STM_NOCACHE added : Useful if you want to receive FMPM_BUF_SEEK or FMPM_PUSH_SEEK messages even if data are in the internal cache of the driver
· Better handling of still pictures and slide shows for Video-CD 2.0.
· Support for Hollywood MPEG2 board.

Version 4.00b3:

· FMPI_FIFO_VID_LEFT and FMI_FIFO_AUD_LEFT added : number of left bytes in each FiFo.
· STOP (MULTIPLE_IRP_COMPLETION) (Blue Screen) in MPEG1 drivers for Windows NT when using FMPSignal.

Version 4.00RC1

· FMPI_STM_DEV_POS added to differenciate last played position from last read position :
FMPI_STM_POSITION is the actual position of the stream in the stream time format (last played data)
FMPI_STM_DEV_POS is the actual position of the device (file, buffer) in the stream format. (last read data)
· When seek pass the end of the file, FMPE_POS instead of FMPE_STREAM_DATA will be send to the callback.

Command Set

Following are the different commands you can use to access the driver.

Here is a summary of the commands classed by function.

* To open and close streams:
FMP_OPEN opens a stream
FMP_CLOSE closes a stream

* To play the stream
FMP_FREEZE pauses video without pausing audio
FMP_PLAY plays a stream
FMP_PAUSE pauses a stream
FMP_STOP stops a stream
FMP_SEEK seek at a position in a stream
FMP_STEP step frames for video streams

* To manage group streams
FMP_GROUP

* To set and get params about the driver and streams
FMP_SET sets a parameter
FMP_GET gets a parameter

* Todo
specials functions on streams
FMP_CAPTURE captures a frame of video into a bitmap
FMP_CALLBACK installs a callback function for a stream
FMP_SIGNAL installs a signal for a stream




FMPCallback



Description registers a callback function for buffered stream mode

DWORD FMPCallback (stream, callback);

BYTE stream MPEG stream handle
DWORD callback Pointer to the callback routine.

Return Value

Zero if successful or returns an error code
FMPGetLastError may be used to retrieve the last error code. The following are valid error codes from FMPGetLastError:

FMPE_HANDLE The handle of the stream is not valid.

Remarks

The FMPCallback command allows you to install callback functions. These functions are called when a command is completed, when an error occurs, or when driver needs data for a buffered stream. If a NULL callback handle is specified, the callback messages are sent to the driver. You can specify a null pointer if youdo
n't want a callback function for a stream or for all the streams.

See Also

Callback Functions



MCI Equivalent

MMIO install IO procedure.

FMPCapture

Description: Captures a video frame into a bitmap



DWORD FMPCapture (stream, flags, position);


BYTE stream Handle of the stream to capture.
WORD flags Bitmap type:

FMPF_PIC_BMP - Capture into 24-bit Windows BMP format.
FMPF_PIC_DIB24 - Capture into 24-bit DIB bitmap.

DWORD position Pointer to the buffer where the driver should store the bitmap. If this Pointer is 0, the driver will return the size necessary to store the image. then
you can allocate a buffer of this size and call FMPCapture with the pointer.


Return Value

Zero if successful. Otherwise, returns an error code.


Remarks

The FMPCapture command allows you to capture the currently displayed frame into a still image file.


See Also




MCI Equivalent

MCI_CAPTURE

FMPClose

Description: This function closes the specified stream



DWORD FMPClose (stream);

BYTE stream Handle of the stream to close.

Return Value

Zero if successful. Otherwise returns an error code.


Remarks

The FMPClose command closes a previously opened stream. All buffers are released, the file is closed and the handle becomes invalid until attributed to another stream. If the stream is not in the stop mode, a stop command is issued before closing.


See Also

FMPOpen


MCI Equivalent

MCI_CLOSE

FMPCloseDriver

Description: This function closes the MPEG driver.

.

DWORD FMPCloseDriver (void)

Return Value

None


Remarks

This function closes the 32-bit MPEG driver (IMPEG32.DLL) under Windows. No FMP functions should be called after the driver is closed.

This function is implemented in FMPFCTW.C.


See Also

FMPOpenDriver
Application Startup / Exit


MCI Equivalent

None


FMPCommand

Description: This command can be used to send a generic command to the driver.



DWORD FMPCommand (command, stream, flags, value);

BYTE command Command code.
BYTE stream Stream ID.
WORD flags Command flags.
DWORD value Command value.

Return Value

Return value of the command.


Remarks

This command sends a generic command to the driver. Most other commands are macros that map to this function.

In Win32, this function is implemented in FMPFCTW.C.

See Also

None


MCI Equivalent

None


FMPFreeze

Description: This command freezes Video frame, but continues to play Audio



DWORD FMPFreeze (stream);

BYTE stream Handle of the stream to pause.

Return Value

Zero if successful. Otherwise, returns one of the following error codes:

FMPE_HANDLE The handle of the stream is not valid.

Remarks

The FMPFreeze command freezes the video of an MPEG stream, but audio continues to play.


See Also

FMPPause, FMPStop



MCI Equivalent

MCI_FREEZE


FMPGet

Description: This command returns a value of specified setting for specified stream



DWORD FMPGet (stream, index);

BYTE stream Handle to the stream.
WORD index Index of the value to get.

Return Value

Value of the setting. Or 0xFFFFFFFF in case of error.
FMPGetLastError can be used to obtain error information about the command.
Error codes returned from FMPGetLastError:

FMPE_HANDLE The handle of the stream is not valid.
FMPE_INDEX The index is invalid.
FMPE_TYPE The index represents a value meaningless for the stream (for example, a volume setting for a video stream).

Remarks

The FMPGet command allows you to get a stream setting.
A NULL handle allows retrieval of a non-stream setting. The driver settings include information, status and default settings.


See Also

Settings
FMPSet


MCI Equivalent

MCI_INFO,
MCI_STATUS

FMPGetLastError

Description: This command returns the error code for last command executed by the driver.



DWORD FMPGetLastError ();


Return Value

Returns the error code for the last command executed.


Remarks



See Also

Error Codes



FMPGroup

Description: This command is general-purpose command for group stream. The user should use this command to manipulate group streams.



DWORD FMPGroup (stream, flags, value)

BYTE stream Stream handle

WORD flags Sub-command:

FMPF_INSERT Inserts a stream in the group (handle).
FMPF_REMOVE Remove a stream from the group (handle or index).
FMPF_GET Returns a stream handle given an index in the group list.
FMPF_SELECT Selects a stream in the group (handle or index) for playing.
FMPF_UNSELECT Unselects a stream in the group (handle or index) from playing.

Combined with the flags:
FMPF_HANDLE (Default) The element is given by its handle.
FMPF_INDEX The element is given by its index in the group list.

DWORD value Index or handle of the element. If NULL then
remove, select and deselect commands will apply to all streams in the group.

Return Value

Zero if successful. Otherwise FMPGetLastError can be used to obtain the last error code.

FMPE_HANDLE The handle of the group stream is not valid.
FMPE_FLAGS Invalid or incoherent flags (FMPF_INSERT with FMPF_INDEX for example).
FMPE_TOO_MANY There are too many streams in the group.
FMPE_ITEM_INDEX The index is invalid.
FMPE_ITEM_HANDLE The item handle is not valid.

Remarks

The FMPGroup command allows you to manipulate group streams.
If you try to add an already inserted stream in the group, there will be no error but the stream will not be inserted twice. The streams inserted in a groupdo
not have child/parent relationship. If the group is closed, the streams inserted in the group are not closed automatically. When a stream is inserted in the group, it is automatically selected.


MCI Equivalent

MCI_SETAUDIO/MCI_DGV_SETAUDIO_STREAM
MCI_SETVIDEO/MCI_DGV_SETVIDEO_STREAM

FMPOpen

Description: This command opens an MPEG stream.



DWORD FMPOpen (flags, value);

WORD flags Specifies initial Stream mode on Open

FMPF_FILE (Default) Stream data is read from a file.
FMPF_BUFFERS Stream provided by application. Cannot be used with FMPF_NOACCESS. (Pull buffers)
FMPF_GROUP Group of streams.
FMPF_BROADCAST Stream provided by application.(Push buffers)

DWORD value
· pointer to a null terminated string for FMPF_FILE.
that contains the file name to be opened
· pointer to a FMP_OPEN_STRUCT struct for FMPF_BUFFERS.
· NULL for FMPF_GROUP.
· pointer to a FMP_OPEN_STRUCT struct for FMPF_BROADCAST

The FMP_OPEN_STRUCT is defined as follows:
typedef struct {
LPTSTR lpFileName;
DWORD dwCallBack;
BYTE Reserved[8];
} FMP_OPEN_STRUCT;

lpFileName Pointer to a null terminated string that contains the file name to be opened. In buffered mode and broadcast mode, lpFileName is ignored.
dwCallBack Pointer to the callback routine (for buffered stream mode).

Return Value
If successful, this command will return a handle to a stream. or NULL if an error occurs.
The FMPGetLastError command may be used to determine the last error that occurred. Valid error
codes are:

FMPE_TOO_MANY Too many streams are actually opened and the driver refuses to open another one.
FMPE_OUT_OF_MEM The driver can't allocate buffers for the stream.
FMPE_INVALID_FLAGS Flags are invalid or incoherent.

Remarks
The FMPOpen command opens and prepares a new stream. The handle returned uniquely identifies the stream and will be required for all the commands that manipulate it.

If you are using buffered streams, your callback function may receive numerous messages from FMPOpen in order to determine type of stream being opened. The first message in this case is FMPM_BUF_CREATE. This allows you to allocate your buffers, provide pointers to existing buffers, or attach identifying structures or values via the FMPI_STM_USER field. The handle send to the callback function is the one returned by FMPOpen.

If the operation is successful, the stream is initialized, seeked to start and put in the stop mode. The stream settings are initialized to the default settings of the driver.
If the stream source is a file or user defined buffers, and if it contains more than a video or audio stream it will be considered a Group Stream.

In case of a broadcasted stream, the stream begin
s to play as soon as you push data But youdo
n’t need to pre-fill the buffers before opening the stream.

See Also
FMPClose, FMPGroup, FMPCallback
Callback Functions


MCI Equivalent
MCI_OPEN

FMPOpenDriver

Description This call will open the Realmagic MPEG driver

.

int FMPOpenDriver(void)

Return Value

Returns a non-zero value if the driver was successfully opened. Otherwise, it returns zero.


Remarks

This function opens the 32-bit MPEG driver (IMPEG32.DLL) under Win32 and prepares it to receive other FMP commands.

This function is implemented in FMPFCTW.C.

When an application terminates, it should execute and FMPCloseDriver to close the MPEG driver.


See Also

FMPCloseDriver, FMPFindDriver
Application Startup / Exit


MCI Equivalent

None

FMPPause

Description: This command will PAUSE currently playing stream. During PAUSE, last frame will be displayed in the mpeg window.



DWORD FMPPause(stream);

BYTE stream Handle of the stream to pause.

Return Value

Zero if successful. Otherwise, returns the following error code:

FMPE_HANDLE Invalid Stream handle.

Remarks

The FMPPause command pauses a stream. For audio streams, FMPPause AND FMPStop have the same effect, audio is stopped. FMPPause for video streams, freezes the last frame and keeps the window open.


See Also

FMPFreeze, FMPStop



MCI Equivalent

MCI_PAUSE

FMPPlay

Description: This command starts playing the specified Stream.

DWORD FMPPlay (stream, flags, position);

BYTE stream Handle of the stream to play
WORD flags One or more combination of following flags:

FMPF_POS_START Play to the start.
FMPF_POS_SET Play to an absolute position.
FMPF_POS_END (Default) Play to the end.

FMPF_POS_CUR Play to a relative position from the current one
FMPF_END_PAUSE After playing, the stream enters paused stream mode on the last frame.
FMPF_END_STOP (Default) After playing, the stream enters stop stream mode.
FMPF_END_KEEP After playing, the stream returns to the stream mode it was before FMPPlay command was issued.
FMPF_END_REPEAT After playing, the stream will restart at the begin
ning of the file.

DWORD position Position to play to in the current stream time format (if required by FMPF_POS_SET or FMPF_POS_CUR)


Return Value

Zero if successful. Otherwise, returns one of the following error codes:

FMPE_HANDLE The handle of the stream is not valid.
FMPE_POS The position given is out of the stream limits.
FMPE_STREAM The stream contains invalid data.
FMPE_TOO_MANY If the stream is a group, there are too many streams selected in it for the hardware.
FMPE_INVALID_FLAGS Flags are invalid or incoherent.

Remarks

The FMPPlay command plays a stream from its current position to another position given in the stream time format and with the stream speed.

The stream selected for playing has the priority on the hardware resources so if there are other streams playing, the most recent FMPPlay command will cause the other to enter pause or stop mode.

See Also

FMPPause, FMPStop


MCI Equivalent

MCI_PLAY

FMPSeek

Description: This command will seek to specified position in the stream.



DWORD FMPSeek(stream, flags, position);

BYTE stream Handle of the stream to seek
WORD flags One or more combination of following flags:

FMPF_POS_START Seek to the start.
FMPF_POS_SET Seek to an absolute position.
FMPF_POS_END Seek to the end.

FMPF_POS_CUR Relative seek from the current position.
FMPF_END_PAUSE After seeking, the stream enters pause mode on the new frame.
FMPF_END_STOP (Default) After seeking, the stream enters stop mode.
FMPF_END_KEEP After seeking, the stream returns to the stream mode it was before the FMPSeek function. If it was in paused stream mode, the display is not modified and the stream returns to paused mode. If it was in stopped stream mode, it returns to stop mode.

DWORD position Position to seek at in current time format (if required by FMPF_POS_SET or FMPF_POS_CUR)


Return Value

Zero if successful. Otherwise, the function returns one of the following error codes:

FMPE_HANDLE The handle of the stream is not valid.
FMPE_POS The position given is out of the stream limits.
FMPE_STREAM The stream contains invalid data.
FMPE_INVALID_CMD The command is not supported by the driver or by the hardware for this type of stream.
FMPE_INVALID_FLAGS Flags are invalid or incoherent.

Remarks

The FMPSeek command seeks to a position in a stream. The position is given in the current time
format. If a video stream is in pause mode, the last picture is still displayed during and after the seek.


See Also


Seeking


MCI Equivalent

MCI_SEEK

FMPSet

Description: This command will initialize the stream or the driver with specified setting.



DWORD FMPSet (stream, index, value);

BYTE stream Handle of the stream or zero for the driver settings
WORD index Index of the value to set or zero for nothing that can be combined with a flag:
DWORD value New value for the setting

Return Value

Returns the previous value of the given setting if successful otherwise returns 0xFFFFFFFF in case of error.
FMPGetLastError may be used to obtain the last error
code which may be one of the following:

FMPE_HANDLE The handle of the stream is not valid.
FMPE_INDEX The index is invalid.
FMPE_ITEM_INDEX The index represents a invalid value for this stream (for example a volume setting for a video stream).
FMPE_VALUE The value is invalid.
FMPE_WRITE The value cannot be written but only read.
FMPE_INVALID_FLAGS Flags are invalid or incoherent.

Remarks

The FMPSet command allows you to set a parameter of a stream or the driver if you specify a null handle. The driver settings include information, status and default settings.

You can specify audio or video settings for the driver. In this case, the values set in the driver will be the default values, for any future opened streams.

See Also

FMPGet,
Settings

MCI Equivalent
MCI_SET,MCI_SETVIDEO,MCI_SETAUDIO

FMPSignal

Description: This command is designed to notify the user for any Event for a stream



DWORD FMPSignal(stream, flags, position);

BYTE stream Handle of the stream
WORD flags Options:

FMPF_SIG_REMOVE Removes a signal (signal number given in position parameter).
FMPF_SIG_REMOVE_AT Removes all the signals at the given position.
FMPF_SIG_REMOVE_ALL Removes all the signals.
FMPF_SIG_AT A signal will occur at the given position.
FMPF_SIG_EVERY Signals will occur at the period in the position parameter.

DWORD position Position (for FMPF_SIG_AT and FMPF_SIG_REMOVE_AT).
Period (for FMPF_SIG_EVERY).
Signal number (for FMPF_SIG_REMOVE).

Return Value

The driver will return Signal number when FMP_SIGNAL_AT or FMP_SIGNAL_EVERY
is specified.
FMPGetLastError can be used to determine the last error code which may be one of the following:

FMPE_HANDLE The handle of the stream is not valid.
FMPE_VALUE The value is invalid.
FMPE_INVALID_FLAGS Flags are invalid or incoherent.


Remarks

The FMPSignal command lets you specify a signals when the stream reaches a position or periodic signals given in frame time format (signals in bytes will be supported in a future version). Signals will be sent to the callback function of the stream or the default callback function.

You cannot signal an audio stream.


See Also

FMPCallback
Callback Functions



MCI Equivalent

MCI_SIGNAL


FMPStep

Description: This command moves the video stream specified number of frames.

.

DWORD FMPStep(stream, flags, frames);

BYTE stream Handle of the stream.
WORD flags Valid flags:

FMPF_END_PAUSE After the operation, the stream will enter pause mode on the last frame.
FMPF_END_STOP (Default) After the operation, the stream will stop.
FMPF_END_KEEP After the operation , the stream returns to the mode it was in before.

DWORD frames Number of frames to step.

Return Value

Returns zero if successful. Otherwise, returns one of the following error codes:

FMPE_HANDLE The handle of the stream is not valid.
FMPE_STREAM_DATA The stream contains invalid data.
FMPE_INVALID_FLAGS Flags are invalid or incoherent.

Remarks

The FMPStep command steps a video stream one or more frames forward. If the number specified is 1, the stream advances to the next frame.


MCI Equivalent

MCI_STEP

FMPStop

Description: This command stops specified MPEG Stream



FMPStop(stream);

BYTE stream Handle of the stream to close.

Return Value

Zero if successful. Otherwise, returns one of the following error codes:

FMPE_HANDLE The handle of the stream is not valid.

Remarks

The FMPStop command stops a stream and closes its window if it is a video stream. The stream pointer is reset and next play command will start playing from begin
ning of the stream.


See Also

FMPPlay, FMPPause, FMPFreeze



MCI Equivalent

MCI_STOP


Settings

Following are the different settings and status for streams.

They can be read with the FMPGet command (see pg. Error! Bookmark not defined.) and written with the FMPSet command (see pg.Error! Bookmark not defined.) using the FMPI_xxx index.

The driver settings are considered as default settings future opened streams.

Some settings are read only and are marked as 'r', others can be written and are marked 'r/w'.
When it is 'r/s' it means that you can write the value only if it is not yet determined. To be used carefully.

All the writeable settings can be used as driver settings.

If you specify audio or video settings for a group stream, the values will be passed to all the corresponding audio and video streams of the group.

The FMPGet and FMPSet commands always use 32 bits values. When a value is less than 32 bits long, the unused bits are zero.

Driver specific settings

FMPI_DRV_PRODUCT r pointer on the driver name
FMPI_DRV_VERSION r version number r Lo-word : majorr Hi-word : minor
FMPI_DRV_MAX_CHAN r number of video and audio channels (streams) that can be played simultaneously.r Lo-word : maximum number of video channelsr Hi-word : maximum number of audio channels
FMPI_DRV_HDR_STAT r State of the hardware. Zero for OK or a combination of this flags:r FMPF_HRD_NO_DMA &amp;eth;
no DMA channel availableor FMPF_HRD_NO_INTS &amp;eth;
no interrupt availableor FMPF_HRD_NO_PORT &amp;eth;
no port availableor FMPF_HRD_NOT_FOUND &amp;eth;
board not foundor FMPF_HRD_UNKNOWN &amp;eth;
hardware problem (not yet specified)
FMPI_DRV_VID_SUP r (DWORD) mask containing all the video formats supported (up to 32). See FMPI_VID_TYPE for the different formats
FMPI_DRV_AUD_SUP r (DWORD_ mask containing all the audio formats supported (up to 32). See FMPI_AUD_TYPE for the different formats
FMPI_DRV_GRP_SUP r (DWORD) mask containing all the interlaced formats supported (up to 32). See FMPI_GRP_TYPE for the different formats

FiFo settings
FMPI_FIFO_FCNTRL r/w (BOOL) Enable or disable the flow control (should be used with buffered or broadcast streams).
FMPI_FIFO_SIZE r (DWORD) Size of the FiFo (Video + Audio) in bytes
FMPI_FIFO_VID_LEFT r (DWORD) Number of bytes left in the Video FiFo
FMPI_FIFO_AUD_LEFT r (DWORD) Number of bytes left in the Audio FiFo
FMPI_FIFO_MAX r/w Action taken by the driver when the FiFo is full :r FMPF_IGNORE : Ignore the maximum : FiFo will grow indefinitely in case of overflow.or FMPF_REFUSE : Refuse any more data until FiFo can absorb more packets (default)
FMPI_FIFO_DROP r/w Represents the percentage of packets that can be dropped by the driver in case of overflow : e.g 20% of dropping packet will handle an overflow of 17% of the bitrate (default is 0%)
FMPI_FIFO_UNIT r/w Unit of FiFo settings (size and start settings) :r FMPF_BYTES &amp;eth;
units are bytes (default)or FMPF_MSEC&amp;eth;
units are millisecond.
FMPI_FIFO_VID_SIZE r/w (DWORD) Maximum of video in FiFo (bytes or msec) (Flow Control). FMPI_FIFO_DROP needs to be enabled.
FMPI_FIFO_AUD_SIZE r/w (DWORD) Maximum of audio in FiFo (bytes or msec)(Flow Control). FMPI_FIFO_DROP needs to be enabled.
FMPI_FIFO_START r/w (DWORD) Start threshold (Flow control). Start playing when FiFo reaches FMPI_FIFO_START position (bytes or msec).
FMPI_FIFO_LOW r/w Low threshold (Flow control). Send FMPI_BUF_LOW message to the callback when FiFo is less than FMPI_FIFO_LOW % of the FiFO (maximum value is 100%)
FMPI_FIFO_HIGH r/w High threshold (Flow control). Send FMPI_BUF_HIGH message to the callback when FiFo is less than FMPI_FIFO_HIGH % of the FiFO (maximum value is 100%).

Common settings
FMPI_STM_TYPE r/s Type of the streamr FMPF_AUDIO &amp;eth;Audio streamor FMPF_VIDEO&amp;eth;
Video streamor FMPF_GROUP &amp;eth;
Group of streams
FMPI_STM_SOURCE r r FMPF_FILE &amp;eth;
the stream source is a fileor FMPF_BUFFERS &amp;eth;
the stream is provided by buffersor FMPF_BROADCAST&amp;eth;
the stream is provided by network buffers
FMPI_STM_FILEORG r/s (DWORD) Position of MPEG stream within a larger data file. For example, if you have appended all your MPEG movies together, you can tell the driver where to get the data.
FMPI_STM_FILESIZE r/s (DWORD) Size of the MPEG stream. Use this setting when you use FMPI_STM_FILEORG.
FMPI_STM_MODE r Current mode of the streamr FMPF_PAUSED &amp;eth;
in pause modeor FMPF_STOPPED &amp;eth;
in stop modeor FMPF_PLAYING &amp;eth;
currently playingor FMPF_SEEKING &amp;eth;
currently seekingor FMPF_STEPPING &amp;eth;
currently steppingalso defined:FMPF_READY = FMPF_PAUSED or FMPF_STOPPED
FMPI_STM_POSITION r The actual position of the stream in the stream time format. (Last played data)
FMPI_STM_DEV_POS r The actual position of the device (file, buffer) in the stream time format. (Last read data).
FMPI_STM_TIME_FMT r/w Time format of the streamr FMPF_BYTES: bytes format (default)or FMPF_FRAMES: frames format or FMPF_SAMPLES: equivalent to FMPF_FRAMES
FMPI_STM_SPEED r/w Speed of the stream - divisor and multiplier (1:1 is normal speed and default, 2:1 isdo
uble speed)r Lo-word : multiplier (default = 1)r Hi-word : divisor (default = 1)
FMPI_STM_USER r/w 32 bit value where you can read/write any information
FMPI_STM_PASSWD r/w 32 bit key to play an encrypted stream.
FMPI_STM_NOCACHE r/w (BOOL) Enable or disable internal caching when the driver receives a seek command.(Default = 0 : cache enabled) Useful if you want to receive FMPM_BUF_SEEK or FMPM_PUSH_SEEK messages even if data are in the internal cache of the driver.

Buffered streams settings
FMPI_BUF_LEFT r Number of bytes left in the stream buffer.
FMPI_BUF_POS r/w (DWORD) Position causing a message or 0 for no message.
FMPI_BUF_ADDRESS r/w (BYTE *) The buffer address.
FMPI_BUF_SIZE r/w (DWORD) Size of the buffer in bytes (default is zero)
FMPI_BUF_MODE r/w Mode of the buffer streamr FMPF_BUF_LOOP : current buffer is scanned again if no new address is specified.

Broadcasted streams settings
FMPI_PUSH_ASYNC w (FMP_PUSH_STRUCT*) Pointer to a push buffer. Give a buffer to read to the driver.You have to wait for FMPM_PUSH_READ message from the callback routine before using this push buffer again.If the FIFO is full FMPSet returns FMPE_REFUSE
FMPI_PUSH_SYNC w (FMP_PUSH_STRUCT*) Pointer to a push buffer. Give a buffer to read to the driver The driver has finished reading the buffer before returning from FMPSet.If the FIFO is full FMPSet returns FMPE_REFUSE

Video streams settings
FMPI_VID_TYPE r/s type of the video streamr FMPF_VID_MPEG &amp;eth;
MPEG 1 video streamor FMPF_VID_MPEG2 &amp;eth;
MPEG 2 video stream
FMPI_VID_RATE r/s number of pictures per secondr Lo-word &amp;eth;
integer partr Hi-word &amp;eth;
decimal part multiplied by 10000
FMPI_VID_SIZE r/s size of a picturer Lo-word &amp;eth;width in pixelsr Hi-word &amp;eth;
height in pixels
FMPI_VID_ASPECT r/s the pixel aspect ratio (height/width)r Lo-word &amp;eth;
integer partr Hi-word &amp;eth;
decimal part multiplied by 10000
FMPI_VID_BIT_RATE r/s bit rate of the bit stream in bits/second. A zero value identifies variable bit rate operation
FMPI_VID_SRC_POS r/w position of the source windowr Lo-word &amp;eth;
X position (default is zero)r Hi-word &amp;eth;
Y position (default is zero)
FMPI_VID_SRC_SIZE r/w size of the source windowr Lo-word &amp;eth;
width in pixels (zero is default and maximum width)r Hi-word &amp;eth;
height in pixels (zero is default and maximum height)
FMPI_VID_DEST_POS r/w position of the destination windowr Lo-word &amp;eth;
X position (default is zero)r Hi-word &amp;eth;
Y position (default is zero)
FMPI_VID_DEST_SIZE r/w size of the destination windowr Lo-word &amp;eth;
width in pixels (zero is default and maximum width)r Hi-word &amp;eth;
height in pixels (zero is default and maximum height)
FMPI_VID_KEY_MODE r/w The color keying mode (see Frame buffer for details )r FMPF_ALL_VGA : All the VGA is displayed .or FMPF_ALL_VID : All the video is displayedor FMPF_KEY_VGA : VGA keying mode (default)or FMPF_KEY_VID : Video keying modeor FMPF_KEY_MIX : combination of VGA and Video Key
FMPI_VID_KEY_MIN r/w (COLORREF) Minimum color value for the 'video range keying'. 24 bits RGB value
FMPI_VID_KEY_MAX r/w (COLORREF) Maximum color value for the 'video range keying'. 24 bits RGB value :
FMPI_VID_KEY_MASK r/w (COLORREF) Mask for keying (default is 0xFFFFFF)
FMPI_VID_KEY_COL r/w (COLORREF) Color for keying. Default is dark green.
FMPI_VID_BRIGHTNESS r/w Brightness (Pro/Ultra):Lo-word: value from 0 - 256.
FMPI_VID_SATURATION r/w Color saturation (Pro/Ultra) :Lo-word : value from 0 - 256
FMPI_VID_CONTRAST r/w Contrast (Pro/Ultra) :Lo-word : value from 0 - 256

Audio streams settings
FMPI_AUD_TYPE r/s type of the audio stream. r FMPF_AUD_MPEG_L1 &amp;eth;
MPEG1 Audio Layer I or FMPF_AUD_MPEG_L2 &amp;eth;
MPEG1 Audio Layer II or FMPF_AUD_MPEG_L3 &amp;eth;
MPEG1 Audio Layer III or FMPF_AUD_MPEG2_L1 &amp;eth;
MPEG2 Audio Layer I or FMPF_AUD_MPEG2_L2 &amp;eth;
MPEG2 Audio Layer II or FMPF_AUD_MPEG2_L3 &amp;eth;
MPEG2 Audio Layer III or FMPF_AUD_DOLBY_AC3 &amp;eth;
Dolby AC3 or FMPF_AUD_PCM &amp;eth;
PCM sound
FMPI_AUD_CHANNELS r/s r FMPF_AUD_STEREO &amp;eth;
stereo (MPEG Audio) or FMPF_AUD_JSTEREO &amp;eth;
joint stereo (MPEG Audio) or FMPF_AUD_DUAL &amp;eth;
dual channel (MPEG Audio) or FMPF_AUD_SINGLE &amp;eth;
single channel (MPEG Audio) or FMPF_AUD_11 &amp;eth;
Ch1,Ch2 (Dolby AC3) or FMPF_AUD_10 &amp;eth;
C (Dolby AC3) or FMPF_AUD_20 &amp;eth;
L, R (Dolby AC3) or FMPF_AUD_30 &amp;eth;
L, C, R (Dolby AC3) or FMPF_AUD_21 &amp;eth;
L, R, S (Dolby AC3) or FMPF_AUD_31 &amp;eth;
L, C, R, S (Dolby AC3) or FMPF_AUD_22 &amp;eth;
L, R, SL, SR(Dolby AC3) or FMPF_AUD_32 &amp;eth;
L, C, R, SL, SR (Dolby AC3)
FMPI_AUD_EMPH r/s r FMPF_AUD_NO_EMPH &amp;eth;
no emphasis or FMPF_AUD_EMPH_50 &amp;eth;
50/15 msec emphasis or FMPF_AUD_EMPH_J17 &amp;eth;
CCITT J.17 emphasis (MPEG Audio Only)
FMPI_AUD_RIGHTS r/s r FMPF_AUD_COPYRIGHT &amp;eth;
there is a copyright on the streamr FMPF_AUD_ORIGINAL &amp;eth;
the stream is an original(MPEG Audio Only)
FMPI_AUD_RATE r/s the sampling rate in samples per second
FMPI_AUD_BIT_RATE r/s bit rate of the stream in bits/second
FMPI_AUD_VOLUME r/w volumes of the right and left channelsr Lo-word &amp;eth;
left channel in percent . Maximum = 100% (default)r Hi-word &amp;eth;
right channel in percent. Maximum = 100% (default)
FMPI_AUD_TREBLE r/w high frequency level in percent. Default and nominal is 100%
FMPI_AUD_BASS r/w low frequency level in percent. Default and nominal is 100%
FMPI_AUD_BAL_L r/w left output channel balance:r Lo-word &amp;eth;
percentage of left input channel. 100% (default)r Hi-word &amp;eth;
percentage of right input channel. 0% default
FMPI_AUD_BAL_R r/w right output channel balance:r Lo-word &amp;eth;
percentage of left input channel. 0% (default)r Hi-word &amp;eth;
percentage of right input channel. 100% default

Group streams settings
FMPI_GRP_TYPE r type of the group stream.r FMPF_GRP_MPEG : MPEG1 system streamor FMPF_GRP_CUSTOM : streams have been inserted in the groupor FMPF_GRP_MPEG2_PROGRAM : MPEG2 program streamor FMPF_GRP_MPEG2_TRANSPORT : MPEG2 transport stream
FMPI_GRP_NB r Lo-word &amp;eth;
Number of streams in the group

Using FMP Commands from Windows NT&amp;#8482;
&amp;
Windows 95&amp;#8482;

IMPEG32.DLL (named &quot;ReelDrv&quot;
) is implemented as a Windows installable driver that understands the same commands as the Windows 3.1 Driver.

32-bit Windows applications should call FMPOpenDriver, implemented in FMPFCTW.C, before sending other commands. Thus, your application include the FMPFCTW.C module in your project. The FMPOpenDriver function loads Windows MPEG driver (IMPEG32.DLL) which implements the REALmagic API under Win32.

Modules that access the FMP commands should have the following include statement:

#include “FMPDEFS.H

The FMPCommand API is also implemented in FMPFCTW.C. Most other commands are implemented as macros that use FMPCommand.
The application should, before it terminates, call FMPCloseDriver function (implemented in FMPFCTW.C), which essentially unloads the Windows MPEG driver.

A general code shell might look like:

#define DRV_COMMAND DRV_USER+1
#define DRV_STATUS DRV_USER+2

#define MAKEDWORD(low, high) ((DWORD)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))

#define MAKEDWORD(a,b) MAKELPARAM(a,b)

#define FMPCommand(a,b,c,d) SendDriverMessage(hReelDrv,DRV_COMMAND,
MAKELPARAM(MAKEWORD(a,b),c),d)
#define FMPError() SendDriverMessage(hReelDrv,DRV_STATUS,0,0)

#include &quot;fmpmacs.h&quot;
// These macros can now be called exactly as you would in WIN32
{
int stream;
HDRVR hReelDrv;
hReelDrv = OpenDriver(TEXT(“ReelDrv”), NULL, NULL);
if( !hReelDrv)
{
MessageBox ( NULL,TEXT(&quot;REALmagic driver is not installed.&quot;),
szError,MB_ICONASTERISK | MB_OK);
}

stream = FMPOpen(FMPF_FILE,TEXT(”test.mpg”));
if (!stream)
{
char txt[100];
wsprintf(txt,TEXT(”Error %x”),FMPError());
MessageBox ( NULL,TEXT(&quot;REALmagic driver is not installed.&quot;),
szError,MB_ICONASTERISK | MB_OK);
}

// ... blah, blah, blah ...

if (stream)
FMPClose(stream);
CloseDriver(hReelDrv,NULL,NULL);
}
The initialization of the driver and the board is made when DRV_LOAD is received and the clean up isdo
ne when DRV_FREE is received.
Appendix A - Symbols

FMPMACS.H


/*******************************************************************************
*
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
*
* FILENAME : FMPMacs.h
*
* DESCRIPTION : This header file contains FMP specific macros that provide
* for an easier interface to sending FMP calls to the FMP
* MPEG support driver.
*
* PLATFORM : do
S, Windows
*
* PROGRAMMER : ECY
*
* COMMENTS : NONE
*
* NOTES : NONE
*
* CHANGES :
* 08/10/95 - Created.
* (ECY)
*
*******************************************************************************/


#ifndef __FMPMACS_H__
#define __FMPMACS_H__


#define FMPOpen( Flags, Filename ) /
LOBYTE( LOWORD( FMPCommand( FMP_OPEN, 0, Flags, Filename ) ) )

#define FMPClose( hMPEGStream ) /
FMPCommand( FMP_CLOSE, hMPEGStream, 0, 0 )

#define FMPSet( hMPEGStream, Index, Value ) /
FMPCommand( FMP_SET, hMPEGStream, Index, Value )

#define FMPGet( hMPEGStream, Index ) /
FMPCommand( FMP_GET, hMPEGStream, Index, 0 )

#define FMPPlay( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_PLAY, hMPEGStream, Flags, Position )

#define FMPStep( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_STEP, hMPEGStream, Flags, Position )

#define FMPCapture( hMPEGStream, Index, Position ) /
FMPCommand( FMP_CAPTURE, hMPEGStream, Index, Position )

#define FMPSeek( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_SEEK, hMPEGStream, Flags, Position )

#define FMPSignal( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_SIGNAL, hMPEGStream, Flags, Position )

#define FMPPause( hMPEGStream ) /
FMPCommand( FMP_PAUSE, hMPEGStream, 0, 0 )

#define FMPStop( hMPEGStream ) /
FMPCommand( FMP_STOP, hMPEGStream, 0, 0 )

#define FMPGroup( hMPEGStream, Flags, Value ) /
FMPCommand( FMP_GROUP, hMPEGStream, Flags, Value )

#define FMPCallback( hMPEGStream, Value ) /
FMPCommand( FMP_CALLBACK, hMPEGStream, FMPF_C, Value )

#define FMPUnload() /
FMPCommand( FMP_UNLOAD, 0, 0, 0 )

#define FMPInit() /
FMPCommand( FMP_INIT, 0, 0, 0 )

#define FMPFreeze( hMPEGStream, Flags, Value ) /
FMPCommand( FMP_FREEZE, hMPEGStream, Flags, Value )

#define FMPUpdate(subfunc,param1,param2) /
FMPCommand(FMP_UPDATE,subfunc,param1,param2)

#define FMPUpdatePalette( PaletteIndex, nColors ) /
FMPCommand( FMP_UPDATE, FMPI_UPD_PALETTE, 0, MAKEDWORD( nColors, PaletteIndex ) )

#define FMPUpdateVGAMode( Bits, Mode ) /
FMPCommand( FMP_UPDATE, FMPI_UPD_VGA_MODE, Bits, Mode )


#endif /* __FMPMACS_H__ */


FMPDefs.H

/*******************************************************************************
*
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
*
* FILENAME : FMPDefs.h
*
* DESCRIPTION : This header file contains FMP specific definitions.
*
* PLATFORM : do
S, Windows
*
* PROGRAMMER : ECY
*
* COMMENTS : NONE
*
* NOTES : NONE
*
* CHANGES :
* 08/10/95 - Created.
* (ECY)
*
*******************************************************************************/


#ifndef __FMPDEFS_H__
#define __FMPDEFS_H__


/*******************************************************************************
* FMP Commands
*******************************************************************************/
#define FMP_OPEN 0x01
#define FMP_CLOSE 0x02
#define FMP_PLAY 0x03
#define FMP_PAUSE 0x04
#define FMP_STOP 0x05
#define FMP_SEEK 0x06
#define FMP_STEP 0x07
#define FMP_GROUP 0x08
#define FMP_SET 0x09
#define FMP_GET 0x0A
#define FMP_CALLBACK 0x0B
#define FMP_SIGNAL 0x0C
#define FMP_UNLOAD 0x0D
#define FMP_INIT 0x0E
#define FMP_CAPTURE 0x0F
#define FMP_UPDATE 0x10
#define FMP_FREEZE 0x12


/*******************************************************************************
* FMP Errors
*******************************************************************************/
#define FMPE_DOS 0x0100
#define FMPE_INVALID_FLAGS 0x0200
#define FMPE_HANDLE 0x0300
#define FMPE_NOT_IMPLEMENT 0x0400
#define FMPE_INVALID_CMD 0x0500
#define FMPE_OUT_OF_MEM 0x0600
#define FMPE_INDEX 0x0700
#define FMPE_TYPE 0x0800
#define FMPE_WRITE 0x0900
#define FMPE_TOO_MANY 0x0A00
#define FMPE_ITEM_INDEX 0x0B00
#define FMPE_ITEM_HANDLE 0x0C00
#define FMPE_ERROR 0x0D00
#define FMPE_STREAM_DATA 0x0E00
#define FMPE_NOT_CDXA_DRV 0x0F00
#define FMPE_HARDWARE 0x1000
#define FMPE_NA 0x1100
#define FMPE_VALUE 0x1200
#define FMPE_TIME_FMT 0x1300
#define FMPE_NOT_READY 0x1400
#define FMPE_POS 0x1500
#define FMPE_REFUSE 0x1600
#define FMPE_INVALID_INDEX 0x1700

/*******************************************************************************
* FMP Messages
*******************************************************************************/
#define FMPM_BUF_POS 0x01
#define FMPM_BUF_EMPTY 0x02
#define FMPM_BUF_SEEK 0x03
#define FMPM_BUF_CREATE 0x04
#define FMPM_BUF_CLOSE 0x05
#define FMPM_BUF_TOTALSIZE 0x06
#define FMPM_COMPLETED 0x07
#define FMPM_CANCELED 0x08
#define FMPM_ERROR 0x09
#define FMPM_MEM_ALLOC 0x0A
#define FMPM_MEM_FREE 0x0B
#define FMPM_SIGNAL 0x0C
#define FMPM_FIFO_START 0x0D
#define FMPM_FIFO_LOW 0x0E
#define FMPM_FIFO_HIGH 0x0F
#define FMPM_FIFO_DROP 0x10
#define FMPM_PUSH_READ 0x11
#define FMPM_PUSH_SEEK 0x12
#define FMPM_PUSH_INIT 0x13
#define FMPM_PUSH_CLOSE 0x14

/*******************************************************************************
* FMP Flags
*******************************************************************************/
#define FMPF_BUF_LOW 0x00000000L
#define FMPF_BUF_EMS 0x00010000L
#define FMPF_BUF_XMS 0x00020000L

#define FMPF_PASCAL 0x1000
#define FMPF_C 0x2000

#define FMPF_TEST 0x8000

#define FMPF_INSERT 0x0001
#define FMPF_REMOVE 0x0002
#define FMPF_GET 0x0003
#define FMPF_SELECT 0x0004
#define FMPF_UNSELECT 0x0005
#define FMPF_HANDLE 0x0000
#define FMPF_INDEX 0x0020

#define FMPF_FILE 0x0001
#define FMPF_BUFFERS 0x0002
#define FMPF_GROUP 0x0003
#define FMPF_BROADCAST 0x0004
#define FMPF_EXTEND 0x0010
#define FMPF_NOACCESS 0x0100

#define FMPF_UNKNOWN 0x0000
#define FMPF_AUDIO 0x0001
#define FMPF_VIDEO 0x0002

#define FMPF_POS_START 0x0100
#define FMPF_POS_SET 0x0200
#define FMPF_POS_END 0x0300
#define FMPF_POS_CUR 0x0400

#define FMPF_DONT_UPDATE 0x1000
#define FMPF_UPDATE_ALL 0x2000

#define FMPF_SIG_AT 0x0001
#define FMPF_SIG_EVERY 0x0002
#define FMPF_SIG_REMOVE 0x0003
#define FMPF_SIG_REMOVE_AT 0x0004
#define FMPF_SIG_REMOVE_ALL 0x0005

#define FMPE_HRD 0x2000
#define FMPE_HRD_NO_DMA 0x2100
#define FMPE_HRD_NO_INT 0x2200
#define FMPE_HRD_NO_PORT 0x2300
#define FMPE_HRD_NOT_FOUND 0x2400
#define FMPE_HRD_DONT_USE 0x2500

#define FMPF_END_STOP 0x0000
#define FMPF_END_PAUSE 0x0001
#define FMPF_END_KEEP 0x0002
#define FMPF_END_REPEAT 0x0004
#define FMPF_END_CLOSE 0x0005

#define FMPF_PAUSED 0x0001
#define FMPF_STOPPED 0x0002
#define FMPF_PLAYING 0x0004
#define FMPF_SEEKING 0x0008
#define FMPF_STEPPING 0x0010
#define FMPF_CLOSED 0x0020
#define FMPF_READY (FMPF_PAUSED | FMPF_STOPPED)

#define FMPF_BYTES 0x0001
#define FMPF_SAMPLES 0x0002
#define FMPF_MSEC 0x0003
#define FMPF_HMSF 0x0004
#define FMPF_HMSC 0x0005
#define FMPF_FRAMES FMPF_SAMPLES
#define FMPF_TIME FMPF_HMSC
#define FMPF_SMPTE FMPF_HMSF

#define FMPF_BUF_32_BITS 0x0001
#define FMPF_BUF_LOOP 0x0002

#define FMPF_VID_UNKNOWN 0x0000
#define FMPF_VID_MPEG 0x0001
#define FMPF_VID_AVI 0x0002
#define FMPF_VID_MPEG2 0x0004

#define FMPF_ALL_VGA 0x0001
#define FMPF_ALL_VID 0x0002
#define FMPF_KEY_VGA 0x0004
#define FMPF_KEY_VID 0x0008
#define FMPF_KEY_MIX 0x000C
#define FMPF_KEY_CALIBRATE 0x000D

#define FMPF_AUD_UNKNOWN 0x0000
#define FMPF_AUD_MPEG 0x0001
#define FMPF_AUD_MPEG_L1 0x0002
#define FMPF_AUD_MPEG_L2 0x0004
#define FMPF_AUD_MPEG_L3 0x0008
#define FMPF_AUD_MPEG2 0x0010
#define FMPF_AUD_MPEG2_L1 0x0020
#define FMPF_AUD_MPEG2_L2 0x0040
#define FMPF_AUD_MPEG2_L3 0x0080
#define FMPF_AUD_DOLBY_AC3 0x0100

#define FMPF_AUD_WAVE 0x0010
#define FMPF_AUD_VOC 0x0020
#define FMPF_AUD_PCM 0x0040
#define FMPF_AUD_ADPCM 0x0080

#define FMPF_AUD_STEREO 0x0001
#define FMPF_AUD_JSTEREO 0x0002
#define FMPF_AUD_DUAL 0x0003
#define FMPF_AUD_SINGLE 0x0004

#define FMPF_AUD_NO_EMPH 0x0001
#define FMPF_AUD_EMPH_50 0x0002
#define FMPF_AUD_EMPH_J17 0x0003

#define FMPF_AUD_COPYRIGHT 0x0001
#define FMPF_AUD_ORIGINAL 0x0002

#define FMPF_GRP_UNKNOWN 0x0000
#define FMPF_GRP_MPEG 0x0001
#define FMPF_GRP_AVI 0x0002
#define FMPF_GRP_CUSTOM 0x0004
#define FMPF_GRP_MPEG2_PROGRAM 0x0008
#define FMPF_GRP_MPEG2_TRANSPORT 0x0010

#define FMPF_PIC_BMP 0x0001
#define FMPF_PIC_DIB24 0x0002
#define FMPF_PIC_TOFILE 0x0004

#define FMPF_REFUSE 0x0001
#define FMPF_IGNORE 0x0002


/*******************************************************************************
* FMP Index
*******************************************************************************/
#define FMPI_DRV_PRODUCT 0x0101
#define FMPI_DRV_VERSION 0x0102
#define FMPI_DRV_MAX_CHAN 0x0103
#define FMPI_DRV_VID_SUP 0x0104
#define FMPI_DRV_AUD_SUP 0x0105
#define FMPI_DRV_GRP_SUP 0x0106
#define FMPI_DRV_HDR_STAT 0x0107
#define FMPI_DRV_MEMORY 0x0108
#define FMPI_DRV_ID 0x0109
#define FMPI_DRV_CAPABILITY 0x010A

#define FMPI_STM_TYPE 0x0202
#define FMPI_STM_SOURCE 0x0203
#define FMPI_STM_MODE 0x0204
#define FMPI_STM_TIME_FMT 0x0205
#define FMPI_STM_POSITION 0x0206
#define FMPI_STM_SPEED 0x0207
#define FMPI_STM_USER 0x0208
#define FMPI_STM_SIZE 0x0209
#define FMPI_STM_SLIDE 0x020A
#define FMPI_STM_PASSWD 0x0210
#define FMPI_STM_FILETYPE 0x0211
#define FMPI_STM_MEMFLAGS 0x0212
#define FMPI_STM_FILESIZE 0x0213
#define FMPI_STM_FILEORG 0x0214
#define FMPI_STM_BIT_RATE 0x0215
#define FMPI_STM_NOCACHE 0x0216

#define FMPI_BUF_LEFT 0x0301
#define FMPI_BUF_POS 0x0302
#define FMPI_BUF_ADDRESS 0x0303
#define FMPI_BUF_SIZE 0x0304
#define FMPI_BUF_MODE 0x0305
#define FMPI_BUF_TOTALSIZE 0x0306

#define FMPI_VID_TYPE 0x0401
#define FMPI_VID_RATE 0x0402
#define FMPI_VID_SIZE 0x0403
#define FMPI_VID_ASPECT 0x0404
#define FMPI_VID_BIT_RATE 0x0405
#define FMPI_VID_SRC_POS 0x0406
#define FMPI_VID_SRC_SIZE 0x0407
#define FMPI_VID_DEST_POS 0x0408
#define FMPI_VID_DEST_SIZE 0x0409
#define FMPI_VID_KEY_MIN 0x040A
#define FMPI_VID_KEY_MAX 0x040B
#define FMPI_VID_KEY_MASK 0x040C
#define FMPI_VID_KEY_COL 0x040D
#define FMPI_VID_KEY_MODE 0x040E
#define FMPI_VID_KEY_TYPE 0x040F
#define FMPI_VID_CONTRAST 0x0410
#define FMPI_VID_BRIGHTNESS 0x0411
#define FMPI_VID_SATURATION 0x0412
#define FMPI_VID_SLIDE 0x0420
#define FMPI_VID_HWND 0x0413
#define FMPI_VID_KEY_COL_INDEX 0x0414

#define FMPI_VID_DEFAULTS 0x1000
#define FMPI_VID_REGISTRY 0x2000

#define FMPI_AUD_TYPE 0x0501
#define FMPI_AUD_RATE 0x0502
#define FMPI_AUD_VOLUME 0x0503
#define FMPI_AUD_BIT_RATE 0x0504
#define FMPI_AUD_TREBLE 0x0505
#define FMPI_AUD_BASS 0x0506
#define FMPI_AUD_CHANNELS 0x0507
#define FMPI_AUD_EMPH 0x0508
#define FMPI_AUD_RIGHTS 0x0509
#define FMPI_AUD_SHIFT 0x0510
#define FMPI_AUD_BAL_L 0x0511
#define FMPI_AUD_BAL_R 0x0512

#define FMPI_AUD_DEFAULTS 0x1000
#define FMPI_AUD_REGISTRY 0x2000

#define FMPI_GRP_TYPE 0x0601
#define FMPI_GRP_NB 0x0602

#define FMPI_FIFO_FCNTRL 0x0701
#define FMPI_FIFO_SIZE 0x0702
#define FMPI_FIFO_MAX 0x0703
#define FMPI_FIFO_VID_SIZE 0x0704
#define FMPI_FIFO_AUD_SIZE 0x0705
#define FMPI_FIFO_START 0x0706
#define FMPI_FIFO_LOW 0x0707
#define FMPI_FIFO_HIGH 0x0708
#define FMPI_FIFO_DROP 0x0709
#define FMPI_FIFO_UNIT 0x070A

#define FMPI_PUSH_ASYNC 0x0801
#define FMPI_PUSH_SYNC 0x0802

// Overlay specific settings (does not appky to rm 1 &amp;
2)
#define FMPI_OVLY_XOFFSET 0x0901
#define FMPI_OVLY_YOFFSET 0x0902
#define FMPI_OVLY_VGACORRECTION 0x0903
#define FMPI_OVLY_STABILITY 0x0904
#define FMPI_OVLY_HFREQUENCY 0x0905
#define FMPI_OVLY_USEDEFAULTFREQ 0x0906
#define FMPI_OVLY_COLOR_SETTING 0x0907
#define FMPI_OVLY_LOWERLEVEL 0x0908
#define FMPI_OVLY_UPPERLEVEL 0x0909
#define FMPI_OVLY_DELTA_CALIBRATE 0x090A
#define FMPI_OVLY_COLOR_CALIBRATION 0x090B
#define FMPI_OVLY_JITTERING 0x090C

// Hoolywood (IBM MPEG 2) specific settings
#define FMPI_OVLY_CROPLEFT 0x0B01
#define FMPI_OVLY_CROPTOP 0x0B02
#define FMPI_OVLY_CROPRIGHT 0x0B03
#define FMPI_OVLY_CROPBOTTOM 0x0B04
#define FMPI_OVLY_INDELAY 0x0B05
#define FMPI_OVLY_OUTDELAY 0x0B06

// Values used for developpment purpose only
#define FMPI_ADJUSTMENT_A 0x0F01
#define FMPI_ADJUSTMENT_B 0x0F02
#define FMPI_ADJUSTMENT_C 0x0F03
#define FMPI_ADJUSTMENT_D 0x0F04
#define FMPI_ADJUSTMENT_E 0x0F05
#define FMPI_ADJUSTMENT_F 0x0F06

#define FMPI_OVLY_DEFAULTS 0x1000
#define FMPI_OVLY_REGISTRY 0x2000
#define FMPI_OVLY_RESET 0x4000

#define FMPI_UPD_PALETTE 0x0001
#define FMPI_UPD_VGA_MODE 0x0007
#define FMPI_UPD_FRAME_POS 0x0008
#define FMPI_UPD_FRAME_SIZE 0x0009

/*******************************************************************************
* FMP Constants
*******************************************************************************/

#define FMP_MIN_AUD_VOLUME 0
#define FMP_MAX_AUD_VOLUME 100
#define FMP_DEF_AUD_VOLUME 50

#define FMP_MIN_BSC 0 // Brightness, Saturation &amp;
Contrast
#define FMP_MAX_BSC 1000
#define FMP_DEF_BSC 500

// REALmagic capabilities
#define FMP_CAPABILITY_BORDER_ADJUST 0x0001
#define FMP_CAPABILITY_KEYCOLOR_ADJUST 0x0002
#define FMP_CAPABILITY_BSC_ADJUST 0x0004 // Brightness, Saturation &amp;
contrast
#define FMP_CAPABILITY_AUTO_CALIBRATE 0x0008
#define FMP_CAPABILITY_SPECIFIC_ADJUST 0x0010
#define FMP_CAPABILITY_GAMMA_ADJUST 0x0020
#define FMP_CAPABILITY_HIRES 0x0040

// RGB values used for min. medium and max color calibration
#define FMP_MIN_COLOR_LEVEL 0x00000000
#define FMP_MEDIUM_COLOR_LEVEL 0x00808080
#define FMP_MAX_COLOR_LEVEL 0x00FFFFFF
#define FMP_MEDIUM_COLOR 0x80

#define FMP_LOWER_RED 0x01
#define FMP_LOWER_GREEN 0x02
#define FMP_LOWER_BLUE 0x04
#define FMP_UPPER_RED 0x10
#define FMP_UPPER_GREEN 0x20
#define FMP_UPPER_BLUE 0x40

// Max sizes for low resolution
#define FMP_MAX_LOW_RES_WIDTH 640
#define FMP_MAX_LOW_RES_HEIGHT 480

/*******************************************************************************
* FMP Structures
*******************************************************************************/

typedef struct {
LPTSTR lpFileName;
DWORD dwCallBack;
BYTE Reserved[8];
} FMP_OPEN_STRUCT;

typedef struct {
DWORD dwSize;
void* lpBuffer;
} FMP_PUSH_STRUCT;

typedef struct {
COLORREF RGBColorKey;
COLORREF RGBUpper;
COLORREF RGBLower;
USHORT Mask;
} FMP_COLOR_SETTING_STRUCT;

#endif /* __FMPDEFS_H__ */




FMPFCTW.C

/*******************************************************************************
*
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
*
* FILENAME : FMPFctw.c
*
* DESCRIPTION : This source file contains functions to interface with the
* FMP IMPEG32 support driver.
*
* PLATFORM : WIN32
*
* PROGRAMMER : MI
*
* COMMENTS : NONE
*
* NOTES : NONE
*
* CHANGES :
* 8/13/96 - Created.
* (MI)
*
*******************************************************************************/

#include <windows.h>
#include &quot;../../include/winfmp.h&quot;
#include &quot;../../include/FMPfctw.h&quot;

HDRVR hReelDrv;
// REALmagic driver handle


/*******************************************************************************
*
* FUNCTION : FMPOpenDriver()
*
* DESCRIPTION : Opens IMPEG32.DLL
*
* RETURN : non-zero if successful, 0 if failed.
*
* NOTES :
*
*******************************************************************************/
int FMPOpenDriver(void)
{
hReelDrv=OpenDriver(TEXT(&quot;Reeldrv&quot;),TEXT(&quot;Driver32&quot;),0L);
if( !hReelDrv) {
return 0;
}
return 1; // successfully opened driver
}

/*******************************************************************************
*
* FUNCTION : FMPCloseDriver()
*
* DESCRIPTION : Closes IMPEG32.DLL
*
* RETURN : NONE
*
* NOTES :
*
*******************************************************************************/
void FMPCloseDriver(void)
{
CloseDriver(hReelDrv,0L,0L);
hReelDrv = 0;
}

/*******************************************************************************
*
* FUNCTION : FMPCommand()
*
* DESCRIPTION : This function interfaces with the FMP MPEG support driver
* and sends out the requested command.
*
* RETURN : value from SendDriverMessage
*
* NOTES :
*
*******************************************************************************/
DWORD FMPCommand( BYTE Command, BYTE hMPEGStream, WORD Flags, DWORD Value )
{
return (DWORD)SendDriverMessage(hReelDrv,DRV_USER+1,
MAKELPARAM(MAKEWORD(Command,hMPEGStream),Flags),Value);
}

/*******************************************************************************
*
* FUNCTION : FMPGetLastError()
*
* DESCRIPTION : Returns last command error code.
*
* RETURN : last REALmagic command error code
*
* NOTES :
*
*******************************************************************************/
DWORD FMPGetLastError(WORD a)
{
return (DWORD)SendDriverMessage(hReelDrv,DRV_USER+2,(DWORD)a,0L);
}
 
Driver specific settings

FMPI_DRV_PRODUCT r pointer on the driver name
FMPI_DRV_VERSION r version number r Lo-word : majorr Hi-word : minor
FMPI_DRV_MAX_CHAN r number of video and audio channels (streams) that can be played simultaneously.r Lo-word : maximum number of video channelsr Hi-word : maximum number of audio channels
FMPI_DRV_HDR_STAT r State of the hardware. Zero for OK or a combination of this flags:r FMPF_HRD_NO_DMA &amp;eth;
no DMA channel availableor FMPF_HRD_NO_INTS &amp;eth;
no interrupt availableor FMPF_HRD_NO_PORT &amp;eth;
no port availableor FMPF_HRD_NOT_FOUND &amp;eth;
board not foundor FMPF_HRD_UNKNOWN &amp;eth;
hardware problem (not yet specified)
FMPI_DRV_VID_SUP r (DWORD) mask containing all the video formats supported (up to 32). See FMPI_VID_TYPE for the different formats
FMPI_DRV_AUD_SUP r (DWORD_ mask containing all the audio formats supported (up to 32). See FMPI_AUD_TYPE for the different formats
FMPI_DRV_GRP_SUP r (DWORD) mask containing all the interlaced formats supported (up to 32). See FMPI_GRP_TYPE for the different formats

FiFo settings
FMPI_FIFO_FCNTRL r/w (BOOL) Enable or disable the flow control (should be used with buffered or broadcast streams).
FMPI_FIFO_SIZE r (DWORD) Size of the FiFo (Video + Audio) in bytes
FMPI_FIFO_VID_LEFT r (DWORD) Number of bytes left in the Video FiFo
FMPI_FIFO_AUD_LEFT r (DWORD) Number of bytes left in the Audio FiFo
FMPI_FIFO_MAX r/w Action taken by the driver when the FiFo is full :r FMPF_IGNORE : Ignore the maximum : FiFo will grow indefinitely in case of overflow.or FMPF_REFUSE : Refuse any more data until FiFo can absorb more packets (default)
FMPI_FIFO_DROP r/w Represents the percentage of packets that can be dropped by the driver in case of overflow : e.g 20% of dropping packet will handle an overflow of 17% of the bitrate (default is 0%)
FMPI_FIFO_UNIT r/w Unit of FiFo settings (size and start settings) :r FMPF_BYTES &amp;eth;
units are bytes (default)or FMPF_MSEC&amp;eth;
units are millisecond.
FMPI_FIFO_VID_SIZE r/w (DWORD) Maximum of video in FiFo (bytes or msec) (Flow Control). FMPI_FIFO_DROP needs to be enabled.
FMPI_FIFO_AUD_SIZE r/w (DWORD) Maximum of audio in FiFo (bytes or msec)(Flow Control). FMPI_FIFO_DROP needs to be enabled.
FMPI_FIFO_START r/w (DWORD) Start threshold (Flow control). Start playing when FiFo reaches FMPI_FIFO_START position (bytes or msec).
FMPI_FIFO_LOW r/w Low threshold (Flow control). Send FMPI_BUF_LOW message to the callback when FiFo is less than FMPI_FIFO_LOW % of the FiFO (maximum value is 100%)
FMPI_FIFO_HIGH r/w High threshold (Flow control). Send FMPI_BUF_HIGH message to the callback when FiFo is less than FMPI_FIFO_HIGH % of the FiFO (maximum value is 100%).

Common settings
FMPI_STM_TYPE r/s Type of the streamr FMPF_AUDIO &amp;eth;Audio streamor FMPF_VIDEO&amp;eth;
Video streamor FMPF_GROUP &amp;eth;
Group of streams
FMPI_STM_SOURCE r r FMPF_FILE &amp;eth;
the stream source is a fileor FMPF_BUFFERS &amp;eth;
the stream is provided by buffersor FMPF_BROADCAST&amp;eth;
the stream is provided by network buffers
FMPI_STM_FILEORG r/s (DWORD) Position of MPEG stream within a larger data file. For example, if you have appended all your MPEG movies together, you can tell the driver where to get the data.
FMPI_STM_FILESIZE r/s (DWORD) Size of the MPEG stream. Use this setting when you use FMPI_STM_FILEORG.
FMPI_STM_MODE r Current mode of the streamr FMPF_PAUSED &amp;eth;
in pause modeor FMPF_STOPPED &amp;eth;
in stop modeor FMPF_PLAYING &amp;eth;
currently playingor FMPF_SEEKING &amp;eth;
currently seekingor FMPF_STEPPING &amp;eth;
currently steppingalso defined:FMPF_READY = FMPF_PAUSED or FMPF_STOPPED
FMPI_STM_POSITION r The actual position of the stream in the stream time format. (Last played data)
FMPI_STM_DEV_POS r The actual position of the device (file, buffer) in the stream time format. (Last read data).
FMPI_STM_TIME_FMT r/w Time format of the streamr FMPF_BYTES: bytes format (default)or FMPF_FRAMES: frames format or FMPF_SAMPLES: equivalent to FMPF_FRAMES
FMPI_STM_SPEED r/w Speed of the stream - divisor and multiplier (1:1 is normal speed and default, 2:1 isdo
uble speed)r Lo-word : multiplier (default = 1)r Hi-word : divisor (default = 1)
FMPI_STM_USER r/w 32 bit value where you can read/write any information
FMPI_STM_PASSWD r/w 32 bit key to play an encrypted stream.
FMPI_STM_NOCACHE r/w (BOOL) Enable or disable internal caching when the driver receives a seek command.(Default = 0 : cache enabled) Useful if you want to receive FMPM_BUF_SEEK or FMPM_PUSH_SEEK messages even if data are in the internal cache of the driver.

Buffered streams settings
FMPI_BUF_LEFT r Number of bytes left in the stream buffer.
FMPI_BUF_POS r/w (DWORD) Position causing a message or 0 for no message.
FMPI_BUF_ADDRESS r/w (BYTE *) The buffer address.
FMPI_BUF_SIZE r/w (DWORD) Size of the buffer in bytes (default is zero)
FMPI_BUF_MODE r/w Mode of the buffer streamr FMPF_BUF_LOOP : current buffer is scanned again if no new address is specified.

Broadcasted streams settings
FMPI_PUSH_ASYNC w (FMP_PUSH_STRUCT*) Pointer to a push buffer. Give a buffer to read to the driver.You have to wait for FMPM_PUSH_READ message from the callback routine before using this push buffer again.If the FIFO is full FMPSet returns FMPE_REFUSE
FMPI_PUSH_SYNC w (FMP_PUSH_STRUCT*) Pointer to a push buffer. Give a buffer to read to the driver The driver has finished reading the buffer before returning from FMPSet.If the FIFO is full FMPSet returns FMPE_REFUSE

Video streams settings
FMPI_VID_TYPE r/s type of the video streamr FMPF_VID_MPEG &amp;eth;
MPEG 1 video streamor FMPF_VID_MPEG2 &amp;eth;
MPEG 2 video stream
FMPI_VID_RATE r/s number of pictures per secondr Lo-word &amp;eth;
integer partr Hi-word &amp;eth;
decimal part multiplied by 10000
FMPI_VID_SIZE r/s size of a picturer Lo-word &amp;eth;width in pixelsr Hi-word &amp;eth;
height in pixels
FMPI_VID_ASPECT r/s the pixel aspect ratio (height/width)r Lo-word &amp;eth;
integer partr Hi-word &amp;eth;
decimal part multiplied by 10000
FMPI_VID_BIT_RATE r/s bit rate of the bit stream in bits/second. A zero value identifies variable bit rate operation
FMPI_VID_SRC_POS r/w position of the source windowr Lo-word &amp;eth;
X position (default is zero)r Hi-word &amp;eth;
Y position (default is zero)
FMPI_VID_SRC_SIZE r/w size of the source windowr Lo-word &amp;eth;
width in pixels (zero is default and maximum width)r Hi-word &amp;eth;
height in pixels (zero is default and maximum height)
FMPI_VID_DEST_POS r/w position of the destination windowr Lo-word &amp;eth;
X position (default is zero)r Hi-word &amp;eth;
Y position (default is zero)
FMPI_VID_DEST_SIZE r/w size of the destination windowr Lo-word &amp;eth;
width in pixels (zero is default and maximum width)r Hi-word &amp;eth;
height in pixels (zero is default and maximum height)
FMPI_VID_KEY_MODE r/w The color keying mode (see Frame buffer for details )r FMPF_ALL_VGA : All the VGA is displayed .or FMPF_ALL_VID : All the video is displayedor FMPF_KEY_VGA : VGA keying mode (default)or FMPF_KEY_VID : Video keying modeor FMPF_KEY_MIX : combination of VGA and Video Key
FMPI_VID_KEY_MIN r/w (COLORREF) Minimum color value for the 'video range keying'. 24 bits RGB value
FMPI_VID_KEY_MAX r/w (COLORREF) Maximum color value for the 'video range keying'. 24 bits RGB value :
FMPI_VID_KEY_MASK r/w (COLORREF) Mask for keying (default is 0xFFFFFF)
FMPI_VID_KEY_COL r/w (COLORREF) Color for keying. Default is dark green.
FMPI_VID_BRIGHTNESS r/w Brightness (Pro/Ultra):Lo-word: value from 0 - 256.
FMPI_VID_SATURATION r/w Color saturation (Pro/Ultra) :Lo-word : value from 0 - 256
FMPI_VID_CONTRAST r/w Contrast (Pro/Ultra) :Lo-word : value from 0 - 256

Audio streams settings
FMPI_AUD_TYPE r/s type of the audio stream. r FMPF_AUD_MPEG_L1 &amp;eth;
MPEG1 Audio Layer I or FMPF_AUD_MPEG_L2 &amp;eth;
MPEG1 Audio Layer II or FMPF_AUD_MPEG_L3 &amp;eth;
MPEG1 Audio Layer III or FMPF_AUD_MPEG2_L1 &amp;eth;
MPEG2 Audio Layer I or FMPF_AUD_MPEG2_L2 &amp;eth;
MPEG2 Audio Layer II or FMPF_AUD_MPEG2_L3 &amp;eth;
MPEG2 Audio Layer III or FMPF_AUD_DOLBY_AC3 &amp;eth;
Dolby AC3 or FMPF_AUD_PCM &amp;eth;
PCM sound
FMPI_AUD_CHANNELS r/s r FMPF_AUD_STEREO &amp;eth;
stereo (MPEG Audio) or FMPF_AUD_JSTEREO &amp;eth;
joint stereo (MPEG Audio) or FMPF_AUD_DUAL &amp;eth;
dual channel (MPEG Audio) or FMPF_AUD_SINGLE &amp;eth;
single channel (MPEG Audio) or FMPF_AUD_11 &amp;eth;
Ch1,Ch2 (Dolby AC3) or FMPF_AUD_10 &amp;eth;
C (Dolby AC3) or FMPF_AUD_20 &amp;eth;
L, R (Dolby AC3) or FMPF_AUD_30 &amp;eth;
L, C, R (Dolby AC3) or FMPF_AUD_21 &amp;eth;
L, R, S (Dolby AC3) or FMPF_AUD_31 &amp;eth;
L, C, R, S (Dolby AC3) or FMPF_AUD_22 &amp;eth;
L, R, SL, SR(Dolby AC3) or FMPF_AUD_32 &amp;eth;
L, C, R, SL, SR (Dolby AC3)
FMPI_AUD_EMPH r/s r FMPF_AUD_NO_EMPH &amp;eth;
no emphasis or FMPF_AUD_EMPH_50 &amp;eth;
50/15 msec emphasis or FMPF_AUD_EMPH_J17 &amp;eth;
CCITT J.17 emphasis (MPEG Audio Only)
FMPI_AUD_RIGHTS r/s r FMPF_AUD_COPYRIGHT &amp;eth;
there is a copyright on the streamr FMPF_AUD_ORIGINAL &amp;eth;
the stream is an original(MPEG Audio Only)
FMPI_AUD_RATE r/s the sampling rate in samples per second
FMPI_AUD_BIT_RATE r/s bit rate of the stream in bits/second
FMPI_AUD_VOLUME r/w volumes of the right and left channelsr Lo-word &amp;eth;
left channel in percent . Maximum = 100% (default)r Hi-word &amp;eth;
right channel in percent. Maximum = 100% (default)
FMPI_AUD_TREBLE r/w high frequency level in percent. Default and nominal is 100%
FMPI_AUD_BASS r/w low frequency level in percent. Default and nominal is 100%
FMPI_AUD_BAL_L r/w left output channel balance:r Lo-word &amp;eth;
percentage of left input channel. 100% (default)r Hi-word &amp;eth;
percentage of right input channel. 0% default
FMPI_AUD_BAL_R r/w right output channel balance:r Lo-word &amp;eth;
percentage of left input channel. 0% (default)r Hi-word &amp;eth;
percentage of right input channel. 100% default

Group streams settings
FMPI_GRP_TYPE r type of the group stream.r FMPF_GRP_MPEG : MPEG1 system streamor FMPF_GRP_CUSTOM : streams have been inserted in the groupor FMPF_GRP_MPEG2_PROGRAM : MPEG2 program streamor FMPF_GRP_MPEG2_TRANSPORT : MPEG2 transport stream
FMPI_GRP_NB r Lo-word &amp;eth;
Number of streams in the group

Using FMP Commands from Windows NT&amp;#8482;
&amp;
Windows 95&amp;#8482;

IMPEG32.DLL (named &quot;ReelDrv&quot;
) is implemented as a Windows installable driver that understands the same commands as the Windows 3.1 Driver.

32-bit Windows applications should call FMPOpenDriver, implemented in FMPFCTW.C, before sending other commands. Thus, your application include the FMPFCTW.C module in your project. The FMPOpenDriver function loads Windows MPEG driver (IMPEG32.DLL) which implements the REALmagic API under Win32.

Modules that access the FMP commands should have the following include statement:

#include “FMPDEFS.H

The FMPCommand API is also implemented in FMPFCTW.C. Most other commands are implemented as macros that use FMPCommand.
The application should, before it terminates, call FMPCloseDriver function (implemented in FMPFCTW.C), which essentially unloads the Windows MPEG driver.

A general code shell might look like:

#define DRV_COMMAND DRV_USER+1
#define DRV_STATUS DRV_USER+2

#define MAKEDWORD(low, high) ((DWORD)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))

#define MAKEDWORD(a,b) MAKELPARAM(a,b)

#define FMPCommand(a,b,c,d) SendDriverMessage(hReelDrv,DRV_COMMAND,
MAKELPARAM(MAKEWORD(a,b),c),d)
#define FMPError() SendDriverMessage(hReelDrv,DRV_STATUS,0,0)

#include &quot;fmpmacs.h&quot;
// These macros can now be called exactly as you would in WIN32
{
int stream;
HDRVR hReelDrv;
hReelDrv = OpenDriver(TEXT(“ReelDrv”), NULL, NULL);
if( !hReelDrv)
{
MessageBox ( NULL,TEXT(&quot;REALmagic driver is not installed.&quot;),
szError,MB_ICONASTERISK | MB_OK);
}

stream = FMPOpen(FMPF_FILE,TEXT(”test.mpg”));
if (!stream)
{
char txt[100];
wsprintf(txt,TEXT(”Error %x”),FMPError());
MessageBox ( NULL,TEXT(&quot;REALmagic driver is not installed.&quot;),
szError,MB_ICONASTERISK | MB_OK);
}

// ... blah, blah, blah ...

if (stream)
FMPClose(stream);
CloseDriver(hReelDrv,NULL,NULL);
}
The initialization of the driver and the board is made when DRV_LOAD is received and the clean up isdo
ne when DRV_FREE is received.
Appendix A - Symbols

FMPMACS.H


/*******************************************************************************
*
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
*
* FILENAME : FMPMacs.h
*
* DESCRIPTION : This header file contains FMP specific macros that provide
* for an easier interface to sending FMP calls to the FMP
* MPEG support driver.
*
* PLATFORM : do
S, Windows
*
* PROGRAMMER : ECY
*
* COMMENTS : NONE
*
* NOTES : NONE
*
* CHANGES :
* 08/10/95 - Created.
* (ECY)
*
*******************************************************************************/


#ifndef __FMPMACS_H__
#define __FMPMACS_H__


#define FMPOpen( Flags, Filename ) /
LOBYTE( LOWORD( FMPCommand( FMP_OPEN, 0, Flags, Filename ) ) )

#define FMPClose( hMPEGStream ) /
FMPCommand( FMP_CLOSE, hMPEGStream, 0, 0 )

#define FMPSet( hMPEGStream, Index, Value ) /
FMPCommand( FMP_SET, hMPEGStream, Index, Value )

#define FMPGet( hMPEGStream, Index ) /
FMPCommand( FMP_GET, hMPEGStream, Index, 0 )

#define FMPPlay( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_PLAY, hMPEGStream, Flags, Position )

#define FMPStep( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_STEP, hMPEGStream, Flags, Position )

#define FMPCapture( hMPEGStream, Index, Position ) /
FMPCommand( FMP_CAPTURE, hMPEGStream, Index, Position )

#define FMPSeek( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_SEEK, hMPEGStream, Flags, Position )

#define FMPSignal( hMPEGStream, Flags, Position ) /
FMPCommand( FMP_SIGNAL, hMPEGStream, Flags, Position )

#define FMPPause( hMPEGStream ) /
FMPCommand( FMP_PAUSE, hMPEGStream, 0, 0 )

#define FMPStop( hMPEGStream ) /
FMPCommand( FMP_STOP, hMPEGStream, 0, 0 )

#define FMPGroup( hMPEGStream, Flags, Value ) /
FMPCommand( FMP_GROUP, hMPEGStream, Flags, Value )

#define FMPCallback( hMPEGStream, Value ) /
FMPCommand( FMP_CALLBACK, hMPEGStream, FMPF_C, Value )

#define FMPUnload() /
FMPCommand( FMP_UNLOAD, 0, 0, 0 )

#define FMPInit() /
FMPCommand( FMP_INIT, 0, 0, 0 )

#define FMPFreeze( hMPEGStream, Flags, Value ) /
FMPCommand( FMP_FREEZE, hMPEGStream, Flags, Value )

#define FMPUpdate(subfunc,param1,param2) /
FMPCommand(FMP_UPDATE,subfunc,param1,param2)

#define FMPUpdatePalette( PaletteIndex, nColors ) /
FMPCommand( FMP_UPDATE, FMPI_UPD_PALETTE, 0, MAKEDWORD( nColors, PaletteIndex ) )

#define FMPUpdateVGAMode( Bits, Mode ) /
FMPCommand( FMP_UPDATE, FMPI_UPD_VGA_MODE, Bits, Mode )


#endif /* __FMPMACS_H__ */


FMPDefs.H

/*******************************************************************************
*
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
*
* FILENAME : FMPDefs.h
*
* DESCRIPTION : This header file contains FMP specific definitions.
*
* PLATFORM : do
S, Windows
*
* PROGRAMMER : ECY
*
* COMMENTS : NONE
*
* NOTES : NONE
*
* CHANGES :
* 08/10/95 - Created.
* (ECY)
*
*******************************************************************************/


#ifndef __FMPDEFS_H__
#define __FMPDEFS_H__


/*******************************************************************************
* FMP Commands
*******************************************************************************/
#define FMP_OPEN 0x01
#define FMP_CLOSE 0x02
#define FMP_PLAY 0x03
#define FMP_PAUSE 0x04
#define FMP_STOP 0x05
#define FMP_SEEK 0x06
#define FMP_STEP 0x07
#define FMP_GROUP 0x08
#define FMP_SET 0x09
#define FMP_GET 0x0A
#define FMP_CALLBACK 0x0B
#define FMP_SIGNAL 0x0C
#define FMP_UNLOAD 0x0D
#define FMP_INIT 0x0E
#define FMP_CAPTURE 0x0F
#define FMP_UPDATE 0x10
#define FMP_FREEZE 0x12


/*******************************************************************************
* FMP Errors
*******************************************************************************/
#define FMPE_DOS 0x0100
#define FMPE_INVALID_FLAGS 0x0200
#define FMPE_HANDLE 0x0300
#define FMPE_NOT_IMPLEMENT 0x0400
#define FMPE_INVALID_CMD 0x0500
#define FMPE_OUT_OF_MEM 0x0600
#define FMPE_INDEX 0x0700
#define FMPE_TYPE 0x0800
#define FMPE_WRITE 0x0900
#define FMPE_TOO_MANY 0x0A00
#define FMPE_ITEM_INDEX 0x0B00
#define FMPE_ITEM_HANDLE 0x0C00
#define FMPE_ERROR 0x0D00
#define FMPE_STREAM_DATA 0x0E00
#define FMPE_NOT_CDXA_DRV 0x0F00
#define FMPE_HARDWARE 0x1000
#define FMPE_NA 0x1100
#define FMPE_VALUE 0x1200
#define FMPE_TIME_FMT 0x1300
#define FMPE_NOT_READY 0x1400
#define FMPE_POS 0x1500
#define FMPE_REFUSE 0x1600
#define FMPE_INVALID_INDEX 0x1700

/*******************************************************************************
* FMP Messages
*******************************************************************************/
#define FMPM_BUF_POS 0x01
#define FMPM_BUF_EMPTY 0x02
#define FMPM_BUF_SEEK 0x03
#define FMPM_BUF_CREATE 0x04
#define FMPM_BUF_CLOSE 0x05
#define FMPM_BUF_TOTALSIZE 0x06
#define FMPM_COMPLETED 0x07
#define FMPM_CANCELED 0x08
#define FMPM_ERROR 0x09
#define FMPM_MEM_ALLOC 0x0A
#define FMPM_MEM_FREE 0x0B
#define FMPM_SIGNAL 0x0C
#define FMPM_FIFO_START 0x0D
#define FMPM_FIFO_LOW 0x0E
#define FMPM_FIFO_HIGH 0x0F
#define FMPM_FIFO_DROP 0x10
#define FMPM_PUSH_READ 0x11
#define FMPM_PUSH_SEEK 0x12
#define FMPM_PUSH_INIT 0x13
#define FMPM_PUSH_CLOSE 0x14

/*******************************************************************************
* FMP Flags
*******************************************************************************/
#define FMPF_BUF_LOW 0x00000000L
#define FMPF_BUF_EMS 0x00010000L
#define FMPF_BUF_XMS 0x00020000L

#define FMPF_PASCAL 0x1000
#define FMPF_C 0x2000

#define FMPF_TEST 0x8000

#define FMPF_INSERT 0x0001
#define FMPF_REMOVE 0x0002
#define FMPF_GET 0x0003
#define FMPF_SELECT 0x0004
#define FMPF_UNSELECT 0x0005
#define FMPF_HANDLE 0x0000
#define FMPF_INDEX 0x0020

#define FMPF_FILE 0x0001
#define FMPF_BUFFERS 0x0002
#define FMPF_GROUP 0x0003
#define FMPF_BROADCAST 0x0004
#define FMPF_EXTEND 0x0010
#define FMPF_NOACCESS 0x0100

#define FMPF_UNKNOWN 0x0000
#define FMPF_AUDIO 0x0001
#define FMPF_VIDEO 0x0002

#define FMPF_POS_START 0x0100
#define FMPF_POS_SET 0x0200
#define FMPF_POS_END 0x0300
#define FMPF_POS_CUR 0x0400

#define FMPF_DONT_UPDATE 0x1000
#define FMPF_UPDATE_ALL 0x2000

#define FMPF_SIG_AT 0x0001
#define FMPF_SIG_EVERY 0x0002
#define FMPF_SIG_REMOVE 0x0003
#define FMPF_SIG_REMOVE_AT 0x0004
#define FMPF_SIG_REMOVE_ALL 0x0005

#define FMPE_HRD 0x2000
#define FMPE_HRD_NO_DMA 0x2100
#define FMPE_HRD_NO_INT 0x2200
#define FMPE_HRD_NO_PORT 0x2300
#define FMPE_HRD_NOT_FOUND 0x2400
#define FMPE_HRD_DONT_USE 0x2500

#define FMPF_END_STOP 0x0000
#define FMPF_END_PAUSE 0x0001
#define FMPF_END_KEEP 0x0002
#define FMPF_END_REPEAT 0x0004
#define FMPF_END_CLOSE 0x0005

#define FMPF_PAUSED 0x0001
#define FMPF_STOPPED 0x0002
#define FMPF_PLAYING 0x0004
#define FMPF_SEEKING 0x0008
#define FMPF_STEPPING 0x0010
#define FMPF_CLOSED 0x0020
#define FMPF_READY (FMPF_PAUSED | FMPF_STOPPED)

#define FMPF_BYTES 0x0001
#define FMPF_SAMPLES 0x0002
#define FMPF_MSEC 0x0003
#define FMPF_HMSF 0x0004
#define FMPF_HMSC 0x0005
#define FMPF_FRAMES FMPF_SAMPLES
#define FMPF_TIME FMPF_HMSC
#define FMPF_SMPTE FMPF_HMSF

#define FMPF_BUF_32_BITS 0x0001
#define FMPF_BUF_LOOP 0x0002

#define FMPF_VID_UNKNOWN 0x0000
#define FMPF_VID_MPEG 0x0001
#define FMPF_VID_AVI 0x0002
#define FMPF_VID_MPEG2 0x0004

#define FMPF_ALL_VGA 0x0001
#define FMPF_ALL_VID 0x0002
#define FMPF_KEY_VGA 0x0004
#define FMPF_KEY_VID 0x0008
#define FMPF_KEY_MIX 0x000C
#define FMPF_KEY_CALIBRATE 0x000D

#define FMPF_AUD_UNKNOWN 0x0000
#define FMPF_AUD_MPEG 0x0001
#define FMPF_AUD_MPEG_L1 0x0002
#define FMPF_AUD_MPEG_L2 0x0004
#define FMPF_AUD_MPEG_L3 0x0008
#define FMPF_AUD_MPEG2 0x0010
#define FMPF_AUD_MPEG2_L1 0x0020
#define FMPF_AUD_MPEG2_L2 0x0040
#define FMPF_AUD_MPEG2_L3 0x0080
#define FMPF_AUD_DOLBY_AC3 0x0100

#define FMPF_AUD_WAVE 0x0010
#define FMPF_AUD_VOC 0x0020
#define FMPF_AUD_PCM 0x0040
#define FMPF_AUD_ADPCM 0x0080

#define FMPF_AUD_STEREO 0x0001
#define FMPF_AUD_JSTEREO 0x0002
#define FMPF_AUD_DUAL 0x0003
#define FMPF_AUD_SINGLE 0x0004

#define FMPF_AUD_NO_EMPH 0x0001
#define FMPF_AUD_EMPH_50 0x0002
#define FMPF_AUD_EMPH_J17 0x0003

#define FMPF_AUD_COPYRIGHT 0x0001
#define FMPF_AUD_ORIGINAL 0x0002

#define FMPF_GRP_UNKNOWN 0x0000
#define FMPF_GRP_MPEG 0x0001
#define FMPF_GRP_AVI 0x0002
#define FMPF_GRP_CUSTOM 0x0004
#define FMPF_GRP_MPEG2_PROGRAM 0x0008
#define FMPF_GRP_MPEG2_TRANSPORT 0x0010

#define FMPF_PIC_BMP 0x0001
#define FMPF_PIC_DIB24 0x0002
#define FMPF_PIC_TOFILE 0x0004

#define FMPF_REFUSE 0x0001
#define FMPF_IGNORE 0x0002


/*******************************************************************************
* FMP Index
*******************************************************************************/
#define FMPI_DRV_PRODUCT 0x0101
#define FMPI_DRV_VERSION 0x0102
#define FMPI_DRV_MAX_CHAN 0x0103
#define FMPI_DRV_VID_SUP 0x0104
#define FMPI_DRV_AUD_SUP 0x0105
#define FMPI_DRV_GRP_SUP 0x0106
#define FMPI_DRV_HDR_STAT 0x0107
#define FMPI_DRV_MEMORY 0x0108
#define FMPI_DRV_ID 0x0109
#define FMPI_DRV_CAPABILITY 0x010A

#define FMPI_STM_TYPE 0x0202
#define FMPI_STM_SOURCE 0x0203
#define FMPI_STM_MODE 0x0204
#define FMPI_STM_TIME_FMT 0x0205
#define FMPI_STM_POSITION 0x0206
#define FMPI_STM_SPEED 0x0207
#define FMPI_STM_USER 0x0208
#define FMPI_STM_SIZE 0x0209
#define FMPI_STM_SLIDE 0x020A
#define FMPI_STM_PASSWD 0x0210
#define FMPI_STM_FILETYPE 0x0211
#define FMPI_STM_MEMFLAGS 0x0212
#define FMPI_STM_FILESIZE 0x0213
#define FMPI_STM_FILEORG 0x0214
#define FMPI_STM_BIT_RATE 0x0215
#define FMPI_STM_NOCACHE 0x0216

#define FMPI_BUF_LEFT 0x0301
#define FMPI_BUF_POS 0x0302
#define FMPI_BUF_ADDRESS 0x0303
#define FMPI_BUF_SIZE 0x0304
#define FMPI_BUF_MODE 0x0305
#define FMPI_BUF_TOTALSIZE 0x0306

#define FMPI_VID_TYPE 0x0401
#define FMPI_VID_RATE 0x0402
#define FMPI_VID_SIZE 0x0403
#define FMPI_VID_ASPECT 0x0404
#define FMPI_VID_BIT_RATE 0x0405
#define FMPI_VID_SRC_POS 0x0406
#define FMPI_VID_SRC_SIZE 0x0407
#define FMPI_VID_DEST_POS 0x0408
#define FMPI_VID_DEST_SIZE 0x0409
#define FMPI_VID_KEY_MIN 0x040A
#define FMPI_VID_KEY_MAX 0x040B
#define FMPI_VID_KEY_MASK 0x040C
#define FMPI_VID_KEY_COL 0x040D
#define FMPI_VID_KEY_MODE 0x040E
#define FMPI_VID_KEY_TYPE 0x040F
#define FMPI_VID_CONTRAST 0x0410
#define FMPI_VID_BRIGHTNESS 0x0411
#define FMPI_VID_SATURATION 0x0412
#define FMPI_VID_SLIDE 0x0420
#define FMPI_VID_HWND 0x0413
#define FMPI_VID_KEY_COL_INDEX 0x0414

#define FMPI_VID_DEFAULTS 0x1000
#define FMPI_VID_REGISTRY 0x2000

#define FMPI_AUD_TYPE 0x0501
#define FMPI_AUD_RATE 0x0502
#define FMPI_AUD_VOLUME 0x0503
#define FMPI_AUD_BIT_RATE 0x0504
#define FMPI_AUD_TREBLE 0x0505
#define FMPI_AUD_BASS 0x0506
#define FMPI_AUD_CHANNELS 0x0507
#define FMPI_AUD_EMPH 0x0508
#define FMPI_AUD_RIGHTS 0x0509
#define FMPI_AUD_SHIFT 0x0510
#define FMPI_AUD_BAL_L 0x0511
#define FMPI_AUD_BAL_R 0x0512

#define FMPI_AUD_DEFAULTS 0x1000
#define FMPI_AUD_REGISTRY 0x2000

#define FMPI_GRP_TYPE 0x0601
#define FMPI_GRP_NB 0x0602

#define FMPI_FIFO_FCNTRL 0x0701
#define FMPI_FIFO_SIZE 0x0702
#define FMPI_FIFO_MAX 0x0703
#define FMPI_FIFO_VID_SIZE 0x0704
#define FMPI_FIFO_AUD_SIZE 0x0705
#define FMPI_FIFO_START 0x0706
#define FMPI_FIFO_LOW 0x0707
#define FMPI_FIFO_HIGH 0x0708
#define FMPI_FIFO_DROP 0x0709
#define FMPI_FIFO_UNIT 0x070A

#define FMPI_PUSH_ASYNC 0x0801
#define FMPI_PUSH_SYNC 0x0802

// Overlay specific settings (does not appky to rm 1 &amp;
2)
#define FMPI_OVLY_XOFFSET 0x0901
#define FMPI_OVLY_YOFFSET 0x0902
#define FMPI_OVLY_VGACORRECTION 0x0903
#define FMPI_OVLY_STABILITY 0x0904
#define FMPI_OVLY_HFREQUENCY 0x0905
#define FMPI_OVLY_USEDEFAULTFREQ 0x0906
#define FMPI_OVLY_COLOR_SETTING 0x0907
#define FMPI_OVLY_LOWERLEVEL 0x0908
#define FMPI_OVLY_UPPERLEVEL 0x0909
#define FMPI_OVLY_DELTA_CALIBRATE 0x090A
#define FMPI_OVLY_COLOR_CALIBRATION 0x090B
#define FMPI_OVLY_JITTERING 0x090C

// Hoolywood (IBM MPEG 2) specific settings
#define FMPI_OVLY_CROPLEFT 0x0B01
#define FMPI_OVLY_CROPTOP 0x0B02
#define FMPI_OVLY_CROPRIGHT 0x0B03
#define FMPI_OVLY_CROPBOTTOM 0x0B04
#define FMPI_OVLY_INDELAY 0x0B05
#define FMPI_OVLY_OUTDELAY 0x0B06

// Values used for developpment purpose only
#define FMPI_ADJUSTMENT_A 0x0F01
#define FMPI_ADJUSTMENT_B 0x0F02
#define FMPI_ADJUSTMENT_C 0x0F03
#define FMPI_ADJUSTMENT_D 0x0F04
#define FMPI_ADJUSTMENT_E 0x0F05
#define FMPI_ADJUSTMENT_F 0x0F06

#define FMPI_OVLY_DEFAULTS 0x1000
#define FMPI_OVLY_REGISTRY 0x2000
#define FMPI_OVLY_RESET 0x4000

#define FMPI_UPD_PALETTE 0x0001
#define FMPI_UPD_VGA_MODE 0x0007
#define FMPI_UPD_FRAME_POS 0x0008
#define FMPI_UPD_FRAME_SIZE 0x0009

/*******************************************************************************
* FMP Constants
*******************************************************************************/

#define FMP_MIN_AUD_VOLUME 0
#define FMP_MAX_AUD_VOLUME 100
#define FMP_DEF_AUD_VOLUME 50

#define FMP_MIN_BSC 0 // Brightness, Saturation &amp;
Contrast
#define FMP_MAX_BSC 1000
#define FMP_DEF_BSC 500

// REALmagic capabilities
#define FMP_CAPABILITY_BORDER_ADJUST 0x0001
#define FMP_CAPABILITY_KEYCOLOR_ADJUST 0x0002
#define FMP_CAPABILITY_BSC_ADJUST 0x0004 // Brightness, Saturation &amp;
contrast
#define FMP_CAPABILITY_AUTO_CALIBRATE 0x0008
#define FMP_CAPABILITY_SPECIFIC_ADJUST 0x0010
#define FMP_CAPABILITY_GAMMA_ADJUST 0x0020
#define FMP_CAPABILITY_HIRES 0x0040

// RGB values used for min. medium and max color calibration
#define FMP_MIN_COLOR_LEVEL 0x00000000
#define FMP_MEDIUM_COLOR_LEVEL 0x00808080
#define FMP_MAX_COLOR_LEVEL 0x00FFFFFF
#define FMP_MEDIUM_COLOR 0x80

#define FMP_LOWER_RED 0x01
#define FMP_LOWER_GREEN 0x02
#define FMP_LOWER_BLUE 0x04
#define FMP_UPPER_RED 0x10
#define FMP_UPPER_GREEN 0x20
#define FMP_UPPER_BLUE 0x40

// Max sizes for low resolution
#define FMP_MAX_LOW_RES_WIDTH 640
#define FMP_MAX_LOW_RES_HEIGHT 480

/*******************************************************************************
* FMP Structures
*******************************************************************************/

typedef struct {
LPTSTR lpFileName;
DWORD dwCallBack;
BYTE Reserved[8];
} FMP_OPEN_STRUCT;

typedef struct {
DWORD dwSize;
void* lpBuffer;
} FMP_PUSH_STRUCT;

typedef struct {
COLORREF RGBColorKey;
COLORREF RGBUpper;
COLORREF RGBLower;
USHORT Mask;
} FMP_COLOR_SETTING_STRUCT;

#endif /* __FMPDEFS_H__ */




FMPFCTW.C

/*******************************************************************************
*
* COPYRIGHT : (c) 1995-1996 Sigma Designs, Inc. All rights reserved.
*
* FILENAME : FMPFctw.c
*
* DESCRIPTION : This source file contains functions to interface with the
* FMP IMPEG32 support driver.
*
* PLATFORM : WIN32
*
* PROGRAMMER : MI
*
* COMMENTS : NONE
*
* NOTES : NONE
*
* CHANGES :
* 8/13/96 - Created.
* (MI)
*
*******************************************************************************/

#include <windows.h>
#include &quot;../../include/winfmp.h&quot;
#include &quot;../../include/FMPfctw.h&quot;

HDRVR hReelDrv;
// REALmagic driver handle


/*******************************************************************************
*
* FUNCTION : FMPOpenDriver()
*
* DESCRIPTION : Opens IMPEG32.DLL
*
* RETURN : non-zero if successful, 0 if failed.
*
* NOTES :
*
*******************************************************************************/
int FMPOpenDriver(void)
{
hReelDrv=OpenDriver(TEXT(&quot;Reeldrv&quot;),TEXT(&quot;Driver32&quot;),0L);
if( !hReelDrv) {
return 0;
}
return 1; // successfully opened driver
}

/*******************************************************************************
*
* FUNCTION : FMPCloseDriver()
*
* DESCRIPTION : Closes IMPEG32.DLL
*
* RETURN : NONE
*
* NOTES :
*
*******************************************************************************/
void FMPCloseDriver(void)
{
CloseDriver(hReelDrv,0L,0L);
hReelDrv = 0;
}

/*******************************************************************************
*
* FUNCTION : FMPCommand()
*
* DESCRIPTION : This function interfaces with the FMP MPEG support driver
* and sends out the requested command.
*
* RETURN : value from SendDriverMessage
*
* NOTES :
*
*******************************************************************************/
DWORD FMPCommand( BYTE Command, BYTE hMPEGStream, WORD Flags, DWORD Value )
{
return (DWORD)SendDriverMessage(hReelDrv,DRV_USER+1,
MAKELPARAM(MAKEWORD(Command,hMPEGStream),Flags),Value);
}

/*******************************************************************************
*
* FUNCTION : FMPGetLastError()
*
* DESCRIPTION : Returns last command error code.
*
* RETURN : last REALmagic command error code
*
* NOTES :
*
*******************************************************************************/
DWORD FMPGetLastError(WORD a)
{
return (DWORD)SendDriverMessage(hReelDrv,DRV_USER+2,(DWORD)a,0L);
}
 
// Copyright (c) Sigma Designs Inc. 1997. All Rights Reserved
//
// Here is one way to render a filter - I cannot say it it the best
// way or the only way. It's just an example.
// To use software, #define _USE_SOFTWARE_DECODER_, to use hardware
// just comment out the #define _USE_SOFTWARE_DECODER_.
//
// The way I choose hw or sw is that I assume that if I select a certain
// filter into the graph, and when I tell the filter graph manger to
// render the graph, it will first try the filters currently in the graph.
// I hope this assumption is correct. If it is not, then
you can always
// attach the pins manually.
//
// I also can not guarantee that this code is bug free...
//
// program usage: amtest <filename>
//
// Have fun.
//
// --
// Vincent.
#include &quot;precomp.h&quot;

//#define _USE_SOFTWARE_DECODER_

// The Sigma Designs MPEG1 hardware filter guid
#define DEFINE_MY_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) /
extern &quot;C&quot;
const GUID _cdecl name /
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }

DEFINE_MY_GUID(CLSID_SDMPEG1PacketPlayer,
0x65006770, 0xd9cf, 0x11cf, 0xa0, 0x36, 0x00, 0x00, 0x1b, 0x4e, 0xad, 0x07);

IFilterGraph *pFG = NULL; // interface to filter graph we are to build
IFilter *pAR = NULL; // interface to the async file reader
IFilter *pVC = NULL; // interface to sw audio codec
IFilter *pAC = NULL; // interface to sw video codec
IFilter *pSigma = NULL; // interface to sigma hardware
IMediaControl *pMC = NULL; // interface to control start the playback
IMediaEvent *pME = NULL; // interface to know when playback ends
IGraphBuilder *pBuilder = NULL; // interface to render the filter graph
IFileSourceFilter *pSourceFilter = NULL;
// interface to the source filter

//do
init and exit stuff here
class automatic_class
{
public:
automatic_class ()
{
CoInitialize (NULL);
};
~automatic_class ()
{
// release objects
if (pSourceFilter)
pSourceFilter->Release ();
if (pBuilder)
pBuilder->Release();
if (pSigma)
pSigma->Release ();
if (pVC)
pVC->Release ();
if (pAC)
pAC->Release ();
if (pAR)
pAR->Release ();
if (pFG)
pFG->Release ();
if (pME)
pME->Release ();
if (pMC)
pMC->Release ();

CoUninitialize ();
};
};

// main entry point
int WINAPI
WinMain (
IN HINSTANCE hInstance, // handle to current instance
IN HINSTANCE hPrevInstance, // handle to previous instance
IN LPSTR lpCmdLine, // pointer to command line
IN int nShowCmd // show state of window
)
{
// automatic class todo
init and clean-up
automatic_class ac;

HRESULT hr;

// create filter graph
hr = CoCreateInstance (
CLSID_FilterGraph,
NULL,
CLSCTX_INPROC,
IID_IFilterGraph,
(void**) &amp;pFG);
if (FAILED(hr))
return hr;

// create file source
hr = CoCreateInstance (
CLSID_AsyncReader,
NULL,
CLSCTX_INPROC,
IID_IFilter,
(void**) &amp;pAR);
if (FAILED(hr))
return hr;
// create sw video codec
hr = CoCreateInstance (
CLSID_CMpegVideoCodec,
NULL,
CLSCTX_INPROC,
IID_IFilter,
(void**) &amp;pVC);
if (FAILED(hr))
return hr;
// create sw audio codec
hr = CoCreateInstance (
CLSID_CMpegAudioCodec,
NULL,
CLSCTX_INPROC,
IID_IFilter,
(void**) &amp;pAC);
if (FAILED(hr))
return hr;
// create sigma hardware decoder
hr = CoCreateInstance (
CLSID_SDMPEG1PacketPlayer,
NULL,
CLSCTX_INPROC,
IID_IFilter,
(void**) &amp;pSigma);
if (FAILED(hr))
return hr;

// add filters to filter graph
hr = pFG->AddFilter (pAR, NULL); // always add file source
if (FAILED(hr))
return hr;

// render the graph
hr = pFG->QueryInterface (IID_IGraphBuilder, (void **)&amp;pBuilder);
if (FAILED(hr))
return hr;

// add filter(s)
#ifdef _USE_SOFTWARE_DECODER_
hr = pFG->AddFilter (pVC, NULL); // add sw to graph
if (FAILED(hr))
return hr;
hr = pFG->AddFilter (pAC, NULL);
if (FAILED(hr))
return hr;
#else

hr = pFG->AddFilter (pSigma, NULL); // add sigma hardware to graph
if (FAILED(hr))
return hr;
#endif

// setup the source filter
hr = pAR->QueryInterface (IID_IFileSourceFilter, (void**)&amp;pSourceFilter);
if (FAILED(hr))
return hr;
// hard code a filename
if ((lpCmdLine) &amp;&amp;
(strlen(lpCmdLine) != 0))
{
unsigned short szFile[256];
MultiByteToWideChar (GetACP(), 0, lpCmdLine, strlen(lpCmdLine)+1,
szFile, 256);
hr = pSourceFilter->Load (szFile, NULL);
}
else

hr = pSourceFilter->Load (L&quot;f://media//mpg//120min.mpg&quot;, NULL);
if (FAILED(hr))
return hr;
IPin *pPin = NULL;
IEnumPins *pEnumPins = NULL;
pAR->EnumPins (&amp;pEnumPins);
if (FAILED(hr))
return hr;
hr = pEnumPins->Reset ();
if (FAILED(hr))
return hr;
ULONG nPlaced = 0;
hr = pEnumPins->Next (1, &amp;pPin, &amp;nPlaced);
if (FAILED(hr))
return hr;
hr = pAR->FindPin (L&quot;Output&quot;, &amp;pPin);
if (FAILED(hr))
return hr;

hr = pBuilder->Render (pPin);
if (FAILED(hr))
return hr;

// play and wait for the graph to finish
hr = pFG->QueryInterface (IID_IMediaControl, (void **)&amp;pMC);
if (FAILED(hr))
return hr;

hr = pFG->QueryInterface (IID_IMediaEvent, (void **)&amp;pME);
if (FAILED(hr))
return hr;
OAEVENT oEvent;
hr = pME->GetEventHandle(&amp;oEvent);
if (SUCCEEDED(hr))
{
hr = pMC->Run();
}
if (SUCCEEDED(hr))
{
LONG levCode;
hr = pME->WaitForCompletion(INFINITE, &amp;levCode);
}

return hr;
}
 
以上这些,是我收集的一些关于神龙卡调用的源代码分散文件 不知道该怎样 在Delphi里拼凑起来 望老师给点提示
 
后退
顶部