123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FRAME_CameraF.h"
- #include "FrmCameraScreenF.h"
- #include "FrmCameraInfoF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #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 1
- //---------------------------------------------------------------------------
- __fastcall TFRAMECamera::TFRAMECamera(TComponent* Owner)
- : TFrame(Owner)
- {
- FPlay = false;
- FAutoPlay = true;
- FConHandle = 0;
- FFullScreen = false;
- FParent = this->Parent;
- PnlStream->Tag = (int)this;
- FCrsCam = NULL;
- PnlStream->Font->Color = clWhite;
- FFPlayer->SetLicenseKey(LICENSE_KEY);
- FFPlayer->DisableFPUExceptions();
- String sAVILibDir = g_sAppDir + "LibAV";
- if (!FFPlayer->AVLibLoaded())
- {
- if (!FFPlayer->LoadAVLib(sAVILibDir))
- {
- PnlTitle->Caption = FCtlrNm + ": 영상표출 라이브러리를 로드 실패!!";
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::LoadEmptyImage()
- {
- try {
- String sImageFile = g_sAppDir + "Image\\crs_empty.bmp";
- if (FileExists(sImageFile)) {
- ImgNoData->Picture->LoadFromFile(sImageFile);
- ImgNoData->Align = alClient;
- //ImgNoData->Visible = true;
- }
- else {
- sImageFile = g_AppCfg.sEmptyImg;
- if (sImageFile != "") {
- ImgNoData->Picture->LoadFromFile(sImageFile);
- ImgNoData->Align = alClient;
- //ImgNoData->Visible = true;
- }
- }
- } catch(Exception &e) {
- //ImgNoData->Visible = true;
- }
- }
- //---------------------------------------------------------------------------
- bool __fastcall TFRAMECamera::Init(TScreenCtlr *ACrsCam, String AMngrNmbr, String ACtlrId, String ACtlrNm, String AStreamUrl)
- {
- if (FCrsCam != NULL) {
- Disconnect();
- }
- FPlay = false;
- FAutoPlay = true;
- FConHandle = 0;
- FFullScreen = false;
- FCrsCam = ACrsCam;
- FMngrNmbr = AMngrNmbr;
- FCtlrId = ACtlrId;
- FCtlrNm = ACtlrNm;
- FStreamUrl = AStreamUrl;
- FPlay = false;
- FConHandle = 0;
- PnlTitle->Caption = FCtlrNm;
- PnlStream->Caption = "";
- PopupMenu = NULL;
- if (FCrsCam != NULL) {
- if (FStreamUrl == "") {
- PnlTitle->Caption = FCtlrNm + ", Stream URL Empty!";
- PnlStream->Caption = "Invalid Stream Address!!!";//영상주소가 설정되지 않았습니다.";
- PnlTitle->Visible = true;
- Timer1->Enabled = false;
- ImgNoData->Visible = false;
- }
- else {
- PnlStream->Caption = "";
- PnlTitle->Visible = true;
- Timer1->Enabled = true;
- ImgNoData->Visible = false;
- PopupMenu = PopupMenu1;
- }
- }
- else {
- PnlTitle->Visible = false;
- Timer1->Enabled = false;
- ImgNoData->Visible = 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;
- FFPlayer->AspectRatio = -1;
- FFPlayer->TryOpen(FStreamUrl, PnlStream->Handle);
- FConHandle = (long)FFPlayer->ScreenHandle;
- FPlay = true;
- }
- Application->ProcessMessages();
- }
- catch(Exception &e) {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::Disconnect()
- {
- Timer1->Enabled = false;
- if (!FPlay) return;
- FPlay = false;
- try {
- if (FStreamUrl != "") {
- if (FFPlayer->ScreenHandle != NULL)
- {
- FFPlayer->Stop(true);
- PostMessage(FFPlayer->ScreenHandle, CM_INVALIDATE, 0, 0);
- UpdateWindow(FFPlayer->ScreenHandle);
- FFPlayer->ScreenHandle = NULL;
- }
- 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;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::MnuFullScreenClick(TObject *Sender)
- {
- TMenuItem *pMenuItem = (TMenuItem*)Sender;
- if (FCrsCam != NULL) {
- if (pMenuItem->Tag == 0) {
- Disconnect();
- Connect();
- }
- else if (pMenuItem->Tag == 1) {
- Disconnect();
- }
- else if (pMenuItem->Tag == 2) {
- if (FCrsCam != NULL) {
- FrmCameraScreen->TmrFullScreen->Enabled = false;
- FrmCameraScreen->FFullCrsCam = FCrsCam;
- FrmCameraScreen->TmrFullScreen->Enabled = true;
- }
- }
- else if (pMenuItem->Tag == 3) {
- FrmCameraInfo = new TFrmCameraInfo(this);
- FrmCameraInfo->Edit1->Text = FCrsCam->CAM_ID;
- FrmCameraInfo->Edit2->Text = FCrsCam->CAM_NAME;
- FrmCameraInfo->Edit3->Text = FCrsCam->STRM_ADDR;
- FrmCameraInfo->Edit4->Text = FCrsCam->FULL_STRM_ADDR;
- FrmCameraInfo->ShowModal();
- FrmCameraInfo = NULL;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMECamera::PnlStreamDblClick(TObject *Sender)
- {
- if (FCrsCam != NULL) {
- FrmCameraScreen->TmrFullScreen->Enabled = false;
- FrmCameraScreen->FFullCrsCam = FCrsCam;
- FrmCameraScreen->TmrFullScreen->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
|