00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef PHONEUI_H_
00011 #define PHONEUI_H_
00012
00013 #include <qregexp.h>
00014 #include <qtimer.h>
00015 #include <qptrlist.h>
00016 #include <qthread.h>
00017 #include <qsound.h>
00018
00019 #include <mythtv/mythwidgets.h>
00020 #include <mythtv/dialogbox.h>
00021
00022
00023 #include "directory.h"
00024 #include "webcam.h"
00025 #include "sipfsm.h"
00026 #include "rtp.h"
00027 #include "h263.h"
00028 #include "tone.h"
00029
00030
00031
00032 extern SipContainer *sipStack;
00033 class PhoneUIStatusBar;
00034
00035 #define MAX_DISPLAY_IM_MSGS 5 // No lines of IM per mythdialog box
00036
00037
00038 #define WC_INSET_WIDTH (176)
00039 #define WC_INSET_HEIGHT (144)
00040
00041 class PhoneUIBox : public MythThemedDialog
00042 {
00043
00044 Q_OBJECT
00045
00046 public:
00047
00048 typedef QValueVector<int> IntVector;
00049
00050 PhoneUIBox(MythMainWindow *parent, QString window_name,
00051 QString theme_filename, const char *name = 0);
00052
00053 ~PhoneUIBox(void);
00054
00055 void keyPressEvent(QKeyEvent *e);
00056 void customEvent(QCustomEvent *);
00057
00058 public slots:
00059
00060 void MenuButtonPushed();
00061 void InfoButtonPushed();
00062 void LoopbackButtonPushed();
00063 void handleTreeListSignals(int, IntVector*);
00064 void TransmitLocalWebcamImage(uchar *yuvBuffer, int w, int h);
00065 void OnScreenClockTick();
00066 void closeUrlPopup();
00067 void dialUrlVideo();
00068 void dialUrlVoice();
00069 void dialUrlSwitchToDigits();
00070 void dialUrlSwitchToUrl();
00071 void closeAddEntryPopup();
00072 void entryAddSelected();
00073 void closeAddDirectoryPopup();
00074 void directoryAddSelected();
00075 void closeCallPopup();
00076 void incallDialVoiceSelected();
00077 void incallDialVideoSelected();
00078 void outcallDialVoiceSelected();
00079 void outcallDialVideoSelected();
00080 void outcallSendIMSelected();
00081 void menuCallUrl();
00082 void menuAddContact();
00083 void menuDirAdd();
00084 void menuDirDel();
00085 void menuDirRen();
00086 void menuSpeedDialRemove();
00087 void menuHistorySave();
00088 void menuHistoryClear();
00089 void menuEntryEdit();
00090 void menuEntryMakeSpeedDial();
00091 void menuEntryDelete();
00092 void vmailEntryDelete();
00093 void vmailEntryDeleteAll();
00094 void closeMenuPopup();
00095 void closeIMPopup();
00096 void imSendReply();
00097 void closeStatisticsPopup();
00098 void changeVolumeControl(bool up_or_down);
00099 void changeVolume(bool up_or_down);
00100 void toggleMute();
00101 QString getVideoFrameSizeText();
00102 void hideVolume(){showVolume(false);}
00103 void showVolume(bool on_or_off);
00104 void DisplayMicSpkPower();
00105 void statsIncreaseAudioPlayout();
00106 void statsDecreaseAudioPlayout();
00107
00108
00109 private:
00110 void DrawLocalWebcamImage();
00111 void TransmitLocalWebcamImage();
00112 void ProcessRxVideoFrame();
00113 void ProcessSipStateChange();
00114 void ProcessSipNotification();
00115 void PlaceCall(QString url, QString name, QString Mode, bool onLocalLan=false);
00116 void AnswerCall(QString Mode, bool onLocalLan=false);
00117 void HangUp();
00118 void StartVideo(int lPort, QString remoteIp, int remoteVideoPort, int videoPayload, QString rxVidRes);
00119 void StopVideo();
00120 void ChangeVideoTxResolution();
00121 void ChangeVideoRxResolution();
00122 void keypadPressed(char k);
00123 void getResolution(QString setting, int &width, int &height);
00124 void videoCifModeToRes(QString cifMode, int &w, int &h);
00125 const char *videoResToCifMode(int w);
00126 void ProcessAudioRtpStatistics(RtpEvent *stats);
00127 void ProcessVideoRtpStatistics(RtpEvent *stats);
00128 void ProcessAudioRtcpStatistics(RtpEvent *stats);
00129 void ProcessVideoRtcpStatistics(RtpEvent *stats);
00130 void doMenuPopup();
00131 void doUrlPopup(char key, bool DigitsOrUrl);
00132 void doIMPopup(QString otherParty, QString callId, QString Msg);
00133 void scrollIMText(QString Msg, bool msgReceived);
00134 void doAddEntryPopup(DirEntry *edit=0, QString nn="", QString Url="");
00135 void doAddDirectoryPopup();
00136 void addNewDirectoryEntry(QString Name, QString Url, QString Dir, QString fn, QString sn, QString ph, bool isSpeed, bool OnHomeLan);
00137 void doCallPopup(DirEntry *entry, QString DialorAnswer, bool audioOnly);
00138 void drawCallPopupCallHistory(MythPopupBox *popup, CallRecord *call);
00139 void startRTP(int audioPayload, int videoPayload, int dtmfPayload, int audioPort, int videoPort,
00140 QString remoteIp, QString audioCodec, QString videoCodec, QString videoRes);
00141 void stopRTP(bool stopAudio=true, bool stopVideo=true);
00142 void alertUser(QString callerUser, QString callerName, QString callerUrl, bool inAudioOnly);
00143 void showStatistics(bool showVideo);
00144 void updateAudioStatistics(int pkIn, int pkLost, int pkLate, int pkOut, int pkInDisc, int pkOutDrop, int bIn, int bOut, int minPlayout, int avgPlayout, int maxPlayout);
00145 void updateVideoStatistics(int pkIn, int pkLost, int pkLate, int pkOut, int pkInDisc, int pkOutDrop, int bIn, int bOut, int fIn, int fOut, int fDiscIn, int fDiscOut);
00146 void updateAudioRtcpStatistics(int fractionLoss, int totalLoss);
00147 void updateVideoRtcpStatistics(int fractionLoss, int totalLoss);
00148
00149 void wireUpTheme();
00150 DirectoryContainer *DirContainer;
00151 PhoneUIStatusBar *phoneUIStatusBar;
00152
00153 int State;
00154 rtp *rtpAudio;
00155 rtp *rtpVideo;
00156 QString audioCodecInUse;
00157 QString videoCodecInUse;
00158 TelephonyTones Tones;
00159 Tone *vmail;
00160
00161 Webcam *webcam;
00162 wcClient *localClient;
00163 wcClient *txClient;
00164 int wcWidth, wcHeight, txWidth, txHeight, rxWidth, rxHeight;
00165 int wcDeliveredFrames;
00166 int wcDroppedFrames;
00167 QString txVideoMode;
00168 int zoomWidth, zoomHeight, zoomFactor;
00169 int hPan, wPan;
00170 int screenwidth, screenheight;
00171 bool fullScreen;
00172 QRect rxVideoArea;
00173 bool loopbackMode;
00174
00175 H263Container *h263;
00176 QTimer *powerDispTimer;
00177 QTimer *OnScreenClockTimer;
00178 QTime ConnectTime;
00179
00180
00181 QTimer *volume_display_timer;
00182 UIStatusBarType *volume_status;
00183 enum {VOL_VOLUME, VOL_MICVOLUME, VOL_BRIGHTNESS, VOL_CONTRAST, VOL_COLOUR, VOL_TXSIZE, VOL_TXRATE, VOL_AUDCODEC } VolumeMode;
00184
00185 int camBrightness, camContrast, camColour, txFps;
00186
00187 uchar localRgbBuffer[MAX_RGB_704_576];
00188 uchar rxRgbBuffer[MAX_RGB_704_576];
00189 uchar yuvBuffer1[MAX_YUV_704_576];
00190 uchar yuvBuffer2[MAX_YUV_704_576];
00191 QImage savedLocalWebcam;
00192
00193 UIManagedTreeListType *DirectoryList;
00194
00195 UIRepeatedImageType *micAmplitude;
00196 UIRepeatedImageType *spkAmplitude;
00197
00198 UIImageType *volume_bkgnd;
00199 UIImageType *volume_icon;
00200 UITextType *volume_setting;
00201 UITextType *volume_value;
00202 UITextType *volume_info;
00203 UIBlackHoleType *localWebcamArea;
00204 UIBlackHoleType *receivedWebcamArea;
00205
00206
00207 bool VideoOn;
00208 bool show_whole_tree;
00209 CallRecord *currentCallEntry;
00210
00211 MythPopupBox *menuPopup;
00212
00213 MythPopupBox *urlPopup;
00214 MythRemoteLineEdit *urlRemoteField;
00215 MythLineEdit *urlField;
00216 QLabel *callLabelUrl;
00217 QLabel *callLabelName;
00218 MythPopupBox *imPopup;
00219 MythRemoteLineEdit *imReplyField;
00220 QMap<int,QLabel *> imLine;
00221 int displayedIMMsgs;
00222 QString imCallid;
00223 QString imUrl;
00224
00225 MythPopupBox *statsPopup;
00226 QLabel *audioPkInOutLabel;
00227 QLabel *audioPlayoutLabel;
00228 QLabel *audioPkRtcpLabel;
00229 QLabel *videoPkInLabel;
00230 QLabel *videoPkOutLabel;
00231 QLabel *videoPkRtcpLabel;
00232 QLabel *videoFramesInOutDiscLabel;
00233 QLabel *videoAvgFpsLabel;
00234 QLabel *videoWebcamFpsLabel;
00235 QLabel *videoResLabel;
00236
00237
00238 MythPopupBox *addEntryPopup;
00239 MythRemoteLineEdit *entryNickname;
00240 MythRemoteLineEdit *entryFirstname;
00241 MythRemoteLineEdit *entrySurname;
00242 MythRemoteLineEdit *entryUrl;
00243 MythComboBox *entryDir;
00244 MythComboBox *entryPhoto;
00245 MythCheckBox *entrySpeed;
00246 MythCheckBox *entryOnHomeLan;
00247 DirEntry *EntrytoEdit;
00248 bool entryIsOnLocalLan;
00249
00250 MythPopupBox *addDirectoryPopup;
00251 MythRemoteLineEdit *newDirName;
00252
00253 MythPopupBox *incallPopup;
00254
00255 bool SelectHit;
00256 };
00257
00258
00259
00260 class PhoneUIStatusBar : public QObject
00261 {
00262
00263 Q_OBJECT
00264
00265 public:
00266
00267 PhoneUIStatusBar(UITextType *a, UITextType *b, UITextType *c, UITextType *d, UITextType *e, UITextType *f, QObject *parent = 0, const char * = 0);
00268 ~PhoneUIStatusBar();
00269 void DisplayInCallStats(bool initialise);
00270 void DisplayCallState(QString s);
00271 void DisplayNotification(QString s, int Seconds);
00272 void updateMidCallCaller(QString t);
00273 void updateMidCallTime(int Seconds);
00274 void updateMidCallAudioStats(int pIn, int pMiss, int pLate, int pOut, int bIn, int bOut, int msPeriod);
00275 void updateMidCallVideoStats(int pIn, int pMiss, int pLate, int pOut, int bIn, int bOut, int msPeriod);
00276 void updateMidCallVideoCodec(QString c);
00277 void updateMidCallAudioCodec(QString c);
00278
00279 public slots:
00280 void notificationTimeout();
00281
00282 private:
00283 QTimer *notificationTimer;
00284
00285 bool modeInCallStats;
00286 bool modeNotification;
00287 QString callerString;
00288 QString TimeString;
00289 QString audioStatsString;
00290 QString videoStatsString;
00291 QString bwStatsString;
00292 QString statusMsgString;
00293 QString callStateString;
00294
00295
00296 QString statsVideoCodec;
00297 QString statsAudioCodec;
00298 int audLast_pIn;
00299 int audLast_pLoss;
00300 int audLast_pTotal;
00301 int audLast_bIn;
00302 int audLast_bOut;
00303 int vidLast_bIn;
00304 int vidLast_bOut;
00305 int vidLast_pIn;
00306 int vidLast_pLoss;
00307 int vidLast_pTotal;
00308 int last_bOut;
00309 QTime lastPoll;
00310
00311 UITextType *callerText;
00312 UITextType *audioStatsText;
00313 UITextType *videoStatsText;
00314 UITextType *bwStatsText;
00315 UITextType *callTimeText;
00316 UITextType *statusMsgText;
00317
00318
00319 };
00320
00321
00322
00323 #endif