123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FRAME_CameraF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "AcesTechXPlayer2Lib_OCX"
- #pragma link "FFBaseComponent"
- #pragma link "FFBasePlay"
- #pragma link "FFPlay"
- #pragma link "dxGDIPlusClasses"
- #pragma resource "*.dfm"
- TFRAMECamera *FRAMECamera;
- #define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"
- #define FFPLAY 0
- #define ACES 1
- //---------------------------------------------------------------------------
- __fastcall TFRAMECamera::TFRAMECamera(TComponent* Owner)
- : TFrame(Owner)
- {
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFRAMECamera::Init(String AMngrNmbr, String ACtlrId, String ACtlrNm, String AStreamUrl)
- {
- #if FFPLAY
- AcesTechXPlayer2->Visible = false;
- FFPlayer->SetLicenseKey(LICENSE_KEY);
- FFPlayer->DisableFPUExceptions();
- #endif
- #if ACES
- AcesTechXPlayer2->Align = alClient;
- AcesTechXPlayer2->Visible = true;
- #endif
- Disconnect();
- PnlTitle->Visible = true;
- FMngrNmbr = AMngrNmbr;
- FCtlrId = ACtlrId;
- FCtlrNm = ACtlrNm;
- FStreamUrl = AStreamUrl;
- FPlay = false;
- FConHandle = 0;
- PnlTitle->Caption = FCtlrNm;
- PnlStream->Font->Color = clWhite;
- #if FFPLAY
- String sAVILibDir = g_sAppDir + "LibAV";
- if (!FFPlayer->AVLibLoaded())
- {
- if (!FFPlayer->LoadAVLib(sAVILibDir))
- {
- PnlTitle->Caption = FCtlrNm + ": 영상표출 라이브러리를 로드 실패!!";
- return false;
- }
- }
- #endif
- if (FStreamUrl == "") {
- PnlTitle->Caption = FCtlrNm + ", Stream URL Empty!";
- PnlStream->Caption = "Invalid Stream Address!!!";//영상주소가 설정되지 않았습니다.";
- PnlStream->Font->Color = clWhite;
- }
- ImgDefault->Visible = false;
- Timer1->Enabled = true;
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::Timer1Timer(TObject *Sender)
- {
- Timer1->Enabled = false;
- Connect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::Connect()
- {
- Disconnect();
- try
- {
- if (FStreamUrl != "") {
- PnlStream->Caption = FStreamUrl + ", Connecting...";
- PnlTitle->Caption = FCtlrNm;
- #if FFPLAY
- FFPlayer->AspectRatio = -1;
- FFPlayer->TryOpen(FStreamUrl, PnlStream->Handle);
- FConHandle = (long)FFPlayer->ScreenHandle;
- #endif
- #if ACES
- AcesTechXPlayer2->URL = FStreamUrl;
- FConHandle = AcesTechXPlayer2->ConnectAsync();
- if (FConHandle > 0)
- {
- }
- #endif
- FPlay = true;
- }
- Application->ProcessMessages();
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::Disconnect()
- {
- Timer1->Enabled = false;
- if (!FPlay) return;
- FPlay = false;
- try
- {
- if (FStreamUrl != "") {
- #if FFPLAY
- if (FFPlayer->ScreenHandle != NULL)
- {
- FFPlayer->Stop(true);
- PostMessage(FFPlayer->ScreenHandle, CM_INVALIDATE, 0, 0);
- UpdateWindow(FFPlayer->ScreenHandle);
- FFPlayer->ScreenHandle = NULL;
- }
- #endif
- #if ACES
- if (FConHandle > 0)
- {
- AcesTechXPlayer2->Close();
- }
- #endif
- PnlStream->Caption = "Disconnected";
- }
- FConHandle = 0;
- Application->ProcessMessages();
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::FFPlayerState(TObject *Sender, TPlayState APlayState)
- {
- enum TPlayState { psPlay, psPause, psResume, psStep, psStop, psEnd };
- if (APlayState == Ffbasecomponent::psStop || APlayState == Ffbasecomponent::psEnd)
- {
- PnlTitle->Caption = FCtlrNm + " : Disconnected";
- Timer1->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
|