h281handler.h

Go to the documentation of this file.
00001 /*
00002  * h281handler.h
00003  *
00004  * H.281 protocol handler implementation for the OpenH323 Project.
00005  *
00006  * Copyright (c) 2006 Network for Educational Technology, ETH Zurich.
00007  * Written by Hannes Friederich.
00008  *
00009  * The contents of this file are subject to the Mozilla Public License
00010  * Version 1.0 (the "License"); you may not use this file except in
00011  * compliance with the License. You may obtain a copy of the License at
00012  * http://www.mozilla.org/MPL/
00013  *
00014  * Software distributed under the License is distributed on an "AS IS"
00015  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  * the License for the specific language governing rights and limitations
00017  * under the License.
00018  *
00019  * Contributor(s): ______________________________________.
00020  *
00021  * $Log: h281handler.h,v $
00022  * Revision 1.1  2006/06/22 11:07:22  shorne
00023  * Backport of FECC (H.224) from Opal
00024  *
00025  * Revision 1.2  2006/04/23 18:52:19  dsandras
00026  * Removed warnings when compiling with gcc on Linux.
00027  *
00028  * Revision 1.1  2006/04/20 16:48:17  hfriederich
00029  * Initial version of H.224/H.281 implementation.
00030  *
00031  */
00032 
00033 #ifndef __OPAL_H281HANDLER_H
00034 #define __OPAL_H281HANDLER_H
00035 
00036 #ifdef P_USE_PRAGMA
00037 #pragma interface
00038 #endif
00039 
00040 #include <ptlib.h>
00041 #include <h224handler.h>
00042 #include <h281.h>
00043 
00044 #ifdef _MSC_VER
00045 #pragma warning(disable : 4244)
00046 #endif
00047 
00048 class OpalH224Handler;
00049 
00053 class H281VideoSource : public PObject
00054 {
00055   PCLASSINFO(H281VideoSource, PObject);
00056 
00057 public:
00058         
00059   H281VideoSource();
00060   ~H281VideoSource();
00061         
00062   BOOL IsEnabled() const { return isEnabled; }
00063   void SetEnabled(BOOL flag) { isEnabled = flag; }
00064         
00065   BYTE GetVideoSourceNumber() const { return (firstOctet >> 4) & 0x0f; }
00066   void SetVideoSourceNumber(BYTE number);
00067         
00068   BOOL CanMotionVideo() const { return (firstOctet >> 2) & 0x01; }
00069   void SetCanMotionVideo(BOOL flag);
00070 
00071   BOOL CanNormalResolutionStillImage() const { return (firstOctet >> 1) & 0x01; }
00072   void SetCanNormalResolutionStillImage(BOOL flag);
00073 
00074   BOOL CanDoubleResolutionStillImage() const { return (firstOctet & 0x01); }
00075   void SetCanDoubleResolutionStillImage(BOOL flag);
00076 
00077   BOOL CanPan() const { return (secondOctet >> 7) & 0x01; }
00078   void SetCanPan(BOOL flag);
00079         
00080   BOOL CanTilt() const { return (secondOctet >> 6) & 0x01; }
00081   void SetCanTilt(BOOL flag);
00082         
00083   BOOL CanZoom() const { return (secondOctet >> 5) & 0x01; }
00084   void SetCanZoom(BOOL flag);
00085         
00086   BOOL CanFocus() const { return (secondOctet >> 4) & 0x01; }
00087   void SetCanFocus(BOOL flag);
00088         
00089   void Encode(BYTE *data) const;
00090   BOOL Decode(const BYTE *data);
00091         
00092 protected:
00093         
00094   BOOL isEnabled;
00095   BYTE firstOctet;
00096   BYTE secondOctet;
00097         
00098 };
00099 
00102 class OpalH281Handler : public PObject
00103 {
00104   PCLASSINFO(OpalH281Handler, PObject);
00105         
00106 public:
00107         
00108   OpalH281Handler(OpalH224Handler & h224Handler);
00109   ~OpalH281Handler();
00110         
00111   enum VideoSource {
00112     CurrentVideoSource          = 0x00,
00113         MainCamera                              = 0x01,
00114         AuxiliaryCamera                 = 0x02,
00115         DocumentCamera                  = 0x03,
00116         AuxiliaryDocumentCamera = 0x04,
00117         VideoPlaybackSource             = 0x05
00118   };
00119         
00120   BOOL GetRemoteHasH281() const { return remoteHasH281; }
00121   void SetRemoteHasH281(BOOL flag) { remoteHasH281 = flag; }
00122         
00123   BYTE GetLocalNumberOfPresets() const { return localNumberOfPresets; }
00124   void SetLocalNumberOfPresets(BYTE presets) { localNumberOfPresets = presets; }
00125         
00126   BYTE GetRemoteNumberOfPresets() const { return remoteNumberOfPresets; }
00127         
00128   H281VideoSource & GetLocalVideoSource(VideoSource source);
00129   H281VideoSource & GetRemoteVideoSource(VideoSource source);
00130         
00134   void StartAction(H281_Frame::PanDirection panDirection,
00135                                    H281_Frame::TiltDirection tiltDirection,
00136                                    H281_Frame::ZoomDirection zoomDireciton,
00137                                H281_Frame::FocusDirection focusDirection);
00138   
00141   void StopAction();
00142 
00147   void SelectVideoSource(BYTE videoSourceNumber, H281_Frame::VideoMode videoMode);
00148   
00152   void StoreAsPreset(BYTE presetNumber);
00153   
00156   void ActivatePreset(BYTE presetNumber);
00157         
00163   void SendExtraCapabilities() const;
00164         
00167   void OnReceivedExtraCapabilities(const BYTE *capabilities, PINDEX size);
00168   void OnReceivedMessage(const H281_Frame & message);
00169         
00170   /*
00171    * methods that subclasses can override.
00172    * The default handler does not implement FECC on the local side.
00173    * Thus, the default behaviour is to do nothing.
00174    */
00175         
00178   virtual void OnRemoteCapabilitiesUpdated();
00179         
00182   virtual void OnStartAction(H281_Frame::PanDirection panDirection,
00183                                                          H281_Frame::TiltDirection tiltDirection,
00184                                                          H281_Frame::ZoomDirection zoomDirection,
00185                                                          H281_Frame::FocusDirection focusDirection);
00186         
00189   virtual void OnStopAction();
00190         
00193   virtual void OnSelectVideoSource(BYTE videoSourceNumber, H281_Frame::VideoMode videoMode);
00194         
00197   virtual void OnStoreAsPreset(BYTE presetNumber);
00198 
00201   virtual void OnActivatePreset(BYTE presetNumber);
00202         
00203 protected:
00204                 
00205   PDECLARE_NOTIFIER(PTimer, OpalH281Handler, ContinueAction);
00206   PDECLARE_NOTIFIER(PTimer, OpalH281Handler, StopActionLocally);
00207         
00208   OpalH224Handler & h224Handler;
00209   BOOL remoteHasH281;
00210   BYTE localNumberOfPresets;
00211   BYTE remoteNumberOfPresets;
00212   H281VideoSource localVideoSources[6];
00213   H281VideoSource remoteVideoSources[6];
00214         
00215   H281_Frame transmitFrame;
00216   PTimer transmitTimer;
00217 
00218   H281_Frame::PanDirection requestedPanDirection;
00219   H281_Frame::TiltDirection requestedTiltDirection;
00220   H281_Frame::ZoomDirection requestedZoomDirection;
00221   H281_Frame::FocusDirection requestedFocusDirection;
00222   PTimer receiveTimer;
00223 };
00224 
00225 #endif // __OPAL_H281HANDLER_H
00226 

Generated on Wed Feb 6 09:02:38 2008 for OpenH323 by  doxygen 1.5.4