Stream-Filter Types

Module API help / support section for programmers.

Moderators: Dreamer, FredB, X05

alexi
Just can't stay away
Posts: 31
Joined: Mon Jul 26, 2010 9:55 am

Stream-Filter Types

Postby alexi » Mon Jul 26, 2010 10:08 am

Hi!

in DVBDreamModuleSDKv17 in DreamSDK\Include\ModuleAPI.pas are Stream-Filter Types:

FT_SECTION = $03; {Section filter, allows bit masks for filtering by header}

FT_SECTION_BUFFER = $04; {Same as above but it doesn't call a callback, fills
a buffer instead. Runs once. In other words, automatically stopped after
one section buffered}


How to use it?
where are Definitions of bit masks?
Is anywhere a Program Example (*.pas)?

TIA, Alexi

User avatar
rel
relocation
Posts: 2051
Joined: Fri Jun 16, 2006 9:50 am

Postby rel » Mon Aug 02, 2010 11:43 am

Hi,
if you know the structure of PSI tables, this code piece should give you all the answers.

Bit masks - you should define yourself according to the exact PSI table you want.

AddSectionFilter(): you pass a buffer (maximum length of a PSI table specified, and only once gets the section)
AddSectionProc(): you pass a callback function (to continuously get the sections)


Code: Select all

////////////////////////////////////////////////////////////////////////////////
// AddSectionFilter: Starts a section filter using TableID interval and PID
////////////////////////////////////////////////////////////////////////////////
function AddSectionFilter(wPid: WORD; FilterTableID: BYTE; FilterSID: WORD; lpBuf, lpLen: Pointer; SectionNo: Integer; pDesc: PChar): DWORD;
var
fp: TStartFilterParams;
i: Integer;
str: string;
begin
ZeroMemory(@fp, sizeof(fp));
fp.dwSize := sizeof(TStartFilterParams);
fp.wFilterType := FT_SECTION_BUFFER;
fp.wPID := wPid;
fp.dwHookProc := nil;
fp.FilterTableID_Min := FilterTableID;
fp.FilterTableID_Max := FilterTableID;

for i := 0 to 13 do
fp.FilterMask[i] := 0;

if FilterSID <> 0 then
begin
fp.FilterMask[3] := $ff;
fp.FilterMask[4] := $ff;
fp.FilterData[3] := (FilterSID shr 8) and $ff;
fp.FilterData[4] := FilterSID and $ff;
end;

if SectionNo <> -1 then
begin
fp.FilterMask[6] := $ff;
fp.FilterData[6] := SectionNo;
end;

fp.FilterLength := 7; // use section header mask
fp.lpBuf := lpBuf;
fp.lpLen := lpLen;


SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_START_FILTER, Integer(@fp));
result := fp.dwHandle;
end;



////////////////////////////////////////////////////////////////////////////////
// DelSectionFilter: Removes specified section filter
////////////////////////////////////////////////////////////////////////////////
procedure DelSectionFilter(dwHandle: DWORD);
begin
// AddVerboseF('DelSectionFilter HANDLE:%d', [dwHandle]);
if dwHandle <> INVALID_FILTER_HANDLE then
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_STOP_FILTER, dwHandle);
end;




////////////////////////////////////////////////////////////////////////////////
// AddSectionProc: Starts a section filter using TableID interval and PID
////////////////////////////////////////////////////////////////////////////////
function AddSectionProc(wPid: WORD; FilterTableID_min, FilterTableID_max: BYTE; FilterSID: WORD; lpProc: Pointer; SectionNo: Integer; pDesc: PChar): DWORD;
var
fp: TStartFilterParams;
i: Integer;
str: string;
begin
ZeroMemory(@fp, sizeof(fp));
fp.dwSize := sizeof(TStartFilterParams);
fp.wFilterType := FT_SECTION;
fp.wPID := wPid;
fp.dwHookProc := lpProc;
fp.FilterTableID_Min := FilterTableID_min;
fp.FilterTableID_Max := FilterTableID_max;

for i := 0 to 13 do
fp.FilterMask[i] := 0;

if FilterSID <> 0 then
begin
fp.FilterMask[3] := $ff;
fp.FilterMask[4] := $ff;
fp.FilterData[3] := (FilterSID shr 8) and $ff;
fp.FilterData[4] := FilterSID and $ff;
end;

if SectionNo <> -1 then
begin
fp.FilterMask[6] := $ff;
fp.FilterData[6] := SectionNo;
end;

fp.FilterLength := 7; // use section header mask
fp.lpBuf := nil;
fp.lpLen := nil;
str:= 'PSI Parser - ' + string(pDesc);
StrPLCopy(@fp.Description, str, sizeof(fp.Description));

SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_START_FILTER, Integer(@fp));
result := fp.dwHandle;
end;

////////////////////////////////////////////////////////////////////////////////
// DelSectionProc: Removes specified section filter
////////////////////////////////////////////////////////////////////////////////
procedure DelSectionProc(dwHandle: DWORD);
begin
// AddVerboseF('DelSectionProc HANDLE:%d', [dwHandle]);
if dwHandle <> INVALID_FILTER_HANDLE then
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_STOP_FILTER, dwHandle);
end;
DVB Dream - because I have to dream about having time to code it

Return to “Module / Plugin Programming”

Who is online

Users browsing this forum: No registered users and 1 guest