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.3  2007/04/19 06:17:20  csoutheren
00023  * Fixes for precompiled headers with gcc
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 #ifndef _PTLIB_H
00041 #include <ptlib.h>
00042 #endif
00043 
00044 #include <h224/h224handler.h>
00045 #include <h224/h281.h>
00046 
00047 class OpalH224Handler;
00048 
00052 class H281VideoSource : public PObject
00053 {
00054   PCLASSINFO(H281VideoSource, PObject);
00055 
00056 public:
00057         
00058   H281VideoSource();
00059   ~H281VideoSource();
00060         
00061   BOOL IsEnabled() const { return isEnabled; }
00062   void SetEnabled(BOOL flag) { isEnabled = flag; }
00063         
00064   BYTE GetVideoSourceNumber() const { return (firstOctet >> 4) & 0x0f; }
00065   void SetVideoSourceNumber(BYTE number);
00066         
00067   BOOL CanMotionVideo() const { return (firstOctet >> 2) & 0x01; }
00068   void SetCanMotionVideo(BOOL flag);
00069 
00070   BOOL CanNormalResolutionStillImage() const { return (firstOctet >> 1) & 0x01; }
00071   void SetCanNormalResolutionStillImage(BOOL flag);
00072 
00073   BOOL CanDoubleResolutionStillImage() const { return (firstOctet & 0x01); }
00074   void SetCanDoubleResolutionStillImage(BOOL flag);
00075 
00076   BOOL CanPan() const { return (secondOctet >> 7) & 0x01; }
00077   void SetCanPan(BOOL flag);
00078         
00079   BOOL CanTilt() const { return (secondOctet >> 6) & 0x01; }
00080   void SetCanTilt(BOOL flag);
00081         
00082   BOOL CanZoom() const { return (secondOctet >> 5) & 0x01; }
00083   void SetCanZoom(BOOL flag);
00084         
00085   BOOL CanFocus() const { return (secondOctet >> 4) & 0x01; }
00086   void SetCanFocus(BOOL flag);
00087         
00088   void Encode(BYTE *data) const;
00089   BOOL Decode(const BYTE *data);
00090         
00091 protected:
00092         
00093   BOOL isEnabled;
00094   BYTE firstOctet;
00095   BYTE secondOctet;
00096         
00097 };
00098 
00101 class OpalH281Handler : public PObject
00102 {
00103   PCLASSINFO(OpalH281Handler, PObject);
00104         
00105 public:
00106         
00107   OpalH281Handler(OpalH224Handler & h224Handler);
00108   ~OpalH281Handler();
00109         
00110   enum VideoSource {
00111     CurrentVideoSource          = 0x00,
00112         MainCamera                              = 0x01,
00113         AuxiliaryCamera                 = 0x02,
00114         DocumentCamera                  = 0x03,
00115         AuxiliaryDocumentCamera = 0x04,
00116         VideoPlaybackSource             = 0x05
00117   };
00118         
00119   BOOL GetRemoteHasH281() const { return remoteHasH281; }
00120   void SetRemoteHasH281(BOOL flag) { remoteHasH281 = flag; }
00121         
00122   BYTE GetLocalNumberOfPresets() const { return localNumberOfPresets; }
00123   void SetLocalNumberOfPresets(BYTE presets) { localNumberOfPresets = presets; }
00124         
00125   BYTE GetRemoteNumberOfPresets() const { return remoteNumberOfPresets; }
00126         
00127   H281VideoSource & GetLocalVideoSource(VideoSource source);
00128   H281VideoSource & GetRemoteVideoSource(VideoSource source);
00129         
00133   void StartAction(H281_Frame::PanDirection panDirection,
00134                                    H281_Frame::TiltDirection tiltDirection,
00135                                    H281_Frame::ZoomDirection zoomDireciton,
00136                                H281_Frame::FocusDirection focusDirection);
00137   
00140   void StopAction();
00141 
00146   void SelectVideoSource(BYTE videoSourceNumber, H281_Frame::VideoMode videoMode);
00147   
00151   void StoreAsPreset(BYTE presetNumber);
00152   
00155   void ActivatePreset(BYTE presetNumber);
00156         
00162   void SendExtraCapabilities() const;
00163         
00166   void OnReceivedExtraCapabilities(const BYTE *capabilities, PINDEX size);
00167   void OnReceivedMessage(const H281_Frame & message);
00168         
00169   /*
00170    * methods that subclasses can override.
00171    * The default handler does not implement FECC on the local side.
00172    * Thus, the default behaviour is to do nothing.
00173    */
00174         
00177   virtual void OnRemoteCapabilitiesUpdated();
00178         
00181   virtual void OnStartAction(H281_Frame::PanDirection panDirection,
00182                                                          H281_Frame::TiltDirection tiltDirection,
00183                                                          H281_Frame::ZoomDirection zoomDirection,
00184                                                          H281_Frame::FocusDirection focusDirection);
00185         
00188   virtual void OnStopAction();
00189         
00192   virtual void OnSelectVideoSource(BYTE videoSourceNumber, H281_Frame::VideoMode videoMode);
00193         
00196   virtual void OnStoreAsPreset(BYTE presetNumber);
00197 
00200   virtual void OnActivatePreset(BYTE presetNumber);
00201         
00202 protected:
00203                 
00204   PDECLARE_NOTIFIER(PTimer, OpalH281Handler, ContinueAction);
00205   PDECLARE_NOTIFIER(PTimer, OpalH281Handler, StopActionLocally);
00206         
00207   OpalH224Handler & h224Handler;
00208   BOOL remoteHasH281;
00209   BYTE localNumberOfPresets;
00210   BYTE remoteNumberOfPresets;
00211   H281VideoSource localVideoSources[6];
00212   H281VideoSource remoteVideoSources[6];
00213         
00214   H281_Frame transmitFrame;
00215   PTimer transmitTimer;
00216 
00217   H281_Frame::PanDirection requestedPanDirection;
00218   H281_Frame::TiltDirection requestedTiltDirection;
00219   H281_Frame::ZoomDirection requestedZoomDirection;
00220   H281_Frame::FocusDirection requestedFocusDirection;
00221   PTimer receiveTimer;
00222 };
00223 
00224 #endif // __OPAL_H281HANDLER_H
00225 

Generated on Fri Mar 7 06:33:31 2008 for OPAL by  doxygen 1.5.1