亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uasyncrdr.pas

?? 一套及時通訊的原碼
?? PAS
字號:
//------------------------------------------------------------------------------
// File: UAsyncRdr.pas
// Original files: asyncrdr.h, asyncrdr.c
//
// Desc: Defines an IO source filter.
//
// This filter (CAsyncReader) supports IBaseFilter and IFileSourceFilter interfaces from the
// filter object itself. It has a single output pin (CAsyncOutputPin)
// which supports IPin and IAsyncReader.
//
// This filter is essentially a wrapper for the CAsyncFile class that does
// all the work.
//
//
// Portions created by Microsoft are
// Copyright (c) 2000-2002  Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------------------------
unit UAsyncRdr;

interface
uses
  BaseClass, DirectShow9, DSUtil, ActiveX, Windows, SysUtils,
  UAsyncIo;

const
  CLSID_AsyncSample: TGUID = '{10F9E8F1-FE54-470C-9F1A-FE587DF7BD0B}';

type
  // the filter class (defined below)
  TBCAsyncReader = class;

  // the output pin class
  TBCAsyncOutputPin = class(TBCBasePin, IAsyncReader)
  protected
    FReader: TBCAsyncReader;
    FIo: TBCAsyncIo;

    //  This is set every time we're asked to return an IAsyncReader
    //  interface
    //  This allows us to know if the downstream pin can use
    //  this transport, otherwise we can hook up to thinks like the
    //  dump filter and nothing happens
    FQueriedForAsyncReader: Boolean;

    function InitAllocator(out AAlloc: IMemAllocator): HRESULT; virtual;

  public
    // constructor and destructor
    constructor Create(out hr: HResult; Reader: TBCAsyncReader;
      IO: TBCAsyncIo; Lock: TBCCritSec);

    destructor Destroy; override;

    // --- CUnknown ---

    // need to expose IAsyncReader
    function NonDelegatingQueryInterface(const IID: TGUID;
      out Obj): HResult; override; stdcall;

    // --- IPin methods ---
    function Connect(AReceivePin: IPin;
      const pmt: PAMMediaType): HResult; reintroduce; stdcall;

    // --- CBasePin methods ---

    // return the types we prefer - this will return the known
    // file type
    function GetMediaType(Position: Integer;
      out MediaType: PAMMediaType): HResult; override;

    // can we support this type?
    function CheckMediaType(AType: PAMMediaType): HResult; override;

    // Clear the flag so we see if IAsyncReader is queried for
    function CheckConnect(Pin: IPin): HResult; override;

    // See if it was asked for
    function CompleteConnect(ReceivePin: IPin): HResult; override;

    //  Remove our connection status
    function BreakConnect: HResult; override;

    // --- IAsyncReader methods ---
    // pass in your preferred allocator and your preferred properties.
    // method returns the actual allocator to be used. Call GetProperties
    // on returned allocator to learn alignment and prefix etc chosen.
    // this allocator will be not be committed and decommitted by
    // the async reader, only by the consumer.
    function RequestAllocator(APreferred: IMemAllocator;
        AProps: PAllocatorProperties;
        out AActual: IMemAllocator): HResult; stdcall;

    // queue a request for data.
    // media sample start and stop times contain the requested absolute
    // byte position (start inclusive, stop exclusive).
    // may fail if sample not obtained from agreed allocator.
    // may fail if start/stop position does not match agreed alignment.
    // samples allocated from source pin's allocator may fail
    // GetPointer until after returning from WaitForNext.
    function Request(ASample: IMediaSample; AUser: DWord): HResult; stdcall;

    // block until the next sample is completed or the timeout occurs.
    // timeout (millisecs) may be 0 or INFINITE. Samples may not
    // be delivered in order. If there is a read error of any sort, a
    // notification will already have been sent by the source filter,
    // and STDMETHODIMP will be an error.
    function WaitForNext(ATimeout: DWord; out ASample: IMediaSample;
        out AUser: DWord): HResult; stdcall;

    // sync read of data. Sample passed in must have been acquired from
    // the agreed allocator. Start and stop position must be aligned.
    // equivalent to a Request/WaitForNext pair, but may avoid the
    // need for a thread on the source filter.
    function SyncReadAligned(ASample: IMediaSample): HResult; stdcall;


    // sync read. works in stopped state as well as run state.
    // need not be aligned. Will fail if read is beyond actual total
    // length.
    function SyncRead(APosition: int64; ALength: Longint;
      ABuffer: PByte): HResult; stdcall;

    // return total length of stream, and currently available length.
    // reads for beyond the available length but within the total length will
    // normally succeed but may block for a long period.
    function Length(out ATotal, AAvailable: int64): HResult; stdcall;

    // cause all outstanding reads to return, possibly with a failure code
    // (VFW_E_TIMEOUT) indicating they were cancelled.
    // these are defined on IAsyncReader and IPin
    function BeginFlush: HResult; override;
    function EndFlush: HResult; override;
  end;

  //
  // The filter object itself. Supports IBaseFilter through
  // CBaseFilter and also IFileSourceFilter directly in this object

  TBCAsyncReader = class(TBCBaseFilter)
  protected
    // filter-wide lock
    FCSFilter: TBCCritSec;

    // all i/o done here
    FIO: TBCAsyncIo;

    // our output pin
    FOutputPin: TBCAsyncOutputPin;

    // Type we think our data is
    Fmt: TAMMediaType;

  public

    // construction / destruction
    constructor Create(Name: String; Unk: IUnknown;
      Stream: TBCAsyncStream; out hr: HResult);

    destructor Destroy; override;


    // --- CBaseFilter methods ---
    function GetPinCount: Integer; override;
    function GetPin(n: Integer): TBCBasePin; override;

    // --- Access our media type
    function LoadType: PAMMediaType; virtual;

    function Connect(pReceivePin: IPin;
      const pmt: PAMMediaType): HRESULT; virtual;
  end;


implementation

// --- TBCCAsyncReader ---

constructor TBCAsyncReader.Create(Name: String; Unk: IUnknown;
  Stream: TBCAsyncStream; out hr: HResult);
begin
  FCSFilter := TBCCritSec.Create;
  ZeroMemory(@Fmt, SizeOf(TAMMediaType));

  Inherited Create(Name, Unk, FCSFilter, CLSID_AsyncSample, hr);
  FIO := TBCAsyncIo.Create(Stream);
  FOutputPin := TBCAsyncOutputPin.Create(hr, Self, FIO, FCSFilter);
end;

destructor TBCAsyncReader.Destroy;
begin
  Inherited;

  // FCSFilter is destroyed by parent class
end;

function TBCAsyncReader.GetPinCount: Integer;
begin
  Result := 1;
end;

function TBCAsyncReader.GetPin(n: Integer): TBCBasePin;
begin
  if ((GetPinCount > 0) and (n = 0)) then
    Result := FOutputPin
  else
    Result := nil;
end;

function TBCAsyncReader.LoadType: PAMMediaType;
begin
  Result := @Fmt;
end;

function TBCAsyncReader.Connect(pReceivePin: IPin;
  const pmt: PAMMediaType): HRESULT;
begin
  Result := FOutputPin.Connect(pReceivePin, pmt);
end;

// --- TBCAsyncOutputPin ---

constructor TBCAsyncOutputPin.Create(out hr: HResult; Reader: TBCAsyncReader;
  IO: TBCAsyncIo; Lock: TBCCritSec);
begin
  Inherited Create('Async output pin', Reader, Lock, hr, 'Output',
    PINDIR_OUTPUT);
  FReader := Reader;
  FIO := IO;
end;

destructor TBCAsyncOutputPin.Destroy;
begin
  Inherited;
end;

function TBCAsyncOutputPin.InitAllocator(out AAlloc: IMemAllocator): HRESULT;
begin
  // Create a default memory allocator
  Result := CreateMemoryAllocator(AAlloc);
  if Failed(Result) then
    Exit;

  if (AAlloc = nil) then
  begin
    Result := E_OUTOFMEMORY;
    Exit;
  end;
end;

function TBCAsyncOutputPin.NonDelegatingQueryInterface(const IID: TGUID;
  out Obj): HResult;
begin
  if IsEqualGUID(IID, IID_IAsyncReader) then
  begin
    FQueriedForAsyncReader := True;
    if GetInterface(IID_IAsyncReader, Obj) then
      Result := S_OK
    else
      Result := E_FAIL;
  end
    else
      Result := Inherited NonDelegatingQueryInterface(IID, Obj);
end;

function TBCAsyncOutputPin.Connect(AReceivePin: IPin;
  const pmt: PAMMediaType): HResult;
begin
  Result := FReader.Connect(AReceivePin, pmt);
end;

function TBCAsyncOutputPin.GetMediaType(Position: Integer;
  out MediaType: PAMMediaType): HResult;
begin
  if (Position < 0) then
    Result := E_INVALIDARG
  else
    if (Position > 0) then
      Result := VFW_S_NO_MORE_ITEMS
    else
      begin
        if (FReader = nil) then
        begin
          Result := E_UNEXPECTED;
          Exit;
        end;

        CopyMemory(MediaType, FReader.LoadType, SizeOf(TAMMediaType));
        Result := S_OK;
      end;
end;

function TBCAsyncOutputPin.CheckMediaType(AType: PAMMediaType): HResult;
begin
  FLock.Lock;
  try
    // We treat MEDIASUBTYPE_NULL subtype as a wild card
    with FReader do
    if (IsEqualGUID(LoadType.majortype, AType.majortype) and
      (IsEqualGUID(LoadType.subtype, MEDIASUBTYPE_NULL) or
      IsEqualGUID(LoadType.subtype, AType.subtype))) then
      Result := S_OK
    else
      Result := S_FALSE;
  finally
    FLock.Unlock;
  end;
end;

function TBCAsyncOutputPin.CheckConnect(Pin: IPin): HResult;
begin
  FQueriedForAsyncReader := False;
  Result := Inherited CheckConnect(Pin);
end;

function TBCAsyncOutputPin.CompleteConnect(ReceivePin: IPin): HResult;
begin
  if FQueriedForAsyncReader then
    Result := inherited CompleteConnect(ReceivePin)
  else
    {$IFDEF VFW_E_NO_TRANSPORT}
    Result := VFW_E_NO_TRANSPORT;
    {$ELSE}
    Result := E_FAIL;
    {$ENDIF}
end;

function TBCAsyncOutputPin.BreakConnect: HResult;
begin
  FQueriedForAsyncReader := False;
  Result := Inherited BreakConnect;
end;

function TBCAsyncOutputPin.RequestAllocator(APreferred: IMemAllocator;
  AProps: PAllocatorProperties; out AActual: IMemAllocator): HResult;
var
  Actual: TAllocatorProperties;
  Alloc: IMemAllocator;
begin
  // we need to return an addrefed allocator, even if it is the preferred
  // one, since he doesn't know whether it is the preferred one or not.
  Assert(Assigned(FIO));

  // we care about alignment but nothing else
  if ((Not Boolean(AProps.cbAlign)) or
    (Not FIo.IsAligned(AProps.cbAlign))) then
    AProps.cbAlign := FIo.Alignment;

  if Assigned(APreferred) then
  begin
    Result := APreferred.SetProperties(AProps^, Actual);

    if (Succeeded(Result) and FIo.IsAligned(Actual.cbAlign)) then
    begin
        AActual := APreferred;
        Result := S_OK;
        Exit;
    end;
  end;

  // create our own allocator
  Result := InitAllocator(Alloc);
  if Failed(Result) then
    Exit;

  //...and see if we can make it suitable
  Result := Alloc.SetProperties(AProps^, Actual);
  if (Succeeded(Result) and FIo.IsAligned(Actual.cbAlign)) then
  begin
    // we need to release our refcount on pAlloc, and addref
    // it to pass a refcount to the caller - this is a net nothing.
    AActual := Alloc;
    Result := S_OK;
    Exit;
  end;

  // failed to find a suitable allocator
  Alloc._Release;

  // if we failed because of the IsAligned test, the error code will
  // not be failure
  if Succeeded(Result) then
    Result := VFW_E_BADALIGN;
end;

function TBCAsyncOutputPin.Request(ASample: IMediaSample; AUser: DWord): HResult;
var
  Start, Stop: TReferenceTime;
  Pos, Total, Available: LONGLONG;
  Length, Align: Integer;
  Buffer: PByte;
begin
  // queue an aligned read request. call WaitForNext to get
  // completion.

  Result := ASample.GetTime(Start, Stop);
  if Failed(Result) then
    Exit;

  Pos := Start div UNITS;
  Length := (Stop - Start) div UNITS;

  Total := 0;
  Available := 0;

  FIO.Length(Total, Available);
  if (Pos + Length > Total) then
  begin
    // the end needs to be aligned, but may have been aligned
    // on a coarser alignment.
    FIo.Alignment(Align);

    Total := (Total + Align -1) and (Not (Align-1));

    if (Pos + Length > Total) then
    begin
      Length := Total - Pos;

      // must be reducing this!
      Assert((Total * UNITS) <= Stop);
      Stop := Total * UNITS;
      ASample.SetTime(@Start, @Stop);
    end;
  end;

  Result := ASample.GetPointer(Buffer);
  if Failed(Result) then
    Exit;

  Result := FIO.Request(Pos, Length, True, Buffer, Pointer(ASample), AUser);
end;

function TBCAsyncOutputPin.WaitForNext(ATimeout: DWord; out ASample: IMediaSample;
  out AUser: DWord): HResult;
var
  Actual: Integer;
  Sample: IMediaSample;
begin
  Sample := nil;
  Result := FIo.WaitForNext(ATimeout, @Sample, AUser, Actual);
  if Succeeded(Result) then
    Sample.SetActualDataLength(Actual);
  ASample := Sample;
end;

function TBCAsyncOutputPin.SyncReadAligned(ASample: IMediaSample): HResult;
var
  Start, Stop: TReferenceTime;
  Pos, Total, Available: LONGLONG;
  Length, Align, Actual: Integer;
  Buffer: PByte;
begin
  Result := ASample.GetTime(Start, Stop);
  if Failed(Result) then
    Exit;

  Pos := Start div UNITS;
  Length := (Stop - Start) div UNITS;

  FIo.Length(Total, Available);
  if (Pos + Length > Total) then
  begin
    // the end needs to be aligned, but may have been aligned
    // on a coarser alignment.
    FIo.Alignment(Align);

    Total := (Total + Align - 1) and (Not (Align - 1));

    if (Pos + Length > Total) then
    begin
        Length := Total - Pos;

        // must be reducing this!
        Assert((Total * UNITS) <= Stop);
        Stop := Total * UNITS;
        ASample.SetTime(@Start, @Stop);
    end;
  end;

  Result := ASample.GetPointer(Buffer);
  if Failed(Result) then
    Exit;

  Result := FIO.SyncReadAligned(Pos, Length, Buffer, Actual, Pointer(ASample));
  ASample.SetActualDataLength(Actual);
end;

function TBCAsyncOutputPin.SyncRead(APosition: Int64; ALength: Longint;
  ABuffer: Pbyte): HResult;
begin
  Result := FIO.SyncRead(APosition, ALength, ABuffer);
end;

function TBCAsyncOutputPin.Length(out ATotal, AAvailable: int64): HResult;
begin
  Result := FIO.Length(ATotal, AAvailable);
end;

function TBCAsyncOutputPin.BeginFlush: HResult;
begin
  Result := FIO.BeginFlush;
end;

function TBCAsyncOutputPin.EndFlush: HResult;
begin
  Result := FIO.EndFlush;
end;

end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
捆绑调教一区二区三区| 麻豆freexxxx性91精品| 久久久一区二区| 欧美xxxx老人做受| 欧美成人a∨高清免费观看| 欧美一区在线视频| 51午夜精品国产| 日韩一区二区免费电影| 日韩欧美中文字幕精品| 精品99一区二区| 久久精品视频一区二区三区| 久久久久国产免费免费| 国产亚洲欧美在线| 亚洲色欲色欲www| 亚洲已满18点击进入久久| 日韩高清不卡在线| 国产精品一区二区在线看| 懂色一区二区三区免费观看| av不卡免费在线观看| 欧美亚洲动漫精品| 欧美一级生活片| 国产亚洲美州欧州综合国| 亚洲欧洲日产国产综合网| 亚洲成人综合视频| 国产精选一区二区三区| 色综合 综合色| 欧美一区二区三区电影| 国产欧美视频在线观看| 亚洲国产一区视频| 久久99精品视频| 99久久精品久久久久久清纯| 69p69国产精品| 18成人在线视频| 久久国产剧场电影| 99久久国产综合色|国产精品| 欧美老肥妇做.爰bbww| 日本一区二区免费在线观看视频| 一区二区国产视频| 粉嫩蜜臀av国产精品网站| 欧美日韩中文字幕一区| 日本一区二区三级电影在线观看 | 国产一区二区三区在线观看免费| 99久久国产免费看| 欧美videofree性高清杂交| 中文字幕字幕中文在线中不卡视频| 午夜av区久久| 91久久一区二区| 国产欧美日韩在线观看| 奇米777欧美一区二区| 成人国产精品免费网站| 日韩精品专区在线影院重磅| 亚洲激情男女视频| 成人免费视频国产在线观看| 日韩免费一区二区三区在线播放| 一区二区激情视频| 色综合一个色综合亚洲| 国产精品天天看| 国产在线视视频有精品| 日韩一区二区三区视频| 午夜精品久久久久久久99樱桃| jvid福利写真一区二区三区| 久久人人爽人人爽| 蜜臀av性久久久久蜜臀av麻豆| 欧美日韩精品欧美日韩精品一综合| 国产精品久久久久一区二区三区| 韩国女主播一区| 久久亚洲精品小早川怜子| 麻豆国产精品视频| 日韩免费在线观看| 免费成人在线播放| 精品国产乱码久久久久久影片| 日本亚洲天堂网| 91精品国产全国免费观看| 亚洲国产另类av| 欧美伦理视频网站| 免费高清在线一区| 精品国产乱码久久久久久免费| 美女一区二区在线观看| 日韩欧美www| 国产传媒一区在线| 中文字幕国产一区二区| 成人国产精品视频| 亚洲最大成人综合| 在线成人小视频| 精品一区二区三区影院在线午夜| 日韩欧美国产麻豆| 国产成人无遮挡在线视频| 国产清纯白嫩初高生在线观看91 | 国产激情视频一区二区三区欧美 | 7878成人国产在线观看| 日韩电影在线一区二区| 日韩美一区二区三区| 极品尤物av久久免费看| 国产精品网友自拍| 欧美性猛片aaaaaaa做受| 日韩精品亚洲一区| 国产午夜精品理论片a级大结局| 成人sese在线| 亚洲电影视频在线| 91麻豆精品国产| 久久精工是国产品牌吗| 国产精品嫩草久久久久| 在线观看成人免费视频| 日韩精品亚洲一区| 国产欧美日韩在线看| 欧美视频一区二区三区四区| 看片网站欧美日韩| 亚洲视频1区2区| 日韩小视频在线观看专区| 成人网页在线观看| 免费观看一级欧美片| 亚洲欧洲一区二区在线播放| 欧美一区二区视频在线观看2022 | 国产精品不卡在线观看| 欧美日韩aaaaa| 成人激情午夜影院| 日韩av电影免费观看高清完整版| 国产欧美日韩另类一区| 欧美精品丝袜中出| 97久久超碰国产精品| 精品一区精品二区高清| 午夜久久久影院| 国产精品丝袜91| 久久综合色婷婷| 91麻豆精品国产自产在线观看一区| 成人做爰69片免费看网站| 毛片av一区二区| 亚洲与欧洲av电影| 国产精品的网站| 国产午夜精品理论片a级大结局 | 午夜私人影院久久久久| 亚洲国产精品精华液ab| 日韩精品一区二区三区中文不卡| 色婷婷av一区二区三区之一色屋| 国产精品99久久久久久久vr| 日韩精品免费专区| 亚洲国产精品影院| 亚洲视频一区二区在线| 欧美国产一区二区在线观看| 欧美一区三区四区| 欧美日韩国产欧美日美国产精品| 日本道免费精品一区二区三区| 成人免费视频免费观看| 国产成人av电影在线| 九色综合国产一区二区三区| 六月丁香婷婷色狠狠久久| 舔着乳尖日韩一区| 一区二区三区在线播放| 亚洲人xxxx| 亚洲欧美另类久久久精品| ㊣最新国产の精品bt伙计久久| 国产欧美中文在线| 国产情人综合久久777777| 久久品道一品道久久精品| 久久久噜噜噜久噜久久综合| 久久久久久夜精品精品免费| 久久女同性恋中文字幕| 欧美精彩视频一区二区三区| 国产精品色哟哟| 亚洲视频 欧洲视频| 亚洲乱码国产乱码精品精98午夜 | 国产激情一区二区三区桃花岛亚洲| 精品在线亚洲视频| 国产精品亚洲一区二区三区妖精 | 三级久久三级久久久| 日本欧洲一区二区| 国模少妇一区二区三区| 狠狠色综合色综合网络| 成人app在线观看| av一区二区三区四区| 91色婷婷久久久久合中文| 色哟哟亚洲精品| 欧美高清精品3d| 精品国产一区二区亚洲人成毛片| 久久九九影视网| 亚洲图片欧美激情| 亚洲成人777| 懂色av一区二区三区免费观看| 成人伦理片在线| 欧美日韩国产综合一区二区三区| 日韩精品一区二区三区在线 | 国产精品国产三级国产aⅴ原创 | 成人听书哪个软件好| 在线一区二区三区四区五区 | 国产一二精品视频| 色婷婷亚洲一区二区三区| 在线综合亚洲欧美在线视频| 欧美国产精品一区二区三区| 夜夜嗨av一区二区三区四季av| 国内精品伊人久久久久影院对白| 91在线观看污| 欧美一二三四区在线| 最新欧美精品一区二区三区| 日韩不卡手机在线v区| 成人网在线免费视频| 欧美一区二区三区免费大片| 国产精品国产三级国产| 久久精品二区亚洲w码| 欧美午夜精品一区二区三区| 国产亚洲精久久久久久|