D:/Storage/CVS_Head/h323plus/include/h281handler.h

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  2007/08/06 20:50:49  shorne
00023  * First commit of h323plus
00024  *
00025  * Revision 1.1  2006/06/22 11:07:22  shorne
00026  * Backport of FECC (H.224) from Opal
00027  *
00028  * Revision 1.2  2006/04/23 18:52:19  dsandras
00029  * Removed warnings when compiling with gcc on Linux.
00030  *
00031  * Revision 1.1  2006/04/20 16:48:17  hfriederich
00032  * Initial version of H.224/H.281 implementation.
00033  *
00034  */
00035 
00036 #ifndef __OPAL_H281HANDLER_H
00037 #define __OPAL_H281HANDLER_H
00038 
00039 #ifdef P_USE_PRAGMA
00040 #pragma interface
00041 #endif
00042 
00043 #include <ptlib.h>
00044 #include <h224handler.h>
00045 #include <h281.h>
00046 
00047 #ifdef _MSC_VER
00048 #pragma warning(disable : 4244)
00049 #endif
00050 
00051 class OpalH224Handler;
00052 
00056 class H281VideoSource : public PObject
00057 {
00058   PCLASSINFO(H281VideoSource, PObject);
00059 
00060 public:
00061         
00062   H281VideoSource();
00063   ~H281VideoSource();
00064         
00065   BOOL IsEnabled() const { return isEnabled; }
00066   void SetEnabled(BOOL flag) { isEnabled = flag; }
00067         
00068   BYTE GetVideoSourceNumber() const { return (firstOctet >> 4) & 0x0f; }
00069   void SetVideoSourceNumber(BYTE number);
00070         
00071   BOOL CanMotionVideo() const { return (firstOctet >> 2) & 0x01; }
00072   void SetCanMotionVideo(BOOL flag);
00073 
00074   BOOL CanNormalResolutionStillImage() const { return (firstOctet >> 1) & 0x01; }
00075   void SetCanNormalResolutionStillImage(BOOL flag);
00076 
00077   BOOL CanDoubleResolutionStillImage() const { return (firstOctet & 0x01); }
00078   void SetCanDoubleResolutionStillImage(BOOL flag);
00079 
00080   BOOL CanPan() const { return (secondOctet >> 7) & 0x01; }
00081   void SetCanPan(BOOL flag);
00082         
00083   BOOL CanTilt() const { return (secondOctet >> 6) & 0x01; }
00084   void SetCanTilt(BOOL flag);
00085         
00086   BOOL CanZoom() const { return (secondOctet >> 5) & 0x01; }
00087   void SetCanZoom(BOOL flag);
00088         
00089   BOOL CanFocus() const { return (secondOctet >> 4) & 0x01; }
00090   void SetCanFocus(BOOL flag);
00091         
00092   void Encode(BYTE *data) const;
00093   BOOL Decode(const BYTE *data);
00094         
00095 protected:
00096         
00097   BOOL isEnabled;
00098   BYTE firstOctet;
00099   BYTE secondOctet;
00100         
00101 };
00102 
00105 class OpalH281Handler : public PObject
00106 {
00107   PCLASSINFO(OpalH281Handler, PObject);
00108         
00109 public:
00110         
00111   OpalH281Handler(OpalH224Handler & h224Handler);
00112   ~OpalH281Handler();
00113         
00114   enum VideoSource {
00115     CurrentVideoSource          = 0x00,
00116         MainCamera                              = 0x01,
00117         AuxiliaryCamera                 = 0x02,
00118         DocumentCamera                  = 0x03,
00119         AuxiliaryDocumentCamera = 0x04,
00120         VideoPlaybackSource             = 0x05
00121   };
00122         
00123   BOOL GetRemoteHasH281() const { return remoteHasH281; }
00124   void SetRemoteHasH281(BOOL flag) { remoteHasH281 = flag; }
00125         
00126   BYTE GetLocalNumberOfPresets() const { return localNumberOfPresets; }
00127   void SetLocalNumberOfPresets(BYTE presets) { localNumberOfPresets = presets; }
00128         
00129   BYTE GetRemoteNumberOfPresets() const { return remoteNumberOfPresets; }
00130         
00131   H281VideoSource & GetLocalVideoSource(VideoSource source);
00132   H281VideoSource & GetRemoteVideoSource(VideoSource source);
00133         
00137   void StartAction(H281_Frame::PanDirection panDirection,
00138                                    H281_Frame::TiltDirection tiltDirection,
00139                                    H281_Frame::ZoomDirection zoomDireciton,
00140                                H281_Frame::FocusDirection focusDirection);
00141   
00144   void StopAction();
00145 
00150   void SelectVideoSource(BYTE videoSourceNumber, H281_Frame::VideoMode videoMode);
00151   
00155   void StoreAsPreset(BYTE presetNumber);
00156   
00159   void ActivatePreset(BYTE presetNumber);
00160         
00166   void SendExtraCapabilities() const;
00167         
00170   void OnReceivedExtraCapabilities(const BYTE *capabilities, PINDEX size);
00171   void OnReceivedMessage(const H281_Frame & message);
00172         
00173   /*
00174    * methods that subclasses can override.
00175    * The default handler does not implement FECC on the local side.
00176    * Thus, the default behaviour is to do nothing.
00177    */
00178         
00181   virtual void OnRemoteCapabilitiesUpdated();
00182         
00185   virtual void OnStartAction(H281_Frame::PanDirection panDirection,
00186                                                          H281_Frame::TiltDirection tiltDirection,
00187                                                          H281_Frame::ZoomDirection zoomDirection,
00188                                                          H281_Frame::FocusDirection focusDirection);
00189         
00192   virtual void OnStopAction();
00193         
00196   virtual void OnSelectVideoSource(BYTE videoSourceNumber, H281_Frame::VideoMode videoMode);
00197         
00200   virtual void OnStoreAsPreset(BYTE presetNumber);
00201 
00204   virtual void OnActivatePreset(BYTE presetNumber);
00205         
00206 protected:
00207                 
00208   PDECLARE_NOTIFIER(PTimer, OpalH281Handler, ContinueAction);
00209   PDECLARE_NOTIFIER(PTimer, OpalH281Handler, StopActionLocally);
00210         
00211   OpalH224Handler & h224Handler;
00212   BOOL remoteHasH281;
00213   BYTE localNumberOfPresets;
00214   BYTE remoteNumberOfPresets;
00215   H281VideoSource localVideoSources[6];
00216   H281VideoSource remoteVideoSources[6];
00217         
00218   H281_Frame transmitFrame;
00219   PTimer transmitTimer;
00220 
00221   H281_Frame::PanDirection requestedPanDirection;
00222   H281_Frame::TiltDirection requestedTiltDirection;
00223   H281_Frame::ZoomDirection requestedZoomDirection;
00224   H281_Frame::FocusDirection requestedFocusDirection;
00225   PTimer receiveTimer;
00226 };
00227 
00228 #endif // __OPAL_H281HANDLER_H
00229 

Generated on Thu Oct 25 13:42:25 2007 for h323plus by  doxygen 1.5.2