亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
91国产精品成人| 成人av在线资源网站| 欧美一级久久久| 激情国产一区二区| 欧美精品一区视频| 国产91精品一区二区麻豆网站| 久久精品视频一区二区| 东方欧美亚洲色图在线| 亚洲欧美日韩在线| 9191国产精品| 国产经典欧美精品| 亚洲免费资源在线播放| 91久久线看在观草草青青| 亚洲超丰满肉感bbw| 日韩一级欧美一级| 成人的网站免费观看| 亚洲制服丝袜av| 精品国产乱码久久久久久图片| 日本伊人午夜精品| 日本一区二区成人| 色噜噜狠狠成人网p站| 亚洲一区在线观看网站| 精品国内二区三区| 99久久综合精品| 日韩av一级片| 中文字幕日韩一区| 91精品国产日韩91久久久久久| 国产毛片一区二区| 悠悠色在线精品| 欧美本精品男人aⅴ天堂| 白白色亚洲国产精品| 午夜在线成人av| 中文字幕欧美国产| 91精品国产高清一区二区三区| 国产成a人亚洲| 亚洲va欧美va天堂v国产综合| 久久免费精品国产久精品久久久久| 色国产综合视频| 黄色资源网久久资源365| 亚洲伦理在线精品| 亚洲精品在线网站| 欧美色视频一区| 国产91精品露脸国语对白| 日韩av中文字幕一区二区三区| 中文字幕一区二区三中文字幕| 日韩一级黄色大片| 欧美午夜精品免费| av一区二区三区黑人| 国产自产视频一区二区三区| 亚洲电影在线播放| 亚洲欧洲日产国产综合网| 精品国产一区a| 欧美日韩国产欧美日美国产精品| 成人午夜激情在线| 国产在线不卡一卡二卡三卡四卡| 亚洲成人一二三| 亚洲卡通欧美制服中文| 久久久久99精品国产片| 日韩三级中文字幕| 欧美撒尿777hd撒尿| 91视频一区二区三区| 成人中文字幕电影| 国产精品一区专区| 久久不见久久见中文字幕免费| 婷婷中文字幕一区三区| 亚洲影视在线播放| 亚洲在线观看免费视频| 亚洲天堂福利av| 亚洲免费观看高清| 亚洲特黄一级片| 亚洲乱码国产乱码精品精小说| 中文字幕中文在线不卡住| 日韩电影在线看| 一区二区三区自拍| 欧美一区二区黄| 狠狠色丁香久久婷婷综合丁香| 椎名由奈av一区二区三区| 欧美欧美欧美欧美| 国产黄色精品视频| 欧美卡1卡2卡| 国产高清在线观看免费不卡| 国产激情视频一区二区在线观看 | 91蜜桃免费观看视频| 国产成人精品免费视频网站| 国产精品资源网| 国产乱码字幕精品高清av| 国产精品一区二区你懂的| 国产成人精品午夜视频免费| 成人综合婷婷国产精品久久免费| 99精品一区二区| 欧美日韩国产综合视频在线观看| 91精品国产福利在线观看| 日韩色在线观看| 中文字幕第一区| 亚洲黄色性网站| 日韩国产欧美在线视频| 麻豆91免费观看| 丁香婷婷综合网| 91亚洲精品一区二区乱码| 日本韩国欧美在线| 欧美一级一级性生活免费录像| 日韩欧美国产系列| 亚洲国产精华液网站w | 亚洲一区二区中文在线| 亚洲高清视频在线| 国产综合色精品一区二区三区| 成人午夜av在线| 欧美在线观看一区二区| 制服.丝袜.亚洲.另类.中文 | 亚洲国产精品黑人久久久| 亚洲精品视频免费看| 日本欧美一区二区三区| 成人在线视频一区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 91精品国产色综合久久不卡电影| 久久网站热最新地址| 亚洲女同一区二区| 美国毛片一区二区| 色婷婷精品大在线视频 | 色老综合老女人久久久| 日韩欧美国产综合| 一区二区成人在线| 国产精品亚洲专一区二区三区| 在线观看日韩精品| 中文字幕精品—区二区四季| 日韩av不卡在线观看| 91麻豆精品视频| 欧美精品一区二区三区一线天视频 | 欧美精品一二三| 国产色综合一区| 五月综合激情日本mⅴ| 成年人午夜久久久| 久久蜜臀中文字幕| 日本怡春院一区二区| 在线观看av一区二区| 国产精品蜜臀av| 激情偷乱视频一区二区三区| 欧美色视频在线观看| 综合久久久久久久| 成人午夜免费电影| 久久精品夜色噜噜亚洲aⅴ| 日本欧洲一区二区| 欧美老女人在线| 亚洲综合激情小说| 91免费看片在线观看| 国产人伦精品一区二区| 韩国av一区二区三区| 这里是久久伊人| 午夜精品一区二区三区三上悠亚| 99久久久久久99| 成人免费小视频| 成人福利在线看| 久久精品夜色噜噜亚洲a∨| 狠狠色丁香九九婷婷综合五月| 91精品国产一区二区| 日韩中文字幕91| 在线成人午夜影院| 日韩黄色免费电影| 欧美日韩视频一区二区| 亚洲综合网站在线观看| 一本色道久久综合狠狠躁的推荐| 国产欧美日韩麻豆91| 国产成人精品一区二 | 亚洲欧美日韩国产中文在线| www.欧美色图| 亚洲三级小视频| 色婷婷综合久久久| 亚洲激情校园春色| 日本道在线观看一区二区| 亚洲欧美日韩综合aⅴ视频| 91女人视频在线观看| 亚洲免费看黄网站| 欧美日韩一级大片网址| 亚洲狠狠爱一区二区三区| 欧美日韩精品一区二区三区四区 | 亚洲成av人片在线| 9191成人精品久久| 日本成人在线网站| 日韩精品免费专区| 91视频在线看| 亚洲精品视频在线观看网站| 欧美色男人天堂| 久久狠狠亚洲综合| 欧美成人免费网站| 久久精品夜色噜噜亚洲aⅴ| 懂色av一区二区三区免费看| 国产精品毛片久久久久久久| 色综合咪咪久久| 香蕉乱码成人久久天堂爱免费| 欧美一级xxx| 国产一区二区伦理| 亚洲视频狠狠干| 欧美日韩一区二区电影| 久久www免费人成看片高清| 国产精品久久久久影视| 在线欧美日韩精品| 美女一区二区在线观看| 国产精品三级在线观看| 欧美午夜精品理论片a级按摩| 美女视频黄a大片欧美|