//
// 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: vdisplay.h,v $
* Revision 1.5 2003/08/11 01:48:14 dereksmithies
* Fix windows compile errors
*
* Revision 1.4 2003/08/06 05:04:25 dereksmithies
* Add feature to display bmp
*
* Revision 1.3 2003/05/09 03:08:24 dereksmithies
* Fix Microtelco handling, and message display
*
* 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:03 dereksmithies
* Initial release.
*
*
*
*
*/
#ifndef VDISPLAY_H
#define VDISPLAY_H
#include <ptlib.h>
#include <ptlib/vconvert.h>
#ifndef QT_H
#include "qwidget.h"
#endif
#include <qframe.h>
#include <qimage.h>
#include <qthread.h>
#include <qlabel.h>
#define SWAP_BLANK 1
#define SWAP_BUFFER 2
#define SWAP_INCOMING 3
#define SWAP_FIXED 4
//This class takes YUV420P data, scales and displays it.
class VideoDisplay : public QFrame //VideoDisplay class
{
public:
VideoDisplay( QWidget *parent=0, const char *name=0, WFlags f=0);
~VideoDisplay();
void drawContents(QPainter *p);
void SetDisplayBuffer(const void *videoFrame, unsigned _width, unsigned _height, BOOL doFlip);
void RemoveVideoImage();
void InitiateRepaint(BOOL doErase);
void DisplayQImage(QImage *qImage);
private:
void CreateColourConverter();
void ResizeImage(uchar *dest_data, unsigned dest_width, unsigned dest_height,
uchar *source_data, unsigned source_width, unsigned source_height);
void SwapImages(int swapNeeded);
int width;
int height;
PColourConverter *converter;
PMutex bufferMutex;
QImage *blankImage;
QImage *bufferImage;
QImage *displayImage;
QImage *fixedImage;
QImage *incomingImage;
QImage *scaledImage;
BOOL displayFlipped;
BOOL newImageData;
};
//This class is provided so any thread can safely send text to this label,
//and have it displayed without thread violations.
class LabelDisplay : public QLabel
{
public:
LabelDisplay(QWidget *parent=0, const char *name=0, WFlags f=0);
void customEvent(QCustomEvent *e);
void prepareDisplayText(QString s);
private:
QString displayText;
PMutex displayMutex;
};
//This class is used to generate a RGB32 image of size (X,Y) with
//text displayed on it.
class Rgb32Image : public QObject
{
Q_OBJECT
public:
Rgb32Image(int x, int y, QString newMessage);
~Rgb32Image();
QString GetTextMessage() const { return textMessage; }
unsigned Width() const { return frameWidth ; }
unsigned Height() const { return frameHeight; }
void RestrictAccess() { access.lock(); }
void EnableAccess() { access.unlock(); }
BYTE * GetDataPointer() const;
void CopyData(Q_UINT8 *dest);
bool event(QEvent *e);
void MakeImage();
private:
unsigned frameWidth, frameHeight;
QImage *image;
QString textMessage;
QMutex access;
};
#endif // VDISPLAY_H
syntax highlighted by Code2HTML, v. 0.9.1