Jow Flow를 그리는데에는 시스템의 어느 정도의 깊이를 다루느냐가 중요한 변수가 되는데, 그것은 추후 다루기로 하겠습니다.
unit DeskCamEncoder; interface uses DeskCamUtils, DeskCamCapture, ScreenSlice, ThreadRepeater, FrameEncoder, Classes, SysUtils; type TDeskCamEncoder = class (TComponent) private FDeskCamCapture : TDeskCamCapture; FFrameEncoder : TFrameEncoder; private FRepeater : TThreadRepeater; procedure on_Repeat(Sender:TObject); private function GetDeskCamCapture: IDeskCamCapture; function GetOnDeskFrame: TDeskFrameEvent; function GetOnEndOfFrame: TNotifyEvent; procedure SetOnDeskFrame(const Value: TDeskFrameEvent); procedure SetOnEndOfFrame(const Value: TNotifyEvent); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Start; procedure Stop; published property DeskCamCapture : IDeskCamCapture read GetDeskCamCapture; property OnDeskFrame : TDeskFrameEvent read GetOnDeskFrame write SetOnDeskFrame; property OnEndOfFrame : TNotifyEvent read GetOnEndOfFrame write SetOnEndOfFrame; end; implementation { TDeskCamEncoder } constructor TDeskCamEncoder.Create(AOwner: TComponent); begin inherited; FDeskCamCapture := TDeskCamCapture.Create(Self); FFrameEncoder := TFrameEncoder.Create; FRepeater := TThreadRepeater.Create(Self); end; destructor TDeskCamEncoder.Destroy; begin Stop; FreeAndNil(FDeskCamCapture); FreeAndNil(FFrameEncoder); FreeAndNil(FRepeater); inherited; end; function TDeskCamEncoder.GetDeskCamCapture: IDeskCamCapture; begin Result := FDeskCamCapture; end; function TDeskCamEncoder.GetOnDeskFrame: TDeskFrameEvent; begin Result := FFrameEncoder.OnDeskFrame; end; function TDeskCamEncoder.GetOnEndOfFrame: TNotifyEvent; begin Result := FFrameEncoder.OnEndOfFrame; end; procedure TDeskCamEncoder.on_Repeat(Sender: TObject); var ScreenSlice : TScreenSlice; begin ScreenSlice := FDeskCamCapture.GetScreenSlice; if ScreenSlice = nil then begin Sleep(5); Exit; end; FFrameEncoder.Execute(ScreenSlice); end; procedure TDeskCamEncoder.SetOnDeskFrame(const Value: TDeskFrameEvent); begin FFrameEncoder.OnDeskFrame := Value; end; procedure TDeskCamEncoder.SetOnEndOfFrame(const Value: TNotifyEvent); begin FFrameEncoder.OnEndOfFrame := Value; end; procedure TDeskCamEncoder.Start; begin FFrameEncoder.Clear; FDeskCamCapture.Start; FRepeater.Execute(on_Repeat); end; procedure TDeskCamEncoder.Stop; begin FDeskCamCapture.Stop; FRepeater.Stop; end; end.
Jow Flow를 제대로 활용하려면 소스를 보고 다시 Jow Flow를 그리는 연습도 필요합니다.
function GetScreenSlice:TScreenSlice;
상속과 위임에 대한 가벼운 예제 (0) | 2013.04.29 |
---|---|
인터페이스 릴레이 (0) | 2012.06.01 |
Job Flow의 소개 (1) | 2011.12.14 |
데이터베이스 설계의 기본 원리 (0) | 2011.02.12 |
클래스 상속과 인터페이스 구현의 차이 (8) | 2010.11.15 |