📄 qtvid.cxx
字号:
//// The contents of this file are subject to the Mozilla Public License// Version 1.0 (the "License"); you may not use this file except in// compliance with the License. You may obtain a copy of the License at// http://www.mozilla.org/MPL/// // Software distributed under the License is distributed on an "AS IS"// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See// the License for the specific language governing rights and limitations// under the License.// // The Original Code is CPhone, a cross platform voip gui.//// The Initial Developer of the Original Code is Derek Smithies.//// Copyright (C) 2002 Indranet Technologies Ltd, // http://www.indranet-technologies.com// All Rights Reserved.//// Contributor(s): _______________/* * * $Log: qtvid.cxx,v $ * Revision 1.2 2003/04/04 04:37:49 dereksmithies * Major upgrade. * Ixj & microtelco support added. Fix threading issues. * * Revision 1.1.1.1 2002/05/12 22:55:05 dereksmithies * Initial release. * * * * */#include <ptlib.h>#include "vdisplay.h"#include "qtvid.h"#include <qimage.h>QtVideoDevice::QtVideoDevice(BOOL _isEncoding, VideoDisplay *_displayWidget, BOOL vertFlip){ isEncoding= _isEncoding; width=0; height=0; displayWidget = _displayWidget; doVerticalFlip = vertFlip;}QtVideoDevice::~QtVideoDevice(){ Close();}BOOL QtVideoDevice::Close(){ RemoveVideoImage(); return TRUE;}void QtVideoDevice::RemoveVideoImage(){ displayWidget->RemoveVideoImage();}BOOL QtVideoDevice::SetFrameSize (unsigned _width, unsigned _height){ width = _width; height = _height; return TRUE;} BOOL QtVideoDevice::GetVFlipState(){ return doVerticalFlip;}BOOL QtVideoDevice::SetVFlipState(BOOL newVFlipState){ doVerticalFlip = newVFlipState; return TRUE;} BOOL QtVideoDevice::ToggleVFlipState(){ doVerticalFlip = !doVerticalFlip; return TRUE;}BOOL QtVideoDevice::SetFrameData(unsigned x, unsigned y, unsigned width, unsigned height, const BYTE * data, BOOL endFrame){ if (!endFrame) return FALSE; return Redraw(data);}BOOL QtVideoDevice::EndFrame(){ return TRUE;}BOOL QtVideoDevice::Redraw (const void *frame){ displayWidget->SetDisplayBuffer(frame, width, height, doVerticalFlip); return TRUE; }BOOL QtVideoDevice::WriteLineSegment(int /*x*/, int /*y*/, unsigned /*len*/, const BYTE * /*data*/){ cerr <<"WriteLineSegment in qtvid.cxx is called in error"<<endl; return TRUE; }PStringList QtVideoDevice::GetDeviceNames() const{ PStringList devlist; devlist.AppendString(GetDeviceName()); return devlist;}BOOL QtVideoDevice::IsOpen(){ return TRUE;}//////////////////////////////////////////////PStringList PTextVideoInputDevice::GetInputDeviceNames(){ PStringList list; list.AppendString("text generation"); return list;}PTextVideoInputDevice::PTextVideoInputDevice(){ rgbImage = NULL;}PTextVideoInputDevice::PTextVideoInputDevice(PString newMessage){ rgbImage = NULL; text = newMessage;}PTextVideoInputDevice::~PTextVideoInputDevice(){ PWaitAndSignal m(bufferMutex); if (rgbImage != NULL) delete rgbImage;}int PTextVideoInputDevice::GetNumChannels(){ return P_MAX_INDEX;}BOOL PTextVideoInputDevice::SetColourFormat(const PString & newFormat){ if (newFormat != "RGB32") return FALSE; if (!PVideoDevice::SetColourFormat("RGB32")) return FALSE; // set the new information return SetFrameSizeConverter(frameWidth, frameHeight, FALSE);}BOOL PTextVideoInputDevice::SetFrameSize( unsigned newWidth, unsigned newHeight){ if (!PVideoDevice::SetFrameSize(newWidth, newHeight)) return FALSE; return TRUE;} void PTextVideoInputDevice::SetDisplayText(PString newText){ PWaitAndSignal m(bufferMutex); text = newText;}BOOL PTextVideoInputDevice::GetFrameDataNoDelay(BYTE *destFrame, PINDEX * bytesReturned){ PWaitAndSignal m(bufferMutex); QString displayText(text.GetPointer()); if (rgbImage == NULL) rgbImage = new Rgb32Image(frameWidth, frameHeight, displayText); if ((rgbImage->Width() != frameWidth ) || (rgbImage->Height() != frameHeight)) { delete rgbImage; rgbImage = new Rgb32Image(frameWidth, frameHeight, displayText); } // If converting on the fly do it from frame store to output buffer, otherwise do // straight copy. if (converter != NULL) { *bytesReturned = 3 * frameWidth * frameHeight; rgbImage->RestrictAccess(); converter->Convert(rgbImage->GetDataPointer(), (BYTE *)destFrame, bytesReturned); rgbImage->EnableAccess(); } else { *bytesReturned = frameWidth * frameHeight *3 / 2; memset(destFrame, *bytesReturned, 13); } return TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -