Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[14166] [질문]indy10으로 구현시 어떻게 하나요??
쿠핑 [couping] 2342 읽음    2012-03-10 01:07
안녕하세요

unit ClientDM;

interface

uses
  Windows, SysUtils, Classes, ExtCtrls, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient,
  VideoCoDec, CommonU;

type
  TdmClient = class(TDataModule)
    TCPClient: TIdTCPClient;
    tmrDisplay: TTimer;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
    procedure TCPClientConnected(Sender: TObject);
    procedure TCPClientDisconnected(Sender: TObject);
    procedure tmrDisplayTimer(Sender: TObject);
  private
    VideoCoDec: TVideoCoDec;
    FFrames, FKeyFrames: Cardinal;
    procedure UpdateVideoFormat(InputFormat: TBitmapInfoHeader);
  end;

var
  dmClient: TdmClient;

implementation

uses SettingsU, DisplayU;

{$R *.dfm}

procedure TdmClient.DataModuleCreate(Sender: TObject);
begin
  VideoCoDec := TVideoCoDec.Create;
end;

procedure TdmClient.DataModuleDestroy(Sender: TObject);
begin
  FreeAndNil(VideoCoDec);
end;

procedure TdmClient.TCPClientConnected(Sender: TObject);
var
  bmih: TBitmapInfoHeader;
  CH: TCommHeader;
begin
  FFrames := 0;
  FKeyFrames := 0;
  SettingsF.btnConnect.Enabled := False;
  SettingsF.btnDisconnect.Enabled := True;
  ZeroMemory(@CH, SizeOf(CH));
  CH.DPType := 1;  // request for frame format
  TCPClient.WriteBuffer(CH, SizeOf(CH), True); TCPClient.ReadBuffer(CH, SizeOf(CH));
  if CH.DPType <> 1 then
    Exit;  // not the right packet
  if CH.DPSize <> SizeOf(bmih) then
    Exit;  // not what we expected
  // Read the format
  TCPClient.ReadBuffer(bmih, SizeOf(bmih));
  // Update the format
  UpdateVideoFormat(bmih);
  tmrDisplay.Interval := 1000 div CH.DPExtra;
  tmrDisplay.Enabled := True;

  DisplayF.lbClientSt.Caption := 'CONNECTED';
end;

procedure TdmClient.TCPClientDisconnected(Sender: TObject);
begin
  tmrDisplay.Enabled := False;
  SettingsF.btnConnect.Enabled := True;
  SettingsF.btnDisconnect.Enabled := False;

  DisplayF.lbClientSt.Caption := 'DISCONNECTED';
end;

procedure TdmClient.UpdateVideoFormat(InputFormat: TBitmapInfoHeader);
var
  bmihOut: TBitmapInfoHeader;
  FrameRate: Integer;
  FCC: TFourCC;
begin
  FCC.AsCardinal := InputFormat.biCompression;
  SettingsF.lbFCC.Caption := FCC.AsString;
  bmihOut := InputFormat;
  FrameRate := 30;
  InputFormat.biCompression :=0;  // rgb - used to decompress
  InputFormat.biBitCount := 24;   // decompress to 24 bit rgb
  VideoCoDec.Finish;
  VideoCoDec.Init(InputFormat, bmihOut, 100, 10);
  VideoCoDec.SetDataRate(1024, 1000 * 1000 div FrameRate, 1);
  if not VideoCoDec.StartDeCompressor then
    SettingsF.lbClientError.Caption := TranslateICError(VideoCoDec.LastError);
  DisplayF.ClientHeight := InputFormat.biHeight +
    DisplayF.Panel1.Height + DisplayF.Panel2.Height;
  DisplayF.ClientWidth  := InputFormat.biWidth;
end;

procedure TdmClient.tmrDisplayTimer(Sender: TObject);
var
  CH: TCommHeader;
  Data: PByte;
begin
  if not VideoCoDec.DecompressorStarted then
    Exit;

  ZeroMemory(@CH, SizeOf(CH));
  CH.DPType := 2; // request the frame
  TCPClient.WriteBuffer(CH, SizeOf(CH), True);

  // Read the frame
  TCPClient.ReadBuffer(CH, SizeOf(CH));

  if CH.DPType <> 2 then
    Exit; // not a frame packet
  if CH.DPSize < 1 then
    Exit;

  GetMem(Data, CH.DPSize);
  try
    TCPClient.ReadBuffer(Data^, CH.DPSize);
    if VideoCoDec.UnpackBitmap(Data, Boolean(CH.DPCode), DisplayF.imgDisplay.Picture.Bitmap) then begin
      Inc(FFrames);
      Inc(FKeyFrames, CH.DPCode);
      DisplayF.imgDisplay.Repaint;
      SettingsF.lbFrames.Caption := Format('Frames: %d (%d kf)', [FFrames, FKeyFrames]);
      SettingsF.Update;
    end;
  finally
    FreeMem(Data);
  end;
end;

end.
  FreeMem(Data);
  end;
end;

end.

위의 내용중 굵은 글씨로 된 부부을 인디10으로 표현을 하려면 어떻게 하나요???

고수님들의 답글 부탁드립니다.

+ -

관련 글 리스트
14166 [질문]indy10으로 구현시 어떻게 하나요?? 쿠핑 2342 2012/03/10
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.