Home » Source Code » PMCAM2_2.50_Delphi_Source_Code » UnitMDInterface.pas

UnitMDInterface.pas ( File view )

  • By sathex 2016-03-20
  • View(s):0
  • Download(s):0
  • Point(s): 1
			unit UnitMDInterface;

interface
uses Windows,Sysutils,UMDDefs,Forms,Messages,UnitTimer,
     UDVBCoreToMD,Classes,SyncObjs,DateUtils;

const SWW_HPARENT = -8;
const MAX_CLASS=20-1;
const MAX_FILTERS=7;

const PMCAM_MSG_ONCHANNELCHANGE = 128;

{
$define NOTLOGAPI
}
type TMDRegisteredClass=record
    ClassPointer: TObject;
    Events: TMultiDecPlugInEvents;
end;

Type TMemBuffer=Class(TObject)
  private
    mvarDataInBuffer: DWORD;
    mvarBufferSize: DWORD;
    mvarOffSet: DWORD;
    mvarBuffer: PBYTEARRAY;
    mvarProcessedData: DWORD;
    mvarMAXBufferSize: DWORD;
    mvarBufferMustBeResetted: Boolean;
    function NextBlock(var Filter: integer;var P: Pointer; var Len: DWORD): Boolean;
    function GetLengthDataPending: DWORD;
  public
    procedure RemoveFilterData(Filter: integer);
    function AddToBuffer(Filter: integer;Buffer: Pointer;Len: DWORD): Boolean;
    property LengthDataPending: DWORD read GetLengthDataPending;
    procedure BufferReset;
    Constructor Create;
    Destructor Destroy; override;
end;

type TFiltersThread=Class(TThread)
    Buffer: TMemBuffer;
    Crit: TCriticalSection;
  private
    function GetLengthDataInBuffer: DWORD;
  public
    property LengthDataInBuffer: DWORD read GetLengthDataInBuffer;
    procedure AddToBuffer(Filter: integer;P: Pointer;Len: integer);
    procedure Execute; override;
    procedure RemoveFilterData(Filter: integer);
    procedure ResetBuffer;
    Constructor Create(Suspended: Boolean);
    Destructor Destroy; override;
end;

type MDAPI_PLUGIN_SYSTEM=(MDAPI_MULTIDEC,MDAPI_DVBCORE);

{
$ifdef LOGAPI
}
    procedure SendToLog(Text: string);
{
$endif
}

{
Class interface
}
type TMultiDecPlugIn=class(TObject)
  Private
    mvarBUGinIRQ: Boolean;
    mvarRegisteredClass: Array [0..MAX_CLASS] of TMDRegisteredClass;
    procedure SetDockedWindows(const Value: Boolean);
    function GetFiltersBufferPending: DWORD;
    function GetFilterName(const index: integer): string;
    function GetFilterTransferredData(const index: integer): int64;
{
$HINTS OFF
}
    function GetFilterTransferredDataFromHandle(const FilterHandle: integer): int64;
{
$HINTS ON
}
    function GetFilterElapsedSinceLastReceive(const FilterHandle: integer): DWORD;
  Protected
    mvarMDInstance: THANDLE;
    mvarMDWnd: HWND;
    mvarLog_Set: Boolean;
    mvarDLL_ID: integer;
    mvarAPI_Version: string;
    mvarDLLIDName: String;
    mvarHotKey: char;
    mvarDockedWindows: Boolean;
    mvarPlugInFolder: string;
    mvarPlugInFile: string;
    mvarPluginSystem: MDAPI_PLUGIN_SYSTEM;
    mvarFilterThread: TFiltersThread;
    function GetFreeFilterID(): WORD;
    procedure UnRegisterAllClass();
  Public
    property Instance: THANDLE read mvarMDInstance;
    property WindowHandle: HWND read mvarMDWnd;
    property FiltersBufferPending: DWORD read GetFiltersBufferPending;
    property DLL_ID: integer read mvarDLL_ID;
    property DLLName: string read mvarDLLIDName write mvarDLLIDName;
    property HotKey: char read mvarHotKey write mvarHotKey;
    property DockedWindows: Boolean read mvarDockedWindows write SetDockedWindows;
    property PlugInFolder: string read mvarPlugInFolder;
    property APIVersion: string read mvarAPI_Version;
    property PlugInFile: string read mvarPlugInFile;
    property PlugInSystem: MDAPI_PLUGIN_SYSTEM read mvarPluginSystem write mvarPluginSystem;
    property FilterName[const index: integer]: string read GetFilterName;
    property FilterTransferredData[const index: integer]: int64 read GetFilterTransferredData;
    property FilterTransferredDataFromHandle[const FilterHandle: integer]: int64 read GetFilterTransferredData;
    property FilterElapsedSinceLastReceive[const FilterHandle: integer]: DWORD read GetFilterElapsedSinceLastReceive;

    procedure RegisterClass(Sender: TObject; Events: TMultiDecPlugInEvents);
    procedure UnRegisterClass(Sender: TObject);

    procedure On_Start( MDInstance:THANDLE;MDWnd: HWND;Log_Set: Boolean;
                    DLL_ID: integer;My_Hot_Key: PChar;Api_Version: PChar;
                    Keep_me_running: PINTEGER);
    procedure On_Exit(MDInstance: THANDLE;MDWnd: HWND;Log_Set: Boolean);
    procedure On_Menu_Select(MenuID: DWORD);
    procedure On_Hot_Key();
    procedure On_Channel_Change(CurrentProgramm: TMDProgram82 );
    procedure On_Filter_Close(FilterOffset: DWORD);
    procedure On_Send_Dll_ID_Name(const Name: PChar);
    procedure On_Rec_Play(Mode: TMDRecPlay);
    procedure On_Osd_Key(Key: BYTE);
    procedure On_FilterData(FilterHandle: integer; FilterData: PBYTEARRAY; DataLength: integer);

    function StartFilter(PID: WORD; FilterType: integer; Name: String): integer;
    procedure StopFilter(FilterHandle: integer; Inmediate: Boolean);
    function GetFilterRunningTime(FilterHandle: integer): DWORD;
    procedure StopAllFilters(Inmediate:Boolean);
    Function GetCurrentDecryptWordsPointer(): PBYTEARRAY;
    function SetProgram(Programm: PMDProgram82): Boolean;

    Constructor Create;
    Destructor Destroy; override;
end;

var
    MD: TMultiDecPlugIn=nil;
{
$ifdef LOGAPI
}
    FLog: integer;
{
$endif
}

implementation

type TFilterObjects=record
    MD: TMultiDecPlugIn;
    RunningID: integer;
    Timer: TFineTimer;
    ReceivedData: DWORD;
    LastTimeStamp: DWORD;
    Name: string;
end;

var
    FilterObjects: Array [0..MAX_FILTERS] of TFilterObjects;

constructor TMultiDecPlugIn.Create;
begin
{
$ifdef LOGAPI
}
    FLog:=0;
    if not FileExists('API_LOG.log') then begin
        Flog:=FileCreate('API_LOG.log');
    end else begin
        FLog:=FileOpen('API_LOG.log',fmOpenReadWrite or fmShareDenyNone);
        FileSeek(FLog,0,2);
    end;
    SendToLog('Starting....');
{
$endif
}
    mvarFilterThread:=TFiltersThread.Create(true);
    UnRegisterAllClass;
    mvarDockedWindows:=true;
    SetLength(mvarPlugInFolder,260);
    SetLength(mvarPlugInFolder,GetModuleFileName(HInstance,pchar(mvarPlugInFolder),260));
    mvarPlugInFile:=mvarPlugInFolder;
    mvarPlugInFolder:=ExtractFilePath(mvarPlugInFolder);
    mvarBUGinIRQ:=false;
    mvarPluginSystem:=MDAPI_MULTIDEC; //Default value;
end;

destructor TMultiDecPlugIn.Destroy;
begin
{
$ifdef LOGAPI
}
    SendToLog('Closing system...');
{
$endif
}
    mvarFilterThread.Terminate;
    if mvarFilterThread.Suspended Then begin
        mvarFilterThread.Resume;
    end;
    mvarFilterThread.WaitFor;
    mvarFilterThread.Free;
    mvarFilterThread:=nil;
{
$ifdef LOGAPI
}
    if Flog<>0 Then FileClose(FLog);
{
$endif
}
    UnRegisterAllClass;
    inherited;
end;

{
MultidecPlugin class
}
procedure TMultiDecPlugIn.On_Start(MDInstance: THANDLE; MDWnd: HWND;
  Log_Set: Boolean; DLL_ID: integer; My_Hot_Key, Api_Version: PChar;
  Keep_me_running: PINTEGER);
var
    i: integer;
    N: TMDOnStart;
    MyHotKey: Char;
    KeepMeRunning: integer;
    VersionTXT: array [0..255] of char;
begin
{
$ifdef LOGAPI
}
    SendToLog('OnStart enter');
{
$endif
}
    Keep_me_running^:=0;
    mvarMDInstance:=MDInstance;
    mvarMDWnd:=MDWnd;
    mvarLog_Set:=Log_Set;
    mvarDLL_ID:=DLL_ID;
    mvarAPI_Version:=Api_Version;

    SendMessage(MDWnd,WM_USER,MDAPI_GET_VERSION,Integer(@VersionTXT[0]));

    MyHotKey:=My_Hot_Key^;
    KeepMeRunning:=Keep_Me_Running^;
    for i := 0 to MAX_CLASS do begin
        N:=mvarRegisteredClass[i].Events.OnStart;
        if Assigned(N) Then begin
            if Assigned(mvarRegisteredClass[i].ClassPointer) Then begin
{
*                if mvarDockedWindows Then begin
                    SetWindowLong(TForm(mvarRegisteredClass[i].ClassPointer).Handle, GWL_HWNDPARENT, mvarMDWnd);
                end;*
}
            end;
            N(MDInstance,MDWnd,Log_Set,DLL_ID,@MyHotKey,API_Version,@KeepMeRunning);
            if KeepMeRunning=0 Then begin
                Keep_me_running^:=0;
            end;
        end;
    end;
    My_Hot_Key^:=MyHotKey;
{
$ifdef LOGAPI
}
    SendToLog('OnStart exit');
{
$endif
}
end;

procedure TMultiDecPlugIn.On_Channel_Change(CurrentProgramm: TMDProgram82);
var i:integer;
    N:TMDOnChannelChange;
    P: Pointer;
begin
{
$ifdef LOGAPI
}
    SendToLog('OnChannelChange enter');
{
$endif
}
    for i := 0 to MAX_CLASS do begin
        N:=mvarRegisteredClass[i].Events.OnChannelChange;
        if Assigned(N) Then begin
            GetMem(P,Sizeof(CurrentProgramm));
            MoveMemory(P,@CurrentProgramm,Sizeof(CurrentProgramm));
            SendMessage(TForm(mvarRegisteredClass[i].ClassPointer).Handle,WM_USER,PMCAM_MSG_ONCHANNELCHANGE,DWORD(P));
//            N(CurrentProgramm);
        end;
    end;
{
$ifdef LOGAPI
}
    SendToLog('OnChannelChange exit');
{
$endif
}
end;

procedure TMultiDecPlugIn.On_Exit(MDInstance: THANDLE; MDWnd: HWND;
  Log_Set: Boolean);
var i:integer;
    N:TMDOnExit;
begin
{
$ifdef LOGAPI
}
    SendToLog('OnExit enter');
{
$endif
}
    for i := 0 to MAX_CLASS do begin
        N:=mvarRegisteredClass[i].Events.OnExit;
        if Assigned(N) Then begin
            N(MDInstance,MDWnd,Log_Set);
        end;
    end;
{
$ifdef LOGAPI
}
    SendToLog('OnExit exit');
{
$endif
}
end;

procedure TMultiDecPlugIn.On_Filter_Close(FilterOffset: DWORD);
var i:integer;
    N:TMDOnFilterClose;
begin
{
$ifdef LOGAPI
}
    SendToLog('OnFilterClose enter '+inttostr(FilterOffSet));
{
$endif
}
    for i := 0 to MAX_CLASS do begin
        N:=mvarRegisteredClass[i].Events.OnFilterClose;
        if Assigned(N) Then begin
{
$ifdef LOGAPI
}
            SendToLog('Closed filter '+inttostr(FilterOffSet)+' '+FilterObjects[FilterOffSet].Name);
{
$endif
}
            N(FilterOffSet);
        end;
    end;
{
$ifdef LOGAPI
}
    SendToLog('OnFilterClose exit');
{
$endif
}
end;

procedure TMultiDecPlugIn.On_Hot_Key;
var i:integer;
    N:TMDOnHotKey;
begin
    for i := 0 to MAX_CLASS do begin
        N:=mvarRegisteredClass[i].Events.OnHotKey;
        if Assigned(N) Then begin
            N;
        end;
    end;
end;

procedure TMultiDecPlugIn.On_Menu_Select(MenuID: DWORD);
var i:integer;
    N:TMDOnMenuSelect;
begin
    for i := 0 to MAX_CLASS d
...
...
(Not finished, please download and read the complete file)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
About.rtf20.49 kB2005-03-15|17:16
changelog.txt4.26 kB2005-03-15|17:16
clean.bat92.00 B2005-01-05|02:35
DVBCore.pas31.98 kB2004-12-17|23:45
frmPPVInfo.dfm15.69 kB2004-12-19|19:54
frmPPVInfo.pas6.17 kB2005-03-03|01:02
01.96 kB
About.bmp3.05 kB2004-12-17|23:52
About.ico2.40 kB2004-12-17|23:52
Add.bmp1.30 kB2004-12-17|23:52
bluenote.ico7.23 kB2004-12-17|23:52
bug.jpg6.04 kB2005-01-05|02:35
CAM.ico2.40 kB2004-12-17|23:52
Close.bmp3.05 kB2004-12-17|23:52
EPG.bmp1.05 kB2005-01-05|21:10
EPG.ico1.37 kB2004-12-17|23:52
EPGOFF.bmp1.62 kB2004-12-17|23:52
EPGON.bmp1.62 kB2004-12-17|23:52
EPG_Gliph.bmp3.43 kB2004-12-17|23:52
Event.ico1.37 kB2004-12-17|23:52
jetons.ico1.37 kB2004-12-17|23:52
leftLogo.bmp9.96 kB2004-12-17|23:52
logger.ico1.68 kB2004-12-17|23:52
MagicWand.bmp1.30 kB2004-12-17|23:52
MagicWand.ico1.37 kB2004-12-17|23:52
MAS.ico1.37 kB2004-12-17|23:52
MENOS.ico1.37 kB2004-12-17|23:52
nemesis.ico4.19 kB2004-12-17|23:52
Phoenix.ico1.72 kB2004-12-17|23:52
Provider.ico1.37 kB2004-12-17|23:52
Remove.bmp1.30 kB2004-12-17|23:52
Reset.bmp3.05 kB2004-12-17|23:52
Restart.bmp1.30 kB2004-12-17|23:52
Save.bmp2.05 kB2004-12-17|23:52
scriptengine.ico7.23 kB2004-12-17|23:52
ScriptsEngine.bmp6.80 kB2004-12-17|23:52
Tools.bmp246.00 B2004-12-17|23:52
tuxprogramming.jpg4.15 kB2005-01-13|19:01
V9Card.jpg11.00 kB2005-03-03|01:02
IFSI_IniFiles.pas10.45 kB2004-12-19|19:54
MpgLib.DLL141.50 kB2004-12-24|17:03
PMCAM0.00 B2005-03-15|17:18
PMCAM4.67 kB2005-01-05|17:24
PMCAM4.69 kB2005-01-05|17:24
PMCAM4.52 kB2005-01-05|17:24
PMCAM.rc3.60 kB2004-12-17|23:47
PMCAM2.dpr6.30 kB2005-03-11|20:15
PMCAM2.res1.70 kB2005-03-15|17:16
PMCAM2StandAlone.dpr1.19 kB2005-03-03|01:02
PMCAM2StandAlone.res4.95 kB2005-03-11|20:15
PMCAMMenu.rc259.00 B2004-12-26|20:10
PMCAMMenu.RES162.25 kB2005-03-15|17:16
rUPClickSplitter.res740.00 B2004-12-19|19:54
santa_rock.jpg5.65 kB2004-12-24|17:59
UBitManager.pas4.18 kB2004-12-17|23:45
uDecode123.pas4.01 kB2004-12-29|01:33
UDVBConditionalAccessSystemNames.pas1.49 kB2004-12-17|23:45
UDVBCoreToMD.pas4.59 kB2004-12-17|23:45
UDVBPIDNames.pas1.23 kB2004-12-17|23:45
UDVBTablesHolder.pas2.68 kB2004-12-28|02:17
UEPGEntry.pas3.29 kB2004-12-17|23:45
UEPGMHW.dfm7.72 kB2005-01-11|02:38
UEPGMHW.pas40.85 kB2005-01-11|02:38
UfrmAddFilter.dfm6.86 kB2004-12-17|23:46
UfrmAddFilter.pas3.68 kB2004-12-17|23:45
UfrmCAM.dfm217.00 kB2005-03-15|03:22
UfrmCAM.pas159.37 kB2005-03-15|17:16
ufrmDLLForm.dfm420.00 B2004-12-19|19:54
ufrmDLLForm.pas1.87 kB2004-12-26|20:10
UfrmEMM.dfm1.28 kB2004-12-17|23:46
UfrmEMM.pas1.47 kB2004-12-17|23:45
UfrmEPGAdvanced.dfm7.01 kB2005-01-05|21:10
UfrmEPGAdvanced.pas2.56 kB2005-01-05|21:10
UfrmMHWEPGEntries.dfm3.81 kB2004-12-17|23:46
UfrmMHWEPGEntries.pas4.33 kB2004-12-17|23:45
ufrmMHWRadio.dfm35.85 kB2005-01-21|18:53
ufrmMHWRadio.pas37.84 kB2005-01-21|18:53
UfrmPMTDetails.dfm2.31 kB2005-01-21|18:53
UfrmPMTDetails.pas2.74 kB2005-01-21|18:53
UfrmWarningOnExit.dfm15.64 kB2005-01-05|21:10
UfrmWarningOnExit.pas1.44 kB2005-01-05|21:10
ULogEngine.pas15.89 kB2005-03-12|17:11
UMDDefs.pas4.07 kB2005-03-03|01:02
UMD_Impl.pas11.26 kB2005-03-03|01:02
United32.pas14.20 kB2004-12-17|23:45
UnitISO639_3.pas10.04 kB2005-03-03|01:02
UnitMDInterface.pas28.92 kB2005-03-15|03:22
UnitTimer.pas1.39 kB2004-12-17|23:45
Unit_CRC32.pas3.62 kB2004-12-17|23:45
uPESToTS.pas6.11 kB2005-03-03|01:02
UScriptFunctions.pas2.97 kB2005-01-03|16:45
UScriptsEditor.dfm58.10 kB2005-01-21|18:53
UScriptsEditor.pas22.02 kB2005-03-03|01:02
USECAManager.pas18.26 kB2005-03-03|01:02
USECATableStore.pas12.92 kB2004-12-17|23:45
USECA_EMM.pas7.74 kB2005-03-12|03:36
USmartCardISO.pas14.45 kB2004-12-17|23:45
UTfrmMultiDec.dfm407.00 B2005-01-21|18:53
UTfrmMultiDec.pas4.38 kB2005-01-21|18:53
UTranslate.pas6.49 kB2004-12-24|17:03
UTS184ToBitFilter.pas36.28 kB2005-03-11|20:15
uUPClickSplitter.dcr488.00 B2004-12-19|19:54
uUPClickSplitter.dcu18.09 kB2005-03-03|01:02
uUPClickSplitter.pas20.43 kB2004-12-26|20:10
PMCAM2_2.50.zip870.87 kB2016-03-19|22:08
...
Sponsored links

UnitMDInterface.pas (1.30 MB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D