uses DirectShow,
ActiveX;
function GetOutputPin(
const BF: IBaseFilter): IPin;
var
EP: IEnumPins;
PD: PIN_DIRECTION;
begin
if BF.EnumPins(EP) = S_OK
then
begin
while (EP.Next(1, Result,
nil) = S_OK)
do
begin
if (Result.QueryDirection(PD) = S_OK)
and (PD = PINDIR_OUTPUT)
then
Exit;
Result :=
nil;
end;
end;
end;
function FindAudioSwith(
const FG: IFilterGraph): IBaseFilter;
var
EF: IEnumFilters;
Pin: IPin;
SS: IAMStreamSelect;
SCount: Cardinal;
MT: TAMMediaType;
begin
if FG.EnumFilters(EF) = S_OK
then
begin
while (EF.Next(1, Result,
nil) = S_OK)
do
begin
if Result.QueryInterface(IID_IAMStreamSelect, SS) = S_OK
then
begin
if (SS.Count(SCount) = S_OK)
and (SCount > 1)
then
begin
Pin := GetOutputPin(Result);
if Assigned(Pin)
and (Pin.ConnectionMediaType(MT) = S_OK)
then
begin
if IsEqualGUID(MT.majortype, MEDIATYPE_AnalogAudio)
or
IsEqualGUID(MT.majortype, MEDIATYPE_Audio)
then
Exit;
end;
end;
end;
Result :=
nil;
end;
end else
Result :=
nil;
end;
procedure SetAudioStream(
const FilterGraph: IFilterGraph;
const Index: Integer);
var
BF: IBaseFilter;
SS: IAMStreamSelect;
begin
BF := FindAudioSwith(FilterGraph);
if Assigned(BF)
then
begin
if BF.QueryInterface(IID_IAMStreamSelect, SS) = S_OK
then
begin
SS.Enable(
Index, AMSTREAMSELECTENABLE_ENABLE);
// Evtl. Fehlerabfrage einfügen
end;
end;
end;